<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="主键id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品编码" prop="sku">
            <el-input v-model="form.sku" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品名称">
            <el-input v-model="form.skuDesc" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否有效" prop="activeFlag">
            <el-input v-model="form.activeFlag" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品大类">
            <el-input v-model="form.skuCategory" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品小类" prop="smallCategory">
            <el-input v-model="form.smallCategory" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="备注1">
            <el-input v-model="form.remark1" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="备注2">
            <el-input v-model="form.remark2" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="辅助条码1">
            <el-input v-model="form.alternateSku1" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="辅助条码2">
            <el-input v-model="form.alternateSku2" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="JDE单位">
            <el-input v-model="form.jdeUom" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="最小包装">
            <el-input v-model="form.mpq" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产线UPH">
            <el-input v-model="form.uph" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="leadTime">
            <el-input v-model="form.leadTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否启用期效">
            <el-input v-model="form.isEffect" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否管控批次">
            <el-input v-model="form.batchControl" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="失效天数">
            <el-input v-model="form.expiredDays" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="扩展字段1">
            <el-input v-model="form.reservedField01" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="扩展字段2">
            <el-input v-model="form.reservedField02" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="扩展字段3">
            <el-input v-model="form.reservedField03" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="扩展字段4">
            <el-input v-model="form.reservedField04" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="扩展字段5">
            <el-input v-model="form.reservedField05" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建人">
            <el-input v-model="form.createdBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建时间">
            <el-input v-model="form.createdTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新人">
            <el-input v-model="form.updatedBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新时间">
            <el-input v-model="form.updatedTime" 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="sku" label="商品编码" />
        <el-table-column prop="skuDesc" label="商品名称" />
        <el-table-column prop="activeFlag" label="是否有效" />
        <el-table-column prop="skuCategory" label="商品大类" />
        <el-table-column prop="smallCategory" label="商品小类" />
        <el-table-column prop="remark1" label="备注1" />
        <el-table-column prop="remark2" label="备注2" />
        <el-table-column prop="alternateSku1" label="辅助条码1" />
        <el-table-column prop="alternateSku2" label="辅助条码2" />
        <el-table-column prop="jdeUom" label="JDE单位" />
        <el-table-column prop="mpq" label="最小包装" />
        <el-table-column prop="uph" label="产线UPH" />
        <el-table-column prop="leadTime" label="leadTime" />
        <el-table-column prop="isEffect" label="是否启用期效" />
        <el-table-column prop="batchControl" label="是否管控批次" />
        <el-table-column prop="expiredDays" label="失效天数" />
        <el-table-column prop="reservedField01" label="扩展字段1" />
        <el-table-column prop="reservedField02" label="扩展字段2" />
        <el-table-column prop="reservedField03" label="扩展字段3" />
        <el-table-column prop="reservedField04" label="扩展字段4" />
        <el-table-column prop="reservedField05" label="扩展字段5" />
        <el-table-column prop="createdBy" label="创建人" />
        <el-table-column prop="createdTime" label="创建时间" />
        <el-table-column prop="updatedBy" label="更新人" />
        <el-table-column prop="updatedTime" label="更新时间" />
        <el-table-column v-if="checkPer(['admin','barcodeSku:edit','barcodeSku: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 crudBarcodeSku from '@/api/barcode/barcodeSku'
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, sku: null, skuDesc: null, activeFlag: null, skuCategory: null, smallCategory: null, remark1: null, remark2: null, alternateSku1: null, alternateSku2: null, jdeUom: null, mpq: null, uph: null, leadTime: null, isEffect: null, batchControl: null, expiredDays: null, reservedField01: null, reservedField02: null, reservedField03: null, reservedField04: null, reservedField05: null, createdBy: null, createdTime: null, updatedBy: null, updatedTime: null }
export default {
  name: 'BarcodeSku',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '条码系统:商品接口', url: 'api/barcodeSku', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBarcodeSku }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'barcodeSku:add'],
        edit: ['admin', 'barcodeSku:edit'],
        del: ['admin', 'barcodeSku:del']
      },
      rules: {
        sku: [
          { required: true, message: '商品编码不能为空', trigger: 'blur' }
        ],
        activeFlag: [
          { required: true, message: '是否有效不能为空', trigger: 'blur' }
        ],
        smallCategory: [
          { required: true, message: '商品小类不能为空', trigger: 'blur' }
        ]
      }    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
