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();