<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-form
          :inline="true"
          class="demo-form-inline"
          label-position="right"
          label-width="80px"
          label-suffix=":"
          size="mini"
        >

          <el-form-item label="日期">
            <label slot="label">日&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;期:</label>
            <date-range-picker v-model="query.createTime" class="date-item" />
          </el-form-item>

          <el-form-item label="产品编码">
            <el-input
              v-model="query.material_code"
              clearable
              size="mini"
              placeholder="请输入产品编码、名称"
              style="width: 230px;"
              class="filter-item"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>

          <el-form-item label="批次">
            <label slot="label">批&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;次:</label>
            <el-input
              v-model="query.pcsn"
              clearable
              size="mini"
              placeholder="请输入批次"
              style="width: 230px;"
              class="filter-item"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>
          <rrOperation />
        </el-form>
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="mini"
        style="width: 100%;"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column type="index" label="序号" width="100" align="center" />
        <template v-for="(col,index) in cols">
          <el-table-column v-if="col" :prop="col.prop" :label="col.label" width="120px" show-overflow-tooltip />
        </template>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudHpcQuery from '@/api/wms/statistics/hpcquery'
import CRUD, { presenter, header, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import DateRangePicker from '@/components/DateRangePicker'
import crudInspectionsheetmst from '@/api/wms/ql/inspectionsheetmst'

export default {
  name: 'HpcQuery',
  components: { pagination, crudOperation, rrOperation, udOperation, DateRangePicker },
  mixins: [presenter(), header(), crud()],
  cruds() {
    return CRUD({
      title: '物理性能查询',
      url: 'api/HpcQuery',
      idField: 'performance_id',
      sort: 'performance_id,desc',
      crudMethod: { ... crudHpcQuery },
      optShow: {
        add: false,
        edit: false,
        del: false,
        download: false,
        reset: true
      }
    })
  },
  data() {
    return {
      cols: [],
      statusList: [],
      permission: {
      },
      rules: {
      }}
  },
  beforeCreate() {
  },
  created() {

  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      crudHpcQuery.getHeader().then(res => {
        this.cols = res
      })
      crudInspectionsheetmst.getStatus().then(res => {
        this.statusList = res
      })
    },
    hand(value) {
      this.crud.toQuery()
    }
  }
}
</script>

<style scoped>

</style>
