From 5e13575dd30cd08b04f6b8367192a2e8fae3d117 Mon Sep 17 00:00:00 2001 From: YuanFeng <770153798@qq.com> Date: Wed, 9 Oct 2024 20:52:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=9B=9E=E6=98=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dialog/src/BrandDataListDialog/index.vue | 40 +++++++++------ .../src/DraftDesignDataListDialog/index.vue | 47 ++++++++++------- .../src/ProductTypeDataListDialog/index.vue | 50 +++++++++++-------- .../views/oms/productinfo/ProductInfoForm.vue | 5 +- 4 files changed, 84 insertions(+), 58 deletions(-) diff --git a/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/BrandDataListDialog/index.vue b/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/BrandDataListDialog/index.vue index 6b216e2..177ce3a 100644 --- a/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/BrandDataListDialog/index.vue +++ b/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/BrandDataListDialog/index.vue @@ -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 = ''; diff --git a/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/DraftDesignDataListDialog/index.vue b/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/DraftDesignDataListDialog/index.vue index 89d0e49..fec4f70 100644 --- a/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/DraftDesignDataListDialog/index.vue +++ b/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/DraftDesignDataListDialog/index.vue @@ -18,7 +18,7 @@ - {{tmp}} + {{ tmp }} { } 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(',') diff --git a/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/ProductTypeDataListDialog/index.vue b/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/ProductTypeDataListDialog/index.vue index a0ce183..51813a4 100644 --- a/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/ProductTypeDataListDialog/index.vue +++ b/hangtag-ui/hangtag-ui-admin/src/components/Dialog/src/ProductTypeDataListDialog/index.vue @@ -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 = ''; diff --git a/hangtag-ui/hangtag-ui-admin/src/views/oms/productinfo/ProductInfoForm.vue b/hangtag-ui/hangtag-ui-admin/src/views/oms/productinfo/ProductInfoForm.vue index 92a533d..e931688 100644 --- a/hangtag-ui/hangtag-ui-admin/src/views/oms/productinfo/ProductInfoForm.vue +++ b/hangtag-ui/hangtag-ui-admin/src/views/oms/productinfo/ProductInfoForm.vue @@ -81,7 +81,7 @@ - + @@ -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,