修改foreignInput组件

This commit is contained in:
wcq 2023-12-11 16:17:01 +08:00
parent ef520c2843
commit 50bd12318c
1 changed files with 17 additions and 2 deletions

View File

@ -8,7 +8,9 @@
closable
@close="handleClose"
>
{{ (column.config.instanceKey&&ctx?.[column.config.instanceKey]?.[column.config.nameKey])||value }}
{{
showValue
}}
</el-tag>
<el-button @click="showSelect" size="small">选择</el-button>
</div>
@ -59,6 +61,19 @@ const handleClose = () => {
value.value = null
}
function getValueByNameKey(data, nameKey) {
return data ? (typeof nameKey === "string" ? data[nameKey] : nameKey.map(key => [tempValue[key]]).join("-")) : ''
}
const showValue = computed(() => {
const nameKey = props.column.config.nameKey
//
const val1 = getValueByNameKey(props.column.config.instanceKey && props.ctx?.[props.column.config.instanceKey], nameKey)
//
const val2 = getValueByNameKey(tempValue.value, nameKey)
return val2 || (value.value ? (val1 || value.value) : value.value)
})
const handleTempClose = () => {
tempValue.value = null
}