Просмотр исходного кода

出入库申请增加附件上传:应对销售出库、成品入库不在系统做相应qc但是上传Excel后放行

yesheng 3 недель назад
Родитель
Сommit
358060a8fb

+ 42 - 0
src/views/rtkwms/inrequest/InRequestForm.vue

@@ -255,6 +255,16 @@
                 </el-select>
               </el-form-item>
             </el-col>
+            <el-col :span="8" class="text-right">
+              <el-button
+                type="primary"
+                plain
+                style="width: 60%"
+                icon="el-icon-upload2"
+                @click="handleUpload"
+              >附件上传</el-button
+              >
+            </el-col>
           </el-row>
         </el-form>
 
@@ -422,19 +432,25 @@
         <div v-else class="isNotApproval">暂未开启工作流</div>
       </el-tab-pane>
     </el-tabs>
+
+    <!-- 附件上传 -->
+    <AttachmentUpload ref="attachmentUpload" @files="getFileList" />
   </div>
 </template>
 
 <script>
 import * as InRequestApi from "@/api/wms/output/inrequest";
 import DepartMentSelect from "./components/DepartMentSelect.vue";
+import AttachmentUpload from "../../wms/incoming/register/components/AttachmentUpload.vue";
 // 审批任务
 import ApprovalTask from "../../wms/quality/iqcInspection/components/ApprovalTaskNew.vue";
+import {getFilesById} from "@/api/wms/incoming/register";
 export default {
   name: "InRequestForm",
   components: {
     DepartMentSelect,
     ApprovalTask,
+    AttachmentUpload,
   },
   data() {
     return {
@@ -444,6 +460,7 @@ export default {
       sourceOrderNoList: [],
       businessDescribeList: [],
       warehouseList: [],
+      uploadFiles: [],// 上传的文件
       loading: false,
       // 页面标题
       dialogTitle: "",
@@ -777,6 +794,8 @@ export default {
         res.data.status = res.data.status ? res.data.status.toString() : "0";
         // res.data.list = res.data.list || [];
         this.formData = res.data;
+        // 附件列表
+        this.uploadFiles = this.formData.filesListVos;
       } finally {
         this.formLoading = false;
       }
@@ -804,6 +823,14 @@ export default {
             }) => rest
           );
 
+        //上传的附件拼接传给后端
+        const fileIds = this.uploadFiles.map((item) => {
+          return item.id || item.name?.fileId;
+        }).filter(id => id && id !== '');
+
+        // 拼接文件ID
+        data.fileId = fileIds.join(',');
+
         // 修改的提交
         if (data.id) {
           await InRequestApi.updateRequest(data);
@@ -922,6 +949,21 @@ export default {
       // 这里可以写“本次出入数量”变化后的校验或计算逻辑
       console.log("deliverChange", val);
     },
+    // 附件上传
+    handleUpload() {
+      this.$refs.attachmentUpload.isUploadShow = -1;
+      this.$refs.attachmentUpload.title = "上传附件";
+
+      // 直接使用当前组件维护的 uploadFiles,而不是重新获取
+      this.$refs.attachmentUpload.fileList = this.uploadFiles || [];
+
+      this.$refs.attachmentUpload.visible = true;
+    },
+    // 获取上传的附件
+    getFileList(data) {
+      this.uploadFiles = data;
+    },
+
   },
 };
 </script>

+ 17 - 24
src/views/wms/incoming/register/materialRegistration.vue

@@ -57,17 +57,13 @@
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item label="源单单号" prop="purchaseOrderNo">
+          <el-form-item label="采购订单" prop="purchaseOrderNo">
             <OrderSelect
               ref="purchaseOrder"
               v-model="form.purchaseOrderNo"
               clearable
-              :disabled="
-                form.receiptType === '4' ||
-                form.receiptType === '2' ||
-                !!materialLots
-              "
-              placeholder="请选择源单单号"
+              :disabled="form.receiptType === '4' ||form.receiptType === '2'||!!materialLots"
+              placeholder="请选择采购订单"
               :options="orderOptions"
               @change="OrderNoChange"
             />
@@ -573,6 +569,10 @@ export default {
         if (data.receiptType == 2) {
           this.otherShow = false;
         }
+        if(data.receiptType !== 1){
+          // 设置采购订单号为非必填项
+          this.$refs.form.rules.purchaseOrderNo[0].required = false;
+        }
         // 补打列表
         this.$nextTick(() => {
           this.$refs.labelRepair.queryParams.materialLots = materialLots;
@@ -582,7 +582,7 @@ export default {
         // 物料列表
         this.list = data.materials;
         // 附件列表
-        this.$refs.attachmentUpload.fileList = data.filesListVos;
+        this.uploadFiles = data.filesListVos;
         await this.supplierChange({ code: this.form.supplierCode });
         await this.fetchOrderNoList(this.form.supplierCode);
         await this.OrderNoChange({
@@ -709,10 +709,12 @@ export default {
       try {
         await this.$refs.form.validate();
         this.sureLoading = true;
+
+        //取出上传的文件id
         const files = this.uploadFiles.map((item) => {
-          const { fileId } = item.url;
-          return fileId;
-        });
+          return item.id || item.name?.fileId;
+        }).filter(id => id && id !== '');
+
         const isAll = this.list.some(
           (item) => item.qty && item.length && item.width
         );
@@ -1020,19 +1022,10 @@ export default {
     handleUpload() {
       this.$refs.attachmentUpload.isUploadShow = -1;
       this.$refs.attachmentUpload.title = "上传附件";
-      if (this.uploadFiles.length > 0) {
-        // const { fileId } = this.uploadFiles[0].name
-        const fileIds = this.uploadFiles.map((item) => {
-          const { fileId } = item.name;
-          return fileId;
-        });
-        const params = {
-          files: fileIds.join(",") || null,
-        };
-        getFilesById(params).then((res) => {
-          this.$refs.attachmentUpload.fileList = res.data || [];
-        });
-      }
+
+      // 直接使用当前组件维护的 uploadFiles,而不是重新获取
+      this.$refs.attachmentUpload.fileList = this.uploadFiles || [];
+
       this.$refs.attachmentUpload.visible = true;
     },
     // 获取上传的附件

+ 41 - 0
src/views/wms/output/inrequest/components/InRequestForm.vue

@@ -261,6 +261,16 @@
                 </el-select>
               </el-form-item>
             </el-col>
+            <el-col :span="8" class="text-right">
+              <el-button
+                type="primary"
+                plain
+                style="width: 60%"
+                icon="el-icon-upload2"
+                @click="handleUpload"
+              >附件上传</el-button
+              >
+            </el-col>
           </el-row>
         </el-form>
         <!-- <el-tabs v-model="activeName" @tab-click="handleClick">
@@ -430,12 +440,15 @@
       </el-tab-pane>
     </el-tabs>
     <!-- 移除原有的form-footer -->
+    <!-- 附件上传 -->
+    <AttachmentUpload ref="attachmentUpload" @files="getFileList" />
   </div>
 </template>
 
 <script>
 import * as InRequestApi from "@/api/wms/output/inrequest";
 import DepartMentSelect from "./DepartMentSelect.vue";
+import AttachmentUpload from "../../../../wms/incoming/register/components/AttachmentUpload.vue";
 // 审批任务
 import ApprovalTask from "../../../../wms/quality/iqcInspection/components/ApprovalTaskNew.vue";
 // import ShipmentNotification from "./ShipmentNotification.vue";
@@ -445,6 +458,7 @@ export default {
     // ShipmentNotification,
     DepartMentSelect,
     ApprovalTask,
+    AttachmentUpload,
   },
   data() {
     return {
@@ -457,6 +471,7 @@ export default {
       loadingMaterial: false,
       loadingSourceOrder: false,
       loadingWarehouse: false,
+      uploadFiles: [],// 上传的文件
       // 页面标题
       dialogTitle: "",
       // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
@@ -766,6 +781,8 @@ export default {
           res.data.list = res.data.list || [];
           this.formData = res.data;
           this.dialogTitle = "修改";
+          // 附件列表
+          this.uploadFiles = this.formData.filesListVos;
         } finally {
           this.formLoading = false;
         }
@@ -796,6 +813,15 @@ export default {
               ...rest
             }) => rest
           );
+
+        //上传的附件拼接传给后端
+        const fileIds = this.uploadFiles.map((item) => {
+          return item.id || item.name?.fileId;
+        }).filter(id => id && id !== '');
+
+        // 拼接文件ID
+        data.fileId = fileIds.join(',');
+
         // 修改的提交;
         if (data.id) {
           await InRequestApi.updateInRequest(data);
@@ -920,6 +946,21 @@ export default {
       // 这里可以写“本次出入数量”变化后的校验或计算逻辑
       console.log("deliverChange", val);
     },
+    // 附件上传
+    handleUpload() {
+      this.$refs.attachmentUpload.isUploadShow = -1;
+      this.$refs.attachmentUpload.title = "上传附件";
+
+      // 直接使用当前组件维护的 uploadFiles,而不是重新获取
+      this.$refs.attachmentUpload.fileList = this.uploadFiles || [];
+
+      this.$refs.attachmentUpload.visible = true;
+    },
+    // 获取上传的附件
+    getFileList(data) {
+      this.uploadFiles = data;
+    },
+
   },
 };
 </script>