|
|
|
@ -39,7 +39,7 @@ |
|
|
|
:class="{ 'treeselect-error': fieldErrors[item.fieldName] }" |
|
|
|
@select="selectTree" |
|
|
|
@open="openTree(item)" |
|
|
|
@blur="() => { this.$refs.addOrUpdateForm.validateField(item.fieldName) }" |
|
|
|
@close="() => { handleSelectClose(item.fieldName) }" |
|
|
|
> |
|
|
|
<div slot="value-label" slot-scope="{ node }">{{ getAutoNameUnknown(node.label) }}</div> |
|
|
|
</treeselect> |
|
|
|
@ -661,7 +661,6 @@ export default { |
|
|
|
return row.level ? row.level === 3 : true |
|
|
|
}, |
|
|
|
normalizer(node) { |
|
|
|
console.log('normalizer', node.dictionaryName) |
|
|
|
if ((node.childDictionarys && !node.childDictionarys.length) || node.childDictionarys === null) { |
|
|
|
delete node.childDictionarys |
|
|
|
} |
|
|
|
@ -991,7 +990,7 @@ export default { |
|
|
|
this.$set(this.rules, 'item_no', [{ |
|
|
|
validator: async(rule, value, callback) => { |
|
|
|
// 通过档号是否重复来判断,而不是通过件号大小判断(因为可能有断档) |
|
|
|
console.log('this.archiveNoDuplicate', this.archiveNoDuplicate) |
|
|
|
// console.log('this.archiveNoDuplicate', this.archiveNoDuplicate) |
|
|
|
if (this.archiveNoDuplicate && this.maxItemNo !== null) { |
|
|
|
callback(new Error(`可用起始件号建议: ${this.maxItemNo}`)) |
|
|
|
} else { |
|
|
|
@ -1055,7 +1054,7 @@ export default { |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (item.dictionaryId) { |
|
|
|
console.log('item.dictionaryId', item.dictionaryId) |
|
|
|
// console.log('item.dictionaryId', item.dictionaryId) |
|
|
|
// const params = { |
|
|
|
// 'pid': item.dictionaryId.id |
|
|
|
// } |
|
|
|
@ -1081,11 +1080,14 @@ export default { |
|
|
|
.filter(parent => filterCodes.includes(parent.dictionaryCode)) // 匹配顶级项 |
|
|
|
.map(topItem => topItem.childDictionarys) // 只取顶级项的子级(保留多级结构) |
|
|
|
.flat() // 扁平化一维数组(多个顶级项的子树合并) |
|
|
|
console.log('保留多级结构的子项:', filteredItems) |
|
|
|
|
|
|
|
console.log('filteredItems', filteredItems) |
|
|
|
// 去重处理:移除重复的节点ID |
|
|
|
const uniqueItems = this.removeDuplicateNodes(filteredItems) |
|
|
|
if (item.isInputClass === 'select') { |
|
|
|
this.$set(item, 'options', filteredItems) |
|
|
|
this.$set(item, 'options', uniqueItems) |
|
|
|
} else if (item.isInputClass === 'popover') { |
|
|
|
this.popoverTableData = filteredItems |
|
|
|
this.popoverTableData = uniqueItems |
|
|
|
this.popoverVisible = true |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
@ -1253,6 +1255,67 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
console.log('isRepeatHandle', item) |
|
|
|
}, |
|
|
|
// treeselect close事件处理 - 验证必填字段 |
|
|
|
handleSelectClose(fieldName) { |
|
|
|
console.log('handleSelectClose', fieldName) |
|
|
|
if (this.$refs.addOrUpdateForm) { |
|
|
|
// 先验证字段 |
|
|
|
this.$refs.addOrUpdateForm.validateField(fieldName) |
|
|
|
|
|
|
|
// 检查该字段是否为必填且值为空 |
|
|
|
const fieldItem = this.formPreviewData.find(item => item.fieldName === fieldName) |
|
|
|
if (fieldItem && fieldItem.isRequired) { |
|
|
|
const fieldValue = this.addOrUpdateForm[fieldName] |
|
|
|
if (!fieldValue && fieldValue !== 0 && fieldValue !== false) { |
|
|
|
// 设置错误信息 |
|
|
|
this.$set(this.fieldErrors, fieldName, '请选择' + fieldItem.fieldCnName) |
|
|
|
} else { |
|
|
|
// 清除错误信息 |
|
|
|
this.$set(this.fieldErrors, fieldName, '') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
// 递归移除树形数据中重复的节点ID |
|
|
|
removeDuplicateNodes(nodes) { |
|
|
|
const seenIds = new Set() |
|
|
|
const result = [] |
|
|
|
|
|
|
|
const processNode = (node) => { |
|
|
|
// 检查当前节点ID是否已存在 |
|
|
|
const nodeId = node.dictionaryName || node.id || node.code |
|
|
|
if (nodeId && seenIds.has(nodeId)) { |
|
|
|
return null // 跳过重复节点 |
|
|
|
} |
|
|
|
if (nodeId) { |
|
|
|
seenIds.add(nodeId) |
|
|
|
} |
|
|
|
|
|
|
|
// 递归处理子节点 |
|
|
|
if (node.childDictionarys && Array.isArray(node.childDictionarys)) { |
|
|
|
const uniqueChildren = [] |
|
|
|
for (const child of node.childDictionarys) { |
|
|
|
const processedChild = processNode(child) |
|
|
|
if (processedChild) { |
|
|
|
uniqueChildren.push(processedChild) |
|
|
|
} |
|
|
|
} |
|
|
|
node.childDictionarys = uniqueChildren |
|
|
|
} |
|
|
|
|
|
|
|
return node |
|
|
|
} |
|
|
|
|
|
|
|
for (const node of nodes) { |
|
|
|
const processedNode = processNode(node) |
|
|
|
if (processedNode) { |
|
|
|
result.push(processedNode) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result |
|
|
|
}, |
|
|
|
// tree - open |
|
|
|
openTree(item) { |
|
|
|
@ -1443,8 +1506,6 @@ export default { |
|
|
|
if (item.fieldName === 'fonds_name' && this.isDesFormType !== 'category') { |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, this.selectedCategory.fondName) |
|
|
|
} |
|
|
|
console.log('item', item) |
|
|
|
console.log('item.isRequired', item.isRequired) |
|
|
|
const rule = { |
|
|
|
required: !!item.isRequired, |
|
|
|
message: ((item.isInputClass === 'text' || item.isInputClass === 'textarea') ? '请输入' : '请选择') + item.fieldCnName, |
|
|
|
@ -1634,7 +1695,7 @@ export default { |
|
|
|
} |
|
|
|
const originalArchiveNo = this.addOrUpdateForm.archive_no |
|
|
|
|
|
|
|
console.log('this.addOrUpdateForm', this.addOrUpdateForm) |
|
|
|
// console.log('this.addOrUpdateForm', this.addOrUpdateForm) |
|
|
|
|
|
|
|
// 先验证重复字段 |
|
|
|
const isRepeatValid = await this.validateRepeatFieldsBeforeSubmit(formName) |
|
|
|
|