From aecff9864281c1e571d7904a41e52e478c07bad6 Mon Sep 17 00:00:00 2001 From: Teo <2642673902@qq.com> Date: Sun, 10 Aug 2025 14:21:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E8=B5=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/api/materials/orderMaterials/index.ts | 5 +- src/views/materials/orderEquipment/index.vue | 5 +- .../orderEquipment/indexEquipment.vue | 36 +++++++----- src/views/materials/orderMaterials/index.vue | 57 +++++++++++-------- 5 files changed, 63 insertions(+), 42 deletions(-) diff --git a/.env.development b/.env.development index 21892b7..fe20df3 100644 --- a/.env.development +++ b/.env.development @@ -5,7 +5,7 @@ VITE_APP_TITLE = 新能源项目管理平台 VITE_APP_ENV = 'development' # 开发环境 -VITE_APP_BASE_API = 'http://192.168.110.180:8898' +VITE_APP_BASE_API = 'http://192.168.110.159:8898' # 无人机接口地址 diff --git a/src/api/materials/orderMaterials/index.ts b/src/api/materials/orderMaterials/index.ts index 3be16be..93b8aa2 100644 --- a/src/api/materials/orderMaterials/index.ts +++ b/src/api/materials/orderMaterials/index.ts @@ -33,8 +33,11 @@ export const getCailiaoshebei = (id: string | number): AxiosPromise { return request({ - url: '/cailiaoshebei/cailiaoshebei', + url: '/cailiaoshebei/materialsorder/changeTheStatusOfTheMaterials', method: 'post', + headers: { + 'Content-Type': 'multipart/form-data' + }, data: data }); }; diff --git a/src/views/materials/orderEquipment/index.vue b/src/views/materials/orderEquipment/index.vue index 3914660..fad63d0 100644 --- a/src/views/materials/orderEquipment/index.vue +++ b/src/views/materials/orderEquipment/index.vue @@ -255,8 +255,9 @@ const getBatchList = async () => { /** 节点单击事件 */ const handleNodeClick = (data: any) => { queryParams.value.batchNumber = data.batchNumber; - form.value.batchNumber = data.batchNumber; - form.value.approvalOrder = data.approvalOrder; + form.value = data; + // form.value.batchNumber = data.batchNumber; + // form.value.approvalOrder = data.approvalOrder; if (data.batchNumber === '0') { queryParams.value.batchNumber = ''; } diff --git a/src/views/materials/orderEquipment/indexEquipment.vue b/src/views/materials/orderEquipment/indexEquipment.vue index 3a7315f..c1660cb 100644 --- a/src/views/materials/orderEquipment/indexEquipment.vue +++ b/src/views/materials/orderEquipment/indexEquipment.vue @@ -20,12 +20,12 @@ --> - + - + @@ -35,12 +35,12 @@ - + - + @@ -147,7 +147,7 @@ const getList = async () => { getListAll(); }) .catch((error) => { - console.error('请求失败:', error); + proxy?.$modal.msgError(error); }); }; // 获取列表 @@ -172,17 +172,18 @@ const getListAll = () => { loading.value = false; }) .catch((error) => { - console.error('请求失败:', error); + proxy?.$modal.msgError(error); + loading.value = false; }); }; /** 提交按钮 */ const submitForm = async () => { - cailiaoshebeiList.value.forEach((item) => { - if (item.id) { - delete item.id; - } - }); + // cailiaoshebeiList.value.forEach((item) => { + // if (item.id) { + // delete item.id; + // } + // }); axios .put( 'http://192.168.110.159:8898/cailiaoshebei/materialsorder/modifyTheOrderFormGYS', @@ -198,13 +199,20 @@ const submitForm = async () => { } } ) - .then((response) => { - proxy?.$modal.msgSuccess('操作成功'); + .then((res) => { + console.log(res.data.code); + + if (res.data.code === 200) { + proxy?.$modal.msgSuccess('操作成功'); + } else { + proxy?.$modal.msgError(res.data.msg + ''); + } loading.value = false; }) .catch((error) => { - console.error('请求失败:', error); + proxy?.$modal.msgError(error); + loading.value = false; }); }; diff --git a/src/views/materials/orderMaterials/index.vue b/src/views/materials/orderMaterials/index.vue index e95997d..639ffbe 100644 --- a/src/views/materials/orderMaterials/index.vue +++ b/src/views/materials/orderMaterials/index.vue @@ -27,7 +27,12 @@ - + @@ -124,7 +129,7 @@ :fileType="['doc', 'docx']" :autoUpload="false" ref="fileUploadRef" - :data="{ ...form.bo }" + :data="form.bo" uploadUrl="/cailiaoshebei/materialsorder/changeTheStatusOfTheMaterials" :onUploadError=" (err, file, fileList) => { @@ -143,7 +148,7 @@ @@ -208,8 +213,8 @@ const initFormData: CailiaoshebeiForm = { finishTime: undefined, unit: undefined, plan: undefined, + file: '', realQuantity: undefined, - file: undefined, projectId: currentProject.value.id, bo: { requiredTime: undefined, @@ -272,6 +277,7 @@ const getBatchList = async () => { try { batchTreeRef.value.setCurrentKey(res.rows[0].batchNumber); form.value.batchNumber = res.rows[0].batchNumber; + queryParams.value.batchNumber = res.rows[0].batchNumber; } catch (error) { form.value.batchNumber = ''; } @@ -303,8 +309,14 @@ const cancel = () => { /** 表单重置 */ const reset = () => { - const preservedBatchId = form.value.batchNumber; // 先保存当前的 batchNumber - form.value = { ...initFormData, batchNumber: preservedBatchId }; // 重置但保留 + const preservedBatchId = form.value.batchNumber; + + form.value = { + ...initFormData, + bo: { ...initFormData.bo }, // 新建一个 bo 对象 + batchNumber: preservedBatchId + }; + cailiaoshebeiFormRef.value?.resetFields(); }; @@ -341,18 +353,30 @@ const handleUpdate = async (row?: CailiaoshebeiVO) => { operation_s.value = operation_status.value.slice(0, 2); Object.assign(form.value.bo, row); console.log('🚀 ~ handleUpdate ~ form.value:', form.value); - // selectValue.value = (form.value.supplierId as string).split(','); dialog.visible = true; dialog.title = '修改物资-材料设备'; }; /** 提交按钮 */ const submitForm = () => { - console.log('🚀 ~ submitForm ~ form.value:', form.value); + Object.keys(form.value.bo).forEach((key) => { + if (form.value.bo[key] == 'null' || form.value.bo[key] == null) { + delete form.value.bo[key]; + } + }); + console.log('🚀 ~ submitForm ~ form.value:', form.value.bo); + cailiaoshebeiFormRef.value?.validate(async (valid: boolean) => { if (valid) { buttonLoading.value = true; - fileUploadRef.value!.submitUpload(); + if (fileUploadRef.value) { + fileUploadRef.value!.submitUpload(); + } else { + form.value.bo.file = null; + await addCailiaoshebei(form.value.bo).finally(() => (buttonLoading.value = false)); + dialog.visible = false; + getList(); + } } }); }; @@ -374,7 +398,6 @@ const handleDeleteBatch = async () => { await delBatch(_ids); proxy?.$modal.msgSuccess('删除成功'); queryParams.value.batchNumber = ''; - await getBatchList(); }; @@ -415,20 +438,6 @@ const getSupplierList = async () => { supplierOptions.value = res.rows; }; -// 中间数组变量供 el-select 使用 -const selectValue = ref([]); - -// 监听 selectValue,每次变化时同步更新 form.supplierId 和 form.supplier -watch( - selectValue, - (newVal) => { - form.value.supplierId = newVal.join(','); - const selectedNames = supplierOptions.value.filter((opt) => newVal.includes(opt.id)).map((opt) => opt.name); - form.value.supplier = selectedNames.join(','); - }, - { immediate: true } -); - onMounted(() => { getBatchList(); getSupplierList();