|
|
|
|
@ -14,6 +14,37 @@
|
|
|
|
|
/>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<!-- 全部到货确认区块:仅到货确认节点允许申请人录入 -->
|
|
|
|
|
<el-card v-if="isArrivalConfirmApprover" shadow="never" style="margin-top: 10px; border: 1px solid #e6a23c">
|
|
|
|
|
<template #header>
|
|
|
|
|
<div style="text-align: left; font-weight: bold; font-size: 16px; color: #e6a23c">
|
|
|
|
|
<el-icon style="margin-right: 6px"><Warning /></el-icon>全部到货确认
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<el-form :model="arrivalConfirmForm" label-width="120px" ref="arrivalConfirmFormRef">
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="全部到货标识" prop="isAllReceiving" :rules="[{ required: true, message: '请选择全部到货标识', trigger: 'change' }]">
|
|
|
|
|
<el-radio-group v-model="arrivalConfirmForm.isAllReceiving">
|
|
|
|
|
<el-radio-button v-for="dict in is_all_receiving" :key="dict.value" :label="dict.value">
|
|
|
|
|
{{ dict.label }}
|
|
|
|
|
</el-radio-button>
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item
|
|
|
|
|
label="收货单附件"
|
|
|
|
|
prop="arrivalReceiptOssId"
|
|
|
|
|
:rules="[{ required: arrivalConfirmForm.isAllReceiving === '0', message: '全部到货必须上传收货单', trigger: 'change' }]"
|
|
|
|
|
>
|
|
|
|
|
<fileUpload v-model="arrivalConfirmForm.arrivalReceiptOssId" :limit="5" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<!-- 基本信息区域 -->
|
|
|
|
|
<el-card shadow="never" style="margin-top: 0">
|
|
|
|
|
<template #header>
|
|
|
|
|
@ -30,11 +61,17 @@
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="发货单号" prop="shippingCode">
|
|
|
|
|
<el-input v-model="form.shippingCode" placeholder="请输入发货单号">
|
|
|
|
|
<template #append>
|
|
|
|
|
<el-button type="primary" @click="generateShippingCode" :disabled="isCodeGenerated">生成单号</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-input>
|
|
|
|
|
<el-input v-model="form.shippingCode" placeholder="由系统自动生成" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="发货类型" prop="shippingType">
|
|
|
|
|
<el-select v-model="form.shippingType" placeholder="请选择发货类型" style="width: 100%">
|
|
|
|
|
<!-- <el-option label="普通发货" value="1" />
|
|
|
|
|
<el-option label="备件发货" value="2" />
|
|
|
|
|
<el-option label="物流发货" value="3" /> -->
|
|
|
|
|
<el-option v-for="dict in shipping_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
@ -168,6 +205,25 @@
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
<el-form label-width="120px">
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="抄送人员" prop="tManagerId">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="form.tManagerId"
|
|
|
|
|
placeholder="请选择抄送人员"
|
|
|
|
|
:disabled="copyManagerDisabled"
|
|
|
|
|
clearable
|
|
|
|
|
filterable
|
|
|
|
|
multiple
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
>
|
|
|
|
|
<el-option v-for="user in userList" :key="user.userId" :label="user.nickName" :value="user.userId" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<!-- 物流信息区域 -->
|
|
|
|
|
@ -401,8 +457,17 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup name="WmsShippingBillEdit" lang="ts">
|
|
|
|
|
import { addWmsShippingBill, getWmsShippingBill, shippingBillSubmitAndFlowStart, updateWmsShippingBill } from '@/api/wms/wmsShippingBill';
|
|
|
|
|
import { WmsShippingBillForm } from '@/api/wms/wmsShippingBill/types';
|
|
|
|
|
import {
|
|
|
|
|
addWmsShippingBill,
|
|
|
|
|
arrivalConfirmShippingBill,
|
|
|
|
|
getWmsShippingBill,
|
|
|
|
|
shippingBillSubmitAndFlowStart,
|
|
|
|
|
updateWmsShippingBill
|
|
|
|
|
} from '@/api/wms/wmsShippingBill';
|
|
|
|
|
import { WmsShippingArrivalConfirmForm, WmsShippingBillForm } from '@/api/wms/wmsShippingBill/types';
|
|
|
|
|
import { useUserStore } from '@/store/modules/user';
|
|
|
|
|
import { getTask } from '@/api/workflow/task';
|
|
|
|
|
import type { FlowTaskVO } from '@/api/workflow/task/types';
|
|
|
|
|
import { WmsShippingDetailsForm } from '@/api/wms/wmsShippingDetails/types';
|
|
|
|
|
import { listInventoryDetails } from '@/api/wms/inventoryDetails';
|
|
|
|
|
import { InventoryDetailsQuery, InventoryDetailsVO } from '@/api/wms/inventoryDetails/types';
|
|
|
|
|
@ -411,32 +476,83 @@ import { getCrmCustomerInfoList } from '@/api/oa/crm/customerInfo';
|
|
|
|
|
import { getCrmCustomerContactList } from '@/api/oa/crm/customerContact';
|
|
|
|
|
import type { CustomerContactVO } from '@/api/oa/crm/customerContact/types';
|
|
|
|
|
import { getCrmSupplierInfoList } from '@/api/oa/crm/crmSupplierInfo';
|
|
|
|
|
import { getRuleGenerateCode } from '@/api/system/codeRule';
|
|
|
|
|
import { listUser } from '@/api/system/user';
|
|
|
|
|
import type { UserQuery } from '@/api/system/user/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 ProjectSelect from '@/components/ProjectSelect/index.vue';
|
|
|
|
|
import type { ProjectInfoVO } from '@/api/oa/erp/projectInfo/types';
|
|
|
|
|
import { listContractInfo } from '@/api/oa/erp/contractInfo';
|
|
|
|
|
import { getProjectInfo } from '@/api/oa/erp/projectInfo';
|
|
|
|
|
import { getContractInfo, listContractInfo } from '@/api/oa/erp/contractInfo';
|
|
|
|
|
import type { ContractInfoQuery, ContractInfoVO } from '@/api/oa/erp/contractInfo/types';
|
|
|
|
|
import { CodeRuleEnum, FlowCodeEnum } from '@/enums/OAEnum';
|
|
|
|
|
import { Search } from '@element-plus/icons-vue';
|
|
|
|
|
import { FlowCodeEnum } from '@/enums/OAEnum';
|
|
|
|
|
import { Search, Warning } from '@element-plus/icons-vue';
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
|
|
|
|
// 路由参数
|
|
|
|
|
const routeParams = ref<Record<string, any>>({});
|
|
|
|
|
|
|
|
|
|
// 字典
|
|
|
|
|
const { shipping_mode, shipping_status, shipping_bill_status, material_source_type } = toRefs<any>(
|
|
|
|
|
proxy?.useDict('shipping_mode', 'shipping_status', 'shipping_bill_status', 'material_source_type')
|
|
|
|
|
const { shipping_mode, shipping_status, shipping_bill_status, material_source_type, shipping_type, is_all_receiving } = toRefs<any>(
|
|
|
|
|
proxy?.useDict('shipping_mode', 'shipping_status', 'shipping_bill_status', 'material_source_type', 'shipping_type', 'is_all_receiving')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const buttonLoading = ref(false);
|
|
|
|
|
const shippingBillFormRef = ref<ElFormInstance>();
|
|
|
|
|
const arrivalConfirmFormRef = ref<ElFormInstance>();
|
|
|
|
|
|
|
|
|
|
// 到货确认表单数据
|
|
|
|
|
const arrivalConfirmForm = ref<WmsShippingArrivalConfirmForm>({
|
|
|
|
|
shippingBillId: '',
|
|
|
|
|
isAllReceiving: '0',
|
|
|
|
|
arrivalReceiptOssId: '',
|
|
|
|
|
taskId: ''
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => arrivalConfirmForm.value.isAllReceiving,
|
|
|
|
|
() => {
|
|
|
|
|
arrivalConfirmFormRef.value?.clearValidate(['arrivalReceiptOssId']);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const currentTask = ref<FlowTaskVO | null>(null);
|
|
|
|
|
|
|
|
|
|
// 是否显示到货确认区块:审批模式 + 到货确认节点 + 当前用户是申请人
|
|
|
|
|
const isArrivalConfirmApprover = computed(() => {
|
|
|
|
|
return (
|
|
|
|
|
routeParams.value.type === 'approval' &&
|
|
|
|
|
form.value.needArrivalConfirm === '1' &&
|
|
|
|
|
currentTask.value?.nodeCode === 'arrival-confirm' &&
|
|
|
|
|
String(currentTask.value?.businessId || '') === String(form.value.shippingBillId || '') &&
|
|
|
|
|
String(userStore.userId) === String(form.value.createBy)
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const isArrivalConfirmNode = computed(() => {
|
|
|
|
|
return (
|
|
|
|
|
routeParams.value.type === 'approval' &&
|
|
|
|
|
currentTask.value?.nodeCode === 'arrival-confirm' &&
|
|
|
|
|
String(currentTask.value?.businessId || '') === String(form.value.shippingBillId || '')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const canEditCopyManager = computed(() => {
|
|
|
|
|
if (routeParams.value.type === 'view') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const flowStatus = String(form.value.flowStatus || '');
|
|
|
|
|
// Why:字段级权限仅控制“抄送人员”,规则为草稿可改、到货确认节点可改
|
|
|
|
|
return flowStatus === 'draft' || isArrivalConfirmNode.value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const copyManagerDisabled = computed(() => !canEditCopyManager.value);
|
|
|
|
|
|
|
|
|
|
// 审批相关组件引用
|
|
|
|
|
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
|
|
|
|
|
@ -445,13 +561,11 @@ const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
|
|
|
|
|
// 任务变量
|
|
|
|
|
const taskVariables = ref<Record<string, any>>({});
|
|
|
|
|
|
|
|
|
|
// 发货单号生成状态
|
|
|
|
|
const isCodeGenerated = ref(false);
|
|
|
|
|
|
|
|
|
|
// 物料来源类型(1-ERP物料,2-WMS物料),默认使用WMS物料
|
|
|
|
|
const materialSourceType = ref('2');
|
|
|
|
|
|
|
|
|
|
// 下拉数据源
|
|
|
|
|
const userList = ref<any[]>([]);
|
|
|
|
|
const customerList = ref<any[]>([]);
|
|
|
|
|
const supplierList = ref<any[]>([]);
|
|
|
|
|
const warehouseList = ref<any[]>([]);
|
|
|
|
|
@ -549,7 +663,6 @@ const validateContractWhenBind = (rule: any, value: any, callback: any) => {
|
|
|
|
|
const data = reactive<{ form: WmsShippingBillForm; rules: any }>({
|
|
|
|
|
form: { ...initFormData },
|
|
|
|
|
rules: {
|
|
|
|
|
shippingCode: [{ required: true, message: '发货单号不能为空', trigger: 'blur' }],
|
|
|
|
|
shippingMode: [{ required: true, message: '发货方式不能为空', trigger: 'change' }],
|
|
|
|
|
bindType: [{ required: true, message: '绑定类型不能为空', trigger: 'change' }],
|
|
|
|
|
projectId: [{ validator: validateProjectOrContract, trigger: 'change' }],
|
|
|
|
|
@ -560,17 +673,90 @@ const data = reactive<{ form: WmsShippingBillForm; rules: any }>({
|
|
|
|
|
|
|
|
|
|
const { form, rules } = toRefs(data);
|
|
|
|
|
|
|
|
|
|
/** 生成发货单号 */
|
|
|
|
|
const generateShippingCode = async () => {
|
|
|
|
|
if (isCodeGenerated.value) return; // 如果已经生成过,直接返回
|
|
|
|
|
try {
|
|
|
|
|
const params = { codeRuleCode: CodeRuleEnum.SHIPPING_BILL } as any;
|
|
|
|
|
const res = await getRuleGenerateCode(params);
|
|
|
|
|
form.value.shippingCode = res.msg;
|
|
|
|
|
isCodeGenerated.value = true;
|
|
|
|
|
proxy?.$modal.msgSuccess('发货单号生成成功');
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('生成发货单号失败:', error);
|
|
|
|
|
const normalizeWorkflowUserIds = (value: unknown): string | undefined => {
|
|
|
|
|
if (Array.isArray(value)) {
|
|
|
|
|
const ids = value.map((item) => String(item ?? '').trim()).filter((item) => item.length > 0);
|
|
|
|
|
return ids.length > 0 ? ids.join(',') : undefined;
|
|
|
|
|
}
|
|
|
|
|
if (value === undefined || value === null) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
const text = String(value).trim();
|
|
|
|
|
return text.length > 0 ? text : undefined;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const toWorkflowUserIdArray = (value: unknown): (string | number)[] | undefined => {
|
|
|
|
|
const text = normalizeWorkflowUserIds(value);
|
|
|
|
|
if (!text) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
return text
|
|
|
|
|
.split(',')
|
|
|
|
|
.map((id) => id.trim())
|
|
|
|
|
.filter((id) => id.length > 0);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const buildFlowCopyVariables = async (submitData: WmsShippingBillForm) => {
|
|
|
|
|
let tManagerId = normalizeWorkflowUserIds((submitData as any).tManagerId);
|
|
|
|
|
const bindType = submitData.bindType;
|
|
|
|
|
|
|
|
|
|
// 先使用页面已有口径(合同负责人/项目抄送人),避免每次都发起远程查询
|
|
|
|
|
if (!tManagerId && bindType === '2') {
|
|
|
|
|
tManagerId = normalizeWorkflowUserIds((submitData as any).contractManagerId);
|
|
|
|
|
}
|
|
|
|
|
if (!tManagerId && bindType === '1') {
|
|
|
|
|
tManagerId = normalizeWorkflowUserIds((submitData as any).peopleId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 绑定合同时优先取合同负责人作为流程抄送人,保证流程变量完整
|
|
|
|
|
// Why:统一归一为 tManagerId,流程节点只关心当前业务口径下的实际抄送人
|
|
|
|
|
if (bindType === '2' && !tManagerId && submitData.contractId) {
|
|
|
|
|
try {
|
|
|
|
|
const contractRes = await getContractInfo(submitData.contractId);
|
|
|
|
|
tManagerId = normalizeWorkflowUserIds((contractRes.data as any)?.contractManagerId);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('加载合同负责人失败:', error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 绑定项目时兜底取项目负责人,防止流程变量缺失
|
|
|
|
|
if (bindType === '1' && !tManagerId && submitData.projectId) {
|
|
|
|
|
try {
|
|
|
|
|
const projectRes = await getProjectInfo(submitData.projectId);
|
|
|
|
|
tManagerId = normalizeWorkflowUserIds((projectRes.data as any)?.peopleId);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('加载抄送人员失败:', error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { tManagerId };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const prepareTaskVariables = async () => {
|
|
|
|
|
const { tManagerId } = await buildFlowCopyVariables(form.value as WmsShippingBillForm);
|
|
|
|
|
if (tManagerId) {
|
|
|
|
|
// Why:到货确认节点配置了 ${tManagerId} 抄送表达式,审批时必须显式传入,避免解析为空
|
|
|
|
|
taskVariables.value = { tManagerId };
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// 部门负责人节点流转到到货确认节点时,若未传 tManagerId 会触发流程抄送解析异常
|
|
|
|
|
if (currentTask.value?.nodeCode === 'dept-leader') {
|
|
|
|
|
proxy?.$modal.msgError('未获取到到货确认抄送人ID(tManagerId),请先维护合同负责人或项目抄送人员');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
taskVariables.value = {};
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const syncCopyManagerSelection = async () => {
|
|
|
|
|
const current = normalizeWorkflowUserIds((form.value as any).tManagerId);
|
|
|
|
|
if (current) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const { tManagerId } = await buildFlowCopyVariables(form.value as WmsShippingBillForm);
|
|
|
|
|
if (tManagerId) {
|
|
|
|
|
// Why:编辑历史单据时回显抄送人员,保持与 orderActivate 一样“可见可改”
|
|
|
|
|
(form.value as any).tManagerId = toWorkflowUserIdArray(tManagerId);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -604,6 +790,9 @@ const submitContractSelect = () => {
|
|
|
|
|
form.value.contractId = contract.contractId as any;
|
|
|
|
|
form.value.contractCode = contract.contractCode || '';
|
|
|
|
|
form.value.contractName = contract.contractName || '';
|
|
|
|
|
const contractManagerId = normalizeWorkflowUserIds((contract as any).contractManagerId);
|
|
|
|
|
(form.value as any).contractManagerId = contractManagerId;
|
|
|
|
|
(form.value as any).tManagerId = toWorkflowUserIdArray(contractManagerId);
|
|
|
|
|
selectedContractName.value = contract.contractName || '';
|
|
|
|
|
// SAP订单号来自合同的 orderContractCode
|
|
|
|
|
selectedSapOrderCode.value = (contract as any).orderContractCode || '';
|
|
|
|
|
@ -632,6 +821,9 @@ const projectInfoSelectCallBack = (data: ProjectInfoVO[]) => {
|
|
|
|
|
form.value.projectId = project.projectId;
|
|
|
|
|
form.value.projectCode = project.projectCode || '';
|
|
|
|
|
form.value.projectName = project.projectName || '';
|
|
|
|
|
const peopleId = normalizeWorkflowUserIds((project as any).peopleId);
|
|
|
|
|
(form.value as any).peopleId = peopleId;
|
|
|
|
|
(form.value as any).tManagerId = toWorkflowUserIdArray(peopleId);
|
|
|
|
|
selectedProjectName.value = project.projectName || '';
|
|
|
|
|
// 如果项目有关联客户,自动带入
|
|
|
|
|
if (project.customerId) {
|
|
|
|
|
@ -822,14 +1014,22 @@ const submitForm = async (status: string, mode: boolean) => {
|
|
|
|
|
const submitData = { ...form.value };
|
|
|
|
|
|
|
|
|
|
if (status !== 'draft') {
|
|
|
|
|
// 提交流程:设置流程编码与变量,驱动审批流
|
|
|
|
|
// 提交审批 - 后端发起流程模式
|
|
|
|
|
submitData.flowCode = FlowCodeEnum.SHIPPING_BILL_CODE;
|
|
|
|
|
const { tManagerId } = await buildFlowCopyVariables(submitData);
|
|
|
|
|
if (!tManagerId) {
|
|
|
|
|
proxy?.$modal.msgError('未获取到到货确认抄送人ID(tManagerId),请先维护合同负责人或项目抄送人员');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
submitData.tManagerId = tManagerId;
|
|
|
|
|
// 流程变量
|
|
|
|
|
submitData.variables = {
|
|
|
|
|
shippingBillId: submitData.shippingBillId,
|
|
|
|
|
shippingCode: submitData.shippingCode,
|
|
|
|
|
projectName: submitData.projectName,
|
|
|
|
|
customerName: submitData.customerName
|
|
|
|
|
customerName: submitData.customerName,
|
|
|
|
|
tManagerId
|
|
|
|
|
};
|
|
|
|
|
// 流程实例业务扩展字段
|
|
|
|
|
submitData.bizExt = {
|
|
|
|
|
@ -844,6 +1044,7 @@ const submitForm = async (status: string, mode: boolean) => {
|
|
|
|
|
form.value = res.data;
|
|
|
|
|
proxy?.$modal.msgSuccess('提交成功');
|
|
|
|
|
} else {
|
|
|
|
|
// 暂存仅做草稿保存,不触发流程
|
|
|
|
|
// 暂存
|
|
|
|
|
submitData.outStockBillStatus = '1';
|
|
|
|
|
submitData.flowStatus = 'draft';
|
|
|
|
|
@ -867,16 +1068,16 @@ const submitForm = async (status: string, mode: boolean) => {
|
|
|
|
|
/** 加载下拉数据 */
|
|
|
|
|
const loadSelectOptions = async () => {
|
|
|
|
|
try {
|
|
|
|
|
// 加载客户列表
|
|
|
|
|
const customerRes = await getCrmCustomerInfoList(null);
|
|
|
|
|
const userQuery: UserQuery = { pageNum: 1, pageSize: 9999 };
|
|
|
|
|
const [userRes, customerRes, supplierRes, warehouseRes] = await Promise.all([
|
|
|
|
|
listUser(userQuery),
|
|
|
|
|
getCrmCustomerInfoList(null),
|
|
|
|
|
getCrmSupplierInfoList(null),
|
|
|
|
|
getWmsWarehouseInfoList(null)
|
|
|
|
|
]);
|
|
|
|
|
userList.value = userRes.rows || [];
|
|
|
|
|
customerList.value = customerRes.data || [];
|
|
|
|
|
|
|
|
|
|
// 加载供应商列表
|
|
|
|
|
const supplierRes = await getCrmSupplierInfoList(null);
|
|
|
|
|
supplierList.value = supplierRes.data || [];
|
|
|
|
|
|
|
|
|
|
// 加载仓库列表
|
|
|
|
|
const warehouseRes = await getWmsWarehouseInfoList(null);
|
|
|
|
|
warehouseList.value = warehouseRes.data || [];
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('加载下拉数据失败:', error);
|
|
|
|
|
@ -888,6 +1089,10 @@ const loadFormData = async (id: string | number) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getWmsShippingBill(id);
|
|
|
|
|
Object.assign(form.value, res.data);
|
|
|
|
|
await syncCopyManagerSelection();
|
|
|
|
|
arrivalConfirmForm.value.shippingBillId = res.data.shippingBillId;
|
|
|
|
|
arrivalConfirmForm.value.isAllReceiving = res.data.isAllReceiving || '0';
|
|
|
|
|
arrivalConfirmForm.value.arrivalReceiptOssId = res.data.arrivalReceiptOssId || '';
|
|
|
|
|
selectedProjectName.value = form.value.projectName || '';
|
|
|
|
|
selectedContractName.value = form.value.contractName || '';
|
|
|
|
|
// SAP订单号(来自后端联查合同表)
|
|
|
|
|
@ -916,11 +1121,6 @@ const loadFormData = async (id: string | number) => {
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果已有单号,禁用生成按钮
|
|
|
|
|
if (form.value.shippingCode) {
|
|
|
|
|
isCodeGenerated.value = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑模式下:如果有客户ID,加载客户联系人列表
|
|
|
|
|
if (form.value.customerId) {
|
|
|
|
|
try {
|
|
|
|
|
@ -935,6 +1135,22 @@ const loadFormData = async (id: string | number) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const loadCurrentTask = async () => {
|
|
|
|
|
if (routeParams.value.type !== 'approval' || !routeParams.value.taskId) {
|
|
|
|
|
currentTask.value = null;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const res = await getTask(String(routeParams.value.taskId));
|
|
|
|
|
currentTask.value = res.data;
|
|
|
|
|
return !!currentTask.value;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
currentTask.value = null;
|
|
|
|
|
console.error('加载当前审批任务失败:', error);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 审批记录
|
|
|
|
|
const handleApprovalRecord = () => {
|
|
|
|
|
approvalRecordRef.value?.init(form.value.shippingBillId);
|
|
|
|
|
@ -946,22 +1162,52 @@ const submitCallback = async () => {
|
|
|
|
|
router.go(-1);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 审批
|
|
|
|
|
// 审批(到货确认节点时,先保存到货业务数据,再走流程审批)
|
|
|
|
|
const approvalVerifyOpen = async () => {
|
|
|
|
|
if (routeParams.value.type === 'approval' && routeParams.value.taskId) {
|
|
|
|
|
const taskLoaded = await loadCurrentTask();
|
|
|
|
|
if (!taskLoaded || !currentTask.value) {
|
|
|
|
|
proxy?.$modal.msgError('当前任务信息加载失败,请刷新后重试');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isArrivalConfirmApprover.value) {
|
|
|
|
|
// 到货确认节点:先校验并保存到货业务数据
|
|
|
|
|
// 校验到货确认表单
|
|
|
|
|
const valid = await arrivalConfirmFormRef.value?.validate().catch(() => false);
|
|
|
|
|
if (!valid) return;
|
|
|
|
|
// 先调用到货确认接口保存业务数据
|
|
|
|
|
arrivalConfirmForm.value.shippingBillId = form.value.shippingBillId!;
|
|
|
|
|
arrivalConfirmForm.value.taskId = String(routeParams.value.taskId);
|
|
|
|
|
try {
|
|
|
|
|
const res = await arrivalConfirmShippingBill(arrivalConfirmForm.value);
|
|
|
|
|
Object.assign(form.value, res.data);
|
|
|
|
|
arrivalConfirmForm.value.isAllReceiving = res.data.isAllReceiving || arrivalConfirmForm.value.isAllReceiving;
|
|
|
|
|
arrivalConfirmForm.value.arrivalReceiptOssId = res.data.arrivalReceiptOssId || arrivalConfirmForm.value.arrivalReceiptOssId;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('到货确认保存失败:', error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const prepared = await prepareTaskVariables();
|
|
|
|
|
if (!prepared) return;
|
|
|
|
|
await submitVerifyRef.value?.openDialog(routeParams.value.taskId);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
nextTick(async () => {
|
|
|
|
|
routeParams.value = route.query;
|
|
|
|
|
// 页面初始化先展示加载态,防止首屏空白
|
|
|
|
|
proxy?.$modal.loading('正在加载数据,请稍后...');
|
|
|
|
|
|
|
|
|
|
await loadSelectOptions();
|
|
|
|
|
|
|
|
|
|
const id = routeParams.value.id as string | number;
|
|
|
|
|
if (id && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'approval')) {
|
|
|
|
|
// 编辑/查看/审批场景加载后端数据,避免覆盖草稿
|
|
|
|
|
await loadFormData(id);
|
|
|
|
|
}
|
|
|
|
|
await loadCurrentTask();
|
|
|
|
|
|
|
|
|
|
proxy?.$modal.closeLoading();
|
|
|
|
|
});
|
|
|
|
|
|