<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      :inline="true"
      v-show="showSearch"
      label-width="120px"
    >
      <el-form-item label="申请编号" prop="fBillno">
        <el-input
          v-model="queryParams.fBillno"
          disabled
          size="small"
          style="width: 200px"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="客户名称" prop="fCtrlcorpid">
        <el-select
          v-model="queryParams.fCtrlcorpid"
          filterable
          remote
          clearable
          disabled
          size="small"
          style="width: 200px"
          :remote-method="corpsRemoteMethod"
        >
          <el-option
            v-for="(dict, index) in fMblnoOptions"
            :key="index.fId"
            :label="dict.fName"
            :value="dict.fId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="开票单位" prop="fCorpidName">
        <el-select
          v-model="queryParams.fCorpidName"
          filterable
          remote
          clearable
          disabled
          size="small"
          style="width: 200px"
          :remote-method="corpsRemoteMethod"
        >
          <el-option
            v-for="(dict, index) in fMblnoOptions"
            :key="index.fId"
            :label="dict.fName"
            :value="dict.fId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="申请人" prop="createBy">
        <el-input
          disabled
          v-model="queryParams.createBy"
          clearable
          style="width: 200px"
          size="small"
        />
      </el-form-item>
      <el-form-item label="金额合计（元）" prop="fAmtdr">
        <el-input
          disabled
          v-model="queryParams.fAmtdr"
          clearable
          style="width: 200px"
          size="small"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="申请日期" prop="createTime">
        <el-input
          disabled
          v-model="queryParams.createTime"
          clearable
          size="small"
          style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="税率（%）" prop="fTaxrate">
        <el-input
          disabled
          v-model="queryParams.fTaxrate"
          clearable
          size="small"
          style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input
          disabled
          v-model="queryParams.remark"
          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"

        ></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, feeList)"
          >删除
          </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"
        sortable
        :fixed="item.fixed"
      >
        <template slot-scope="scope">
          <el-select v-model="scope.row.fFeeName" @change="changeId" v-if="item.label == 'fFeeName'">
              <el-option
                v-for="dict in fDNameOptions"
                :key="dict.fId"
                :label="dict.fName"
                :value="dict.fId"
              ></el-option>
          </el-select>
          <el-input v-model="scope.row.fModel" v-if="item.label == 'fModel'"/>
          <el-select v-model="scope.row.fSbu" v-if="item.label == 'fSbu'">
            <el-option
              v-for="dict in unitOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"/>
          </el-select>
          <el-input v-model="scope.row.fNumber" @change="priceTotal" v-if="item.label == 'fNumber'"/>
          <el-input v-model="scope.row.fUnitprice" @change="priceTotal" v-if="item.label == 'fUnitprice'"/>
          <el-input v-model="scope.row.fMoney" disabled v-if="item.label == 'fMoney'"/>
          <el-input v-model="scope.row.fTaxrate" @change="priceTotal" v-if="item.label == 'fTaxrate'"/>
          <el-input v-model="scope.row.fTax" disabled v-if="item.label == 'fTax'"/>
          <el-input v-model="scope.row.fAmount" disabled 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" disabled v-if="item.label == 'createBy'"/>
          <el-date-picker v-model="scope.row.createTime" style="width:100%" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" v-if="item.label == 'createTime'"/>
          <el-input v-model="scope.row.updateBy" disabled v-if="item.label ==  'updateBy' && scope.row.fStatus == '0'"/>
          <el-date-picker v-model="scope.row.updateTime" style="width:100%" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" 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="deleteRoww(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>


  </div>

</template>

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

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{
      Lander:null,
      unitOptions:[],
      fMblnoOptions: [],
      empty: [],
      nothing: [],
      pass: {
        fAmtdr: "", //应收合计
        fMblno: "", //提单号
        fName: "", //货权方
      },
      businessTypeOptions:[],
      fDNameOptions: [],
      nameOptions:[],
      doNot:false,
      tableDate: [
        {
          surface: "1",
          label: "srcBillNo",
          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: "fMblno",
          name: "提单号",
          checked: 0,
          width: 100,
        },
        {
          surface: "5",
          label: "fFeeName",
          name: "费用名称",
          checked: 0,
          width: 100,
        },
        {
          surface: "6",
          label: "fCurrency",
          name: "币别",
          checked: 0,
          width: 100,
        },
        {
          surface: "7",
          label: "fAmtdr",
          name: "金额",
          checked: 0,
          width: 100,
        },
        {
          surface: "8",
          label: "fExrate",
          name: "汇率",
          checked: 0,
          width: 100,
        },
        {
          surface: "9",
          label: "fBilltype",
          name: "业务类型",
          checked: 0,
          width: 100,
        },
        {
          surface: "10",
          label: "fStatusName",
          name: "状态",
          checked: 0,
          width: 100,
        },
        {
          surface: "11",
          label: "updateTime",
          name: "审核日期",
          checked: 0,
          width: 100,
        },
        {
          surface: "12",
          label: "remark",
          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: "fSbu",
          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,
      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.setRowList = this.tableDate;
    this.getRowList = this.tableDate;
    this.setRowList2 = this.tableDate2;
    this.getRowList2 = this.tableDate2;
    this.getDicts("data_billType").then((response) => {
      if (response.data) {
        this.businessTypeOptions = response.data
      }
    });
    this.getDicts("data_unitfees").then((response) => {
      if (response.data) {
        this.unitOptions = response.data
      }
    });
    queryUserVal().then((response) => {
      this.Lander = response.user.userName;
    });
    this.getRow();
    this.nameRemoteMethod()
    this.corpsRemoteMethod()
    this.getRow2();
    this.feeName()
  },
  activated() {
    if(this.$route.query.data){
      let data = JSON.parse(this.$route.query.data)
      if(data.Num === 0){
        this.doNot = true
      }else{
        this.doNot = false
      }
      listChange(data.fId).then(response=>{
        if(response.data.tFee){
          this.queryParams = response.data.tFee
          this.$set(this.queryParams,'createTime',this.queryParams.createTime.slice(0,10))
        }
        if(response.data.feeDoList){
          this.feeList = response.data.feeDoList
        }
        if(response.data.tFeeInvoiceList){
          this.invoiceList = response.data.tFeeInvoiceList
          for(let item in response.data.tFeeInvoiceList){
            for(let li in this.invoiceList){
              if(this.invoiceList[li].fId == response.data.tFeeInvoiceList[item].fId){
                this.invoiceList[li].fSbu = response.data.tFeeInvoiceList[item].fSbu + ''
              }
            }
          }
          for(let li in this.fDNameOptions){
            for(let item in this.invoiceList){
              if(this.invoiceList[item].fFeeName == this.fDNameOptions[li].fName){
                this.invoiceList[item].fFeeid = this.fDNameOptions[li].fId
              }
            }
          }
        }
      })
    }
  },
  methods:{
    changeId(){
        for(let item in this.invoiceList){
          this.invoiceList[item].fFeeid = this.invoiceList[item].fFeeName
        }
    },
    //获取服务费名称
    feeName(){
      let query = { pageNum: 1, fDc: "D" };
      listFees(query).then((response) => {
        this.fDNameOptions = response.rows;
      });
    },
    //金额（含税）
    priceTotal(){
      for(let li in this.invoiceList){
        if(this.invoiceList[li].fNumber || this.invoiceList[li].fUnitprice){
          this.$set(this.invoiceList[li],'fMoney',(this.invoiceList[li].fNumber * this.invoiceList[li].fUnitprice).toFixed(2))
        }
        if(this.invoiceList[li].fTaxrate && this.invoiceList[li].fNumber
          || this.invoiceList[li].fTaxrate && this.invoiceList[li].fUnitprice
          || this.invoiceList[li].fNumber && this.invoiceList[li].fUnitprice){
          this.$set(this.invoiceList[li],'fTax',(this.invoiceList[li].fMoney * (this.invoiceList[li].fTaxrate/100)/ (1 + this.invoiceList[li].fTaxrate/100) ).toFixed(2))
          if(this.invoiceList[li].fMoney && this.invoiceList[li].fTax){
            this.$set(this.invoiceList[li],'fAmount',(this.invoiceList[li].fMoney - this.invoiceList[li].fTax).toFixed(2))
          }
        }
      }
    },
    /** 远程模糊查询用户 */
    corpsRemoteMethod(name) {
      if (name == null || name === "") {
        return false;
      }
      let queryParams = { fName: name };
      listCorps(queryParams).then((response) => {
        this.fMblnoOptions = response;
      });
    },
    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(){
      let res = {}
      let fSrcpid = []
      let fSrcid = []
      console.log(this.feeList)
      for(let li in this.feeList){
        fSrcpid.push(this.feeList[li].fSrcpid)
        fSrcpid = Array.from(new Set(fSrcpid))
        fSrcid.push(this.feeList[li].fSrcid)
      }
      res = {
        fSrcid:fSrcid,
        fSrcpid:fSrcpid,
        fCorpid:this.queryParams.fCorpidName,
        billsType:this.queryParams.fBilltype,
        fId:this.queryParams.fId
      }
      this.$router.push({
        path:'/finance/generalLedger',
        query:{ data:JSON.stringify(res) }
      })
    },
    //获取客户名称下拉
    nameRemoteMethod(){
      let queryParams = { pageNum: 1 }
      getFName(queryParams).then(response=>{
        this.nameOptions = response.data
      })
    },
    submit(){
      if(this.invoiceList[0].fTaxrate){
        this.queryParams.fTaxrate = this.invoiceList[0].fTaxrate
      }
      let formData = new window.FormData()
      formData.append('tFee',JSON.stringify(this.queryParams))
      formData.append('tFeeDo',JSON.stringify(this.feeList))
      formData.append('billsType',this.queryParams.fBilltype)
      formData.append('tFeeInvoice',JSON.stringify(this.invoiceList))
      addPreservation(formData).then(response=>{
        this.$message.success("操作成功")
      })
    },
    //列设置全选
    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;
    },

    //sheet切换
    handleSelect(key, keyPath) {
      if(key === '1') {
        this.feeInfo = true
        this.invoiceInfo = false
      }else{
        this.feeInfo = false
        this.invoiceInfo = true
      }
    },
    //发票信息新行
    addList(){
        this.invoiceList.push({
          fModel:null,
          fSbu:'1',
          fNumber:null,
          fUnitprice:null,
          fMoney:null,
          fTaxrate:null,
          fTax:null,
          fAmount:null,
          fStatus:'1',
          remarks:null,
          createBy:this.Lander,
          createTime:null,
          updateBy:this.Lander,
          updateTime:null,
        })
    },
    // 导入多选框
    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);
    },
    deleteRoww(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>
