heshaofeng
2026-01-13 d741e7a7ad7de5045e5c6b6145d9da1783cadecd
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue
@@ -1,9 +1,10 @@
<template>
  <div>
    <!-- åº“存指定弹窗 -->
    <vol-box
      v-model="showDetialBox"
      :lazy="true"
      width="60%"
      width="80%"
      :padding="15"
      title="指定库存"
    >
@@ -11,6 +12,8 @@
        <el-alert :closable="false" style="width: 100%">
          <el-row>
            <el-col :span="16">
              <span class="less-style">单据编号:{{ mainOrderNo }}</span>
              <el-divider direction="vertical"></el-divider>
              <span class="less-style">物料名称: {{ row.materielName }} </span>
              <el-divider direction="vertical"></el-divider>
              <span class="less-style">物料编号: {{ row.materielCode }} </span>
@@ -24,13 +27,6 @@
              </span>
            </el-col>
            <el-col :span="8">
             <!--  <el-link
                type="primary"
                size="small"
                style="float: right; height: 20px"
                @click="getData(false)"
                >{{ kcname }}</el-link
              > -->
              <el-link
                type="primary"
                size="small"
@@ -38,13 +34,6 @@
                @click="getData"
                >刷新</el-link
              >
      <!--         <el-link
                type="primary"
                size="small"
                style="float: right; height: 20px; margin-right: 10px"
                @click="revokeAssign"
                >撤销分配</el-link
              > -->
            </el-col>
          </el-row>
        </el-alert>
@@ -58,7 +47,6 @@
          @row-click="handleRowClick"
          height="500px"
          @selection-change="handleSelectionChange"
        >
          >
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column
@@ -92,30 +80,78 @@
        </el-table>
      </div>
      <template #footer>
       <!--  <el-button type="primary" size="small" @click="outbound"
        <el-button type="primary" size="small" @click="openStationDialog"
          >直接出库</el-button
        >
        <el-button type="primary" size="small" @click="lockStock"
          >锁定库存</el-button
        > -->
        <el-button type="danger" size="small" @click="showDetialBox = false"
          >关闭</el-button
        >
      </template>
    </vol-box>
    <!-- ç«™å°é€‰æ‹©å¼¹çª— -->
    <el-dialog
      v-model="showStationDialog"
      title="选择出库站台"
      width="500px"
      :close-on-click-modal="false"
    >
      <div class="station-dialog-content">
        <el-form :model="stationForm" label-width="100px">
          <el-form-item label="选择站台:" required>
            <el-select
              v-model="stationForm.selectedPlatform"
              placeholder="请选择出库站台"
              style="width: 100%"
            >
              <el-option
                v-for="item in stations"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="出库数量:">
            <el-input
              v-model="selectionSum"
              readonly
              style="width: 100%"
            ></el-input>
          </el-form-item>
          <el-form-item label="物料信息:">
            <div style="font-size: 12px; color: #666; line-height: 1.5">
              <div>物料编号:{{ row.materielCode }}</div>
              <div>物料名称:{{ row.materielName }}</div>
            </div>
          </el-form-item>
        </el-form>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="showStationDialog = false">取消</el-button>
          <el-button type="primary" @click="confirmOutbound">确认出库</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script>
import VolBox from "@/components/basic/VolBox.vue";
import { fa } from "element-plus/es/locales.mjs";
// å¼•入站台管理工具
import { stationManager } from "@/../src/uitils/stationManager";
export default {
  components: { VolBox },
  data() {
    return {
      row: null,
      kcname: "",
      mainOrderNo: "",
      pkcx: false,
      showDetialBox: false,
      showStationDialog: false, // ç«™å°é€‰æ‹©å¼¹çª—显示控制
      tableData: [],
      tableColumns: [
        {
@@ -137,6 +173,12 @@
          width: 150,
        },
        {
          prop: "barcode",
          title: "条码",
          type: "string",
          width: 150,
        },
        {
          prop: "locationCode",
          title: "货位编号",
          type: "string",
@@ -147,21 +189,51 @@
          title: "可用数量",
          type: "string",
        },
        {
          prop: "supplyCode",
          title: "供应商",
          type: "string",
        },
        {
          prop: "batchNo",
          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: "", // ä¿®æ”¹å­—段名以匹配参数
      },
    };
  },
  methods: {
    open(row) {
      console.log(row);
    open(row, orderNo) {
      this.row = row;
      this.mainOrderNo = orderNo;
      this.showDetialBox = true;
      this.originalQuantity = this.row.lockQuantity;
      this.selectionSum = this.row.lockQuantity;
      this.getData();
      if (this.selectionSum == this.row.orderQuantity) {
        this.selectionClass = "equle-style";
      } else if (this.selectionSum < this.row.orderQuantity) {
@@ -170,40 +242,80 @@
        this.selectionClass = "more-style";
      }
    },
    lockStock() {
      this.http
        .post(
          "api/OutboundOrderDetail/LockOutboundStock?id=" + this.row.id,
          this.selection,
          "数据处理中"
        )
        .then((x) => {
          if (!x.status) return this.$message.error(x.message);
          this.$message.success("操作成功");
          this.showDetialBox = false;
          this.$emit("parentCall", ($vue) => {
            $vue.getData();
          });
        });
    },
    outbound() {
    // æ‰“开站台选择弹窗
    openStationDialog() {
      if (this.selection.length <= 0) {
        return this.$message.error("请勾选");
        return this.$message.error("请先勾选要出库的库存");
      }
      let url = this.pkcx
        ? "api/Task/GenerateOutboundTask?orderDetailId="
        : "api/Task/GenerateOutboundTask?orderDetailId=";
      this.http
        .post(url + this.row.id, this.selection, "数据处理中")
        .then((x) => {
          if (!x.status) return this.$message.error(x.message);
          this.$message.success("操作成功");
      // ä»Žç¼“存中获取默认站台
      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) // åº“存明细主键数组
      };
      try {
        const x = await this.http.post(
          "api/Outbound/ProcessPickingOutbound",
          requestParams,
          "数据处理中"
        );
        if (!x.status) {
          return this.$message.error(x.message);
        }
        this.$message.success("出库任务创建成功");
        this.showStationDialog = false;
          this.showDetialBox = false;
          this.$emit("parentCall", ($vue) => {
            $vue.getData();
          });
        });
      } catch (error) {
        this.$message.error(error.message || "出库处理失败");
      }
    },
    // èŽ·å–å½“å‰æ“ä½œäºº
    getCurrentOperator() {
      // å¯ä»¥ä»Žæœ¬åœ°å­˜å‚¨ã€Vuex或全局状态中获取当前用户
      try {
        // ç¤ºä¾‹ï¼šä»ŽlocalStorage获取用户信息
        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);
      }
      // é»˜è®¤æ“ä½œäºº
      return "admin";
    },
    getData(a) {
      if (!a) this.pkcx = !this.pkcx;
      let url = this.pkcx
@@ -220,23 +332,7 @@
          this.tableData = x;
        });
    },
    revokeAssign() {
      console.log(this.row);
      this.http
        .post(
          "api/OutboundOrderDetail/RevokeLockOutboundStock?id=" + this.row.id,
          null,
          "数据处理中"
        )
        .then((x) => {
          if (!x.status) return this.$message.error(x.message);
          this.$message.success("操作成功");
          this.showDetialBox = false;
          this.$emit("parentCall", ($vue) => {
            $vue.getData();
          });
        });
    },
    handleSelectionChange(val) {
      this.selection = val;
      this.selectionSum =
@@ -253,6 +349,7 @@
        this.selectionClass = "more-style";
      }
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
@@ -262,15 +359,18 @@
        this.$refs.singleTable.clearSelection();
      }
    },
    clearSelection() {
      this.$refs.singleTable.clearSelection();
    },
    handleRowClick(row) {
      this.$refs.singleTable.toggleRowSelection(row);
    },
  },
};
</script>
<style scoped>
.less-style {
  color: black;
@@ -282,6 +382,17 @@
.more-style {
  color: red;
}
/* ç«™å°é€‰æ‹©å¼¹çª—样式 */
.station-dialog-content {
  padding: 10px 0;
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
</style>
@@ -296,12 +407,10 @@
.box-table .el-table tbody tr:hover > td {
  background-color: #d8e0d4 !important;
  /* color: #ffffff; */
}
.box-table .el-table tbody tr.current-row > td {
  background-color: #f0f9eb !important;
  /* color: #ffffff; */
}
.el-table .success-row {