<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=":"
        >
          <el-form-item label="载具类型">
            <el-select
              v-model="query.vehicle_type"
              clearable
              size="mini"
              placeholder="请选择"
              class="filter-item"
              style="width: 180px;"
              @change="hand"
            >
              <el-option
                v-for="item in dict.vehicle_type"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="载具号">
            <el-input
              v-model="query.vehicle_code"
              clearable
              size="mini"
              placeholder="载具号"
              style="width: 180px;"
              class="filter-item"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>
          <rrOperation />
        </el-form>
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， 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.vehicle_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="载具名称">
            <el-input v-model="form.vehicle_name" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="载具类型">
            <el-input v-model="form.vehicle_type" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="一维码">
            <el-input v-model="form.one_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="二维码">
            <el-input v-model="form.two_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="RFID编码">
            <el-input v-model="form.rfid_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="载具宽度">
            <el-input v-model="form.vehicle_width" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="载具长度">
            <el-input v-model="form.vehicle_long" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="载具高度">
            <el-input v-model="form.vehicle_height" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="载具超仓位类型">
            <el-input v-model="form.overstruct_type" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="占仓位数">
            <el-input v-model="form.occupystruct_qty" 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="载具编码" :min-width="flexWidth('vehicle_code',crud.data,'载具编码')" />
        <el-table-column prop="vehicle_name" label="载具名称" :min-width="flexWidth('vehicle_name',crud.data,'载具名称')" />
        <el-table-column prop="vehicle_type" label="载具类型" :min-width="flexWidth('vehicle_type',crud.data,'载具类型')" />
        <el-table-column prop="one_code" label="一维码" :min-width="flexWidth('one_code',crud.data,'一维码')" />
        <el-table-column prop="two_code" label="二维码" :min-width="flexWidth('two_code',crud.data,'二维码')" />
        <el-table-column prop="rfid_code" label="RFID编码" :min-width="flexWidth('rfid_code',crud.data,'RFID编码')" />
        <el-table-column prop="vehicle_width" label="载具宽度" :min-width="flexWidth('vehicle_width',crud.data,'载具宽度')" />
        <el-table-column prop="vehicle_long" label="载具长度" :min-width="flexWidth('vehicle_long',crud.data,'载具长度')" />
        <el-table-column prop="vehicle_height" label="载具高度" :min-width="flexWidth('vehicle_height',crud.data,'载具高度')" />
        <el-table-column prop="overstruct_type" label="载具超仓位类型" :min-width="flexWidth('overstruct_type',crud.data,'载具超仓位类型')" />
        <el-table-column prop="occupystruct_qty" label="占仓位数" :min-width="flexWidth('occupystruct_qty',crud.data,'占仓位数')" />
        <el-table-column prop="create_name" label="创建人" :min-width="flexWidth('create_name',crud.data,'创建人')" />
        <el-table-column prop="create_time" label="创建时间" :min-width="flexWidth('create_time',crud.data,'创建时间')" />
        <el-table-column prop="update_name" label="修改人" :min-width="flexWidth('update_name',crud.data,'修改人')" />
        <el-table-column prop="update_time" label="修改时间" :min-width="flexWidth('update_time',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 crudMdBaseVehicle from './mdBaseVehicle'
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 = {
  vehicle_code: null,
  vehicle_name: null,
  vehicle_type: null,
  one_code: null,
  two_code: null,
  rfid_code: null,
  vehicle_width: null,
  vehicle_long: null,
  vehicle_height: null,
  overstruct_type: null,
  occupystruct_qty: null,
  ext_id: null,
  create_id: null,
  create_name: null,
  create_time: null,
  update_id: null,
  update_name: null,
  update_time: null
}
export default {
  name: 'Vehicle',
  dicts: ['vehicle_type'],
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '载具维护',
      url: 'api/mdBaseVehicle',
      idField: 'vehicle_code',
      sort: 'vehicle_code,desc',
      crudMethod: { ...crudMdBaseVehicle }
    })
  },
  data() {
    return {
      permission: {
      },
      rules: {
      }
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
