<template>
  <div :style="{ 'padding-bottom': opType == 3 ? '20px' : '' }">
    <div class="reply_form">
      <el-form ref="form" :model="form" label-width="120px">
          <el-row>
            <el-col :span="10">
                <el-form-item :label="$t('quota.quotaNode')+'：'" class="unabled is-disabled">
                    <el-input v-model="form.id" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="10" class="left_30">
                <el-form-item :label="$t('quota.collateralType')+'：'" :class="form.collateralTypeOriginal&&mine&&form.operateStatus==2&&form.collateralType!=form.collateralTypeOriginal?'modified':opType==3?'unabled is-disabled':'require'">
                    <el-select v-model="form.collateralType" @change="collateralChange" :disabled="opType==3?true:false">
                        <el-option
                        v-for="item in collateralTypeList"
                        :key="item.code"
                        :label="item.desc"
                        :value="item.code">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-col>
        </el-row>

        <el-row>
            <el-col :span="10">
                <el-form-item :label="$t('quota.nodeName')+'：'" :class="opType==3||form.startDateOriginal?'unabled is-disabled':'require'">
                    <el-input v-model="form.nodeName" :disabled="opType==3||form.startDateOriginal?true:false"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="10" class="left_30">
                <el-form-item  label="担保成数(%)：" :class="form.colPercentOriginal&&mine&&form.operateStatus==2&&form.colPercent!=form.colPercentOriginal?'modified':opType==3||form.collateralType!=3?'unabled is-disabled':'require'">
                    <el-input
                        v-model="form.colPercentNum"
                        min="1"
                        onKeyUp="value=value.replace(/[^\d]/g, '').replace(/^0{1,}/g,'');if(value.length>3)value=value.slice(0,3);;if(value>100)value=100"
                        @blur="form.colPercentNum = $event.target.value"
                        :disabled="opType==3||form.collateralType!=3?true:false"></el-input>
                </el-form-item>
            </el-col>
        </el-row>

        <el-row>
          <el-col :span="10">
            <el-form-item
              :label="$t('quota.nodeDescrip')+'：'"
              :class="
                opType == 3 || form.startDateOriginal
                  ? 'unabled is-disabled'
                  : ''
              "
            >
              <el-tooltip
                v-if="form.nodeDescrip && form.nodeDescrip.length > 28"
                :content="form.nodeDescrip"
                placement="top"
              >
                <el-input
                  v-model="form.nodeDescrip"
                  oninput="if(value.length>200)value=value.slice(0,200)"
                  :disabled="
                    opType == 3 || form.startDateOriginal ? true : false
                  "
                ></el-input>
              </el-tooltip>
              <el-input
                v-else
                v-model="form.nodeDescrip"
                oninput="if(value.length>200)value=value.slice(0,200)"
                :disabled="
                  opType == 3 || form.startDateOriginal ? true : false
                "
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10" class="left_30">
            <el-form-item
              :label="$t('quota.startDate')+'：'"
              :class="
                form.startDateOriginal &&
                mine &&
                form.operateStatus == 2 &&
                form.startDate != form.startDateOriginal
                  ? 'modified'
                  : opType == 3
                  ? 'unabled is-disabled'
                  : 'require'
              "
            >
              <!-- <el-input v-model="form.startDate" ></el-input> -->
              <el-date-picker
                :disabled="opType == 3 ? true : false"
                v-model="form.startDate"
                :clearable="false"
                @change="
                  dataCheck($event, form.enterpriseId, 'startDate', 'isForm')
                "
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item :label="$t('quota.propertyName')+'：'"  class="unabled is-disabled">
              <el-select v-model="form.property" :disabled="true">
                <el-option
                  v-for="item in propertyList"
                  :key="item.code"
                  :label="item.desc"
                  :value="item.code"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10" class="left_30">
            <el-form-item
              :label="$t('quota.endDate')+'：'"
              :class="
                form.endDateOriginal &&
                mine &&
                form.operateStatus == 2 &&
                form.endDate != form.endDateOriginal
                  ? 'modified'
                  : opType == 3
                  ? 'unabled is-disabled'
                  : 'require'
              "
            >
              <!-- <el-input  v-model="form.endDate" ></el-input> -->
              <el-date-picker
                v-model="form.endDate"
                :disabled="opType == 3 ? true : false"
                :clearable="false"
                @change="
                  dataCheck($event, form.enterpriseId, 'endDate', 'isForm')
                "
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item :label="$t('quota.liabilityCode')+'：'" class="unabled is-disabled">
              <el-input
                v-model="form.liabilityCode"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10" class="left_30">
            <el-form-item :label="$t('quota.sanctionDate')+'：'" class="unabled is-disabled">
              <!-- <el-input v-model="form.sanctionDate" ></el-input> -->
              <!-- opType == 3 || form.startDateOriginal ? true : false -->
              <el-date-picker
                v-model="form.sanctionDate"
                :clearable="false"
                @change="
                  dataCheck($event, form.enterpriseId, 'sanctionDate', 'isForm')
                "
                :disabled="true"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder=""
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item :label="$t('quota.certificateCode')+'：'"  class="unabled is-disabled">
              <el-input
                v-model="form.certificateCode"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10" class="left_30">
            <el-form-item
              :label="$t('quota.liabilityDistribution')+'：'"
              :class="
                opType == 3 || form.startDateOriginal
                  ? 'unabled is-disabled'
                  : 'require'
              "
            >
              <el-select
                v-model="form.liabilityDistribution"
                :disabled="
                  opType == 3 || form.startDateOriginal ? true : false
                "
                @change="setChange"
              >
                <el-option
                  v-for="item in liabilityList"
                  :key="item.code"
                  :label="item.desc"
                  :value="item.code"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item :label="$t('quota.custCode')+'：'"  class="unabled is-disabled">
              <el-input v-model="form.custCode" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10" class="left_30">
            <el-form-item
              :label="$t('quota.currencyCode')+'：'"
              :class="
                opType == 3 || form.startDateOriginal
                  ? 'unabled is-disabled'
                  : 'require'
              "
            >
              <el-select
                v-model="form.currencyCode"
                :disabled="
                  opType == 3 || form.startDateOriginal ? true : false
                "
                @change="setChange"
              >
                <el-option
                  v-for="item in currencyList"
                  :key="item.id"
                  :label="item.currencyCode"
                  :value="item.currencyCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item :label="$t('quota.custName')+'：'" class="unabled is-disabled">
              <el-input v-model="form.custName" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10" class="left_30">
            <el-form-item
            :label="$t('quota.overalLimit2')+'：'"
              :class="
                form.startDateOriginal &&
                mine &&
                form.operateStatus == 2 &&
                form.overalLimit != form.overalLimitOriginal
                  ? 'modified'
                  : opType == 3
                  ? 'unabled is-disabled'
                  : 'require'
              "
            >
              <cinput
                v-model="form.overalLimit"
                :disabled="opType == 3 ? true : false"
              ></cinput>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item :label="$t('quota.treePname')+'：'"   class="unabled is-disabled">
              <el-input
                :value="
                  (form.preNode && form.preNode.nodeName) || form.treePname
                "
                :disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10" class="left_30">
            <el-form-item  :label="$t('quota.earmarkAmount')+'：'" class="unabled is-disabled">
              <el-input
                :value="form.earmarkAmount | numberToCurrency"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item
              :label="$t('quota.partialFlag')+'：'"
              :class="
                form.partialFlagOriginal &&
                mine &&
                form.operateStatus == 2 &&
                form.partialFlag != form.partialFlagOriginal
                  ? 'modified'
                  : opType == 3
                  ? 'unabled is-disabled'
                  : 'require'
              "
            >
              <el-select
                v-model="form.partialFlag"
                :disabled="opType == 3 ? true : false"
              >
                <el-option
                  v-for="item in partialFlagList"
                  :key="item.code"
                  :label="item.desc"
                  :value="item.code"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10" class="left_30">
            <el-form-item :label="$t('quota.utilizedAmount2')+'：'" class="unabled is-disabled">
              <el-input
                :value="form.utilizedAmount | numberToCurrency"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item
              :label="$t('quota.revolvingFlag')+'：'"
              :class="
                form.revolvingFlagOriginal &&
                mine &&
                form.operateStatus == 2 &&
                form.revolvingFlag != form.revolvingFlagOriginal
                  ? 'modified'
                  : opType == 3
                  ? 'unabled is-disabled'
                  : 'require'
              "
            >
              <el-select
                v-model="form.revolvingFlag"
                :disabled="opType == 3 ? true : false"
              >
                <el-option
                  v-for="item in revolvingFlagList"
                  :key="item.code"
                  :label="item.desc"
                  :value="item.code"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10" class="left_30">
            <el-form-item :label="$t('quota.availableCredit')+'：'"  class="unabled is-disabled">
              <cinput :value="form.overalLimit-form.earmarkAmount-form.utilizedAmount" :disabled="true"></cinput>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item  :label="$t('quota.isUsable')+'：'" class="unabled is-disabled">
              <el-input
                :value="form.isUsable == 1 ? '十足担保' : '担保不足'"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.operateStatus ==3&&mine||form.operateStatus ==4&&mine||form.operateStatus ==5&&mine">
          <el-col :span="24">
            <el-form-item  :label="$t('quota.applyDescrip')+'：'"  class="unabled is-disabled">
              <el-input
                type="textarea"
                :rows="3"
                v-model="form.applyDescrip"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <span
      slot="footer"
      v-if="opType > 1"
      class="dialog-footer"
      style="padding-bottom: 10px; padding-right: 16px"
    >
      <el-button
        v-waves
        class="filter-item flex_align el-button--success"
        type="primary"
        style="margin-right: 20px; width: 110px"
        @click="establish"
        v-if="opType > 2"
      >
        <!-- {{ $t('table.sbumit') }} -->
        {{ opType == 3 ? "查看金融产品" : "建立金融产品" }}
      </el-button>
      <el-button
        v-waves
        class="filter-item flex_align el-button--success"
        @click="linkcoll"
        style="margin-right: 20px; width: 110px"
        type="primary"
        v-if="form.collateralType !== 2"
      >
        <!-- 信用形式为纯信用时，不显示该按钮-->
        {{ opType == 3 ? "查看抵(质)押品" : "连接抵(质)押品" }}
      </el-button>
    </span>
    <div v-if="showFinance && financedata.length > 0" class="finance">
      <p class="finance-header">
        <span>向下分配额度</span>
        <span>币种</span>
        <span style="width: 138px">批准额</span>
        <span style="width: 118px">虚占</span>
        <span style="width: 118px">动用</span>
        <span style="width: 118px">可用</span>
        <span style="width: 120px">起日</span>
        <span style="width: 126px">迄日</span>
        <span style="width: 120px">操作</span>
      </p>
      <el-row :gutter="10" style="padding: 0 20px; overflow: auto">
        <el-col :span="24">
          <!-- <div :style="{'max-height':'370px'}" class="flex-tree"> -->
          <div style="height: 100%" class="flex-tree">
            <el-scrollbar style="height: 100%">
              <el-tree
                class="my-tree"
                style="overflow-y: scroll"
                node-key="financialProductId"
                :data="financedata"
                :indent="0"
                :props="defaultProps"
                :expand-on-click-node="false"
                :default-expanded-keys="defaultShowKeys"
              >
                <!-- <div class="custom-tree-node"  slot-scope="{ data}"> -->
                <div class="custom-tree-node" slot-scope="{ node, data }">
                  <div class="node-cnt">
                    <img class="node-img" :src="imgPathUrl(data)" />
                    <el-tooltip
                      v-if="
                        (node.level == 1 &&
                          data.productCode &&
                          data.productCode.length > 10) ||
                        (node.level == 2 &&
                          data.productCode &&
                          data.productCode.length > 6) ||
                        (node.level == 3 &&
                          data.productCode &&
                          data.productCode.length > 3) ||
                        (node.level == 4 &&
                          data.productCode &&
                          data.productCode.length > 1) ||
                        (node.level == 5 &&
                          data.productCode &&
                          data.productCode.length > 1)
                      "
                      class="item"
                      effect="dark"
                      :content="data.productCode"
                      placement="top"
                    >
                      <span
                        class="node-sp span_desc"
                        :style="{
                          width:
                            node.level == 1
                              ? '130px'
                              : node.level == 2
                              ? '100px'
                              : node.level == 3
                              ? '110px'
                              : node.level == 4
                              ? '90px'
                              : '70px',
                        }"
                        >{{ data.productCode }}</span
                      >
                    </el-tooltip>
                    <span v-else class="node-sp">
                      {{ data.productCode }}
                    </span>
                  </div>
                  <p class="lint"></p>
                  <div
                    class="tab_input"
                    :style="{
                      left:
                        node.level == 1
                          ? '246px'
                          : node.level == 2
                          ? '211px'
                          : node.level == 3
                          ? '184px'
                          : node.level == 4
                          ? '162px'
                          : node.level == 5
                          ? '130px'
                          : node.level == 6
                          ? '100px'
                          : '70px',
                    }"
                  >
                    <span>
                      <a href="javascript:;" v-if="opType == 3">{{
                        data.liabilityDistribution === 1 && data.overalLimit > 0
                          ? "流用"
                          : data.liabilityDistribution === 2 &&
                            data.overalLimit > 0
                          ? "分享"
                          : ""
                      }}</a>
                      <el-select
                        v-else
                        clearable
                        v-model="data.liabilityDistribution"
                        :disabled="data.disabled"
                        @change="liabiCh($event, data)"
                        style="width: 90px"
                      >
                        <el-option
                          v-for="item in liabilityList"
                          :key="item.code"
                          :label="item.desc"
                          :value="item.code"
                        >
                        </el-option>
                      </el-select>
                    </span>
                    <!-- 币种 -->
                    <span
                      class="cur-sp"
                      :class="
                        data.currencyCodeOriginal &&
                        mine &&
                        data.currencyCode != data.currencyCodeOriginal
                          ? 'span_color'
                          : ''
                      "
                    >
                      <a href="javascript:;" v-if="data.startDateOriginal||opType == 3">{{
                        data.currencyCode
                      }}</a>
                      <el-select
                        class="cur-ipt"
                        v-else
                        clearable
                        v-model="data.currencyCode"
                        @change="ccyChange($event, data)"
                        style="width: 70px;"
                      >
                        <el-option
                          v-for="item in currencyList"
                          :key="item.id"
                          :label="item.currencyCode"
                          :value="item.currencyCode"
                        >
                        </el-option>
                      </el-select>
                    </span>
                    <!-- 批准额 -->
                    <span
                      style="width: 134px"
                      :class="
                        data.startDateOriginal &&
                        mine &&
                        data.overalLimit != data.overalLimitOriginal
                          ? 'span_color'
                          : ''
                      "
                    >
                      <a href="javascript:;" v-if="opType == 3">{{
                        data.overalLimit | numberToCurrency
                      }}</a>
                      <cinput
                        v-else
                        style="width: 130px;"
                        v-model="data.overalLimit"
                        place="right"
                        class="require-input"
                      ></cinput>
                    </span>

                    <span style="width: 114px;line-height:37px;">{{
                      data.earmarkAmount | numberToCurrency
                    }}</span>

                    <span style="width: 114px;line-height:37px;">{{
                      data.utilizedAmount | numberToCurrency
                    }}</span>
                    <span style="width: 114px;line-height:37px;"
                      >{{
                        (data.overalLimit - (data.earmarkAmount ? data.earmarkAmount : 0) - (data.utilizedAmount ? data.utilizedAmount : 0)) | numberToCurrency
                      }}
                    </span>
                    <span
                      style="margin-right: 12px; width: 116px"
                      :class="
                        data.startDateOriginal &&
                        mine &&
                        data.startDate != data.startDateOriginal
                          ? 'span_color'
                          : ''
                      "
                    >
                      <a href="javascript:;" v-if="opType == 3">{{
                        data.startDate&&data.startDate.split(' ')[0]
                      }}</a>
                      <el-date-picker
                        v-else
                        v-model="data.startDate"
                        @change="dataCheck($event, data, 'startDate', 'isTree')"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择日期"
                      >
                      </el-date-picker>
                    </span>
                    <span
                      style="margin-right: 12px; width: 116px"
                      :class="
                        data.endDateOriginal &&
                        mine &&
                        data.endDate != data.endDateOriginal
                          ? 'span_color'
                          : ''
                      "
                    >
                      <a href="javascript:;" v-if="opType == 3">{{
                        data.endDate&&data.endDate.split(' ')[0]
                      }}</a>
                      <el-date-picker
                        v-else
                        v-model="data.endDate"
                        @change="dataCheck($event, data, 'endDate', 'isTree')"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择日期"
                      >
                      </el-date-picker>
                    </span>
                    <span>
                      <el-button
                        v-if="opType != 3 && data.id&&!data.startDateOriginal"
                        style="margin:0 37px;"
                        @click="delfinance(data)"
                        type="text"
                        >删除</el-button
                      >
                      <template  v-if="isDraf==2">
                        <div>
                          {{data.operateStatus==1?'新增':data.operateStatus==2?'修改':data.operateStatus==9?'删除':''}}
                        </div>
                      </template>
                    </span>
                  </div>
                </div>
                <!-- </div> -->
              </el-tree>
            </el-scrollbar>
          </div>
        </el-col>
      </el-row>
    </div>
    <span
      slot="footer"
      class="dialog-footer"
      v-if="opType < 3"
      style="padding-bottom: 10px; padding-right: 36px"
    >
      <el-button
        v-waves
        class="filter-item flex_align"
        type="info"
        icon="el-icon-my-baocun"
        style="margin-right: 20px"
        @click="sbumit"
      >
        {{ $t("table.draft") }}
      </el-button>
      <el-button
        v-waves
        class="filter-item flex_align"
        type="primary"
        icon="el-icon-my-quxiao"
        @click="cancelBut"
      >
        {{ $t("table.cancel") }}
      </el-button>
    </span>
    <el-dialog
      title="批复书连接抵(质)押品"
      :append-to-body="true"
      v-el-drag-dialog
      :close-on-click-modal="false"
      :visible.sync="dataFormVisible"
      @close="cancelButDet"
      width="1260px"
    >
      <coll
        @cancelButDet="cancelButDet"
        :data="form"
        :isDraf="isDraf"
        :operatype="opType"
        ref="IncomeStatisticsChild"
        :mine="mine"
        v-if="DestroyIncomeStatistics == true"
      ></coll>
    </el-dialog>
  </div>
</template>

<script>
import elDragDialog from "@/directive/el-drag-dialog";
import waves from "@/directive/waves"; // waves directive
import http from "@/api/http";
import cinput from "../collateral/cinput.vue";
import coll from "./connectedcollateral.vue";
import { defaults } from 'js-cookie';
export default {
  name: "",
  components: { cinput, coll },
  directives: { waves, elDragDialog },
  props: {
    data: Object,
    item: Object,
    // type:String,
    formData: {
      type: Object,
      default: () => {}
    },
    operatype: Number,
    mine: Boolean,
    isDraf: Number,
    liabilityDistribution: Number,
    currencyCode: String,
    overalLimit: Number,
    startDate: String,
    endDate: String,
  },
  data() {
    return {
      form: {
        colPercentNum: "",
        preNode: {},
      },
      amouDis: false,
      collateralTypeList: [
        { code: 1, desc: "全额担保" },
        { code: 2, desc: "纯信用" },
        { code: 3, desc: "担保信用混合模式" },
      ],
      propertyList: [{ code: 13, desc: "批复书" }],
      liabilityList: [
        { code: 1, desc: "流用" },
        { code: 2, desc: "分享" },
      ],
      partialFlagList: [
        { code: 1, desc: "单张" },
        { code: 2, desc: "分批" },
      ],
      revolvingFlagList: [
        { code: 1, desc: "循环" },
        { code: 2, desc: "非循环" },
      ],
      // collateralTypeList:[],
      financedata: [],
      showFinance: false,
      defaultProps: {
        children: "chirdren",
        label: "productCode",
      },
      currencyList: [],
      yData: this.data,
      dataFormVisible: false,
      defaultShowKeys: [],
      DestroyIncomeStatistics: false,
      isShowBut: false,
      opType: this.operatype,
      alloPfType: false,
    };
  },
//   mounted() {  },
  // created() {this.getFormData()},
  watch: {
    formData: {
      handler() {
        this.$nextTick(() => {
          this.getFormData()
        })
      },
      immediate: true // 默认立即触发一次
    }
  },
  created() {
    // console.log('opType------------------', this.opType);
    // console.log('liabilityDistribution------------------', this.liabilityDistribution);
    // console.log('currencyCode------------------', this.currencyCode);
    // console.log('overalLimit------------------', this.overalLimit);
    // console.log('startDate------------------', this.startDate);
    // console.log('endDate------------------', this.endDate);
    this.getCurrency();
  },
  mounted(){

  },
  methods: {
    getFormData() {
      // console.log('eeeeeeeeeeeeeeeeee触发了一次eeeeeeeeeeeee');
      // console.log( this.opType,this.isDraf);
      // console.log("this.form", this.yData);
      console.log('this.formData', this.formData);
      this.$nextTick(() => {
        // console.log(this.operatype);
          console.log('this.opType-------------', this.opType);
        //   console.log('this.formData',this.formData);
        if (this.opType > 1) {
            this.form = this.formData;
            // console.log('this.form.relationFinancialProduct',this.form.relationFinancialProduct)
            if(this.form.collateralType==1){
                this.$set(this.form,'colPercentNum',100)
            }else if(this.form.collateralType==2){
                this.$set(this.form,'colPercentNum','0')
            }else{
                this.$set(this.form,'colPercentNum',this.formData.colPercent*100)
            }
            if(this.form.endDateOriginal){
                this.$set(this.form,'endDateOriginal',this.form.endDateOriginal.split(' ')[0])
            }
            if(this.form.startDateOriginal){
                this.$set(this.form,'startDateOriginal',this.form.startDateOriginal.split(' ')[0])
            }
            // if (this.form.relationFinancialProduct == 1 || this.form.relationFinancialProduct == 0) {
            //     this.establish();
            // }

            if (this.form.currencyCode) {
              if (this.liabilityDistribution === 1) { // 上级分配额度类型 为流用 需求:上级类型是流用，下级币种和上级相同 批准额等于上级的批准额
                if (this.currencyCode === this.form.currencyCode) {
                  // this.form.overalLimit = this.overalLimit
                  // this.$set(this.form, 'overalLimit', this.overalLimit)
                  this.amouDis = true
                } else {
                  // let { overalLimit } = this.formData
                  // this.$set(this.form, 'overalLimit', overalLimit ? overalLimit : '')
                  this.amouDis = false
                }
              }
            }
        } else {
          //  console.log(this.data);
          this.form = {
            treePname: this.data.nodeName || "",
            nodeName: this.data.nodeName + "-批复书" || "",
            utilizedAmount: "0",
            earmarkAmount: "0",
            frozenAmount: "0",
            property: 13,
            enterpriseId: this.data.enterpriseId,
            pid: this.data.pid,
            custCode: this.data.custCode||this.data.pNodeObj.custCode,
            custName: this.data.custName||this.data.pNodeObj.custName,
            liabilityCode: this.data.custCode,
            preNode: {},
            // colPercent:this.data.colPercent*100
          };
        }
        if(this.opType==2&&this.formData.id){
          this.establish();
        }
      });
    },
    establish() {
      let url = "",par = {};
      if (this.mine) {
        url = `/liability/getProductLog`;
        par = { id: this.formData.id };
      } else if (
        (this.opType == 3 && this.isDraf == 0) ||
        (this.opType == 3 && this.isDraf == 2) ||
        this.opType == 5
      ) {
        url = `/liability/getProduct`;
        par = { id: this.formData.id };
      } else {
        url = `/liability/getProductDraft`;
        par = { id: this.form.id||this.formData.id };
      }
      http
        .post(url, par)
        .then((res) => {
          // this.$emit('cancelBut','1');
          for (let item of res.data) {
            if (item.liabilityDistribution && item.chirdren.length > 0) {
              this.xhch(item.liabilityDistribution, item.chirdren);
            }
            if (item.availAmount) {
              this.defaultShowKeys.push(item.financialProductId);
            }
          }
          this.financedata = res.data;
          this.showFinance = true;
          console.log(this.financedata)
          let ARRs = this.initFinancedataHd(this.financedata)
          // console.log('ARRs-----------', ARRs);
        }).catch((err) => {});
    },

    // 初始化金融树 处理 返回处理完的新树
    initFinancedataHd(fData) {
      // 遍历树下所有节点
      // console.log('fData----------------', fData);
      let { liabilityDistribution, currencyCode, overalLimit } = this.form
      for (let i=0;i<fData.length;i++) {
        let item = fData[i]
        if (item.isProduct === 0) {
          if (item.liabilityDistribution && item.currencyCode) {
            if (liabilityDistribution === 1) {
              if (currencyCode === item.currencyCode) {
                item.overalLimit = overalLimit
                item.alloPfType = true
              }
            }
          }
        } else if (item.isProduct === 1) {
          if (item.liabilityDistribution && item.currencyCode) {
            let preData = this.financedata.find(ele => ele.treeCode === item.treePcode); // 父节点数据
            if (preData.liabilityDistribution === 1) {
              if (preData.currencyCode === item.currencyCode) {
                item.overalLimit = preData.overalLimit
                item.alloPfType = true
              }
            }
          }
        }
        if (item.chirdren && item.chirdren.length !== 0) {
          this.initFinancedataHd(item.chirdren)
        }
      }
      return fData
    },
    xhch(a, list) {
      for (let item of list) {
        item.disabled = true;
        item.liabilityDistribution = a;
        if (item.availAmount && item.chirdren.length > 0) {
          this.defaultShowKeys.push(item.financialProductId);
        }
        if (item.chirdren.length > 0) {
          this.xhch(a, item.chirdren);
        }
      }
    },
    getCurrency() {
      http
        .post(`/share/currency/queryList`, { cpage: 1, pageSize: 99 })
        .then((res) => {
          this.currencyList = res.data.list;
        })
        .catch((err) => {});
    },
    async sbumit() {
      // let ls = this.cleandata(this.financedata)
      // console.log(ls);
      if(!this.form.nodeName){
        this.$message.error('请输入节点名称')
        return false
      }
      if (!this.form.collateralType) {
        this.$message.error("请选择信用形式");
        return false;
      }
      if (!this.form.colPercentNum) {
        this.$message.error("请输入担保成数");
        return false;
      }
      if (!this.form.startDate) {
        this.$message.error("请选择生效起日");
        return false;
      }
      if (!this.form.endDate) {
        this.$message.error("请选择生效迄日");
        return false;
      }
      if (new Date(this.form.startDate) > new Date(this.form.endDate)) {
        this.$message.error("生效起日不能大于生效迄日");
        return false;
      }
      if (!this.form.liabilityDistribution) {
        this.$message.error("请选择向下分配额度");
        return false;
      }
      if (!this.form.currencyCode) {
        this.$message.error("请选择币种");
        return false;
      }
      if (!this.form.overalLimit) {
        this.$message.error("请输入核准额");
        return false;
      }
      if (!this.form.partialFlag) {
        this.$message.error("请选择贷放型式");
        return false;
      }
      if (!this.form.revolvingFlag) {
        this.$message.error("请选择循环注记");
        return false;
      }
      let [...validateTree] = JSON.parse(JSON.stringify(this.financedata)); // 保证校验的tree和传递的树不会相互影响
      this.form.products = this.financedata;
      await this.validateSubmitTree(validateTree);
      await this.validateValTree(validateTree)
      if (this.opType == 1) {
        this.form.pid = this.yData.islevel ? this.yData.pid : this.yData.id;
      }
      this.form.colPercent = this.form.colPercentNum / 100;
      http.post(`/liability/saveDraft`, this.form).then((res) => {
        this.$message.success("提交成功");
        this.form = res.data
        if(res.data.collateralType==1){
          this.$set(this.form,'colPercentNum',100)
        }else if(res.data.collateralType==2){
          this.$set(this.form,'colPercentNum','0')
        }else{
          this.$set(this.form,'colPercentNum',res.data.colPercent*100)
        }
        this.establish()
        this.opType = 2;
        this.$emit("cancelButRep", "1");
      }).catch((err) => {});
    },
    // 校验树 核准额
    async validateValTree(checkArr) {
      return new Promise((resolve) => {
        // console.log('checkArr--------', checkArr);
        const lt = getAllNodeData(checkArr, [])
        // console.log('lt----------', lt);
        for (let t=0;t<lt.length;t++) {
          let ltem = lt[t]
          if (ltem.treePcode === "0") { // 金融产品树一级节点
            let { liabilityDistribution, currencyCode, overalLimit, nodeName } = this.form
            if (liabilityDistribution === 1) { // 上级分配额度类型 为流用
              if (currencyCode === ltem.currencyCode && ltem.overalLimit !== overalLimit) {
                console.log('12222222232143435345345345300-0-----');
                // 额度类型为流用,币种相同情况下[节点]的核准额与[节点]的核准额必须一致。
                this.$message.error(`额度类型为流用,币种相同情况下【${ltem.productCode}】的核准额与【${nodeName}】的核准额必须一致。`)
                return
              }
            }
          }
          if (ltem.treePcode !== "0") { // 金融产品树二级节点
            let preNode = lt.find(ele => ele.treeCode === ltem.treePcode)
            let { liabilityDistribution, currencyCode, overalLimit, productCode } = preNode
            if (liabilityDistribution === 1) { // 上级分配额度类型 为流用
              if (currencyCode === ltem.currencyCode && ltem.overalLimit !== overalLimit) {
                // 额度类型为流用,币种相同情况下[节点]的核准额与[节点]的核准额必须一致。
                this.$message.error(`额度类型为流用,币种相同情况下【${ltem.productCode}】的核准额与【${productCode}】的核准额必须一致。`)
                return
              }
            }
          }
        }
        // 获取所有节点数组
        function getAllNodeData(json, temp) {
          for(let i=0;i<json.length;i++) {
            let item = json[i]
            temp.push(item)
            if (item.chirdren && item.chirdren.length) {
              getAllNodeData(item.chirdren, temp);
            }
          }
          return temp
        }
        resolve();
      })
    },
    // tree 子节点校验
    async validateSubmitTree(checkArr) {
      return new Promise((resolve) => {
        // 暂时没用到，校验直接提示一级的子节点是否有填写，没有具体到那个字段没填写，如需要，则需用到该数组去做相应提示
        const validateArr = [
          { paramsName: "liabilityDistribution", message: "向下分配额度类型" },
          { paramsName: "currencyCode", message: "币种" },
          { paramsName: "overalLimit", message: "批准额" },
          { paramsName: "startDate", message: "起日" },
          { paramsName: "endDate", message: "迄日" },
        ];
        let lvlTemp = treePhs(checkArr, []);

        if (lvlTemp.length === 0 && this.opType === 2) {
          this.$message.error("请至少选择一种金融产品");
          return;
        }

        let childJson = treeChs(checkArr, []);
        console.log("lvlTemp", lvlTemp);
        let lvl2Temp = treeJhs(checkArr, [], {});
        console.log("lvl2Temp", lvl2Temp);
        for (let l = 0; l < lvl2Temp.length; l++) {
          let num = 0;
          if (lvl2Temp[l].chirdren && lvl2Temp[l].chirdren.length) {
            for (let c = 0; c < lvl2Temp[l].chirdren.length; c++) {
              let tar = lvl2Temp[l].chirdren[c];
              if (
                tar.liabilityDistribution &&
                tar.currencyCode &&
                tar.overalLimit &&
                tar.startDate &&
                tar.endDate
              ) {
                childJson = childJson.filter(
                  (ele) => ele.treePcode !== tar.treePcode
                );
              }
            }
          }
        }
        console.log("childJson", childJson);
        //   用已筛选的childJson 做相应的校验提示
        for (let n = 0; n < childJson.length; n++) {
          let childb = childJson.find((ele) => ele.currencyCode || ele.overalLimit || ele.startDate || ele.endDate)
          if (!childb) {
            let obj = lvl2Temp.find(
              (ele) => ele.treeCode === childJson[n].treePcode
            );
            if(obj){
              this.$message.error(
                `至少选择【${obj.productCode}】下的一种产品授权额度`
              );
              return;
            }

          } else {
            if (!childb.currencyCode) {
              this.$message.error(
                `金融产品【${childb.productCode}】的币种不能为空`
              );
              return;
            }
            if (!childb.overalLimit) {
              this.$message.error(
                `金融产品【${childb.productCode}】的批准额不能为空`
              );
              return;
            }
            if (!childb.startDate) {
              this.$message.error(
                `金融产品【${childb.productCode}】的起日不能为空`
              );
              return;
            }
            if (!childb.endDate) {
              this.$message.error(
                `金融产品【${childb.productCode}】的迄日不能为空`
              );
              return;
            }
          }
        }
        // 获取已选择的一级 满足条件（向下分配额度、币种、批准额、起日、迄日同时有值）
        function treeJhs(json, temp) {
          // let _that = this
          for (let i = 0; i < json.length; i++) {
            let item = json[i];
            //   console.log(item.productCode);
            if (
              item.liabilityDistribution &&
              item.currencyCode &&
              item.overalLimit &&
              item.startDate &&
              item.endDate &&
              item.isProduct === 0
            ) {
              temp.push(item);
            }
          }
          return temp;
        }
        // 一级有的的情况下，获取所有有值的一级下的子节点数据，用于之后判断
        function treeChs(json, temp) {
          for (let i = 0; i < json.length; i++) {
            let item = json[i];
            if (
              item.liabilityDistribution &&
              item.currencyCode &&
              item.overalLimit &&
              item.startDate &&
              item.endDate &&
              item.isProduct === 0
            ) {
              if (item.chirdren && item.chirdren.length) {
                treeChs(item.chirdren, temp);
              }
            } else {
              if (item.isProduct === 1) {
                temp.push(item);
              }
            }
          }
          return temp;
        }
        // 循环tree一级，判断有没有选择金融产品的币种，币种有选择，即会进入接口(接口是这样的)
        function treePhs(json, temp) {
          for (let i = 0; i < json.length; i++) {
            let item = json[i];
            if (item.currencyCode) {
              temp.push(item);
            }
          }
          return temp;
        }
        resolve();
      });
    },

    cleandata(data) {
      let list = [];
      for (let item of data) {
        if (
          item.liabilityDistribution &&
          item.currencyCode &&
          item.overalLimit &&
          item.startDate &&
          item.endDate
        ) {
          list.push(item);
        }
        if (item.chirdren && item.chirdren.length > 0) {
          this.cleandata(item.chirdren);
        }
      }
      return list;
    },
    cancelBut() {
      this.$emit("cancelButRep");
    },
    imgPathUrl(data) {
      let { isProduct } = data;
      let imgPath = "";

      if (isProduct === 0) {
        imgPath = require("@/assets/images/tree/node_root.png");
      } else {
        imgPath = require("@/assets/images/tree/node_leaf.png");
      }
      return imgPath;
    },
    linkcoll() {
      this.DestroyIncomeStatistics = false;
      setTimeout(() => {
        this.DestroyIncomeStatistics = true;
        this.dataFormVisible = true;
      },300);
    },
    cancelButDet(t) {
      // if(t==1){ this.getData()}
      this.dataFormVisible = false;
      setTimeout(()=>{
        this.DestroyIncomeStatistics = false
      },500)
    },
    // dataCheck(date,id,name){
    //     http.post(`/liabilityCol/isHoliday`,{date,id}).then((res)=>{
    //         if(res.data==1){
    //             this.form[name] = ''
    //             this.$message.error('当前日期为节假日')
    //         }
    //     }).catch(err=>{});
    // },
    delfinance(data) {
      http.post(`/liability/delProductDraft`, { id: data.id })
        .then((res) => {
          this.$message.success("操作成功");
          this.delData(data.financialProductId, this.financedata);
        })
        .catch((err) => {});
    },
    liabiCh(e, data) {
      // console.log(e,data);
      // this.repList(e, data.financialProductId, this.financedata);
      // -----------之前版本分割线 以上是之前版本，下面是更新后代码 版本-------------

      // 描述:
      if (data.isProduct === 0) { // 二级的额度分配 选择不考虑，因为二级的核准额 是根据一级的额度分配类型，币种来判断。而不是本身
        let { liabilityDistribution, currencyCode, overalLimit } = this.form
        if (liabilityDistribution === 1) { // 上级分配额度类型 为流用 需求:上级类型是流用，下级币种和上级相同 批准额等于上级的批准额
          if (currencyCode === data.currencyCode) {
            data.overalLimit = overalLimit
            data.alloPfType = true
          } else {
            data.overalLimit = ''
            data.alloPfType = false
          }
        }
      }
      if (data.chirdren && data.chirdren.length !== 0 && data.isProduct === 0) {
        let finData = JSON.parse(JSON.stringify(this.financedata))
        if (data.liabilityDistribution === 1) {  //流用
          this.nodeDownStus(finData, data)
        } else { // 分享
          this.nodeDownStus1(finData, data)
        }
        for(let i in this.financedata){
          if (finData[i].liabilityDistribution) {
            this.defaultShowKeys.push(finData[i].financialProductId);
          }
          this.$set(this.financedata,i,finData[i])
        }
      }
    },
    nodeDownStus(json, data) {
      for (let i=0;i<json.length;i++) {
        let item = json[i]
        if (data.treeCode === item.treePcode) {
          // debugger;
          item.liabilityDistribution = data.liabilityDistribution
          item.disabled = true
          if (item.currencyCode && data.overalLimit) {
            if (item.currencyCode === data.currencyCode) {
              item.overalLimit = data.overalLimit
              item.alloPfType = true
            } else {
              item.overalLimit = ''
              item.alloPfType = false
            }
          }
        }
        if (item.chirdren && item.chirdren.length !== 0) {
          this.nodeDownStus(item.chirdren, data)
        }
      }
      //
    },
    nodeDownStus1(json, data) {
      for (let i=0;i<json.length;i++) {
        let item = json[i]
        if (data.treeCode === item.treePcode) {
          item.overalLimit = ''
          item.alloPfType = false
          item.liabilityDistribution = data.liabilityDistribution
          item.disabled = true
        }
        if (item.chirdren && item.chirdren.length !== 0) {
          this.nodeDownStus1(item.chirdren, data)
        }
      }
    },

    repList(a, b, list) {
      for (let item of list) {
        if (item.financialProductId == b) {
          this.chirdrenData(a, item.chirdren);
        } else if (item.chirdren) {
          this.repList(a, b, item.chirdren);
        }
      }
    },
    chirdrenData(a, list) {
      // console.log(a);
      for (let item of list) {
        if (a == 2 || a == 1) {
          item.liabilityDistribution = a;
          item.disabled = true;
        } else {
          item.liabilityDistribution = "";
          item.disabled = false;
        }
        if (item.chirdren) {
          this.chirdrenData(a, item.chirdren);
        }
      }
      this.$forceUpdate();
    },
    delData(a, list) {
      for (let item of list) {
        if (item.financialProductId == a) {
          // console.log(item.id);
          // item = {}
          item.id = null;
        //   item.liabilityDistribution = null;
          item.currencyCode = null;
          item.overalLimit = null;
          item.earmarkAmount = null;
          item.utilizedAmount = null;
          item.availAmount = null;
          item.startDate = null;
          item.endDate = null;
          this.delchirdrenData(item.chirdren);
          this.$forceUpdate();
          return "";
        } else if (item.chirdren) {
          this.delData(a, item.chirdren);
        }
      }
    },
    delchirdrenData(data) {
      for (let item of data) {
        item.id = null;
        // item.liabilityDistribution = null;
        item.currencyCode = null;
        item.overalLimit = null;
        item.earmarkAmount = null;
        item.utilizedAmount = null;
        item.availAmount = null;
        item.startDate = null;
        item.endDate = null;
      }
      if (data.chirdren.length > 0) {
        this.delchirdrenData(data.chirdren);
      }
    },

    // 币种 变更方法
    ccyChange(val, data) {
      let { isProduct, treePcode } = data
      // console.log(treePcode);
      switch(treePcode) {
        case '0': {
          let { liabilityDistribution, currencyCode, overalLimit } = this.form
          if (liabilityDistribution === 1) {
            if (currencyCode === data.currencyCode) {
              data.overalLimit = overalLimit
              data.alloPfType = true
            } else {
              data.overalLimit = ''
              data.alloPfType = false
            }
          }
          let finData = JSON.parse(JSON.stringify(this.financedata))
          for(let i in this.financedata){
            this.$set(this.financedata,i,finData[i])
          }
          // this.nodeDownStus(this.financedata, data)
          break;
        }
        default: {
          let preData = this.financedata.find(ele => ele.treeCode === data.treePcode)
          let { liabilityDistribution, currencyCode, overalLimit } = preData
          if (liabilityDistribution === 1) {
            if (currencyCode === data.currencyCode) {
              data.overalLimit = overalLimit
              data.alloPfType = true
            } else {
              data.overalLimit = ''
              data.alloPfType = false
            }
          }
          let finData = JSON.parse(JSON.stringify(this.financedata))
          for(let i in this.financedata){
            this.$set(this.financedata,i,finData[i])
          }
          break;
        }
      }
    },

    dataCheck(date, data, name, type) {
      switch (type) {
        case "isForm": {
          if (this.startDate && this.endDate) {
            const CUR_DATE = new Date(date.substr(0, 10))
            const OTHER_DATE_NAME = name === 'startDate' ? 'endDate' : 'startDate'
            const OTHER_DATE_MES_STR = OTHER_DATE_NAME === 'startDate' ? '生效起日' : '生效迄日'
            switch(name) {
              case 'startDate' : {
                if (CUR_DATE < new Date(this[name].substr(0, 10))) {
                  this.form[name] = ''
                  this.$message.error(`生效起日不能小于上一节点的生效起日${this[name].substr(0, 10)}`)
                  return
                }
                if (CUR_DATE > new Date(this[OTHER_DATE_NAME].substr(0, 10))) {
                  this.form[name] = ''
                  this.$message.error(`生效起日不能大于上一节点的生效迄日${this[OTHER_DATE_NAME].substr(0, 10)}`)
                  return
                }

                if (this.form[OTHER_DATE_NAME]) {
                  if (CUR_DATE > new Date(this.form[OTHER_DATE_NAME].substr(0, 10))) {
                    this.form[name] = ''
                    this.$message.error(`生效起日不能大于生效迄日${this.form[OTHER_DATE_NAME].substr(0, 10)}`)
                    return
                  }
                }
                break;
              }
              case 'endDate' : {
                if (CUR_DATE > new Date(this[name].substr(0, 10))) {
                  this.form[name] = ''
                  this.$message.error(`生效迄日不能大于上一节点的生效迄日${this[name].substr(0, 10)}`)
                  return
                }
                if (CUR_DATE < new Date(this[OTHER_DATE_NAME].substr(0, 10))) {
                  this.form[name] = ''
                  this.$message.error(`生效迄日不能小于上一节点的生效起日${this[OTHER_DATE_NAME].substr(0, 10)}`)
                  return
                }
                if (this.form[OTHER_DATE_NAME]) {
                  if (CUR_DATE < new Date(this.form[OTHER_DATE_NAME].substr(0, 10))) {
                    this.form[name] = ''
                    this.$message.error(`生效迄日不能小于生效起日${this.form[OTHER_DATE_NAME].substr(0, 10)}`)
                    return
                  }
                }
                break;
              }
              default: {
                break;
              }
            }
          }
          // form表单上的日期 只需清空相应的表单日期
          const params = {
            date,
            id: this.formData.enterpriseId
          }
          http.post(`/liabilityCol/isHoliday`, params)
            .then((res) => {
              if (res.data == 1) {
                this.form[name] = "";
                this.$message.error("当前日期为节假日");
              }
            })
            .catch((err) => {});
          break;
        }
        case "isTree": {
          // 金融树tree的日期
          if (name === "endDate") {
            if (!this.form.endDate) {
              // tree的迄日需要根据 表单的额度到期日判断 故额度到期日不能为空
              this.$message.error("请选择额度到期日");
              return;
            }
            if (date) {
              if (data.startDate) { // 起日存在
                let mesStr = `金融产品【${data.productCode}】的迄日不能小于起日`;
                let oDate1 = new Date(date.substr(0, 10));
                let oDate2 = new Date(data.startDate.substr(0, 10));
                if (oDate1.getTime() < oDate2.getTime()) {
                  this.$message.error(mesStr);
                  this.checkDataq(this.financedata, data, name);
                  return;
                }
              }
              // 额度到期日不为空进行
              // tree的迄日 不能大于额度到期日
              if (data.treePcode == 0) {
                // 只判断isProduct为0 非产品的情况 isProduct为0的情况 提示直接接口返回
                let { endDate } = this.form;
                let mesStr = `金融产品【${data.productCode}】的迄日不能大于生效迄日`;
                let oDate1 = new Date(date.substr(0, 10));
                let oDate2 = new Date(endDate.substr(0, 10));
                if (oDate1.getTime() > oDate2.getTime()) {
                  this.$message.error(mesStr);
                  this.checkDataq(this.financedata, data, name);
                  return;
                }
              } else {
                let list = this.returntreePcode(this.financedata, data.treePcode, 'endDate', {})
                let { productCode, pDate } = list
                if (!pDate) {
                  // tree的迄日需要根据 表单的额度到期日判断 故额度到期日不能为空
                  data.endDate = ""
                  this.$message.error(`请选择金融产品【${productCode}】的迄日`);
                  return;
                }
                let oDate1 = new Date(data.endDate.substr(0, 10));
                let oDate2 = new Date(pDate.substr(0, 10));
                if (oDate1.getTime() > oDate2.getTime()) {
                  data.endDate = ""
                  this.$message.error(`金融产品【${data.productCode}】的迄日不能大于上一节点的迄日`);
                  return;
                }
              }
            }
          }

          if (name === "startDate") {
            if (!this.form.startDate) {
              // tree的迄日需要根据 表单的额度到期日判断 故额度到期日不能为空
              this.$message.error("请选择额度起日");
              return;
            }

            if (date) {
              if (data.endDate) { // 迄日存在
                let mesStr = `金融产品【${data.productCode}】的起日不能大于迄日`;
                let oDate1 = new Date(date.substr(0, 10));
                let oDate2 = new Date(data.endDate.substr(0, 10));
                if (oDate1.getTime() > oDate2.getTime()) {
                  this.$message.error(mesStr);
                  this.checkDataq(this.financedata, data, name);
                  return;
                }
              }
              // 额度到期日不为空进行
              // tree的迄日 不能大于额度到期日
              if (data.treePcode == 0) {
                // 只判断isProduct为0 非产品的情况 isProduct为0的情况 提示直接接口返回
                let { startDate } = this.form;
                let mesStr = `金融产品【${data.productCode}】的起日不能早于生效起日`;
                let oDate1 = new Date(date.substr(0, 10));
                let oDate2 = new Date(startDate.substr(0, 10));
                if (oDate1.getTime() < oDate2.getTime()) {
                  this.$message.error(mesStr);
                  this.checkDataq(this.financedata, data, name);
                  return;
                }
              } else {
                let list = this.returntreePcode(this.financedata, data.treePcode, 'startDate', {})
                let { productCode, pDate } = list
                console.log('list', list);
                console.log('productCode, pDate', productCode, pDate);
                if (!pDate) {
                  // tree的迄日需要根据 表单的额度到期日判断 故额度到期日不能为空
                  data.startDate = ""
                  this.$message.error(`请选择金融产品【${productCode}】的起日`);
                  return;
                }
                let oDate1 = new Date(data.startDate.substr(0, 10));
                let oDate2 = new Date(pDate.substr(0, 10));
                if (oDate1.getTime() < oDate2.getTime()) {
                  data.startDate = ""
                  this.$message.error(`金融产品【${data.productCode}】的起日不能小于上一节点的起日`);
                  return;
                }
              }
            }
          }

          // 判断是否节假日
          http
            .post(`/liabilityCol/isHoliday`, {
              date,
              id: this.formData.enterpriseId,
            })
            .then((res) => {
              if (res.data == 1) {
                this.checkDataq(this.financedata, data, name);
                this.$message.error("当前日期为节假日");
              }
            })
            .catch((err) => {});
          break;
        }
        default:
          break;
      }
    },
    /**
     * json 金融产品tree data
     * treePcode
     * name 起日或者迄日名
     * date 上一节点的起日或者迄日
     */
    returntreePcode(json, treePcode, name, list) {
      for (let i=0;i<json.length;i++) {
        let item = json[i]
        if (item.treeCode === treePcode) {
          list = Object.assign({}, { pDate: item[name], productCode: item.productCode })
        }
      }
      return list
    },
    checkDataq(obj, data, name) {
      for (let item of obj) {
        if (item.financialProductId == data.financialProductId) {
          item[name] = "";
          this.$forceUpdate();
          return;
        }
        if (item.chirdren.length > 0) {
          this.checkDataq(item.chirdren, data, name);
        }
      }
    },
    collateralChange(e){
      if(e==1){
        this.$set(this.form,'colPercentNum',100)
      }else if(e==2){
        this.$set(this.form,'colPercentNum','0')
      }else{
        this.$set(this.form,'colPercentNum','')
      }
    },
    setChange() {
      // liabilityDistribution 1流用 2分享
      // currencyCode 币种
      // overalLimit 批准额
      if (this.opType == 1) {
        if (this.form.currencyCode) {
          if (this.liabilityDistribution === 1) { // 上级分配额度类型 为流用 需求:上级类型是流用，下级币种和上级相同 批准额等于上级的批准额
            if (this.currencyCode === this.form.currencyCode) {
              // this.form.overalLimit = this.overalLimit
              this.$set(this.form, 'overalLimit', this.overalLimit)
              this.amouDis = true
            } else {
              let { overalLimit } = this.formData
              this.$set(this.form, 'overalLimit', overalLimit ? overalLimit : '')
              this.amouDis = false
            }
          }
        }
      }
    }
  },
};
</script>
<style lang="scss" scoped>
.reply_form {
  padding: 10px 70px;
}
::v-deep .is-right{
  .el-input__inner{
    font-family: 'SourceHanSansCN';
    padding-right: 5px;
    font-size: 13px;
  }
}
.el-tree {
  background: none !important;
}

.left_30 {
  margin-left: 106px;
}
//   .flex-tree {
/* position: relative; */
//   padding: 8px;
// background-color: #fff;

// }
.my-tree {
  padding-bottom: 20px;
  overflow: auto;
}
.my-tree ::v-deep .el-tree-node__content {
  height: 37px !important;
}
.my-tree::-webkit-scrollbar {
  width: 0 !important;
}

.tree-menu {
  position: absolute;
  top: 10px;
  width: 116px;
  background: #ffffff;
  box-shadow: 0px 3px 11px 0px rgba(0, 0, 0, 0.3);
  // transition: all .3s;
  .tree-menu-body {
    position: relative;
    .tree-menu-item {
      height: 28px;
      font-size: 12px;
      color: #212121;
      display: flex;
      align-items: center;
      padding: 0 10px;
      cursor: pointer;
      &:hover {
        background: #e5f3ff;
      }
    }
    &:after {
      content: " ";
      border-width: 6px;
      position: absolute;
      display: block;
      width: 0;
      height: 0;
      border-color: transparent;
      border-style: solid;
      top: 10px;
      left: -4px;
      border-right-color: #fff;
      border-left-width: 0;
    }
  }
}
.flex-tree {
  .el-scrollbar {
    ::v-deep.el-scrollbar__wrap {
      overflow-x: hidden !important;
    }
  }
}

// tree 提示线
.my-tree {
  ::v-deep .el-tree-node {
    position: relative;
    padding-left: 16px; // 缩进量
  }
  ::v-deep .el-tree-node__children {
    padding-left: 16px; // 缩进量
    overflow: inherit;
  }

  // 竖线
  ::v-deep .el-tree-node::before {
    content: "";
    height: 100%;
    width: 1px;
    position: absolute;
    left: 0;
    // top: -6px;
    border-width: 1px;
    border-left: 1px solid #707070;
  }
  // 当前层最后一个节点的竖线高度固定
  ::v-deep .el-tree-node:last-child::before {
    height: 21px; // 可以自己调节到合适数值
  }

  // 横线
  ::v-deep .el-tree-node::after {
    content: "";
    width: 29px;
    height: 20px;
    position: absolute;
    left: 0;
    top: 19px;
    border-width: 1px;
    border-top: 1px solid #707070;
  }
  ::v-deep .el-tree-node {
    .el-tree-node__children {
      margin-left: 3px;
      .el-tree-node::before {
        content: "";
        height: 100%;
        width: 1px;
        position: absolute;
        left: 2px;
        top: -7px;
        border-width: 1px;
        border-left: 1px solid #707070;
      }
      .el-tree-node::after {
        content: "";
        width: 30px;
        position: absolute;
        left: 2px;
        top: 19px;
        border-width: 1px;
        border-top: 1px solid #707070;
      }
      .el-tree-node:last-child::before {
        height: 71% !important;
      }
    }
  }

  // // 去掉最顶层的虚线，放最下面样式才不会被上面的覆盖了
  // ::v-deep & > .el-tree-node::after {
  //   // border-top: none;
  // }
  // ::v-deep & > .el-tree-node::before {
  //   // border-left: none;
  // }
  ::v-deep .expanded:before {
    content: "\e722";
  }
  ::v-deep .el-tree-node__expand-icon.expanded {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  ::v-deep .el-tree-node__expand-icon:hover {
    color: #2058c9;
  }
  ::v-deep .el-icon-caret-right::before {
    content: "\e723";
  }

  //   ::v-deep .el-tree-node__expand-icon::before {
  // box-shadow: 0px 1px 4px 0px #536183;
  // border-radius: 50%;
  // background: #FFFFFF;
  // margin-left: 2px;
  //   }

  ::v-deep
    .el-tree-node.is-current
    > .el-tree-node__content
    > .custom-tree-node {
    // background: #fff;
    // display: flex;
    // position: relative;
    .node-cnt {
      padding: 4px 30px 4px 4px;
      background: #3d5596;
      box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.35);
      border-radius: 2px;
      transition: all 0.3s;
      .node-sp {
        color: #ffffff;
      }
    }
  }
  ::v-deep .node-cnt {
    padding: 4px;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 9;
    background: #fbfdff;
    .node-img {
      width: 20px;
      height: 20px;
      margin-right: 4px;
    }
    .node-sp {
      color: #212121;
      font-size: 13px;
      font-family: 'SourceHanSansCN';
    }
  }

  //   // 展开关闭的icon
  //   ::v-deep .el-tree-node__expand-icon {
  //     font-size: 18px;
  //     color: #212121;
  //     // 叶子节点（无子节点）
  //     &.is-leaf{
  //       color: transparent;
  //       // display: none; // 也可以去掉
  //     }
  //     &.is-leaf:before{
  //       font-size: 0;
  //       content: "\e722";
  //       // display: none; // 也可以去掉
  //     }
  //   }
}
.tab_input {
  position: absolute;
  z-index: 9;;
  top: 0;
  height: 37px;
  background: #fbfdff;
  border-bottom: 1px solid #a0adcd;
  border-left: 1px solid #a0adcd;
  border-right: 1px solid #a0adcd;
}
.tab_input {
    span {
    display: inline-block;
    width: 95px;
    line-height: 37px;
    margin-right: 4px;
    float: left;
    text-align: center;
    font-size: 13px;
    font-family: 'SourceHanSansCN';
    border-right: 1px solid #a0adcd;
      &:nth-child(3),
      &:nth-child(4),
      &:nth-child(5),
      &:nth-child(6)
      {
        text-align: right;
        padding-right: 5px;
      }
    a{
      display: inline-block;
      line-height: 32px;
    }
    &:last-child{
      border-right: unset;
      .el-button{
        height: 37px;
      }
    }
    ::v-deep .require-input{
      height: 36px;
     .el-input{
          height: 28px !important;
          border: 1px solid #267CD5;
          border-radius: 2px;
          box-shadow: 0px 2px 0px 0px #96AABA ,
          1px 5px 7px 0px rgba(12, 19, 36, 0.21),
          1px 1px 0px 0px #FFFFFF,
          1px 1px 0px 0px #FFFFFF,
          1px 1px 0px 0px #FFFFFF,
          1px 1px 0px 0px #FFFFFF ;
          .el-input__inner {
            height: 19px;
            line-height: 28px;
            background: linear-gradient(180deg, #FFFFFF, #EAF8FF) !important;
            background-color: unset;
            box-shadow: none;
          }
        }
    }
    // ::v-deep .el-select{
    //   height: 28px;
    //   .el-input{
    //     line-height: 28px !important;
    //   }
    // }
    div{
      height: 37px;
      ::v-deep .el-input{
        line-height: 28px !important;
      }
    }

  }
}
.el-date-editor ::v-deep .el-input__inner {
  font-size: 13px;
  font-family: 'SourceHanSansCN';
  // color: #707070 !important;
  // -webkit-box-shadow: 1px 1px 2px 0px rgb(0 0 0 / 40%) inset !important;
  // box-shadow: 1px 1px 2px 0px rgb(0 0 0 / 40%) inset !important;
  // background: #e6e6e6 !important;
}
.el-date-editor {
  ::v-deep .el-input__suffix {
    right: -3px !important;
  }
}
.el-select ::v-deep .el-input__inner {
  font-size: 13px;
  font-family: 'SourceHanSansCN';
  // color: #707070 !important;
  // -webkit-box-shadow: 1px 1px 2px 0px rgb(0 0 0 / 40%) inset !important;
  // box-shadow: 1px 1px 2px 0px rgb(0 0 0 / 40%) inset !important;
  // background: #e6e6e6 !important;
}
.cur-ipt ::v-deep .el-input__inner {
  padding: 0 15px 0 0;
}
// .cur-ipt ::v-deep .el-input__suffix {
//   right: 10px!important;
// }
.finance {
  margin: 8px 15px;
  background: rgba(212, 235, 254, 0.1);
  border: 1px solid rgba(61, 85, 150, 0.1);
  .finance-header {
    padding: 0;
    margin: 0;
    font-size: 14px;
    margin-left: 266px;
    height: 30px;
    line-height: 30px;
    font-family: "SourceHanSansCN";
    font-weight: 500;
    color: #ffffff;
    border-radius: 4px 4px 0px 0px;
    background: url('~@/assets/images/tabhead1.png') no-repeat;
    background-position: 93% 80%;
    span {
      width: 100px;
      display: inline-block;
      text-align: center;
    }
  }
  // 添加滚动条
  ::v-deep .el-row {
    height: 372px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-right: unset !important;
    padding-bottom: 10px !important;
  }

  /* 修改原生滚动条的样式 */
  ::-webkit-scrollbar {
    // width: 8px;
    cursor: pointer;
    box-shadow: inset 0 0 6px rgba($color: #000000, $alpha: 0.3);
    width: 10px;
    border-radius: 5px;
  }

  /* Track */
  ::-webkit-scrollbar-track {
    // -webkit-border-radius: 2px;
    // border-radius: 2px;
    // background: rgba(181, 182, 183, 0.2);
    background: transparent;
  }

  /* Handle */
  ::-webkit-scrollbar-thumb {
    box-shadow: inset 0 0 6px rgba($color: #000000, $alpha: 0.4);
    width: 6px;
    height:15px ;
    background: linear-gradient(0deg, #5683D4,#95B9FA );
    border-radius: 5px;
  }
}
// 树文字后面的虚线
.lint {
  padding: 0;
  margin: 0;
  width: 50%;
  height: 1px;
  border-bottom: 1px dashed rgba($color: #3d5596, $alpha: 0.5);
  position: absolute;
  top: 15px;
  z-index: 0;
}
.el-tree-node__content:hover {
  background: #fbfdff !important;
}
.el-tree-node.is-current > .el-tree-node__content {
  background: #fbfdff !important;
}
.span_desc {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.span_color {
  border: 1px solid red;
  height: 25px !important;
}
</style>
<style scoped>
/* 未展开 */
.el-tree /deep/ .el-icon-caret-right:before {
  background: url("../../assets/images/zijiadd.png") no-repeat 0 0px;
  content: "" !important;
  display: block;
  width: 24px;
  height: 24px;
  font-size: 16px;
  background-size: 24px;
}
/* 展开 */
.el-tree /deep/ .el-tree-node__expand-icon.expanded.el-icon-caret-right:before {
  background: url("../../assets/images/zijicut.png") no-repeat 0 0px;
  content: "" !important;
  display: block;
  width: 24px;
  height: 24px;
  font-size: 16px;
  background-size: 24px;
}
.el-tree /deep/.el-tree-node__expand-icon.is-leaf::before {
  background: none !important;
  content: "" !important;
  display: block;
  width: 0px;
  height: 0px;
  font-size: 0px;
  background-size: 0px;
}
.finance /deep/.el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: 115px !important;
}
.finance /deep/.el-input--prefix .el-input__inner {
  padding-right: 0 !important;
}
.finance /deep/ .el-tree-node__content:hover {
  background-color: #fff;
}
.finance /deep/ .el-tree-node__content {
  padding-left: 4px !important;
}
.finance /deep/ .el-tree-node.is-current > .el-tree-node__content {
  background-color: #fff;
}

.finance /deep/ .el-tree-node:focus > .el-tree-node__content,
.finance /deep/ .el-tree-node.is-expanded > .el-tree-node__content,
.finance /deep/ .el-tree-node.is-focusable > .el-tree-node__content {
  background-color: rgba(0, 0, 0, 0);
}

.cur-sp {
  padding: 0 0 0 24px;
  text-align: left!important;
}
</style>
