<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="small" label-width="80px">
          <el-form-item label="工单标识" prop="order_id">
            <el-input v-model="form.order_id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工单编码" prop="order_code">
            <el-input v-model="form.order_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否已拆分">
            <el-input v-model="form.is_unbundling" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工单状态">
            <el-input v-model="form.order_status" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="下料数量">
            <el-input v-model="form.qty" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品编码">
            <el-input v-model="form.product_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料编码">
            <el-input v-model="form.material_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料名称">
            <el-input v-model="form.material_name" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料标识">
            <el-input v-model="form.material_uuid" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="客户编码">
            <el-input v-model="form.cust_code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="客户名称">
            <el-input v-model="form.cust_name" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="型号">
            <el-input v-model="form.model" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="熔池">
            <el-input v-model="form.molten_pool" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="重量">
            <el-input v-model="form.weight" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建者">
            <el-input v-model="form.create_by" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建时间" prop="create_time">
            <el-input v-model="form.create_time" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="修改者">
            <el-input v-model="form.update_by" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="修改时间">
            <el-input v-model="form.update_time" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否删除" prop="is_deleted">
            <el-input v-model="form.is_deleted" 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="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="order_id" label="工单标识" />
        <el-table-column prop="order_code" label="工单编码" />
        <el-table-column prop="is_unbundling" label="是否已拆分" />
        <el-table-column prop="order_status" label="工单状态" />
        <el-table-column prop="qty" label="下料数量" />
        <el-table-column prop="product_code" label="产品编码" />
        <el-table-column prop="material_code" label="物料编码" />
        <el-table-column prop="material_name" label="物料名称" />
        <el-table-column prop="material_uuid" label="物料标识" />
        <el-table-column prop="cust_code" label="客户编码" />
        <el-table-column prop="cust_name" label="客户名称" />
        <el-table-column prop="model" label="型号" />
        <el-table-column prop="molten_pool" label="熔池" />
        <el-table-column prop="weight" label="重量" />
        <el-table-column prop="create_by" label="创建者" />
        <el-table-column prop="create_time" label="创建时间" />
        <el-table-column prop="update_by" label="修改者" />
        <el-table-column prop="update_time" label="修改时间" />
        <el-table-column prop="is_deleted" label="是否删除" />
        <el-table-column v-permission="['admin','produceshiftorder:edit','produceshiftorder:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
    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 = { order_id: null, order_code: null, is_unbundling: null, order_status: null, qty: null, product_code: null, material_code: null, material_name: null, material_uuid: null, cust_code: null, cust_name: null, model: null, molten_pool: null, weight: null, create_by: null, create_time: null, update_by: null, update_time: null, is_deleted: null }
export default {
  name: 'Produceshiftorder',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '工单信息', url: 'api/produceshiftorder', idField: 'create_time', sort: 'create_time,desc', crudMethod: { ...crudProduceshiftorder }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'produceshiftorder:add'],
        edit: ['admin', 'produceshiftorder:edit'],
        del: ['admin', 'produceshiftorder:del']
      },
      rules: {
        order_id: [
          { required: true, message: '工单标识不能为空', trigger: 'blur' }
        ],
        order_code: [
          { required: true, message: '工单编码不能为空', trigger: 'blur' }
        ],
        create_time: [
          { required: true, message: '创建时间不能为空', trigger: 'blur' }
        ],
        is_deleted: [
          { required: true, message: '是否删除不能为空', trigger: 'blur' }
        ]
      }    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
