<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <el-form ref="form4" :inline="true" :model="form4" >

        <el-form-item label="送货单ID">
          <el-input v-model="query.deliveryHeaderId" clearable placeholder="请输入送货单ID" style="width: 170px;"
                    class="filter-item"
                    @keyup.enter.native="crud.toQuery"/>
        </el-form-item>

        <el-form-item label="送货单条码">
          <el-input v-model="query.barcodeNumber" clearable placeholder="请输入送货单条码号" style="width: 170px;"
                    class="filter-item"
                    @keyup.enter.native="crud.toQuery"/>
        </el-form-item>

        <el-form-item label="物料编号">
          <el-input v-model="query.itemCode" clearable placeholder="请输入物料编号" style="width: 170px;" class="filter-item"
                    @keyup.enter.native="crud.toQuery"/>
        </el-form-item>

        <label class="el-form-item-label">接收日期</label>
        <date-range-picker v-model="query.createTime" class="date-item" style="width: 100px"/>

        <rrOperation :crud="crud"/>
        <el-button class="filter-item" size="mini" type="warning" icon="el-icon-refresh-left" @click="resetQuery">重置
        </el-button>
      </el-form>

      <div class="statusButton" style="border-bottom: solid lightgray 1px;">
        <el-radio-group v-model="radio3" @change="clickChange" size="small">
          <el-radio-button label="全部"> 全部</el-radio-button>
          <el-radio-button label="lm_initial"> lm_initial</el-radio-button>
          <el-radio-button label="lm_closed"> lm_closed</el-radio-button>
          <el-radio-button label="其他"> 其他状态</el-radio-button>
        </el-radio-group>
      </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>
        <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"  height="400"  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="index" align="center" label="序号" :resizable="false" type="index" width="50" />
        <el-table-column prop="deliveryHeaderId" align="center" label="送货单ID" width="100"  />
        <el-table-column prop="barcodeNumber" align="center" label="送货单条码" width="100" />
        <el-table-column prop="itemCode" align="center" label="物料编码" width="120" />
        <el-table-column prop="iqcResult" align="center" label="检验结果" width="100" />
        <el-table-column prop="deliveryStatus" align="center" label="送货单状态" width="100" />
        <el-table-column prop="deliveryQty" align="center" label="计划数量" width="100"/>
        <el-table-column prop="receivedQty" align="center" label="接收数量" width="100" />
        <el-table-column prop="supplierCode" align="center" label="供应商编码" width="100" />
        <el-table-column prop="supplierName" align="center" label="供应商名称" :show-overflow-tooltip="true" width="100" />
        <el-table-column prop="deliveryNumber" align="center" label="送货单号" width="100" />
        <el-table-column prop="isIqcInspected" align="center" label="是否检验" width="100" />
<!--
        <el-table-column prop="receivedLocationName" align="center" label="mls货位名称"  :show-overflow-tooltip="true" width="100"  />
        <el-table-column prop="receivedLocationCode" align="center" label="mls货位编码" width="100" />
        <el-table-column prop="receivedInvCode" align="center" label="mls子库编码" width="100" />
        <el-table-column prop="receivedInvName" align="center" label="mls子库名称" :show-overflow-tooltip="true" width="100" />
        <el-table-column prop="receivedAreaCode" label="mls货区编码" width="100" />
        <el-table-column prop="receivedAreaName" label="mls货区名称" :show-overflow-tooltip="true" width="100" />
-->
        <el-table-column prop="inInspector" label="检验员" width="100" />
        <el-table-column prop="mlsUpdateTime" label="mls修改时间" width="140" />
        <el-table-column prop="createTime" label="wms接收时间" width="140" />
        <el-table-column prop="updateTime" label="wms修改时间" width="140" />
<!--        <el-table-column fixed="right" v-if="checkPer(['admin','order:edit','order:del'])" label="操作" width="150px"
                         align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>-->
      </el-table>
      <!--分页组件-->
      <div style="float: right">
        <pagination/>
      </div>

    </div>
  </div>
</template>

<script>
import crudOrder from '@/api/order'
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'
import DateRangePicker from "@/components/DateRangePicker/index.vue";

const defaultForm = {
  id: null
}
export default {
  name: 'Order',
  components: {DateRangePicker, pagination, crudOperation, rrOperation, udOperation},
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '送货单管理',
      url: 'api/order',
      idField: 'id',
      sort: 'id,desc',
      crudMethod: {...crudOrder},
      optShow: {
        add: false,
        edit: false,
        del: false,
        reset: false,
        download: true
      }
    })
  },
  data() {
    return {
      form4: {},
      radio3: '全部',
      permission: {
        add: ['admin', 'order:add'],
        edit: ['admin', 'order:edit'],
        del: ['admin', 'order:del']
      },
      rules: {}
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    clickChange(lab) {
      if (lab === "全部") {
        this.crud.resetQuery();
        this.crud.toQuery();
      } else if (lab === "lm_initial") {
        this.query.deliveryStatus = 'lm_initial'
        this.crud.toQuery();
      } else if (lab === "lm_closed") {
        this.query.deliveryStatus = 'lm_closed'
        this.crud.toQuery();
      } else if (lab === "其他") {
        this.query.deliveryStatus = '-'
        this.crud.toQuery();
      }
    },
    resetQuery() {
      this.radio3 = '全部';
      this.crud.resetQuery()
    },
  }
}
</script>

<style scoped>

</style>
