<template>
  <div class="page-box" v-loading="Loading.appMainLoading">
    <tablePagination
      :currenButtonData="currenButtonData"
      :tableData="tableData"
      :tableLoading="Loading.tableLoading"
      :tableColumns="tableColumns"
      @rowDrop="rowDrop"
      :totalCount="totalCount"
      :multipleSelection="multipleSelection"
      :MaxResultCount="PageListParams.MaxResultCount"
      @topbutton="topbutton"
      @inlineDialog="inlineDialog"
      @sortChange="sortChange"
      @alertoldSkipCount="alertoldSkipCount"
      @alterResultCount="alterResultCount"
      @handleSelectionChange="handleSelectionChange"
      :currentPageProps="oldSkipCount"
      :quicklySearchOption="quicklySearchOption"
      @quicklySearchClick="quicklySearchClick"
      @quicklySearchClear="quicklySearchClear"
      :primarySearchOption="primarySearchOption"
      @overallSearchFormClick="overallSearchFormClick"
      :httpOverallSearchData="httpOverallSearchData"
    >
    </tablePagination>
    <!-- 新导入 disabledMethod 导入方式禁用 disabledIsAllowPartImport 是否局部导入禁用-->
    <!-- methodValue 导入方式默认选项  是否局部导入 默认选项  -->
    <importFile
      :loading="Loading.importLoading"
      :show="displayDialog.importDialog"
      :URL="URL"
      :disabledMethod = {method1:false,method2:false,method3:false}
      :disabledIsAllowPartImport = {isAllowPartImport1:false,isAllowPartImport2:false}
      methodValue="0"
      isAllowPartImportValue="1"
      @importClick="postImportMergeClick(arguments)"
      @postImportDown="importDown"
    ></importFile>
    <!--抽屉-->
    <curren-Drawer
      :title="tableColumns"
      :DrawerLoading="Loading.DrawerLoading"
      :drawer="displayDialog.detailsDialog"
      :propsData="propsData"
      :tabsDesTions="tabsDesTions"
      :Butttondata="DrawerButtonData"
      @drawerShut="(val) => (displayDialog.detailsDialog = val)"
      @drawerbutton="drawerbutton"
      @handleCommand="drawerHandle"
      @close-value="closeValue"
      :tableColumns="detailsTableColumns"
      :totalCount="totalCountDetails"
      :MaxResultCount="MaxResultCountDetails"
      @alterResultCountDetails="alterResultCountDetails"
      @alertoldSkipCountDetails="alertoldSkipCountDetails"
    ></curren-Drawer>
  </div>
</template>
<script>
import { getInventoryLabelByCodes } from "@/api/wms-core"
import { tableMixins } from "@/mixins/TableMixins";
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { drawerMixins } from "@/mixins/drawerMixins";
import { TableHeaderMixins } from "@/mixins/TableHeaderMixins";
import { mixins } from "@/mixins/mixins";
import {initPrintPackingCodeManyData } from "@/mixins/printMixin"
export default {
  name: "PurchaseReceiptRequest",
  mixins: [
    tableMixins,
    LoadingMixins,
    drawerMixins,
    TableHeaderMixins,
    mixins,
  ],
  computed: {
    editDialog: {
      get: function () {
        return this.displayDialog.newDialog || this.displayDialog.editDialog;
      },
    },
  },
  data() {
    return {
      URL: "wms/store/purchase-receipt-request",
      DrawerButtonData: [
        {
          type: 'info',
          icon: 'el-icon-printer',
          label: '打印',
          hide: false,
          name: "print",
          size: 'mini'
        },
      ],
      //常用按钮数据
      currenButtonData: [
        this.defaultExportBtn(),//导出
        this.defaultFieldSettingBtn(),//字段设置
        this.defaultFreshBtn(),//刷新
        this.defaultFilterBtn(),//筛选
      ],
    };
  },
  mounted() {
    this.paging();
  },
  methods: {
    //抽屉内常用按钮
    drawerbutton (val) {
      // 打印
      if(val == 'print'){
        let _ids = []
        this.propsData.details.forEach(item => {
          _ids.push(item.packingCode)
        });
        this.Loading.appMainLoading = true;
        getInventoryLabelByCodes(_ids).then(res => {
          this.Loading.appMainLoading = false;
          let _printData = {
            supplierSimpleName:res[0].supplierSimpleName || "",
            supplierCode:res[0].supplierCode || "",
            contacts:res[0].contacts || "",
            customerAddressCode:res[0].customerAddressCode || "",
            remark:res[0].remark || "",
            planArriveDate:res[0].planArriveDate || "",
            poNumber:res[0].poNumber || "",
            asnNumber:res[0].asnNumber || "",
            details:[],
          }
          res.forEach(item=>{
            item.packingCode = item.code
            _printData.details.push(item)
          })
          let _data = initPrintPackingCodeManyData(_printData);
          this.Print(_data)
        }).catch(err => {
          console.log(err)
          this.Loading.appMainLoading = false;
        })
      }
    },
  },
};
</script>
<style lang="scss" scoped>
@import "../../../styles/mainbasicData.scss";
</style>