wangxinhui
2025-03-01 d11b1f9c98e8765d3cee15abd4474b0e05a5acbc
´úÂë¹ÜÀí/WMS/WIDESEA_WMSClient/src/extension/basic/materielCodeInfo.js
@@ -14,8 +14,92 @@
  tableAction: '', //指定某张表的权限(这里填写表名,默认不用填写)
  buttons: { view: [], box: [], detail: [] }, //扩展的按钮
  methods: {
    //获取表单配置
    getOption(field) {
      let option;
      this.editFormOptions.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        })
      })
      return option;
    },
    formatDate(dateStr) {
      let date = new Date(dateStr);
      let year = date.getFullYear();
      let month = String(date.getMonth() + 1).padStart(2, "0");
      let day = String(date.getDate()).padStart(2, "0");
      return year + "-" + month + "-" + day;
    },
    // æ–°å¢žæ–¹æ³•:加载物料编号数据
    async loadMaterielCodes(option) {
      try {
        option.loading = true;
        const { page, pageSize, keyword } = option.pagination;
        const res = await this.http.post("/api/PurchaseOrderDetail/GetPurchaseOrderDetailMaterielCode", {
          warehouseId: this.editFormFields.warehouseId,
          keyword,
          page,
          pageSize
        }, true);
        if (res.status) {
          option.pagination.total = res.total || res.data.length;
          const newData = res.data.map(item => ({ key: item, value: item }));
          option.data = page === 1 ? newData : [...option.data, ...newData];
        }
      } catch (error) {
        this.$error("数据加载失败");
      } finally {
        option.loading = false;
      }
    },
    //下面这些方法可以保留也可以删除
    onInit() {  //框架初始化配置前,
      this.$nextTick(() => {
        let warehouseIdOption = this.getOption("warehouseId");
        let materielCodeOption = this.getOption("materielCode");
        let purchaseOrderNoOption = this.getOption("purchaseOrderNo");
        let materielQueryOption = this.getOption("materielQuery");
        warehouseIdOption.onChange = (val, option) => {
          this.editFormFields.materielCode = "";
          materielCodeOption.data = [];
          this.editFormFields.purchaseOrderNo = "";
          purchaseOrderNoOption.data = [];
          if (val == null || val == 0) {
            return this.$error("请选择仓库!")
          }
          this.http.post("/api/PurchaseOrderDetail/GetPurchaseOrderDetailMaterielCode?warehouseId=" + val, {}, true).then(
            source => {
              if (!source.status) return this.$error(source.message);
              this.$nextTick(() => {
                for (let i = 0; i < source.data.length; i++) {
                  materielCodeOption.data.push({ key: source.data[i], value: source.data[i] })
                }
              })
            })
        }
        materielCodeOption.onChange = (val, option) => {
          this.editFormFields.purchaseOrderNo = "";
          purchaseOrderNoOption.data = [];
          if (val == null || val == 0) {
            return this.$error("请选择物料编号!")
          }
          this.http.post("/api/PurchaseOrderDetail/GetPurchaseOrderNos?materielCode=" + val, {}, true).then(
            source => {
              if (!source.status) return this.$error(source.message);
              this.$nextTick(() => {
                for (let i = 0; i < source.data.length; i++) {
                  purchaseOrderNoOption.data.push({ key: source.data[i], value: source.data[i] })
                }
              });
            })
        }
      });
      this.columns.push({
        field: '操作',
        title: '操作',
@@ -65,6 +149,16 @@
      //(3)this.editFormFields.字段='xxx';
      //如果需要给下拉框设置默认值,请遍历this.editFormOptions找到字段配置对应data属性的key值
      //看不懂就把输出看:console.log(this.editFormOptions)
      let isAdd = this.currentAction == 'Add';
      if (isAdd) {
        let date = new Date();
        let year = date.getFullYear();
        let month = String(date.getMonth() + 1).padStart(2, "0");
        let day = String(date.getDate()).padStart(2, "0");
        this.editFormFields.lotNo = year + month + day;
        this.editFormFields.productionDate = year + "-" + month + "-" + day;
        this.editFormFields.effectiveDate = year + 2 + "-" + month + "-" + day;
      }
    }
  }
};