|
|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="p-2">
|
|
|
|
|
<!-- 审批按钮组件(参考 contractInfo/edit.vue) -->
|
|
|
|
|
<el-card shadow="never" style="margin-top: 0">
|
|
|
|
|
<!-- 审批按钮组件:内容变更且已提交(变更状态=3)时不显示 -->
|
|
|
|
|
<el-card v-if="showApprovalCard" shadow="never" style="margin-top: 0">
|
|
|
|
|
<approvalButton
|
|
|
|
|
@submitForm="submitForm"
|
|
|
|
|
@approvalVerifyOpen="approvalVerifyOpen"
|
|
|
|
|
@ -13,11 +13,13 @@
|
|
|
|
|
:mode="false"
|
|
|
|
|
/>
|
|
|
|
|
</el-card>
|
|
|
|
|
<el-card v-if="!showApprovalCard" shadow="never" style="margin-top: 0">
|
|
|
|
|
<el-button style="float: right" @click="goBack">返回</el-button>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
<template #header>
|
|
|
|
|
<span>{{ isEdit ? '编辑合同变更' : '合同变更申请' }}</span>
|
|
|
|
|
<el-button class="float-right" link @click="goBack">返回</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
@ -33,6 +35,11 @@
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="原合同编号">
|
|
|
|
|
<el-input v-model="form.contractCode" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="选择合同" prop="contractId">
|
|
|
|
|
<el-input
|
|
|
|
|
@ -185,9 +192,26 @@
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12" v-show="form.changeInfo.contractTemplateFlag !== '1'">
|
|
|
|
|
<el-form-item label="合同模板">
|
|
|
|
|
<el-select v-model="form.changeInfo.templateId" placeholder="请选择合同模板" :disabled="isFormDisabled" filterable style="width: 100%">
|
|
|
|
|
<el-option v-for="item in printTemplateList" :key="item.templateId" :label="item.templateName + '-' + (item.version || '')" :value="item.templateId" />
|
|
|
|
|
<div class="flex gap-2 items-center" style="width: 100%">
|
|
|
|
|
<el-select v-model="form.changeInfo.templateId" placeholder="请选择合同模板" :disabled="isFormDisabled" filterable style="flex: 1">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in printTemplateList"
|
|
|
|
|
:key="item.templateId"
|
|
|
|
|
:label="item.templateName + '-' + item.version"
|
|
|
|
|
:value="item.templateId"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-button
|
|
|
|
|
link
|
|
|
|
|
type="primary"
|
|
|
|
|
icon="Download"
|
|
|
|
|
:disabled="!form.changeInfo.templateId || !form.contractId"
|
|
|
|
|
@click="handleContractTemplateDownload"
|
|
|
|
|
style="font-weight: 600"
|
|
|
|
|
>
|
|
|
|
|
查看模板
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
@ -442,7 +466,7 @@
|
|
|
|
|
import { Search } from '@element-plus/icons-vue';
|
|
|
|
|
import { getContractInfo } from '@/api/oa/erp/contractInfo';
|
|
|
|
|
import type { ContractInfoVO } from '@/api/oa/erp/contractInfo/types';
|
|
|
|
|
import { saveContractChange, getContractChangeDetail, contractChangeSubmitAndFlowStart } from '@/api/oa/erp/contractChange';
|
|
|
|
|
import { saveContractChange, getContractChangeDetail, contractChangeSubmitAndFlowStart, contractChangeContentSubmit } from '@/api/oa/erp/contractChange';
|
|
|
|
|
import type { ContractChangeSaveForm } from '@/api/oa/erp/contractChange/types';
|
|
|
|
|
import type { ContractMaterialForm } from '@/api/oa/erp/contractMaterial/types';
|
|
|
|
|
import type { ContractPaymentMethodForm } from '@/api/oa/erp/contractPaymentMethod/types';
|
|
|
|
|
@ -635,6 +659,7 @@ const contractSelectRef = ref<InstanceType<typeof ContractSelect>>();
|
|
|
|
|
|
|
|
|
|
const isEdit = computed(() => !!(routeParams.value.id && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'approval')));
|
|
|
|
|
const isFormDisabled = computed(() => routeParams.value.type === 'view' || routeParams.value.type === 'approval');
|
|
|
|
|
const showApprovalCard = computed(() => !(form.value.changeStatus === '3' && form.value.changeType === '1'));
|
|
|
|
|
|
|
|
|
|
const form = ref<
|
|
|
|
|
ContractChangeSaveForm & {
|
|
|
|
|
@ -643,10 +668,12 @@ const form = ref<
|
|
|
|
|
changePaymentMethodList?: any[];
|
|
|
|
|
flowStatus?: string;
|
|
|
|
|
changeCode?: string;
|
|
|
|
|
newContractId?: string | number;
|
|
|
|
|
}
|
|
|
|
|
>({
|
|
|
|
|
contractChangeId: undefined,
|
|
|
|
|
contractId: undefined as any,
|
|
|
|
|
newContractId: undefined,
|
|
|
|
|
changeType: '1',
|
|
|
|
|
changeReason: '',
|
|
|
|
|
applyTime: undefined,
|
|
|
|
|
@ -683,6 +710,16 @@ function goBack() {
|
|
|
|
|
router.push({ path: '/contract/contractChange' });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 合同模板下载/查看(仿照合同修改页) */
|
|
|
|
|
function handleContractTemplateDownload() {
|
|
|
|
|
if (!form.value.changeInfo?.templateId) return;
|
|
|
|
|
console.log(form.value);
|
|
|
|
|
router.push({
|
|
|
|
|
path: '/contract/contractView',
|
|
|
|
|
query: { templateId: form.value.changeInfo.templateId, contractId: form.value.newContractId }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 打开合同选择弹框 */
|
|
|
|
|
function openContractSelect() {
|
|
|
|
|
if (isFormDisabled.value) return;
|
|
|
|
|
@ -807,6 +844,7 @@ async function loadDetail() {
|
|
|
|
|
form.value.undertakeBy = m.undertakeBy;
|
|
|
|
|
form.value.industryRegion = m.industryRegion;
|
|
|
|
|
form.value.sealLegalEntity = m.sealLegalEntity;
|
|
|
|
|
form.value.newContractId = m.newContractId;
|
|
|
|
|
selectedContractName.value = m.contractName || '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1002,7 +1040,7 @@ function buildPayload(changeStatus: '1' | '2'): ContractChangeSaveForm {
|
|
|
|
|
return payload;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 审批栏:提交(暂存 / 提交审批),仿照合同 contractInfo/edit 提交流程,提交审批走新接口 contractChangeSubmitAndFlowStart */
|
|
|
|
|
/** 审批栏:提交(暂存 / 提交审批)。内容变更走 contractChangeContentSubmit 不走 HTBG;解除合同走 contractChangeSubmitAndFlowStart */
|
|
|
|
|
function submitForm(status: string, _mode: boolean) {
|
|
|
|
|
formRef.value?.validate((valid: boolean) => {
|
|
|
|
|
if (!valid) return;
|
|
|
|
|
@ -1010,10 +1048,34 @@ function submitForm(status: string, _mode: boolean) {
|
|
|
|
|
proxy?.$modal.msgError('内容变更请先选择合同,以加载变更后合同信息');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (status !== 'draft' && form.value.changeType === '1') {
|
|
|
|
|
const newCode = (form.value.changeInfo?.contractCode ?? '').trim();
|
|
|
|
|
const oldCode = (form.value.contractCode ?? '').trim();
|
|
|
|
|
if (newCode === oldCode) {
|
|
|
|
|
proxy?.$modal.msgError('合同内容变更时,变更后合同编号必须与原合同编号不同');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
if (status !== 'draft') {
|
|
|
|
|
// 提交审批:后端发起流程
|
|
|
|
|
const payload = buildPayload('2');
|
|
|
|
|
if (form.value.changeType === '1') {
|
|
|
|
|
// 内容变更:不走 HTBG,保存变更单并新增合同,新合同走 OAC
|
|
|
|
|
contractChangeContentSubmit(payload)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
if (res.data) {
|
|
|
|
|
form.value.contractChangeId = res.data.contractChangeId;
|
|
|
|
|
form.value.changeStatus = res.data.changeStatus ?? '3';
|
|
|
|
|
form.value.flowStatus = res.data.flowStatus ?? 'content_submitted';
|
|
|
|
|
}
|
|
|
|
|
proxy?.$modal.msgSuccess('操作成功,已生成新合同,请在合同管理中提交新合同审批');
|
|
|
|
|
goBack();
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// 解除合同:走 HTBG
|
|
|
|
|
payload.flowCode = FlowCodeEnum.CONTRACT_CHANGE_CODE;
|
|
|
|
|
payload.flowStatus = 'waiting';
|
|
|
|
|
payload.variables = {
|
|
|
|
|
@ -1023,8 +1085,8 @@ function submitForm(status: string, _mode: boolean) {
|
|
|
|
|
changeReason: form.value.changeReason
|
|
|
|
|
};
|
|
|
|
|
payload.bizExt = {
|
|
|
|
|
businessTitle: '合同变更',
|
|
|
|
|
businessCode: form.value.changeCode || '合同变更'
|
|
|
|
|
businessTitle: '合同解除',
|
|
|
|
|
businessCode: form.value.changeCode || ''
|
|
|
|
|
};
|
|
|
|
|
contractChangeSubmitAndFlowStart(payload)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
@ -1039,6 +1101,7 @@ function submitForm(status: string, _mode: boolean) {
|
|
|
|
|
.finally(() => {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 暂存
|
|
|
|
|
const payload = buildPayload('1');
|
|
|
|
|
|