<template>
  <!-- 订单管理 -->
  <div>
    <div ref="grabble">
      <actionBar :operateList="operateList" :formList="formList" :ruleForm="searchRuleForm" @openModel="openModel"
        @searchProtocol="searchProtocol"></actionBar>
    </div>
    <div class="card_content">
      <!-- 表单 -->
      <tables ref="refWaybill" tableHeight="68vh" :suspension="true" :tableList="tableList" :tableData="tableData"
        @buttonData="buttonData">
      </tables>
      <!-- 分页 -->
      <div v-if="Total">
        <pagination :total="Total" :currentPage="Pagination.PageIndex" @changeSize="changeSize"
          @changeCurrent="changeCurrent">
        </pagination>
      </div>
    </div>
  </div>
</template>

<script>
  import actionBar from '@/components/actionBar'
  import tables from '@/components/tables'
  import pagination from '@/components/pagination'
  import {
    employee,
  } from "./waybill.js";
  import {
    WaybillStatus
  } from '@/assets/js/blockSort'
  export default {
    name: 'OrderManagement',
    components: {
      actionBar,
      tables,
      pagination,
    },
    data() {
      return {
        operateList: [{
          type: 'sends',
          title: '批量派单',
          colour: 'success'
        }, {
          type: 'import',
          title: '批量导入',
          colour: 'warning'
        }, {
          type: 'add',
          title: '添加订单',
          icon: 'el-icon-plus',
        }],
        formList: [{
          type: 'input',
          label: '订单号',
          field: 'orderNo',
          placeholder: '请输入订单号',
        }, {
          type: 'select',
          label: '状态',
          field: 'status',
          placeholder: '请选择状态',
          options: WaybillStatus(),
        }, {
          type: 'picker',
          label: '下单时间',
          field: 'time',
          placeholder: '下单时间',
        }],
        searchRuleForm: {
          orderNo: '',
          status: null,
          time: [],
        },
        searchValue: {},
        Pagination: {
          PageIndex: 1,
          PageSize: 10,
        },
        Total: 0,
        operationType: '',
        tableData: [],
        tableList: employee(),
      }
    },
    methods: {
      // 搜索
      searchProtocol(value) {
        this.Pagination.PageIndex = 1
        this.searchValue = value
        if (value.time) {
          this.searchValue.orderStartTime = value.time[0]
          this.searchValue.orderEndTime = value.time[1]
        }
        this.getList()
      },
      openModel(type) {
        this.operationType = type
      },
      buttonData(row, type) {
        this.operationType = type
      },
      changeSize(val) {
        this.Pagination.PageSize = val
        this.getList()
      },
      changeCurrent(val) {
        this.Pagination.PageIndex = val
        this.getList()
      },
    },
  }
</script>

<style lang="scss">
</style>
