<template>
  <div class="app-container">
    <el-card>
      <div>
        <el-input
          v-model="listQuery.search"
          placeholder="仓库名称/仓库编号"
          style="width: 300px"
          class="filter-item"
          @keyup.enter.native="handleFilter"
        />
        <el-button
          class="filter-item"
          type="primary"
          icon="el-icon-search"
          @click="handleFilter"
          >搜索</el-button
        >
        <el-button
          class="filter-item"
          type="primary"
          icon="el-icon-refresh-left"
          @click="resetFilter"
          >重置</el-button
        >
      </div>
    </el-card>
    <el-card >
      <el-table
        v-loading="listLoading"
        :data="InventoryList.results"
        border
        fit
        stripe
        highlight-current-row
      
          height="100"
        v-el-height-adaptive-table="{bottomOffset: 42}"
      >
        <el-table-column type="index" width="50" />
        <el-table-column label="物料批次">
          <template slot-scope="scope">{{ scope.row.batch }}</template>
        </el-table-column>
        <el-table-column label="物料名称">
          <template slot-scope="scope">{{ scope.row.material_.name }}</template>
        </el-table-column>
           <el-table-column label="规格型号">
          <template slot-scope="scope">{{ scope.row.material_.specification }}</template>
        </el-table-column>
           <el-table-column label="有效期">
          <template slot-scope="scope">{{ scope.row.expiration_date }}</template>
        </el-table-column>
      
        <el-table-column label="物料编号">
          <template slot-scope="scope">{{
            scope.row.material_.number
          }}</template>
        </el-table-column>
        <el-table-column label="仓库名称">
          <template slot-scope="scope">{{
            scope.row.warehouse_.name
          }}</template>
        </el-table-column>
        <el-table-column label="仓库编号">
          <template slot-scope="scope">{{
            scope.row.warehouse_.number
          }}</template>
        </el-table-column>
        <el-table-column label="物料总存量">
          <template slot-scope="scope">{{ scope.row.count }}</template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="InventoryList.count > 0"
        :total="InventoryList.count"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.page_size"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>
<script>
import {
  getInventoryList,
  getfifoList,
  getmaterialbatchList,
  createInventory,
  getWarehouseList,
} from "@/api/inm";
import checkPermission from "@/utils/permission";
import { getMaterialList } from "@/api/mtm";
import { getUserList } from "@/api/user";
import { genTree } from "@/utils";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination

export default {
  components: { Pagination },
  data() {
    return {
      InventoryList: {
        count: 0,
      },

      listQuery: {
        page: 1,
        page_size: 20,
      },

      rule1: {
        name: [{ required: true, message: "请输入", trigger: "blur" }],
      },
    };
  },
  computed: {},
  watch: {},
  created() {
    this.getList();
  },
  methods: {
    checkPermission,

    getList() {
      this.listLoading = true;

      getmaterialbatchList(this.listQuery).then((response) => {
        if (response.data) {
          this.InventoryList = response.data;
        }
        this.listLoading = false;
      });
    },

    handleFilter() {
      this.listQuery.page = 1;
      this.getList();
    },
    resetFilter() {
      this.listQuery = {
        page: 1,
        page_size: 20,
      };
      this.getList();
    },
  },
};
</script>
