<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-input
              v-model="query.repair_item_code"
              clearable
              size="mini"
              placeholder="请输入编码、名称"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>
          <el-form-item label="维修要求">
            <el-input
              v-model="query.requirement"
              clearable
              size="mini"
              placeholder="请输入要求"
              @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="750px">
        <el-form ref="form" :model="form" :rules="rules" size="mini" label-width="120px">
          <el-row>
            <el-col span="12">
              <el-form-item label="维修项目编码:" prop="repair_item_code">
                <el-input v-model="form.repair_item_code" style="width: 200px;" />
              </el-form-item>
            </el-col>
            <el-col span="12">
              <el-form-item label="维修项目名称:" prop="repair_item_name">
                <el-input v-model="form.repair_item_name" style="width: 200px;" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col span="24">
              <el-form-item label="维修要求:" prop="requirement">
                <el-input v-model="form.requirement" style="width: 555px;" rows="2" type="textarea" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col span="24">
              <el-form-item label="备注:">
                <el-input v-model="form.remark" style="width: 555px;" rows="2" type="textarea" />
              </el-form-item>
            </el-col>
          </el-row>
        </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 v-if="false" prop="repair_item_id" label="设备维修项目标识" />
        <el-table-column prop="repair_item_code" label="维修项目编码" />
        <el-table-column prop="repair_item_name" label="维修项目名称" />
        <el-table-column prop="requirement" label="维修要求" show-overflow-tooltip />
        <el-table-column prop="remark" label="备注" show-overflow-tooltip />
        <el-table-column prop="create_name" label="创建人姓名" />
        <el-table-column prop="create_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 crudDevicerepairitems from '@/api/wms/basedata/em/devicerepairitems'
import CRUD, { presenter, header, form, 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'

const defaultForm = { repair_item_id: null, repair_item_code: null, repair_item_name: null, requirement: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null, is_delete: null, remark: null }
export default {
  name: 'Devicerepairitems',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '设备维修项目维护',
      url: 'api/devicerepairitems',
      idField: 'repair_item_id',
      sort: 'repair_item_id,desc',
      crudMethod: { ...crudDevicerepairitems },
      optShow: {
        add: true,
        edit: false,
        del: false,
        download: false,
        reset: true
      }})
  },
  data() {
    return {
      permission: {
      },
      rules: {
        repair_item_code: [
          { required: true, message: '设备维修项目编码不能为空', trigger: 'blur' }
        ],
        repair_item_name: [
          { required: true, message: '设备维修项目名称不能为空', trigger: 'blur' }
        ],
        requirement: [
          { required: true, message: '维修要求不能为空', trigger: 'blur' }
        ]
      }}
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
