|
|
|
@ -11,15 +11,6 @@ |
|
|
|
|
@clear="list = []" |
|
|
|
|
@change="change" |
|
|
|
|
> |
|
|
|
|
<!-- <template v-if="labelIsMore"> |
|
|
|
|
<el-option |
|
|
|
|
v-for="(item, index) in list" |
|
|
|
|
:key="item.id + index" |
|
|
|
|
:label="item[config.labelKey[0]] + '(' + item[config.labelKey[1]] + '-' + item[config.labelKey[2]] + ')'" |
|
|
|
|
:value="item[config.valueKey]" |
|
|
|
|
> |
|
|
|
|
</el-option> |
|
|
|
|
</template> --> |
|
|
|
|
<template> |
|
|
|
|
<el-option v-for="(item, index) in list" :key="index" :label="labelHandler(item)" :value="item[config.valueKey]"> </el-option> |
|
|
|
|
</template> |
|
|
|
@ -33,17 +24,17 @@ export default { |
|
|
|
|
config: Object |
|
|
|
|
// config: { |
|
|
|
|
// serveTarget: {}, // 远程搜索接口 |
|
|
|
|
// autocompleteKey: "", //远程搜索接口参数名 |
|
|
|
|
// labelKey: [] || '', //接口返回数据label |
|
|
|
|
// valueKey: "", //接口返回数据id |
|
|
|
|
// querykey: "", //查询接口参数名 |
|
|
|
|
// echoId:'', // |
|
|
|
|
// autocompleteKey: "" || {}, // 远程搜索接口参数名 |
|
|
|
|
// labelKey: "" || [], // 接口返回数据label |
|
|
|
|
// valueKey: "", // 接口返回数据id |
|
|
|
|
// querykey: "", // 查询接口参数名 |
|
|
|
|
// echoId: "", // 用于回显的id |
|
|
|
|
// echoName: "", // 用于回显的name |
|
|
|
|
// }, |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
text: '', |
|
|
|
|
// labelIsMore: false, |
|
|
|
|
list: [], |
|
|
|
|
isDisabled: false |
|
|
|
|
} |
|
|
|
@ -51,7 +42,6 @@ export default { |
|
|
|
|
watch: { |
|
|
|
|
'config.echoId': { |
|
|
|
|
handler(nval, oval) { |
|
|
|
|
console.log('nvalnvalnvalnvalnval', nval) |
|
|
|
|
this.list = [] |
|
|
|
|
let type = this.$utils.typeJudgment(this.config.echoName) |
|
|
|
|
if (nval && ['String'].includes(type)) { |
|
|
|
@ -77,11 +67,8 @@ export default { |
|
|
|
|
created() { |
|
|
|
|
let { labelKey } = this.config |
|
|
|
|
let type = this.$utils.typeJudgment(labelKey) |
|
|
|
|
// if (type === 'Array') { |
|
|
|
|
// this.labelIsMore = true |
|
|
|
|
// } |
|
|
|
|
// 重构labelHandler |
|
|
|
|
this.labelHandler = this.labelHandler(type) |
|
|
|
|
// console.log(this.labelHandler()) |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
labelHandler(type) { |
|
|
|
@ -99,7 +86,6 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 远程搜索 |
|
|
|
|
remoteMethod(query) { |
|
|
|
|
console.log('query', query) |
|
|
|
|
if (query !== '') { |
|
|
|
|
this.loading = true |
|
|
|
|
let type = this.$utils.typeJudgment(this.config.autocompleteKey) |
|
|
|
|