Browse Source

bug修复

master
xuhuajiao 1 month ago
parent
commit
827b8c79d4
  1. 16
      src/views/archivesManage/managementLibrary/index.vue
  2. 22
      src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
  3. 426
      src/views/components/category/PreviewForm.vue
  4. 6
      src/views/prearchiveLibrary/index.vue

16
src/views/archivesManage/managementLibrary/index.vue

@ -159,9 +159,9 @@ export default {
},
fixedStatusSelect: [],
fixedStatusOptions: [
{ value: 1, label: '标签' },
{ value: 2, label: '装盒' },
{ value: 3, label: '入库' },
// { value: 1, label: '' },
// { value: 2, label: '' },
// { value: 3, label: '' },
{ value: 4, label: '借阅' },
{ value: 5, label: '开放' },
{ value: 6, label: '实体' },
@ -394,9 +394,9 @@ export default {
this.$nextTick(() => {
if (this.selectedCategory.arrangeType === 1) {
this.fixedStatusOptions = [
{ value: 1, label: '标签' },
{ value: 2, label: '装盒' },
{ value: 3, label: '入库' },
// { value: 1, label: '' },
// { value: 2, label: '' },
// { value: 3, label: '' },
{ value: 4, label: '借阅' },
{ value: 5, label: '开放' },
{ value: 6, label: '实体' },
@ -404,8 +404,8 @@ export default {
]
} else {
this.fixedStatusOptions = [
{ value: 2, label: '装盒' },
{ value: 3, label: '入库' },
// { value: 2, label: '' },
// { value: 3, label: '' },
{ value: 5, label: '开放' },
{ value: 6, label: '实体' },
{ value: 7, label: '审批锁定' }

22
src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue

@ -626,6 +626,12 @@ export default {
},
// -form/-api
handleForm(type, isPaper) {
if (this.$refs.previewForm) {
this.$refs.previewForm.resetForm()
}
// formPreviewData
this.formPreviewData = []
this.formIsAddOrEdit = type
if (type === 'add') {
@ -831,11 +837,21 @@ export default {
localStorage.removeItem('savePrevFromData')
this.aiCategoryData = []
this.isAiAutoCategory = false
this.displayedText = '' // displayedText
this.isDialogClosed = true // true
this.displayedText = ''
this.isDialogClosed = true
if (this.reader) {
this.reader.cancel() //
this.reader.cancel()
}
// PreviewForm
this.$nextTick(() => {
if (this.$refs.previewForm) {
this.$refs.previewForm.resetForm()
// formPreviewData
this.formPreviewData = []
}
})
done()
},
//

426
src/views/components/category/PreviewForm.vue

@ -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...ofasync/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) {
// handleAutofetchNoFormatAndAutoGenerate
// 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 {
// pickerValnull/undefined
//
this.$set(this.addOrUpdateForm, item.fieldName, '')
this.$set(this.pickerDateMap, item.fieldName, '')
}
//
this.$forceUpdate()
}
}
}

6
src/views/prearchiveLibrary/index.vue

@ -271,6 +271,12 @@ export default {
},
// -form/-api
handleForm(type) {
if (this.$refs.previewForm) {
this.$refs.previewForm.resetForm()
}
// formPreviewData
this.formPreviewData = []
this.mergeVisible = false
this.selectedCategory = this.selectedDocument
this.isDesFormType = 'prearchiveLibrary'

Loading…
Cancel
Save