<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">物料凭证头文本 Y</label>
        <el-input v-model="query.materialDocHeader" clearable placeholder="物料凭证头文本 Y" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">物料凭证编号</label>
        <el-input v-model="query.materialDocNo" clearable placeholder="物料凭证编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </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="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="物料凭证头文本 Y" prop="materialDocHeader">
            <el-input v-model="form.materialDocHeader" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料凭证编号">
            <el-input v-model="form.materialDocNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料移动编码">
            <el-input v-model="form.goodsMoveCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="打印标识">
            <el-input v-model="form.printTrigger" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="汇总打印">
            <el-input v-model="form.versionPrint" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="回传日期">
            <el-input v-model="form.postingDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料凭证年">
            <el-input v-model="form.materialDocYear" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料凭证行项目">
            <el-input v-model="form.materialDocItem" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="单位">
            <el-input v-model="form.entryUnit" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料编码">
            <el-input v-model="form.material" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料名称">
            <el-input v-model="form.materialDesc" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工厂">
            <el-input v-model="form.plant" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="预留">
            <el-input v-model="form.reservation" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="预留项目">
            <el-input v-model="form.reservationItem" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="批次">
            <el-input v-model="form.batch" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="数量">
            <el-input v-model="form.entryQty" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="移动类型">
            <el-input v-model="form.goodsMoveType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售单行项目">
            <el-input v-model="form.salesOrderItem" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="库位">
            <el-input v-model="form.storageLocation" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售单号">
            <el-input v-model="form.salesOrderNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="生产单号">
            <el-input v-model="form.manufactOrder" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="状态">
            <el-input v-model="form.state" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="source_sys">
            <el-input v-model="form.sourceSys" 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="materialDocHeader" label="物料凭证头文本 Y" />
        <el-table-column prop="materialDocNo" label="物料凭证编号" />
        <el-table-column prop="goodsMoveCode" label="物料移动编码" />
        <el-table-column prop="printTrigger" label="打印标识" />
        <el-table-column prop="versionPrint" label="汇总打印" />
        <el-table-column prop="postingDate" label="回传日期" />
        <el-table-column prop="materialDocYear" label="物料凭证年" />
        <el-table-column prop="materialDocItem" label="物料凭证行项目" />
        <el-table-column prop="entryUnit" label="单位" />
        <el-table-column prop="material" label="物料编码" />
        <el-table-column prop="materialDesc" label="物料名称" />
        <el-table-column prop="plant" label="工厂" />
        <el-table-column prop="reservation" label="预留" />
        <el-table-column prop="reservationItem" label="预留项目" />
        <el-table-column prop="batch" label="批次" />
        <el-table-column prop="entryQty" label="数量" />
        <el-table-column prop="goodsMoveType" label="移动类型" />
        <el-table-column prop="salesOrderItem" label="销售单行项目" />
        <el-table-column prop="storageLocation" label="库位" />
        <el-table-column prop="salesOrderNo" label="销售单号" />
        <el-table-column prop="manufactOrder" label="生产单号" />
        <el-table-column prop="state" label="状态" />
        <el-table-column prop="sourceSys" label="source_sys" />
        <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','materialIssuing:edit','materialIssuing: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 crudMaterialIssuing from '@/api/mes/materialIssuing/materialIssuing'
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, materialDocHeader: null, materialDocNo: null, goodsMoveCode: null, printTrigger: null, versionPrint: null, postingDate: null, materialDocYear: null, materialDocItem: null, entryUnit: null, material: null, materialDesc: null, plant: null, reservation: null, reservationItem: null, batch: null, entryQty: null, goodsMoveType: null, salesOrderItem: null, storageLocation: null, salesOrderNo: null, manufactOrder: null, state: null, sourceSys: null, reservedField01: null, reservedField02: null, reservedField03: null, reservedField04: null, reservedField05: null, createdBy: null, createdTime: null, updatedBy: null, updatedTime: null }
export default {
  name: 'MaterialIssuing',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '条码系统：生产领料接口', url: 'api/materialIssuing', idField: 'id', sort: 'id,desc', crudMethod: { ...crudMaterialIssuing }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'materialIssuing:add'],
        edit: ['admin', 'materialIssuing:edit'],
        del: ['admin', 'materialIssuing:del']
      },
      rules: {
        materialDocHeader: [
          { required: true, message: '物料凭证头文本 Y不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'materialDocHeader', display_name: '物料凭证头文本 Y' },
        { key: 'materialDocNo', display_name: '物料凭证编号' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
