1.1.4 从合同订单台账新增采购,并携带项目信息

dev
yinq 3 weeks ago
parent 171148e2ee
commit cb0e5a7d96

@ -101,3 +101,14 @@ export function getErpProjectWithContractList(query) {
});
}
/**
* ID
* @param contractId
*/
export const listProjectInfoByContractId = (contractId: string | number): AxiosPromise<ProjectInfoVO[]> => {
return request({
url: '/oa/erp/projectInfo/listByContractId/' + contractId,
method: 'get'
});
};

@ -3,6 +3,11 @@ import { AxiosPromise } from 'axios';
import { ProjectPurchaseVO, ProjectPurchaseForm, ProjectPurchaseQuery } from '@/api/oa/erp/projectPurchase/types';
import { ProjectPurchaseMaterialVO } from '@/api/oa/erp/projectPurchaseMaterial/types';
export interface ProjectMaterialsSourceDTO {
relationId?: string | number;
materialList?: ProjectPurchaseMaterialVO[];
}
/**
*
* @param query
@ -93,9 +98,14 @@ export function getErpProjectPurchaseList (query) {
* @param projectId
* @param spareFlag
*/
export const getProjectMaterialsByProjectId = (projectId: string | number, spareFlag: string): AxiosPromise<ProjectPurchaseMaterialVO[]> => {
export const getProjectMaterialsByProjectId = (
projectId: string | number,
spareFlag: string,
contractId?: string | number
): AxiosPromise<ProjectMaterialsSourceDTO> => {
return request({
url: `/oa/erp/projectPurchase/getContractMaterialsByProjectId/${projectId}/${spareFlag}`,
method: 'get'
method: 'get',
params: contractId ? { contractId } : {}
});
};

@ -145,7 +145,7 @@ export const constantRoutes: RouteRecordRaw[] = [
path: 'orderLedger/:projectId',
component: () => import('@/views/oa/erp/orderLedger/index.vue'),
name: 'OrderLedger',
meta: { title: '订单管理台账', activeMenu: '/contract/contractInfo/contractOrder' }
meta: { title: '合同订单台账', activeMenu: '/contract/contractInfo/contractOrder' }
}
]
},

@ -3,7 +3,7 @@
<el-card shadow="never" class="main-card">
<template #header>
<div class="card-header">
<span class="header-title">合同订单管理台账</span>
<span class="header-title">合同订单台账</span>
<el-button size="default" type="primary" icon="ArrowLeft" @click="handleBack"></el-button>
</div>
</template>
@ -80,6 +80,7 @@
<el-tag v-if="purchaseTotal > 0" type="info" size="small" class="count-tag"> {{ purchaseTotal }} </el-tag>
</div>
<div class="header-actions">
<el-button size="default" type="primary" icon="Plus" @click="addPurchaseFromLedger"></el-button>
<el-button size="default" type="primary" plain icon="Link" @click="openPurchasePage"></el-button>
<el-button size="default" icon="Refresh" @click="loadPurchaseList"></el-button>
</div>
@ -358,7 +359,13 @@ const loadingInvoice = ref(false);
const shippingTotal = ref(0);
const shippingQuery = reactive({ pageNum: 1, pageSize: 10 });
const purchaseTotal = ref(0);
const purchaseQuery = reactive({ pageNum: 1, pageSize: 10, projectId: undefined as string | number | undefined });
const purchaseQuery = reactive({
pageNum: 1,
pageSize: 10,
projectId: undefined as string | number | undefined,
relationId: undefined as string | number | undefined,
spareFlag: undefined as string | undefined
});
const invoiceTotal = ref(0);
const invoiceQuery = reactive({ pageNum: 1, pageSize: 10, projectId: undefined as string | number | undefined, contractId: undefined as string | number | undefined });
@ -392,6 +399,20 @@ const viewPurchase = (row: ProjectPurchaseVO) => {
});
};
/** 从台账新增采购,并携带项目信息 */
const addPurchaseFromLedger = () => {
const contractId = orderInfo.value?.contractId ?? contractInfo.value?.contractId;
if (!contractId) {
proxy?.$modal.msgWarning('合同信息未加载完成,请稍后重试');
return;
}
proxy?.$tab.openPage('/purchase/projectPurchase/edit', '采购信息', {
type: 'add',
source: 'orderLedger',
contractId
});
};
/** 查看开票信息 */
const viewInvoice = (row: FinInvoiceInfoVO) => {
if (!row?.invoiceId) return;
@ -421,16 +442,18 @@ const loadOrderAndContract = async () => {
/** 加载采购信息 */
const loadPurchaseList = async () => {
if (!projectId.value) {
const contractId = orderInfo.value.contractId;
if (!contractId && !projectId.value) {
purchaseList.value = [];
purchaseTotal.value = 0;
return;
}
// ID
purchaseQuery.relationId = contractId ? contractId : undefined;
loadingPurchase.value = true;
try {
const res: any = await listProjectPurchase({
...purchaseQuery,
projectId: projectId.value
...purchaseQuery
});
purchaseList.value = res.rows || [];
purchaseTotal.value = res.total || 0;
@ -538,7 +561,6 @@ const handleTabChange = (tabName: string) => {
break;
case 'purchase':
purchaseQuery.pageNum = 1;
purchaseQuery.projectId = projectId.value;
loadPurchaseList();
break;
case 'shipping':

@ -323,6 +323,7 @@ import { useUserStore } from '@/store/modules/user';
import { getBaseUnitInfoList } from '@/api/oa/base/unitInfo';
import { getInfo } from '@/api/login';
import type { MaterialInfoVO } from '@/api/oa/base/materialInfo/types';
import { listProjectInfoByContractId } from '@/api/oa/erp/projectInfo';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const router = useRouter();
@ -394,14 +395,22 @@ const nonStandardMaterialList = computed(() => {
return materialList.value.filter((item) => item.materialFlag === '2');
});
const loadProjectMaterialsFromSource = async (projectId?: string | number, spareFlag?: string) => {
const loadProjectMaterialsFromSource = async (
projectId?: string | number,
spareFlag?: string,
contractId?: string | number
) => {
if (!projectId || !spareFlag) {
return;
}
materialLoading.value = true;
try {
const res = await getProjectMaterialsByProjectId(projectId, spareFlag);
let data = res?.data || [];
const res = await getProjectMaterialsByProjectId(projectId, spareFlag, contractId);
const relationId = res?.data?.relationId;
if (relationId !== undefined && relationId !== null) {
form.value.relationId = relationId as any;
}
let data = res?.data?.materialList || [];
data = data.map((item, index) => ({
...item,
purchasePlanFlag: '1',
@ -790,6 +799,38 @@ const projectInfoSelectCallBack = (data: ProjectInfoVO[]) => {
}
};
const initFromRouteQuery = async () => {
const queryType = (routeParams.type as string) || 'add';
const contractId = routeParams.contractId as string | number | undefined;
if (
routeParams.id ||
queryType !== 'add' ||
(routeParams.source as string) !== 'orderLedger' ||
!contractId
) {
return;
}
const res = await listProjectInfoByContractId(contractId);
const projectList = res?.data || [];
if (!projectList.length) {
proxy?.$modal.msgWarning('该合同未查询到关联系项目信息');
return;
}
if (projectList.length > 1) {
proxy?.$modal.msgWarning('该合同关联了多个项目,系统将默认带出第一个项目,请确认后再提交');
}
const project = projectList[0];
form.value.projectId = project.projectId;
form.value.projectCode = project.projectCode;
form.value.projectName = project.projectName;
form.value.managerId = project.managerId;
form.value.chargeId = project.chargeId;
form.value.deputyId = project.deputyId;
form.value.deptId = project.deptId;
form.value.spareFlag = project.spareFlag;
await loadProjectMaterialsFromSource(project.projectId as string | number, project.spareFlag, contractId);
};
const handleExportSingle = () => {
proxy?.download(
`oa/erp/projectPurchase/exportSingle/${form.value.projectPurchaseId}`,
@ -821,7 +862,13 @@ onMounted(async () => {
userRoles.value = [];
}
const shouldLoadDetail = !!id && (type === 'update' || type === 'view' || type === 'approval');
await loadDetail(shouldLoadDetail ? (id as string | number) : undefined);
if (shouldLoadDetail) {
await loadDetail(id as string | number);
} else {
resetForm();
materialList.value = [];
await initFromRouteQuery();
}
pageLoading.value = false;
});
});

Loading…
Cancel
Save