<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog
        :close-on-click-modal="false"
        :before-close="crud.cancelCU"
        :visible.sync="crud.status.cu > 0"
        :title="crud.status.title"
        width="500px"
      >
        <el-form ref="form" :model="form" :rules="rules" size="mini" label-width="80px">
          <el-form-item label="当前抓取工位">
            <el-input v-model="form.get_station" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="当前放置工位">
            <el-input v-model="form.put_station" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否合格">
            <el-input v-model="form.is_qualified" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="激光标刻码">
            <el-input v-model="form.laser_marking_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="碾次">
            <el-input v-model="form.grinding_number" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="高度1">
            <el-input v-model="form.height1" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="高度2">
            <el-input v-model="form.height2" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="高度3">
            <el-input v-model="form.height3" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="高度4">
            <el-input v-model="form.height4" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="宽度1">
            <el-input v-model="form.width1" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="宽度2">
            <el-input v-model="form.width2" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="长度">
            <el-input v-model="form.len" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="体积">
            <el-input v-model="form.volume" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="平面度">
            <el-input v-model="form.flatness" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="缺陷个数">
            <el-input v-model="form.unqualified_qty" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="组盘标识">
            <el-input v-model="form.group_id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否组盘">
            <el-input v-model="form.is_group" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="mini"
        style="width: 100%;"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column
          prop="get_station"
          label="当前抓取工位"
          :min-width="flexWidth('get_station',crud.data,'当前抓取工位')"
        />
        <el-table-column
          prop="put_station"
          label="当前放置工位"
          :min-width="flexWidth('put_station',crud.data,'当前放置工位')"
        />
        <el-table-column
          prop="is_qualified"
          label="是否合格"
          :min-width="flexWidth('is_qualified',crud.data,'是否合格')"
        />
        <el-table-column
          prop="laser_marking_code"
          label="激光标刻码"
          :min-width="flexWidth('laser_marking_code',crud.data,'激光标刻码')"
        />
        <el-table-column
          prop="grinding_number"
          label="碾次"
          :min-width="flexWidth('grinding_number',crud.data,'碾次')"
        />
        <el-table-column prop="height1" label="高度1" :min-width="flexWidth('height1',crud.data,'高度1')" />
        <el-table-column prop="height2" label="高度2" :min-width="flexWidth('height2',crud.data,'高度2')" />
        <el-table-column prop="height3" label="高度3" :min-width="flexWidth('height3',crud.data,'高度3')" />
        <el-table-column prop="height4" label="高度4" :min-width="flexWidth('height4',crud.data,'高度4')" />
        <el-table-column prop="width1" label="宽度1" :min-width="flexWidth('width1',crud.data,'宽度1')" />
        <el-table-column prop="width2" label="宽度2" :min-width="flexWidth('width2',crud.data,'宽度2')" />
        <el-table-column prop="len" label="长度" :min-width="flexWidth('len',crud.data,'长度')" />
        <el-table-column prop="volume" label="体积" :min-width="flexWidth('volume',crud.data,'体积')" />
        <el-table-column prop="flatness" label="平面度" :min-width="flexWidth('flatness',crud.data,'平面度')" />
        <el-table-column
          prop="unqualified_qty"
          label="缺陷个数"
          :min-width="flexWidth('unqualified_qty',crud.data,'缺陷个数')"
        />
        <el-table-column prop="group_id" label="组盘标识" :min-width="flexWidth('group_id',crud.data,'组盘标识')" />
        <el-table-column prop="is_group" label="是否组盘" :min-width="flexWidth('is_group',crud.data,'是否组盘')" />
        <el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudMdBaseBrickInfo from './mdBaseBrickInfo'
import CRUD, { crud, form, 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'

const defaultForm = {
  brick_id: null,
  get_station: null,
  put_station: null,
  is_qualified: null,
  laser_marking_code: null,
  grinding_number: null,
  height1: null,
  height2: null,
  height3: null,
  height4: null,
  width1: null,
  width2: null,
  len: null,
  volume: null,
  flatness: null,
  unqualified_qty: null,
  group_id: null,
  is_group: null
}
export default {
  name: 'BrickInfo',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '每块砖的信息记录',
      url: 'api/mdBaseBrickInfo',
      idField: 'brick_id',
      sort: 'brick_id,desc',
      crudMethod: { ...crudMdBaseBrickInfo },
      optShow: {
        add: false,
        edit: false,
        del: false,
        download: false
      }
    })
  },
  data() {
    return {
      permission: {},
      rules: {}
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
