index.vue 12.1 KB
<template>
  <div class="app-container">
    <el-row :gutter="24">
      <el-col :span="8" :xs="24" style="margin-bottom: 10px; ">
        <el-form :model="queryHeaderParams" ref="headerForm" :inline="true">
          <el-form-item label="出库单号" prop="code">
            <el-input
              v-model="queryHeaderParams.code"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="headerQuery"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="cyan" icon="el-icon-search" size="small" @click="headerQuery">搜索</el-button>
            <!--<el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>-->
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="12" :offset="4" :xs="24" class="info_text">
        物料总数:<span>{{HeaderList.length}}</span> 总单据数量:<span>{{billTotal}}</span>已出库数量:<span>{{checkoutTotal}}</span>
      </el-col>
    </el-row>

    <el-row :gutter="24">
      <el-col :span="12" :xs="24" style="margin: 10px 0">
        <el-card shadow="always">
          <!--<right-toolbar :showSearch.sync="showHeaderSearch" @queryTable="getHeaderList"></right-toolbar>-->
          <el-table v-loading="headerLoading" :data="HeaderList" border @selection-change="headerSelectionChange" highlight-current-row @row-click="handle" ref="table">
            <el-table-column label="id" width="55" align="center" prop="id"  />
            <el-table-column label="物料编码" align="center" prop="materialCode" width="120px"/>
            <el-table-column label="物料名称" align="center" prop="materialName" :show-overflow-tooltip="true" />
            <el-table-column label="物料规格" align="center" prop="materialSpec" :show-overflow-tooltip="true" />
            <el-table-column label="单据数量" align="center" prop="shipQty" width="78px" />
            <el-table-column label="已出数量" align="center" prop="requestQty" width="78px" />
            <el-table-column label="库存状态" align="center" prop="inventorySts" :formatter="kcstatusFormat" width="78px">
              <template slot-scope="scope">
                <el-button size="mini" type="primary" round>{{
                  kcstatusFormat(scope.row, scope.column)
                  }}</el-button>
              </template>
            </el-table-column>
            <el-table-column label="单位" align="center" prop="materialUnit" width="60px" />
          </el-table>

          <pagination
            v-show="headerTotal > 0"
            :total="headerTotal"
            :page.sync="queryHeaderParams.pageNum"
            :limit.sync="queryHeaderParams.pageSize"
            @pagination="getHeaderList"
          />
        </el-card>
      </el-col>

      <el-col :span="12" :xs="24" style="margin: 10px 0">
        <el-card shadow="always">
          <el-form :model="queryDetailParams" ref="detailForm" :rules="detailRules">
            <el-form-item label="出库数量" prop="receiveNum">
              <el-input
                v-model="queryDetailParams.receiveNum"
                clearable
                size="small"
                style="width: 240px"
                @keyup.enter.native="detailQuery"
              />
            </el-form-item>
          </el-form>
          <el-table v-loading="detailLoading" :data="DetailList" border @selection-change="detailSelectionChange" ref="table">
            <el-table-column fixed="left" label="操作" width="60" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="handleGroup(scope.row)"
                  v-hasPermi="['shipment:shippingCombination:combination']"
                >组盘</el-button>
              </template>
            </el-table-column>
            <el-table-column label="id" width="55" align="center" prop="id"  />
            <el-table-column label="货主" width="55" align="center" prop="companyCode" />
            <el-table-column label="库位编号" align="center" prop="locationCode" :show-overflow-tooltip="true" />
            <el-table-column label="容器编号" align="center" prop="containerCode" :show-overflow-tooltip="true" />
            <el-table-column label="数量" width="55" align="center" prop="qty" />
            <el-table-column label="物料编码" align="center" prop="materialCode" :show-overflow-tooltip="true" />
            <el-table-column label="物料名称" align="center" prop="materialName" :show-overflow-tooltip="true" />
            <el-table-column label="物料规格" align="center" prop="materialSpec" :show-overflow-tooltip="true" />
            <el-table-column label="库存状态" width="75" align="center" prop="inventorySts" :formatter="kcstatusFormat">
              <template slot-scope="scope">
                <el-button size="mini" type="primary" round>{{
                  kcstatusFormat(scope.row, scope.column)
                  }}</el-button>
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="detailTotal > 0"
            :total="detailTotal"
            :page.sync="queryDetailParams.pageNum"
            :limit.sync="queryDetailParams.pageSize"
            @pagination="getDetailList"
          />
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import {listHeader,listDetail,getGroupdisk,delDetail,} from "@/api/shipment/shippingCombination";
  export default {
    name: "ShippingCombination",
    data() {
      return {
        // 主表遮罩层
        headerLoading: true,
        // 主表选中数组
        headerIds: [],
        // 主表非单个禁用
        headerSingle: true,
        // 主表非多个禁用
        headerMultiple: true,
        // 主表显示搜索条件
        showHeaderSearch: true,
        // 主表总条数
        headerTotal: 0,
        // 主表表格数据
        HeaderList: [],

        // 主表弹出层标题
        headerTitle: "",
        // 主表是否显示弹出层
        headerOpen: false,
        // 主表数据字典

        // 主表查询参数
        queryHeaderParams: {
          pageNum: 1,
          pageSize: 10,
          code: undefined,
        },
        // 主表表单参数
        headerForm: {},
        // 主表表单校验
        headerRules: {},
        // 明细遮罩层
        detailLoading: true,
        // 明细选中数组
        detailIds: [],
        // 明细非单个禁用
        detailSingle: true,
        // 明细非多个禁用
        detailMultiple: true,
        // 明细显示搜索条件
        showDetailSearch: true,
        // 明细总条数
        detailTotal: 0,
        // 明细表格数据
        DetailList: [],
        // 明细弹出层标题
        detailTitle: "",
        // 明细是否显示弹出层
        detailOpen: false,
        // 明细库存数据字典
        kcstatusOptions: [],
        // 明细查询参数
        queryDetailParams: {
          pageNum: 1,
          pageSize: 10,
          receiveNum:undefined,
          id:'',
          code:'',
        },

        groupDiskParams:{
          shipmentDetailId:'',
          inventoryDetailId:'',
          shipQty:'',
        },
        // 明细表单参数
        detailForm: {},
        // 明细表单校验
        detailRules: {
          receiveNum: [
            {
              pattern: /^[0-9]+$/,
              message: "请输入正确的数字",
              trigger: ["blur", "change"],
            },
          ],

        },

      };
    },

    //计算右上角总单据数量、已出库数量
    computed:{
      billTotal:function () {
        let result = 0
        for(let i=0;i<this.HeaderList.length;i++){
          result +=this.HeaderList[i].shipQty
        }
        return result
      },
      checkoutTotal:function () {
        let result = 0
        for(let i=0;i<this.HeaderList.length;i++){
          result +=this.HeaderList[i].requestQty
        }
        return result
      }
    },

      created() {
      this.queryHeaderParams.code = this.$route.query.shipmentCode;
      this.getHeaderList();


      // 库存状态字典下拉
      this.getDicts("inventorySts").then(response => {
        this.kcstatusOptions = response.data;
      });
    },

    // 对路由参数的变化作出监测(解决同步刷新问题)
    watch: {
      $route(to, from) {
        //当参数改变时就会触发比方法,以此达到数据属性
        this.queryHeaderParams.code = this.$route.query.shipmentCode;
        this.getHeaderList();
        }
      },

    beforeUpdate() {
      this.$nextTick(() => {
        this.$refs["table"].doLayout();
      });
    },

    methods: {
      /** 查询主表列表 */
      getHeaderList() {
        this.headerLoading = true;
        listHeader(this.queryHeaderParams).then((response) => {
          this.HeaderList = response.data
          this.headerTotal = response.total;
          this.headerLoading = false;
        });
      },


      //左表单击选中时触发的事件
      handle(row,event,column) {
          this.detailLoading = true;
          this.queryDetailParams.id = row.id;
          this.groupDiskParams.shipmentDetailId = row.id;
          this.queryDetailParams.receiveNum = row.shipQty;
          this.queryDetailParams.code = this.$route.query.shipmentCode;
        this.getDetailList();

      },
      /** 查询明细列表 */
      getDetailList() {
        this.detailLoading = true;
        listDetail(this.queryDetailParams).then((response) => {
          this.DetailList = response.rows;
          this.detailTotal = response.total;
          this.detailLoading = false;
        });
      },
      // 明细库存状态字典翻译
      kcstatusFormat(row, column) {
        return this.selectDictLabel(this.kcstatusOptions, row.inventorySts);
      },

      /** 主表搜索按钮操作 */
      headerQuery() {
        this.queryHeaderParams.pageNum = 1;
        this.getHeaderList();
      },


      // 主表多选框选中数据
      headerSelectionChange(selection) {
        this.headerIds = selection.map((item) => item.id);
        this.headerSingle = selection.length != 1;
        this.headerMultiple = !selection.length;
      },


      // 明细多选框选中数据
      detailSelectionChange(selection) {
        this.detailIds = selection.map((item) => item.id);
        this.detailSingle = selection.length != 1;
        this.detailMultiple = !selection.length;
      },

      //右表组盘
      handleGroup(row) {
        this.groupDiskParams.inventoryDetailId = row.id;
        this.groupDiskParams.shipQty = this.queryDetailParams.receiveNum;
        getGroupdisk(this.groupDiskParams).then(response => {
          this.groupDiskParams.shipQty = '';
          if(response.code == 200) {
            this.msgSuccess(response.msg);
           //数量更改后重新加载左右表
            this.getHeaderList();
            this.getDetailList();
          }
          else {
            this.msgError(response.msg)
          }
        })
      },

      /** 明细删除按钮操作 */
      detailDelete(row) {
        const detailIds = row.id || this.detailIds;
        this.$confirm(
          row.id?'是否确认取消该条组盘信息吗?':'是否确认取消选中的' + this.detailIds.length + '条数据项?',
          "警告",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }
        )
          .then(function () {
            return delDetail(detailIds);
          })
          .then(() => {
            this.getDetailList();
            this.msgSuccess("删除成功");
          })
          .catch(function () {});
      },


    },
  };
</script>


<style lang="scss" scoped>
  .info_text{margin-top: 10px;text-align: right}
  .info_text span {
    font-size: 20px;
    font-weight: bold;
    margin-right: 20px;
    color: rgb(28,132,198);
  }
  .el-button--mini.is-round {
    padding: 5px 10px;
  }
</style>