<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <el-input
        v-model="query.search"
        clearable
        style="width: 300px"
        size="mini"
        placeholder="输入编码或名称"
        prefix-icon="el-icon-search"
        class="filter-item"
      />
      <rrOperation />
      <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="载具编码" prop="vehicle_code">
            <el-input v-model="form.vehicle_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="载具条码值">
            <el-input v-model="form.vehicle_value" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否打印" prop="is_print">
            <el-input v-model="form.is_print" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="生产区域" prop="product_area">
            <el-input v-model="form.product_area" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否可用" prop="is_active">
            <el-input v-model="form.is_active" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否删除" prop="is_delete">
            <el-input v-model="form.is_delete" 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="vehicle_code" label="载具编码" />
        <el-table-column prop="vehicle_value" label="载具条码值" />
        <el-table-column prop="print_num" label="打印次数" />
        <el-table-column prop="is_print" label="是否打印" />
        <el-table-column prop="print_time" label="打印时间" />
        <el-table-column prop="product_area" label="生产区域" />
        <el-table-column prop="is_active" label="是否可用" />
        <el-table-column prop="is_delete" label="是否删除" />
        <el-table-column prop="create_name" label="创建人" />
        <el-table-column prop="create_time" label="创建时间" />
        <el-table-column prop="update_name" label="修改人" />
        <el-table-column prop="update_time" label="修改时间" />
        <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 crudCachelineVehicle from '@/api/wms/cacheline/vehicle/cachelineVehicle'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation.vue'
import crudOperation from '@crud/CRUD.operation.vue'
import udOperation from '@crud/UD.operation.vue'
import pagination from '@crud/Pagination.vue'

const defaultForm = { vehicle_code: null, vehicle_value: null, print_num: null, is_print: null, print_time: null, product_area: null, is_active: null, is_delete: null, create_id: null, create_name: null, create_time: null, update_id: null, update_name: null, update_time: null }
export default {
  name: 'CachelineVehicle',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '缓存线载具',
      url: 'api/cachelineVehicle',
      idField: 'vehicle_code',
      sort: 'vehicle_code,desc',
      crudMethod: { ...crudCachelineVehicle }
    })
  },
  data() {
    return {
      permission: {
      },
      rules: {
        vehicle_code: [
          { required: true, message: '载具编码不能为空', trigger: 'blur' }
        ],
        is_print: [
          { required: true, message: '是否打印不能为空', trigger: 'blur' }
        ],
        product_area: [
          { required: true, message: '生产区域不能为空', trigger: 'blur' }
        ],
        is_active: [
          { required: true, message: '是否可用不能为空', trigger: 'blur' }
        ],
        is_delete: [
          { required: true, message: '是否删除不能为空', trigger: 'blur' }
        ]
      }}
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
