|
|
|
|
@ -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;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|