<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="物料名称">
        <el-input
          v-model="queryParams.FMaterialName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料类型">
        <el-input
          v-model="queryParams.FBaseProperty"
          placeholder="请输入物料类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="序号" align="center" prop="id" />
      <el-table-column label="规格型号" align="center" prop="FModel" />
      <el-table-column label="物料名称" align="center" prop="FMaterialName" />
      <el-table-column label="仓库名称" align="center" prop="FStockName" />
      <el-table-column label="库存量" align="center" prop="FBaseQty" />
      <el-table-column label="物料类型" align="center" prop="FBaseProperty" />
      <el-table-column label="创建日期" align="center" prop="FUpdateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.FUpdateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getStkInventory } from "@/api/stock/realStock/index"

export default {
  name: "Data",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 是否显示弹出层
      open: false,
      // 总条数
      total: 0,
      // 检验单数据
      dataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        FMaterialName: null,
        FBaseProperty: null
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询检验单 */
    getList() {
      this.loading = true
      getStkInventory(this.queryParams).then(res => {
        this.dataList = res.rows;
        this.total = res.total;
        this.loading = false;
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        FMaterialName: null,
        FBaseProperty: null
      }
      this.handleQuery()
    }
  }
}
</script>
