dengjunjie
2025-05-26 d845312bb27972771b566054a906cc25af83e209
´úÂë¹ÜÀí/WMS/WIDESEA_WMSClient/src/extension/outbound/extend/ProStockSelect.vue
@@ -3,7 +3,7 @@
      <vol-box
        v-model="showDetialBox"
        :lazy="true"
        width="80%"
        width="78%"
        :padding="15"
        title="指定库存"
      >
@@ -21,8 +21,8 @@
                  >需求数量: {{ row.qtyPcs }}
                </span>
                <el-divider direction="vertical"></el-divider>
                <span class="less-style"
                  >已分配数量: {{ row.lockQtyPcs }}
                <span :class="selectionClass"
                  >已选数量: {{ selectionSum }}
                </span>
              </el-col>
              <el-col>
@@ -57,24 +57,33 @@
              align="center"
            ></el-table-column>
            <el-table-column
              v-for="(item, index) in tableColumns"
              v-for="(item, index) in tableColumns.filter((x) => !x.hidden)"
              :key="index"
              :prop="item.prop"
              :label="item.title"
              :width="item.width"
              align="center"
            >
              <template #default="scoped" v-if="item.type == 'icon'">
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="item.title"
                  placement="bottom"
                  ><el-button
                    type="text"
                    @click="tableButtonClick(scoped.row, item)"
                    ><i :class="item.icon" style="font-size: 22px"></i></el-button
                ></el-tooltip>
              <template #default="scoped">
                <div v-if="item.type == 'icon'">
                  <el-tooltip
                    class="item"
                    effect="dark"
                    :content="item.title"
                    placement="bottom"
                    ><el-link
                      type="primary"
                      :disabled="getButtonEnable(item.prop, scoped.row)"
                      @click="tableButtonClick(scoped.row, item)"
                      ><i :class="item.icon" style="font-size: 22px"></i></el-link
                  ></el-tooltip>
                </div>
                <div v-else-if="item.type == 'tag'">
                  <el-tag size="small">
                    {{ getDictionary(scoped.row, item) }}
                  </el-tag>
                </div>
              </template>
            </el-table-column>
          </el-table>
@@ -93,6 +102,7 @@
  <script>
  import VolBox from "@/components/basic/VolBox.vue";
  import { fa } from "element-plus/es/locales.mjs";
import { el } from 'element-plus/es/locale';
  export default {
    components: { VolBox },
    data() {
@@ -104,46 +114,78 @@
        tableData: [],
        tableColumns: [
          {
            field: "proStockId",
            prop: "proStockId",
            title: "库存信息主键",
            type: "string",
            width: 90,
            align: "left"
            hidden: true,
          },
          {
            field: "productCode",
            prop: "proStockAttribute",
            title: "库存属性",
            type: "tag",
            width: 110,
            bindKey: "proStockAttributeEnum",
          },
          {
            prop: "locationCode",
            title: "仓储位置",
            type: "string",
            width: 130,
          },
          {
            prop: "palletCode",
            title: "外包号",
            type: "string",
            width: 130,
          },
          {
            prop: "productCode",
            title: "产品编码",
            type: "string",
            width: 140,
            align: "left",
          },
          {
            field: "productVersion",
            prop: "productVersion",
            title: "产品版本",
            type: "string",
            width: 80,
            align: "left",
            width: 100,
          },
          {
            field: "dateCode",
            prop: "dateCode",
            title: "周期",
            type: "string",
            width: 80,
            align: "left",
            width: 120,
          },
          {
            field: "saleOrder",
            prop: "erpOrder",
            title: "ERP工单",
            type: "string",
            width: 200,
          },
          {
            prop: "moNumber",
            title: "制造单",
            type: "string",
            width: 140,
          },
          {
            prop: "saleOrder",
            title: "销售订单",
            type: "string",
            width: 200,
            align: "left",
          },
          {
            field: "sumStocks",
            prop: "sumStocks",
            title: "库存PCS数",
            type: "string",
            width: 90,
            align: "left",
            width: 120,
          },
          {
            prop: "createDate",
            title: "创建时间",
            type: "string",
            width: 160,
          },
        //   {
        //     field: "lotNumber",
@@ -213,6 +255,7 @@
        //   },
        ],
        selection: [],
        isTrue: false,
        selectionSum: 0,
        selectionClass: "less-style",
        originalQuantity: 0,
@@ -224,8 +267,9 @@
        this.row = row;
        this.showDetialBox = true;
        this.originalQuantity = this.row.lockQuantity;
        this.selectionSum = this.row.lockQuantity;
        this.selectionSum = this.row.lockQtyPcs;
        this.getData();
        this.getDictionaryData();
        if (this.selectionSum == this.row.orderQuantity) {
          this.selectionClass = "equle-style";
        } else if (this.selectionSum < this.row.orderQuantity) {
@@ -238,9 +282,7 @@
        if (this.selection.length <= 0) {
          return this.$message.error("请勾选");
        }
        let url = this.pkcx
          ? "api/Task/GeneratePKOutboundTask?orderDetailId="
          : "api/Task/GenerateOutboundTask?orderDetailId=";
        let url ="api/Task/OutProductSelect?orderDetailId=";
        this.http
          .post(url + this.row.id, this.selection, "数据处理中")
          .then((x) => {
@@ -250,6 +292,7 @@
            this.$emit("parentCall", ($vue) => {
              $vue.getData();
            });
            this.$parent.refresh();
          });
      },
      getData(a) {
@@ -266,20 +309,41 @@
          });
      },
      handleSelectionChange(val) {
        this.selection = val;
        this.selectionSum =
          val.reduce(
            (accumulator, currentValue) =>
              accumulator + currentValue["useableQuantity"],
            0
          ) + this.originalQuantity;
        if (this.selectionSum == this.row.orderQuantity) {
          this.selectionClass = "equle-style";
        } else if (this.selectionSum < this.row.orderQuantity) {
          this.selectionClass = "less-style";
        } else {
          this.selectionClass = "more-style";
        }
        this.selection=val;
        this.CheckSelection(val);
        //判断勾选中的sumStocks数量如果当前勾选数大于row.qtyPcs则取消勾选
        // if (this.selection.length<=0) {
        //   this.selection = val;
        //   this.selectionSum = val[0].sumStocks;
        // }else{
        //   if (this.selectionSum + val[0].sumStocks > this.row.qtyPcs) {
        //     this.$message.error("勾选数量已满足需求数量,无需再勾选");
        //   }else {
        //     this.selection = val;
        //     this.selectionSum += val[0].sumStocks;
        //   }
        // }1
      },
      CheckSelection(rows) {
          if (rows.length <= 0) {
            this.selectionSum = this.row.lockQtyPcs;
          } else {
            if (this.selectionSum >= this.row.qtyPcs) {
              this.$message.error("已满足需求数量,无需再勾选");
              //移除this.selection中最后一个
              this.$refs.singleTable.toggleRowSelection(this.selection[this.selection.length - 1],false);
              this.selection.splice(-1, 1);
              this.selectionSum = this.selection.reduce((sum, item) => {
                return sum + item.sumStocks;
              }, 0)+this.row.lockQtyPcs;
            }else {
              this.selectionSum=0;
              rows.forEach(row => {
                this.selectionSum+= row.sumStocks;
              });
              this.selectionSum+=this.row.lockQtyPcs;
            }
          }
      },
      toggleSelection(rows) {
        if (rows) {
@@ -295,6 +359,41 @@
      },
      handleRowClick(row) {
        this.$refs.singleTable.toggleRowSelection(row);
      },
      getDictionaryData() {
        if (this.dictionaryList) {
          return;
        }
        var param = [];
        this.tableColumns.forEach((x) => {
          if (x.type == "tag" && x.bindKey != "") {
            param.push(x.bindKey);
          }
        });
        this.http
          .post("api/Sys_Dictionary/GetVueDictionary", param, "查询中")
          .then((x) => {
            if (x.length > 0) {
              this.dictionaryList = x;
              console.log(this.dictionaryList);
            }
          });
      },
      getDictionary(row, column) {
        if (this.dictionaryList) {
          var item = this.dictionaryList.find((x) => x.dicNo == column.bindKey);
          if (item) {
            var dicItem = item.data.find((x) => x.key == row[column.prop]);
            console.log(dicItem);
            if (dicItem) {
              return dicItem.value;
            } else {
              return row[column.prop];
            }
          } else {
            return row[column.prop];
          }
        }
      },
    },
  };
@@ -343,4 +442,7 @@
  .box-head .el-alert__content {
    width: 100%;
  }
  .el-table__header .el-checkbox {
    display: none;
  }
  </style>