wangyi
2026-02-28 fd9d75b6d9c8ce5b36afd46c2751164259af24ee
src/views/scMould/warehouse/Sc_MouldMoveStockRequestBillEdit.vue
@@ -202,6 +202,8 @@
            <el-button type="success" plain icon="el-icon-arrow-down" @click="handleMoveRowDown(zbSelForm)"
              size="mini">下移</el-button>
            <el-button type="success" plain icon="el-icon-printer" @click="get_ICInventoryMould(zbSelForm)">容器库存</el-button>
            <el-button type="success" plain icon="el-icon-printer" @click="get_ContainerInstantStock(zbSelForm)">容器即时库存</el-button>
          </div>
          <el-table :data="editData" style="width: 100%" height="300" width="100%" ref="zbTable"
            @selection-change="handleTableZbEdit" :row-class-name="rowSysZbIndex" show-summary border>
@@ -233,6 +235,11 @@
                <span>{{ scope.row.HUnitName }}</span>
              </template>
            </el-table-column>
              <el-table-column align="center" label="库存数量" width="120">
            <template slot-scope="scope">
                {{ scope.row.KuHQty || 0 }}
            </template>
          </el-table-column>
            <el-table-column align="center" label="数量" width="120">
              <template slot-scope="scope">
                <el-input-number v-model="scope.row.HQty" :min="1" style="width: 90px;"
@@ -732,6 +739,91 @@
      });
    },
    /** 修改按钮操作 */
      //#region 查看容器即时库存
  async get_ContainerInstantStock(zbSelForm) {
    if (!this.zbIndex) {
      this.$modal.msgError("请选择一行数据");
      return;
    }
    var index = zbSelForm.index - 1;
    const rowData = this.editData[index];
    if (rowData.HMaterID==0) {
      this.$modal.msgError("请先选择容器");
      return;
    }
    const whId = rowData.HWHID || this.form.HWHID;
    if (!whId || whId == 0) {
      this.$modal.msgError("请先选择有效的仓库");
      return;
    }
    try {
      this.$modal.loading("正在查询库存...");
      // 获取仓库名称
      const whResponse = await axios.get(this.$baseUrl + "/CommonModel/searchMethod", {
        params: {
          "sql": `select HName from Gy_Warehouse where HItemID = ${whId}`,
          "user": sessionStorage["HUserName"],
          "ModRightNameCheck": ""
        }
      });
      const whName = whResponse.data.data[0]?.HName;
      if (!whName) {
        this.$modal.closeLoading();
        this.$modal.msgError("未找到仓库信息");
        return;
      }
      // 获取所有库存数据
      var sql = "exec h_p_Kf_ICInventory_Mould ''";
      const response = await axios.get(this.$baseUrl + "/CommonModel/searchMethod", {
        params: {
          "sql": sql,
          "user": sessionStorage["HUserName"],
          "ModRightNameCheck": ""
        }
      });
      let totalQty = 0;
      if (response.data.count == 1 && response.data.data) {
        // 基础过滤:容器ID + 仓库名称
        let filteredData = response.data.data.filter(item =>
          item['HMaterID'] == rowData.HMaterID && item['仓库'] === whName
        );
        // 如果有库位,按库位过滤
        if (rowData.HSPName) {
          filteredData = filteredData.filter(item => item['仓位'] === rowData.HSPName);
        }
        // 计算总库存
        filteredData.forEach(item => {
          totalQty += Number(item['库存数量'] || 0);
        });
      }
      // 更新当前行的库存数量
      this.$set(this.editData, index, {
        ...rowData,
        KuHQty: totalQty
      });
      this.$modal.closeLoading();
      this.$modal.msgSuccess(`库存查询成功,当前库存:${totalQty}`);
    } catch (error) {
      this.$modal.closeLoading();
      this.$modal.msgError("查询库存失败");
    }
  },
  //#endregion
    handleUpdate() {
      this.reset()
      let rowHmainid = this.linterid