✨ 合同编号支持手工填写,组织可配置初始流水号
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -380,17 +380,15 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="合同编号">
|
||||
<el-form-item label="合同编号" prop="contractNo">
|
||||
<el-input
|
||||
v-model="form.contractNo"
|
||||
disabled
|
||||
maxlength="100"
|
||||
clearable
|
||||
:placeholder="
|
||||
formMode === 'add'
|
||||
? form.organizationId
|
||||
? '系统按部门规则自动生成'
|
||||
: '请先选择合同负责部门'
|
||||
: ''
|
||||
formMode === 'add' ? '不填写则按部门规则自动生成' : '请输入合同编号'
|
||||
"
|
||||
@input="handleContractNoInput"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="合同名称" prop="contractName">
|
||||
@@ -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: '开始日期',
|
||||
|
||||
Reference in New Issue
Block a user