<template>
  <!-- 预托书列表 -->
  <div id="preBookList">
    <!-- 查询区域 -->
    <a-card :bordered="false">
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :md="5" :sm="8">
              <a-form-item label="订单号">
                <a-input placeholder="请输入订单号" v-model="queryParam.orderNumber"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="5" :sm="8">
                <a-form-item label="托书号">
                  <a-input placeholder="请输入托书号" v-model="queryParam.shippingOrderNumber"></a-input>
                </a-form-item>
              </a-col>
            
            <a-col :md="5" :sm="8">
              <a-form-item label="客户简称">
                <!-- <a-input placeholder="请输入客户简称" v-model="queryParam.clientAbbreviation"></a-input> -->
                 <j-search-select-tag
                  placeholder="请选择客户简称"
                  v-model="queryParam.clientAbbreviation"
                  dict="view_customer,customername,customername">
                </j-search-select-tag>
              </a-form-item>
            </a-col>
            <a-col :md="5" :sm="8">
                <a-form-model-item label="类型">
                  <a-select v-model="queryParam.type">
                    <a-select-option value="成衣">成衣</a-select-option>
                    <a-select-option value="面辅料">面辅料</a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>

            <template v-if="toggleSearchStatus">
              <a-col :md="4" :sm="8">
              <a-form-item label="账套号">
                 <j-search-select-tag
                  placeholder="请选择账套号"
                  v-model="queryParam.pkOrg"
                  dict="view_account,account,account">
                </j-search-select-tag>
              </a-form-item>
            </a-col>
              <!-- <a-col :md="6" :sm="8">
                <a-form-item label="箱号">
                  <a-input placeholder="请输入箱号" v-model="queryParam.containerNumber"></a-input>
                </a-form-item>
              </a-col> -->

              <a-col :md="5" :sm="8">
                <a-form-item label="小po号">
                  <a-input placeholder="请输入小po号" v-model="queryParam.smailPo"></a-input>
                </a-form-item>
              </a-col>

              <a-col :md="5" :sm="8">
              <a-form-item label="单据日期" has-feedback>
                <a-range-picker
                  :placeholder="['开始时间', '结束时间']"
                  format="YYYY-MM-DD"
                  style="width: 100%"
                  v-model="shippingOrderDate"
                  @change="orderDataChange"
                />
                <!-- <a-date-picker style="width: 100%" v-model="queryParam.shippingOrderDate" @change="orderDataChange" > </a-date-picker> -->
              </a-form-item>
            </a-col>
            <a-col :md="5" :sm="8">
                <a-form-item label="船期">
                  <a-date-picker
                    placeholder="请选择"
                    style="width:100%;"
                    format="YYYY-MM-DD"
                    valueFormat="YYYY-MM-DD"
                    v-model="queryParam.theFinalShippingDate"
                  />
                </a-form-item>
              </a-col>
              <a-col :md="5" :sm="8">
                <a-form-item label="供应商">
                    <j-search-select-tag
                        placeholder="请选择供应商"
                        v-model="queryParam.supplier"
                        dict="view_supplier,supplier,supplier">
                    </j-search-select-tag>
                </a-form-item>
              </a-col>
              <a-col :md="5" :sm="8">
                <a-form-item label="款号">
                  <a-input placeholder="请输入款号" v-model="queryParam.styleNum"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="5" :sm="8">
                <a-form-item label="外销发票">
                  <a-input placeholder="请输入外销发票" v-model="queryParam.exportInvoiceNo"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="5" :sm="8">
                <a-form-model-item label="发票推送状态">
                  <a-select v-model="queryParam.timeStuta">
                    <a-select-option value="">请选择</a-select-option>
                    <a-select-option value="0">可推送</a-select-option>
                    <a-select-option value="1">推送中</a-select-option>
                    <a-select-option value="2">推送成功</a-select-option>
                    <a-select-option value="3">推送失败</a-select-option>
                    <a-select-option value="4">不可推送</a-select-option>
                    <a-select-option value="5">推送中</a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
               
            </template>
            <a-col :md="4" :sm="8">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                <a @click="handleToggleSearch" style="margin-left: 8px">
                  {{ toggleSearchStatus ? '收起' : '展开' }}
                  <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-card>

    <!-- 操作按钮区域 新增-->
    <a-card :bordered="false" style="marginTop:10px;">
      <div class="table-operator">
        <a-button type="primary" @click="addBookDrawer" icon="plus">新增</a-button>
        <a-button type="primary" @click="batchSubmit()"  icon="plus">批量提交</a-button>
        <a-button type="primary" @click="batchCanaleSubmit()" icon="plus">批量取消提交</a-button>
        <a-button type="primary" @click="batchPushU8()" icon="plus" :disabled="loadingU8">批量推送U8</a-button>
        <a-button type="primary" @click="batchPushInvoice()" icon="plus">批量推送装箱单发票  </a-button>
      </div>

      <!-- 子表 -->
      <a-table
        bordered
        :columns="bookListColumns"
        :data-source="bookListData"
        :loading="loading"
        :scroll="{x: 1200 , y: 600 }"
        :pagination="pagination"
        :row-key="record => record.id"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
      >
        <!-- 金额 输入框
        <template slot="money" slot-scope="text, record, index">
          <a-form-model-item prop="money" :rules="rules.money" required>
            <a-input style="width:100%" type="text" v-model="record.money" />
          </a-form-model-item>
        </template> -->

        <!-- 单据状态 -->
        <span slot="documentStateSlot" slot-scope="text, record">
          <a-tag color="orange" v-if="record.theDocumentsState == '0'">未提交</a-tag>
          <a-tag color="green" v-if="record.theDocumentsState == '1'">提交</a-tag>
        </span>

        <!-- 推送状态 -->
        <span slot="syStuta" slot-scope="text, record">
          <a-tag color="orange" v-if="record.syStuta == '0'">未推送</a-tag>
          <a-tag color="green" v-if="record.syStuta == '1'">已推送</a-tag>
        </span>
        <!-- 发票推送状态 -->
        <span slot="timeStuta" slot-scope="text, record">
          <a-tag color="#f50" v-if="record.timeStuta == '0'">可推送</a-tag>
          <a-tag color="blue" v-if="record.timeStuta == '1'">推送中</a-tag>
          <a-tag color="green" v-if="record.timeStuta == '2'">推送成功</a-tag>
          <a-tag color="red" v-if="record.timeStuta == '3'">推送失败</a-tag>
          <a-tag color="B7B7B7" v-if="record.timeStuta == '4'">不可推送</a-tag>
          <a-tag color="blue" v-if="record.timeStuta == '5'">推送中</a-tag>
        </span>
        
        <!-- if  已提交 -->
        <!-- <span slot="documentStateSlot">
          <a-tag color="#2db7f5">已提交</a-tag>
        </span> -->

        <!-- 操作 -->
        <span slot="operationSlot" slot-scope="text, record">
          <a @click="handleExportXls(record)" style="color:green;">{{record.isAhaa}}-结汇发票打印</a>
          <a-divider type="vertical" />

          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
            <a-menu slot="overlay" v-if="record.theDocumentsState == '0'">
              <!-- <a-menu-item><a @click="submit(record)">提交</a></a-menu-item> -->
              <a-menu-item><a @click="edit(record,'2')">详情</a></a-menu-item>
              <a-menu-item><a @click="edit(record,'1')">编辑</a></a-menu-item>
               <a-menu-item v-if="record.readyFabric=='辅料'||record.readyFabric=='面料'"><a @click="copyForm(record)">复制</a></a-menu-item>
              <!-- <a-menu-item ><a @click="pushU8(record)">推送u8</a></a-menu-item> -->
              <!-- <a-menu-item><a @click="print(record)">打印</a></a-menu-item> -->
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="handleDelete(record.id)">
                  <a href="javascript:void(0);" style="color:red;">删除</a>
                </a-popconfirm></a-menu-item
              >
            </a-menu>
             <a-menu slot="overlay" v-if="record.theDocumentsState == '1'">
              <!-- <a-menu-item><a @click="canaleSubmit(record)">取消提交</a></a-menu-item> -->
              <a-menu-item><a @click="edit(record,'2')">详情</a></a-menu-item>
              <a-menu-item v-if="record.readyFabric=='辅料'||record.readyFabric=='面料'"><a @click="copyForm(record)">复制</a></a-menu-item>
              <a-menu-item ><a @click="pushU8(record)" >推送u8</a></a-menu-item>
              <a-menu-item ><a @click="pushPackLst(record)" >推送装箱单发票</a></a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
      <span style="position: absolute;bottom: 9%;">共勾选{{selectedNumber}}条数</span>
    </a-card>

    <!-- 抽屉 -->
    <addBook-drawer ref="addBookDrawer"  @ok="modalFormOk" @back="getBookList"></addBook-drawer>
    <detailsBook-drawer ref="detailsBookDrawer"  @ok="modalFormOk"></detailsBook-drawer>
    <!-- <editBook-drawer ref="editBookDrawer" :father="cc" @ok="modalFormOk"></editBook-drawer> -->
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import moment from 'moment'

import { downFile ,getAction,deleteAction,postActio} from '@/api/manage'

import addBookDrawer from '@views/book/addBookDrawer.vue'
import detailsBookDrawer from '@views/book/detailsBookDrawer.vue'
import editBookDrawer from '@views/book/editBookDrawer.vue'
import {bookList,bookListId,submitPackingList,deletePackingList,settlement,pushU8,pushPackeList} from '@api/document/book.js'

export default {
  name: 'BookList', // 托书列表
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment, addBookDrawer, detailsBookDrawer, editBookDrawer },
  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />
    return {
      // 表头
      bookListColumns: [
        { title: '托书号', width: 150, dataIndex: 'shippingOrderNumber',  className: 'replacecolor' , ellipsis: true,fixed: 'left'},
        {
          title: '实际船期',
          dataIndex: 'theFinalShippingDate',
           ellipsis: true,
          width: 110,
          // customRender: text => { 有问题 显示当日日期
          //   return moment(text).format('YYYY-MM-DD')
          // },
          className: 'replacecolor'
        },
        { title: '成衣工厂', width: 150, dataIndex: 'garmentFactory', className: 'replacecolor', ellipsis: true, },
        { title: '客户简称', dataIndex: 'clientAbbreviation', width: 120, className: 'replacecolor' , ellipsis: true,},
        {
          title: '分销点',
          dataIndex: 'distributionPoint',
          width: 120,
           ellipsis: true,
          className: 'replacecolor'
        },
        {
          title: '经营单位',
          dataIndex: 'unitInOperation',
          width: 160,
           ellipsis: true,
          className: 'replacecolor'
        },
        { title: '总箱数', dataIndex: 'boxNumber', width: 80, className: 'replacecolor', ellipsis: true, },
        { title: '总毛重', dataIndex: 'totalGrossWeight', width: 80, className: 'replacecolor', ellipsis: true, },
        { title: '总体积', dataIndex: 'totalVolume', width: 80, className: 'replacecolor', ellipsis: true, },
        {
          title: '金额',
          dataIndex: 'money',
          // scopedSlots: { customRender: 'money' },
          width: 100,
           ellipsis: true,
          className: 'replacecolor'
        },
        // {
        //   title: '净价总金额',
        //   dataIndex: 'totalNetPrice',
        //   width: 120,
        //    ellipsis: true,
        //   className: 'replacecolor'
        // },
        { title: '外销发票号码', dataIndex: 'exportInvoiceNo', width: 120, className: 'replacecolor', ellipsis: true, },
        {
          title: '发票推送状态',
          dataIndex: 'timeStuta',
          width: 120,
          scopedSlots: { customRender: 'timeStuta' },
          fixed: 'right',
          className: 'replacecolor'
        },
        {
          title: '状态',
          dataIndex: 'theDocumentsState',
          scopedSlots: { customRender: 'documentStateSlot' },
          width: 95,
           fixed: 'right',
          className: 'replacecolor'
        },
        // { title: '收汇方式', dataIndex: 'exchangeEarningsValue', width: 120, className: 'replacecolor' },
        // {
        //   title: '收货人',
        //   dataIndex: 'consignee',
        //   width: 100,
        //   customRender: t => ellipsis(t),
        //   className: 'replacecolor'
        // },
        // {
        //   title: '提单或承运收据',
        //   dataIndex: 'billOfLadingOrCarriageReceipt',
        //   width: 140,
        //   customRender: t => ellipsis(t),
        //   className: 'replacecolor'
        // },
        // {
        //   title: '抬头人',
        //   dataIndex: 'addressee',
        //   width: 120,
        //   customRender: t => ellipsis(t),
        //   className: 'replacecolor'
        // },
        // { title: '贸易国别', dataIndex: 'tradeCountry', width: 100, className: 'replacecolor' },
        // { title: '运抵国别', dataIndex: 'arriveInCountry', width: 100, className: 'replacecolor' },
        // { title: '出口口岸', dataIndex: 'exportPort', width: 100, className: 'replacecolor' },
        // {
        //   title: '通知人',
        //   dataIndex: 'notifier',
        //   width: 100,
        //   customRender: t => ellipsis(t),
        //   className: 'replacecolor'
        // },
        // { title: 'NOTIFY', dataIndex: 'nottfy', width: 150, className: 'replacecolor' },
        // { title: '目的港', dataIndex: 'destinationPort', width: 100, className: 'replacecolor' },
        // { title: '装运期限', dataIndex: 'latestDateOfShipment', width: 100, className: 'replacecolor' },
        {
          title: '推送状态',
          dataIndex: 'syStuta',
          width: 90,
          scopedSlots: { customRender: 'syStuta' },
          fixed: 'right',
          className: 'replacecolor'
        },
       
        {
          title: '操作',
          dataIndex: 'operation',
          scopedSlots: { customRender: 'operationSlot' },
          width: 220,
          fixed: 'right',
          className: 'replacecolor'
        }
      ],
      bookListData: [],
      shippingOrderDate:[], //单据日期区间
      id: '',
      selectedRowKeys:[],//选中行id
      loadingU8:false,
      loading: false, // 表格加载
      pagination:{
        pageSizeOptions: ["50", "100", "150"],
        showSizeChanger: true,
      },
      selectedNumber:0,//已选择条数
      // 查询条件
      queryParam: {
        pageNo:'',
        pageSize:'50',
        type:'成衣'
      }
    }
  },

  created() {
    this.getDefaultTime()
    // this.getBookList( )
  },
  watch:{
    selectedRowKeys(newVal){
       this.selectedNumber =newVal.length
    }
  },
  methods: {
    moment,
    //获取表格数据
    getBookList(data){
      this.$nextTick(() => {
        // this.queryParam.pageSize = 50
        this.loading = true
        if(data=='await'){this.loading = false}
        bookList(this.queryParam).then(res => {
          this.loading = false
          if (res.success) {
           this.bookListData = res.result.records
           this.selectedRowKeys = []
           this.pagination = {
              total: res.result.total,
              current: res.result.current,
              pageSize: res.result.size
            }
          }else {
             this.$message.error(res.message);
          }
        })
      })
    },
    getDefaultTime(){
    var  date = new Date();
    date.setDate(0);
    var y = date.getFullYear(); //获取年份
    var m = date.getMonth() + 1; //获取月份
    m = m < 10 ? "0" + m : m; //月份补 0
    var lastM = [y, m, '01'].join("-")
    console.log([y, m, '01'].join("-"))
    this.shippingOrderDate[0]= lastM
    this.shippingOrderDate[1]= moment(new Date()).format('YYYY-MM-DD')
    this.queryParam.shippingOrderDateB =  (lastM!==''&&lastM)?(moment( lastM).format('YYYY-MM-DD')):''
    this.queryParam.shippingOrderDateE =  moment(new Date()).format('YYYY-MM-DD')
    // return [y, m, '01'].join("-");
    },
    // 查询按钮
    searchQuery() {
      this.toggleSearchStatus = false
      this.queryParam.pageNo = ''
      if(this.queryParam.type==''||!this.queryParam.type){
        this.$message.error('请选择类型');
      }else{
        this.getBookList()
      }
      // this.getpreBookList() // 渲染渲染预托书
    },
    // 重置
    searchReset() {
      this.shippingOrderDate=[]
      this.queryParam = {
        pageNo:'',
        pageSize:this.pagination.pageSize,
        type:'成衣'
      }
      this.getDefaultTime()
      this.getBookList()
      // this.getpreBookList()
    },
    // 新增
    addBookDrawer() {
      console.log('新增托书')
      this.$refs.addBookDrawer.visible = true
      this.$refs.addBookDrawer.query ='1'
    },

    // -----------------------------------
    // 结汇发票打印
    handleExportXls(record) {
     
     if(record.isAhaa == '国内'){
       if(record.readyFabric=='成衣'){
         var exinvoiceArr = ["-报关资料","-结汇资料"]
       }else{
         var exinvoiceArr = ["-报关资料"]
       }
    }else{//
      var exinvoiceArr = ["国外-报关信息-托书","-结汇资料"]
    }
       
       exinvoiceArr.map(item =>{
      downFile('/syShippingOrder/syShippingOrder/syShippingOrderPrint',{id:record.id,testName:item,isAhaa:record.isAhaa}).then(data => {
        if (!data) {
          this.$message.warning('文件下载失败')
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), item + '.xlsx')
        } else {
          let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', record.shippingOrderNumber+item + '.xlsx')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link) // 下载完成移除元素
          window.URL.revokeObjectURL(url) // 释放掉blob对象
        }
      })
})
    },
    // 上传附件
    accessoryUpload() {},
    // 操作 提交
    submit(record) {
      this.$nextTick(() => {
        submitPackingList({ id: record.id, type: '1' }).then(res => {
          if (res.success) {
          //  record.theDocumentsState = '1'
           this.getBookList()
           this.$message.success('提交成功')
          }else {
             this.$message.error(res.message);
          }
        })
      })
    },
    // //批量提交
    batchSubmit(){
      this.$nextTick(() => {
        submitPackingList({ ids: this.selectedRowKeys, type: '1'}).then(res => {
          if (res.success) {
          //  record.theDocumentsState = '1'
           this.getBookList()
           this.$message.success('提交成功')
           this.selectedRowKeys = []
          }else {
             this.$message.error(res.message);
          }
        })
      })

    },
    //取消提交
    canaleSubmit(record) {
      this.$nextTick(() => {
        submitPackingList({ id: record.id, type: '2' }).then(res => {
          if (res.success) {
           this.$message.success('取消提交成功')
           record.theDocumentsState = '0'
           this.getBookList()
          }else {
             this.$message.error(res.message);
          }
        })
      })
    },
    batchCanaleSubmit(){
      this.$nextTick(() => {
        submitPackingList({ ids: this.selectedRowKeys, type: '2' }).then(res => {
          if (res.success) {
           this.$message.success('取消提交成功')
          //  record.theDocumentsState = '0'
           this.getBookList()
           this.selectedRowKeys = []
          }else {
             this.$message.error(res.message);
          }
        })
      })
    },
    //批量推送U8
    batchPushU8(){
      if(this.selectedRowKeys.length==0){
        this.$message.success('请勾选数据')
      }else{
        this.loadingU8 = true
        getAction('/syShippingOrder/syShippingOrder/expensesU8Batch',{ids:this.selectedRowKeys.join(',')}).then((res) => {
          if (res.success) {
            this.getBookList('await')
          }else{
            this.$message.warning(res.message);
          }
        }).finally(() => {
            this.loadingU8 = false          
        });
      }
    },
    //批量推送装箱单发票 
    batchPushInvoice(){
      if(this.selectedRowKeys.length==0){
        this.$message.success('请勾选数据')
      }else{
        getAction('/syShippingOrder/syShippingOrder/updateTimeStutaBatch',{ids:this.selectedRowKeys.join(',')}).then((res) => {
          if (res.success) {
            this.getBookList('await')
          }else{
            this.$message.warning(res.message);
          }
        })
      }
    },
    //推送U8
    pushU8(record){
      pushU8({ id: record.id}).then(res => {
          if (res.success) {
          //  this.$message.success('推送U8成功')
          //  record.theDocumentsState = '0'
           this.getBookList('await')
          }else {
             this.$message.error(res.message);
          }
        })
    },
    pushPackLst(record){
      pushPackeList({ id: record.id}).then(res => {
          if (res.success) {
          //  this.$message.success('推送装箱单发票成功')
          //  record.theDocumentsState = '0'
           this.getBookList('await')
          }else {
             this.$message.error(res.message);
          }
        })
    },
    // 操作 详情
    details(record) {
      this.$refs.detailsBookDrawer.visible = true
    },
    // 操作 编辑
    edit(record,pattern) {
      this.$nextTick(() => {
        bookListId({id:record.id,type:this.queryParam.type}).then(res => {
          if (res.success) {
            var data =res.result
            if(pattern == '1'){
              this.$refs.addBookDrawer.visible = true
              this.$refs.addBookDrawer.defaultMethod = 'edit'
              this.$refs.addBookDrawer.syStuta = record.syStuta
              if(data.latestDateOfShipment!==''&&data.latestDateOfShipment){
                 data.latestDateOfShipment = (moment(data.latestDateOfShipment)).format('YYYY-MM-DD')
              }
              this.$refs.addBookDrawer.getFreightForwarder(data.syShippingOrderItemList[0].pkOrg)
              this.$refs.addBookDrawer.addBook = data
              this.$refs.addBookDrawer.addBookData = data.syShippingOrderItemList
              this.$refs.addBookDrawer.addBookData.map(item =>{
                item.smallPo = item.smailPo
                item.itemNumber = item.styleNumber
                // item.volume = item.volume
                item.price = item.unitPrice
                item.englishProductName = item.englishName
              })
              if(data.rmbList.length == 0){
                data.rmbList = [{}]
              }
              if(data.usdList.length == 0){
                data.usdList = [{}]
              }
              this.$refs.addBookDrawer.rmbList = data.rmbList
              this.$refs.addBookDrawer.usdList = data.usdList
            }else {
              this.$refs.detailsBookDrawer.visible = true
              if(data.latestDateOfShipment!==''&&data.latestDateOfShipment){
                data.latestDateOfShipment = (moment(data.latestDateOfShipment)).format('YYYY-MM-DD')
              }
              this.$refs.detailsBookDrawer.addBook = data
              this.$refs.detailsBookDrawer.addBookData = data.syShippingOrderItemList
              this.$refs.detailsBookDrawer.rmbList = data.rmbList
              this.$refs.detailsBookDrawer.usdList = data.usdList
              this.$refs.detailsBookDrawer.timeMesage = (data.timeMesage!=='' && data.timeMesage) ? (data.timeMesage.split(";")) :[]
              if(data.syStuta == 0){
                this.$refs.detailsBookDrawer.disabled = false
              }
            }
             
            this.$refs.addBookDrawer.query = '1'
          }else {
             this.$message.error(res.message);
          }
        })
      })
    },

    //辅料 - 复制
    copyForm(record){
      bookListId({id:record.id,type:this.queryParam.type}).then(res => {
          if (res.success) {
            var data =res.result
            this.$refs.addBookDrawer.visible = true
              this.$refs.addBookDrawer.defaultMethod = 'edit'
              if(data.latestDateOfShipment!==''&&data.latestDateOfShipment){
                 data.latestDateOfShipment = (moment(data.latestDateOfShipment)).format('YYYY-MM-DD')
              }
              this.$refs.addBookDrawer.addBook = data
              this.$refs.addBookDrawer.addBook.id = ''
          }
        })
    },
    // 操作 打印
    print(record) {},
    // 操作 删除
    handleDelete(id) {
        this.$nextTick(() => {
          if(this.queryParam.pageNo > 1 && this.bookListData.length === 1){
          this.queryParam.pageNo = this.queryParam.pageNo -1
        }
        this.loading = true
        deletePackingList({id:id}).then(res => {
          this.loading = false
          if (res.success) {
            this.getBookList()
          }else {
             this.$message.error(res.message);
          }
        })
      })
    },
    // 单据日期发生改变时
    orderDataChange(data){
       this.queryParam.shippingOrderDateB = (data.length==2&&data)?(moment( data[0]).format('YYYY-MM-DD')):''
       this.queryParam.shippingOrderDateE = (data.length==2&&data)?(moment( data[1]).format('YYYY-MM-DD')):''
    },

    // // 分页、排序、筛选变化时触发
    handleTableChange(pagination, filters, sorter) {
      // console.log('当前页信息>>>>',pagination)
      this.queryParam.pageNo = pagination.current
      this.queryParam.pageSize = pagination.pageSize
      this.getBookList()
    },
    // 选中行
    onSelectChange(keys) {
      this.selectedRowKeys = keys
    }
    
  },
  computed: {},
  mounted() {}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/overwriter.less';
/deep/ .ant-table-thead > tr > th {
  text-align: center;
  // font-weight: 700;
}

/deep/ .ant-table-tbody {
  text-align: center;
}
/deep/ .ant-table-tbody .ant-table-row td{
    padding-top: 8px;
    padding-bottom: 8px;
}
/deep/.ant-card-body{
padding-top: 10px !important;
padding-bottom: 0px !important;
}
/deep/.table-operator .ant-btn{
  margin: 0 8px 3px 0;
}
/deep/.table-page-search-wrapper .ant-form-inline .ant-form-item{
  margin-bottom: 10px;
}
/deep/.table-page-search-wrapper .table-page-search-submitButtons{
 margin-bottom: 10px;
}
// /deep/ th.replacecolor {
//   background-color: #ccc;
// }
/deep/ .ant-table-fixed-left table,.ant-table-fixed-right table{
  width: min-content;
}
/deep/ thead.ant-table-thead>tr{
      height: 0 !important;
}
/deep/ .ant-table-thead > tr > th, .ant-table-tbody > tr > td{
  padding: 9px 16px
}
</style>
