<template>
  <div>
    <el-card class="el-card">
      <el-form :model="filterQuery" class="query-form" size="mini" label-width="100px" v-show="showSearch">
        <el-row>
          <el-col :span="18">
            <el-form-item class="query-form-item" label="编码:">
              <el-input v-model="filterQuery.code" placeholder="请扫描或输入编码" ref="inputRef" clearable style="width: 97%" @keyup.enter.native="keyup_submit($event)"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="top-right-btn">
        <el-button-group>
          <el-button icon="el-icon-view" type="primary" @click="hideSearch">显示/隐藏搜索栏</el-button>
          <el-button type="primary" icon="el-icon-refresh" @click="onReset">重置</el-button>
          <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
        </el-button-group>
      </div>

      <el-table v-loading="loading" :data="list" style="width: 100%" highlight-current-row
                border>
        <el-table-column label="序号" type="index"></el-table-column>
        <el-table-column label="部门" prop="deptName" width="180"></el-table-column>
        <el-table-column label="仓库" prop="invName" width="180"></el-table-column>
        <el-table-column label="货位" prop="invSpaceName" width="180"></el-table-column>
        <el-table-column label="单号" v-if="filterQuery.type === 2" prop="orderId" width="120"></el-table-column>
        <el-table-column label="DI/物资编码" prop="relId" width="150"></el-table-column>
        <el-table-column label="物资名称" prop="productName" width="200" show-overflow-tooltip></el-table-column>
        <el-table-column label="数量" prop="count" width="150" show-overflow-tooltip></el-table-column>
        <el-table-column label="规格型号" prop="ggxh" width="150" show-overflow-tooltip></el-table-column>
        <el-table-column label="批次号" prop="batchNo" width="120"></el-table-column>
        <el-table-column label="生产日期" prop="productionDate" width="120"></el-table-column>
        <el-table-column label="失效日期" prop="expireDate" width="120"></el-table-column>
        <el-table-column label="计量单位" prop="measname" width="120"></el-table-column>
        <el-table-column label="注册备案号" prop="zczbhhzbapzbh" show-overflow-tooltip
                         width="200"></el-table-column>
        <el-table-column label="生产厂家" prop="manufactory" show-overflow-tooltip
                         width="200"></el-table-column>
        <el-table-column label="供应商" prop="supName" show-overflow-tooltip
                         width="200"></el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :limit.sync="filterQuery.limit"
        :page.sync="filterQuery.page"
        @pagination="getList"
      ></pagination>
    </el-card>

  </div>
</template>

<script>

import {getInvPlaceOrderList, selectPlaceList} from "@/api/inventory/invPlaceOrder";

export default {
  name: "InvProducts",
  data() {
    return {
      filterQuery: {
        code: null,
        page: 1,
        limit: 20,
      },
      list: [],
      total: 0,
      invList: [],
      spaceList: [],
      loading: false,
      showSearch: true
    };
  },
  methods: {
    hideSearch() {
      this.showSearch = !this.showSearch;
    },
    onReset() {
      this.$router.push({
        path: "",
      });
      this.filterQuery = {
        code:null,
        page: 1,
        limit: 20,
      };
      this.getList();
    },
    onSubmit() {
      this.filterQuery.page = 1;
      this.getList();
    },
    getList() {
      this.loading = true;
      selectPlaceList(this.filterQuery).then((res) => {
        this.loading = false;
        if (res.code === 20000) {
          this.list = res.data.list || [];
          this.total = res.data.total || 0;
        } else {
          this.$message.error(res.message);
          this.list = [];
          this.total = 0;
        }
      }).catch((error) => {
        this.loading = false;
        this.$message.error(error.message);
        this.list = [];
        this.total = 0;
      });
    },
    keyup_submit(event) {
      this.getList();
      this.$refs.inputRef.focus();
      this.$refs.inputRef.select();
    },
  },
  components: {},
  mounted() {
    document.body.ondrop = function (event) {
      event.preventDefault();
      event.stopPropagation();
    };
  },
  created() {
  },
};
</script>

<style type="text/scss" lang="scss">
</style>

