<template>
  <div>
    <scan-code v-model="scanVisible" ref="scan" :stage="stage" :scanTable="scanTableList"></scan-code>
    <p-card v-show="isShow == 1" title="外复核">
      <template slot="extra">
        <a-space>
          <!-- <p-checkbox v-model="isAutoPrint">自动打印</p-checkbox>-->
          <p-checkbox v-model="isAutoPrint" v-if="activeKey === '1'">报告单</p-checkbox>
          <p-button
            type="primary"
            :disabled="activeKey !== '2'"
            v-if="activeKey === '2'"
            @clickSync="Askfor"
            icon="fork"
            >索取
          </p-button>
          <p-button type="primary" v-if="activeKey === '1'" @click="outerCheckPrint">打印</p-button>
          <p-button type="primary" v-if="activeKey === '2'" icon="scan" :disabled="!showSupervisedBtn" @click="scan">扫描监管码</p-button>
          <p-button
            type="primary"
            v-if="activeKey === '1'"
            :disabled="checkStatus"
            @clickSync="checkConfirm"
            icon="check"
            >复核</p-button
          >
          <p-button type="primary" v-if="activeKey === '4'" @clickSync="checkConfirmRed" icon="check">复核</p-button>
        </a-space>
      </template>
      <div class="plg-inner-form-mb">
        <p-grid-form ref="gridform" :span="8" :label-col="{ span: 8 }" :items="items" @submit="handlerSubmit" />
      </div>
      <a-tabs v-model="activeKey" @change="changTabs">
        <a-tab-pane key="1" tab="已索取任务" force-render>
          <p-table
            ref="table1"
            size="small"
            :autoLoad="false"
            v-if="activeKey === '1'"
            :scroll="{ x: 3500 }"
            :columns="columns"
            rowKey="_cusId"
            :doneBefore="doneBefore1"
            :remoteUrl="params1"
            :remoteData="params1.params"
            :remoteParams="params1.params"
            :dataSource.sync="dataSource1"
            :selectedRowKeys.sync="selectedRowKeys1"
            @clickRow="clickRow"
            :checkRow="checkRows"
            @select="selectRow"
            bordered
          >
          </p-table>
        </a-tab-pane>
        <a-tab-pane key="2" tab="未索取任务" force-render>
          <p-table
            ref="table2"
            size="small"
            :autoLoad="false"
            v-if="activeKey === '2'"
            :scroll="{ x: 3500 }"
            :columns="columns"
            rowKey="_cusId"
            :doneBefore="doneBefore1"
            :remoteUrl="params2"
            :remoteData="params2.params"
            :remoteParams="params2.params"
            :dataSource.sync="dataSource2"
            :selectedRowKeys.sync="selectedRowKeys2"
            @clickRow="clickRow"
            bordered
          />
        </a-tab-pane>
        <!-- <a-tab-pane key='4' tab='冲红单据' force-render>
          <p-table
            ref='table4'
            size='small'
            :autoLoad='false'
            v-if="activeKey === '4'"
            :scroll='{ x: 3500 }'
            :columns='columns'
            rowKey='_cusId'
            :doneBefore='doneBefore1'
            :remoteUrl='params4'
            :remoteData='params4.params'
            :remoteParams='params4.params'
            :dataSource.sync='dataSource4'
            :selectedRowKeys.sync='selectedRowKeys4'
            @clickRow='clickRow'
            bordered
          />
        </a-tab-pane> -->
        <!--        <a-tab-pane key="3" tab="外复核草单">-->
        <!--          <p-table-->
        <!--              ref="table3"-->
        <!--              size="small"-->
        <!--              :autoLoad="false"-->
        <!--              v-if="activeKey === '3'"-->
        <!--              :scroll="{ x: 3500 }"-->
        <!--              :columns="columns"-->
        <!--              rowKey="_cusId"-->
        <!--              :doneBefore="doneBefore1"-->
        <!--              :remoteUrl="params3"-->
        <!--              :remoteData="params3.params"-->
        <!--              :remoteParams="params3.params"-->
        <!--              :dataSource.sync="dataSource3"-->
        <!--              :selectedRowKeys.sync="selectedRowKeys3"-->
        <!--              @clickRow="clickRow"-->
        <!--              bordered-->
        <!--          />-->
        <!--        </a-tab-pane>-->
      </a-tabs>
      <p-table
        size="small"
        :loading="loading"
        :columns="singleColumns"
        :customRow="detailCustomRow"
        rowKey="srcCode"
        :rowSelectType="2"
        bordered
        :dataSource.sync="detailDataSource"
        :selectedRowKeys.sync="detailSelectedRowKeys"
        :scroll="{ x: 3000 }"
      >
        <template slot="action" slot-scope="text, record">
          <a @click.stop="itemDet(record)">详情</a>
          <a style="margin: 0 5px" @click.stop="HcOrder(record)">红冲</a>
        </template>
      </p-table>
    </p-card>
    <!-- 红冲弹窗 -->
    <HCdetailDialog v-if="isShow == 2" :billid="billid" :singleData="singleData" @clickEvent="clickEvent" />
    <!-- 解锁弹窗 -->
    <workerLogin
      :loginVisible="loginVisible"
      :isSupervisedData="isSupervisedData"
      @loginResult="loginResult"
      @handleCancel="handleCancel"
    />
    <!-- 自提弹窗 -->
    <a-modal width="700px" title="" ok-text="" :visible="LCLinfoVisible" @cancel="handleCancel">
      <template slot="footer">
        <a-button @click="handleCancel">取消</a-button>
        <a-button type="primary" @click="eidthandleOk">确认</a-button>
      </template>
      <div>
        <p-table-edit-pro
          ref="hcTable"
          style="padding: 30px"
          :scroll="{ x: true }"
          :dataSource.sync="takeGoodData"
          :columns="singleColumnsEdit"
          @clickRow="clickRow"
          :hasRepairDataSource="true"
          :rowSelectType="false"
          rowKey="lineid"
        >
          <!-- <div slot="action" href="javascript:;" slot-scope="text, record">
            <a slot="action" style="margin: 0 10px" @click.stop="orderHC(record)">红冲</a>
          </div> -->
        </p-table-edit-pro>
      </div>
    </a-modal>
    <!-- 冲红弹窗 -->
    <a-modal width="700px" title="冲红" ok-text="" :visible="HCVisible" v-if="HCVisible" @cancel="handleCancel">
      <template slot="footer">
        <a-button @click="handleCancel">取消</a-button>
        <a-button type="primary" @click="HChandleOk">确认</a-button>
      </template>
      <div>
        <p-grid-form ref="HCgridform" :span="24" :label-col="{ span: 8 }" :items="HCitems" />
      </div>
    </a-modal>
    <itemDetail ref="detailItem" :itemId="itemId" />
  </div>
</template>

<script>
// 设置默认仓库
import { setwarehouse } from "@/views/kzyWMS/SearchModal/mixins_warehouse.js";
import { items, columns, singleColumns, HCitems } from "./config/outerCheck";
import { toPrintServer, tempType } from "@/views/kzyWMS/utils/printServer.js";
import workerLogin from "@/views/kzyWMS/outBound/check/innerCheck/components/workerLogin";
import HCdetailDialog from "../../schedule/HCdetailDialog.vue";

import {
  outercheckGain,
  outercheckConfirm,
  picktaskList,
  outerhPrint,
  outerPapersliphPrint,
  isSupervised,
  isShowSupervised,
  outercheck,
  outerhPrintouter,
} from "./api";
import { scan_warehouse } from "../../picking/config/api.js";
import { mapGetters } from "vuex";
import scanCode from "../../components/scanCode"; //扫描监管码
import itemDetail from "@/views/kzyWMS/components/itemDetail";

import { sorter } from "@/views/kzyWMS/utils/sort.js";
import { diffOption } from "@/views/kzyWMS/utils/index.js";
import { upcloud_base_wh_outbound } from "@/config/serviceSettings";

export default {
  name: "InnerCheck",
  mixins: [setwarehouse],
  components: { scanCode, itemDetail, workerLogin, HCdetailDialog },
  data() {
    return {
      // tabs 显示 1-已索取任务 2-未索取任务 3-外复核草单
      activeKey: "1",
      // 汇总列配置
      columns: [],
      // 明细列配置
      singleColumns: sorter(singleColumns),
      // 汇总表单配置
      items: items(this),
      HCitems: HCitems(this),
      itemId: "",
      // 是否自动打印
      isAutoPrint: true,
      // 是否扫描监管码
      showSupervisedBtn: false,
      // 已索取任务
      dataSource1: [],
      selectedRowKeys1: [],
      params1: {
        url: upcloud_base_wh_outbound + "/picktask/page-outercheckh",
        params: {},
        timeout: 30000,
        method: "get",
      },
      // 未索取任务
      dataSource2: [],
      selectedRowKeys2: [],
      params2: {
        url: upcloud_base_wh_outbound + "/picktask/page-unoutercheckh2",
        params: {},
        timeout: 30000,
        method: "get",
      },
      // 冲红单据
      dataSource4: [],
      selectedRowKeys4: [],
      params4: {
        url: upcloud_base_wh_outbound + "/picktask/page-unoutercheckh2",
        params: {},
        timeout: 30000,
        method: "get",
      },
      // 外复核草单
      dataSource3: [],
      selectedRowKeys3: [],
      params3: {
        url: upcloud_base_wh_outbound + "/picktask/page-outercheck-order",
        params: {},
        timeout: 30000,
        method: "get",
      },
      // 明细
      detailDataSource: [],
      detailSelectedRowKeys: [],

      checkStatus: false,
      loading: false,
      lookats: false,
      isUpload: false,
      scanVisible: false, //p-modal弹窗：扫描监管码
      warehouseId: "",
      isScan: 0, //扫描监管码是否禁用。
      scanTableList: [], // 扫描监管码数据
      loginVisible: false,
      isSupervisedData: {},
      isShow: 1,
      billid: "",
      singleData: [],
      LCLinfoVisible: false,
      takeGoodData: [],
      takeGoodData2: [],
      selectedRows: [],
      singleColumnsEdit: [
        { type: "txt", ellipsis: true, dataIndex: "srcCode", title: "单据编号" },
        { type: "edit", ellipsis: true, dataIndex: "takeGoodsName", title: "提货人姓名" },
        { type: "edit", ellipsis: true, dataIndex: "takeGoodsPhone", title: "提货人电话" },
      ],
      singleItem: {},
      HCVisible: false,
      stage: 3, //扫码阶段：0=入库质检 1=PC拣货 2=PC内复核 3=PC外复核 4=补录 5=PDA拣货 6=PDA内复核 7=PDA外复核
    };
  },
  watch: {
    warehouseId(nVal, oVal) {
      this.scanCode();
    },
  },
  created() {
    this.warehouseId = this.warehouse.warehouseId;
    this.scanCode();
    this.params1.params.bldgId = "599581810778836992";

    // 判断监管码弹窗是否显示
    isShowSupervised({ id: this.warehouseId }).then((res) => {
      if (res.success) {
        // 是否显示【扫描监管码】按钮
        this.showSupervisedBtn = [1, 3].includes(res.data.scanSupervisionCodeStage);
      }
    });
  },
  mounted() {
    diffOption(columns).then((res) => {
      this.columns = sorter(res);
    });
    this.$refs.gridform.form.setFieldsValue({ bldgId: "599581810778836992", bldgName: "曲靖康桥仓" });

    this.items[0].value = this.userInfo.employeeNo;
    // 已索取任务
    this.$refs.table1.reload({
      params: {
        operatorCode: this.userInfo.employeeNo,
        warehouseId: this.warehouse.warehouseId,
      },
    });
  },
  computed: {
    ...mapGetters(["userInfo", "warehouse"]),
    rowSelection() {
      let _this = this;
      return {
        selectedRowKeys: _this.selectedRowKeys,
        onChange(selectedRowKeys, selectedRows) {
          _this.selectedRows = selectedRows;
          _this.selectedRowKeys = selectedRowKeys;
        },
      };
    },
  },
  methods: {
    // 扫描监管码
    async scan() {
      const detailSelectedRowKeys = this.detailSelectedRowKeys;
      if (detailSelectedRowKeys.length === 0) return this.$message.error("请至少选择一条数据");
      const supervisedList = this.detailDataSource.filter(
        (_) => detailSelectedRowKeys.includes(_.srcCode) && _.isSupervise == "1"
      );
      if (supervisedList.length === 0) return this.$message.error("选择的数据不需要扫描监管码");
      this.isSupervised(supervisedList);
    },
    async isSupervised(data) {
      console.log(data);
      let list = data.map((item) => {
        const { barcode: refBillId, barcodeDId: refBillLineId } = item;
        return { ...item, refBillId, refBillLineId };
      });
      let res = await isSupervised(list);
      console.log(res);
      if (res.success) {
        if (res.data !== true && list.length) {
          this.dataTransformation(data);
          return false;
        } else {
          return true;
        }
      }
    },
    checkRows(selectedRow, selectedRowKey) {},
    // 获取是否 [integer] 扫描监管码节点：0=拣货 1=外复核
    scanCode() {
      scan_warehouse({ id: this.warehouseId }).then((res) => {
        if (res.success) {
          console.log("扫描监管码节点：0=拣货 1=外复核:", res.data.scanSupervisionCodeStage);
          this.isScan = res.data.scanSupervisionCodeStage;
        } else {
          this.$exception(res);
        }
      });
    },
    detailCustomRow(record, index) {
      return {
        on: {
          dblclick: () => {
            console.log(record);
            if (record.isSupervise == "0") return this.$message.error("无需扫描监管码");
            this.dblClickIsSupervise([record]);
          },
        },
      };
    },
    async dblClickIsSupervise(supervisedList) {
      if (supervisedList.length > 0) {
        let isSupervisedStatus = await this.isSupervised(supervisedList);
        return !!isSupervisedStatus;
      }
    },
    doneBefore1(data, list) {
      data.data.list.forEach((item) => {
        item._cusId = "_cusId" + Math.random() * 10000;
      });
    },
    dataTransformation(data) {
      this.scanTableList = data
        .filter((item) => item.isSupervise == "1")
        .map((item) => {
          const {
            barcode: refBillId,
            barcodeDId: refBillLineId,
            qty: pieceQty,
            itemCode: itemNum,
            specification: itemSpecs,
            billCode: srcCode,
            lotNo: manufacturerLotNum,
          } = item;
          return { ...item, refBillId, refBillLineId, pieceQty, itemNum, itemSpecs, srcCode, manufacturerLotNum };
        });
      if (this.scanTableList.length === 0) return;
      this.scanVisible = true;
    },
    itemDet(data) {
      console.log(data);
      this.itemId = data.itemId;
      this.$refs.detailItem.open();
    },
    handlerSubmit(event, form) {
      event.preventDefault();
      this.$refs.gridform.form.validateFields((error, values) => {
        if (!!error) return;
        this.detailDataSource = [];
        if (this.activeKey == "1") {
          delete values.warehouseName;
          this.params1.params = values;
        }
        if (this.activeKey == "2") {
          delete values.warehouseName;
          this.params2.params = { ...values, partlyRed: "0" };
        }
        if (this.activeKey == "3") {
          this.params3.params = values;
        }
        if (this.activeKey == "4") {
          this.params4.params = { ...values, partlyRed: "1" };
        }
      });
    },
    clickRow(form, rowKey, record) {
      this.headerItem = record;
      this.getItemsLine(record);
    },
    selectRow(record) {
      this.getItemsLine(record);
    },
    getItemsLine(record) {
      const { srcCode } = record;
      this.$refs.gridform.form.validateFields((error, values) => {
        if (!error) {
          const { warehouseId, bldgId } = this.$refs.gridform.form.getFieldsValue();
          const params = { srcCode, warehouseId, bldgId };
          this.loading = true;
          picktaskList(params).then((res) => {
            this.loading = false;
            if (res.success) {
              this.detailDataSource = res.data.map((item) => {
                const srcCode = "_cusId" + Math.random() * 10000;
                return { ...item, srcCode };
              });
            } else {
              this.$exception(res);
            }
          });
        }
      });
    },
    async checkConfirm() {
      const selectedRowKeys1 = this.selectedRowKeys1;
      if (selectedRowKeys1.length === 0) return this.$message.error("请至少选择一条数据");

      let supervisedList = this.detailDataSource.filter((item) => item.isSupervise == "1");
      if (supervisedList.length > 0) {
        let isSupervisedStatus = await this.isSupervised(supervisedList);
        if (!isSupervisedStatus) return;
      }
      const srcCodes = this.dataSource1.filter((_) => selectedRowKeys1.includes(_._cusId)).map((_) => _.srcCode);
      this.$refs.gridform.form.validateFields((error, values) => {
        if (!!error) return;
        const partlyRed = this.activeKey === "4" ? "1" : undefined;
        const params = {
          srcCodes,
          operatorCode: values.operatorCode,
          warehouseId: values.warehouseId,
          bldgId: values.bldgId,
          partlyRed,
        };
        this.checkStatus = true;
        outercheckConfirm(params).then((res) => {
          this.checkStatus = false;
          this.detailDataSource = [];
          if (res.success) {
            this.$message.success(res.message);
            if (this.activeKey === "1") {
              this.$refs.table1.reload();
            } else {
              this.$refs.table2.reload();
            }
          } else {
            this.$exception(res);
          }
        });
      });
    },
    async checkConfirmRed() {
      const selectedRowKeys4 = this.selectedRowKeys4;
      if (selectedRowKeys4.length === 0) return this.$message.error("请至少选择一条数据");

      const srcCodes = this.dataSource4.filter((_) => selectedRowKeys4.includes(_._cusId)).map((_) => _.srcCode);
      this.$refs.gridform.form.validateFields((error, values) => {
        if (!!error) return;
        const params = {
          srcCodes,
          operatorCode: values.operatorCode,
          warehouseId: values.warehouseId,
          bldgId: values.bldgId,
          partlyRed: "1",
        };
        this.checkStatus = true;
        outercheckConfirm(params).then((res) => {
          this.checkStatus = false;
          this.detailDataSource = [];
          if (res.success) {
            this.$message.success(res.message);
            this.$refs.table4.reload();
          } else {
            this.$exception(res);
          }
        });
      });
    },
    //红冲
    async HcOrder(data) {
      this.loginVisible = true;
      // this.HCVisible = true

      this.singleItem = data;
      console.log(this.headerItem, "this.headerItem");
      let warehouseId = this.$refs.gridform.form.getFieldsValue().warehouseId;
      this.isSupervisedData = {
        specialWorkType: "外复核红冲",
        warehouseId: warehouseId,
      };

      // this.billid = data.billid
      // const warehouseId = this.$refs.gridform.form.getFieldValue('warehouseId')
      // this.isSupervisedData = {
      //   specialWorkType: '外复核红冲',
      //   warehouseId: warehouseId
      // }
      // const res = await orderOne({ billid: data.billid, pageNum: 1, pageSize: 10 })
      // if (res.success) {
      //   const { list } = res.data
      //   this.singleData = list
      //   this.loginVisible = true
      // } else {
      //   this.$exception(res)
      // }
    },
    HChandleOk() {
      this.$refs.HCgridform.form.validateFields((error, values) => {
        if (!error) {
          const { warehouseId, bldgId } = this.$refs.gridform.form.getFieldsValue();
          const params = { ...this.singleItem, warehouseId, bldgId, ...values };
          this.loading = true;
          outercheck(params).then((res) => {
            this.loading = false;
            if (res.success) {
              this.HCVisible = false;
              this.getItemsLine(this.headerItem);
            } else {
              this.$exception(res);
            }
          });
        }
      });
    },
    //红冲成功
    clickEvent() {
      this.isShow = 1;
    },
    //登录成功
    loginResult(data, value) {
      if (!data) {
        console.log(value);
        this.workercode = value.workercode;
        this.loginVisible = data;
        // this.isShow = 2
        this.HCVisible = true;
      }
    },
    //解锁窗口关闭
    handleCancel(e) {
      this.visible = false;
      this.loginVisible = false;
      this.LCLinfoVisible = false;
      this.HCVisible = false;
    },
    // 切换tabs
    changTabs(activeKey) {
      this.detailDataSource = [];
      console.log("当前tab:", activeKey);
      let params = this.$refs.gridform.form.getFieldsValue();
      if (activeKey === "1") {
        this.params1.params = params;
        this.$nextTick(() => {
          // 已索取任务
          this.$refs.table1.reload({ params });
        });
      }
      if (activeKey === "2") {
        this.params2.params = params;
        this.$nextTick(() => {
          // 未索取任务
          this.$refs.table2.reload({ params: { ...params, partlyRed: "0" } });
        });
      }
      if (activeKey === "3") {
        this.params3.params = params;
        this.$nextTick(() => {
          // 外复核草单
          this.$refs.table3.reload({ params });
        });
      }
      if (activeKey === "4") {
        this.params4.params = params;
        this.$nextTick(() => {
          // 冲红单据
          this.$refs.table4.reload({ params: { ...params, partlyRed: "1" } });
        });
      }
    },
    outerCheckPrint() {
      const activeKey = this.activeKey;
      // 打印已索取任务
      // console.log(this.selectedRowKeys1,'selectedRowKeys1')
      const selectedRowKeys1 = this.selectedRowKeys1;
      if (activeKey == "1") {
        if (this.selectedRowKeys1.length < 1) {
          this.$message.error("请至少选择一条数据");
          return;
        }
        const warehouseId = this.$refs.gridform.form.getFieldsValue().warehouseId;
        const warehouseName = this.$refs.gridform.form.getFieldsValue().warehouseName;
        console.log(warehouseName, "warehouseName");
        // this.selectedRows.forEach((item) => {
        //   srcCodes.push(item.srcCode)
        // })
        const srcCodes = this.dataSource1.filter((_) => selectedRowKeys1.includes(_._cusId)).map((_) => _.srcCode);
        if (this.isAutoPrint) {
          outerhPrintouter({ srcCodes: srcCodes, warehouseId, warehouseName }).then((res) => {
            if (!res.success) {
              this.$exception(res);
              return;
            }
            let printdata = [];
            res.data.forEach((item) => {
              item.data.forEach((items) => {
                printdata.push(items);
              });
            });
            toPrintServer(printdata, warehouseId, "wfhcd").then((res) => {
              if (!res.success) {
                this.$exception(res);
                return;
              }
              this.$message.success(res.message);
            });
          });
        }
        outerhPrint({ srcCodes: srcCodes, warehouseId, warehouseName }).then((res) => {
          if (!res.success) {
            this.$exception(res);
            return;
          }
          let printdata = [];
          res.data.forEach((item) => {
            item.data.forEach((items) => {
              printdata.push(items);
            });
          });
          toPrintServer(printdata, warehouseId, "wfhd").then((res) => {
            if (!res.success) {
              this.$exception(res);
              return;
            }
            this.$message.success(res.message);
          });
        });
        return;
      }
      // 打印外复核草单
      if (activeKey == "3") {
        const selectedRowKeys3 = this.selectedRowKeys3;
        if (selectedRowKeys3.length === 0) return this.$message.error("请至少选择一条数据");
        const warehouseId = this.$refs.gridform.form.getFieldsValue().warehouseId;
        const srcCodes = this.dataSource3.filter((_) => selectedRowKeys3.includes(_._cusId)).map((_) => _.srcCode);
        outerPapersliphPrint({ srcCodes, warehouseId }).then((res) => {
          if (res.success) {
            const printData = [];
            res.data.forEach((item) => {
              item.data.forEach((items) => {
                printData.push(items);
              });
            });
            toPrintServer(printData, warehouseId, tempType.wfhcd).then((res) => {
              if (!res.success) {
                this.$exception(res);
                return;
              }
              this.$message.success(res.message);
            });
          } else {
            this.$exception(res);
            return;
          }
        });
      }
    },
    eidthandleOk() {
      let data = this.takeGoodData.concat(this.takeGoodData2);
      let values = this.$refs.gridform.form.getFieldsValue();
      this.outercheckGain(values, data);
      console.log(data, "this.takeGoodData");
    },
    outercheckGain(values, selectRecords) {
      let params = selectRecords.map((i) => {
        console.log(i);
        return {
          ...values,
          srcBillCode: i.srcCode,
          barcode: i.barcode,
          takeGoodsName: i.takeGoodsName ? i.takeGoodsName : "",
          takeGoodsPhone: i.takeGoodsPhone ? i.takeGoodsPhone : "",
        };
      });
      // console.log(data);
      // return;
      outercheckGain(params).then((res) => {
        this.detailDataSource = [];
        this.selectedRowKeys2 = [];
        if (res.success) {
          this.$message.success(res.message);
          this.LCLinfoVisible = false;
          this.$refs.table2.reload();
          // 索取成功,判断是否自动打印
          // if (this.isAutoPrint) {
          //   const warehouseId = this.$refs.gridform.form.getFieldsValue().warehouseId
          //   let srcCodes = selectRecords.map((_) => _.srcCode)
          //   outerhPrint({ srcCodes, warehouseId }).then((res) => {
          //     if (!res.success) {
          //       this.$exception(res)
          //       return
          //     }
          //     const printData = []
          //     res.data.forEach((item) => {
          //       item.data.forEach((items) => {
          //         printData.push(items)
          //       })
          //     })
          //     toPrintServer(printData, warehouseId, tempType.wfhd)
          //   })
          // }
          // 切换至已索取tab
          this.changTabs("1");
        } else {
          this.$exception(res);
        }
      });
    },

    Askfor() {
      const selectedRowKeys2 = this.selectedRowKeys2;
      if (selectedRowKeys2.length === 0) return this.$message.error("请至少选择一条数据进行索取!");
      this.$refs.gridform.form.validateFields((error, values) => {
        if (!!error) return;
        const selectRecords = this.dataSource2.filter((_) => selectedRowKeys2.includes(_._cusId));
        console.log(selectRecords);
        if (
          selectRecords.some((item) => {
            return item.arrivalMode == "自提";
          })
        ) {
          let takeGoods = selectRecords.filter((item) => {
            return item.arrivalMode == "自提";
          });
          this.takeGoodData = takeGoods;
          this.takeGoodData2 = selectRecords.filter((item) => {
            return item.arrivalMode !== "自提";
          });
          this.LCLinfoVisible = true;
          return;
        }
        this.outercheckGain(values, selectRecords);
      });
    },
  },
};
</script>
