Browse Source

件号自动生成1

master
xuhuajiao 2 weeks ago
parent
commit
06ff9a4ce8
  1. 12
      src/api/collect/collect.js
  2. 142
      src/views/components/category/PreviewForm.vue
  3. 1
      src/views/prearchiveLibrary/index.vue

12
src/api/collect/collect.js

@ -403,6 +403,15 @@ export function FetchIsRepeatAllByArchivesNo(params) {
}) })
} }
// 通过档号获取最大件号
export function FetchMaxItemNoByArchivesNo(params) {
return request({
url: 'api/collect/getMaxItemNoByArchivesNo',
method: 'get',
params
})
}
export default { export default {
collectAdd, collectAdd,
collectEdit, collectEdit,
@ -444,5 +453,6 @@ export default {
FetchInitFileMarkCategoryView, FetchInitFileMarkCategoryView,
FetchMaxItemNoByParentId, FetchMaxItemNoByParentId,
FetchIsRepeatByArchivesNo, FetchIsRepeatByArchivesNo,
FetchIsRepeatAllByArchivesNo
FetchIsRepeatAllByArchivesNo,
FetchMaxItemNoByArchivesNo
} }

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

@ -201,7 +201,7 @@
<script> <script>
import { crud } from '@crud/crud' import { crud } from '@crud/crud'
import { FetchDoeditIsRepeat } from '@/api/archivesManage/archivesList' import { FetchDoeditIsRepeat } from '@/api/archivesManage/archivesList'
import { collectAdd, collectEdit, FetchIsRepeatByArchivesNo, FetchIsRepeatAllByArchivesNo } from '@/api/collect/collect'
import { collectAdd, collectEdit, FetchIsRepeatByArchivesNo, FetchIsRepeatAllByArchivesNo, FetchMaxItemNoByArchivesNo } from '@/api/collect/collect'
import { prearchEdit, FetchMergeToFile, FetchReDoeditIsRepeat } from '@/api/prearchiveLibrary/prearchiveLibrary' import { prearchEdit, FetchMergeToFile, FetchReDoeditIsRepeat } from '@/api/prearchiveLibrary/prearchiveLibrary'
import { getNoFormatField } from '@/api/system/category/fileNoFormat' import { getNoFormatField } from '@/api/system/category/fileNoFormat'
import draggable from 'vuedraggable' import draggable from 'vuedraggable'
@ -322,6 +322,10 @@ export default {
minioPreResult: [], // minio minioPreResult: [], // minio
jsonArrayStore: [], // jsonArrayToSendminioPreResult jsonArrayStore: [], // jsonArrayToSendminioPreResult
fileNameStore: [], // fileNameminioPreResult fileNameStore: [], // fileNameminioPreResult
itemNoAutoGenerated: false, //
maxItemNo: null, //
archiveNoDuplicate: false, //
lastModifiedField: null, //
iconShowRule: { iconShowRule: {
'3-1': 'item_no', '3-1': 'item_no',
'3-2': 'record_no', '3-2': 'record_no',
@ -793,6 +797,11 @@ export default {
// 使for...ofasync/await // 使for...ofasync/await
for (const val of this.autoMatic) { for (const val of this.autoMatic) {
//
if (val.fieldName === 'item_no' && !this.addOrUpdateForm[val.fieldName]) {
continue
}
if (!this.addOrUpdateForm[val.fieldName]) { if (!this.addOrUpdateForm[val.fieldName]) {
continue continue
} }
@ -856,8 +865,42 @@ export default {
}) })
console.log('档号生成完成:', string) console.log('档号生成完成:', string)
return string return string
}, },
//
async fetchAndSetMaxItemNo(archivesNo) {
try {
const response = await FetchMaxItemNoByArchivesNo({ archivesNo })
console.log('查询最大件号响应:', response)
//
this.maxItemNo = response
if (response) {
//
const itemNoField = this.formPreviewData.find(item => item.fieldName === 'item_no')
if (itemNoField) {
//
this.$set(this.addOrUpdateForm, 'item_no', response)
//
if (itemNoField.isFilling && itemNoField.fillingDigit) {
this.autoAddZero(itemNoField.isFilling, 'item_no', response, itemNoField.fillingDigit)
}
//
this.itemNoAutoGenerated = true
console.log('件号自动赋值完成:', this.addOrUpdateForm.item_no)
//
const isItemNoInAutoMatic = this.autoMatic.some(item => item.fieldName === 'item_no')
if (isItemNoInAutoMatic && !this.itemNoAutoGenerated) {
//
await this.handleAuto()
}
}
}
} catch (error) {
console.error('查询最大件号失败:', error)
}
},
// 2. // 2.
updateArchiveNoValidator(item) { updateArchiveNoValidator(item) {
const validateArchiveNo = async(value) => { const validateArchiveNo = async(value) => {
@ -874,27 +917,67 @@ export default {
if (this.isDesFormType === 'mergeFile') { if (this.isDesFormType === 'mergeFile') {
response = await FetchIsRepeatByArchivesNo({ archivesId: null, archivesNo: value }) response = await FetchIsRepeatByArchivesNo({ archivesId: null, archivesNo: value })
if (response !== 0) { if (response !== 0) {
//
this.archiveNoDuplicate = true
//
// await this.fetchAndSetMaxItemNo(value)
//
this.$nextTick(() => {
if (this.$refs.addOrUpdateForm) {
this.$refs.addOrUpdateForm.validateField('item_no')
}
})
return '请注意,该档号已被使用' return '请注意,该档号已被使用'
} }
//
this.archiveNoDuplicate = false
//
this.$nextTick(() => {
if (this.$refs.addOrUpdateForm) {
this.$refs.addOrUpdateForm.clearValidate('item_no')
}
})
} else { } else {
response = await FetchIsRepeatAllByArchivesNo({ response = await FetchIsRepeatAllByArchivesNo({
archivesId: this.archivesType === 'add' ? null : this.addOrUpdateForm.id, archivesId: this.archivesType === 'add' ? null : this.addOrUpdateForm.id,
archivesNo: value archivesNo: value
}) })
if ((response.nodelcount !== 0 && response.delcount === 0) ||
(response.nodelcount === 0 && response.delcount !== 0)) {
if ((response.nodelcount !== 0 && response.delcount === 0) || (response.nodelcount === 0 && response.delcount !== 0)) {
//
this.archiveNoDuplicate = true
//
// await this.fetchAndSetMaxItemNo(value)
//
this.$nextTick(() => {
if (this.$refs.addOrUpdateForm) {
this.$refs.addOrUpdateForm.validateField('item_no')
}
})
return '请注意,该档号已被使用' return '请注意,该档号已被使用'
} }
//
this.archiveNoDuplicate = false
this.archivesSummaryResponse = response this.archivesSummaryResponse = response
//
this.$nextTick(() => {
if (this.$refs.addOrUpdateForm) {
this.$refs.addOrUpdateForm.clearValidate('item_no')
}
})
} }
return null return null
} catch (error) { } catch (error) {
console.error('档号重复检查失败:', error) console.error('档号重复检查失败:', error)
//
this.archiveNoDuplicate = false
return '验证档号重复时发生错误,请稍后再试' return '验证档号重复时发生错误,请稍后再试'
} }
} }
// //
//
this.updateItemNoValidator()
this.$set(this.rules, item.fieldName, [{ this.$set(this.rules, item.fieldName, [{
validator: async(rule, value, callback) => { validator: async(rule, value, callback) => {
const errorMessage = await validateArchiveNo(value) const errorMessage = await validateArchiveNo(value)
@ -903,6 +986,19 @@ export default {
} else { } else {
callback() callback()
} }
//
this.$nextTick(() => {
if (this.$refs.addOrUpdateForm) {
//
if (this.archiveNoDuplicate) {
this.$refs.addOrUpdateForm.validateField('item_no')
} else {
//
this.$refs.addOrUpdateForm.clearValidate('item_no')
}
}
})
}, },
trigger: 'blur' // trigger: 'blur' //
}]) }])
@ -915,6 +1011,22 @@ export default {
}) })
}, },
//
updateItemNoValidator() {
this.$set(this.rules, 'item_no', [{
validator: async(rule, value, callback) => {
//
console.log('this.archiveNoDuplicate', this.archiveNoDuplicate)
if (this.archiveNoDuplicate && this.maxItemNo !== null) {
callback(new Error(`可用起始件号建议: ${this.maxItemNo}`))
} else {
callback()
}
},
trigger: ['blur', 'change'] // blur change
}])
},
// //
compare(property) { compare(property) {
return function(a, b) { return function(a, b) {
@ -1086,6 +1198,9 @@ export default {
} }
}, },
async isRepeatHandle(item) { async isRepeatHandle(item) {
//
this.lastModifiedField = item.fieldName
// //
if (item.isRepeat) { if (item.isRepeat) {
const params = this.isDesFormType !== 'prearchiveLibrary' const params = this.isDesFormType !== 'prearchiveLibrary'
@ -1108,10 +1223,23 @@ export default {
if (this.isDesFormType !== 'prearchiveLibrary' && item.fieldName !== 'archive_no') { if (this.isDesFormType !== 'prearchiveLibrary' && item.fieldName !== 'archive_no') {
// + // +
await this.fetchNoFormatAndAutoGenerate(this.selectedCategory.id) 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()
// autoMatic
const isInAutoMatic = this.autoMatic && this.autoMatic.some(i => i.fieldName === item.fieldName)
if (isInAutoMatic && item.fieldName !== 'item_no') {
//
const archiveNo = this.addOrUpdateForm.archive_no
if (archiveNo) {
// 1.
this.$set(this.addOrUpdateForm, 'item_no', '')
this.maxItemNo = null
// 2.
await this.handleAuto()
// 3.
await this.fetchAndSetMaxItemNo(this.addOrUpdateForm.archive_no)
// 4.
await this.handleAuto()
}
} }
} }
}, },

1
src/views/prearchiveLibrary/index.vue

@ -238,7 +238,6 @@ export default {
isDisabled: false, isDisabled: false,
isHasCode: false, isHasCode: false,
selectedCategoryMerge: null, selectedCategoryMerge: null,
timer: null, timer: null,
mousedownTime: 0, mousedownTime: 0,
mousedownX: 0, mousedownX: 0,

Loading…
Cancel
Save