<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 style="margin-top: 2px">
      
      <el-table
        v-loading="listLoading"
        :data="InventoryList.results"
        border
        fit
        stripe
        highlight-current-row
        max-height="600"
      >
      
     
        <el-table-column type="index" width="50" />
        <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_.number }}</template>
        </el-table-column>
          <el-table-column label="物料单位">
          <template slot-scope="scope">{{ scope.row.material_.unit }}</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"> {{options_[scope.row.material_.type]}}</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,getfifodetailList,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,
      },
      options_:{
        
        "1":'成品',
        "2":'半成品',
        "3":'主要原料',
        "4":'辅助材料',
         "5":'加工工具',
        "6":'辅助工装',
       
      },
      listLoading: true,
      dialogVisible: false,
      dialogType: "new",
      rule1: {
        name: [{ required: true, message: "请输入", trigger: "blur" }],
        
      },
    };
  },
  computed: {},
  watch: {},
  created() {
    this.getList();
  },
  methods: {
    checkPermission,
    
    getList() {
      this.listLoading = true;
      if(this.$route.params.id!="")
      {
        this.listQuery.warehouse=this.$route.params.id;
        getInventoryList(this.listQuery).then((response) => {
        if (response.data) {
          this.InventoryList = response.data;
        }
        this.listLoading = false;
      });
      }
      else
      {
         getInventoryList(this.listQuery).then((response) => {
        if (response.data) {
          this.InventoryList = response.data;
        }
        this.listLoading = false;
      });
      }
      
    },
   
  },
};
</script>
