1.0.15 合同审批逻辑

dev
yinq 2 months ago
parent ce33ae36f1
commit 23a08a288e

@ -4,6 +4,17 @@
<template #header>
<div style="text-align: left; font-weight: bold; font-size: 24px">合同{{ form.contractId ? ' - 修改' : ' - 新增' }}</div>
</template>
<!-- 审批按钮组件 -->
<approvalButton
@submitForm="submitForm"
@approvalVerifyOpen="approvalVerifyOpen"
@handleApprovalRecord="handleApprovalRecord"
:buttonLoading="buttonLoading"
:id="form.contractId"
:status="form.contractStatus"
:pageType="routeParams.type"
:mode="false"
/>
<el-form ref="contractInfoFormRef" :model="form" :rules="rules" label-width="120px">
<el-row :gutter="20">
<el-col :span="12">
@ -199,10 +210,10 @@
</el-table-column>
</el-table>
<el-card shadow="never" style="margin-top: 20px">
<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"> </el-button>
<el-button :loading="buttonLoading" type="primary" @click="() => submitForm('draft', false)"> </el-button>
<el-button @click="goBack"> </el-button>
</el-form-item>
</el-col>
@ -349,6 +360,11 @@
</div>
</template>
</el-dialog>
<!-- 提交审批组件 -->
<submitVerify ref="submitVerifyRef" :task-variables="taskVariables" @submit-callback="submitCallback" />
<!-- 审批记录 -->
<approvalRecord ref="approvalRecordRef" />
</div>
</template>
@ -360,6 +376,9 @@ import { ContractMaterialVO, ContractMaterialForm } from '@/api/oa/erp/contractM
import { getBaseUnitInfoList } from '@/api/oa/base/unitInfo';
import { getRuleGenerateCode } from '@/api/system/codeRule';
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 { getCrmCustomerInfoList } from '@/api/oa/crm/customerInfo';
@ -367,6 +386,9 @@ import { getBasePrintTemplateList } from '@/api/oa/base/printTemplate';
const route = useRoute();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
//
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')
);
@ -374,6 +396,13 @@ const { contract_category, business_direction, active_flag, contract_flag, contr
const buttonLoading = ref(false);
const contractInfoFormRef = ref<ElFormInstance>();
//
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
//
const taskVariables = ref<Record<string, any>>({});
const type = ref(0);
const dialog = reactive<DialogOption>({
visible: false,
@ -565,17 +594,28 @@ const handleFile = () => {
ossFileModel.value = form.value.ossId as any;
};
const submitForm = () => {
const submitForm = (status: string, mode: boolean) => {
contractInfoFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.contractId) {
await updateContractInfo(form.value).finally(() => (buttonLoading.value = false));
} else {
await addContractInfo(form.value).finally(() => (buttonLoading.value = false));
try {
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('操作成功');
goBack();
}
});
};
@ -743,8 +783,12 @@ const loadSelectOptions = () => {
};
onMounted(async () => {
//
routeParams.value = route.query || {};
const id = (route.query.id || route.params.id) as string | number;
loadSelectOptions();
if (id) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const res = await getContractInfo(id);
@ -772,6 +816,47 @@ onMounted(async () => {
}
});
//
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);
};
// ossId
//
watch(

@ -154,7 +154,7 @@
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="100" fixed="right" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" width="150" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/erp:contractInfo:edit']"></el-button>
@ -165,6 +165,12 @@
<el-tooltip content="上传终版合同" placement="top" v-if="!scope.row.signatureAppendix">
<el-button link type="success" icon="Upload" @click="openUploadFinalDialog(scope.row)" v-hasPermi="['oa/erp:contractInfo:edit']"></el-button>
</el-tooltip>
<el-tooltip content="提交审批" placement="top" v-if="scope.row.contractStatus === '1'">
<el-button link type="warning" icon="Check" @click="handleSubmitApproval(scope.row)" v-hasPermi="['oa/erp:contractInfo:edit']"></el-button>
</el-tooltip>
<el-tooltip content="审批记录" placement="top" v-if="scope.row.contractStatus === '2' || scope.row.contractStatus === '3'">
<el-button link type="info" icon="View" @click="handleApprovalRecord(scope.row)"></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
@ -186,6 +192,11 @@
</div>
</template>
</el-dialog>
<!-- 审批记录 -->
<ApprovalRecord ref="approvalRecordRef" />
<!-- 提交审批组件 -->
<SubmitVerify ref="submitVerifyRef" :task-variables="taskVariables" @submit-callback="submitCallback" />
</div>
</template>
@ -194,6 +205,10 @@ import { listContractInfo, delContractInfo } from '@/api/oa/erp/contractInfo';
import { ContractInfoVO, ContractInfoQuery } from '@/api/oa/erp/contractInfo/types';
import { updateContractInfo } from '@/api/oa/erp/contractInfo';
import download from '@/plugins/download';
import { startWorkFlow } from '@/api/workflow/task';
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
import SubmitVerify from '@/components/Process/submitVerify.vue';
import { StartProcessBo } from '@/api/workflow/workflowCommon/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { contract_category, business_direction, active_flag, contract_flag, contract_type, contract_status } = toRefs<any>(
@ -209,6 +224,11 @@ const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
//
const taskVariables = ref<Record<string, any>>({});
//
const columns = ref<FieldOption[]>([
@ -320,13 +340,22 @@ const handleSelectionChange = (selection: ContractInfoVO[]) => {
/** 新增按钮操作 */
const handleAdd = () => {
proxy?.$tab.openPage('/oa/erp/contractInfo/edit', '添加市场销售合同');
proxy.$tab.closePage(proxy.$route);
proxy.$router.push({
path: '/contract/contractInfo/edit',
query: {}
});
};
/** 修改按钮操作 */
const handleUpdate = (row?: ContractInfoVO) => {
const _contractId = row?.contractId || ids.value[0];
proxy?.$tab.openPage(`/oa/erp/contractInfo/edit`, '合同信息-修改', { id: _contractId });
proxy.$router.push({
path: '/contract/contractInfo/edit',
query: {
id: _contractId
}
});
};
/** 删除按钮操作 */
@ -382,4 +411,72 @@ const confirmUploadFinal = async () => {
const downloadFinalContract = (ossId: string | number) => {
download.oss(ossId);
};
//
const handleSubmitApproval = async (row: ContractInfoVO) => {
try {
//
await proxy?.$modal.confirm('确认提交该合同进行审批?');
//
const submitFormData: StartProcessBo = {
businessId: row.contractId.toString(),
flowCode: 'OAC', // 使
variables: {
//
contractId: row.contractId,
contractName: row.contractName,
totalPrice: row.totalPrice
},
bizExt: {
businessTitle: '合同审批',
businessCode: row.contractId
}
};
//
taskVariables.value = {
contractId: row.contractId,
contractName: row.contractName,
totalPrice: row.totalPrice,
contractCode: row.contractCode
};
// ID
const resp = await startWorkFlow(submitFormData);
//
await updateContractInfo({
contractId: row.contractId,
contractStatus: '2',
flowStatus: 'waiting'
} as any);
//
if (submitVerifyRef.value && resp.data && resp.data.taskId) {
submitVerifyRef.value.openDialog(resp.data.taskId);
} else {
proxy?.$modal.msgSuccess('审批流程已启动');
await getList();
}
} catch (error) {
//
if (error === 'cancel') {
return;
}
console.error('提交审批失败:', error);
proxy?.$modal.msgError('提交审批失败,请重试');
}
};
//
const handleApprovalRecord = (row: ContractInfoVO) => {
approvalRecordRef.value?.init(row.contractId);
};
//
const submitCallback = async () => {
proxy?.$modal.msgSuccess('审批操作成功');
await getList();
};
</script>

Loading…
Cancel
Save