llj
2026-04-08 8cd0e22e4a194252c4639bebdec59f565f393f93
src/views/scMould/warehouse/Sc_MouldInRequestBillEdit.vue
@@ -3,7 +3,7 @@
    <div style=" margin-bottom: 10px; border-bottom: 1px solid #f6f6f6;">
      <!-- <el-button type="primary" @click="handleAdd(OperationType = 1)" v-if="addBtnShow">新增</el-button> -->
      <el-button type="primary" @click="submitForm" :disabled="subDisabled">保 存</el-button>
      <el-button type="primary" @click="set_CheckBill(1, form)">审 核</el-button>
      <!-- <el-button type="primary" @click="set_CheckBill(1, form)">审 核</el-button> -->
      <el-button type="primary" @click="close">退 出</el-button>
      <!-- <el-button @click="cancel">取 消</el-button> -->
    </div>
@@ -14,7 +14,7 @@
          <el-row>
            <el-col :span="6">
              <el-form-item v-show="HIsShow" label="单据号" prop="HBillNo">
                <el-input v-model="form.HBillNo" placeholder="请输入单据号" />
                <el-input v-model="form.HBillNo" placeholder="请输入单据号" disabled/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
@@ -34,7 +34,7 @@
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item v-show="HIsShow" label="往来类型" prop="HSupTypeID">
              <el-form-item v-show="false" label="往来类型" prop="HSupTypeID">
                <el-select v-model="form.HSupTypeID" placeholder="请选择往来类型" @change="form.HSupName='',form.HSupId=0">
                  <el-option v-for="(item, index) in hSupTypeList" :key="index" :label="item.name" :value="item.id">
                  </el-option>
@@ -42,7 +42,7 @@
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item v-show="HIsShow" label="往来单位" prop="HSupName">
              <el-form-item v-show="false" label="往来单位" prop="HSupName">
                <el-input v-model="form.HSupName" placeholder="请选择往来单位" disabled>
                  <el-button slot="append" icon="el-icon-search" @click="openDataDialogChoose()"></el-button>
                </el-input>
@@ -72,7 +72,7 @@
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item v-show="HIsHide" label="主管" prop="HMangerName">
              <el-form-item v-show="HIsShow" label="主管" prop="HMangerName">
                <el-input v-model="form.HMangerName" placeholder="请选择" disabled>
                  <el-button slot="append" icon="el-icon-search" @click="openDataDialog(4,empType=2)"></el-button>
                </el-input>
@@ -90,6 +90,16 @@
                <el-input v-model="form.HKeeperName" placeholder="请选择" disabled>
                  <el-button slot="append" icon="el-icon-search" @click="openDataDialog(4,empType=4)"></el-button>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item v-show="HIsShow" label="子单据类型" prop="HBillSubType">
                <el-select v-model="form.HBillSubType" placeholder="请选择子单据类型">
                  <el-option label="采购入库" value="采购入库"></el-option>
                  <el-option label="生产入库" value="生产入库"></el-option>
                  <el-option label="客返" value="客返"></el-option>
                  <el-option label="供应商返还" value="供应商返还"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
@@ -184,7 +194,8 @@
              size="mini">上移</el-button>
            <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_ICInvget_ContainerInstantStockentoryMould(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>
@@ -216,6 +227,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;"
@@ -299,6 +315,7 @@
      HIsShow: true,
      HIsHide: false,
      HModName: "Sc_MouldInRequestBill",
      HBillSubType:'',
      formShow: false,
      temp: undefined,
      formLoading: true,
@@ -383,15 +400,18 @@
        HStockOrgID: [
          { required: true, message: "组织不能为空", trigger: "blur" }
        ],
        HEmpName: [
          { required: true, message: "业务员不能为空", trigger: "blur" }
        HBillSubType: [
          { required: true, message: "子单据类型不能为空", trigger: "blur" }
        ],
        HSecManagerName: [
          { required: true, message: "验收员不能为空", trigger: "blur" }
        ],
        HKeeperName: [
          { required: true, message: "保管员不能为空", trigger: "blur" }
        ]
        // HEmpName: [
        //   { required: true, message: "业务员不能为空", trigger: "blur" }
        // ],
        // HSecManagerName: [
        //   { required: true, message: "验收员不能为空", trigger: "blur" }
        // ],
        // HKeeperName: [
        //   { required: true, message: "保管员不能为空", trigger: "blur" }
        // ]
      }
    };
  },
@@ -552,6 +572,7 @@
        HInterID: 0,
        HDate: new Date(),
        HStockOrgID:sessionStorage["OrganizationID"] - 0,
        HBillSubType: '',
        HSupTypeID:1,
        HSupName:'',
        HSupID:0,
@@ -637,7 +658,7 @@
      //新增获取单据号
      this.getHBillNo()
      let date = new Date()
      this.form.HDate = moment(date).format('YYYY-MM-DD')
      this.form.HDate = moment(date).format('YYYY-MM-DD HH:mm:ss')
      if (this.OperationType == 1) {
        this.handleAddSysZb()
      }
@@ -646,6 +667,90 @@
        this.formLoading = false
      })
    },
    //#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
    getHBillNo() {
      axios.get(this.$baseUrl + "/WEBSController/GetMaxBillNo_Json", {
        params: {
@@ -674,7 +779,7 @@
          if (this.copyType == 1) {
            this.getHBillNo()
            let date = new Date()
            this.form.HDate = moment(date).format('YYYY-MM-DD')
            this.form.HDate = moment(date).format('YYYY-MM-DD HH:mm:ss')
          } else {
            this.form = {
                  "HBillNo": data.单据号
@@ -697,6 +802,7 @@
                , "HExplanation": data.摘要
                , "HRemark": data.表头备注
                , "HStockOrgID": data.HStockOrgID
                , "HBillSubType": data.子单据类型
                
                , "HMaker": data.制单人
                , "HMakeDate": data.制单日期 == null ? "" : data.制单日期
@@ -911,6 +1017,9 @@
    
    // 编辑提交保存
    submitForm() {
        if (this.form.HDate) {
      this.form.HDate = moment(this.form.HDate).format('YYYY-MM-DD');
    }
      this.$refs["form"].validate(valid => {
        if (valid) {
          let fhck = false