修复 产品回显问题

This commit is contained in:
YuanFeng 2024-10-09 20:52:39 +08:00
parent 932fbf9015
commit 5e13575dd3
4 changed files with 84 additions and 58 deletions

View File

@ -109,7 +109,7 @@ const dialogTitle = ref('设计稿件') // 弹窗的标题
const props = defineProps({
modelValue: {
type: String,
type: [String,Number],
required: true
},
dataKey: {
@ -165,23 +165,11 @@ const viewDetails = () => {
openDialog();
}
}
//
const tmp = computed(()=>{
setTimeout(()=>{
that.inputVal = toStr(props.modelValue,that.inputVal)
if (that.inputVal) {
initInput();
}
},100)
return ''
},{
deep: true
})
const toStr = (data: any) => {
const toStr = (data: any,def = '') => {
if (data !== null && data !== undefined) {
return `${data}`
}
return data
return def
}
let map = new Map();
const initInput = async () => {
@ -211,9 +199,31 @@ const initInput = async () => {
showValue: that.showValue
})
}
//
const tmp = computed(()=>{
setTimeout(()=>{
that.inputVal = toStr(props.modelValue,that.inputVal)
if (that.inputVal) {
initInput();
}
},100)
return ''
},{
deep: true
})
watch(() => props.visible, (newVal) => {
that.visible = newVal;
})
watch(() => props.modelValue, (newVal)=>{
that.inputVal = toStr(newVal,'')
if (that.inputVal) {
initInput();
}
},{
immediate: true
})
const clearData = () => {
that.inputVal = '';
that.showValue = '';

View File

@ -18,7 +18,7 @@
</el-input>
</div>
</slot>
{{tmp}}
{{ tmp }}
<Dialog
:title="dialogTitle"
width="80%"
@ -110,7 +110,7 @@ const dialogTitle = ref('设计稿件') // 弹窗的标题
const props = defineProps({
modelValue: {
type: [String],
type: [String,Number],
required: true
},
dataKey: {
@ -167,26 +167,14 @@ const viewDetails = () => {
}
console.log("viewDetails", viewDetails)
}
//
const tmp = computed(()=>{
setTimeout(()=>{
that.inputVal = toStr(props.modelValue,that.inputVal)
if (that.inputVal) {
initInput();
}
},100)
return ''
},{
deep: true
})
const toStr = (data: any) => {
const toStr = (data: any, def = '') => {
if (data !== null && data !== undefined) {
return `${data}`
}
return data
return def
}
let map = new Map();
const initInput = async () => {
const dataKey = that.inputVal + ',' + props.dataKey + ',' + props.showKey + ',' + props.multiple;
@ -218,6 +206,27 @@ watch(() => props.visible, (newVal) => {
that.visible = newVal;
})
//
const tmp = computed(() => {
setTimeout(() => {
that.inputVal = toStr(props.modelValue, that.inputVal)
if (that.inputVal) {
initInput();
}
}, 100)
return ''
}, {
deep: true
})
watch(() => props.modelValue, (newVal) => {
that.inputVal = toStr(newVal, '')
if (that.inputVal) {
initInput();
}
}, {
immediate: true
})
const clearData = () => {
that.inputVal = '';
that.showValue = '';
@ -237,12 +246,12 @@ const submit = () => {
updateVisible(false)
}
const updateValue = () => {
console.log("that.inputVal",that.inputVal)
console.log("that.inputVal", that.inputVal)
emit("update:modelValue", that.inputVal)
}
//
const selectionChange = (row) => {
console.log("row",row)
console.log("row", row)
if (row && row.length > 0) {
if (props.multiple) {
that.inputVal = row.map(item => item[props.dataKey || 'id']).join(',')

View File

@ -109,7 +109,7 @@ const dialogTitle = ref('设计稿件') // 弹窗的标题
const props = defineProps({
modelValue: {
type: [String],
type: [String,Number],
required: true
},
dataKey: {
@ -154,7 +154,12 @@ const that = reactive({
showValue: '',
visible: false,
})
const toStr = (data: any, def = '') => {
if (data !== null && data !== undefined) {
return `${data}`
}
return def
}
const openDialog = () => {
updateVisible(true);
}
@ -164,26 +169,6 @@ const viewDetails = () => {
} else {
openDialog();
}
console.log("viewDetails", viewDetails)
}
//
const tmp = computed(()=>{
setTimeout(()=>{
that.inputVal = toStr(props.modelValue,that.inputVal)
if (that.inputVal) {
initInput();
}
},100)
return ''
},{
deep: true
})
const toStr = (data: any) => {
if (data !== null && data !== undefined) {
return `${data}`
}
return data
}
let map = new Map();
const initInput = async () => {
@ -217,6 +202,27 @@ watch(() => props.visible, (newVal) => {
that.visible = newVal;
})
watch(() => props.modelValue, (newVal)=>{
that.inputVal = toStr(newVal,'')
if (that.inputVal) {
initInput();
}
},{
immediate: true
})
//
const tmp = computed(()=>{
setTimeout(()=>{
that.inputVal = toStr(props.modelValue,that.inputVal)
if (that.inputVal) {
initInput();
}
},100)
return ''
},{deep: true})
const clearData = () => {
that.inputVal = '';
that.showValue = '';

View File

@ -81,7 +81,7 @@
<el-row>
<el-col :span="12" :xs="24">
<el-form-item label="材质说明" prop="specMaterial">
<el-input v-model="formData.specMaterial" />
<el-input name="auto_specMaterial" autocomplete="on" v-model="formData.specMaterial" />
</el-form-item>
</el-col>
<el-col :span="12" :xs="24">
@ -424,7 +424,7 @@ const submitForm = async () => {
return;
}
countInfo[key] = 1;
ids.push(id as string);
ids.push(id);
}
const data = formData.value;
@ -489,6 +489,7 @@ const addProcessRow = () => {
/** 重置表单 */
const resetForm = () => {
activeName.value = 'base'
that.updateProcess = false;
formData.value = {
id: undefined,
code: undefined,