index.vue 10.4 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="queryForm" :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="primary" 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>25</span> 总单据数量:<span>40</span>已出库数量:<span>80</span>
      </el-col>
    </el-row>

    <el-row :gutter="24">
      <el-col :span="12" :xs="24" style="margin: 10px 0">
        <el-card shadow="always">
          <el-table v-loading="headerLoading" :data="HeaderList" border @selection-change="headerSelectionChange">
            <el-table-column label="id" align="center" prop="id"  />
            <el-table-column label="物料编码" align="center" prop="materialCode" :formatter="materialFormat" />
            <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" />
            <el-table-column label="已出数量" align="center" prop="requestQty" />
            <el-table-column label="库存状态" align="center" prop="inventorySts" :formatter="kcstatusFormat">
              <template slot-scope="scope">
                <el-tag :type="scope.row.inventorySts | statusFilter">{{scope.row.inventorySts}}</el-tag>
              </template>
            </el-table-column>
            <el-table-column label="单位" align="center" prop="materialUnit" />
          </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">
            <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">
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="handleUpdate(scope.row)"
                  v-hasPermi="['shipment:shippingCombination:combination']"
                >组盘</el-button>
              </template>
            </el-table-column>
            <el-table-column label="id" align="center" prop="id"  />
            <el-table-column label="货主" align="center" prop="companyCode" />
            <el-table-column label="库位编号" align="center" prop="locationCode"/>
            <el-table-column label="容器编号" align="center" prop="containerCode"/>
            <el-table-column label="数量" align="center" prop="qty" />
            <el-table-column label="物料编码" align="center" prop="materialCode" />
            <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="inventorySts" :formatter="kcstatusFormat">
              <template slot-scope="scope">
                <el-tag :type="scope.row.inventorySts | statusFilter">{{scope.row.inventorySts}}</el-tag>
              </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,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: {
          receiveNum:undefined,
          /*pageNum: 1,
          pageSize: 10,*/
        },
        // 明细表单参数
        detailForm: {},
        // 明细表单校验
        detailRules: {
          shipQty: [
            {
              required: true,
              message: "发货数量不能为空",
              trigger: ["blur", "change"],
            },
          ],
          sequence: [
            {
              required: true,
              message: "序号不能为空",
              trigger: ["blur", "change"],
            },
          ],
        },
        activeName: "first",
        activeName2: "first1",
      };
    },
    created() {
      this.getHeaderList();
      this.getDicts("sys_yes_no").then((response) => {
        console.log(response)
        this.typeOptions = response.data;
      });


      // 明细字典下拉
      this.getDetailList();
      this.getDicts("sys_common_status").then(response => {
        this.materialOptions = response.data;
      });

    },

    methods: {
      /** 查询主表列表 */
      getHeaderList() {
        this.headerLoading = true;
        listHeader(this.queryHeaderParams).then((response) => {
          console.log(response);
          this.HeaderList = response.rows;
          this.headerTotal = response.total;
          this.headerLoading = false;
        });
      },
      /** 查询明细列表 */
      getDetailList() {
        this.detailLoading = true;
           (this.queryDetailParams).then((response) => {
          console.log(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();
      },
      /** 主表重置按钮操作 */
      resetHeaderQuery() {
        this.resetForm("queryHeaderForm");
        this.headerQuery();
      },

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


      /** 明细搜索按钮操作 */
      detailQuery() {
        this.queryDetailParams.pageNum = 1;
        this.getDetailList();
      },


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

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

      //状态渲染
      filters: {
        statusFilter(shipmentType) {
          const statusMap = {
            published: 'success',
            draft: 'gray',
            deleted: 'danger'
          }
          return statusMap[shipmentType]
        }
      }

    },
  };
</script>


<style lang="scss">
  .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);
  }
</style>