diff --git a/src/api/oa/erp/projectPurchase/types.ts b/src/api/oa/erp/projectPurchase/types.ts index 2bd6669..020b756 100644 --- a/src/api/oa/erp/projectPurchase/types.ts +++ b/src/api/oa/erp/projectPurchase/types.ts @@ -1,3 +1,5 @@ +import { ProjectPurchaseMaterialVO } from '@/api/oa/erp/projectPurchaseMaterial/types'; + export interface ProjectPurchaseVO { /** * 项目采购ID @@ -114,6 +116,11 @@ export interface ProjectPurchaseVO { */ activeFlag: string; + /** + * 采购物料List + */ + purchaseMaterialList: [ProjectPurchaseMaterialVO]; + } export interface ProjectPurchaseForm extends BaseEntity { diff --git a/src/views/oa/erp/projectPurchase/edit.vue b/src/views/oa/erp/projectPurchase/edit.vue index 4abca3e..cdda0b2 100644 --- a/src/views/oa/erp/projectPurchase/edit.vue +++ b/src/views/oa/erp/projectPurchase/edit.vue @@ -105,8 +105,11 @@ @@ -145,8 +148,11 @@ @@ -212,7 +218,17 @@ - + + + @@ -245,7 +261,6 @@ class="w-full" placeholder="请输入数量" :precision="2" - :disabled="true" /> @@ -282,6 +297,7 @@ + @@ -304,6 +320,7 @@ 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 MaterialSelect from '@/components/MaterialSelect/index.vue'; import { FlowCodeEnum } from '@/enums/OAEnum'; import type { ProjectInfoVO } from '@/api/oa/erp/projectInfo/types'; import { listUser } from '@/api/system/user'; @@ -311,6 +328,7 @@ import type { UserVO, UserQuery } from '@/api/system/user/types'; 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'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const router = useRouter(); @@ -335,6 +353,7 @@ const projectPurchaseFormRef = ref(); const submitVerifyRef = ref>(); const approvalRecordRef = ref>(); const projectSelectRef = ref>(); +const materialSelectRef = ref>(); const taskVariables = ref>({}); const initFormData: ProjectPurchaseForm & { projectName?: string } = { @@ -409,6 +428,26 @@ const getRowClassName = ({ row }: { row: ProjectPurchaseMaterialVO }) => { return ''; }; +const openMaterialSelect = () => { + if (!canEditMaterial.value) { + return; + } + materialSelectRef.value?.open(); +}; + +const materialSelectCallBack = (data: MaterialInfoVO[]) => { + if (!data?.length) { + return; + } + const material = data[0]; + materialForm.value.materialId = material.materialId; + materialForm.value.materialCode = material.materialCode; + materialForm.value.materialName = material.materialName; + materialForm.value.purchaseMaterialName = material.materialName; + // materialForm.value.relationMaterialCode = material.materialCode; + // materialForm.value.relationMaterialName = material.materialName; +}; + // 用户列表 const userList = ref([]); const getUserList = async () => { @@ -445,8 +484,11 @@ const initMaterialFormData: ProjectPurchaseMaterialForm = { materialFlag: undefined, materialId: undefined, relationMaterialId: undefined, + relationMaterialCode: undefined, + relationMaterialName: undefined, materialCode: undefined, materialName: undefined, + purchaseMaterialName: undefined, specificationDescription: undefined, unitId: undefined, needPurchaseAmount: undefined, @@ -497,7 +539,6 @@ const loadDetail = async (projectPurchaseId?: string | number) => { materialList.value = []; return; } - pageLoading.value = true; try { resetForm(); const res = await getProjectPurchase(projectPurchaseId); @@ -512,29 +553,12 @@ const loadDetail = async (projectPurchaseId?: string | number) => { if (userList.value.length === 0) { await getUserList(); } - await loadMaterials(); + materialList.value = res?.data.purchaseMaterialList || []; } finally { pageLoading.value = false; } }; -/** - * 加载物料列表 - */ -const loadMaterials = async () => { - if (!form.value.projectPurchaseId) { - materialList.value = []; - return; - } - materialLoading.value = true; - try { - const res = await getErpProjectPurchaseMaterialList({ projectPurchaseId: form.value.projectPurchaseId }); - materialList.value = res?.data || []; - } finally { - materialLoading.value = false; - } -}; - /** * 提交主表单 */ @@ -624,6 +648,21 @@ const handleEditMaterial = (row: ProjectPurchaseMaterialVO) => { materialDialog.visible = true; }; +/** + * 新增物料 + */ +const handleAddMaterial = (materialFlag) => { + if (!canEditMaterial.value) { + return; + } + resetMaterialForm(); + materialForm.value.materialFlag = materialFlag; + materialForm.value.purchasePlanFlag = '2'; + materialForm.value.projectPurchaseId = form.value.projectPurchaseId; + materialDialog.title = materialFlag === '1' ? '新增标准物料' : '新增非标准物料'; + materialDialog.visible = true; +}; + /** * 提交物料表单(仅操作本地列表) */ @@ -767,6 +806,7 @@ onMounted(async () => { nextTick(async () => { // 获取路由参数 Object.assign(routeParams, route.query); + pageLoading.value = true; loadSelectOptions(); const id = routeParams.id as string | number; const type = routeParams.type as string; @@ -796,10 +836,17 @@ onMounted(async () => { .table-header { display: flex; align-items: center; + justify-content: space-between; font-weight: 600; font-size: 16px; } +.title-wrapper { + display: flex; + align-items: center; + gap: 8px; +} + .title-dot { width: 8px; height: 24px; diff --git a/src/views/oa/erp/projectPurchase/index.vue b/src/views/oa/erp/projectPurchase/index.vue index a5cd435..c2161ae 100644 --- a/src/views/oa/erp/projectPurchase/index.vue +++ b/src/views/oa/erp/projectPurchase/index.vue @@ -90,9 +90,9 @@ - - - + + +