1
647556386
109 分钟以前 2bdda9b2bedb8f084e364e92627f19e1938dceca
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue
@@ -18,12 +18,12 @@
              <el-divider direction="vertical"></el-divider>
              <span class="less-style">物料编号: {{ row.materielCode }} </span>
              <el-divider direction="vertical"></el-divider>
              <span class="less-style"
                >需求数量: {{ row.orderQuantity }}
              <span class="less-style">
                éœ€æ±‚数量: {{ requireQuantity }}
              </span>
              <el-divider direction="vertical"></el-divider>
              <span :class="selectionClass"
                >已选数量: {{ selectionSum }}
              <span :class="selectionClass">
                å·²é€‰æ•°é‡ï¼š {{ selectionSum }}
              </span>
            </el-col>
            <el-col :span="8">
@@ -47,6 +47,8 @@
          @row-click="handleRowClick"
          height="500px"
          @selection-change="handleSelectionChange"
          @select="selectRowChange"
          @select-all="selectAllChange"
        >
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column
@@ -149,7 +151,6 @@
<script>
import VolBox from "@/components/basic/VolBox.vue";
// å¼•入站台管理工具
import { stationManager } from "@/../src/uitils/stationManager";
export default {
@@ -161,55 +162,18 @@
      mainOrderNo: "",
      pkcx: false,
      showDetialBox: false,
      showStationDialog: false, // ç«™å°é€‰æ‹©å¼¹çª—显示控制
      showStationDialog: false,
      tableData: [],
      dictionaryList: null, // æ–°å¢žï¼šå­—典数据
      dictionaryList: null,
      tableColumns: [
        {
          prop: "materielCode",
          title: "物料编号",
          type: "string",
          width: 150,
        },
        {
          prop: "materielName",
          title: "物料名称",
          type: "string",
          width: 150,
        },
        {
          prop: "palletCode",
          title: "托盘编号",
          type: "string",
          width: 150,
        },
        {
          prop: "barcode",
          title: "条码",
          type: "string",
          width: 150,
        },
        {
          prop: "locationCode",
          title: "货位编号",
          type: "string",
          width: 180,
        },
        {
          prop: "useableQuantity",
          title: "可用数量",
          type: "string",
        },
        {
          prop: "supplyCode",
          title: "供应商",
          type: "string",
        },
        {
          prop: "batchNo",
          title: "批次号",
          type: "string",
        },
        { prop: "materielCode", title: "物料编号", type: "string", width: 150 },
        { prop: "materielName", title: "物料名称", type: "string", width: 150 },
        { prop: "palletCode", title: "托盘编号", type: "string", width: 150 },
        { prop: "barcode", title: "条码", type: "string", width: 150 },
        { prop: "locationCode", title: "货位编号", type: "string", width: 180 },
        { prop: "useableQuantity", title: "可用数量", type: "string" },
        { prop: "supplyCode", title: "供应商", type: "string" },
        { prop: "batchNo", title: "批次号", type: "string" },
        {
          prop: "stockStatus",
          title: "库存明细状态",
@@ -217,54 +181,48 @@
          width: 90,
          bindKey: "stockStatusEmun",
        },
        {
          prop: "stockId",
          title: "库存主键",
          type: "string",
        },
        {
          prop: "orderDetailId",
          title: "单据明细主键",
          type: "string",
        },
        { prop: "stockId", title: "库存主键", type: "string" },
        { prop: "orderDetailId", title: "单据明细主键", type: "string" },
      ],
      selection: [],
      selectionSum: 0,
      selectionClass: "less-style",
      originalQuantity: 0,
      
      // ç«™å°ç›¸å…³æ•°æ®
      stations: [
        { label: "站台2", value: "2-1" },
        { label: "站台3", value: "3-1" },
      ],
      stationForm: {
        selectedPlatform: "", // ä¿®æ”¹å­—段名以匹配参数
        selectedPlatform: "",
      },
      isProcessingSelect: false,
    };
  },
  computed: {
    requireQuantity() {
      if (!this.row) return 0;
      return this.row.orderQuantity - this.row.lockQuantity - (this.row.moveQty || 0);
    },
    isFull() {
      return this.selectionSum >= this.requireQuantity && this.requireQuantity > 0;
    }
  },
  methods: {
    open(row, orderNo) {
      this.row = row;
      this.mainOrderNo = orderNo;
      this.showDetialBox = true;
      this.originalQuantity = this.row.lockQuantity;
      this.selectionSum = this.row.lockQuantity;
      
      // åŠ è½½å­—å…¸æ•°æ®
      this.originalQuantity = 0;
      this.selectionSum = 0;
      this.selection = [];
      this.getDictionaryData();
      this.getData();
      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.updateSelectionStyle();
    },
    // èŽ·å–å­—å…¸æ•°æ®
    getDictionaryData() {
      if (this.dictionaryList) {
        return;
@@ -284,7 +242,6 @@
        });
    },
    // èŽ·å–å­—å…¸å€¼
    getDictionary(row, column) {
      if (this.dictionaryList) {
        var item = this.dictionaryList.find((x) => x.dicNo == column.bindKey);
@@ -295,40 +252,32 @@
          } else {
            return row[column.prop];
          }
        } else {
          return row[column.prop];
        }
      }
      return row[column.prop];
    },
    // æ‰“开站台选择弹窗
    openStationDialog() {
      if (this.selection.length <= 0) {
        return this.$message.error("请先勾选要出库的库存");
      }
      // ä»Žç¼“存中获取默认站台
      const cachedStation = stationManager.getStation();
      this.stationForm.selectedPlatform = cachedStation || "";
      this.showStationDialog = true;
    },
    // ç¡®è®¤å‡ºåº“
    async confirmOutbound() {
      if (!this.stationForm.selectedPlatform) {
        return this.$message.error("请选择出库站台");
      }
      // å‡†å¤‡è¯·æ±‚参数
      const requestParams = {
        detailIds: [this.row.id], // å‡ºåº“单的明细ID
        outboundTargetLocation: this.stationForm.selectedPlatform, // é€‰æ‹©çš„站台
        outboundQuantity: this.selectionSum, // å·²é€‰æ•°é‡
        operator: this.getCurrentOperator(), // èŽ·å–å½“å‰æ“ä½œäºº
        orderNo: this.mainOrderNo, // å•据编号
        stockDetailIds: this.selection.map(item => item.stockId) // åº“存明细主键数组
        detailIds: [this.row.id],
        outboundTargetLocation: this.stationForm.selectedPlatform,
        outboundQuantity: this.selectionSum,
        operator: this.getCurrentOperator(),
        orderNo: this.mainOrderNo,
        stockDetailIds: this.selection.map((item) => item.stockId),
      };
      try {
@@ -337,11 +286,9 @@
          requestParams,
          "数据处理中"
        );
        if (!x.status) {
          return this.$message.error(x.message);
        }
        this.$message.success("出库任务创建成功");
        this.showStationDialog = false;
        this.showDetialBox = false;
@@ -353,25 +300,18 @@
      }
    },
    // èŽ·å–å½“å‰æ“ä½œäºº
    getCurrentOperator() {
      // å¯ä»¥ä»Žæœ¬åœ°å­˜å‚¨ã€Vuex或全局状态中获取当前用户
      try {
        // ç¤ºä¾‹ï¼šä»ŽlocalStorage获取用户信息
        const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}');
        const userInfo = JSON.parse(localStorage.getItem("userInfo") || "{}");
        if (userInfo.userName) {
          return userInfo.userName;
        }
        // ç¤ºä¾‹ï¼šä»ŽVuex获取用户信息
        if (this.$store && this.$store.state.user) {
          return this.$store.state.user.userName;
        }
      } catch (error) {
        console.error('获取操作人信息失败:', error);
        console.error("获取操作人信息失败:", error);
      }
      // é»˜è®¤æ“ä½œäºº
      return "admin";
    },
@@ -389,96 +329,111 @@
        )
        .then((x) => {
          this.tableData = x;
          this.clearSelection();
        });
    },
    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";
    // ç‚¹å‡»è¡Œå‹¾é€‰ - æœ€ç»ˆä¿®å¤ç‰ˆ
    handleRowClick(row) {
      // åˆ¤æ–­å½“前行是否已选中
      const isSelected = this.selection.some(s => s.stockId === row.stockId);
      // å·²é€‰ä¸­ â†’ å…è®¸å–消勾选
      if (isSelected) {
        this.$refs.singleTable.toggleRowSelection(row);
        return;
      }
      // æœªé€‰ä¸­ + å·²æ»¡ â†’ ç¦æ­¢æ–°å¢žï¼ŒæŠ¥é”™
      if (this.isFull) {
        this.$message.error(`已达到需求数量 ${this.requireQuantity},无法再勾选库存!`);
        return;
      }
      // æ­£å¸¸å‹¾é€‰
      this.$refs.singleTable.toggleRowSelection(row);
    },
    // å‹¾é€‰æ¡†é€‰æ‹© - æœ€ç»ˆä¿®å¤ç‰ˆ
    selectRowChange(selection, row) {
      if (this.isProcessingSelect) return;
      const isAdding = selection.some(x => x.stockId === row.stockId);
      // æ–°å¢žå‹¾é€‰ + å·²æ»¡ â†’ æ‹¦æˆª
      if (isAdding && this.isFull) {
        this.isProcessingSelect = true;
        this.$message.error(`已达到需求数量 ${this.requireQuantity},无法再勾选!`);
        this.$nextTick(() => {
          this.$refs.singleTable.toggleRowSelection(row, false);
          this.isProcessingSelect = false;
        });
      }
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.singleTable.toggleRowSelection(row);
        });
      } else {
    // å…¨é€‰ - æœ€ç»ˆä¿®å¤ç‰ˆ
    selectAllChange(selection) {
      if (this.isProcessingSelect) return;
      const allTotal = this.tableData.reduce((sum, item) => sum + (item.useableQuantity || 0), 0);
      const need = this.requireQuantity;
      if (allTotal > need && selection.length > 0) {
        this.isProcessingSelect = true;
        this.$message.error(`全选数量超出需求,已清空选择!`);
        this.$refs.singleTable.clearSelection();
        this.selection = [];
        this.selectionSum = 0;
        this.updateSelectionStyle();
        this.$nextTick(() => {
          this.isProcessingSelect = false;
        });
      }
    },
    // é€‰æ‹©è®¡ç®—
    handleSelectionChange(val) {
      if (this.isProcessingSelect) return;
      let total = val.reduce((s, i) => s + (i.useableQuantity || 0), 0);
      const need = this.requireQuantity;
      this.selectionSum = total >= need ? need : total;
      this.selection = val;
      this.updateSelectionStyle();
    },
    updateSelectionStyle() {
      if (this.isFull) {
        this.selectionClass = "equle-style";
      } else {
        this.selectionClass = "less-style";
      }
    },
    clearSelection() {
      this.$refs.singleTable.clearSelection();
    },
    handleRowClick(row) {
      this.$refs.singleTable.toggleRowSelection(row);
      this.selection = [];
      this.selectionSum = 0;
      this.updateSelectionStyle();
    },
  },
};
</script>
<style scoped>
.less-style {
  color: black;
}
.equle-style {
  color: green;
}
.more-style {
  color: red;
}
/* ç«™å°é€‰æ‹©å¼¹çª—样式 */
.station-dialog-content {
  padding: 10px 0;
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.text-button:hover {
  background-color: #f0f9eb !important;
}
.el-table .warning-row {
  background: oldlace;
}
.box-table .el-table tbody tr:hover > td {
  background-color: #d8e0d4 !important;
}
.box-table .el-table tbody tr.current-row > td {
  background-color: #f0f9eb !important;
}
.el-table .success-row {
  background: #f0f9eb;
}
.box-table .el-table {
  border: 1px solid #ebeef5;
}
.box-head .el-alert__content {
  width: 100%;
}
.less-style { color: black; }
.equle-style { color: green; }
.more-style { color: red; }
.station-dialog-content { padding: 10px 0; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; }
.text-button:hover { background-color: #f0f9eb !important; }
.el-table .warning-row { background: oldlace; }
.box-table .el-table tbody tr:hover > td { background-color: #d8e0d4 !important; }
.box-table .el-table tbody tr.current-row > td { background-color: #f0f9eb !important; }
.el-table .success-row { background: #f0f9eb; }
.box-table .el-table { border: 1px solid #ebeef5; }
.box-head .el-alert__content { width: 100%; }
</style>