<template>
  <ContainerQuery>
    <div slot="left">
      <el-button size="small" type="primary">打印</el-button>
      <el-button size="small" type="primary">导出</el-button>
    </div>
    <div slot="more">
      <el-tabs
        v-model="top_time"
        style="position: absolute; top: 70px; left: 180px"
        @tab-click="selTopType"
      >
        <el-tab-pane label="昨日" name="1"></el-tab-pane>
        <el-tab-pane label="今日" name="2"></el-tab-pane>
        <el-tab-pane label="本周" name="3"></el-tab-pane>
        <el-tab-pane label="本月" name="4"></el-tab-pane>
        <el-tab-pane label="上月" name="5"></el-tab-pane>
        <el-tab-pane label="近三月" name="6"></el-tab-pane>
        <el-tab-pane label="本年" name="7"></el-tab-pane>
      </el-tabs>
    </div>
    <div slot="more">
      <el-form inline size="small">
        <el-form-item>
          <el-date-picker
            v-model="time"
            clearable
            type="daterange"
            value-format="timestamp"
            range-separator="-"
            start-placeholder="下单开始日期"
            end-placeholder="下单结束日期"
            @change="orderDate"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="Return"
            style="width: 220px"
            multiple
            placeholder="配送状态"
            @change="pageChange(1)"
          >
            <el-option
              v-for="item in Return_status"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <SelectCustomer
            v-model="customer_name"
            placeholder="配送司机"
            @clear="customerClear"
            @change="customerSel"
          />
        </el-form-item>
        <el-form-item>
          <SelectCustomer
            v-model="customer_name"
            placeholder="送货员"
            @clear="customerClear"
            @change="customerSel"
          />
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="keyword"
            style="width: 220px"
            placeholder="任务编号"
            clearable
            @keyup.enter.native="pageChange(1)"
            @clear="pageChange(1)"
          >
            <el-button slot="append" @click="pageChange(1)">
              <i class="el-icon-search"></i>
            </el-button>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="keyword"
            style="width: 220px"
            placeholder="备注"
            clearable
            @keyup.enter.native="pageChange(1)"
            @clear="pageChange(1)"
          >
            <el-button slot="append" @click="pageChange(1)">
              <i class="el-icon-search"></i>
            </el-button>
          </el-input>
        </el-form-item>
      </el-form>
      <!--    选择仓库-->
      <WarehouseModel
        v-if="warehouse_show"
        :is-check="false"
        :is-show="warehouse_show"
        @confirm="selWarehouse"
        @cancel="warehouse_show = false"
      />
    </div>
    <vxe-table
      ref="xTable"
      :data="tableData"
      @checkbox-all="checkboxChangeEvent"
      @checkbox-change="checkboxChangeEvent"
    >
      <vxe-table-column type="checkbox" width="60"></vxe-table-column>
      <vxe-table-column
        field="sex"
        title="指定配送日期"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="任务编号"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="配送状态"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="配送开始时间"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="配送结束时间"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="司机名称"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="配送车辆"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="送货员"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="配送单量"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="退货单量"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="发货数量"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="发货金额"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="签收数量"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="签收金额"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="拒收数量"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="拒收金额"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="退货数量"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="退货金额"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="装箱数量"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="age"
        title="配送里程"
        width="150"
      ></vxe-table-column>
      <vxe-table-column field="age" title="备注" width="150"></vxe-table-column>
      <vxe-table-column fixed="right" field="name" title="操作" width="400">
        <template #default>
          <el-button type="text" size="mini">商品汇总</el-button>
          <el-button type="text" size="mini">修改司机</el-button>
          <el-button type="text" size="mini">开始配送</el-button>
          <el-button type="text" size="mini">完成配送</el-button>
          <el-button type="text" size="mini">打印</el-button>
          <el-button type="text" size="mini">取消</el-button>
        </template>
      </vxe-table-column>
    </vxe-table>
    <FooterPage
      :page-size="pageSize"
      :total-page.sync="total"
      :current-page.sync="page"
      @pageChange="pageChange"
      @sizeChange="sizeChange"
    >
      <div slot="btn-div" class="foot-btn-div">
        <span class="batch-checkbox">
          <vxe-checkbox
            v-model="checkedAll"
            :indeterminate="isIndeterminate"
            @change="checkAllChange"
          ></vxe-checkbox>
        </span>
        <el-button size="mini">批量完成配送</el-button>
        <el-button size="mini">修改司机</el-button>
      </div>
    </FooterPage>
  </ContainerQuery>
</template>
<script>
  import SelectCustomer from "@/component/common/SelectCustomer.vue";
  import WarehouseModel from "@/component/common/WarehouseModel.vue";

  export default {
    components: {
      // SelectCustomer,
      WarehouseModel,
    },
    data() {
      return {
        keyword: "",
        top_time: "1",
        customer_name: "",
        customerId: "",
        time: "",
        start: "",
        end: "",
        Return: "",
        Return_status: [],
        warehouseName: "",
        warehouse_show: false,
        warehouseId: "",
        tableData: [
          {
            id: 10001,
            name: "Test1",
            role: "Develop",
            sex: "Man",
            age: 28,
            address: "vxe-table 从入门到放弃",
          },
          {
            id: 10002,
            name: "Test2",
            role: "Test",
            sex: "Women",
            age: 22,
            address: "Guangzhou",
          },
          {
            id: 10003,
            name: "Test3",
            role: "PM",
            sex: "Man",
            age: 32,
            address: "Shanghai",
          },
          {
            id: 10004,
            name: "Test4",
            role: "Designer",
            sex: "Women",
            age: 23,
            address: "vxe-table 从入门到放弃",
          },
          {
            id: 10005,
            name: "Test5",
            role: "Develop",
            sex: "Women",
            age: 30,
            address: "Shanghai",
          },
        ],
        page: 1,
        pageSize: 10,
        total: 0,
        checkedAll: false,
        records: [],
        time1: "",
        isIndeterminate: false,
      };
    },
    methods: {
      pageChange() {},
      sizeChange() {},
      selTopType() {},
      customerClear() {
        this.customerId = "";
        this.customer_name = "";
        this.pageChange(1);
      },
      // 选择客户
      customerSel(val, list) {
        this.customerId = list[0].id;
        this.pageChange(1);
      },
      //  时间
      orderDate(val) {
        if (val && val.length) {
          this.start = val[0] / 1000;
          this.end = val[1] / 1000 + 86399;
        } else {
          this.start = "";
          this.end = "";
        }
        this.pageChange(1);
      },
      selWarehouse(row) {
        this.warehouseName = row[0].warehouseName;
        this.warehouseId = row[0].id;
        this.pageChange(1);
      },
      checkboxChangeEvent({ records }) {
        this.checkedAll = this.$refs.xTable.isAllCheckboxChecked();
        this.isIndeterminate = this.$refs.xTable.isAllCheckboxChecked();
        this.records = records;
      },
      checkAllChange() {
        this.$refs.xTable.setAllCheckboxRow(this.checkedAll);
        this.records = this.$refs.xTable.getCheckboxRecords();
      },
    },
  };
</script>
<style></style>
