From eafe86a54a8de20c56f1d8d7e98ff11031c43eb1 Mon Sep 17 00:00:00 2001 From: yinq Date: Fri, 12 Jun 2026 16:11:21 +0800 Subject: [PATCH] =?UTF-8?q?1.1.66=20=E5=90=88=E5=90=8C=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E5=90=8C=E6=BF=80=E6=B4=BB=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E6=AE=B5=EF=BC=9A=E5=AE=A2=E6=88=B7=E5=90=88?= =?UTF-8?q?=E5=90=8C=E7=BC=96=E5=8F=B7=E3=80=81=E6=9C=80=E7=BB=88=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E3=80=81=E5=AF=B9=E4=BA=BA=E6=B0=91=E5=B8=81=E6=B1=87?= =?UTF-8?q?=E7=8E=87=E3=80=81=E5=90=88=E5=90=8C=E6=BF=80=E6=B4=BB=E7=9A=84?= =?UTF-8?q?=E6=8A=84=E9=80=81=E4=BA=BA=E5=91=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/oa/erp/contractInfo/edit.vue | 210 ++++++++++++++++++------- 1 file changed, 156 insertions(+), 54 deletions(-) diff --git a/src/views/oa/erp/contractInfo/edit.vue b/src/views/oa/erp/contractInfo/edit.vue index e94f7b3..ee6112e 100644 --- a/src/views/oa/erp/contractInfo/edit.vue +++ b/src/views/oa/erp/contractInfo/edit.vue @@ -230,6 +230,37 @@ + @@ -384,22 +415,30 @@ 新增付款方式 - - - - - + + + + + + + @@ -837,6 +876,7 @@ import { MaterialInfoForm } from '@/api/oa/base/materialInfo/types'; import { getBasePaymentStageList } from '@/api/oa/base/paymentStage'; import type { PaymentStageVO } from '@/api/oa/base/paymentStage/types'; import { getCrmPaymentAccountList } from '@/api/oa/crm/paymentAccount'; +import { listContractOrder } from '@/api/oa/erp/contractOrder'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const route = useRoute(); @@ -883,6 +923,7 @@ const paymentMethodOptions = [ const buttonLoading = ref(false); const contractInfoFormRef = ref(); +const contractPaymentFormRef = ref(); // 审批相关组件引用 const submitVerifyRef = ref>(); @@ -971,6 +1012,52 @@ const getUserInfoListSelect = async () => { userInfoList.value = res.data; }; +/** 合同激活抄送人员 ID 列表(来自合同订单项目) */ +const activatePeopleIds = ref([]); + +/** 合同是否已激活 */ +const isContractActivated = computed(() => String(form.value.contractStatus) === '5'); + +/** 最终客户展示名称 */ +const finalCustomerDisplay = computed(() => { + const name = (form.value as any).finalCustomerName; + if (name) return name; + const id = (form.value as any).finalCustomerId; + if (!id) return ''; + const customer = customerInfoList.value.find((c: any) => String(c.customerId) === String(id)); + return customer?.customerName || String(id); +}); + +/** 合同激活抄送人员展示名称 */ +const activatePeopleDisplay = computed(() => { + if (!activatePeopleIds.value.length) return ''; + return activatePeopleIds.value + .map((id) => { + const user = userInfoList.value.find((u: any) => String(u.userId) === String(id)); + return user?.nickName || id; + }) + .join(','); +}); + +/** 加载合同激活抄送人员 */ +const loadActivatePeople = async (contractId: string | number) => { + try { + const orderRes = await listContractOrder({ contractId, pageNum: 1, pageSize: 10 } as any); + const orders = (orderRes as any).rows || []; + const peopleId = orders[0]?.peopleId; + if (peopleId) { + activatePeopleIds.value = String(peopleId) + .split(',') + .map((id) => id.trim()) + .filter(Boolean); + } else { + activatePeopleIds.value = []; + } + } catch { + activatePeopleIds.value = []; + } +}; + /** 付款节点下拉列表(回款阶段) */ const paymentStageList = ref([]); const getPaymentStageListSelect = async () => { @@ -1307,7 +1394,7 @@ const data = reactive<{ form: ContractInfoFormEx; rules: any }>({ shipMethod: [{ required: true, message: '运输方式不能为空', trigger: 'blur' }], deliveryStart: [{ required: true, message: '发货/交货期不能为空', trigger: 'blur' }], signingPlace: [{ required: true, message: '签订地点不能为空', trigger: 'blur' }], - paymentMethod: [{ required: true, message: '请选择付款形式', trigger: 'blur' }] + paymentMethod: [{ required: true, message: '请选择付款形式', trigger: 'change' }] } }); @@ -1478,46 +1565,58 @@ const handleFile = () => { ossFileModel.value = form.value.ossId as any; }; +const validateFormRef = (formRef: ElFormInstance | undefined) => + new Promise((resolve) => { + if (!formRef) { + resolve(true); + return; + } + formRef.validate((valid: boolean) => resolve(valid)); + }); + /** 提交按钮 */ -const submitForm = (status: string, mode: boolean) => { +const submitForm = async (status: string, mode: boolean) => { try { - contractInfoFormRef.value?.validate(async (valid: boolean) => { - if (valid) { - const paymentList = (form.value as any).contractPaymentMethodList; - if (!Array.isArray(paymentList) || paymentList.length === 0) { - proxy?.$modal.msgWarning('请维护合同付款方式'); - return; - } - const materialList = (form.value as any).contractMaterialList; - if (!Array.isArray(materialList) || materialList.length === 0) { - proxy?.$modal.msgWarning('请维护合同物料'); - return; - } - buttonLoading.value = true; - // 设置后端发起和不等于草稿状态 直接走流程发起 - if (status != 'draft') { - // 走流程所需的 flowCode/variables/bizExt/状态字段,由后端 contractSubmitAndFlowStart 统一补齐并落库 - const res = await contractSubmitAndFlowStart(form.value).finally(() => (buttonLoading.value = false)); - form.value = res.data; - 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)); - } - proxy?.$modal.msgSuccess('暂存成功'); - proxy?.$tab.closePage(); - router.go(-1); - } + const [mainValid, paymentValid] = await Promise.all([ + validateFormRef(contractInfoFormRef.value), + validateFormRef(contractPaymentFormRef.value) + ]); + if (!mainValid || !paymentValid) { + return; + } + const paymentList = (form.value as any).contractPaymentMethodList; + if (!Array.isArray(paymentList) || paymentList.length === 0) { + proxy?.$modal.msgWarning('请维护合同付款方式'); + return; + } + const materialList = (form.value as any).contractMaterialList; + if (!Array.isArray(materialList) || materialList.length === 0) { + proxy?.$modal.msgWarning('请维护合同物料'); + return; + } + buttonLoading.value = true; + // 设置后端发起和不等于草稿状态 直接走流程发起 + if (status != 'draft') { + // 走流程所需的 flowCode/variables/bizExt/状态字段,由后端 contractSubmitAndFlowStart 统一补齐并落库 + const res = await contractSubmitAndFlowStart(form.value).finally(() => (buttonLoading.value = false)); + form.value = res.data; + 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)); + } + proxy?.$modal.msgSuccess('暂存成功'); + proxy?.$tab.closePage(); + router.go(-1); + } } catch (e) { console.error(e); } finally { @@ -1886,6 +1985,9 @@ onMounted(async () => { proxy?.$modal.loading('正在加载数据,请稍后...'); const res = await getContractInfo(id); Object.assign(form.value, res.data); + if (isContractActivated.value) { + await loadActivatePeople(id); + } proxy?.$modal.closeLoading();