乐菲 2 days ago
parent
commit
ea0277ddb5
1 changed files with 322 additions and 291 deletions
  1. 322 291
      src/views/wms/incoming/register/materialRegistration.vue

+ 322 - 291
src/views/wms/incoming/register/materialRegistration.vue

@@ -10,7 +10,8 @@
           icon="el-icon-check"
           :loading="sureLoading"
           @click="submitForm"
-        >提交</el-button>
+          >提交</el-button
+        >
       </el-col>
     </el-row>
 
@@ -63,8 +64,8 @@
               clearable
               :disabled="
                 form.receiptType === '4' ||
-                  form.receiptType === '2' ||
-                  !!materialLots
+                form.receiptType === '2' ||
+                !!materialLots
               "
               placeholder="请选择源单单号"
               :options="orderOptions"
@@ -224,7 +225,8 @@
             style="width: 60%"
             icon="el-icon-upload2"
             @click="handleUpload"
-          >附件上传</el-button>
+            >附件上传</el-button
+          >
         </el-col>
         <el-col :span="form.receiptType === '4' ? 8 : 16">
           <el-form-item label="备注" prop="remark">
@@ -249,7 +251,8 @@
               icon="el-icon-plus"
               size="mini"
               @click="handleAdd"
-            >新增</el-button>
+              >新增</el-button
+            >
           </el-col>
         </el-row>
         <!-- 列表 -->
@@ -324,7 +327,8 @@
                 icon="el-icon-delete"
                 class="text-danger"
                 @click="handleDelete(scope.row)"
-              >删除</el-button>
+                >删除</el-button
+              >
             </template>
           </el-table-column>
         </el-table>
@@ -349,32 +353,32 @@ import {
   validateIsQuality,
   // getRegisterMaterialLabelPrintData,
   getFilesById,
-  getMaterialInfo
-} from '@/api/wms/incoming/register'
-import OrderSelect from './components/OrderSelect.vue'
-import MaterialSelect from './components/MaterialSelect.vue'
-import PrintTemplate from './components/PrintTemplate.vue'
-import { printLabel } from '@/api/common'
+  getMaterialInfo,
+} from "@/api/wms/incoming/register";
+import OrderSelect from "./components/OrderSelect.vue";
+import MaterialSelect from "./components/MaterialSelect.vue";
+import PrintTemplate from "./components/PrintTemplate.vue";
+import { printLabel } from "@/api/common";
 // 物料下拉
 // import { getMaterialDropDownList } from "@/api/wms/base/material";
 // 客户下拉选择
-import CustomerSelect from './components/CustomerSelect.vue'
+import CustomerSelect from "./components/CustomerSelect.vue";
 // 东苏发单据打印
-import IssuePrinit from '../../output/productionIssue/issueDetails/IssuePrinit.vue'
-const AccessTokenKey = 'ACCESS_TOKEN'
+import IssuePrinit from "../../output/productionIssue/issueDetails/IssuePrinit.vue";
+const AccessTokenKey = "ACCESS_TOKEN";
 // 供应商下拉列表
-import SupplierListSelect from './components/SupplierListSelect.vue'
-import { getDropDownList } from '@/api/wms/orders/purchase'
+import SupplierListSelect from "./components/SupplierListSelect.vue";
+import { getDropDownList } from "@/api/wms/orders/purchase";
 // 部门
-import DepartMentSelect from './components/DepartMentSelect.vue'
-import AttachmentUpload from './components/AttachmentUpload.vue'
+import DepartMentSelect from "./components/DepartMentSelect.vue";
+import AttachmentUpload from "./components/AttachmentUpload.vue";
 // 单位
-import UnitCodeSelect from './components/UnitCodeSelect.vue'
-import { getAppendixTableData } from '@/api/system/appendix.js'
-import LabelRepair from '@/views/wms/incoming/register/components/LabelRepair.vue'
+import UnitCodeSelect from "./components/UnitCodeSelect.vue";
+import { getAppendixTableData } from "@/api/system/appendix.js";
+import LabelRepair from "@/views/wms/incoming/register/components/LabelRepair.vue";
 
 export default {
-  name: 'MaterialRegistration',
+  name: "MaterialRegistration",
   components: {
     OrderSelect,
     MaterialSelect,
@@ -385,7 +389,7 @@ export default {
     DepartMentSelect,
     AttachmentUpload,
     UnitCodeSelect,
-    LabelRepair
+    LabelRepair,
   },
   data() {
     return {
@@ -394,7 +398,7 @@ export default {
       // 供应商置灰状态
       supplierDisabled: false,
       // 生产日期
-      produceDate: '',
+      produceDate: "",
       printData: [],
       // 遮罩层
       loading: false,
@@ -412,7 +416,7 @@ export default {
       // WMS 入库业务-来料登记主列表
       list: [],
       // 弹出层标题
-      title: '',
+      title: "",
       currentData: [],
       // 是否显示弹出层
       open: false,
@@ -429,7 +433,7 @@ export default {
         receiptQty: null,
         testStatus: null,
         createTime: [],
-        materialName: null
+        materialName: null,
       },
       // 显示客户
       receiptShow: true,
@@ -444,9 +448,9 @@ export default {
       //  过保质期提示
       warningText: null,
       // 单据打印参数
-      tokens: '',
-      baseUrl: '',
-      reportId: '',
+      tokens: "",
+      baseUrl: "",
+      reportId: "",
       // 登记的参数
       registerParams: {
         areaTest: null,
@@ -454,16 +458,16 @@ export default {
         purchaseOrderNo: null,
         materialNo: null,
         receiptQty: null,
-        testStatus: null
+        testStatus: null,
       },
       // 表单参数
       form: {
-        printer: '',
-        BtReportId: '',
-        BtReportUrl: '',
-        BtReportName: '',
-        HicoreReportName: '',
-        reportType: '0',
+        printer: "",
+        BtReportId: "",
+        BtReportUrl: "",
+        BtReportName: "",
+        HicoreReportName: "",
+        reportType: "0",
         deliverBatch: null,
         materialNo: null,
         produceDate: null,
@@ -474,7 +478,7 @@ export default {
         validTill: null,
         receiptQty: null,
         size: null,
-        remark: null
+        remark: null,
       },
       nextIndex: 0,
       nextPrintState: false,
@@ -487,145 +491,145 @@ export default {
         purchaseOrderNo: [
           {
             required: true,
-            message: '请输入关键字选择采购订单',
-            trigger: 'change'
-          }
+            message: "请输入关键字选择采购订单",
+            trigger: "change",
+          },
         ],
         materialNo: [
           {
             required: true,
-            message: '请输入关键字选择物料编码',
-            trigger: 'change'
-          }
+            message: "请输入关键字选择物料编码",
+            trigger: "change",
+          },
         ],
         bagQty: [
-          { required: true, message: '到货包数不能为空', trigger: 'change' }
+          { required: true, message: "到货包数不能为空", trigger: "change" },
         ],
         receiptQty: [
-          { required: true, message: '到货包数不能为空', trigger: 'blur' }
+          { required: true, message: "到货包数不能为空", trigger: "blur" },
         ],
         mantissaQty: [
-          { required: true, message: '到货尾数不能为空', trigger: 'change' }
+          { required: true, message: "到货尾数不能为空", trigger: "change" },
         ],
         pieceQty: [
-          { required: true, message: '到货件数不能为空', trigger: 'change' }
+          { required: true, message: "到货件数不能为空", trigger: "change" },
         ],
         deliverBatch: [
-          { required: true, message: '送货批次不能为空', trigger: 'change' }
+          { required: true, message: "送货批次不能为空", trigger: "change" },
         ],
         customerCode: [
-          { required: true, message: '请选择客户', trigger: 'change' }
+          { required: true, message: "请选择客户", trigger: "change" },
         ],
         receiptType: [
-          { required: true, message: '请选择物料类别', trigger: 'change' }
+          { required: true, message: "请选择物料类别", trigger: "change" },
         ],
         produceDate: [
-          { required: true, message: '生产日期不能为空', trigger: 'change' }
+          { required: true, message: "生产日期不能为空", trigger: "change" },
         ],
         supplierCode: [
-          { required: false, message: '供应商不能为空', trigger: 'change' }
+          { required: false, message: "供应商不能为空", trigger: "change" },
         ],
 
         departmentNo: [
           {
             required: true,
-            message: '部门不能为空',
-            trigger: 'change'
-          }
+            message: "部门不能为空",
+            trigger: "change",
+          },
         ],
         inType: [
           {
             required: true,
-            message: '入库类型不能为空',
-            trigger: 'change'
-          }
-        ]
-      }
-    }
+            message: "入库类型不能为空",
+            trigger: "change",
+          },
+        ],
+      },
+    };
   },
   created() {
-    this.tokens = localStorage.getItem(AccessTokenKey)
-    this.reportId = this.$route.meta.reportId
-    this.baseUrl = process.env.VUE_APP_REPORT_API
-    this.getTemplateList()
+    this.tokens = localStorage.getItem(AccessTokenKey);
+    this.reportId = this.$route.meta.reportId;
+    this.baseUrl = process.env.VUE_APP_REPORT_API;
+    this.getTemplateList();
 
-    const { materialLots } = this.$route.query
+    const { materialLots } = this.$route.query;
     if (materialLots) {
-      this.materialLots = materialLots
+      this.materialLots = materialLots;
       // 物料列表
-      this.handleGetMaterialInfo({ materialLots })
+      this.handleGetMaterialInfo({ materialLots });
     }
   },
   methods: {
     // 获取来料登记详情
     handleGetMaterialInfo({ materialLots }) {
-      getMaterialInfo({ materialLots }).then(async({ code, data, msg }) => {
+      getMaterialInfo({ materialLots }).then(async ({ code, data, msg }) => {
         this.form = {
           ...this.form,
           ...data,
           produceDate: data.produceDate
-            ? new Date(data.produceDate).toLocaleString().replace(/\//g, '-')
-            : '',
+            ? new Date(data.produceDate).toLocaleString().replace(/\//g, "-")
+            : "",
           validTill: data.validTill
-            ? new Date(data.validTill).toLocaleString().replace(/\//g, '-')
-            : ''
-        }
+            ? new Date(data.validTill).toLocaleString().replace(/\//g, "-")
+            : "",
+        };
         if (data.receiptType == 2) {
-          this.otherShow = false
+          this.otherShow = false;
         }
         // 补打列表
         this.$nextTick(() => {
-          this.$refs.labelRepair.queryParams.materialLots = materialLots
-          this.$refs.labelRepair.loading = false
-          this.$refs.labelRepair.list = data.qrCodes
-        })
+          this.$refs.labelRepair.queryParams.materialLots = materialLots;
+          this.$refs.labelRepair.loading = false;
+          this.$refs.labelRepair.list = data.qrCodes;
+        });
         // 物料列表
-        this.list = data.materials
+        this.list = data.materials;
         // 附件列表
-        this.$refs.attachmentUpload.fileList = data.filesListVos
-        await this.supplierChange({ code: this.form.supplierCode })
-        await this.fetchOrderNoList(this.form.supplierCode)
+        this.$refs.attachmentUpload.fileList = data.filesListVos;
+        await this.supplierChange({ code: this.form.supplierCode });
+        await this.fetchOrderNoList(this.form.supplierCode);
         await this.OrderNoChange({
           erpOrderNo: this.form.purchaseOrderNo,
           id: this.orderOptions.find(
             (ret) => ret.erpOrderNo === this.form.purchaseOrderNo
-          )
-        })
-        await this.materialNoChange({ ...this.form })
-      })
+          ),
+        });
+        await this.materialNoChange({ ...this.form });
+      });
     },
     // 模板选择
     reportChange(e) {
-      const fdIndex = this.btTemplateList.findIndex((ret) => ret.id === e)
-      this.form.HicoreReportName = this.btTemplateList[fdIndex].sysName
-      this.form.BtReportName = this.btTemplateList[fdIndex].originName
-      this.form.BtReportUrl = this.btTemplateList[fdIndex].url
+      const fdIndex = this.btTemplateList.findIndex((ret) => ret.id === e);
+      this.form.HicoreReportName = this.btTemplateList[fdIndex].sysName;
+      this.form.BtReportName = this.btTemplateList[fdIndex].originName;
+      this.form.BtReportUrl = this.btTemplateList[fdIndex].url;
     },
     // 获取BT打印模板
     getTemplateList() {
       getAppendixTableData({
         pageNum: 1,
         pageSize: 999,
-        printFlag: '1',
-        filesMenuId: '1000000000000000001'
+        printFlag: "1",
+        filesMenuId: "1000000000000000001",
       }).then(({ data }) => {
-        this.btTemplateList = data?.list ?? []
-      })
+        this.btTemplateList = data?.list ?? [];
+      });
     },
     handleAdd() {
       this.list.push({
-        qty: '',
-        length: '',
-        width: '',
-        thickness: '',
-        id: this.list.length
-      })
+        qty: "",
+        length: "",
+        width: "",
+        thickness: "",
+        id: this.list.length,
+      });
     },
     /** 删除按钮操作 */
     handleDelete(row, $index) {
-      const { id } = row
-      const index = this.list.findIndex((item) => item.id === id)
-      this.list.splice(index, 1)
+      const { id } = row;
+      const index = this.list.findIndex((item) => item.id === id);
+      this.list.splice(index, 1);
     },
     /** 表单重置 */
     reset() {
@@ -641,62 +645,62 @@ export default {
         width: undefined,
         length: undefined,
         thickness: undefined,
-        pieceQty: undefined
-      }
-      this.resetForm('form')
+        pieceQty: undefined,
+      };
+      this.resetForm("form");
     },
     // 小数点问题处理
     getHandleNumber(val) {
-      return Math.round(parseFloat(val) * 100000000) / 100000000
+      return Math.round(parseFloat(val) * 100000000) / 100000000;
     },
     // 根据每批尾数计算到货数量
     mantissaQtyChange(v) {
-      const { bagQty, pieceQty } = this.form
+      const { bagQty, pieceQty } = this.form;
       if (v * 1 > pieceQty * 1) {
-        this.$modal.msgWarning('到货尾数不能大于到货件数~')
-        this.form.receiptQty = ''
-        return
+        this.$modal.msgWarning("到货尾数不能大于到货件数~");
+        this.form.receiptQty = "";
+        return;
       }
       if (bagQty === undefined || pieceQty === undefined) {
-        this.$modal.msgWarning('请先输入到货包数或每包件数!')
-        return
+        this.$modal.msgWarning("请先输入到货包数或每包件数!");
+        return;
       }
       this.form.receiptQty = this.getHandleNumber(
         bagQty * pieceQty + parseFloat(v)
-      )
+      );
     },
     // 根据到货包数计算到货数量
     mantissaQtyChangeOfPack(v) {
-      const { mantissaQty, pieceQty } = this.form
+      const { mantissaQty, pieceQty } = this.form;
       if (mantissaQty === undefined || pieceQty === undefined) {
-        this.form.receiptQty = ''
-        return
+        this.form.receiptQty = "";
+        return;
       }
       this.form.receiptQty = this.getHandleNumber(
         v * pieceQty + parseFloat(mantissaQty)
-      )
+      );
     },
     // 根据每包数量计算到货数量
     mantissaQtyChangeOfPice(v) {
-      const { mantissaQty, bagQty } = this.form
+      const { mantissaQty, bagQty } = this.form;
       if (mantissaQty === undefined || bagQty === undefined) {
-        this.form.receiptQty = ''
-        return
+        this.form.receiptQty = "";
+        return;
       }
       this.form.receiptQty = this.getHandleNumber(
         v * bagQty + parseFloat(mantissaQty)
-      )
+      );
     },
     reLoading(timeout) {
       const loading = this.$loading({
         lock: true,
-        text: '标签打印中,请勿重复操作',
-        spinner: 'el-icon-loading',
-        background: 'rgba(0, 0, 0, 0.7)'
-      })
+        text: "标签打印中,请勿重复操作",
+        spinner: "el-icon-loading",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
       setTimeout(() => {
-        loading.close()
-      }, timeout * 1000)
+        loading.close();
+      }, timeout * 1000);
     },
     /** 提交按钮 */
     async submitForm() {
@@ -707,142 +711,142 @@ export default {
       //   }
       // }
       try {
-        await this.$refs.form.validate()
-        this.sureLoading = true
+        await this.$refs.form.validate();
+        this.sureLoading = true;
         const files = this.uploadFiles.map((item) => {
-          const { fileId } = item.url
-          return fileId
-        })
+          const { fileId } = item.url;
+          return fileId;
+        });
         const isAll = this.list.some(
           (item) => item.qty && item.length && item.width
-        )
-        if (this.form.unitName === '平方米' && this.list.length === 0) {
-          this.$modal.msgWarning('请填写物料的长度、宽度、数量等信息!')
-          return
+        );
+        if (this.form.unitName === "平方米" && this.list.length === 0) {
+          this.$modal.msgWarning("请填写物料的长度、宽度、数量等信息!");
+          return;
         }
-        if (this.form.unitName === '平方米' && !isAll && this.list.length > 0) {
-          this.$modal.msgWarning('长度/宽度/数量不能为空!')
-          return
+        if (this.form.unitName === "平方米" && !isAll && this.list.length > 0) {
+          this.$modal.msgWarning("长度/宽度/数量不能为空!");
+          return;
         }
-        this.form.files = files
-        this.form.unitCode = undefined
+        this.form.files = files;
+        this.form.unitCode = undefined;
         const subitParams = {
           ...this.form,
-          materials: this.list || []
-        }
+          materials: this.list || [],
+        };
         if (this.form.checkIncoming === 0) {
-          this.$modal.confirm('此物料为免检物料,可直接入库').then(() => {
-            this.commonSubmit(subitParams)
-          })
+          this.$modal.confirm("此物料为免检物料,可直接入库").then(() => {
+            this.commonSubmit(subitParams);
+          });
         } else {
-          this.commonSubmit(subitParams)
+          this.commonSubmit(subitParams);
         }
       } catch (error) {
-        console.log(error)
+        console.log(error);
       } finally {
-        this.sureLoading = false
+        this.sureLoading = false;
       }
     },
 
     // 打印
     async commonSubmit(subitParams) {
-      const result = await createIncomingReceipt(subitParams)
-      const { data: materialLots } = result
+      const result = await createIncomingReceipt(subitParams);
+      const { data: materialLots } = result;
 
       if (
-        (process.env.VUE_APP_TITLE === '麦禾田WMS管理系统' ||
-          process.env.VUE_APP_TITLE === 'WMS开发环境') &&
+        (process.env.VUE_APP_TITLE === "麦禾田WMS管理系统" ||
+          process.env.VUE_APP_TITLE === "WMS开发环境") &&
         !this.form.id &&
         false
       ) {
-        this.$modal.msgSuccess('登记成功,正在打印')
+        this.$modal.msgSuccess("登记成功,正在打印");
         const params = {
-          materialLots
-        }
+          materialLots,
+        };
 
-        const printDetailData = await getLabelPrintData(params) // 获取打印数据
-        const { data: productsDetails } = printDetailData
-        this.printData.push(...productsDetails)
+        const printDetailData = await getLabelPrintData(params); // 获取打印数据
+        const { data: productsDetails } = printDetailData;
+        this.printData.push(...productsDetails);
         // 打印参数
         const printParams = {
           printJson: JSON.stringify(this.printData),
-          fileUrl: this.form.BtReportUrl
-        }
+          fileUrl: this.form.BtReportUrl,
+        };
         try {
-          const data = await printLabel(printParams) // 打印
-          console.log(data, '???')
+          const data = await printLabel(printParams); // 打印
+          console.log(data, "???");
         } catch (error) {
-          console.log(error)
+          console.log(error);
         } finally {
-          this.printData = []
+          this.printData = [];
           this.$router.replace({
             path:
-              '/entry-exit/purchase-out-in/material-regist-enter?materialLots?materialLots=' +
-              materialLots
-          })
+              "/entry-exit/purchase-out-in/material-regist-enter?materialLots?materialLots=" +
+              materialLots,
+          });
         }
       } else {
         if (this.form.id) {
-          this.$modal.msgSuccess('修改成功')
+          this.$modal.msgSuccess("修改成功");
         } else {
-          this.$modal.msgSuccess('登记成功')
+          this.$modal.msgSuccess("登记成功");
           this.$router.replace({
             path:
-              '/entry-exit/purchase-out-in/material-regist-enter?materialLots?materialLots=' +
-              materialLots
-          })
-          console.log(this.reportId)
-          const src = `${this.baseUrl}/jmreport/view/${this.reportId}?token=${this.tokens}&materialLots=${materialLots}`
-          this.$refs.issuePrint.dialogVisible = true
-          this.$refs.issuePrint.src = src
+              "/entry-exit/purchase-out-in/material-regist-enter?materialLots?materialLots=" +
+              materialLots,
+          });
+          console.log(this.reportId);
+          const src = `${this.baseUrl}/jmreport/view/${this.reportId}?token=${this.tokens}&materialLots=${materialLots}`;
+          this.$refs.issuePrint.dialogVisible = true;
+          this.$refs.issuePrint.src = src;
         }
       }
     },
     // 根据到货包数 到货包数*每包数量计算到货总数
     handleBagQtyChange(row) {
-      const { bagQty, qty } = row
+      const { bagQty, qty } = row;
       if (!bagQty || !qty) {
-        this.form.receiptQty = null
-        return
+        this.form.receiptQty = null;
+        return;
       }
-      this.form.receiptQty = this.getHandleNumber(bagQty * qty)
-      if (this.form.unitCode === 'Pcs') {
+      this.form.receiptQty = this.getHandleNumber(bagQty * qty);
+      if (this.form.unitCode === "Pcs") {
         this.form.receiptQty = this.list.reduce((acc, cur) => {
           acc =
             this.getHandleNumber(acc) +
-            this.getHandleNumber(cur.qty * cur.bagQty)
-          return acc
-        }, 0)
+            this.getHandleNumber(cur.qty * cur.bagQty);
+          return acc;
+        }, 0);
       }
     },
     // 根据每包数量 每包数量 * 到货包数
     handleQtyChange(row) {
-      const { bagQty, qty } = row
+      const { bagQty, qty } = row;
       if (!bagQty || !qty) {
-        this.form.receiptQty = null
-        return
+        this.form.receiptQty = null;
+        return;
       }
-      this.form.receiptQty = this.getHandleNumber(bagQty * qty)
-      if (this.form.unitCode === 'Pcs') {
+      this.form.receiptQty = this.getHandleNumber(bagQty * qty);
+      if (this.form.unitCode === "Pcs") {
         this.form.receiptQty = this.list.reduce((acc, cur) => {
           acc =
             this.getHandleNumber(acc) +
-            this.getHandleNumber(cur.qty * cur.bagQty)
-          return acc
-        }, 0)
+            this.getHandleNumber(cur.qty * cur.bagQty);
+          return acc;
+        }, 0);
       }
     },
     // 原单单号change事件
     OrderNoChange(item) {
       if (item) {
-        const { erpOrderNo, id, supplierCode } = item
-        this.form.purchaseOrderNo = erpOrderNo
+        const { erpOrderNo, id, supplierCode } = item;
+        this.form.purchaseOrderNo = erpOrderNo;
         if (supplierCode) {
-          this.form.supplierCode = supplierCode
+          this.form.supplierCode = supplierCode;
         }
-        this.$refs.materialOrder.inStockId = id
+        this.$refs.materialOrder.inStockId = id;
         // this.fetchMaterialNoList(id);
-        this.materialDisabled = false
+        this.materialDisabled = false;
       }
     },
     // 物料编码change事件
@@ -853,105 +857,132 @@ export default {
           checkIncoming,
           materialName,
           storageEnvironment,
-          needProduceDate,
+          // needProduceDate,
           size,
           unitCode,
-          unitName
-        } = item
-        this.form.size = size
-        this.form.materialNo = materialNo
-        this.form.materialName = materialName
-        this.form.checkIncoming = checkIncoming
-        this.form.storageEnvironment = storageEnvironment
-        this.form.unitCode = unitCode
-        this.form.unitName = unitName
-        if (needProduceDate === 1) {
-          this.rules.produceDate[0].required = true
-        } else {
-          this.rules.produceDate[0].required = false
-        }
+          unitName,
+        } = item;
+        this.form.size = size;
+        this.form.materialNo = materialNo;
+        this.form.materialName = materialName;
+        this.form.checkIncoming = checkIncoming;
+        this.form.storageEnvironment = storageEnvironment;
+        this.form.unitCode = unitCode;
+        this.form.unitName = unitName;
+        // 根据后端返回的needProduceDate字段来决定是否必填
+        // if (needProduceDate === 1) {
+        //   this.rules.produceDate[0].required = true
+        // } else {
+        //   this.rules.produceDate[0].required = false
+        // }
       }
     },
-    // 收料类别
+    // 收料类别变化事件处理函数
+    // 参数v: 选择的收料类型值
     receiptTypeChange(v) {
-      console.log(v)
-      if (v === '1') {
-        this.receiptShow = true
-        this.otherShow = true
+      console.log(v);
+      // 收料类型为'1'(采购入库)时的处理逻辑
+      if (v === "1") {
+        // 显示收料单相关字段
+        this.receiptShow = true;
+        // 显示其他相关字段
+        this.otherShow = true;
+        // 如果采购订单号未定义
         if (this.purchaseOrderNo === undefined) {
-          this.materialDisabled = true
-          this.form.customerCode = undefined
-          this.$refs.form.rules.purchaseOrderNo[0].required = true
-          this.fetchOrderNoList()
+          // 禁用物料选择
+          this.materialDisabled = true;
+          // 清空客户代码
+          this.form.customerCode = undefined;
+          // 设置采购订单号为必填项
+          this.$refs.form.rules.purchaseOrderNo[0].required = true;
+          // 获取订单号列表
+          this.fetchOrderNoList();
         }
-      } else if (v === '4') {
-        this.otherShow = true
-        this.receiptShow = false
-        this.$refs.form.rules.purchaseOrderNo[0].required = false
-        this.form.customerCode = undefined
-        this.form.purchaseOrderNo = undefined
-        // this.fetchMaterialNoList();
-        this.$refs.materialOrder.inStockId = undefined
-      } else {
-        this.$refs.form.rules.purchaseOrderNo[0].required = false
-        this.receiptShow = false
-        this.otherShow = false
-        this.materialDisabled = false
-        // this.fetchMaterialNoList();
-        this.form.purchaseOrderNo = undefined
-        this.form.supplierCode = undefined
-        this.$refs.materialOrder.inStockId = undefined
+      }
+      // 收料类型为'4'(其他入库)时的处理逻辑
+      else if (v === "4") {
+        // 显示其他相关字段
+        this.otherShow = true;
+        // 禁用物料选择
+        this.materialDisabled = false;
+        // 隐藏收料单相关字段
+        this.receiptShow = false;
+        // 设置采购订单号为非必填项
+        this.$refs.form.rules.purchaseOrderNo[0].required = false;
+        // 清空客户代码
+        this.form.customerCode = undefined;
+        // 清空采购订单号
+        this.form.purchaseOrderNo = undefined;
+        // 清空物料订单的入库ID
+        this.$refs.materialOrder.inStockId = undefined;
+      }
+      // 其他收料类型的处理逻辑
+      else {
+        // 设置采购订单号为非必填项
+        this.$refs.form.rules.purchaseOrderNo[0].required = false;
+        // 隐藏收料单相关字段
+        this.receiptShow = false;
+        // 隐藏其他相关字段
+        this.otherShow = false;
+        // 启用物料选择
+        this.materialDisabled = false;
+        // 清空采购订单号
+        this.form.purchaseOrderNo = undefined;
+        // 清空供应商代码
+        this.form.supplierCode = undefined;
+        // 清空物料订单的入库ID
+        this.$refs.materialOrder.inStockId = undefined;
       }
     },
     // 根据宽度计算每包数量
     widthChange(row) {
-      const { length } = row
+      const { length } = row;
       if (length === null || length === undefined || length === 0) {
-        row.qty = undefined
-        return
+        row.qty = undefined;
+        return;
       }
-      row.qty = this.getHandleNumber((row.width / 1000) * length)
+      row.qty = this.getHandleNumber((row.width / 1000) * length);
       this.form.receiptQty = this.list.reduce(
         (sum, item) =>
           this.getHandleNumber(sum + item.qty * parseFloat(item.bagQty)),
         0
-      )
+      );
     },
     // 根据长度计算每包数量
     lengthChange(row) {
-      const { width } = row
+      const { width } = row;
       if (width === null || width === undefined || width === 0) {
-        row.qty = undefined
-        return
+        row.qty = undefined;
+        return;
       }
-      row.qty = this.getHandleNumber((width / 1000) * row.length)
+      row.qty = this.getHandleNumber((width / 1000) * row.length);
       this.form.receiptQty = this.list.reduce(
         (sum, item) =>
           this.getHandleNumber(sum + item.qty * parseFloat(item.bagQty)),
         0
-      )
+      );
     },
     // 生产日期change事件
     produceDateChange(v) {
-      const currentDate = new Date()
-      const selectedDate = new Date(v)
+      const currentDate = new Date();
+      const selectedDate = new Date(v);
 
       if (selectedDate > currentDate) {
-        this.$modal.msgWarning('生产日期不能超过当前日期,请重新选择!')
-        this.form.produceDate = undefined
+        this.$modal.msgWarning("生产日期不能超过当前日期,请重新选择!");
+        this.form.produceDate = undefined;
       } else if (v) {
         const params = {
           produceDate: v,
-          materialNo: this.form.materialNo
-        }
+          materialNo: this.form.materialNo,
+        };
 
         validateIsQuality(params)
           .then((res) => {
             if (Object.keys(res.data).length > 0) {
-              this.warningText = res.data['1005000162']
-              this.form.validTill = res.data.validTillW
+              this.warningText = res.data["1005000162"];
+              this.form.validTill = res.data.validTillW;
               if (this.warningText) {
-                this.dialogVisible = true
+                this.dialogVisible = true;
               }
             }
             // if (res.data === '1005000162') {
@@ -960,18 +991,18 @@ export default {
           })
           .catch((error) => {
             // 处理错误
-            console.log(error)
-          })
+            console.log(error);
+          });
       }
     },
     // 查询子组件物料编码列表
     fetchMaterialNoList(inStockId) {
-      this.$refs.materialOrder.inStockId = inStockId
+      this.$refs.materialOrder.inStockId = inStockId;
     },
     supplierChange(item) {
       if (item) {
-        const { code } = item
-        this.fetchOrderNoList(code)
+        const { code } = item;
+        this.fetchOrderNoList(code);
       }
     },
     // 查询子组件源单单号列表
@@ -979,53 +1010,53 @@ export default {
       const params = {
         pageNo: 1,
         pageSize: 100,
-        supplierCode
-      }
+        supplierCode,
+      };
       getDropDownList(params)
         .then((res) => {
-          this.orderOptions = res.data || []
+          this.orderOptions = res.data || [];
         })
         .finally(() => {
-          this.loading = false
-        })
+          this.loading = false;
+        });
     },
     // 附件上传
     handleUpload() {
-      this.$refs.attachmentUpload.isUploadShow = -1
-      this.$refs.attachmentUpload.title = '上传附件'
+      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 { fileId } = item.name;
+          return fileId;
+        });
         const params = {
-          files: fileIds.join(',') || null
-        }
+          files: fileIds.join(",") || null,
+        };
         getFilesById(params).then((res) => {
-          this.$refs.attachmentUpload.fileList = res.data || []
-        })
+          this.$refs.attachmentUpload.fileList = res.data || [];
+        });
       }
-      this.$refs.attachmentUpload.visible = true
+      this.$refs.attachmentUpload.visible = true;
     },
     // 获取上传的附件
     getFileList(data) {
-      this.uploadFiles = data
+      this.uploadFiles = data;
     },
     // 查看附件
     handleUploaded(data) {
-      this.$refs.attachmentUpload.fileList = data
-      this.$refs.attachmentUpload.title = '查看附件'
-      this.$refs.attachmentUpload.isUploadShow = 0
-      this.$refs.attachmentUpload.visible = true
+      this.$refs.attachmentUpload.fileList = data;
+      this.$refs.attachmentUpload.title = "查看附件";
+      this.$refs.attachmentUpload.isUploadShow = 0;
+      this.$refs.attachmentUpload.visible = true;
     },
     // 单位
     unitChange(v) {
-      const { name } = v
-      this.form.unitCode = name
-    }
-  }
-}
+      const { name } = v;
+      this.form.unitCode = name;
+    },
+  },
+};
 </script>
 <style scoped>
 .validateDate {