<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="90px"
          label-suffix=":"
        >
          <el-form-item label="点位编码">
            <el-select
              v-model="query.point_code"
              clearable
              size="mini"
              placeholder="点位编码"
              class="filter-item"
              filterable
              @remote-method="getPointList"
            >
              <el-option
                v-for="item in pointList"
                :label="item.point_code"
                :value="item.point_code"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="晶体编号">
            <el-input
              v-model="query.lotSN"
              clearable
              size="mini"
              placeholder="晶体编号"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>
          <el-form-item label="供应商名称">
            <el-select
              v-model="query.supplierName"
              clearable
              size="mini"
              placeholder="供应商名称"
              class="filter-item"
              filterable
              @remote-method="getSupplierNameList"
            >
              <el-option
                v-for="item in supplierNameList"
                :label="item"
                :value="item"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="物料名称">
            <el-select
              v-model="query.productDescription"
              clearable
              size="mini"
              placeholder="物料名称"
              class="filter-item"
              filterable
              @remote-method="getProductDescriptionList"
            >
              <el-option
                v-for="item in productDescriptionList"
                :label="item"
                :value="item"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="批次">
            <el-select
              v-model="query.ingotBatch"
              clearable
              size="mini"
              placeholder="批次"
              class="filter-item"
              filterable
              @remote-method="getIngotBatchList"
            >
              <el-option
                v-for="item in ingotBatchList"
                :label="item"
                :value="item"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="每托根数">
            <el-input-number
              v-model="query.number"
              filterable
              laceholder="每托根数"
              clearable
              controls-position="right"
              :min="0"
              :max="10000"
              :step="10"
              size="mini"
            />
          </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%;" height="300" @selection-change="crud.selectionChangeHandler">
        <el-table-column prop="pointCode" label="点位编码" :min-width="flexWidth('pointCode',crud.data,'点位编码')" />
        <el-table-column prop="regionName" label="区域名称" :min-width="flexWidth('regionName',crud.data,'区域名称')" />
        <el-table-column prop="subTray" label="子托编码" :min-width="flexWidth('subTray',crud.data,'子托编码')" />
        <el-table-column prop="motherTray" label="母托编码" :min-width="flexWidth('motherTray',crud.data,'母托编码')" />
        <el-table-column prop="supplierName" label="供应商名称" :min-width="flexWidth('supplierName',crud.data,'供应商名称')" />
        <el-table-column prop="productDescription" label="物料名称" :min-width="flexWidth('productDescription',crud.data,'物料名称')" />
        <el-table-column prop="ingotBatch" label="批次" :min-width="flexWidth('ingotBatch',crud.data,'批次')" />
        <el-table-column prop="siliconGrade" label="棒源等级" :min-width="flexWidth('siliconGrade',crud.data,'棒源等级')" />
        <el-table-column prop="number" label="每托数量(根)" :min-width="flexWidth('number',crud.data,'每托数量(根)')" />
        <el-table-column prop="updateTime" label="入库时间" :min-width="flexWidth('updateTime',crud.data,'入库时间')" />
        <el-table-column prop="usedTime" label="已回温时间H" :min-width="flexWidth('usedTime',crud.data,'已回温时间H')" />
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudMaterial from './detail'
import CRUD, { crud, header, presenter } 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 crudSchBasePoint from '@/views/wms/sch/point/schBasePoint'

export default {
  name: 'HwIn',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), crud()],
  cruds() {
    return CRUD({
      title: '回温间入库明细',
      url: 'api/report/hw/in',
      idField: 'group_id',
      sort: '',
      optShow: {
        add: false,
        edit: false,
        del: false,
        download: true,
        reset: false
      },
      query: {
      }
    })
  },
  data() {
    return {
      permission: {
      },
      rules: {
      },
      pointList: [],
      supplierNameList: [],
      ingotBatchList: [],
      productDescriptionList: [],
      choose: '物料',
      dialogVisible: false
    }
  },
  created() {
    this.getPointList()
    this.getSupplierNameList()
    this.getIngotBatchList()
    this.getProductDescriptionList()
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    getPointList() { // 获取点位列表
      crudSchBasePoint.getPointsByRegionCodes('YL,YLHC,KJHC').then(res => {
        this.pointList = res
      })
    },
    getSupplierNameList() {
      crudMaterial.getSupplierNameList().then(res => {
        this.supplierNameList = res.content
      })
    },
    getProductDescriptionList() {
      crudMaterial.getProductDescriptionList().then(res => {
        this.productDescriptionList = res.content
      })
    },
    getIngotBatchList() {
      crudMaterial.getIngotBatchList().then(res => {
        this.ingotBatchList = res.content
      })
    }
  }
}
</script>

<style scoped>

</style>
