<template>
  <div class="mod-config">
    <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
      <el-form-item :label="'BU:'">
        <el-select v-model="searchData.buNo" placeholder="请选择"  >
          <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-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-button @click="searchTable()" type="primary" style="margin-left: 2px;margin-top: 0px">{{'查询'}}</el-button>
        <el-button @click="importModel()" type="primary" style="margin-left: 2px;margin-top: 0px">{{'导入'}}</el-button>
        <download-excel
          :fields="fields()"
          :data="exportData"
          type="xls"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :fetch="createExportData"
          :before-generate="startDownload"
          :before-finish="finishDownload"
          worksheet="导出信息"
          class="el-button el-button--primary el-button--medium">
          {{ '导出' }}
        </download-excel>
      </el-form-item>
    </el-form>

    <el-table
      @row-click="changeData"
      highlight-current-row
      :height="height"
      :data="dataList"
      ref="mainTable"
      border
      v-loading="dataListLoading"
      style="width: 100%;">
      <el-table-column
        header-align="center"
        align="center"
        width="150"
        fixed="left"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" v-if="scope.row.notifyStatus==='已计划'" @click="updateHeaderModelDo(scope.row)">修改</a>
          <a type="text" size="small" v-if="scope.row.notifyStatus==='已计划'" @click="xiadaEcssDel(scope.row)">下达</a>
          <a type="text" size="small" v-if="scope.row.notifyStatus==='已下达'" @click="jihuaEcssDel(scope.row)">取消下达</a>
          <a type="text" size="small" v-if="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-table
          :height="height"
          :data="dataList2"
          border
          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">
              <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-column
            fixed="left"
            header-align="center"
            align="center"
            width="100"
            label="操作">
            <template slot-scope="scope">
              <a  v-if="currentRow.notifyStatus==='已计划'" type="text" size="small" @click="openUpdateDetailModel(scope.row)">修改</a>
              <a v-if="currentRow.notifyStatus==='已计划'" type="text" size="small" @click="deleteDelDetail(scope.row)">删除</a>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>

    </el-tabs>
    <el-dialog title="编辑发货通知单" :close-on-click-modal="false" v-drag :visible.sync="updateHeaderModelFlag" 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="'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"
                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="6">
            <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'" >
              <el-input v-model="updateDetailModel.partNo"  ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <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-row>
        <el-row :gutter="20">
          <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-row>
        <el-row :gutter="20">
          <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-row>
        <el-row :gutter="20">
          <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-row>
        <el-row :gutter="20">
          <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-row>
        <el-row :gutter="20">
          <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="18">
            <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>

    <!-- 导入 -->
    <del-upload-excel ref="delUploadExcel" @refreshTable="searchTable" v-drag></del-upload-excel>
  </div>
</template>

<script>
  import delUploadExcel from "./del_upload_excel.vue";
  import {} from "@/api/sysLanguage.js"
  import {
    searchEcssCoDelNotifyHeader,
    searchEcssCoDelNotifyDetail,
    updateEcssDelHeader,
    deleteEcssDelHeader,
    changeEcssDelStatus,
    updateEcssDelDetail,
    deleteEcssDelDetail,
  }from "@/api/ecss/ecss.js"
  import {getAllBuList}from  '@/api/factory/site.js'
  export default {
    name: "null",
    components:{
      delUploadExcel
    },
    data() {
      return {
        pageIndex: 1,
        pageSize: 100,
        totalPage: 0,
        height: 200,
        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:'',
          delNo:'',
          itemNo:'',
          partNo:'',
          partDescription:'',
          qty:'',
          salesOrder:'',
          line:'',
          customerPO:'',
          version:'',
          status:'',
          family:'',
          lt:'',
          cmcComment:'',
          saleType:'',
          awbBl:'',
          shippingNumber:'',
          forwarderInfo:'',
          currency:'',
          tp:'',
          ttlAmount:'',
          sumPrice:'',
          so:'',
          upc:'',
          remark:'',
        },
        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: 80
          },
          {
            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: 120
          },
          {
            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: '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: "partNo",
            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: 100
          },
          {
            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
          },
        ],
        currentRow:{},
        // 导出 start
        exportData: [],
        exportName: '发货通知单'+this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["发货通知单"],
        exportFooter: [],
        // 导出 end
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.height = (window.innerHeight - 240)/2;
      })
    },
    methods: {
      // 每页数
      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])
            }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()
        })
      },
      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 = [];
            }
          });
        }
      },
      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: '确定'
              })
            }
          })
        })
      },
      xiadaEcssDel(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: '确定'
              })
            }
          })
        })
      },
      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: '确定'
              })
            }
          })
        })
      },
      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: '确定'
            })
          }
        })
      },
      openUpdateDetailModel(row){
        this.updateDetailModel=JSON.parse(JSON.stringify(row));
        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,
        }
        getAllBuList(tempData).then(({data}) => {
          if (data.code === 0) {
            this.buList = data.rows
          }
        })
      },
      //导出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
      },
    },
    created() {
        this.getBu ()
    }
  }
</script>

<style scoped>

</style>
