1.1.13 合同订单台账,发货新增时自动赋值合同等信息

dev
yinq 2 weeks ago
parent 0e86a7758c
commit 7ab3c08ae7

@ -184,6 +184,18 @@
<!-- 发货信息 Tab -->
<el-tab-pane label="发货信息" name="shipping">
<div v-loading="loadingShipping" class="tab-content">
<div class="section-header">
<div class="header-left">
<i class="el-icon-truck section-icon"></i>
<span class="section-title">发货信息</span>
<el-tag v-if="shippingTotal > 0" type="info" size="small" class="count-tag"> {{ shippingTotal }} </el-tag>
</div>
<div class="header-actions">
<el-button size="default" type="primary" icon="Plus" @click="addShippingFromLedger"></el-button>
<el-button size="default" type="primary" plain icon="Link" @click="openShippingPage"></el-button>
<el-button size="default" icon="Refresh" @click="loadShippingList"></el-button>
</div>
</div>
<el-table :data="shippingList" border stripe size="default" class="data-table">
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column label="发货单号" prop="shippingCode" width="150" align="center" />
@ -453,6 +465,11 @@ const openPurchasePage = () => {
proxy?.$tab.openPage('/purchase/projectPurchase', '采购管理');
};
/** 前往发货页面 */
const openShippingPage = () => {
proxy?.$tab.openPage('/shipping/wmsShippingBill', '发货管理');
};
/** 查看采购信息 */
const viewPurchase = (row: ProjectPurchaseVO) => {
if (!row?.projectPurchaseId) return;
@ -476,6 +493,22 @@ const addPurchaseFromLedger = () => {
});
};
/** 从台账新增发货,并携带合同信息 */
const addShippingFromLedger = () => {
const contractId = orderInfo.value?.contractId ?? contractInfo.value?.contractId;
if (!contractId) {
proxy?.$modal.msgWarning('合同信息未加载完成,请稍后重试');
return;
}
proxy?.$tab.openPage('/shipping/wmsShippingBill/edit', '发货信息', {
type: 'add',
source: 'orderLedger',
bindType: '2',
contractId,
projectId: projectId.value
});
};
/** 查看开票信息 */
const viewInvoice = (row: FinInvoiceInfoVO) => {
if (!row?.invoiceId) return;

@ -186,8 +186,9 @@
<el-form-item label="发货日期" prop="shippingTime">
<el-date-picker
v-model="form.shippingTime"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
type="date"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
placeholder="请选择发货日期"
style="width: 100%"
/>
@ -480,6 +481,7 @@ import type { CustomerContactVO } from '@/api/oa/crm/customerContact/types';
import { getCrmSupplierInfoList } from '@/api/oa/crm/crmSupplierInfo';
import { listUser } from '@/api/system/user';
import type { UserQuery } from '@/api/system/user/types';
import { getContractOrder } from '@/api/oa/erp/contractOrder';
import MaterialSelect from '@/components/MaterialSelect/index.vue';
import SubmitVerify from '@/components/Process/submitVerify.vue';
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
@ -489,6 +491,7 @@ import type { ProjectInfoVO } from '@/api/oa/erp/projectInfo/types';
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 type { ContractOrderPurchaseMaterialVO } from '@/api/oa/erp/contractOrder/types';
import { FlowCodeEnum } from '@/enums/OAEnum';
import { Search, Warning } from '@element-plus/icons-vue';
@ -668,6 +671,14 @@ const wmsMaterialQueryParams = ref<InventoryDetailsQuery>({
warehouseId: undefined
});
const getTodayDateString = () => {
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
};
//
const initFormData: WmsShippingBillForm = {
shippingBillId: undefined,
@ -693,7 +704,7 @@ const initFormData: WmsShippingBillForm = {
logisticsPhone: undefined,
directions: undefined,
planArrivalTime: undefined,
shippingTime: undefined,
shippingTime: getTodayDateString(),
warehouseId: undefined,
warehouseName: undefined,
outStockBillStatus: '1', //
@ -757,6 +768,11 @@ const syncMaterialSourceTypeByDetails = () => {
}
};
const toNumberOrDefault = (value: unknown, defaultValue = 0) => {
const result = Number(value);
return Number.isFinite(result) ? result : defaultValue;
};
const normalizeWorkflowUserIds = (value: unknown): string | undefined => {
if (Array.isArray(value)) {
const ids = value.map((item) => String(item ?? '').trim()).filter((item) => item.length > 0);
@ -873,20 +889,117 @@ const handleContractRowClick = (row: ContractInfoVO) => {
const submitContractSelect = () => {
if (selectedContract.value) {
const contract = selectedContract.value;
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 || '';
applyContractInfoToForm(selectedContract.value);
}
contractDialog.visible = false;
};
const applyProjectInfoToForm = (project: Partial<ProjectInfoVO> & Record<string, any>) => {
form.value.bindType = '1';
form.value.projectId = project.projectId;
form.value.projectCode = project.projectCode || '';
form.value.projectName = project.projectName || '';
selectedProjectName.value = project.projectName || '';
const peopleId = normalizeWorkflowUserIds(project.peopleId);
(form.value as any).peopleId = peopleId;
(form.value as any).tManagerId = toWorkflowUserIdArray(peopleId);
};
const syncCustomerById = async (customerId?: string | number) => {
if (!customerId) {
return;
}
form.value.customerId = customerId;
await handleCustomerChange(customerId);
};
const applyContractInfoToForm = (contract: ContractInfoVO) => {
form.value.bindType = '2';
form.value.contractId = contract.contractId as any;
form.value.contractCode = contract.contractCode || '';
form.value.contractName = contract.contractName || '';
selectedContractName.value = contract.contractName || '';
selectedSapOrderCode.value = (contract as any).orderContractCode || '';
const contractManagerId = normalizeWorkflowUserIds((contract as any).contractManagerId);
(form.value as any).contractManagerId = contractManagerId;
(form.value as any).tManagerId = toWorkflowUserIdArray(contractManagerId);
};
const mapContractMaterialToShippingDetail = (material: ContractOrderPurchaseMaterialVO | Record<string, any>): WmsShippingDetailsForm => {
const rawMaterial = material as Record<string, any>;
const shippingStockAmount = toNumberOrDefault(rawMaterial.amount ?? rawMaterial.contractAmount, 0);
const unitPrice = toNumberOrDefault(rawMaterial.includingPrice ?? rawMaterial.beforePrice, 0);
return {
shippingDetailsId: undefined,
shippingBillId: form.value.shippingBillId,
materialSourceType: '1',
erpMaterialId: rawMaterial.materialId,
wmsMaterialId: undefined,
sourceDetailType: 'CONTRACT_DETAIL',
sourceDetailId: rawMaterial.contractMaterialId,
warehouseId: undefined,
materielId: rawMaterial.materialId,
materialCode: rawMaterial.materialCode,
materialName: rawMaterial.saleMaterialName || rawMaterial.materialName || rawMaterial.productName,
materielSpecification: rawMaterial.specificationDescription,
batchNumber: undefined,
unitPrice,
shippingStockAmount,
unitId: rawMaterial.unitId,
unitName: rawMaterial.unitName,
totalPrice: unitPrice * shippingStockAmount,
remark: rawMaterial.remark
};
};
const initShippingDetailsFromContract = (contractMaterialList: ContractOrderPurchaseMaterialVO[] | any[]) => {
detailsList.value = (contractMaterialList || []).map((item) => mapContractMaterialToShippingDetail(item));
materialSourceType.value = '1';
syncMaterialSourceTypeByDetails();
};
const initFromContractSource = async (contractId: string | number, projectId?: string | number) => {
const [contractRes, projectRes] = await Promise.all([
getContractInfo(contractId),
projectId ? getContractOrder(projectId).catch((error) => {
console.error('加载合同订单项目数据失败:', error);
return null;
}) : Promise.resolve(null)
]);
const contract = contractRes.data;
applyContractInfoToForm(contract);
await syncCustomerById((contract as any).finalCustomerId ?? (contract as any).oneCustomerId);
if (projectRes?.data) {
applyProjectInfoToForm(projectRes.data as any);
form.value.bindType = '2';
}
initShippingDetailsFromContract((contract as any)?.contractMaterialList || []);
};
const initFromProjectSource = async (projectId: string | number) => {
const projectRes = await getProjectInfo(projectId);
const project = projectRes.data as any;
applyProjectInfoToForm(project);
await syncCustomerById(project.customerId ?? project.finalCustomerId);
};
const initFormByRouteSource = async () => {
if (routeParams.value.type !== 'add') {
return;
}
const source = String(routeParams.value.source || '').trim();
const bindType = String(routeParams.value.bindType || '').trim();
const contractId = routeParams.value.contractId as string | number | undefined;
const projectId = routeParams.value.projectId as string | number | undefined;
if ((source === 'orderLedger' || bindType === '2') && contractId) {
await initFromContractSource(contractId, projectId);
return;
}
if (bindType === '1' && projectId) {
await initFromProjectSource(projectId);
}
};
/** 打开项目选择弹窗 */
const openProjectSelect = () => {
if (!canEditBusinessFields.value) return;
@ -904,14 +1017,8 @@ const openContractSelect = () => {
/** 项目选择回调 */
const projectInfoSelectCallBack = (data: ProjectInfoVO[]) => {
if (data && data.length > 0) {
const project = data[0];
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 || '';
const project = data[0] as ProjectInfoVO & Record<string, any>;
applyProjectInfoToForm(project);
//
if (project.customerId) {
form.value.customerId = project.customerId;
@ -1301,6 +1408,8 @@ onMounted(async () => {
if (id && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'approval')) {
// //稿
await loadFormData(id);
} else {
await initFormByRouteSource();
}
await loadCurrentTask();

Loading…
Cancel
Save