|
|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="p-2">
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
<template #header>
|
|
|
|
|
<div style="text-align: left; font-weight: bold; font-size: 24px">合同{{ form.contractId ? ' - 修改' : ' - 新增' }}</div>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- <template #header>-->
|
|
|
|
|
<!-- <div style="text-align: left; font-weight: bold; font-size: 24px">合同{{ form.contractId ? ' - 修改' : ' - 新增' }}</div>-->
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
<!-- 审批按钮组件 -->
|
|
|
|
|
<approvalButton
|
|
|
|
|
@submitForm="submitForm"
|
|
|
|
|
@ -11,11 +11,11 @@
|
|
|
|
|
@handleApprovalRecord="handleApprovalRecord"
|
|
|
|
|
:buttonLoading="buttonLoading"
|
|
|
|
|
:id="form.contractId"
|
|
|
|
|
:status="form.contractStatus"
|
|
|
|
|
:status="form.flowStatus"
|
|
|
|
|
:pageType="routeParams.type"
|
|
|
|
|
:mode="false"
|
|
|
|
|
/>
|
|
|
|
|
<el-form ref="contractInfoFormRef" :model="form" :rules="rules" label-width="120px">
|
|
|
|
|
<el-form ref="contractInfoFormRef" :model="form" :disabled="routeParams.type === 'view'" :rules="rules" label-width="120px">
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="有无合同" prop="contractFlag">
|
|
|
|
|
@ -146,7 +146,7 @@
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="附件" prop="ossId">
|
|
|
|
|
<!-- <el-input v-model="form.ossId" type="textarea" placeholder="请输入内容" />-->
|
|
|
|
|
<!-- <el-input v-model="form.ossId" type="textarea" placeholder="请输入内容" />-->
|
|
|
|
|
<el-button type="primary" plain icon="Upload" @click="handleFile">上传合同附件</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
@ -167,7 +167,7 @@
|
|
|
|
|
|
|
|
|
|
<!-- 合同物料表格 -->
|
|
|
|
|
<div style="margin-bottom: 16px">
|
|
|
|
|
<el-button type="primary" icon="Plus" @click="handleAddMaterial">新增物料</el-button>
|
|
|
|
|
<el-button type="primary" icon="Plus" v-if="routeParams.type !== 'view'" @click="handleAddMaterial">新增物料 </el-button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<el-table :data="contractMaterialList" border v-loading="materialLoading">
|
|
|
|
|
@ -202,22 +202,13 @@
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="备注" align="center" prop="remark" min-width="100" />
|
|
|
|
|
<el-table-column label="操作" align="center" fixed="right" width="150">
|
|
|
|
|
<el-table-column label="操作" align="center" fixed="right" width="150" v-if="routeParams.type !== 'view'">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-button link type="primary" icon="Edit" @click="handleEditMaterial(scope.row)">编辑</el-button>
|
|
|
|
|
<el-button link type="danger" icon="Delete" @click="handleDeleteMaterial(scope.row)">删除</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<el-card shadow="never" style="margin-top: 20px" v-if="routeParams.type !== 'approval'">
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button :loading="buttonLoading" type="primary" @click="() => submitForm('draft', false)">保 存</el-button>
|
|
|
|
|
<el-button @click="goBack">返 回</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<!-- 合同物料编辑对话框 -->
|
|
|
|
|
@ -338,7 +329,7 @@
|
|
|
|
|
</el-form>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div class="dialog-footer">
|
|
|
|
|
<el-button :loading="materialButtonLoading" type="primary" @click="submitMaterialForm">确 定</el-button>
|
|
|
|
|
<el-button type="primary" @click="submitMaterialForm">确 定</el-button>
|
|
|
|
|
<el-button @click="cancelMaterial">取 消</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
@ -369,28 +360,31 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup name="ContractInfoEdit" lang="ts">
|
|
|
|
|
import { addContractInfo, getContractInfo, updateContractInfo } from '@/api/oa/erp/contractInfo';
|
|
|
|
|
import { addContractInfo, contractSubmitAndFlowStart, getContractInfo, updateContractInfo } from '@/api/oa/erp/contractInfo';
|
|
|
|
|
import { ContractInfoForm } from '@/api/oa/erp/contractInfo/types';
|
|
|
|
|
import { getErpContractMaterialList } from '@/api/oa/erp/contractMaterial';
|
|
|
|
|
import { ContractMaterialVO, ContractMaterialForm } from '@/api/oa/erp/contractMaterial/types';
|
|
|
|
|
import { getBaseUnitInfoList } from '@/api/oa/base/unitInfo';
|
|
|
|
|
import { getRuleGenerateCode } from '@/api/system/codeRule';
|
|
|
|
|
import { startWorkFlow } from '@/api/workflow/task';
|
|
|
|
|
import { StartProcessBo } from '@/api/workflow/workflowCommon/types';
|
|
|
|
|
import SaleMaterialSelect from '@/components/SaleMaterialSelect/index.vue';
|
|
|
|
|
import SubmitVerify from '@/components/Process/submitVerify.vue';
|
|
|
|
|
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
|
|
|
|
|
import ApprovalButton from '@/components/Process/approvalButton.vue';
|
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
import { listDept } from '@/api/system/dept';
|
|
|
|
|
import { allListDept, listDept } from '@/api/system/dept';
|
|
|
|
|
import { getCrmCustomerInfoList } from '@/api/oa/crm/customerInfo';
|
|
|
|
|
import { getBasePrintTemplateList } from '@/api/oa/base/printTemplate';
|
|
|
|
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
// 路由参数
|
|
|
|
|
const routeParams = ref<Record<string, any>>({});
|
|
|
|
|
const { contract_category, business_direction, active_flag, contract_flag, contract_type, contract_status, plan_flag } = toRefs<any>(
|
|
|
|
|
proxy?.useDict('contract_category', 'business_direction', 'active_flag', 'contract_flag', 'contract_type', 'contract_status', 'plan_flag')
|
|
|
|
|
const { contract_category, business_direction, contract_flag, contract_type, contract_status, plan_flag } = toRefs<any>(
|
|
|
|
|
proxy?.useDict('contract_category', 'business_direction', 'contract_flag', 'contract_type', 'contract_status', 'plan_flag')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const buttonLoading = ref(false);
|
|
|
|
|
@ -400,8 +394,17 @@ const contractInfoFormRef = ref<ElFormInstance>();
|
|
|
|
|
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
|
|
|
|
|
const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
|
|
|
|
|
|
|
|
|
|
// 流程相关数据
|
|
|
|
|
const submitFormData = ref<StartProcessBo>({
|
|
|
|
|
businessId: '',
|
|
|
|
|
flowCode: 'OAC',
|
|
|
|
|
variables: {},
|
|
|
|
|
bizExt: {}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 任务变量
|
|
|
|
|
const taskVariables = ref<Record<string, any>>({});
|
|
|
|
|
const flowInstanceBizExtBo = ref<Record<string, any>>({});
|
|
|
|
|
|
|
|
|
|
const type = ref(0);
|
|
|
|
|
const dialog = reactive<DialogOption>({
|
|
|
|
|
@ -417,7 +420,6 @@ const isCodeGenerated = ref(false);
|
|
|
|
|
|
|
|
|
|
// 合同物料相关
|
|
|
|
|
const materialLoading = ref(false);
|
|
|
|
|
const materialButtonLoading = ref(false);
|
|
|
|
|
const materialFormRef = ref<ElFormInstance>();
|
|
|
|
|
|
|
|
|
|
// 合同物料列表计算属性
|
|
|
|
|
@ -443,7 +445,7 @@ const getUnitInfoListSelect = async () => {
|
|
|
|
|
const deptInfoList = ref([]);
|
|
|
|
|
const getDeptInfoListSelect = async () => {
|
|
|
|
|
const params = { deptCategory: '03' } as any;
|
|
|
|
|
let res = await listDept(params);
|
|
|
|
|
let res = await allListDept(params);
|
|
|
|
|
deptInfoList.value = res.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -515,6 +517,9 @@ const initFormData: ContractInfoFormEx = {
|
|
|
|
|
signatureAppendix: undefined,
|
|
|
|
|
taxRate: undefined,
|
|
|
|
|
remark: undefined,
|
|
|
|
|
flowCode: undefined,
|
|
|
|
|
bizExt: undefined,
|
|
|
|
|
variables: undefined,
|
|
|
|
|
activeFlag: '1',
|
|
|
|
|
contractMaterialList: [],
|
|
|
|
|
file: undefined
|
|
|
|
|
@ -529,14 +534,10 @@ const data = reactive<{ form: ContractInfoFormEx; rules: any }>({
|
|
|
|
|
|
|
|
|
|
const { form, rules } = toRefs(data);
|
|
|
|
|
|
|
|
|
|
const goBack = () => {
|
|
|
|
|
proxy?.$tab.closePage();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 监听contractFlag变化
|
|
|
|
|
watch(
|
|
|
|
|
() => form.value.contractFlag,
|
|
|
|
|
(newVal, oldVal) => {
|
|
|
|
|
(newVal) => {
|
|
|
|
|
if (newVal === '2') {
|
|
|
|
|
// 当选择"无合同"时,清空合同编号并重置生成状态
|
|
|
|
|
form.value.contractCode = undefined;
|
|
|
|
|
@ -568,7 +569,7 @@ const openSaleMaterialSelect = () => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//确认选择申请人
|
|
|
|
|
const saleMaterialSelectCallBack = (data) => {
|
|
|
|
|
const saleMaterialSelectCallBack = (data: any) => {
|
|
|
|
|
const materialList = data;
|
|
|
|
|
if (materialList.length > 0) {
|
|
|
|
|
materialForm.value.materialId = materialList[0].materialId;
|
|
|
|
|
@ -594,30 +595,90 @@ const handleFile = () => {
|
|
|
|
|
ossFileModel.value = form.value.ossId as any;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 提交按钮 */
|
|
|
|
|
const submitForm = (status: string, mode: boolean) => {
|
|
|
|
|
try {
|
|
|
|
|
contractInfoFormRef.value?.validate(async (valid: boolean) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
try {
|
|
|
|
|
// 设置后端发起和不等于草稿状态 直接走流程发起
|
|
|
|
|
if (status != 'draft') {
|
|
|
|
|
// 后端发起流程模式
|
|
|
|
|
form.value.flowCode = 'OAC';
|
|
|
|
|
// 流程变量
|
|
|
|
|
form.value.variables = {
|
|
|
|
|
contractName: form.value.contractName,
|
|
|
|
|
totalPrice: form.value.totalPrice,
|
|
|
|
|
contractCode: form.value.contractCode
|
|
|
|
|
};
|
|
|
|
|
// 流程实例业务扩展字段
|
|
|
|
|
form.value.bizExt = {
|
|
|
|
|
businessTitle: '合同审批',
|
|
|
|
|
businessCode: form.value.contractCode
|
|
|
|
|
};
|
|
|
|
|
form.value.contractStatus = '2';
|
|
|
|
|
form.value.flowStatus = 'waiting';
|
|
|
|
|
const res = await contractSubmitAndFlowStart(form.value).finally(() => (buttonLoading.value = false));
|
|
|
|
|
form.value = res.data;
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
|
|
proxy?.$tab.closePage();
|
|
|
|
|
router.go(-1);
|
|
|
|
|
} else {
|
|
|
|
|
if (status === 'draft') {
|
|
|
|
|
form.value.contractStatus = '1';
|
|
|
|
|
form.value.flowStatus = 'draft';
|
|
|
|
|
}
|
|
|
|
|
if (form.value.contractId) {
|
|
|
|
|
await updateContractInfo(form.value).finally(() => (buttonLoading.value = false));
|
|
|
|
|
} else {
|
|
|
|
|
await addContractInfo(form.value).finally(() => (buttonLoading.value = false));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (status === 'draft') {
|
|
|
|
|
proxy?.$modal.msgSuccess('暂存成功');
|
|
|
|
|
goBack();
|
|
|
|
|
} else {
|
|
|
|
|
// 提交审批流程
|
|
|
|
|
await handleStartWorkFlow();
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('保存合同信息失败:', error);
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
proxy?.$modal.msgSuccess('暂存成功');
|
|
|
|
|
proxy?.$tab.closePage();
|
|
|
|
|
router.go(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} finally {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 提交申请
|
|
|
|
|
const handleStartWorkFlow = async (data: ContractInfoForm) => {
|
|
|
|
|
try {
|
|
|
|
|
submitFormData.value.flowCode = 'OAC';
|
|
|
|
|
submitFormData.value.businessId = data.contractId;
|
|
|
|
|
|
|
|
|
|
// 流程变量
|
|
|
|
|
taskVariables.value = {
|
|
|
|
|
contractId: data.contractId,
|
|
|
|
|
contractName: data.contractName,
|
|
|
|
|
totalPrice: data.totalPrice,
|
|
|
|
|
contractCode: data.contractCode
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 流程实例业务扩展字段
|
|
|
|
|
flowInstanceBizExtBo.value = {
|
|
|
|
|
businessTitle: '合同审批',
|
|
|
|
|
businessCode: data.contractCode
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
submitFormData.value.variables = taskVariables.value;
|
|
|
|
|
submitFormData.value.bizExt = flowInstanceBizExtBo.value;
|
|
|
|
|
|
|
|
|
|
const resp = await startWorkFlow(submitFormData.value);
|
|
|
|
|
|
|
|
|
|
if (submitVerifyRef.value) {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
await submitVerifyRef.value.openDialog(resp.data.taskId);
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
router.go(-1);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 确认上传,仅关闭弹窗并依赖 v-model 同步到 ossId
|
|
|
|
|
@ -628,23 +689,6 @@ const submitOss = () => {
|
|
|
|
|
proxy?.$modal.msgSuccess('附件已更新');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 获取合同物料列表
|
|
|
|
|
const getContractMaterialList = async () => {
|
|
|
|
|
if (!form.value.contractId) return;
|
|
|
|
|
materialLoading.value = true;
|
|
|
|
|
try {
|
|
|
|
|
const res = await getErpContractMaterialList({
|
|
|
|
|
contractId: form.value.contractId
|
|
|
|
|
});
|
|
|
|
|
// 将获取到的数据存储到form中
|
|
|
|
|
(form.value as any).contractMaterialList = res.data || [];
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取合同物料列表失败:', error);
|
|
|
|
|
} finally {
|
|
|
|
|
materialLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 新增物料(新增合同时也可添加,不依赖contractId)
|
|
|
|
|
const handleAddMaterial = () => {
|
|
|
|
|
resetMaterialForm();
|
|
|
|
|
@ -732,12 +776,10 @@ const calculateTotalPrice = () => {
|
|
|
|
|
form.value.totalPrice = Number(total.toFixed(2));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 提交物料表单
|
|
|
|
|
// 提交物料表单 - 直接保存到本地数组
|
|
|
|
|
const submitMaterialForm = () => {
|
|
|
|
|
materialFormRef.value?.validate((valid: boolean) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
materialButtonLoading.value = true;
|
|
|
|
|
try {
|
|
|
|
|
// 确保contractMaterialList存在
|
|
|
|
|
if (!(form.value as any).contractMaterialList) {
|
|
|
|
|
(form.value as any).contractMaterialList = [];
|
|
|
|
|
@ -765,11 +807,6 @@ const submitMaterialForm = () => {
|
|
|
|
|
|
|
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
|
|
materialDialog.visible = false;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('保存合同物料失败:', error);
|
|
|
|
|
} finally {
|
|
|
|
|
materialButtonLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
@ -783,16 +820,16 @@ const loadSelectOptions = () => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
nextTick(async () => {
|
|
|
|
|
// 获取路由参数
|
|
|
|
|
routeParams.value = route.query || {};
|
|
|
|
|
|
|
|
|
|
const id = (route.query.id || route.params.id) as string | number;
|
|
|
|
|
routeParams.value = route.query;
|
|
|
|
|
loadSelectOptions();
|
|
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
|
const id = routeParams.value.id as string | number;
|
|
|
|
|
if (id && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'approval')) {
|
|
|
|
|
proxy?.$modal.loading('正在加载数据,请稍后...');
|
|
|
|
|
const res = await getContractInfo(id);
|
|
|
|
|
Object.assign(form.value, res.data);
|
|
|
|
|
|
|
|
|
|
proxy?.$modal.closeLoading();
|
|
|
|
|
|
|
|
|
|
// 编辑模式:如果已有合同编号,禁用生成按钮
|
|
|
|
|
@ -802,9 +839,6 @@ onMounted(async () => {
|
|
|
|
|
// 如果有合同但没有编号,允许生成
|
|
|
|
|
isCodeGenerated.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 加载合同物料列表
|
|
|
|
|
await getContractMaterialList();
|
|
|
|
|
} else {
|
|
|
|
|
// 新增模式:如果已有合同编号,禁用生成按钮
|
|
|
|
|
if (form.value.contractCode) {
|
|
|
|
|
@ -814,47 +848,23 @@ onMounted(async () => {
|
|
|
|
|
isCodeGenerated.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 启动审批流程
|
|
|
|
|
const handleStartWorkFlow = async () => {
|
|
|
|
|
try {
|
|
|
|
|
// 设置流程变量
|
|
|
|
|
taskVariables.value = {
|
|
|
|
|
contractId: form.value.contractId,
|
|
|
|
|
contractName: form.value.contractName,
|
|
|
|
|
totalPrice: form.value.totalPrice,
|
|
|
|
|
contractCode: form.value.contractCode
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 这里可以根据需要调用启动流程的API
|
|
|
|
|
// 由于合同审批流程在index.vue中已经实现,这里主要是处理审批中的状态
|
|
|
|
|
proxy?.$modal.msgSuccess('提交审批成功');
|
|
|
|
|
goBack();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('启动审批流程失败:', error);
|
|
|
|
|
proxy?.$modal.msgError('启动审批流程失败');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 审批验证打开
|
|
|
|
|
const approvalVerifyOpen = async () => {
|
|
|
|
|
if (submitVerifyRef.value && routeParams.value.taskId) {
|
|
|
|
|
submitVerifyRef.value.openDialog(routeParams.value.taskId);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 查看审批记录
|
|
|
|
|
// 审批记录
|
|
|
|
|
const handleApprovalRecord = () => {
|
|
|
|
|
if (approvalRecordRef.value && form.value.contractId) {
|
|
|
|
|
approvalRecordRef.value.init(form.value.contractId);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 提交回调
|
|
|
|
|
const submitCallback = async () => {
|
|
|
|
|
await proxy?.$tab.closePage(route);
|
|
|
|
|
window.history.go(-1);
|
|
|
|
|
await proxy?.$tab.closePage();
|
|
|
|
|
router.go(-1);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 审批
|
|
|
|
|
const approvalVerifyOpen = async () => {
|
|
|
|
|
await submitVerifyRef.value.openDialog(routeParams.value.taskId);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 监听上传组件返回的文件(ossId 串)并同步到表单字段
|
|
|
|
|
|