|
|
|
@ -86,6 +86,7 @@ |
|
|
|
:style="{ width: item.editLength+'px'}" |
|
|
|
@input="handleManualInput(item)" |
|
|
|
@blur="handleManualBlur(item)" |
|
|
|
@keyup="(e) => e.target.value === '' && handleManualClear(item)" |
|
|
|
/> |
|
|
|
<!-- DatePicker组件:仅保留日历图标和面板选择,隐藏输入框 --> |
|
|
|
<el-date-picker |
|
|
|
@ -335,7 +336,9 @@ export default { |
|
|
|
this.editFormRow() |
|
|
|
// 区分 门类著录项 和 档案管理 |
|
|
|
if (this.isDesFormType === 'category' || this.isDesFormType === 'mergeFile') { |
|
|
|
this.FetchNoFormatField(this.selectedCategory.id) |
|
|
|
this.fetchNoFormatAndAutoGenerate(this.selectedCategory.id).catch(err => { |
|
|
|
console.error('监听中生成档号失败:', err) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -345,6 +348,38 @@ export default { |
|
|
|
mounted() { |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// PreviewForm组件中新增 |
|
|
|
resetForm() { |
|
|
|
// 1. 重置表单数据 |
|
|
|
this.addOrUpdateForm = {} |
|
|
|
this.rules = {} |
|
|
|
this.autoMatic = null |
|
|
|
this.fileOriginal = null |
|
|
|
this.fileJsonString = null |
|
|
|
this.newFileCount = 0 |
|
|
|
this.pickerDateMap = {} |
|
|
|
this.loadingStatus = {} |
|
|
|
|
|
|
|
// 2. 重置弹窗状态 |
|
|
|
this.popoverVisible = false |
|
|
|
this.popoverClassifyVisible = false |
|
|
|
this.popoverFondsVisible = false |
|
|
|
this.popoverTableData = [] |
|
|
|
this.popoverTableDataClassify = [] |
|
|
|
this.popoverTableDataFonds = [] |
|
|
|
|
|
|
|
// 3. 重置表单引用(如果需要) |
|
|
|
if (this.$refs.addOrUpdateForm) { |
|
|
|
this.$refs.addOrUpdateForm.resetFields() |
|
|
|
} |
|
|
|
|
|
|
|
// 4. 重置其他临时状态 |
|
|
|
this.currentFieldName = null |
|
|
|
this.treeCurrentFiled = null |
|
|
|
this.entityIndex = null |
|
|
|
this.archivesType = null |
|
|
|
this.activeIndex = null |
|
|
|
}, |
|
|
|
shouldShowIcon(item) { |
|
|
|
if (item.isInputClass !== 'number') return false |
|
|
|
const ruleKey = `${this.isTitleType}-${this.selectedCategory.arrangeType}` |
|
|
|
@ -692,126 +727,135 @@ export default { |
|
|
|
return data |
|
|
|
}, |
|
|
|
// 自动生成 |
|
|
|
handleAuto() { |
|
|
|
console.log('handleAuto') |
|
|
|
async handleAuto() { |
|
|
|
console.log('开始生成档号') |
|
|
|
let string = '' |
|
|
|
const getAutoFiledVal = [] |
|
|
|
this.autoMatic.forEach(async val => { |
|
|
|
|
|
|
|
// 使用for...of循环,支持async/await |
|
|
|
for (const val of this.autoMatic) { |
|
|
|
if (!this.addOrUpdateForm[val.fieldName]) { |
|
|
|
string += '' |
|
|
|
} else { |
|
|
|
const fieldInfo = this.formPreviewData.find(element => element.fieldName === val.fieldName) |
|
|
|
if (fieldInfo.isInputClass === 'select' || fieldInfo.isInputClass === 'popover') { |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
const fieldInfo = this.formPreviewData.find(element => element.fieldName === val.fieldName) |
|
|
|
if (!fieldInfo) continue |
|
|
|
|
|
|
|
if (fieldInfo.isInputClass === 'select' || fieldInfo.isInputClass === 'popover') { |
|
|
|
try { |
|
|
|
let option = null |
|
|
|
if (fieldInfo.mateData === 3) { |
|
|
|
await FetchSonDictionaryList({ 'pid': fieldInfo.dictionaryId.id }).then(res => { |
|
|
|
const option = this.getNode(res, this.addOrUpdateForm[val.fieldName]) |
|
|
|
if (option) { |
|
|
|
const obj = {} |
|
|
|
obj.name = val.fieldName |
|
|
|
obj.val = option[0].dictionaryCode + val.connector |
|
|
|
obj.sequence = val.sequence |
|
|
|
getAutoFiledVal.push(obj) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
if (fieldInfo.mateData === 1) { |
|
|
|
await FetchInitSearchFonds().then(res => { |
|
|
|
const option = this.getFondsNode(res, this.addOrUpdateForm[val.fieldName]) |
|
|
|
if (option) { |
|
|
|
const obj = {} |
|
|
|
obj.name = val.fieldName |
|
|
|
obj.val = option[0].fondsNo + val.connector |
|
|
|
obj.sequence = val.sequence |
|
|
|
getAutoFiledVal.push(obj) |
|
|
|
} |
|
|
|
}) |
|
|
|
const res = await FetchSonDictionaryList({ 'pid': fieldInfo.dictionaryId.id }) |
|
|
|
option = this.getNode(res, this.addOrUpdateForm[val.fieldName]) |
|
|
|
} else if (fieldInfo.mateData === 1) { |
|
|
|
const res = await FetchInitSearchFonds() |
|
|
|
option = this.getFondsNode(res, this.addOrUpdateForm[val.fieldName]) |
|
|
|
} else if (fieldInfo.mateData === 2) { |
|
|
|
const categoryId = this.isDesFormType !== 'mergeFile' && this.isDesFormType !== 'arcives' && this.isDesFormType !== 'manageArcives' |
|
|
|
? this.selectedCategory.pid |
|
|
|
: this.selectedCategory.id |
|
|
|
const res = await FetchArchivesClassTree({ 'categoryId': categoryId }) |
|
|
|
option = this.getClassfiyNode(res, this.addOrUpdateForm[val.fieldName]) |
|
|
|
} |
|
|
|
if (fieldInfo.mateData === 2) { |
|
|
|
let categoryId |
|
|
|
if (this.isDesFormType !== 'mergeFile' && this.isDesFormType !== 'arcives' && this.isDesFormType !== 'manageArcives') { |
|
|
|
categoryId = this.selectedCategory.pid |
|
|
|
} else { |
|
|
|
categoryId = this.selectedCategory.id |
|
|
|
} |
|
|
|
await FetchArchivesClassTree({ 'categoryId': categoryId }).then(res => { |
|
|
|
const option = this.getClassfiyNode(res, this.addOrUpdateForm[val.fieldName]) |
|
|
|
if (option) { |
|
|
|
const obj = {} |
|
|
|
obj.name = val.name |
|
|
|
obj.val = option[0].code + val.connector |
|
|
|
obj.sequence = val.sequence |
|
|
|
getAutoFiledVal.push(obj) |
|
|
|
} |
|
|
|
|
|
|
|
if (option) { |
|
|
|
getAutoFiledVal.push({ |
|
|
|
name: val.fieldName, |
|
|
|
val: (fieldInfo.mateData === 3 ? option[0].dictionaryCode |
|
|
|
: fieldInfo.mateData === 1 ? option[0].fondsNo |
|
|
|
: option[0].code) + val.connector, |
|
|
|
sequence: val.sequence |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
const obj = {} |
|
|
|
obj.name = val.fieldName |
|
|
|
obj.val = this.addOrUpdateForm[val.fieldName] + val.connector |
|
|
|
obj.sequence = val.sequence |
|
|
|
getAutoFiledVal.push(obj) |
|
|
|
} catch (error) { |
|
|
|
console.error('获取字段值失败:', error) |
|
|
|
continue |
|
|
|
} |
|
|
|
} else { |
|
|
|
getAutoFiledVal.push({ |
|
|
|
name: val.fieldName, |
|
|
|
val: this.addOrUpdateForm[val.fieldName] + val.connector, |
|
|
|
sequence: val.sequence |
|
|
|
}) |
|
|
|
} |
|
|
|
getAutoFiledVal.sort(this.compare('sequence')) |
|
|
|
string = getAutoFiledVal.map((item) => item.val).join('') |
|
|
|
this.formPreviewData.map(item => { |
|
|
|
if (item.isAutomatic) { |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, string) |
|
|
|
// 处理 archive_year 字段的验证 |
|
|
|
if (item.fieldName === 'archive_no') { |
|
|
|
const rule = {} |
|
|
|
const validateArchiveNo = async(value) => { |
|
|
|
let errorMessage = null |
|
|
|
if (value === '') { |
|
|
|
if (item.isRequired === null || item.isRequired === false) { |
|
|
|
return |
|
|
|
} |
|
|
|
errorMessage = item.isInputClass === 'text' ? `请输入${item.fieldCnName}` : `请选择${item.fieldCnName}` |
|
|
|
return errorMessage |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (getAutoFiledVal.length === this.autoMatic.length) { |
|
|
|
let response |
|
|
|
try { |
|
|
|
if (this.isDesFormType === 'mergeFile') { |
|
|
|
console.log('mergeFile666') |
|
|
|
response = await FetchIsRepeatByArchivesNo({ archivesId: null, archivesNo: value }) |
|
|
|
if (response !== 0) { |
|
|
|
errorMessage = '请注意,该档号已被使用' |
|
|
|
} |
|
|
|
} else { |
|
|
|
response = await FetchIsRepeatAllByArchivesNo({ |
|
|
|
archivesId: this.archivesType === 'add' ? null : this.addOrUpdateForm.id, |
|
|
|
archivesNo: value |
|
|
|
}) |
|
|
|
if ((response.nodelcount !== 0 && response.delcount === 0) || (response.nodelcount === 0 && response.delcount !== 0)) { |
|
|
|
errorMessage = '请注意,该档号已被使用' |
|
|
|
} |
|
|
|
this.archivesSummaryResponse = response |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
errorMessage = '验证档号重复时发生错误,请稍后再试' |
|
|
|
} |
|
|
|
} |
|
|
|
return errorMessage |
|
|
|
} |
|
|
|
// 排序并生成最终档号 |
|
|
|
getAutoFiledVal.sort(this.compare('sequence')) |
|
|
|
string = getAutoFiledVal.map((item) => item.val).join('') |
|
|
|
|
|
|
|
rule.validator = async(rule, value, callback) => { |
|
|
|
const errorMessage = await validateArchiveNo(value) |
|
|
|
if (errorMessage) { |
|
|
|
rule.message = errorMessage |
|
|
|
callback(new Error(errorMessage)) |
|
|
|
} else { |
|
|
|
callback() |
|
|
|
} |
|
|
|
} |
|
|
|
// 更新档号字段 |
|
|
|
this.formPreviewData.forEach(item => { |
|
|
|
if (item.isAutomatic) { |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, string) |
|
|
|
|
|
|
|
this.$set(this.rules, item.fieldName, [rule]) |
|
|
|
// 处理档号验证规则 |
|
|
|
if (item.fieldName === 'archive_no') { |
|
|
|
this.updateArchiveNoValidator(item) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
console.log('档号生成完成:', string) |
|
|
|
return string |
|
|
|
}, |
|
|
|
// 2. 抽离档号验证逻辑,确保异步验证稳定 |
|
|
|
updateArchiveNoValidator(item) { |
|
|
|
const validateArchiveNo = async(value) => { |
|
|
|
// 空值验证 |
|
|
|
if (value === '') { |
|
|
|
if (item.isRequired) { |
|
|
|
return `请输入${item.fieldCnName}` |
|
|
|
} |
|
|
|
return null |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
let response |
|
|
|
if (this.isDesFormType === 'mergeFile') { |
|
|
|
response = await FetchIsRepeatByArchivesNo({ archivesId: null, archivesNo: value }) |
|
|
|
if (response !== 0) { |
|
|
|
return '请注意,该档号已被使用' |
|
|
|
} |
|
|
|
} else { |
|
|
|
response = await FetchIsRepeatAllByArchivesNo({ |
|
|
|
archivesId: this.archivesType === 'add' ? null : this.addOrUpdateForm.id, |
|
|
|
archivesNo: value |
|
|
|
}) |
|
|
|
if ((response.nodelcount !== 0 && response.delcount === 0) || |
|
|
|
(response.nodelcount === 0 && response.delcount !== 0)) { |
|
|
|
return '请注意,该档号已被使用' |
|
|
|
} |
|
|
|
this.archivesSummaryResponse = response |
|
|
|
} |
|
|
|
}) |
|
|
|
return null |
|
|
|
} catch (error) { |
|
|
|
console.error('档号重复检查失败:', error) |
|
|
|
return '验证档号重复时发生错误,请稍后再试' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 更新验证规则 |
|
|
|
this.$set(this.rules, item.fieldName, [{ |
|
|
|
validator: async(rule, value, callback) => { |
|
|
|
const errorMessage = await validateArchiveNo(value) |
|
|
|
if (errorMessage) { |
|
|
|
callback(new Error(errorMessage)) |
|
|
|
} else { |
|
|
|
callback() |
|
|
|
} |
|
|
|
}, |
|
|
|
trigger: 'blur' // 明确触发时机 |
|
|
|
}]) |
|
|
|
|
|
|
|
// 手动触发表单验证,确保提示及时更新 |
|
|
|
this.$nextTick(() => { |
|
|
|
if (this.$refs.addOrUpdateForm) { |
|
|
|
this.$refs.addOrUpdateForm.validateField('archive_no') |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 排序 |
|
|
|
compare(property) { |
|
|
|
return function(a, b) { |
|
|
|
@ -822,20 +866,39 @@ export default { |
|
|
|
}, |
|
|
|
// 获取档号组成项 |
|
|
|
FetchNoFormatField(categoryId) { |
|
|
|
return new Promise((resolve) => { |
|
|
|
return new Promise((resolve, reject) => { // 增加reject处理异常 |
|
|
|
let categoryLevel |
|
|
|
if (this.isDesFormType === 'mergeFile') { |
|
|
|
categoryLevel = 3 |
|
|
|
} else { |
|
|
|
categoryLevel = this.collectLevel |
|
|
|
} |
|
|
|
getNoFormatField({ categoryId: categoryId, categoryLevel: categoryLevel }).then(res => { |
|
|
|
this.autoMatic = res |
|
|
|
this.handleAuto() |
|
|
|
resolve() |
|
|
|
}) |
|
|
|
|
|
|
|
// 增加try/catch捕获接口异常 |
|
|
|
getNoFormatField({ categoryId: categoryId, categoryLevel: categoryLevel }) |
|
|
|
.then(res => { |
|
|
|
this.autoMatic = res |
|
|
|
resolve(res) // 只返回数据,不执行handleAuto |
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
console.error('获取档号格式配置失败:', error) |
|
|
|
this.$message.error('获取档号格式失败,请重试') |
|
|
|
reject(error) // 抛出异常让外部捕获 |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 补充:如果需要保留“获取配置后自动生成档号”的场景,新增一个封装方法 |
|
|
|
async fetchNoFormatAndAutoGenerate(categoryId) { |
|
|
|
try { |
|
|
|
await this.FetchNoFormatField(categoryId) |
|
|
|
await this.handleAuto() // 等待档号生成完成 |
|
|
|
return this.autoMatic |
|
|
|
} catch (error) { |
|
|
|
console.error('获取配置并生成档号失败:', error) |
|
|
|
throw error |
|
|
|
} |
|
|
|
}, |
|
|
|
// 获取对应字典子集数据 |
|
|
|
getAllSubset(item) { |
|
|
|
if (item.mateData === 1) { |
|
|
|
@ -963,46 +1026,33 @@ export default { |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
// input 判断是否重复 |
|
|
|
isRepeatHandle(item) { |
|
|
|
// 自动重复字段 - 是否重复 |
|
|
|
async isRepeatHandle(item) { |
|
|
|
// 自动重复字段检查 |
|
|
|
if (item.isRepeat) { |
|
|
|
let params |
|
|
|
// && this.isDesFormType !== 'mergeFile' |
|
|
|
if (this.isDesFormType !== 'prearchiveLibrary') { |
|
|
|
params = { |
|
|
|
const params = this.isDesFormType !== 'prearchiveLibrary' |
|
|
|
? { |
|
|
|
'categoryId': this.selectedCategory.id, |
|
|
|
'archivesId': this.arcId, |
|
|
|
'fieldName': item.fieldName, |
|
|
|
'value': this.addOrUpdateForm[item.fieldName] |
|
|
|
} |
|
|
|
} else { |
|
|
|
params = { |
|
|
|
: { |
|
|
|
'documentId': this.selectedCategory.id, |
|
|
|
'archivesId': null, |
|
|
|
'fieldName': item.fieldName, |
|
|
|
'value': this.addOrUpdateForm[item.fieldName] |
|
|
|
} |
|
|
|
} |
|
|
|
this.handlerIsRepeat(params, item) |
|
|
|
} |
|
|
|
// && this.isDesFormType !== 'mergeFile' |
|
|
|
if (this.isDesFormType !== 'prearchiveLibrary') { |
|
|
|
console.log('333') |
|
|
|
console.log('item', item) |
|
|
|
console.log('item.isAutomatic)', item.fieldName) |
|
|
|
console.log('item.isAutomatic)', item.isAutomatic) |
|
|
|
|
|
|
|
if (item.fieldName !== 'archive_no') { |
|
|
|
// 修改这里,使用 async/await |
|
|
|
this.FetchNoFormatField(this.selectedCategory.id).then(() => { |
|
|
|
const index = this.autoMatic.findIndex(i => item.fieldName === i.fieldName) |
|
|
|
console.log('index', index) |
|
|
|
console.log(!item.isAutomatic && index !== -1) |
|
|
|
if (!item.isAutomatic && index !== -1) { |
|
|
|
this.handleAuto() |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
// 档号自动生成 |
|
|
|
if (this.isDesFormType !== 'prearchiveLibrary' && item.fieldName !== 'archive_no') { |
|
|
|
// 等待配置+档号生成都完成 |
|
|
|
await this.fetchNoFormatAndAutoGenerate(this.selectedCategory.id) |
|
|
|
const index = this.autoMatic.findIndex(i => item.fieldName === i.fieldName) |
|
|
|
if (!item.isAutomatic && index !== -1) { |
|
|
|
// 这里不需要再调用handleAuto,因为fetchNoFormatAndAutoGenerate已经包含了 |
|
|
|
// await this.handleAuto() |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -1013,7 +1063,8 @@ export default { |
|
|
|
this.getAllSubset(this.treeCurrentFiled) |
|
|
|
}, |
|
|
|
// tree - select |
|
|
|
selectTree(val) { |
|
|
|
async selectTree(val) { |
|
|
|
// 设置选中值 |
|
|
|
if (val.fondsNo) { |
|
|
|
this.addOrUpdateForm[this.treeCurrentFiled.fieldName] = val.fondsName |
|
|
|
} else if (val.name) { |
|
|
|
@ -1021,38 +1072,34 @@ export default { |
|
|
|
} else { |
|
|
|
this.addOrUpdateForm[this.treeCurrentFiled.fieldName] = val.dictionaryName |
|
|
|
} |
|
|
|
// 自动重复字段 - 是否重复 - treeSelect方式 |
|
|
|
|
|
|
|
// 重复检查 |
|
|
|
if (this.treeCurrentFiled.isRepeat) { |
|
|
|
let params |
|
|
|
if (this.isDesFormType !== 'prearchiveLibrary' && this.isDesFormType !== 'mergeFile') { |
|
|
|
params = { |
|
|
|
const params = this.isDesFormType !== 'prearchiveLibrary' && this.isDesFormType !== 'mergeFile' |
|
|
|
? { |
|
|
|
'categoryId': this.selectedCategory.id, |
|
|
|
'archivesId': this.arcId, |
|
|
|
'fieldName': this.treeCurrentFiled.fieldName, |
|
|
|
'value': val.dictionaryName |
|
|
|
} |
|
|
|
} else { |
|
|
|
params = { |
|
|
|
: { |
|
|
|
'documentId': this.selectedCategory.id, |
|
|
|
'archivesId': null, |
|
|
|
'fieldName': this.treeCurrentFiled.fieldName, |
|
|
|
'value': val.dictionaryName |
|
|
|
} |
|
|
|
} |
|
|
|
this.handlerIsRepeat(params, this.treeCurrentFiled) |
|
|
|
} |
|
|
|
// && this.isDesFormType !== 'mergeFile' |
|
|
|
|
|
|
|
// 重新生成档号 |
|
|
|
if (this.isDesFormType !== 'prearchiveLibrary') { |
|
|
|
console.log('111') |
|
|
|
console.log('this.autoMatic', this.autoMatic) |
|
|
|
console.log('this.treeCurrentFiled.fieldNam', this.treeCurrentFiled.fieldName) |
|
|
|
if (this.archivesType === 'edit') { |
|
|
|
this.FetchNoFormatField(this.selectedCategory.id) |
|
|
|
await this.FetchNoFormatField(this.selectedCategory.id) |
|
|
|
} |
|
|
|
if (this.autoMatic) { |
|
|
|
const index = this.autoMatic.findIndex(i => this.treeCurrentFiled.fieldName === i.fieldName) |
|
|
|
if (index !== -1) { |
|
|
|
this.handleAuto() |
|
|
|
await this.handleAuto() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1067,8 +1114,9 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
// popover - table 选中得项 |
|
|
|
handleSelectionChange(val) { |
|
|
|
async handleSelectionChange(val) { |
|
|
|
if (val.length > 0) { |
|
|
|
// 1. 设置选中值(保持原有逻辑) |
|
|
|
if (this.isTableType === 1) { |
|
|
|
this.addOrUpdateForm[this.currentFieldName] = val[0].fondsNo |
|
|
|
} else if (this.isTableType === 2 && this.isDesFormType !== 'prearchiveLibrary') { |
|
|
|
@ -1077,22 +1125,39 @@ export default { |
|
|
|
this.addOrUpdateForm[this.currentFieldName] = val[0].dictionaryName |
|
|
|
} |
|
|
|
} |
|
|
|
this.$refs.popoverTable.clearSelection() |
|
|
|
|
|
|
|
// 2. 清空选择并关闭弹窗(保持原有逻辑) |
|
|
|
this.$refs.popoverTable?.clearSelection() |
|
|
|
this.popoverVisible = false |
|
|
|
this.popoverClassifyVisible = false |
|
|
|
this.popoverFondsVisible = false |
|
|
|
|
|
|
|
// && this.isDesFormType !== 'mergeFile' |
|
|
|
// 3. 档号自动生成逻辑(核心修改:使用await等待异步操作完成) |
|
|
|
if (this.isDesFormType !== 'prearchiveLibrary') { |
|
|
|
console.log('222') |
|
|
|
if (this.archivesType === 'edit') { |
|
|
|
this.FetchNoFormatField(this.selectedCategory.id) |
|
|
|
} |
|
|
|
if (this.autoMatic) { |
|
|
|
const index = this.autoMatic.findIndex(i => this.currentFieldName === i.fieldName) |
|
|
|
if (index !== -1) { |
|
|
|
this.handleAuto() |
|
|
|
try { |
|
|
|
// 如果是编辑状态,先获取档号格式配置(等待完成) |
|
|
|
if (this.archivesType === 'edit') { |
|
|
|
await this.fetchNoFormatAndAutoGenerate(this.selectedCategory.id) |
|
|
|
} |
|
|
|
|
|
|
|
// 如果当前字段在档号组成项中,执行档号生成(等待完成) |
|
|
|
if (this.autoMatic) { |
|
|
|
const index = this.autoMatic.findIndex(i => this.currentFieldName === i.fieldName) |
|
|
|
if (index !== -1) { |
|
|
|
await this.handleAuto() // 关键:等待档号生成完成 |
|
|
|
|
|
|
|
// 生成完成后,手动触发一次档号字段的验证(确保提示及时更新) |
|
|
|
this.$nextTick(() => { |
|
|
|
if (this.$refs.addOrUpdateForm) { |
|
|
|
this.$refs.addOrUpdateForm.validateField('archive_no') |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('选择后生成档号失败:', error) |
|
|
|
this.$message.error('档号生成失败,请重试') |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -1144,6 +1209,12 @@ export default { |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, null) // 防止unkonwn |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 初始化日期字段时清空pickerDateMap |
|
|
|
if (item.isInputClass === 'date') { |
|
|
|
this.$set(this.pickerDateMap, item.fieldName, '') |
|
|
|
} |
|
|
|
|
|
|
|
if (item.fieldName === 'archival_category_code') { |
|
|
|
let targetNode |
|
|
|
if (this.isDesFormType === 'mergeFile') { |
|
|
|
@ -1582,6 +1653,11 @@ export default { |
|
|
|
} |
|
|
|
// 回写过滤后的值 |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, val) |
|
|
|
|
|
|
|
// 关键修复:如果输入框被清空,同步清空pickerDateMap |
|
|
|
if (val === '') { |
|
|
|
this.$set(this.pickerDateMap, item.fieldName, '') |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -1596,7 +1672,13 @@ export default { |
|
|
|
// 回写补零后的值(用$set确保响应式) |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, filledVal) |
|
|
|
}, |
|
|
|
|
|
|
|
// 新增:处理手动清空输入框(比如用户删除所有字符) |
|
|
|
handleManualClear(item) { |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, '') |
|
|
|
this.$set(this.pickerDateMap, item.fieldName, '') |
|
|
|
// 强制更新视图 |
|
|
|
this.$forceUpdate() |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 多字段适配:面板选择日期同步到表单 |
|
|
|
* @param {Object} item 当前日期字段的配置项 |
|
|
|
@ -1606,11 +1688,19 @@ export default { |
|
|
|
console.log('item', item) |
|
|
|
console.log('item.fieldName', item.fieldName) |
|
|
|
console.log('pickerVal', pickerVal) |
|
|
|
if (!pickerVal) return |
|
|
|
// 面板选择值覆盖手动输入值 |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, pickerVal) |
|
|
|
// 同步到pickerDateMap,保持面板状态一致 |
|
|
|
this.$set(this.pickerDateMap, item.fieldName, pickerVal) |
|
|
|
|
|
|
|
// 选择了具体日期(强制更新,不管是否和旧值相同) |
|
|
|
if (pickerVal) { |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, pickerVal) |
|
|
|
this.$set(this.pickerDateMap, item.fieldName, pickerVal) |
|
|
|
} else { |
|
|
|
// 清空了日期(pickerVal为null/undefined) |
|
|
|
// 强制清空所有相关值 |
|
|
|
this.$set(this.addOrUpdateForm, item.fieldName, '') |
|
|
|
this.$set(this.pickerDateMap, item.fieldName, '') |
|
|
|
} |
|
|
|
// 强制触发视图更新,确保组件感知到值变化 |
|
|
|
this.$forceUpdate() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|