修改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 closable
@close="handleClose" @close="handleClose"
> >
{{ (column.config.instanceKey&&ctx?.[column.config.instanceKey]?.[column.config.nameKey])||value }} {{
showValue
}}
</el-tag> </el-tag>
<el-button @click="showSelect" size="small">选择</el-button> <el-button @click="showSelect" size="small">选择</el-button>
</div> </div>
@ -59,12 +61,25 @@ const handleClose = () => {
value.value = null 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 = () => { const handleTempClose = () => {
tempValue.value = null tempValue.value = null
} }
const value = computed({ const value = computed({
get() { get() {
console.log(props.ctx,'ctx') console.log(props.ctx, 'ctx')
return props.modelValue; return props.modelValue;
}, },
set(newVal) { set(newVal) {