<template>
  <div class="mod-config">
    <el-form :inline="true" label-position="top" label-width="60px" style="margin-top: 0px;">
      <el-form-item :label="'BU:'">
        <el-select v-model="searchData.buNo" placeholder="请选择"  style="width: 80px">
          <el-option label="全部" value=""></el-option>
        <el-option
          v-for = "i in buList"
          :key = "i.buNo"
          :label = "i.buDesc"
          :value = "i.buNo">
        </el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'发货通知单:'">
        <el-input v-model="searchData.delNo"  style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'CMC Invoice:'">
        <el-input v-model="searchData.cmcInvoice"  style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'通知单状态:'">
        <el-select filterable v-model="searchData.notifyStatus" style="width: 120px">
          <el-option label="全部" value=""></el-option>
          <el-option label="已计划" value="已计划"></el-option>
          <el-option label="已下达" value="已下达"></el-option>
          <el-option label="仓库已确认" value="仓库已确认"></el-option>
          <el-option label="已报关" value="已报关"></el-option>
          <el-option label="订单取消" value="订单取消"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'ReadyDate'" >
        <el-date-picker
          style="width: 120px"
          v-model="searchData.startDate"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="'To'" >
        <el-date-picker
          style="width: 120px"
          v-model="searchData.endDate"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="改单">
        <el-checkbox v-model="searchData.modifyData" true-label="true" false-label="false" @change="searchTable()"></el-checkbox>
      </el-form-item>
      <el-form-item :label="' '" >
        <el-button @click="searchTable()" type="primary" style="margin-left: 2px;margin-top: 0px">{{'查询'}}</el-button>
      </el-form-item>
      <el-form-item :label="' '" >
        <el-button @click="importModel()" type="primary" style="margin-left: 2px;margin-top: 0px">{{'导入'}}</el-button>
        <el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button>
      </el-form-item><br>
      <el-form-item label=" ">
        <el-button @click="exportInvoiceList()" type="primary" style="margin-left: 2px">{{'导出发票'}}</el-button>
      </el-form-item>
      <el-form-item label=" ">
        <el-button @click="exportGoodsList()" type="primary" style="margin-left: 2px">{{'导出出口货物委托书'}}</el-button>
      </el-form-item>
    </el-form>

    <el-table
      @row-click="changeData"
      highlight-current-row
      :height="height"
      :data="dataList"
      ref="mainTable" :cell-style="cellStyle"
      border :row-class-name="tableRowClassName"
      v-loading="dataListLoading"
      style="width: 100%;">
      <el-table-column
        header-align="center"
        align="center"
        width="140"
        fixed="left"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" @click="updateHeaderModelDo(scope.row)">修改</a>
          <a type="text" style="color: green" size="small" v-if="scope.row.notifyStatus==='已计划' && scope.row.notifyStatus!=='订单取消'" @click="xiadaChoose()">下达</a>
          <a type="text" style="color: orange" size="small" v-if="scope.row.notifyStatus==='已下达'&& scope.row.notifyStatus!=='订单取消'" @click="jihuaEcssDel(scope.row)">取消下达</a>
          <a type="text" style="color: red" size="small" v-if="scope.row.notifyStatus!=='订单取消'" @click="cancelDelHeader(scope.row)">废弃</a>
          <a type="text" style="color: red" size="small" v-if="scope.row.notifyStatus==='已计划'&& scope.row.notifyStatus!=='订单取消'" @click="deleteDelHeader(scope.row)">删除</a>
        </template>
      </el-table-column>
      <el-table-column
        v-for="(item,index) in columnList1" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed==''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                             style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[20, 50, 100, 1000]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <el-tabs style="font-size: 12px;min-height: 200px" class="customer-tab" v-model="activeName"   type="border-card" @tab-click="tabClick" >
      <el-tab-pane label="明细" name="detail">
        <el-button v-show="currentRow.notifyStatus!=='订单取消'" @click="openCreateDetailModel()" type="primary" style="margin-left: 2px;margin-top: 0px">{{'新增'}}</el-button>
        <el-button v-show="currentRow.notifyStatus!=='订单取消'" @click="importDetailModel()" type="primary" style="margin-left: 2px;margin-top: 0px">{{'改单导入'}}</el-button>
        <el-table ref="detailTable"
          :height="height"
          :data="dataList2" :cell-style="cellStyleDetail"
          border show-summary :summary-method="getSummaries"
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in columnList2" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <template v-if="item.columnProp === 'ttlAmount' || item.columnProp === 'sumPrice'">
                <span>{{!!scope.row[item.columnProp]?scope.row[item.columnProp].toFixed(2):''}}</span>
              </template>
              <template v-else>
                <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
                <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
              </template>
            </template>
          </el-table-column>
          <el-table-column
            fixed="left"
            header-align="center"
            align="center"
            width="100" v-if="currentRow.notifyStatus!=='订单取消'"
            label="操作">
            <template slot-scope="scope">
              <a v-if="currentRow.notifyStatus!=='订单取消'&& scope.row.qty!==0" type="text" size="small" @click="openUpdateDetailModel(scope.row)">修改</a>
              <a v-if="currentRow.notifyStatus!=='订单取消' && scope.row.qty!==0" style="color: red" type="text" size="small" @click="deleteDelDetail(scope.row)">取消</a>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="装箱明细" name="pallet">
        <packing-detail-tab 
          ref="packingDetailTab"
          :current-row="currentRow" 
          :height="height">
        </packing-detail-tab>
      </el-tab-pane>
      <el-tab-pane label="相关文档" name="codelnotifyDocument">
        <oss-components label="申请单号" style="margin-top: 5px" height="44vh" :columns="ossColumns"
                        :order-ref1="currentRow.site" :order-ref2="currentRow.delNo" :codelnotifyFlag="'1'"
                        :rfq-no="currentRow.delNo">
        </oss-components>
      </el-tab-pane>
    </el-tabs>
    <el-dialog title="编辑发货通知单" :close-on-click-modal="false" v-drag :visible.sync="updateHeaderModelFlag" width="672px">
      <el-form  label-position="top"  style="margin-left: 5px;margin-top: -5px;">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="'BU'" >
              <el-input v-model="updateHeaderModel.buDesc" disabled ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'CMC Invoice'" >
              <el-input v-model="updateHeaderModel.cmcInvoice" disabled ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'发货通知单号'" >
              <el-input v-model="updateHeaderModel.delNo" disabled ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'ReadyDate'" >
              <el-date-picker
                style="width: 145px" :disabled="currentRow.notifyStatus!=='已计划'"
                v-model="updateHeaderModel.readyDate"
                type="date"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="'ShippingMode'" >
              <el-input v-model="updateHeaderModel.shippingMode"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'Destination'" >
              <el-input v-model="updateHeaderModel.destination"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'发货日期'" >
              <el-date-picker
                style="width: 145px"
                v-model="updateHeaderModel.notifyDate"
                disabled
                type="date"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item :label="'Remark'" >
              <el-input v-model="updateHeaderModel.remark"  ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="doUpdateHeader()">保存</el-button>
        <el-button type="primary" @click="updateHeaderModelFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog title="编辑发货通知单明细" :close-on-click-modal="false" v-drag :visible.sync="updateDetailModelFlag" width="750px">
      <el-form  label-position="top"  style="margin-left: 7px;margin-top: -5px;">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="'行号'" >
              <el-input v-model="updateDetailModel.itemNo" style="text-align: right" disabled ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item  :label="'PN'">
              <span slot="label" @click="queryComponentPartModal"><a herf="#">PN</a></span>
              <el-input v-model="updateDetailModel.pn"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'Description'" >
              <el-input v-model="updateDetailModel.partDescription"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'Qty (pcs)'" >
              <el-input v-model="updateDetailModel.qty" type="number"   ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'销售订单号'" >
              <el-input v-model="updateDetailModel.salesOrder"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'客户采购单号'" >
              <el-input v-model="updateDetailModel.customerPO"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'Version'" >
              <el-input v-model="updateDetailModel.version"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'Status'" >
              <el-input v-model="updateDetailModel.status"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'Family'" >
              <el-input v-model="updateDetailModel.family"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'LT (wks)'" >
              <el-input v-model="updateDetailModel.lt" type="number" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'CMC Comment'" >
              <el-input v-model="updateDetailModel.cmcComment"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'内外销方式'" >
              <el-input v-model="updateDetailModel.saleType"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'AWB/ BL#'" >
              <el-input v-model="updateDetailModel.awbBl"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'ShippingNumber'" >
              <el-input v-model="updateDetailModel.shippingNumber"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'Forwarder Info'" >
              <el-input v-model="updateDetailModel.forwarderInfo"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'Currency'" >
              <el-input v-model="updateDetailModel.currency"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'TP'" >
              <el-input v-model="updateDetailModel.tp" type="number" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'TTL Amount'" >
              <el-input v-model="updateDetailModel.ttlAmount" type="number" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'价税合计'" >
              <el-input v-model="updateDetailModel.sumPrice" type="number" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'SO'" >
              <el-input v-model="updateDetailModel.so"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'UPC'" >
              <el-input v-model="updateDetailModel.upc"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'Remark'" >
              <el-input v-model="updateDetailModel.remark"  ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="doUpdateDetail()">保存</el-button>
        <el-button type="primary" @click="updateDetailModelFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog title="沃尔玛订单" :close-on-click-modal="false" v-drag :visible.sync="walMartOrderDialog" width="200px">
      <el-form label-position="top"  style="margin-left: 36px;margin-top: 10px;">
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item :label="''" >
              <el-radio v-model="walMartOrderFlag" label="Y">是</el-radio>
              <el-radio v-model="walMartOrderFlag" label="N">否</el-radio>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="xiadaEcssDel">确定</el-button>
        <el-button type="primary" @click="walMartOrderDialog=false">关闭</el-button>
      </el-footer>
    </el-dialog>
    <!-- 导入 -->
    <del-upload-excel ref="delUploadExcel" @refreshTable="searchTable" v-drag></del-upload-excel>
    <!-- 导入 -->
    <del-detail-upload-excel ref="delDetailUploadExcel" @refreshTable="searchTable" v-drag></del-detail-upload-excel>
    <!--列表的组件-->
    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
    <el-dialog title="物料清单" top="17vh" :close-on-click-modal="false" v-drag :visible.sync="componentPartModelFlag" width="700px">
      <el-form :inline="true" label-position="top" :model="componentPartData">
        <el-form-item :label="'PN'">
          <el-input v-model="componentPartData.sku" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料编码'">
          <el-input v-model="componentPartData.partNo" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料描述'">
          <el-input v-model="componentPartData.partDesc" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="queryComponentPartList">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="250"
        :data="componentPartList"
        @row-dblclick="getComponentRowData"
        border
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in componentPartColumnList" :key="index"
          :sortable="item.columnSortable"
          :prop="item.columnProp"
          :header-align="item.headerAlign"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align"
          :fixed="item.fixed==''?false:item.fixed"
          :min-width="item.columnWidth"
          :label="item.columnLabel">
          <template slot-scope="scope">
            <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页插件 -->
      <el-pagination
        @size-change="sizeChangeHandle3"
        @current-change="currentChangeHandle3"
        :current-page="pageIndex3"
        :page-sizes="[20, 50, 100, 200, 500]"
        :page-size="pageSize3"
        :total="totalPage3"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
      <el-footer style="height:35px;margin-top:10px;text-align:center">
        <el-button type="primary" @click="componentPartModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="导出发票" :close-on-click-modal="false" v-drag :visible.sync="exportInvoiceFlag" width="450px">
      <el-form label-position="top"  style="margin-left: 2px;margin-top: 10px;">
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item :label="''" >
              <template #label>
                <span slot="label" style="" class="big-label">
                  <a href="#" @click="openTemplate('发票')">发票模版</a>
                </span>
              </template>
              <el-input v-model="exportInvoice.templateName" disabled ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item :label="''" >
              <el-checkbox v-model="exportInvoice.hsCodeDesc">品名</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item :label="''" >
              <el-checkbox v-model="exportInvoice.hsCodeFlag">Hs Code</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item :label="''" >
              <el-checkbox v-model="exportInvoice.contractFlag">合同</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item :label="''" >
              <el-checkbox v-model="exportInvoice.goodsLabel">货物明细</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'品名类型'" >
              <el-radio v-model="exportInvoice.hsCodeDescType" label="Y">中文</el-radio>
              <el-radio v-model="exportInvoice.hsCodeDescType" label="N">英文</el-radio>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-show="currentRow.buNo==='01-Label' || currentRow.buNo==='03-RFID'">
            <el-form-item :label="'制造地'" >
              <el-input  v-model="exportInvoice.origin"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'RFID Base Material'" >
              <el-checkbox v-model="exportInvoice.material"></el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'HS Code'" >
              <el-input :disabled="!exportInvoice.material" v-model="exportInvoice.hsCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'Non-reusable plastic packaging'" >
              <el-checkbox v-model="exportInvoice.packaging"></el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'plastic packaging'" >
              <el-input :disabled="!exportInvoice.packaging" v-model="exportInvoice.kgs"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24" style="">
            <el-form-item :label="'备注'" >
              <el-input type="textarea" :rows="3" v-model="exportInvoice.fpremark"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table v-show="currentRow.buNo==='03-RFID'"
                :height="240"
                :data="notifyPartDetailList"
                stripe
                highlight-current-row
                border :row-style="{ height: '30px' }"
                style="width: 100%;margin-top: 60px">
        <el-table-column
          prop="pn"
          header-align="center"
          align="center"
          label="PN">
        </el-table-column>
        <el-table-column
          prop="ehundred"
          header-align="center"
          align="center"
          label="E100">
          <template slot-scope="scope">
            <el-input v-model="scope.row.ehundred" style="width: 100px;"></el-input>
          </template>
        </el-table-column>
        <el-table-column
          prop="lossratio"
          header-align="center"
          align="center"
          label="纯FSC纸重量损耗">
          <template slot-scope="scope">
            <el-input v-model="scope.row.lossratio" style="width: 100px;"></el-input>
          </template>
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="downloadInvoice()">确定</el-button>
        <el-button type="primary" @click="exportInvoiceFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog title="导出出口货物委托书" :close-on-click-modal="false" v-drag :visible.sync="exportGoodsFlag" width="500px">
      <el-form label-position="top"  style="margin-left: 7px;margin-top: 10px;">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item :label="'品名类型'" >
              <el-radio v-model="exportGoods.hsCodeDescType" label="Y">中文</el-radio>
              <el-radio v-model="exportGoods.hsCodeDescType" label="N">英文</el-radio>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'贸易方式'" >
              <el-input v-model="exportGoods.salesMethod"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'币制'" >
              <el-input  v-model="exportGoods.currency"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'货物产地'" >
              <el-input  v-model="exportGoods.madeArea"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'发货港'" >
              <el-input v-model="exportGoods.sendPort"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'唛头'" >
              <el-input v-model="exportGoods.voyage"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'提/送货日期'" >
              <el-input v-model="exportGoods.deliveryGoodsDate"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'船期'" >
              <el-input v-model="exportGoods.shippingDate"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item :label="'发货人'" >
              <el-input type="textarea"
                        :rows="4" v-model="exportGoods.shipper"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-footer style="height:40px;margin-top: 80px;text-align:center">
        <el-button type="primary" @click="downloadExportGoods()">确定</el-button>
        <el-button type="primary" @click="exportGoodsFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog title="模版" @close="closeTemplateDialog" @open="openTemplateDialog" :visible.sync="templateFlag" width="559px" v-drag>
      <el-form inline="inline" label-position="top" :model="templateData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="模版名称">
          <el-input v-model="templateData.name" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" style="padding: 3px 12px" @click="searchTemplateList()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="height + 110"
        :data="templateList"
        stripe
        highlight-current-row
        border
        @row-dblclick="templateRowDblclick"
        style="width: 100%;">
        <el-table-column
          prop="buNo"
          header-align="center"
          align="center"
          label="BuNo">
        </el-table-column>
        <el-table-column
          prop="name"
          header-align="center"
          align="center"
          label="模版名称">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button @click="templateFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>
  </div>
</template>

<script>
  import Chooselist from '@/views/modules/common/Chooselist_eam'
  import delUploadExcel from "./del_upload_excel.vue";
  import delDetailUploadExcel from "./del_detail_upload_excel.vue";
  import PackingDetailTab from "./components/PackingDetailTab.vue";
  import {} from "@/api/sysLanguage.js"
  import excel from "@/utils/excel-util.js";
  import {
    searchEcssCoDelNotifyHeader,
    searchEcssCoDelNotifyDetail,
    updateEcssDelHeader,
    deleteEcssDelHeader,
    cancelEcssDelHeader,
    changeEcssDelStatus,
    updateEcssDelDetail,
    deleteEcssDelDetail,
    searchCoDelPalletData,
    searchCoDelPalletDataNew,
    queryPartListAll,
    searchTemplateList,
    getCustomers,
    getCustomerAdd,
    getNotifyPartDetail
  }from "@/api/ecss/ecss.js"
  import {getBuList}from  '@/api/factory/site.js'
  import ExportUtil from "@/utils/export";
  import OssComponents from '../oss/ossComponents.vue'
  export default {
    name: "null",
    components:{
      OssComponents,
      delUploadExcel,
      delDetailUploadExcel,
      Chooselist,
      PackingDetailTab,
    },
    data() {
      return {
        pageIndex: 1,
        pageSize: 100,
        totalPage: 0,
        height: 200,
        componentPartModelFlag: false,
        componentPartData: {
          site: '',
          buNo: '',
          sku: '',
          partNo: '',
          partDesc: '',
          page: 1,
          limit: 10
        },
        pageIndex3: 1,
        pageSize3: 20,
        totalPage3: 0,
        componentPartList: [],
        componentPartColumnList: [
          {
            columnProp: 'sku',
            headerAlign: "center",
            align: "center",
            columnLabel: 'PN',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            columnProp: 'partNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '物料编码',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            columnProp: 'partDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '物料描述',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: '',
            columnWidth: 300
          },
        ],

        walMartOrderFlag: 'N',
        walMartOrderDialog:false,
        buList:[],
        dataList:[],
        dataList2:[],
        dataListLoading: false,
        searchData: {
          page: 1,
          limit: 100,
          buNo:'',
          delNo:'',
          cmcInvoice:'',
          notifyStatus:'',
          startDate:'',
          endDate:'',
          username:this.$store.state.user.name,
        },
        buttons:{
          search:'查询',
        },
        updateHeaderModelFlag:false,
        updateHeaderModel:{
          site:'',
          buDesc:'',
          cmcInvoice:'',
          delNo:'',
          readyDate:'',
          shippingMode:'',
          destination:'',
          notifyDate:'',
          remark:'',
        },
        updateDetailModelFlag:false,
        updateDetailModel:{
          site:'',
          buNo:'',
          delNo:'',
          itemNo:'',
          partNo:'',
          partDescription:'',
          qty:'',
          salesOrder:'',
          line:'',
          customerPO:'',
          version:'',
          status:'',
          family:'',
          lt:'',
          cmcComment:'',
          saleType:'',
          awbBl:'',
          shippingNumber:'',
          forwarderInfo:'',
          currency:'',
          tp:'',
          ttlAmount:'',
          sumPrice:'',
          so:'',
          upc:'',
          remark:'',
          pn:'',
          addFlag:''
        },
        activeName:'detail',
        columnList1: [
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1BuDesc',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "buDesc",
            headerAlign: "center",
            align: "left",
            columnLabel: "BU",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1CmcInvoice',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "cmcInvoice",
            headerAlign: "center",
            align: "left",
            columnLabel: "CMC Invoice",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1DelNo',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "delNo",
            headerAlign: "center",
            align: "center",
            columnLabel: "发货通知单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 110
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1ReadyDate',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "readyDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "ReadyDate",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1CustomerName',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "customerName",
            headerAlign: "center",
            align: "left",
            columnLabel: "客户名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 220
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1ShippingMode',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "shippingMode",
            headerAlign: "center",
            align: "left",
            columnLabel: "ShippingMode",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1Destination',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "destination",
            headerAlign: "center",
            align: "left",
            columnLabel: "Destination",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1NotifyStatus',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "notifyStatus",
            headerAlign: "center",
            align: "left",
            columnLabel: "通知单状态",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1NotifyStatus',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "modifyLabel",
            headerAlign: "center",
            align: "left",
            columnLabel: "改单",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 50
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1NotifyDate',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "notifyDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "发货日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1ErpDelNo',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "erpDelNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "ERP发货单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1CreateBy',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "createBy",
            headerAlign: "center",
            align: "left",
            columnLabel: "创建人",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1CreateDate',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "createDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "创建时间",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 130
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1UpdateBy',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "updateBy",
            headerAlign: "center",
            align: "left",
            columnLabel: "修改人",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1UpdateDate',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "updateDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "修改时间",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 130
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table1Remark',
            tableId: "801001Table1",
            tableName: "关务系统发货通知单",
            columnProp: "remark",
            headerAlign: "center",
            align: "left",
            columnLabel: "Remark",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 300
          },
        ],
        columnList2: [
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2ItemNo',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "itemNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "行号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2PartNo',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "pn",
            headerAlign: "center",
            align: "left",
            columnLabel: "PN",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2PartDescription',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "partDescription",
            headerAlign: "center",
            align: "left",
            columnLabel: "Description",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 300
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2Qty',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "qty",
            headerAlign: "center",
            align: "right",
            columnLabel: "Qty (pcs)",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2SalesOrder',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "salesOrder",
            headerAlign: "center",
            align: "left",
            columnLabel: "销售订单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2CustomerPO',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "customerPO",
            headerAlign: "center",
            align: "left",
            columnLabel: "客户采购单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2Version',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "version",
            headerAlign: "center",
            align: "left",
            columnLabel: "Version",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2Status',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "status",
            headerAlign: "center",
            align: "left",
            columnLabel: "Status",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2Family',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "family",
            headerAlign: "center",
            align: "left",
            columnLabel: "Family",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2Lt',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "lt",
            headerAlign: "center",
            align: "right",
            columnLabel: "LT (wks)",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2CmcComment',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "cmcComment",
            headerAlign: "center",
            align: "left",
            columnLabel: "CMC Comment",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2SaleType',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "saleType",
            headerAlign: "center",
            align: "left",
            columnLabel: "内外销方式",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2AwbBl',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "awbBl",
            headerAlign: "center",
            align: "left",
            columnLabel: "AWB/ BL#",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2ShippingNumber',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "shippingNumber",
            headerAlign: "center",
            align: "left",
            columnLabel: "ShippingNumber",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2ForwarderInfo',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "forwarderInfo",
            headerAlign: "center",
            align: "left",
            columnLabel: "Forwarder Info",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2Currency',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "currency",
            headerAlign: "center",
            align: "left",
            columnLabel: "Currency",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2Tp',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "tp",
            headerAlign: "center",
            align: "right",
            columnLabel: "TP",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2TtlAmount',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "ttlAmount",
            headerAlign: "center",
            align: "right",
            columnLabel: "TTL Amount",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2SumPrice',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "sumPrice",
            headerAlign: "center",
            align: "right",
            columnLabel: "价税合计",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2So',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "so",
            headerAlign: "center",
            align: "left",
            columnLabel: "SO",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2Upc',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "upc",
            headerAlign: "center",
            align: "left",
            columnLabel: "UPC",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 801001,
          //   serialNumber: '801001Table2ErpDelItemNo',
          //   tableId: "801001Table2",
          //   tableName: "关务系统发货通知单明细",
          //   columnProp: "erpDelItemNo",
          //   headerAlign: "center",
          //   align: "right",
          //   columnLabel: "ERP发货单行号",
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: false,
          //   sortLv: 0,
          //   status: true,
          //   fixed: '',
          //   columnWidth: 60
          // },
          {
            userId: this.$store.state.user.name,
            functionId: 801001,
            serialNumber: '801001Table2Remark',
            tableId: "801001Table2",
            tableName: "关务系统发货通知单明细",
            columnProp: "remark",
            headerAlign: "center",
            align: "left",
            columnLabel: "Remark",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 300
          },
        ],

        ossColumns:[
          {
            userId: this.$store.state.user.name,
            functionId: 103001,
            serialNumber: '103001Table2FileName',
            tableId: '103001Table2',
            tableName: '文件信息表',
            columnProp: 'fileName',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '文件名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 140
          },
          {
            userId: this.$store.state.user.name,
            functionId: 103001,
            serialNumber: '103001Table2FileRemark',
            tableId: '103001Table2',
            tableName: '文件信息表',
            columnProp: 'fileRemark',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 240
          },
          {
            userId: this.$store.state.user.name,
            functionId: 103001,
            serialNumber: '103001Table2CreateDate',
            tableId: '103001Table2',
            tableName: '文件信息表',
            columnProp: 'createDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '上传时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 140
          },
          {
            userId: this.$store.state.user.name,
            functionId: 103001,
            serialNumber: '103001Table2CreatedBy',
            tableId: '103001Table2',
            tableName: '文件信息表',
            columnProp: 'createdBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '上传人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 140
          }
        ],
        currentRow:{},
        // 导出 start
        exportData: [],
        exportName: '发货通知单'+this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["发货通知单"],
        exportFooter: [],
        // 导出 end
        exportInvoiceFlag:false,
        exportInvoice:{
          origin:"made in china",
          templateName:'',
          hsCodeDesc:'',
          contractFlag:'',
          packaging:'',
          kgs:'',
          hsCode:'',
          material:'',
          hsCodeDescType:'',
          goodsLabel:true,
          hsCodeFlag:true,
          overseasShipper:'',
          overseasAddress:'',
          fpremark:'',
        },
        exportGoodsFlag:false,
        exportGoods:{
          salesMethod:'EXW',
          currency: 'USD',
          madeArea: 'Shanghai, China',
          sendPort:'Shanghai, China',
          deliveryGoodsDate:'',
          voyage :'',
          shippingDate:'',
          hsCodeDescType:'Y',
          shipper:'Checkpoint Commercial (Shanghai) Co., Ltd.   保点贸易（上海）有限公司\t\t\t\t\t\t\n' +
            'Room 1411, No. 31, Lane 2419, Hunan Road, Pudong New Area, Shanghai\t\t\t\t\t\t\n' +
            '电话/Tel: (86-21)38112888   传真/Fax: (86-21)38112990\t\t\t\t\t\t\n' +
            '上海市浦东新区沪南路2419弄31号1411室\t\t\t\t\t\t\n'
        },
        notifyPartDetailList:[],
        templateFlag:false,
        templateData:{},
        templateList:[],
        customerData:{},
        customerAddData:{},
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.height = (window.innerHeight - 240)/2;
      })
    },
    methods: {
      // 获取基础数据列表S
      getBaseList(val, type) {
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = ''
          if (val === 507) {
            strVal = this.updateDetailModel.partNo
          }
          this.$refs.baseList.init(val, strVal)
        })
      },

      /* 列表方法的回调 */
      getBaseData(val) {
        if (this.tagNo === 507) {
          this.updateDetailModel.partNo = val.part_no
        }
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.searchTable()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.searchTable()
      },
      searchTable(){
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        searchEcssCoDelNotifyHeader(this.searchData).then(({data}) => {
          //区分请求成功和失败的状况
          if (data && data.code == 0) {
            this.dataList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
            if(this.dataList.length>0){
              this.$refs.mainTable.setCurrentRow(this.dataList[0]);
              this.changeData(this.dataList[0])
              this.dataList.forEach(o => {
                o.modifyLabel = !!o.modifyFlag?'是':'';
              });
            }else {
              this.changeData(null)
            }
          } else {
            this.dataList = [];
          }
        });
      },
      changeData(row){
        this.currentRow = JSON.parse(JSON.stringify(row));
        this.headerData=row;
        this.refreshCurrentTabTable ();
      },
      importModel(){
        this.$nextTick(() => {
          this.$refs.delUploadExcel.init()
        })
      },
      importDetailModel(){
        this.$nextTick(() => {
          this.$refs.delDetailUploadExcel.init(this.currentRow)
        })
      },
      refreshCurrentTabTable(){
        if(this.currentRow===''||this.currentRow===null){
          this.currentRow={site:'',delNo:''}
        }
        if(this.activeName==='detail'){
          searchEcssCoDelNotifyDetail(this.currentRow).then(({data}) => {
            //区分请求成功和失败的状况
            if (data && data.code == 0) {
              this.dataList2 = data.rows

            } else {
              this.dataList2 = [];
            }
          });
        }
        if(this.activeName==='pallet'){
          // 刷新装箱明细组件
          if (this.$refs.packingDetailTab) {
            this.$refs.packingDetailTab.refresh();
          }
        }
      },
      tabClick (tab, event) {
        // 刷新列表数据
        this.refreshCurrentTabTable()
      },
      updateHeaderModelDo(row){
        this.updateHeaderModel=JSON.parse(JSON.stringify(row));
        this.updateHeaderModelFlag=true
      },
      doUpdateHeader(){
        if(this.updateHeaderModel.readyDate==null||this.updateHeaderModel.readyDate==''){
          this.$alert('请选择ReadyDate！', '错误', {
            confirmButtonText: '确定'
          })
          return false
        }
        updateEcssDelHeader(this.updateHeaderModel).then(({data}) => {
          if (data && data.code === 0) {
            this.searchTable()
            this.updateHeaderModelFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      deleteDelHeader(row){
        this.$confirm('确认删除吗？', '提示').then(() => {
          deleteEcssDelHeader(row).then(({data}) => {
            if (data && data.code === 0) {
              this.searchTable()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },
      xiadaChoose(){
        if (this.dataList2.length===0) {
          this.$alert('该发货通知单下没有明细无法下达！', '错误', {
            confirmButtonText: '确定'
          })
          return false
        }
        if (this.currentRow.buNo=='03-RFID') {
          this.walMartOrderDialog=true;
          this.walMartOrderFlag='N';
        } else {
          this.xiadaEcssDel()
        }
      },
      cancelDelHeader(row){
        this.$confirm('确认废弃吗？', '提示').then(() => {
          cancelEcssDelHeader(row).then(({data}) => {
            if (data && data.code === 0) {
              this.searchTable()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },
      tableRowClassName({row}) {
        if (row.notifyStatus==='订单取消') {
          return 'warning-row';
        }
      },
      cellStyle({row, column }) {
        if (column.property === 'modifyLabel' && row.modifyLabel==='是') {  // 根据列属性判断
          return { color: '#ff5d03' };
        }
        return {};
      },
      cellStyleDetail({row, column }) {
        if ((column.property === 'pn' || column.property === 'qty') && row.modifyFlag===true) {  // 根据列属性判断
          return { color: '#ff5d03' };
        }
        return {};
      },
      xiadaEcssDel(){
        let inData={
          site:this.currentRow.site,
          buNo:this.currentRow.buNo,
          createBy:this.currentRow.createBy,
          delNo:this.currentRow.delNo,
          cmcInvoice:this.currentRow.cmcInvoice,
          notifyStatus:'已下达',
          walMartOrderFlag:this.walMartOrderFlag
        }
        this.$confirm('确认下达吗？', '提示').then(() => {
          changeEcssDelStatus(inData).then(({data}) => {
            if (data && data.code === 0) {
              this.searchTable()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
        this.walMartOrderDialog=false;
      },
      jihuaEcssDel(row){
        let inData={
          site:row.site,
          delNo:row.delNo,
          notifyStatus:'已计划'
        }
        this.$confirm('确认取消下达吗？', '提示').then(() => {
          changeEcssDelStatus(inData).then(({data}) => {
            if (data && data.code === 0) {
              this.searchTable()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },
      // 每页数
      sizeChangeHandle3 (val) {
        this.pageSize3 = val
        this.pageIndex3 = 1
        this.queryComponentPartModal()
      },

      // 当前页
      currentChangeHandle3 (val) {
        this.pageIndex3 = val
        this.queryComponentPartModal()
      },
      // 子物料列表
      queryComponentPartModal () {
        this.componentPartData.limit = this.pageSize3
        this.componentPartData.page = this.pageIndex3
        this.componentPartData.site = this.currentRow.site
        this.componentPartData.buNo = this.currentRow.buNo
        // 查询所有物料
        queryPartListAll(this.componentPartData).then(({data}) => {
          if (data && data.code === 0) {
            this.componentPartList = data.page.list
            this.pageIndex3 = data.page.currPage
            this.pageSize3 = data.page.pageSize
            this.totalPage3 = data.page.totalCount
            this.componentPartModelFlag = true
          } else {
            this.componentPartList = []
          }
        })
      },
      // 物料查询列表
      queryComponentPartList () {
        this.componentPartData.limit = this.pageSize3
        this.componentPartData.page = this.pageIndex3
        // 查询所有物料
        queryPartListAll(this.componentPartData).then(({data}) => {
          if (data && data.code === 0) {
            this.componentPartList = data.page.list
            this.pageIndex3 = data.page.currPage
            this.pageSize3 = data.page.pageSize
            this.totalPage3 = data.page.totalCount
          } else {
            this.componentPartList = []
          }
        })
      },
      // 双击选中子物料
      getComponentRowData (row) {
        this.updateDetailModel.partDescription = row.partDesc
        this.updateDetailModel.pn = row.sku
        this.updateDetailModel.partNo = row.partNo
        this.componentPartModelFlag = false
      },

      doUpdateDetail(){
        if(this.updateDetailModel.partNo==null||this.updateDetailModel.partNo==''){
          this.$alert('请输入PN！', '错误', {
            confirmButtonText: '确定'
          })
          return false
        }
        if(this.updateDetailModel.qty==null||this.updateDetailModel.qty==''){
          this.$alert('请输入QTY！', '错误', {
            confirmButtonText: '确定'
          })
          return false
        }
        if(this.updateDetailModel.qty<=0){
          this.$alert('QTY必须大于0！', '错误', {
            confirmButtonText: '确定'
          })
          return false
        }
        updateEcssDelDetail(this.updateDetailModel).then(({data}) => {
          if (data && data.code === 0) {
            this.refreshCurrentTabTable()
            this.updateDetailModelFlag=false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      openCreateDetailModel(){
        this.updateDetailModel.site=this.currentRow.site;
        this.updateDetailModel.buNo=this.currentRow.buNo;
        this.updateDetailModel.delNo=this.currentRow.delNo;
        this.updateDetailModel.partNo=''
        this.updateDetailModel.qty=''
        this.updateDetailModel.partDescription=''
        this.updateDetailModel.itemNo=''
        this.updateDetailModel.salesOrder=''
        this.updateDetailModel.line=''
        this.updateDetailModel.customerPO=''
        this.updateDetailModel.version=''
        this.updateDetailModel.status=''
        this.updateDetailModel.family=''
        this.updateDetailModel.lt=''
        this.updateDetailModel.cmcComment=''
        this.updateDetailModel.saleType=''
        this.updateDetailModel.awbBl=''
        this.updateDetailModel.shippingNumber=''
        this.updateDetailModel.forwarderInfo=''
        this.updateDetailModel.currency=''
        this.updateDetailModel.tp=''
        this.updateDetailModel.ttlAmount=''
        this.updateDetailModel.sumPrice=''
        this.updateDetailModel.so=''
        this.updateDetailModel.upc=''
        this.updateDetailModel.remark=''
        this.updateDetailModel.pn=''
        this.updateDetailModel.addFlag=0
        this.updateDetailModelFlag=true
      },
      openUpdateDetailModel(row){
        this.updateDetailModel=JSON.parse(JSON.stringify(row));
        this.updateDetailModel.addFlag=1
        this.updateDetailModelFlag=true
      },
      deleteDelDetail(row){
        this.$confirm('确认取消此明细？', '提示').then(() => {
          deleteEcssDelDetail(row).then(({data}) => {
            if (data && data.code === 0) {
              this.refreshCurrentTabTable()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },
      getBu () {
        let tempData = {
          username: this.$store.state.user.name,
        }
        getBuList(tempData).then(({data}) => {
          if (data.code === 0) {
            this.buList = data.row2
            if (this.buList.length===1) {
              this.searchData.buNo = this.buList[0].buNo;
            }
          }
        })
      },
      //导出excel
      async createExportData() {
        this.searchData.limit = -1
        this.searchData.page = 1
        await searchEcssCoDelNotifyHeader(this.searchData).then(({data}) => {
          this.exportList= data.page.list;
        })

        return this.exportList;
      },
      startDownload() {
        //  this.exportData = this.dataList

      },
      finishDownload() {
      },
      fields() {
        let json = "{"
        this.columnList1.forEach((item, index) => {
          if (index == this.columnList1.length - 1) {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
          } else {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
          }
        })
        json += "}"
        let s = eval("(" + json + ")")

        return s
      },
      async exportExcel() {
        this.searchData.limit = -1
        this.searchData.page = 1
        excel.exportTable({
          url: "/ecss/coDel/searchEcssCoDelNotifyHeader",
          columnMapping:  this.columnList1,//可以直接用table，不需要的列就剔除
          mergeSetting: [],//需要合并的列
          params: this.searchData,
          fileName: this.exportName+".xlsx",
          rowFetcher: res => res.data,
          columnFormatter: [],
          dropColumns: [],//需要剔除的列，例如dropColumns: ["netWeight"]，即剔除净重列
        });
      },
      getSummaries(param) {
        const { columns } = param;
        const sums = [];
        columns.forEach((column, index) => {
          if (index === 0) {
            sums[index] = '合计';
            return;
          }
          let sumDataList = this.dataList2.filter(item => item.qty>0);
          const values = sumDataList.map(item => Number(item[column.property]));
          if (!values.every(value => isNaN(value))) {
            switch(column.property) {
              case 'qty':
                sums[index] = `${values.reduce((a, b) => a + b, 0)}`;
                break;
              case 'ttlAmount':
                sums[index] = `${values.reduce((a, b) => a + b, 0).toFixed(2)}`;
                break;
              case 'sumPrice':
                sums[index] = `${values.reduce((a, b) => a + b, 0).toFixed(2)}`;
                break;
              default:
                sums[index] = '';
            }
          } else {
            sums[index] = '';
          }
        });
        this.$nextTick(() => this.$refs.detailTable.doLayout());// 强制刷新布局,  否则会被表格覆盖
        return sums;
      },

      exportInvoiceList() {
        if (!this.currentRow || !this.currentRow.buNo) {
          this.$message.warning('请选择发货通知单！')
          return
        }
        if (this.currentRow.notifyStatus==='订单取消') {
          this.$message.warning('该发货通知单已取消！')
          return
        }
        this.exportInvoice.templateName=''
        this.exportInvoice.hsCodeDesc=this.currentRow.hsCodeDesc
        this.exportInvoice.contractFlag=this.currentRow.contractFlag
        this.exportInvoice.packaging=this.currentRow.packaging
        this.exportInvoice.kgs=this.currentRow.kgs
        this.exportInvoice.hsCode=this.currentRow.hsCode
        this.exportInvoice.material=this.currentRow.material
        this.exportInvoice.hsCodeDescType=this.currentRow.hsCodeDescType
        this.exportInvoice.goodsLabel=this.currentRow.goodsLabel
        this.exportInvoice.origin="made in china"
        //this.exportInvoice = this.currentRow
        if (!this.exportInvoice.origin) {
          this.exportInvoice.origin = 'made in china'
        }
        if (!this.exportInvoice.itemNo) {
          this.exportInvoice.itemNo = 'Y'
        }
        this.notifyPartDetailList = [];
        this.customerData=''
        this.customerAddData = ''
        this.exportInvoiceFlag = true
        if (this.currentRow.buNo==='03-RFID') {
          getNotifyPartDetail(this.currentRow).then(({data}) => {
            //区分请求成功和失败的状况
            if (data && data.code == 0) {
              this.notifyPartDetailList = data.rows
              this.notifyPartDetailList.forEach(o => {
                if (!o.lossratio) {
                  o.lossratio = '1.2';
                }
              });
            } else {
              this.notifyPartDetailList = [];
            }
          });
        }
        this.templateData.type='发票'
        this.searchTemplateOne();
      },

      searchTemplateOne() {
        this.templateData.buNo = this.currentRow.buNo
        this.templateData.customName = this.currentRow.customerName
        this.templateData.shippingMode = this.currentRow.shippingMode
        searchTemplateList(this.templateData).then(({data}) => {
          if (data && data.code === 0){
            if (data.rows && data.rows.length > 0) {
              this.templateRowDblclick(data.rows[0]);
            }
          }
        })
      },

      exportGoodsList() {
        if (!this.currentRow || !this.currentRow.buNo) {
          this.$message.warning('请选择发货通知单！')
          return
        }
        this.exportGoods.hsCodeDescType = 'N'
        this.exportGoods.salesMethod = 'EXW'
        this.exportGoods.currency = 'USD'
        this.exportGoods.madeArea = 'Shanghai, China'
        this.exportGoods.sendPort = 'Shanghai, China'
        this.exportGoods.deliveryGoodsDate = ''
        this.exportGoods.voyage = this.currentRow.buNo==='01-Label' || this.currentRow.buNo==='03-RFID'?this.currentRow.cmcInvoice:''
        this.exportGoods.shippingDate = ''
        this.exportGoodsFlag = true
      },
      // 导出
      downloadInvoice() {
        if (!this.currentRow || !this.currentRow.buNo) {
          this.$message.warning('请选择报关单！')
          return
        }
        let exportParam=this.exportInvoice
        exportParam.declarationNo = this.currentRow.declarationNo
        exportParam.site = this.currentRow.site
        exportParam.delNo = this.currentRow.delNo
        exportParam.notifyPartDetailList = this.notifyPartDetailList
        ExportUtil.export(
          "/ecss/coDel/downloadInvoice",
          exportParam, this.currentRow.cmcInvoice+"发票.xlsx"
        );
        this.exportInvoiceFlag=false
        this.searchTable()
      },

      downloadExportGoods() {
        if (!this.currentRow || !this.currentRow.buNo) {
          this.$message.warning('请选择报关单！')
          return
        }
        let exportParam=this.exportGoods
        exportParam.declarationNo = this.currentRow.declarationNo
        exportParam.site = this.currentRow.site
        exportParam.delNo = this.currentRow.delNo
        ExportUtil.export(
          "/ecss/coDel/downloadExportGoods",
          exportParam, this.currentRow.cmcInvoice+"出口货物委托书.xlsx"
        );
        this.exportGoodsFlag = false;
        this.searchTable()
      },

      openTemplate (type) {
        this.templateData.type=type;
        this.templateFlag = true;
      },

      openTemplateDialog () {
        //请求
        this.searchTemplateList();
      },
      closeTemplateDialog () {
        this.templateList = []
        this.templateFlag = false
      },
      searchTemplateList () {
        this.templateData.buNo = this.currentRow.buNo
        this.templateData.customName = ''
        searchTemplateList(this.templateData).then(({data}) => {
          if (data && data.code === 0){
            this.templateList = data.rows;
          }
        })
      },
      templateRowDblclick (row) {
        if (this.templateData.type=='发票') {
          this.exportInvoice.templateName=row.name
          this.exportInvoice.hsCodeDesc=row.hsCodeDesc
          this.exportInvoice.contractFlag=row.contractFlag
          this.exportInvoice.origin=this.currentRow.origin?this.currentRow.origin:row.origin
          this.exportInvoice.packaging=this.currentRow.packaging?this.currentRow.packaging:row.packaging
          this.exportInvoice.kgs=this.currentRow.kgs?this.currentRow.kgs:row.kgs
          this.exportInvoice.hsCode=this.currentRow.hsCode?this.currentRow.hsCode:row.hsCode
          this.exportInvoice.material=this.currentRow.material?this.currentRow.material:row.material
          this.exportInvoice.hsCodeDescType=this.currentRow.hsCodeDescType?this.currentRow.hsCodeDescType:row.hsCodeDescType
          this.exportInvoice.goodsLabel=this.currentRow.goodsLabel?this.currentRow.goodsLabel:row.goodsLabel
          this.exportInvoice.fpremark=row.remark
        } else if (this.templateData.type=='出口货物委托书'){
          this.exportGoods.salesMethod = row.salesMethod
          this.exportGoods.currency = row.currency
          this.exportGoods.madeArea = row.madeArea
          this.exportGoods.sendPort = row.sendPort
          this.exportGoods.deliveryGoodsDate = row.deliveryGoodsDate
          this.exportGoods.voyage = this.currentRow.buNo==='01-Label' || this.currentRow.buNo==='03-RFID'?this.currentRow.cmcInvoice:row.voyage
          this.exportGoods.shippingDate = row.shippingDate;
          this.exportGoods.shipper=row.shipper
          this.exportGoods.remark=row.remark
        }
        if (this.templateData.type!=='出口货物委托书') {
          this.notifyPartDetailList.forEach(o => {
            // 开启fsc损耗则给默认值
            if (o.lossratio) {
              if (row.fscWeight) {
                o.lossratio = o.lossratio;
              } else {
                o.lossratio = '';
              }
            } else {
              if (row.fscWeight) {
                o.lossratio = '1.2';
              } else {
                o.lossratio = '';
              }
            }
          });
        }
        this.templateFlag = false
      },
    },
    activated() {
      this.searchTable()
    },
    created() {
        this.getBu ()
    }
  }
</script>

<style lang="scss" >
.warning-row td{
  color: darkred !important;
}
.el-table .cell {
  line-height: 24px;
  font-size: 12px;
  height: 24px;
}
</style>
