<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.task_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="任务分类">
            <el-input v-model="form.task_class_id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="任务状态">
            <el-input v-model="form.task_status" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="配置编码">
            <el-input v-model="form.config_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="点位1">
            <el-input v-model="form.point_code1" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="点位2">
            <el-input v-model="form.point_code2" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="点位3">
            <el-input v-model="form.point_code3" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="点位4">
            <el-input v-model="form.point_code4" 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.vehicle_qty" style="width: 370px;" />
          </el-form-item>
          <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.priority" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="处理类">
            <el-input v-model="form.handle_class" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="处理状态">
            <el-input v-model="form.handle_status" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="车号">
            <el-input v-model="form.car_no" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否自动下发">
            <el-input v-model="form.is_auto_issue" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="任务组标识">
            <el-input v-model="form.task_group_id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="任务组顺序号">
            <el-input v-model="form.task_group_seq" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="任务完成类型">
            <el-input v-model="form.finished_type" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="生成方式">
            <el-input v-model="form.create_mode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="链路标识">
            <el-input v-model="form.acs_trace_id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="生成任务的请求参数">
            <el-input v-model="form.request_param" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="下发任务的请求参数">
            <el-input v-model="form.response_param" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="车间编码">
            <el-input v-model="form.workshop_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="额外组盘信息">
            <el-input v-model="form.ext_group_data" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remark" 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="task_code" label="任务编码" :min-width="flexWidth('task_code',crud.data,'任务编码')"/>
        <el-table-column prop="task_class_id" label="任务分类" :min-width="flexWidth('task_class_id',crud.data,'任务分类')"/>
        <el-table-column prop="task_status" label="任务状态" :min-width="flexWidth('task_status',crud.data,'任务状态')"/>
        <el-table-column prop="config_code" label="配置编码" :min-width="flexWidth('config_code',crud.data,'配置编码')"/>
        <el-table-column prop="point_code1" label="点位1" :min-width="flexWidth('point_code1',crud.data,'点位1')"/>
        <el-table-column prop="point_code2" label="点位2" :min-width="flexWidth('point_code2',crud.data,'点位2')"/>
        <el-table-column prop="point_code3" label="点位3" :min-width="flexWidth('point_code3',crud.data,'点位3')"/>
        <el-table-column prop="point_code4" label="点位4" :min-width="flexWidth('point_code4',crud.data,'点位4')"/>
        <el-table-column prop="vehicle_type" label="载具类型" :min-width="flexWidth('vehicle_type',crud.data,'载具类型')"/>
        <el-table-column prop="vehicle_qty" label="载具数量" :min-width="flexWidth('vehicle_qty',crud.data,'载具数量')"/>
        <el-table-column prop="vehicle_code" label="载具编码" :min-width="flexWidth('vehicle_code',crud.data,'载具编码')"/>
        <el-table-column prop="priority" label="优先级" :min-width="flexWidth('priority',crud.data,'优先级')"/>
        <el-table-column prop="handle_class" label="处理类" :min-width="flexWidth('handle_class',crud.data,'处理类')"/>
        <el-table-column prop="handle_status" label="处理状态" :min-width="flexWidth('handle_status',crud.data,'处理状态')"/>
        <el-table-column prop="car_no" label="车号" :min-width="flexWidth('car_no',crud.data,'车号')"/>
        <el-table-column prop="is_auto_issue" label="是否自动下发" :min-width="flexWidth('is_auto_issue',crud.data,'是否自动下发')"/>
        <el-table-column prop="task_group_id" label="任务组标识" :min-width="flexWidth('task_group_id',crud.data,'任务组标识')"/>
        <el-table-column prop="task_group_seq" label="任务组顺序号" :min-width="flexWidth('task_group_seq',crud.data,'任务组顺序号')"/>
        <el-table-column prop="finished_type" label="任务完成类型" :min-width="flexWidth('finished_type',crud.data,'任务完成类型')"/>
        <el-table-column prop="create_mode" label="生成方式" :min-width="flexWidth('create_mode',crud.data,'生成方式')"/>
        <el-table-column prop="acs_trace_id" label="链路标识" :min-width="flexWidth('acs_trace_id',crud.data,'链路标识')"/>
        <el-table-column prop="request_param" label="生成任务的请求参数" :min-width="flexWidth('request_param',crud.data,'生成任务的请求参数')"/>
        <el-table-column prop="response_param" label="下发任务的请求参数" :min-width="flexWidth('response_param',crud.data,'下发任务的请求参数')"/>
        <el-table-column prop="workshop_code" label="车间编码" :min-width="flexWidth('workshop_code',crud.data,'车间编码')"/>
        <el-table-column prop="ext_group_data" label="额外组盘信息" :min-width="flexWidth('ext_group_data',crud.data,'额外组盘信息')"/>
        <el-table-column prop="remark" label="备注" :min-width="flexWidth('remark',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 crudSchBaseTask from './schBaseTask'
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 = {
  task_code: null,
  task_class_id: null,
  task_status: null,
  config_code: null,
  point_code1: null,
  point_code2: null,
  point_code3: null,
  point_code4: null,
  vehicle_type: null,
  vehicle_qty: null,
  vehicle_code: null,
  priority: null,
  handle_class: null,
  handle_status: null,
  car_no: null,
  is_auto_issue: null,
  task_group_id: null,
  task_group_seq: null,
  finished_type: null,
  create_mode: null,
  acs_trace_id: null,
  request_param: null,
  response_param: null,
  workshop_code: null,
  ext_group_data: null,
  remark: 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: 'Task',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '任务管理',
      url: 'api/schBaseTask',
      idField: 'task_code',
      sort: 'task_code,desc',
      crudMethod: { ...crudSchBaseTask }
    })
  },
  data() {
    return {
      permission: {
      },
      rules: {
      }    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
