<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.receiveOrderNo" 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.purchaseOrderNo" clearable placeholder="采购订单号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">采购订单日期</label>
        <el-input v-model="query.purchaseOrderDate" clearable placeholder="采购订单日期" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">收货日期</label>
        <el-input v-model="query.receiveDate" 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="receiveOrderNo">
            <el-input v-model="form.receiveOrderNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收货单行号 Y">
            <el-input v-model="form.receiveOrderLine" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购订单号">
            <el-input v-model="form.purchaseOrderNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购订单行号">
            <el-input v-model="form.purchaseOrderLine" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="订单公司">
            <el-input v-model="form.purchaseOrderCo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="订单类型">
            <el-input v-model="form.purchaseOrderType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="配送任务号">
            <el-input v-model="form.deliveryNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购订单日期">
            <el-date-picker v-model="form.purchaseOrderDate" type="datetime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收货日期">
            <el-date-picker v-model="form.receiveDate" type="datetime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="供应商编号">
            <el-input v-model="form.supplier" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="供应商名称">
            <el-input v-model="form.supplierName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收货库区">
            <el-input v-model="form.zone" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品编码">
            <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="商品单位">
            <el-input v-model="form.jdeUom" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收货库位">
            <el-input v-model="form.location" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="批次">
            <el-input v-model="form.lot" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="订单数量">
            <el-input v-model="form.quantity" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="未收数量">
            <el-input v-model="form.qtyUn" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="状态">
            <el-input v-model="form.status" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收货员">
            <el-input v-model="form.staffReceive" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收货员名称">
            <el-input v-model="form.staffReceiveName" 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="receiveOrderNo" label="收货单号 Y" />
        <el-table-column prop="receiveOrderLine" label="收货单行号 Y" />
        <el-table-column prop="purchaseOrderNo" label="采购订单号" />
        <el-table-column prop="purchaseOrderLine" label="采购订单行号" />
        <el-table-column prop="purchaseOrderCo" label="订单公司" />
        <el-table-column prop="purchaseOrderType" label="订单类型" />
        <el-table-column prop="deliveryNo" label="配送任务号" />
        <el-table-column prop="purchaseOrderDate" label="采购订单日期" />
        <el-table-column prop="receiveDate" label="收货日期" />
        <el-table-column prop="supplier" label="供应商编号" />
        <el-table-column prop="supplierName" label="供应商名称" />
        <el-table-column prop="zone" label="收货库区" />
        <el-table-column prop="sku" label="商品编码" />
        <el-table-column prop="skuDesc" label="商品名称" />
        <el-table-column prop="jdeUom" label="商品单位" />
        <el-table-column prop="location" label="收货库位" />
        <el-table-column prop="lot" label="批次" />
        <el-table-column prop="quantity" label="订单数量" />
        <el-table-column prop="qtyUn" label="未收数量" />
        <el-table-column prop="status" label="状态" />
        <el-table-column prop="staffReceive" label="收货员" />
        <el-table-column prop="staffReceiveName" 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','receiveOrders:edit','receiveOrders: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 crudReceiveOrders from '@/api/wms/receive/receiveOrders'
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, receiveOrderNo: null, receiveOrderLine: null, purchaseOrderNo: null, purchaseOrderLine: null, purchaseOrderCo: null, purchaseOrderType: null, deliveryNo: null, purchaseOrderDate: null, receiveDate: null, supplier: null, supplierName: null, zone: null, sku: null, skuDesc: null, jdeUom: null, location: null, lot: null, quantity: null, qtyUn: null, status: null, staffReceive: null, staffReceiveName: null, reservedField01: null, reservedField02: null, reservedField03: null, reservedField04: null, reservedField05: null, createdBy: null, createdTime: null, updatedBy: null, updatedTime: null }
export default {
  name: 'ReceiveOrders',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '条码系统:收货信息接口', url: 'api/receiveOrders', idField: 'id', sort: 'id,desc', crudMethod: { ...crudReceiveOrders }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'receiveOrders:add'],
        edit: ['admin', 'receiveOrders:edit'],
        del: ['admin', 'receiveOrders:del']
      },
      rules: {
        receiveOrderNo: [
          { required: true, message: '收货单号 Y不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'receiveOrderNo', display_name: '收货单号 Y' },
        { key: 'purchaseOrderNo', display_name: '采购订单号' },
        { key: 'purchaseOrderDate', display_name: '采购订单日期' },
        { key: 'receiveDate', display_name: '收货日期' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
