✨ 合同编号支持手工填写,组织可配置初始流水号
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -252,8 +252,8 @@ export const option = createCrudOption([
|
|||||||
searchOrder: 6,
|
searchOrder: 6,
|
||||||
searchPlaceholder: '请输入',
|
searchPlaceholder: '请输入',
|
||||||
order: 185,
|
order: 185,
|
||||||
disabled: true,
|
maxlength: 100,
|
||||||
placeholder: '不填写,则系统自动生成',
|
placeholder: '不填写则按部门规则自动生成',
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -380,17 +380,15 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="合同编号">
|
<el-form-item label="合同编号" prop="contractNo">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.contractNo"
|
v-model="form.contractNo"
|
||||||
disabled
|
maxlength="100"
|
||||||
|
clearable
|
||||||
:placeholder="
|
:placeholder="
|
||||||
formMode === 'add'
|
formMode === 'add' ? '不填写则按部门规则自动生成' : '请输入合同编号'
|
||||||
? form.organizationId
|
|
||||||
? '系统按部门规则自动生成'
|
|
||||||
: '请先选择合同负责部门'
|
|
||||||
: ''
|
|
||||||
"
|
"
|
||||||
|
@input="handleContractNoInput"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="合同名称" prop="contractName">
|
<el-form-item label="合同名称" prop="contractName">
|
||||||
@@ -1268,7 +1266,23 @@ export default {
|
|||||||
{ label: '已到期', value: 'expired', statKey: 'expired' },
|
{ label: '已到期', value: 'expired', statKey: 'expired' },
|
||||||
],
|
],
|
||||||
form: defaultForm(),
|
form: defaultForm(),
|
||||||
|
contractNoManual: false,
|
||||||
formRules: {
|
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' }],
|
contractName: [{ required: true, message: '请输入合同名称', trigger: 'blur' }],
|
||||||
contractCategory: [{ required: true, message: '请选择合同类别', trigger: 'change' }],
|
contractCategory: [{ required: true, message: '请选择合同类别', trigger: 'change' }],
|
||||||
signType: [{ 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 || {}));
|
this.api.getDetail(id).then(res => this.applyDetail(res.data?.data || {}));
|
||||||
},
|
},
|
||||||
resetFormState() {
|
resetFormState() {
|
||||||
|
this.contractNoManual = false;
|
||||||
this.form = {
|
this.form = {
|
||||||
...defaultForm(),
|
...defaultForm(),
|
||||||
handlerUserName:
|
handlerUserName:
|
||||||
@@ -1857,7 +1872,20 @@ export default {
|
|||||||
this.$router.$avueRouter?.closeTag?.();
|
this.$router.$avueRouter?.closeTag?.();
|
||||||
this.$router.push(contractManageListRoute);
|
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) {
|
validateBase(action) {
|
||||||
|
if (!this.validateContractNo()) return false;
|
||||||
if (action === 'temporary') {
|
if (action === 'temporary') {
|
||||||
const required = [
|
const required = [
|
||||||
['signType', '签约类型'],
|
['signType', '签约类型'],
|
||||||
@@ -1943,6 +1971,7 @@ export default {
|
|||||||
const projectName = projectId ? normalizeProjectValue(this.form.projectName) : '';
|
const projectName = projectId ? normalizeProjectValue(this.form.projectName) : '';
|
||||||
return {
|
return {
|
||||||
...this.form,
|
...this.form,
|
||||||
|
contractNo: String(this.form.contractNo || '').trim(),
|
||||||
projectId,
|
projectId,
|
||||||
projectName,
|
projectName,
|
||||||
copyCount: normalizeOptionalInteger(this.form.copyCount),
|
copyCount: normalizeOptionalInteger(this.form.copyCount),
|
||||||
@@ -2314,11 +2343,14 @@ export default {
|
|||||||
this.refreshPreviewContractNo();
|
this.refreshPreviewContractNo();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
handleContractNoInput(value) {
|
||||||
|
this.contractNoManual = String(value || '').trim() !== '';
|
||||||
|
},
|
||||||
refreshPreviewContractNo() {
|
refreshPreviewContractNo() {
|
||||||
if (this.formMode !== 'add') return;
|
if (this.formMode !== 'add') return;
|
||||||
const organizationId = this.form.organizationId;
|
const organizationId = this.form.organizationId;
|
||||||
if (!organizationId) {
|
if (!organizationId) {
|
||||||
this.form.contractNo = '';
|
if (!this.contractNoManual) this.form.contractNo = '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const requestId = (this.contractNoPreviewRequestId =
|
const requestId = (this.contractNoPreviewRequestId =
|
||||||
@@ -2326,11 +2358,11 @@ export default {
|
|||||||
api
|
api
|
||||||
.nextContractNo(organizationId)
|
.nextContractNo(organizationId)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (requestId !== this.contractNoPreviewRequestId) return;
|
if (requestId !== this.contractNoPreviewRequestId || this.contractNoManual) return;
|
||||||
this.form.contractNo = res.data?.data || '';
|
this.form.contractNo = res.data?.data || '';
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
if (requestId !== this.contractNoPreviewRequestId) return;
|
if (requestId !== this.contractNoPreviewRequestId || this.contractNoManual) return;
|
||||||
this.form.contractNo = '';
|
this.form.contractNo = '';
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -2763,6 +2795,7 @@ export default {
|
|||||||
},
|
},
|
||||||
getContractChangeFieldLabel(field) {
|
getContractChangeFieldLabel(field) {
|
||||||
const labels = {
|
const labels = {
|
||||||
|
contractNo: '合同编号',
|
||||||
contractName: '合同名称',
|
contractName: '合同名称',
|
||||||
partyB: '乙方',
|
partyB: '乙方',
|
||||||
startDate: '开始日期',
|
startDate: '开始日期',
|
||||||
|
|||||||
@@ -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: '组织简称',
|
label: '组织简称',
|
||||||
prop: 'shortName',
|
prop: 'shortName',
|
||||||
@@ -1156,6 +1187,17 @@ export default {
|
|||||||
row.parentId = 0;
|
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) {
|
isRootDept(row) {
|
||||||
return row && (row.parentId === 0 || String(row.parentId) === '0');
|
return row && (row.parentId === 0 || String(row.parentId) === '0');
|
||||||
},
|
},
|
||||||
@@ -1302,6 +1344,7 @@ export default {
|
|||||||
row.deptCode = String(row.deptCode || '').trim();
|
row.deptCode = String(row.deptCode || '').trim();
|
||||||
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
|
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
|
||||||
row.contractCodePrefix = String(row.contractCodePrefix || '').trim();
|
row.contractCodePrefix = String(row.contractCodePrefix || '').trim();
|
||||||
|
row.contractInitialSerial = this.normalizeContractInitialSerial(row.contractInitialSerial);
|
||||||
row.leaderId = func.join(row.leaderId);
|
row.leaderId = func.join(row.leaderId);
|
||||||
this.normalizeTopParent(row);
|
this.normalizeTopParent(row);
|
||||||
if (!this.prepareDeptSubmitRow(row)) {
|
if (!this.prepareDeptSubmitRow(row)) {
|
||||||
@@ -1349,6 +1392,7 @@ export default {
|
|||||||
row.deptCode = String(row.deptCode || '').trim();
|
row.deptCode = String(row.deptCode || '').trim();
|
||||||
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
|
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
|
||||||
row.contractCodePrefix = String(row.contractCodePrefix || '').trim();
|
row.contractCodePrefix = String(row.contractCodePrefix || '').trim();
|
||||||
|
row.contractInitialSerial = this.normalizeContractInitialSerial(row.contractInitialSerial);
|
||||||
row.leaderId = func.join(row.leaderId);
|
row.leaderId = func.join(row.leaderId);
|
||||||
this.normalizeTopParent(row);
|
this.normalizeTopParent(row);
|
||||||
if (!this.prepareDeptSubmitRow(row)) {
|
if (!this.prepareDeptSubmitRow(row)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user