|
@@ -41,10 +41,7 @@ export default {
|
|
|
clearable: { type: Boolean, default: true },
|
|
|
multiple: { type: Boolean, default: false },
|
|
|
datas: {
|
|
|
- type: Array,
|
|
|
- default() {
|
|
|
- return [];
|
|
|
- }
|
|
|
+ type: Array
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
@@ -61,21 +58,23 @@ export default {
|
|
|
handler(val) {
|
|
|
this.selected = val;
|
|
|
}
|
|
|
+ },
|
|
|
+ datas: {
|
|
|
+ immediate: true,
|
|
|
+ handler(val) {
|
|
|
+ if (!val) return;
|
|
|
+ this.optionList = val.map(item => {
|
|
|
+ return { ...item };
|
|
|
+ });
|
|
|
+ this.labelChange();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.search();
|
|
|
+ if (!this.datas) this.search();
|
|
|
},
|
|
|
methods: {
|
|
|
async search() {
|
|
|
- if (this.datas && this.datas.length) {
|
|
|
- this.optionList = this.datas.map(item => {
|
|
|
- return { ...item };
|
|
|
- });
|
|
|
- this.labelChange();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
const res = await clazzQuery();
|
|
|
this.optionList = res || [];
|
|
|
this.labelChange();
|