台账管理页面修改
This commit is contained in:
parent
68443deca6
commit
173db85e47
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@
|
|||
stripe
|
||||
class="my-table"
|
||||
@row-dblclick="handleDblClick"
|
||||
ref="tableRef"
|
||||
>
|
||||
<el-table-column
|
||||
label="序号"
|
||||
|
|
@ -350,57 +351,51 @@
|
|||
<!-- 动态生成 fieldVoList 列 -->
|
||||
<el-table-column
|
||||
v-for="(item, index) in fieldVoList"
|
||||
:key="index"
|
||||
:key="'field-col-' + index"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
:label="item.propertyName"
|
||||
:prop="item.propertyCode"
|
||||
min-width="200px"
|
||||
>
|
||||
<!-- <template v-slot="{ row }">
|
||||
<div
|
||||
v-if="
|
||||
(index + 1) % 2 === 0 &&
|
||||
row.isNew &&
|
||||
row.fieldVoList.length > 0 &&
|
||||
row.fieldVoList[(index + 1) / 2 - 1]
|
||||
"
|
||||
>
|
||||
<el-input
|
||||
v-if="row.fieldVoList[(index + 1) / 2 - 1].inputType == 1"
|
||||
<template v-slot="{ row }">
|
||||
<div v-if="row.isNew && row.fieldVoList && row.fieldVoList.length > index">
|
||||
<el-input v-if="row.fieldVoList[index].inputType == 'INPUT'"
|
||||
autocomplete="off"
|
||||
maxlength="30"
|
||||
v-model="row.fieldVoList[(index + 1) / 2 - 1].propertyValue"
|
||||
maxlength="30" v-model="row.fieldVoList[index].propertyValue"
|
||||
clearable
|
||||
/>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<el-date-picker
|
||||
v-else-if="row.fieldVoList[index].inputType == 'DATE'"
|
||||
v-model="row.fieldVoList[index].propertyValue"
|
||||
type="date"
|
||||
placeholder="选择日期"
|
||||
format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
|
||||
<el-select
|
||||
v-if="row.fieldVoList[(index + 1) / 2 - 1].inputType == 2"
|
||||
v-model="row.fieldVoList[(index + 1) / 2 - 1].propertyValue"
|
||||
v-else-if="row.fieldVoList[index].inputType == 'SELECT' "
|
||||
v-model="row.fieldVoList[index].propertyValue"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in row.fieldVoList[(index + 1) / 2 - 1].valueList"
|
||||
:key="index"
|
||||
:label="item.value"
|
||||
:value="item.value"
|
||||
v-for="option in getSelectOptions(row.fieldVoList[index].value)"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
|
||||
</div>
|
||||
<span
|
||||
v-else-if="
|
||||
row.isNew &&
|
||||
row.fieldVoList.length > 0 &&
|
||||
row.fieldVoList[Math.ceil(index / 2)] &&
|
||||
row.fieldVoList[Math.ceil(index / 2)].mustHave != 0
|
||||
"
|
||||
style="color: red"
|
||||
>{{ getFeatureValue(row, item.prop) }}</span
|
||||
>
|
||||
<span v-else>{{ getFeatureValue(row, item.prop) }}</span>
|
||||
</template>-->
|
||||
|
||||
<span v-else>{{ getLedgerValue(row, item.propertyCode) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
|
|
@ -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] || ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue