Skip to content

Commit

Permalink
xcui suggestion (wmfe#206)
Browse files Browse the repository at this point in the history
sug/upload/datepicker
  • Loading branch information
LNoe-lzy authored and clancyz committed Jan 3, 2018
1 parent c0bb1c1 commit d7bd633
Show file tree
Hide file tree
Showing 11 changed files with 400 additions and 327 deletions.
3 changes: 2 additions & 1 deletion demos/components/suggestion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@
|wait|Number|500|触发远程请求时的防抖动延迟时间|可选||
|allowClear|Boolean|true|是否允许出现清除图标|可选|true, false|
|matchInput|Boolean|true|是否根据输入在客户端匹配建议列表|可选|true, false|
|matchInputTime|Number|300|是否根据输入在客户端匹配建议列表的延迟时间|可选||
|matchCase|Boolean|false|是否严格匹配输入大小写,matchInput为true时有效|可选|true, false|
|localCache|Boolean|true|是否在组件内设置缓存池,localCache为true时有效|可选|true, false|

## Events

Expand Down Expand Up @@ -184,7 +186,6 @@
},
methods: {
request() {
// console.log('request');
const v = this.state3.text;
this.sug3 = !v ? [] : [
{text: v, value: 1},
Expand Down
2 changes: 2 additions & 0 deletions demos/components/upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@
|on-success|Function|无|文件上传成功时的钩子, 返回服务端数据|可选|response, file, fileList|
|on-error|Function|无|文件上传失败时的钩子, 返回错误|可选|err, file, fileList|
|on-remove|Function|无|文件列表移除文件时的钩子,支持返回promise做删除前确认|可选|file, fileList|
|hide-upload-btn|Boolean|false|是否显示上传按钮|可选|true, false|
|hide-remove-btn|Boolean|false|是否显示删除按钮|可选|true, false|

## Methods
| 名字 |描述 | 参数 |调用方式|
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/date-picker/src/panel/date-range.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<button
type="button"
@click="prevYear"
class="x-picker-panel-icon-btn x-icon x-icon-chevron-d-left"></button>
class="x-picker-panel-icon-btn x-icon x-icon-chevron-left"></button>
<button
type="button"
@click="prevMonth"
Expand All @@ -109,7 +109,7 @@
<button
type="button"
@click="nextYear"
class="x-picker-panel-icon-btn x-icon x-icon-chevron-d-right"></button>
class="x-picker-panel-icon-btn x-icon x-icon-chevron-right"></button>
<button
type="button"
@click="nextMonth"
Expand Down
6 changes: 4 additions & 2 deletions src/components/date-picker/src/panel/date.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
<button
type="button"
@click="prevYear"
class="x-picker-panel-icon-btn x-date-picker-prev-btn x-icon x-icon-chevron-d-left">
v-show="currentView === 'year'"
class="x-picker-panel-icon-btn x-date-picker-prev-btn x-icon x-icon-chevron-left">
</button>
<button
type="button"
Expand All @@ -68,7 +69,8 @@
<button
type="button"
@click="nextYear"
class="x-picker-panel-icon-btn x-date-picker-next-btn x-icon x-icon-chevron-d-right">
v-show="currentView === 'year'"
class="x-picker-panel-icon-btn x-date-picker-next-btn x-icon x-icon-chevron-right">
</button>
<button
type="button"
Expand Down
36 changes: 21 additions & 15 deletions src/components/suggestion/src/suggestion-dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
<transition name="x-slide-up" @after-leave="doDestroy">
<div class="x-suggestion-dropdown"
v-show="showPopper"
:style="{width: dropdownWidth}">
:style="{width: dropdownWidth}"
>
<ul class="x-suggestion-list" ref="sugList">
<li v-for="(item,index) in suggestions" class="x-suggestion-item" :class="{'active' : $parent.currentIndex==index}" @click="setItem(item)">
{{item.text}}
<li v-for="(item,index) in list" class="x-suggestion-item" :class="{'active' : $parent.currentIndex==index}" @click="setItem(item)">
{{item.nomatch ? '未匹配:' : item.text}}
<span v-if="item.nomatch" class="x-suggestion-nomatch">{{item.text}}</span>
</li>
</ul>
</div>
Expand Down Expand Up @@ -40,20 +42,10 @@
data() {
return {
showPopper: false,
dropdownWidth: null
dropdownWidth: null,
list: [],
};
},
methods: {
setItem(item) {
this.dispatch('xSuggestion', 'item-click', item);
}
},
created() {
this.$on('visible', (val, inputWidth) => {
this.dropdownWidth = inputWidth + 'px';
this.showPopper = val;
});
},
mounted() {
this.referenceElm = this.$parent.$refs.xInput.$refs.input;
this.popperElm = this.$el;
Expand All @@ -62,6 +54,20 @@
this.$nextTick(() => {
this.updatePopper();
});
},
methods: {
setItem(item) {
this.dispatch('xSuggestion', 'item-click', item);
},
handleShow(flag, inputWidth) {
this.showPopper = flag;
this.dropdownWidth = inputWidth + 'px';
}
},
watch: {
suggestions(val) {
this.list = val;
}
}
};
</script>
Loading

0 comments on commit d7bd633

Please sign in to comment.