<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>
    <!-- 抽屉 -->
    <curren-Drawer
      :title="tableColumns"
      :DrawerLoading="Loading.DrawerLoading"
      :drawer="displayDialog.detailsDialog"
      :propsData="propsData"
      :Butttondata="DrawerButtonData"
      :tabsDesTions="tabsDesTions"
      @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 { getPageListWip , sumPrint,getOneCustomerInfoByCode} from '@/api/wms-api'
  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 { initPrintAllData } from '@/mixins/printMixin'
  export default {
    name: "materialDirectSendNote",
    mixins: [
      tableMixins,
      LoadingMixins,
      drawerMixins,
      TableHeaderMixins,
      mixins,
    ],
    data () {
      return {
        URL: 'wms/store/deliver-note',
        //常用按钮数据
        currenButtonData: [
          //导出
          this.defaultExportBtn({
            url:"wms/store/deliver-note/export-for-raw"
          }),
          this.defaultFieldSettingBtn(),//字段设置
          this.defaultFreshBtn(),//刷新
          this.defaultFilterBtn(),//筛选
        ],
        DrawerButtonData: [
          {
            type: 'info',
            icon: 'el-icon-printer',
            label: '打印',
            hide: false,
            name: "print",
            size: 'mini'
          },
        ],
      };
    },
    mounted () {
      this.paging();
    },
    methods: {
        paging(){
            this.Loading.tableLoading = true;
            this.PageListParams.SkipCount = (this.oldSkipCount - 1) * this.PageListParams.MaxResultCount,
            getPageListWip(this.PageListParams, 'wms/store/deliver-note/list-for-raw').then(res => {
                this.tableData = res.items
                this.totalCount = res.totalCount
                this.pagingCallback()
            }).catch(err => {
                this.Loading.tableLoading = false
            })
        },

      beforePrintHandle(callback){
        if((this.propsData.customerCode)){
          getOneCustomerInfoByCode(this.propsData.customerCode).then(res => {
            this.propsData.customerAddressCode  = res.address 
            callback()
          }).catch(err => {
              console.log(err)
          })
        }else{
          callback()
        }
      },
      //抽屉常用按钮
      drawerbutton (val) {
        // 打印
        if(val == 'print'){
          this.beforePrintHandle(()=>{
            let _option = {
              details:{
                packingCode:"toPackingCode",
              }
            }
            let data = initPrintAllData(this.propsData,'chdmxb.rdlx',false,_option);
            this.Print(data)
            sumPrint(this.propsData.number, this.URL).then(res => {
              this.paging()
            }).catch(err => {
              console.log(err)
            })
          })
        }
      },
    },
  };
  </script>
  <style lang="scss" scoped>
  @import "../../../styles/basicData.scss";
  </style>