diff --git a/src/option/business/contract-manage.js b/src/option/business/contract-manage.js index 0d1e912..e59adf3 100644 --- a/src/option/business/contract-manage.js +++ b/src/option/business/contract-manage.js @@ -252,8 +252,8 @@ export const option = createCrudOption([ searchOrder: 6, searchPlaceholder: '请输入', order: 185, - disabled: true, - placeholder: '不填写,则系统自动生成', + maxlength: 100, + placeholder: '不填写则按部门规则自动生成', minWidth: 200, }, { diff --git a/src/views/business/contract-manage.vue b/src/views/business/contract-manage.vue index 8076697..158b9cb 100644 --- a/src/views/business/contract-manage.vue +++ b/src/views/business/contract-manage.vue @@ -380,17 +380,15 @@ /> - + @@ -1268,7 +1266,23 @@ export default { { label: '已到期', value: 'expired', statKey: 'expired' }, ], form: defaultForm(), + contractNoManual: false, formRules: { + contractNo: [ + { + validator: (rule, value, callback) => { + const contractNo = String(value || '').trim(); + if (this.formMode === 'edit' && !contractNo) { + return callback(new Error('请输入合同编号')); + } + if (contractNo.length > 100) { + return callback(new Error('合同编号不能超过100个字符')); + } + callback(); + }, + trigger: 'blur', + }, + ], contractName: [{ required: true, message: '请输入合同名称', trigger: 'blur' }], contractCategory: [{ required: true, message: '请选择合同类别', trigger: 'change' }], signType: [{ required: true, message: '请选择签约类型', trigger: 'change' }], @@ -1782,6 +1796,7 @@ export default { this.api.getDetail(id).then(res => this.applyDetail(res.data?.data || {})); }, resetFormState() { + this.contractNoManual = false; this.form = { ...defaultForm(), handlerUserName: @@ -1857,7 +1872,20 @@ export default { this.$router.$avueRouter?.closeTag?.(); this.$router.push(contractManageListRoute); }, + validateContractNo() { + const contractNo = String(this.form.contractNo || '').trim(); + if (this.formMode === 'edit' && !contractNo) { + this.$message.warning('请输入合同编号'); + return false; + } + if (contractNo.length > 100) { + this.$message.warning('合同编号不能超过100个字符'); + return false; + } + return true; + }, validateBase(action) { + if (!this.validateContractNo()) return false; if (action === 'temporary') { const required = [ ['signType', '签约类型'], @@ -1943,6 +1971,7 @@ export default { const projectName = projectId ? normalizeProjectValue(this.form.projectName) : ''; return { ...this.form, + contractNo: String(this.form.contractNo || '').trim(), projectId, projectName, copyCount: normalizeOptionalInteger(this.form.copyCount), @@ -2314,11 +2343,14 @@ export default { this.refreshPreviewContractNo(); } }, + handleContractNoInput(value) { + this.contractNoManual = String(value || '').trim() !== ''; + }, refreshPreviewContractNo() { if (this.formMode !== 'add') return; const organizationId = this.form.organizationId; if (!organizationId) { - this.form.contractNo = ''; + if (!this.contractNoManual) this.form.contractNo = ''; return; } const requestId = (this.contractNoPreviewRequestId = @@ -2326,11 +2358,11 @@ export default { api .nextContractNo(organizationId) .then(res => { - if (requestId !== this.contractNoPreviewRequestId) return; + if (requestId !== this.contractNoPreviewRequestId || this.contractNoManual) return; this.form.contractNo = res.data?.data || ''; }) .catch(() => { - if (requestId !== this.contractNoPreviewRequestId) return; + if (requestId !== this.contractNoPreviewRequestId || this.contractNoManual) return; this.form.contractNo = ''; }); }, @@ -2763,6 +2795,7 @@ export default { }, getContractChangeFieldLabel(field) { const labels = { + contractNo: '合同编号', contractName: '合同名称', partyB: '乙方', startDate: '开始日期', diff --git a/src/views/system/dept.vue b/src/views/system/dept.vue index bfac437..edd5330 100644 --- a/src/views/system/dept.vue +++ b/src/views/system/dept.vue @@ -418,6 +418,37 @@ export default { }, ], }, + { + label: '合同初始流水号', + prop: 'contractInitialSerial', + type: 'input', + minWidth: 140, + order: 61, + placeholder: '如 1', + tip: '该部门当年首个合同时从此流水号起编,后续递增;范围1-999,不填默认从1开始', + rules: [ + { + validator: (rule, value, callback) => { + if (value === undefined || value === null || value === '') { + callback(); + return; + } + const text = String(value).trim(); + if (!/^\d+$/.test(text)) { + callback(new Error('合同初始流水号只能输入正整数')); + return; + } + const serial = Number(text); + if (serial < 1 || serial > 999) { + callback(new Error('合同初始流水号范围为1到999')); + return; + } + callback(); + }, + trigger: 'blur', + }, + ], + }, { label: '组织简称', prop: 'shortName', @@ -1156,6 +1187,17 @@ export default { row.parentId = 0; } }, + normalizeContractInitialSerial(value) { + if (value === undefined || value === null || value === '') { + return null; + } + const text = String(value).trim(); + if (!text) { + return null; + } + const serial = Number(text); + return Number.isInteger(serial) ? serial : value; + }, isRootDept(row) { return row && (row.parentId === 0 || String(row.parentId) === '0'); }, @@ -1302,6 +1344,7 @@ export default { row.deptCode = String(row.deptCode || '').trim(); row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim(); row.contractCodePrefix = String(row.contractCodePrefix || '').trim(); + row.contractInitialSerial = this.normalizeContractInitialSerial(row.contractInitialSerial); row.leaderId = func.join(row.leaderId); this.normalizeTopParent(row); if (!this.prepareDeptSubmitRow(row)) { @@ -1349,6 +1392,7 @@ export default { row.deptCode = String(row.deptCode || '').trim(); row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim(); row.contractCodePrefix = String(row.contractCodePrefix || '').trim(); + row.contractInitialSerial = this.normalizeContractInitialSerial(row.contractInitialSerial); row.leaderId = func.join(row.leaderId); this.normalizeTopParent(row); if (!this.prepareDeptSubmitRow(row)) {