<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="申请编号" prop="fCtrlcorpid">
        <el-input
          :disabled="doNot"
          v-model="queryParams.fCtrlcorpid"
          placeholder="请输入货权方"
          clearable
          size="small"
          style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="fCorpid">
        <el-input
          :disabled="doNot"
          v-model="queryParams.fCorpid"
          filterable
          remote
          clearable
          size="small"
          style="width: 200px"
          placeholder="请输入结算单位"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="开票单位" prop="fAccbilldate">
        <el-date-picker
          clearable
          :disabled="doNot"
          size="small"
          style="width: 200px"
          v-model="queryParams.fAccbilldate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择账单日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="申请人" prop="fBillno">
        <el-input
          :disabled="doNot"
          v-model="queryParams.fBillno"
          placeholder="请输入系统编号"
          clearable
          style="width: 200px"
          size="small"
        />
      </el-form-item>
      <el-form-item label="金额合计" prop="chargingMethod">
        <el-input
          :disabled="doNot"
          v-model="queryParams.chargingMethod"
          placeholder="请选择收费方式"
          clearable
          style="width: 200px"
          size="small"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="申请日期" prop="bank">
        <el-input
          :disabled="doNot"
          v-model="queryParams.bank"
          placeholder="请输入收款银行"
          clearable
          size="small"
          style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="税率" prop="invoiceNo">
        <el-input
          :disabled="doNot"
          v-model="queryParams.invoiceNo"
          placeholder="请输入发票号"
          clearable
          size="small"
          style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="备注" prop="fRemarks">
        <el-input
          :disabled="doNot"
          v-model="queryParams.fRemarks"
          placeholder="请输入备注"
          clearable
          size="small"
          style="width: 200px"
        />
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          @click=""
          size="small"
          :disabled="doNot"
        >请核</el-button
        >
      </el-col>
      <div class="tabSetting">
        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
        <div style="margin: 0 12px">
          <el-button
            icon="el-icon-setting"
            size="mini"
            circle
            @click="feeInfo ? showSetting = !showSetting : showSetting2 = !showSetting2"
          ></el-button>
        </div>
      </div>
    </el-row>
    <el-dialog
      title="自定义列显示"
      :visible.sync="feeInfo ? showSetting :showSetting2"
      width="700px"
      v-dialogDrag
    >
      <template slot="title">
        <div class="avue-crud__dialog__header">
          <span class="el-dialog__title">
            <span
              style="
                display: inline-block;
                width: 3px;
                height: 20px;
                margin-right: 5px;
                float: left;
                margin-top: 2px;
              "
            ></span>
          </span>
        </div>
      </template>
      <div>配置排序列数据（拖动调整顺序）</div>
      <div style="margin-left: 17px">
        <el-checkbox
          v-model="feeInfo ? allCheck : allCheck2"
          label="全选"
          @change="feeInfo ? allChecked : allChecked2"
        ></el-checkbox>
      </div>
      <div style="padding: 4px; display: flex; justify-content: center">
        <draggable
          v-model="feeInfo ? setRowList : setRowList2"
          group="site"
          animation="300"
          @start="onStart"
          @end="onEnd"
          handle=".indraggable"
        >
          <transition-group>
            <div
              v-for="item in feeInfo ? setRowList : setRowList2"
              :key="item.surface"
              class="listStyle"
            >
              <div style="width: 500px" class="indraggable">
                <div class="progress" :style="{ width: item.width + 'px' }">
                  <el-checkbox
                    :label="item.name"
                    v-model="item.checked"
                    :true-label="0"
                    :false-label="1"
                  >{{ item.name }}
                  </el-checkbox>
                </div>
              </div>
              <el-input-number
                v-model.number="item.width"
                controls-position="right"
                :min="1"
                :max="500"
                size="mini"
              ></el-input-number>
            </div>
          </transition-group>
        </draggable>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="feeInfo ? showSetting = false : showSetting2 = false">取 消</el-button>
        <el-button @click="delRow" type="danger">重 置</el-button>
        <el-button type="primary" @click="feeInfo ? save() : save2()">确 定</el-button>
      </span>
    </el-dialog>

    <el-menu
      :default-active="activeIndex"
      class="el-menu-demo"
      mode="horizontal"
      @select="handleSelect"
      text-color="#000"
      active-text-color="#ffd04b"
      style="display: flex;"
    >
      <div style="display: flex;">
        <el-menu-item index="1">费用信息</el-menu-item>
        <el-menu-item index="2">发票信息</el-menu-item>
      </div>
    </el-menu>
    <div style="margin:10px">
      <el-button
        type="success"
        size="small"
        @click="addList"
        v-if="invoiceInfo"
      >新行</el-button
      >
      <el-button
        type="success"
        size="small"
        @click="openSearch"
        v-if="feeInfo"
        :disabled="doNot"
      >检索</el-button
      >
    </div>
    <el-table
      v-if="feeInfo"
      v-loading="loading"
      :data="feeList"
      @selection-change="handleSelectionChange_s"
    >
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="序号" type="index" align="center" fixed/>
      <el-table-column
        v-for="(item, index) in getRowList"
        :key="index"
        :label="item.name"
        :width="item.width"
        :prop="item.label"
        align="center"
        :show-overflow-tooltip="true"
        sortable
        :fixed="item.fixed"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click.native.prevent="deleteRow(scope.$index, invoiceList)"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-table
      v-if="invoiceInfo"
      v-loading="loading"
      :data="invoiceList"
      @selection-change="handleSelectionChange_s"
    >
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="序号" type="index" align="center" />
      <el-table-column
        v-for="(item, index) in getRowList2"
        :key="index"
        :label="item.name"
        :width="item.width"
        :prop="item.label"
        align="center"
        :show-overflow-tooltip="true"
        sortable
        :fixed="item.fixed"
      >
        <template slot-scope="scope">
          <el-select v-model="scope.row.fFeeName" v-if="item.label == 'fFeeName'">
              <el-option
                v-for="(dict, index) in fDNameOptions"
                :key="index.fId"
                :label="dict.fName"
                :value="dict.fId"
              ></el-option>
          </el-select>
          <el-input v-model="scope.row.fModel" v-if="item.label == 'fModel'"/>
          <el-input v-model="scope.row.fSbuName" v-if="item.label == 'fSbuName'"/>
          <el-input v-model="scope.row.fNumber" v-if="item.label == 'fNumber'"/>
          <el-input v-model="scope.row.fUnitprice" v-if="item.label == 'fUnitprice'"/>
          <el-input v-model="scope.row.fMoney" v-if="item.label == 'fMoney'"/>
          <el-input v-model="scope.row.fTaxrate" v-if="item.label == 'fTaxrate'"/>
          <el-input v-model="scope.row.fTax" v-if="item.label == 'fTax'"/>
          <el-input v-model="scope.row.fAmount" v-if="item.label == 'fAmount'"/>
          <el-select v-model="scope.row.fStatus" v-if="item.label == 'fStatus'">
            <el-option label="是" value="0"/>
            <el-option label="否" value="1"/>
          </el-select>
          <el-input v-model="scope.row.remarks" v-if="item.label == 'remarks'"/>
          <el-input v-model="scope.row.createBy" v-if="item.label == 'createBy'"/>
          <el-input v-model="scope.row.createTime" v-if="item.label == 'createTime'"/>
          <el-input v-model="scope.row.updateBy" v-if="item.label ==  'updateBy' && scope.row.fStatus == '0'"/>
          <el-input v-model="scope.row.updateTime" v-if="item.label == 'updateTime' && scope.row.fStatus == '0'"/>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click.native.prevent="deleteRow(scope.$index, invoiceList)"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div slot="footer" class="dialog-footer" style="margin:20px;float: right">

      <el-button type="primary" :disabled="doNot" @click="submit">保 存</el-button>
    </div>
    <el-dialog
      v-dialogDrag
      :fullscreen="dialogFull"
      :close-on-click-modal="false"
      width="70%"
      :visible.sync="innerVisible"
      title="导入数据"
      append-to-body
    >
      <el-form
        ref="form"
        :model="queryParameter"
        label-width="80px"
        style="display: flex; flex-wrap: wrap"
      >
        <el-form-item label="客户名称" prop="fCorpid">
          <el-select
            v-model="queryParameter.fCorpid"
            filterable
            remote
            style="width: 200px"
            placeholder="客户名称"
          >
            <el-option
              v-for="item in nameOptions"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="提单号" prop="fMblno">
          <el-input
            v-model="queryParameter.fMblno"
            filterable
            remote
            clearable
            size="small"
            style="width: 200px"
            placeholder="请输入结算单位"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="审核日期" prop="timeExamine">
          <el-date-picker
            v-model="queryParameter.timeExamine"
            type="daterange"
            range-separator="至"
            @change="timeMethods"
            value-format="yyyy-MM-dd"
            style="width: 250px"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="业务类型" prop="fBusinessType">
          <template>
            <el-select
              v-model="queryParameter.fBusinessType"
              filterable
              remote
              size="small"
              style="width: 200px"
              placeholder="请选择业务类型"
              multiple
            >
              <el-option
                v-for="dict in businessTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
          </template>
        </el-form-item>
        <el-form-item label="船名" prop="fVslid">
          <el-select
            filterable
            v-model="queryParameter.fVslid"
            size="small"
            style="width: 200px"
            placeholder="请选择仓储业务"
          >
            <el-option
              v-for="item in vesselOptions"
              :key="item.fId"
              :label="item.fName"
              :value="item.fId"/>
          </el-select>
        </el-form-item>
        <el-form-item label="航次" prop="fVoyid">
          <el-select
            v-model="queryParameter.fVoyid"
            filterable
            remote
            size="small"
            style="width: 200px"
          >
            <el-option
              v-for="item in voyageOptions"
              :key="item.fId"
              :label="item.fNo"
              :value="item.fId"/>
          </el-select>
        </el-form-item>
        <el-form-item label="收/付" prop="fDc">
          <el-select
            v-model="queryParameter.fDc"
            filterable
            remote
            size="small"
            style="width: 200px">
            <el-option label="收" value="D"/>
<!--            <el-option label="付" value="C"/>-->
          </el-select>
        </el-form-item>
        <el-form-item label="费用名称" label-width="85px" prop="fFeeid">
          <el-select
            v-model="queryParameter.fFeeid"
            filterable
            remote
            clearable
            size="small"
            style="width: 200px">
            <el-option
              v-for="(dict, index) in fDNameOptions"
              :key="index.fId"
              :label="dict.fName"
              :value="dict.fId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="业务日期" prop="createTimeList">
          <el-date-picker
            v-model="queryParameter.createTimeList"
            type="daterange"
            range-separator="至"
            style="width: 250px"
            value-format="yyyy-MM-dd"
            @change="changeTime"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>

        <el-form-item>
          <el-button
            type="cyan"
            icon="el-icon-search"
            size="mini"
            @click="getataDList"
          >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click=""
          >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        v-loading="loading"
        :data="chargeList_s"
        ref="chargeList"
        show-summary
        @selection-change="handleSelectionChange_s"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="序号" type="index" width="55" align="center"/>
        <el-table-column label="货权方" align="center" prop="fName" />
        <el-table-column label="提单号" align="center" prop="fMblno" />
<!--        <el-table-column label="品名" align="center" prop="fProductName" />-->
        <el-table-column label="业务日期" align="center">
          <template slot-scope="scope" v-if="scope.row.createTime">
            <span>{{ scope.row.createTime.slice(0, 10) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="业务类型" align="center" prop="businessName">
<!--          <template slot-scope="scope">-->
<!--            <span v-if="scope.row.fBilltype == 'SJRK'">入库</span>-->
<!--            <span v-else-if="scope.row.fBilltype == 'SJCK'">出库</span>-->
<!--            <span v-else>{{ scope.row.fBilltype }}</span>-->
<!--          </template>-->
        </el-table-column>
<!--        <el-table-column label="作业类型" align="center" prop="fBusinessType"/>-->
        <el-table-column label="审核日期" align="center" prop="fReviewDate" />
        <el-table-column label="费用名称" align="center" prop="fFeeName" />
        <el-table-column label="金额" align="center" prop="fAmtdr" />
<!--        <el-table-column label="本次金额" align="center" prop="fAmt" width="100">-->
<!--          <template slot-scope="scope">-->
<!--            <el-input-->
<!--              v-model="scope.row.fAmt"-->
<!--              placeholder="请输入本次金额"-->
<!--              clearable-->
<!--              size="small"-->
<!--              oninput='this.value=this.value.replace(/[^\-?\d.]/g,"").replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3")'-->
<!--              @change=""-->
<!--            />-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column label="备注" align="center" prop="fRemarks">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.fRemarks"
              placeholder="请输入备注"
              clearable
              size="small"
              width="100"
            />
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="determine">确 定</el-button>
        <el-button @click="innerVisible = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>

</template>

<script>
import Vue from 'vue'
import Cookies from 'js-cookie'
import { getVoyageName, getVesselName,getcontrastList } from '@/api/finance/applyForInvoice/feeDetail'
import { addSet, select } from '@/api/system/set'
import draggable from "vuedraggable";
import { getFName, listFees } from '@/api/kaihe/domesticTrade/orderInformation'

Vue.directive("dialogDrag", {
  bind(el, binding, vnode, oldVnode) {
    const dialogHeaderEl = el.querySelector(".el-dialog__header");
    const dragDom = el.querySelector(".el-dialog");
    const enlarge = el.querySelector(".enlarge");
    dialogHeaderEl.style.cursor = "move";

    // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
    const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null);
    if (enlarge) {
      enlarge.onclick = (e) => {
        dragDom.style.top = "0px";
        dragDom.style.left = "0px";
      };
    }
    dialogHeaderEl.onmousedown = (e) => {
      // 鼠标按下，计算当前元素距离可视区的距离
      const disX = e.clientX - dialogHeaderEl.offsetLeft;
      const disY = e.clientY - dialogHeaderEl.offsetTop;

      // 获取到的值带px 正则匹配替换
      let styL, styT;

      // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
      if (sty.left.includes("%")) {
        styL =
          +document.body.clientWidth * (+sty.left.replace(/\%/g, "") / 100);
        styT =
          +document.body.clientHeight * (+sty.top.replace(/\%/g, "") / 100);
      } else {
        styL = +sty.left.replace(/\px/g, "");
        styT = +sty.top.replace(/\px/g, "");
      }

      document.onmousemove = function (e) {
        // 通过事件委托，计算移动的距离
        const l = e.clientX - disX;
        const t = e.clientY - disY;

        // 移动当前元素

        if (t + styT >= 0) {
          dragDom.style.top = `${t + styT}px`;
        }
        dragDom.style.left = `${l + styL}px`;
        // 将此时的位置传出去
        // binding.value({x:e.pageX,y:e.pageY})
      };

      document.onmouseup = function (e) {
        document.onmousemove = null;
        document.onmouseup = null;
      };
    };
  },
});

export default {
  name: 'feeDetail',
  components:{
    draggable
  },
  data(){
    return{
      empty: [],
      nothing: [],
      pass: {
        fAmtdr: "", //应收合计
        fMblno: "", //提单号
        fName: "", //货权方
      },
      voyageOptions:[],
      vesselOptions:[],
      businessTypeOptions:[],
      fDNameOptions: [],
      nameOptions:[],
      doNot:false,
      tableDate: [
        {
          surface: "1",
          label: "fBillno",
          name: "业务编号",
          checked: 0,
          fixed: "left",
          width: 100,
        },
        {
          surface: "2",
          label: "boatName",
          name: "船名",
          checked: 0,
          fixed: "left",
          width: 100,
        },
        {
          surface: "3",
          label: "voyageName",
          name: "航次",
          checked: 0,
          width: 100,
        },
        {
          surface: "4",
          label: "tMblno",
          name: "提单号",
          checked: 0,
          width: 100,
        },
        {
          surface: "5",
          label: "fAccbilldate",
          name: "费用名称",
          checked: 0,
          width: 100,
        },
        {
          surface: "6",
          label: "fCurreny",
          name: "币别",
          checked: 0,
          width: 100,
        },
        {
          surface: "7",
          label: "chargingMethod",
          name: "金额",
          checked: 0,
          width: 100,
        },
        {
          surface: "8",
          label: "invoiceNo",
          name: "汇率",
          checked: 0,
          width: 100,
        },
        {
          surface: "9",
          label: "bank",
          name: "业务类型",
          checked: 0,
          width: 100,
        },
        {
          surface: "10",
          label: "waterBillNo",
          name: "状态",
          checked: 0,
          width: 100,
        },
        {
          surface: "11",
          label: "审核日期",
          name: "审核日期",
          checked: 0,
          width: 100,
        },
        {
          surface: "12",
          label: "审核日期",
          name: "备注",
          checked: 0,
          width: 100,
        }
      ],
      tableDate2: [
        {
          surface: "1",
          label: "fFeeName",
          name: "货物或应税劳务、服务名称",
          checked: 0,
          width: 100,
        },
        {
          surface: "2",
          label: "fModel",
          name: "规格型号",
          checked: 0,
          width: 100,
        },
        {
          surface: "3",
          label: "fSbuName",
          name: "单位",
          checked: 0,
          width: 100,
        },
        {
          surface: "4",
          label: "fNumber",
          name: "数量",
          checked: 0,
          width: 100,
        },
        {
          surface: "5",
          label: "fUnitprice",
          name: "单价（含税）",
          checked: 0,
          width: 100,
        },
        {
          surface: "6",
          label: "fMoney",
          name: "金额（含税）",
          checked: 0,
          width: 100,
        },
        {
          surface: "7",
          label: "fTaxrate",
          name: "税率",
          checked: 0,
          width: 100,
        },
        {
          surface: "8",
          label: "fTax",
          name: "税额",
          checked: 0,
          width: 100,
        },
        {
          surface: "9",
          label: "fAmount",
          name: "合计金额",
          checked: 0,
          width: 100,
        },
        {
          surface: "10",
          label: "fStatus",
          name: "作废状态",
          checked: 0,
          width: 100,
        },
        {
          surface: "11",
          label: "remarks",
          name: "备注",
          checked: 0,
          width: 100,
        },
        {
          surface: "12",
          label: "createBy",
          name: "录入人",
          checked: 0,
          width: 100,
        },
        {
          surface: "13",
          label: "createTime",
          name: "录入时间",
          checked: 0,
          width: 100,
        },
        {
          surface: "14",
          label: "updateBy",
          name: "作废人",
          checked: 0,
          width: 100,
        },
        {
          surface: "15",
          label: "updateTime",
          name: "作废时间",
          checked: 0,
          width: 100,
        },
      ],
      setRowList: [],
      getRowList: [],
      setRowList2: [],
      getRowList2: [],
      allCheck2: false,
      showSetting2: false,
      allCheck: false,
      showSetting: false,
      chargeList_s:[],
      queryParameter:{
        fCorpid:null,
        fMblno:null,
        timeExamine:null,
        fBusinessType:null,
        fVslid:null,
        fVoyid:null,
        fDc:'D',
        fFeeid:null,
        createTimeList:null
      },
      //打开内部弹窗
      innerVisible: false,
      //全屏放大
      dialogFull: false,
      // 遮罩层
      loading: false,
      activeIndex:"1",
      showSearch: true,
      feeList:[],
      invoiceList:[],
      invoiceInfo:false,
      feeInfo:true,
      queryParams:{},
      Fee: [],
    }
  },
  created(){
    this.getDicts("data_billType").then((response) => {
      if (response.data) {
        this.businessTypeOptions = response.data
      }
    });
    this.setRowList = this.tableDate;
    this.getRowList = this.tableDate;
    this.setRowList2 = this.tableDate2;
    this.getRowList2 = this.tableDate2;
    this.getRow();
    this.nameRemoteMethod()
    this.vessleRemthod()
    this.voyageRemthods()
    // this.getRow2();
  },
  activated() {
    if(this.$route.query.data){
      if(this.$route.query.data.Num === 0){
        this.doNot = true
      }else{
        this.doNot = false
      }
    }
  },
  methods:{
    //确定带入从表
    determine(){
      console.log(this.selection)
      this.pass.fAmtdr = 0;
      for (let item in this.selection) {
        this.pass.fAmtdr = Number(this.pass.fAmtdr);
        this.pass.fAmtdr += Number(this.selection[item].fAmtdr);
      }
      console.log(this.pass.fAmtdr)
      if (!this.selection.length) {
        this.$message.error("未选择导入行");
      }else{
        for (let item in this.selection) {
          console.log(this.selection)
          this.empty.push(this.selection[item].fMblno);
          this.nothing.push(this.selection[item].fName);
          console.log(this.empty, this.nothing)

          if (this.feeList.length === 0) {
            this.feeList = this.feeList.concat(this.selection);
            //去重提单号
            this.empty = new Set(this.empty);
            this.empty = Array.from(this.empty);
            //去重货权方
            this.nothing = new Set(this.nothing);
            this.nothing = Array.from(this.nothing);
            if (this.empty.length <= 1) {
              this.pass.fMblno = this.empty[0];
            } else {
              this.pass.fMblno = this.empty[0] + "...";
            }
            if (this.nothing.length <= 1) {
              this.pass.fName = this.nothing[0];
            } else {
              this.pass.fName = this.nothing[0] + "...";
            }
            // this.queryParams.tMblno = this.pass.fMblno; //提单号
            this.queryParams.fCtrlcorpid = this.pass.fName;
            // this.queryParams.fAmtdr = this.pass.fAmtdr;
            this.innerVisible = false
            this.chargeList_s = []
            this.queryParameter = {
              fCorpid: "",
              fMblno: "",
              timeExamine: "",
              fBusinessType: "",
              fVslid: "",
              fVoyid: "",
              fDc: 'D',
              fFeeid: "",
              createTimeList: ""
            }
            return
          }
        else {
            for (let li in this.feeList) {
              if (this.selection[item].fSrcid !== this.feeList[li].fSrcid) {
                this.Fee = this.feeList.concat(this.selection);
                let result = [];
                let obj = {};
                for (let lis in this.Fee) {
                  if (!obj[this.Fee[lis].fSrcid]) {
                    result.push(this.Fee[lis]);
                    obj[this.Fee[lis].fSrcid] = true;
                  }
                }
                //去重提单号
                this.empty = new Set(this.empty);
                this.empty = Array.from(this.empty);
                //去重货权方
                this.nothing = new Set(this.nothing);
                this.nothing = Array.from(this.nothing);
                if (this.empty.length <= 1) {
                  this.pass.fMblno = this.empty[0];
                } else {
                  this.pass.fMblno = this.empty[0] + "...";
                }
                if (this.nothing.length <= 1) {
                  this.pass.fName = this.nothing[0];
                } else {
                  this.pass.fName = this.nothing[0] + "...";
                }
                this.innerVisible = false
                this.chargeList_s = []
                this.queryParameter = {
                  fCorpid: "",
                  fMblno: "",
                  timeExamine: "",
                  fBusinessType: "",
                  fVslid: "",
                  fVoyid: "",
                  fDc: 'D',
                  fFeeid: "",
                  createTimeList: ""
                }
                this.feeList = result
              }else {
                let i = Number(item) + 1;
                this.$message.error("行号为" + i + "重复");
              }
            }
          }
        }
        console.log(this.feeList)
      }
      // this.chargeList_s = this.feeList
    },
    voyageRemthods(){
      getVoyageName().then(response=>{
        this.voyageOptions = response.rows
      })
    },
    vessleRemthod(){
      getVesselName().then(response=>{
        console.log(response)
        this.vesselOptions = response.rows
      })
    },
    changeTime(){
      this.queryParameter.createTimeList[0] = this.queryParameter.createTimeList[0]+" 00:00:00"
      this.queryParameter.createTimeList[1] = this.queryParameter.createTimeList[1]+" 23:59:59"
    },
    timeMethods(){
      this.queryParameter.timeExamine[0] = this.queryParameter.timeExamine[0]+" 00:00:00"
      this.queryParameter.timeExamine[1] = this.queryParameter.timeExamine[1]+" 23:59:59"
    },
    openSearch(){
      this.queryParameter = {
        fCorpid:null,
          fMblno:null,
          timeExamine:null,
          fBusinessType:null,
          fVslid:null,
          fVoyid:null,
          fDc:'D',
          fFeeid:null,
          createTimeList:null
      },
      this.chargeList_s = []
      let query = { pageNum: 1, fDc: "D" };
      listFees(query).then((response) => {
        this.fDNameOptions = response.rows;
      });
      this.innerVisible = true
    },
    //获取客户名称下拉
    nameRemoteMethod(){
      let queryParams = { pageNum: 1 }
      getFName(queryParams).then(response=>{
        this.nameOptions = response.data
      })
    },
    getataDList(){
      getcontrastList(this.queryParameter).then(res=>{
        console.log(res)
        this.chargeList_s = res.rows

      })
    },
    submit(){

    },
    //列设置全选
    allChecked() {
      if (this.allCheck == true) {
        this.setRowList.map((e) => {
          return (e.checked = 0);
        });
      } else {
        this.setRowList.map((e) => {
          return (e.checked = 1);
        });
      }
    },
    //查询列数据
    getRow() {
      let that = this;
      this.data = {
        tableName: "费用信息",
        userId: Cookies.get("userName"),
      };
      select(this.data).then((res) => {
        if (res.data.length != 0) {
          this.getRowList = res.data.filter((e) => e.checked == 0);
          this.setRowList = res.data;
          this.setRowList = this.setRowList.reduce((res, item) => {
            res.push({
              surface: item.surface,
              label: item.label,
              name: item.name,
              checked: item.checked,
              width: item.width,
              fixed: item.fixed,
            });
            return res;
          }, []);
        }
      });
    },
    //保存列设置
    save() {
      this.showSetting = false;
      this.data = {
        tableName: "费用信息",
        userId: Cookies.get("userName"),
        sysTableSetList: this.setRowList,
      };
      addSet(this.data).then((res) => {
        this.getRowList = this.setRowList.filter((e) => e.checked == 0);
      });
    },
    //重置列表
    delRow() {
      this.data = {
        tableName: "费用信息",
        userId: Cookies.get("userName"),
      };
      resetModule(this.data).then((res) => {
        if (res.code == 200) {
          this.showSetting = false;
          this.setRowList = this.tableDate;
          this.getRowList = this.tableDate;
        }
      });
    },
    //列设置全选
    allChecked2() {
      if (this.allCheck2 == true) {
        this.setRowList2.map((e) => {
          return (e.checked = 0);
        });
      } else {
        this.setRowList2.map((e) => {
          return (e.checked = 1);
        });
      }
    },
    //查询列数据
    getRow2() {
      let that = this;
      this.data = {
        tableName: "发票信息",
        userId: Cookies.get("userName"),
      };
      select(this.data).then((res) => {
        if (res.data.length != 0) {
          this.getRowList2 = res.data.filter((e) => e.checked == 0);
          this.setRowList2 = res.data;
          this.setRowList2 = this.setRowList2.reduce((res, item) => {
            res.push({
              surface: item.surface,
              label: item.label,
              name: item.name,
              checked: item.checked,
              width: item.width,
              fixed: item.fixed,
            });
            return res;
          }, []);
        }
      });
    },
    //保存列设置
    save2() {
      this.showSetting2 = false;
      this.data = {
        tableName: "发票信息",
        userId: Cookies.get("userName"),
        sysTableSetList: this.setRowList2,
      };
      addSet(this.data).then((res) => {
        this.getRowList2 = this.setRowList2.filter((e) => e.checked == 0);
      });
    },
    //重置列表
    delRow2() {
      this.data = {
        tableName: "发票信息",
        userId: Cookies.get("userName"),
      };
      resetModule(this.data).then((res) => {
        if (res.code == 200) {
          this.showSetting2 = false;
          this.setRowList2 = this.tableDate2;
          this.getRowList2 = this.tableDate2;
        }
      });
    },
    //开始拖拽事件
    onStart() {
      this.drag = true;
    },
    //拖拽结束事件
    onEnd() {
      this.drag = false;
    },

    /** 查询财务数据主列表 */
    getList() {
      this.loading = true;
      this.getDicts("approval_process").then((response) => {
        this.options = response.data;
      });
      if (Cookies.get("sysType") == 1) {
        //大木
        listCharge(this.tableFilter).then((response) => {
          this.chargeList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      } else if (Cookies.get("sysType") == 2) {
        //车队
        listCharges(this.tableFilter).then((response) => {
          response.rows.map((e) => {
            if (e.createTime) {
              e.createTime = e.createTime.substring(0, 10);
            }
          });
          this.chargeList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      }
    },
    //sheet切换
    handleSelect(key, keyPath) {
      if(key === '1') {
        this.feeInfo = true
        this.invoiceInfo = false
      }else{
        this.feeInfo = false
        this.invoiceInfo = true
      }
    },
    //发票信息新行
    addList(){
      let query = { pageNum: 1, fDc: "D" };
      listFees(query).then((response) => {
        this.fDNameOptions = response.rows;
      });
      this.invoiceList.push({

      })
    },
    // 导入多选框
    handleSelectionChange_s(selection) {
      this.totAL = 0;
      this.Ttime = 0;
      this.selection = selection;
      if (this.selection.length == 0) {
        for (let item in this.chargeList_s) {
          this.totAL += Number(this.chargeList_s[item].fAmt);
          this.Ttime += Number(this.chargeList_s[item].fAmtdr);
        }
      } else {
        for (let index in selection) {
          this.totAL += Number(selection[index].fAmt);
          this.Ttime += Number(selection[index].fAmtdr);
        }
      }
      // this.getSummaries()
    },
    //清空一行
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },

  }
}
</script>

<style lang="scss" scoped>
.tabSetting {
  display: flex;
  justify-content: flex-end;
}
.listStyle {
  display: flex;
  border-top: 1px solid #dcdfe6;
  border-left: 1px solid #dcdfe6;
  border-right: 1px solid #dcdfe6;
}
.listStyle:last-child {
  border-bottom: 1px solid #dcdfe6;
}
.progress {
  display: flex;
  align-items: center;
  padding: 2px;
  background-color: rgba(0, 0, 0, 0.05);
  height: 100%;
}
</style>
<style lang="scss">
.el-table {
  .el-table__body-wrapper {
    z-index: 2;
  }
}
</style>
