<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" :tableKey="this.$options.name"/>
      <!--表单组件-->
      <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="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="自制件工单id">
            <el-input v-model="form.selfWorkOrderId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="来源系统">
            <el-input v-model="form.sourceSystem" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="自制件工单编号">
            <el-input v-model="form.selfWorkOrderName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料编码">
            <el-input v-model="form.itemCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="标签类型">
            <el-input v-model="form.labelType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MLS货区">
            <el-input v-model="form.goodsAreaCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="检验状态">
            <el-input v-model="form.checkResult" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MLS入库时间">
            <el-input v-model="form.datetimeStockin" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MLS创建人">
            <el-input v-model="form.createUserCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MLS修改时间">
            <el-input v-model="form.mlsUpdatetime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MO票">
            <el-input v-model="form.labelno" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料">
            <el-input v-model="form.itemId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MLS修改人">
            <el-input v-model="form.updateusercode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MLS创建时间">
            <el-input v-model="form.mlsCreatetime" 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.labelState" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="送货单头ID；通过该字段能找到002接口送货单">
            <el-input v-model="form.deliveryHeaderId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工单编号">
            <el-input v-model="form.workOrderName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工单Id">
            <el-input v-model="form.workOrderId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MLS货位">
            <el-input v-model="form.goodsLocationCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MLS子库">
            <el-input v-model="form.invCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建人">
            <el-input v-model="form.createBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="修改人">
            <el-input v-model="form.updateBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建时间">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="修改时间">
            <el-input v-model="form.updateTime" 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.status.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="id" label="id" />
        <el-table-column prop="selfWorkOrderId" label="自制件工单id" />
        <el-table-column prop="sourceSystem" label="来源系统" />
        <el-table-column prop="selfWorkOrderName" label="自制件工单编号" />
        <el-table-column prop="itemCode" label="物料编码" />
        <el-table-column prop="labelType" label="标签类型" />
        <el-table-column prop="goodsAreaCode" label="MLS货区" />
        <el-table-column prop="checkResult" label="检验状态" />
        <el-table-column prop="datetimeStockin" label="MLS入库时间" />
        <el-table-column prop="createUserCode" label="MLS创建人" />
        <el-table-column prop="mlsUpdatetime" label="MLS修改时间" />
        <el-table-column prop="labelno" label="MO票" />
        <el-table-column prop="itemId" label="物料" />
        <el-table-column prop="updateusercode" label="MLS修改人" />
        <el-table-column prop="mlsCreatetime" label="MLS创建时间" />
        <el-table-column prop="qty" label="可用数量" />
        <el-table-column prop="labelState" label="标签状态" />
        <el-table-column prop="deliveryHeaderId" label="送货单头ID；通过该字段能找到002接口送货单" />
        <el-table-column prop="workOrderName" label="工单编号" />
        <el-table-column prop="workOrderId" label="工单Id" />
        <el-table-column prop="goodsLocationCode" label="MLS货位" />
        <el-table-column prop="invCode" label="MLS子库" />
        <el-table-column prop="createBy" label="创建人" />
        <el-table-column prop="updateBy" label="修改人" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column prop="updateTime" label="修改时间" />
        <el-table-column v-if="checkPer(['admin','mo:edit','mo: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 crudMo from '@/api/mo'
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 = { id: null, selfWorkOrderId: null, sourceSystem: null, selfWorkOrderName: null, itemCode: null, labelType: null, goodsAreaCode: null, checkResult: null, datetimeStockin: null, createUserCode: null, mlsUpdatetime: null, labelno: null, itemId: null, updateusercode: null, mlsCreatetime: null, qty: null, labelState: null, deliveryHeaderId: null, workOrderName: null, workOrderId: null, goodsLocationCode: null, invCode: null, createBy: null, updateBy: null, createTime: null, updateTime: null }
export default {
  name: 'Mo',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: 'mo', url: 'api/mo', idField: 'id', sort: 'id,desc', crudMethod: { ...crudMo }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'mo:add'],
        edit: ['admin', 'mo:edit'],
        del: ['admin', 'mo:del']
      },
      rules: {
      }    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
