|
|
|
|
@ -230,6 +230,37 @@
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<template v-if="isContractActivated">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="客户合同编号">
|
|
|
|
|
<el-input v-model="form.customerContractCode" disabled placeholder="-" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="最终客户">
|
|
|
|
|
<el-input :model-value="finalCustomerDisplay" disabled placeholder="-" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="对人民币汇率">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="form.rmbExchangeRate"
|
|
|
|
|
:min="0"
|
|
|
|
|
:precision="4"
|
|
|
|
|
:step="0.0001"
|
|
|
|
|
controls-position="right"
|
|
|
|
|
disabled
|
|
|
|
|
placeholder="-"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="激活抄送人员">
|
|
|
|
|
<el-input :model-value="activatePeopleDisplay" disabled placeholder="-" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- <el-col :span="12">-->
|
|
|
|
|
<!-- <el-form-item label="流程状态" prop="flowStatus">-->
|
|
|
|
|
<!-- <el-input v-model="form.flowStatus" placeholder="请输入流程状态" />-->
|
|
|
|
|
@ -384,22 +415,30 @@
|
|
|
|
|
<el-button type="primary" icon="Plus" v-if="!isFormDisabled" @click="handleAddPaymentMethod"
|
|
|
|
|
>新增付款方式
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-form-item label="付款形式" prop="paymentMethod" style="margin-bottom: 0; width: 360px">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="form.paymentMethod"
|
|
|
|
|
placeholder="请选择付款形式"
|
|
|
|
|
:disabled="isFormDisabled"
|
|
|
|
|
clearable
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in paymentMethodOptions"
|
|
|
|
|
:key="item"
|
|
|
|
|
:label="item"
|
|
|
|
|
:value="item"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form
|
|
|
|
|
ref="contractPaymentFormRef"
|
|
|
|
|
:model="form"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
label-width="120px"
|
|
|
|
|
style="margin-bottom: 0; width: 360px"
|
|
|
|
|
>
|
|
|
|
|
<el-form-item label="付款形式" prop="paymentMethod" style="margin-bottom: 0">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="form.paymentMethod"
|
|
|
|
|
placeholder="请选择付款形式"
|
|
|
|
|
:disabled="isFormDisabled"
|
|
|
|
|
clearable
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in paymentMethodOptions"
|
|
|
|
|
:key="item"
|
|
|
|
|
:label="item"
|
|
|
|
|
:value="item"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
<el-table :data="contractPaymentMethodList" v-loading="buttonLoading" border>
|
|
|
|
|
<el-table-column label="序号" align="center" prop="sortOrder" width="80" />
|
|
|
|
|
@ -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<ElFormInstance>();
|
|
|
|
|
const contractPaymentFormRef = ref<ElFormInstance>();
|
|
|
|
|
|
|
|
|
|
// 审批相关组件引用
|
|
|
|
|
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
|
|
|
|
|
@ -971,6 +1012,52 @@ const getUserInfoListSelect = async () => {
|
|
|
|
|
userInfoList.value = res.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 合同激活抄送人员 ID 列表(来自合同订单项目) */
|
|
|
|
|
const activatePeopleIds = ref<string[]>([]);
|
|
|
|
|
|
|
|
|
|
/** 合同是否已激活 */
|
|
|
|
|
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<PaymentStageVO[]>([]);
|
|
|
|
|
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<boolean>((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();
|
|
|
|
|
|
|
|
|
|
|