From 173db85e47e733f9cf0ca11581f52a27e760f9c5 Mon Sep 17 00:00:00 2001 From: lSun <15893999301@qq.com> Date: Fri, 23 Jan 2026 18:53:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B0=E8=B4=A6=E7=AE=A1=E7=90=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entryApply/components/AddEquip.vue | 8 +- .../entryApply/components/EquipmentAdd.vue | 132 +++++++++++++----- 2 files changed, 104 insertions(+), 36 deletions(-) diff --git a/src/views/stockManagement/entryApply/components/AddEquip.vue b/src/views/stockManagement/entryApply/components/AddEquip.vue index efd5a738..eb3e6400 100644 --- a/src/views/stockManagement/entryApply/components/AddEquip.vue +++ b/src/views/stockManagement/entryApply/components/AddEquip.vue @@ -714,7 +714,7 @@ // 必填规则 if (item.mustHave == '1') { - const trigger = ['SELECT', 'DATE', 'IMAGE', 'FILE'].includes(item.inputType) ? 'change' : 'blur' + const trigger = ['SELECT', 'DATE', 'IMAGE', 'FILE', 'INPUT'].includes(item.inputType) ? 'change' : 'blur' this.$set(this.equipRules, item.propertyCode, [ { required: true, message: `请输入${item.propertyName}`, trigger } ]) @@ -725,7 +725,7 @@ this.isSystem.forEach(item => { if (!item.propertyCode) return if (item.mustHave == '1') { - const trigger = ['SELECT', 'DATE', 'IMAGE', 'FILE'].includes(item.inputType) ? 'change' : 'blur' + const trigger = ['SELECT', 'DATE', 'IMAGE', 'FILE', 'INPUT'].includes(item.inputType) ? 'change' : 'blur' // 如果已经存在,不重复覆盖 if (!this.equipRules[item.propertyCode]) { this.$set(this.equipRules, item.propertyCode, [ @@ -794,6 +794,10 @@ this.dialogVisible = true this.firstLevel() this.getManufacturerSelectList() + + setTimeout(() => { + this.$refs.formRef.clearValidate() + }, 500) }, // 获取详情 async getInfo() { diff --git a/src/views/stockManagement/entryApply/components/EquipmentAdd.vue b/src/views/stockManagement/entryApply/components/EquipmentAdd.vue index d3830b2a..30d2cd0d 100644 --- a/src/views/stockManagement/entryApply/components/EquipmentAdd.vue +++ b/src/views/stockManagement/entryApply/components/EquipmentAdd.vue @@ -115,6 +115,7 @@ stripe class="my-table" @row-dblclick="handleDblClick" + ref="tableRef" > - + + - - {{ getFeatureValue(row, item.prop) }} - {{ getFeatureValue(row, item.prop) }} - --> + + {{ getLedgerValue(row, item.propertyCode) }} + @@ -1075,9 +1070,17 @@ export default { delete params.productionDate const res = await getDeviceByOrderIdApi(params) this.tableData = res.data.rows + + + // console.log("查询列表数据",res.data.rows.fieldVoList) + // this.fieldVoList = res.data.rows.fieldVoList || [] + // console.log("查询列表数据",this.fieldVoList) + this.total = res.data.total - + setTimeout(() => { + this.$refs.tableRef.doLayout() + }, 200) } catch (error) { console.error('获取列表失败:', error) } @@ -1428,6 +1431,8 @@ export default { purchaseInvoices: [], // 采购发票 propertyVoList: [], // 特征属性 + fieldVoList: this.fieldVoList, // 台账属性 + majorList: [], // 专业列表 processList: [], // 工序列表 categoryList: [], // 类目列表 @@ -1440,6 +1445,7 @@ export default { await this.getFirstLevel(newRow) this.tableData.unshift(newRow) console.log('🚀 ~ this.tableData:', this.tableData) + console.log('----》》》', this.fieldVoList) } catch (error) { console.log('🚀 ~ error:', error) } @@ -1608,6 +1614,30 @@ export default { return } } + + // 添加 fieldVoList 必填项验证 + if (row.isNew && row.fieldVoList && row.fieldVoList.length > 0) { + // 收集必填但未填写的字段 + const missingRequiredFields = [] + + row.fieldVoList.forEach((field, index) => { + // 检查是否是必填项 + if (field.mustHave != 0) { + // 检查值是否为空 + const value = field.propertyValue + if (value === undefined || value === null || value === '') { + missingRequiredFields.push(field.propertyName || `字段${index + 1}`) + } + } + }) + + // 如果有必填项未填写,提示用户 + if (missingRequiredFields.length > 0) { + this.$message.error(`请填写以下必填项:${missingRequiredFields.join('、')}`) + return + } + } + console.log('🚀 ~ row.propertyVoList:', row.propertyVoList) // 二次确认 @@ -1662,6 +1692,40 @@ export default { isApprovalVisible: routerParams.isApprovalVisible } }) + }, + + + // 台账属性分割值字符串为数组 + getSelectOptions(value) { + if (!value) return [] + return value.split(/[,,]/).map(v => ({ + value: v.trim(), + label: v.trim() + })) + }, + + //台账属性回显属性 + getLedgerValue(row, propertyCode) { + // 如果 row.fieldVoList 顺序和 fieldVoList 一致,可以使用索引 + const configIndex = this.fieldVoList.findIndex(item => item.propertyCode === propertyCode) + + if (configIndex !== -1 && row.fieldVoList && row.fieldVoList[configIndex]) { + const value = row.fieldVoList[configIndex].propertyValue + if (value !== null && value !== undefined) { + return value + } + } + + // 如果索引查找失败,使用 find 方法 + if (row.fieldVoList && Array.isArray(row.fieldVoList)) { + const field = row.fieldVoList.find(item => item.propertyCode === propertyCode) + if (field && field.propertyValue !== null && field.propertyValue !== undefined) { + return field.propertyValue + } + } + + // 最后尝试从 row 对象本身获取 + return row[propertyCode] || '' } } }