+
diff --git a/src/components/notice/index.js b/src/components/notice/index.js
index 13927748..d6104d60 100644
--- a/src/components/notice/index.js
+++ b/src/components/notice/index.js
@@ -71,7 +71,8 @@ function notice (type, options) {
transitionName: 'move-notice',
content: content,
onClose: onClose,
- closable: true
+ closable: true,
+ type: 'notice'
});
}
diff --git a/src/components/page/options.vue b/src/components/page/options.vue
index ead5b4ea..490bfc2f 100644
--- a/src/components/page/options.vue
+++ b/src/components/page/options.vue
@@ -1,7 +1,7 @@
-
+
{{ item }} {{ t('i.page.page') }}
@@ -35,7 +35,8 @@
_current: Number,
pageSize: Number,
allPages: Number,
- isSmall: Boolean
+ isSmall: Boolean,
+ placement: String
},
data () {
return {
diff --git a/src/components/page/page.vue b/src/components/page/page.vue
index 2262a6df..65c8270d 100644
--- a/src/components/page/page.vue
+++ b/src/components/page/page.vue
@@ -52,6 +52,7 @@
:show-sizer="showSizer"
:page-size="currentPageSize"
:page-size-opts="pageSizeOpts"
+ :placement="placement"
:show-elevator="showElevator"
:_current.once="currentPage"
:current="currentPage"
@@ -92,6 +93,12 @@
return [10, 20, 30, 40];
}
},
+ placement: {
+ validator (value) {
+ return oneOf(value, ['top', 'bottom']);
+ },
+ default: 'bottom'
+ },
size: {
validator (value) {
return oneOf(value, ['small']);
@@ -236,8 +243,8 @@
},
onSize (pageSize) {
this.currentPageSize = pageSize;
- this.changePage(1);
this.$emit('on-page-size-change', pageSize);
+ this.changePage(1);
},
onPage (page) {
this.changePage(page);
diff --git a/src/components/radio/radio.vue b/src/components/radio/radio.vue
index 37261629..d7513dac 100644
--- a/src/components/radio/radio.vue
+++ b/src/components/radio/radio.vue
@@ -71,6 +71,8 @@
if (this.parent) this.group = true;
if (!this.group) {
this.updateValue();
+ } else {
+ this.parent.updateValue();
}
},
methods: {
diff --git a/src/components/select/select.vue b/src/components/select/select.vue
index f611d08d..3c258165 100644
--- a/src/components/select/select.vue
+++ b/src/components/select/select.vue
@@ -22,12 +22,13 @@
@keydown.delete="handleInputDelete"
ref="input">
-
+
-
-
-
-
+
+
+
+
+
@@ -52,6 +53,10 @@
type: [String, Number, Array],
default: ''
},
+ label: {
+ type: [String, Number, Array],
+ default: ''
+ },
multiple: {
type: Boolean,
default: false
@@ -74,6 +79,20 @@
filterMethod: {
type: Function
},
+ remote: {
+ type: Boolean,
+ default: false
+ },
+ remoteMethod: {
+ type: Function
+ },
+ loading: {
+ type: Boolean,
+ default: false
+ },
+ loadingText: {
+ type: String
+ },
size: {
validator (value) {
return oneOf(value, ['small', 'large', 'default']);
@@ -85,6 +104,12 @@
},
notFoundText: {
type: String
+ },
+ placement: {
+ validator (value) {
+ return oneOf(value, ['top', 'bottom']);
+ },
+ default: 'bottom'
}
},
data () {
@@ -97,10 +122,13 @@
selectedMultiple: [],
focusIndex: 0,
query: '',
+ lastQuery: '',
+ selectToChangeQuery: false, // when select an option, set this first and set query, because query is watching, it will emit event
inputLength: 20,
notFound: false,
slotChangeDuration: false, // if slot change duration and in multiple, set true and after slot change, set false
- model: this.value
+ model: this.value,
+ currentLabel: this.label
};
},
computed: {
@@ -128,6 +156,8 @@
if (!this.model.length) {
status = true;
}
+ } else if( this.model === null){
+ status = true;
}
return status;
@@ -161,6 +191,26 @@
} else {
return this.notFoundText;
}
+ },
+ localeLoadingText () {
+ if (this.loadingText === undefined) {
+ return this.t('i.select.loading');
+ } else {
+ return this.loadingText;
+ }
+ },
+ transitionName () {
+ return this.placement === 'bottom' ? 'slide-up' : 'slide-down';
+ },
+ dropVisible () {
+ let status = true;
+ const options = this.$slots.default || [];
+ if (!this.loading && this.remote && this.query === '' && !options.length) status = false;
+ return this.visible && status;
+ },
+ notFountShow () {
+ const options = this.$slots.default || [];
+ return (this.notFound && !this.remote) || (this.remote && !this.loading && !options.length);
}
},
methods: {
@@ -168,7 +218,6 @@
if (this.disabled) {
return false;
}
-
this.visible = !this.visible;
},
hideMenu () {
@@ -219,8 +268,10 @@
this.options = options;
if (init) {
- this.updateSingleSelected(true, slot);
- this.updateMultipleSelected(true, slot);
+ if (!this.remote) {
+ this.updateSingleSelected(true, slot);
+ this.updateMultipleSelected(true, slot);
+ }
}
},
updateSingleSelected (init = false, slot = false) {
@@ -259,7 +310,7 @@
},
updateMultipleSelected (init = false, slot = false) {
if (this.multiple && Array.isArray(this.model)) {
- let selected = [];
+ let selected = this.remote ? this.selectedMultiple : [];
for (let i = 0; i < this.model.length; i++) {
const model = this.model[i];
@@ -276,7 +327,16 @@
}
}
- this.selectedMultiple = selected;
+ const selectedArray = [];
+ const selectedObject = {};
+ selected.forEach(item => {
+ if (!selectedObject[item.value]) {
+ selectedArray.push(item);
+ selectedObject[item.value] = 1;
+ }
+ });
+
+ this.selectedMultiple = this.remote ? selectedArray : selected;
if (slot) {
let selectedModel = [];
@@ -299,6 +359,12 @@
if (this.disabled) {
return false;
}
+
+ if (this.remote) {
+ const tag = this.model[index];
+ this.selectedMultiple = this.selectedMultiple.filter(item => item.value !== tag);
+ }
+
this.model.splice(index, 1);
if (this.filterable && this.visible) {
@@ -469,6 +535,12 @@
this.query = child.label === undefined ? child.searchLabel : child.label;
}
});
+ // 如果删除了搜索词,下拉列表也清空了,所以强制调用一次remoteMethod
+ if (this.remote && this.query !== this.lastQuery) {
+ this.$nextTick(() => {
+ this.query = this.lastQuery;
+ });
+ }
} else {
this.query = '';
}
@@ -518,6 +590,23 @@
},
mounted () {
this.modelToQuery();
+ // 处理 remote 初始值
+ if (this.remote) {
+ if (!this.multiple && this.model !== '') {
+ this.selectToChangeQuery = true;
+ if (this.currentLabel === '') this.currentLabel = this.model;
+ this.lastQuery = this.currentLabel;
+ this.query = this.currentLabel;
+ } else if (this.multiple && this.model.length) {
+ if (this.currentLabel.length !== this.model.length) this.currentLabel = this.model;
+ this.selectedMultiple = this.model.map((item, index) => {
+ return {
+ value: item,
+ label: this.currentLabel[index]
+ };
+ });
+ }
+ }
this.$nextTick(() => {
this.broadcastQuery('');
});
@@ -526,12 +615,30 @@
document.addEventListener('keydown', this.handleKeydown);
this.$on('append', () => {
- this.modelToQuery();
+ if (!this.remote) {
+ this.modelToQuery();
+ this.$nextTick(() => {
+ this.broadcastQuery('');
+ });
+ } else {
+ this.findChild(child => {
+ child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
+ });
+ }
this.slotChange();
this.updateOptions(true, true);
});
this.$on('remove', () => {
- this.modelToQuery();
+ if (!this.remote) {
+ this.modelToQuery();
+ this.$nextTick(() => {
+ this.broadcastQuery('');
+ });
+ } else {
+ this.findChild(child => {
+ child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
+ });
+ }
this.slotChange();
this.updateOptions(true, true);
});
@@ -550,6 +657,8 @@
}
if (this.filterable) {
+ // remote&filterable&multiple时,一次点多项,不应该设置true,因为无法置为false,下次的搜索会失效
+ if (this.query !== '') this.selectToChangeQuery = true;
this.query = '';
this.$refs.input.focus();
}
@@ -559,7 +668,8 @@
if (this.filterable) {
this.findChild((child) => {
if (child.value === value) {
- this.query = child.label === undefined ? child.searchLabel : child.label;
+ if (this.query !== '') this.selectToChangeQuery = true;
+ this.lastQuery = this.query = child.label === undefined ? child.searchLabel : child.label;
}
});
}
@@ -587,6 +697,12 @@
} else {
this.updateSingleSelected();
}
+ // #957
+ if (!this.visible && this.filterable) {
+ this.$nextTick(() => {
+ this.broadcastQuery('');
+ });
+ }
},
visible (val) {
if (val) {
@@ -596,6 +712,16 @@
} else {
this.$refs.input.select();
}
+ if (this.remote) {
+ this.findChild(child => {
+ child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
+ });
+ // remote下,设置了默认值,第一次打开时,搜索一次
+ const options = this.$slots.default || [];
+ if (this.query !== '' && !options.length) {
+ this.remoteMethod(this.query);
+ }
+ }
}
this.broadcast('Drop', 'on-update-popper');
} else {
@@ -610,20 +736,33 @@
}
},
query (val) {
- this.$emit('on-query-change', val);
-
- this.broadcastQuery(val);
-
- let is_hidden = true;
-
- this.$nextTick(() => {
- this.findChild((child) => {
- if (!child.hidden) {
- is_hidden = false;
- }
+ if (this.remote && this.remoteMethod) {
+ if (!this.selectToChangeQuery) {
+ this.$emit('on-query-change', val);
+ this.remoteMethod(val);
+ }
+ this.focusIndex = 0;
+ this.findChild(child => {
+ child.isFocus = false;
});
- this.notFound = is_hidden;
- });
+ } else {
+ if (!this.selectToChangeQuery) {
+ this.$emit('on-query-change', val);
+ }
+ this.broadcastQuery(val);
+
+ let is_hidden = true;
+
+ this.$nextTick(() => {
+ this.findChild((child) => {
+ if (!child.hidden) {
+ is_hidden = false;
+ }
+ });
+ this.notFound = is_hidden;
+ });
+ }
+ this.selectToChangeQuery = false;
this.broadcast('Drop', 'on-update-popper');
}
}
diff --git a/src/components/table/cell.vue b/src/components/table/cell.vue
index 94bcfb44..50f5a3b3 100644
--- a/src/components/table/cell.vue
+++ b/src/components/table/cell.vue
@@ -5,15 +5,22 @@
+
+
+
+
+