<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="yesterday"></el-tab-pane>
        <el-tab-pane label="今日" name="today"></el-tab-pane>
        <el-tab-pane label="本周" name="beforweek"></el-tab-pane>
        <el-tab-pane label="本月" name="nowmonth"></el-tab-pane>
        <el-tab-pane label="上月" name="permonth"></el-tab-pane>
        <el-tab-pane label="近三月" name="preday"></el-tab-pane>
        <el-tab-pane label="本年" name="nowyear"></el-tab-pane>
      </el-tabs>
    </div>
    <div slot="more">
      <el-form inline size="small">
        <!--        <el-form-item>-->
        <!--          <el-select-->
        <!--            v-model="Return"-->
        <!--            style="width: 150px"-->
        <!--            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>
          <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-item>
          <el-input
            v-model="goodsName"
            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-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-input
            v-model="warehouseName"
            placeholder="仓库"
            style="width: 150px"
          >
            <i
              slot="suffix"
              class="el-input__icon el-icon-search"
              @click="warehouse_show = true"
            ></i>
          </el-input>
        </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_name2"
            placeholder="往来单位"
            @clear="customerClear2"
            @change="customerSel2"
          />
        </el-form-item>
        <!--        <el-form-item>-->
        <!--          <el-select-->
        <!--            v-model="Return"-->
        <!--            style="width: 150px"-->
        <!--            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>-->
        <!--          <el-select-->
        <!--            v-model="Return"-->
        <!--            style="width: 150px"-->
        <!--            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>
      <!--    选择仓库-->
      <WarehouseModel
        v-if="warehouse_show"
        :is-check="false"
        :is-show="warehouse_show"
        @confirm="selWarehouse"
        @cancel="warehouse_show = false"
      />
    </div>
    <vxe-table ref="xTable1" :data="tableData">
      <vxe-table-column field="name" title="单据日期" width="150">
        <template #default="{ row }">
          {{ $_common.formatDate(row.createTime) }}
        </template>
      </vxe-table-column>
      <vxe-table-column field="pickingStatus" title="单据状态" width="150">
        <template #default="{ row }">
          <span v-if="row.pickingStatus === 1">未拣货</span>
          <span v-if="row.pickingStatus === 2">待拣货</span>
          <span v-if="row.pickingStatus === 3">拣货完成</span>
        </template>
      </vxe-table-column>
      <vxe-table-column
        field="no"
        title="单据编号"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="currentUnit"
        title="往来单位"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="goodsName"
        title="商品名称"
        width="160"
      ></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="unitName"
        title="单位"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="pickingNum"
        title="拣货数量"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="totalMoney"
        title="拣货金额"
        width="150"
      ></vxe-table-column>
      <vxe-table-column
        field="remark"
        title="备注"
        width="150"
      ></vxe-table-column>
    </vxe-table>
    <FooterPage
      :page-size="pageSize"
      :total-page.sync="total"
      :current-page.sync="page"
      @pageChange="pageChange"
      @sizeChange="sizeChange"
    ></FooterPage>
  </ContainerQuery>
</template>
<script>
  import SelectCustomer from "@/component/common/SelectCustomer.vue";
  import WarehouseModel from "@/component/common/WarehouseModel.vue";
  import RegionSelect from "@/component/common/RegionSelectJSON";
  import { getAllPickingGoodsDetail } from "@/api/Stock";
  export default {
    components: {
      SelectCustomer,
      WarehouseModel,
      // RegionSelect,
    },
    data() {
      return {
        keyword: "",
        top_time: "today",
        customer_name: "",
        customer_name2: "",
        customerId: "",
        time: "",
        start: "",
        end: "",
        Return: "",
        region: "",
        Return_status: [],
        warehouseName: "",
        warehouse_show: false,
        warehouseId: "",
        tableData: [],
        page: 1,
        pageSize: 10,
        total: 0,
        records: [],
        provinceCode: "",
        cityCode: "",
        districtCode: "",
        currentUnit: "",
        personnelName: "",
        originId: "",
        goodsName: "",
      };
    },
    created() {
      this.getAllPickingGoodsDetail();
    },
    methods: {
      pageChange(val) {
        this.page = val;
        this.getAllPickingGoodsDetail();
      },
      sizeChange(val) {
        this.pageSize = val;
        this.pageChange(1);
      },
      selTopType() {},
      customerClear() {
        this.personnelName = "";
        this.customer_name = "";
        this.pageChange(1);
      },
      customerClear2() {
        this.currentUnit = "";
        this.customer_name2 = "";
        this.pageChange(1);
      },
      // 选择拣货人
      customerSel(val, list) {
        this.personnelName = list[0].id;
        this.pageChange(1);
      },
      //选择往来单位
      customerSel2(val, list) {
        this.currentUnit = 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);
      },
      // 选择区域
      regionChange(val) {
        this.provinceCode = val[0];
        this.cityCode = val[1];
        this.districtCode = val[2];
        this.pageChange(1);
      },
      async getAllPickingGoodsDetail() {
        const { data } = await getAllPickingGoodsDetail({
          page: this.page,
          pageSize: this.pageSize,
          no: this.keyword,
          start: this.start,
          end: this.end,
          originNo: this.originId,
          timeName: this.top_time,
          personnel: this.personnelName,
          currentUnitId: this.currentUnit,
          goodsName: this.goodsName,
          managerId: "",
          pickingStatus: "",
        });
        this.tableData = data;
      },
    },
  };
</script>
<style></style>
