<template>
  <div class="app-container">
    <div class="tab-header webtop">
      <div>{{title}}</div>
      <div>
        <el-button type="primary" size="small" :disabled="submitdisabled" @click="saveOrUpdate">保存</el-button>
        <el-button type="info" size="small" icon="el-icon-close" @click="handleReturn()">关闭</el-button>
      </div>
    </div>

    <div style="padding-bottom: 150px;" class="listconadd">
      <el-steps :active="stepIndex" simple style="margin-top: 20px;">
        <el-step title="基础信息" @click.native="stepClick(1)"></el-step>
        <el-step title="关联仓库" @click.native="stepClick(2)"></el-step>
        <el-step title="关联企业" @click.native="stepClick(3)"></el-step>
        <el-step title="关联账户" @click.native="stepClick(4)"></el-step>
        <el-step title="关联章证" @click.native="stepClick(5)"></el-step>
      </el-steps>

      <div v-show="stepIndex==1" style="margin-top: 30px;">

        <el-form ref="dataForm" :model="formobj.baseInfo" label-position="top" label-width="190px" class="formadd">
          <el-row style="border-top: 1px solid #e0e3eb;">
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">项目名称</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-input v-model="formobj.baseInfo.entryName" placeholder="请输入项目名称" style="width:100%"
                  class="addinputw" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">所属行业</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-select v-model="formobj.baseInfo.industryName" class="addinputw" placeholder="请选择所属行业"
                  style="width:100%" @change="getHangYe">
                  <el-option v-for="item in industryList" :key="item.dictKey" :label="item.dictValue"
                    :value="item.dictKey" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">项目类型</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-select v-model="formobj.baseInfo.typeName" class="addinputw" placeholder="请选择项目类型"
                  style="width:100%" @change="getType">
                  <el-option v-for="item in typeList" :key="item.dictKey" :label="item.dictValue"
                    :value="item.dictKey" />
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">质押率(%)</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-input v-model="formobj.baseInfo.bankPledgeRate" placeholder="请输入标准质押率" style="width:100%"
                  class="addinputw" clearable />
              </el-form-item>
            </el-col>

          </el-row>

          <el-row>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">贷款行</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-select v-model="formobj.baseInfo.bankName" class="addinputw" placeholder="请选择贷款行" style="width:100%"
                  @change="getBank">
                  <el-option v-for="item in bankList" :key="item.dictKey" :label="item.dictValue"
                    :value="item.dictKey" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="trightbs">
              <el-form-item class="trightb_item">
                <span slot="label">客户经理</span>
              </el-form-item>
            </el-col>
            <el-col :span="8" class="trightb_items">
              <el-form-item class="trightb_item">
                <el-select v-model="formobj.baseInfo.bmanagerName" class="addinputw" placeholder="请选择客户经理"
                  style="width:100%" @change="getBManager">
                  <el-option v-for="item in bManagerList" :key="item.dictKey" :label="item.dictValue"
                    :value="item.dictKey" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">授信额度</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-input v-model="formobj.baseInfo.creditLimit" placeholder="请输入授信额度" style="width:100%"
                  class="addinputw" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">授信日期</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-date-picker v-model="formobj.baseInfo.engaDate" type="date" style="width:100%"
                  value-format="yyyy-MM-dd" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">签约日期</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-date-picker v-model="formobj.baseInfo.signingDate" type="date" style="width:100%"
                  value-format="yyyy-MM-dd" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">放款日期</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-date-picker v-model="formobj.baseInfo.loanDate" type="date" style="width:100%"
                  value-format="yyyy-MM-dd" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">项目说明</span>
              </el-form-item>
            </el-col>
            <el-col :span="20">
              <el-form-item class="trightb_item">
                <el-input v-model="formobj.baseInfo.remarks" placeholder="请输入项目说明"
                  style="width:100%;margin-bottom: 5px;" type="textarea" :rows="7" class="addinputw" clearable />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">监管负责人</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-input v-model="formobj.baseInfo.regulatoryLeader" placeholder="请输入监管负责人" style="width:100%"
                  class="addinputw" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">监管主管</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-input v-model="formobj.baseInfo.regulatorySupervisor" placeholder="请输入监管主管" style="width:100%"
                  class="addinputw" clearable />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">结束日期</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-date-picker v-model="formobj.baseInfo.endDate" type="date" style="width:100%"
                  value-format="yyyy-MM-dd" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">填表日期</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-date-picker v-model="formobj.baseInfo.fillInDate" type="date" style="width:100%"
                  value-format="yyyy-MM-dd" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>

          </el-row>

          <el-row>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">项目状态</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-select v-model="formobj.baseInfo.stateName" class="addinputw" placeholder="请选择项目状态"
                  style="width:100%" @change="getStateName">
                  <el-option v-for="item in stateList" :key="item.dictKey" :label="item.dictValue"
                    :value="item.dictKey" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="trightb">
              <el-form-item class="trightb_item">
                <span slot="label">项目状态说明</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="trightb_item">
                <el-input v-model="formobj.baseInfo.stateRemarks" placeholder="" :readonly="true" style="width:100%"
                  class="addinputw" clearable />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <div v-show="stepIndex==2" style="margin-top: 10px;">

        <div class="step2Item">

          <el-select v-model="cangKu.name" class="addinputw" placeholder="请选择仓库" style="width:20%" @change="getCangku">
            <el-option v-for="item in tableAllList" :label="item.dictValue" :value="item.dictKey" />
          </el-select>

          <span class="step2ItemBtn" @click="addCangku()">添加</span>

        </div>

        <el-table :data="formobj.warehouse" border style="width: 98%;margin-left: 15px;margin-top: 10px;">
          <!-- <el-table-column type="selection" align="center" width="50"/> -->
          <el-table-column label="操作" wid align="center" width="116">
            <template slot-scope="scope">
              <el-button type="primary" size="mini" @click="doDel(scope.row)">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column label="仓库名称" prop="name" width="350" align="center" />
          <el-table-column label="仓库地址" prop="address" align="center" />
          <el-table-column label="联系人" prop="linkerName" width="200" align="center" />
          <el-table-column label="联系电话" prop="linkerPhone" width="200" align="center" />
        </el-table>


      </div>

      <div v-show="stepIndex==3" style="margin-top: 10px;">


        <div class="step2Item">

          <el-select v-model="enterprise.name" class="addinputw" placeholder="请选择企业" style="width:20%"
            @change="getEnterName">
            <el-option v-for="item in enterpriseAllList" :label="item.dictValue" :value="item.dictKey" />
          </el-select>

          <span class="step2ItemBtn" @click="addEnterprise()">添加</span>

        </div>

        <el-table :data="formobj.enterpriseList" border style="width: 98%;margin-left: 15px;margin-top: 10px;">
          <!-- <el-table-column type="selection" align="center" width="50"/> -->
          <el-table-column label="操作" wid align="center" width="116">
            <template slot-scope="scope">
              <el-button type="primary" size="mini" @click="doDel2(scope.row)">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column label="关联类型" prop="type" align="center" />
          <el-table-column label="企业名称" prop="enterpriseName" align="center" />
          <el-table-column label="联系人" prop="contacts" align="center" />
          <el-table-column label="联系电话" prop="telephone" align="center" />
        </el-table>
      </div>

      <div v-show="stepIndex==4" style="margin-top: 30px; width: 100%;">


        <div class="step4item">

          <div class="step4item-lift">

            <div style="display: flex;flex-direction: row;justify-content: space-between;align-items: center;">
              <span class="item-title">请填写账户信息</span>
              <span class="step2ItemBtn" style="margin-right: 30px;" @click="addBanK">添加</span>
            </div>

            <div class="step4item-lift-item">
              <span class="item-text">账户类型：</span>
              <el-select v-model="bankInfo.bankType" class="addinputw" placeholder="请选择类型" style="width:70%"
                @change="getBankType">
                <el-option v-for="item in bankType" :label="item.dictValue" :value="item.dictKey" />
              </el-select>

            </div>

            <div class="step4item-lift-item">
              <span class="item-text">所属企业：</span>
              <el-select v-model="bankInfo.bankEnterprise" class="addinputw" placeholder="请选择企业" style="width:70%"
                @change="getBankEnterprise">
                <el-option v-for="item in enterpriseRelevanceList" :label="item.dictValue" :value="item.dictKey" />
              </el-select>

            </div>

            <div class="step4item-lift-item">
              <span class="item-text">银行账号：</span>
              <el-input v-model="bankInfo.bankNum" placeholder="请输入账号" style="width:70%" class="addinputw" clearable />

            </div>

            <div class="step4item-lift-item">
              <span class="item-text">开户银行：</span>
              <el-input v-model="bankInfo.bankName" placeholder="请输入账号" style="width:70%" class="addinputw" clearable />

            </div>

          </div>

          <div class="step4item-right">

            <el-table :data="formobj.bankList" border>
              <el-table-column label="操作" wid align="center" width="116">
                <template slot-scope="scope">
                  <el-button type="primary" size="mini" @click="doDel3(scope.row)">删除</el-button>
                </template>
              </el-table-column>
              <el-table-column label="账户类型" prop="accountType" align="center" />
              <el-table-column label="所属企业" prop="enterpriseName" align="center" />
              <el-table-column label="银行账号" prop="accountNumber" align="center" />
              <el-table-column label="开户银行" prop="bank" align="center" />

            </el-table>
          </div>


        </div>


      </div>

      <div v-show="stepIndex==5" style="margin-top: 30px;">

        <div class="step4item">

          <div class="step4item-lift">

            <div style="display: flex;flex-direction: row;justify-content: space-between;align-items: center;">
              <span class="item-title">请填写章证信息</span>
              <span class="step2ItemBtn" style="margin-right: 30px;" @click="addIdCard">添加</span>
            </div>

            <div class="step4item-lift-item">
              <span class="item-text">章证类型：</span>
              <el-select v-model="idCardInfo.idCardType" class="addinputw" placeholder="请选择类型" style="width:70%"
                @change="getIdCardType">
                <el-option v-for="item in idCardType" :label="item.dictValue" :value="item.dictKey" />
              </el-select>

            </div>

            <div class="step4item-lift-item">
              <span class="item-text">所属企业：</span>
              <el-select v-model="idCardInfo.idCardEnterprise" class="addinputw" placeholder="请选择企业" style="width:70%"
                @change="getIdCardEnterprise">
                <el-option v-for="item in enterpriseRelevanceList" :label="item.dictValue" :value="item.dictKey" />
              </el-select>

            </div>

            <div class="step4item-lift-item">
              <span class="item-text">章证名称：</span>
              <el-input v-model="idCardInfo.name" placeholder="请输入名称" style="width:70%" class="addinputw" clearable />

            </div>

            <div class="step4item-lift-item">
              <span class="item-text">章证图片</span>
              <!-- <span class="item-text2">上传</span> -->
            </div>

            <upload style="margin-top: 10px;" ref="uploadImg2" v-model="imgList" :limit="9" @change="backData"
              bucket="map" :upload-data="{ type: '0001' }"></upload>


          </div>

          <div class="step4item-right">

            <el-table :data="formobj.idCardList" border>
              <el-table-column label="操作" wid align="center" width="116">
                <template slot-scope="scope">
                  <el-button type="primary" size="mini" @click="doDel4(scope.row)">删除</el-button>
                </template>
              </el-table-column>
              <el-table-column label="所属企业" prop="enterpriseName" align="center" />
              <el-table-column label="章证类型" prop="idCardType" align="center" />
              <el-table-column label="章证名称" prop="idCardName" align="center" />
              <el-table-column label="章证图片" align="center">
                <template slot-scope="scope">
                  <span v-for="(item,index) in scope.row.urls" :key="index">
                    <el-popover placement="left" trigger="click" width="300">
                      <img :src="item.url" width="100%" />
                      <img slot="reference" :src="item.url" :alt="item.url"
                        style="max-height: 70px;max-width: 70px; padding: 5px" />
                    </el-popover>
                  </span>
                </template>
              </el-table-column>

            </el-table>
          </div>


        </div>



      </div>

      <div style="display: flex;flex-direction: row;justify-content: center;margin-top: 50px;">
        <el-button type="primary" size="small" style="margin-right: 20px;" :disabled="stepIndex==1"
          @click="backClick">上一步</el-button>
        <el-button type="primary" size="small" style="margin-left: 20px;" :disabled="stepIndex==5"
          @click="nextClick">下一步</el-button>
      </div>
    </div>



  </div>
</template>

<script>
  import req from '@/api/project/project'
  import upload from '@/components/uploadFile/upload_yanchejianchaTuBiao.vue'
  export default {
    components: {
      upload
    },
    data() {
      return {
        imgList: [


        ],
        title: "【新增】项目信息",
        submitdisabled: false,
        stepIndex: 1,
        formobj: {
          sid: "",
          baseInfo: {
            entryName: "", // 项目名称
            industryName: "", // 行业名称
            industrySid: "",
            typeName: "", // 项目类型
            typeSid: "",
            bankPledgeRate: "", // 质押率
            creditLimit: "", // 授信额度
            bankName: "", // 贷款行
            bankSid: "",
            bmanagerName: '', // 客户经理
            managerSid: "",
            engaDate: "", // 授信日期
            loanDate: "", // 放款日期
            signingDate: "", // 签约日期
            remarks: "", // 项目说明
            regulatoryLeader: "", // 监管负责人
            regulatorySupervisor: "", // 监管部主管
            endDate: "", // 结束日期
            fillInDate: "", // 填表日期
            stateSid: "",
            stateName: "",
            stateRemarks: "",
          },
          warehouse: [],
          enterpriseList: [],
          bankList: [],
          idCardList: [],

        },
        industryAllList: [],
        industryList: [],
        typeAllList: [],
        typeList: [],
        bankAllList: [],
        bankList: [],
        stateAllList: [],
        stateList: [],
        bManagerAllList: [],
        bManagerList: [],
        enterpriseAllList: [],
        enterpriseRelevanceList: [],
        enterprise: {

        },
        tableAllList: [],
        cangKu: {},
        bankInfo: {

        },
        bankType: [{
            dictValue: "微信",
            dictKey: "1"
          },
          {
            dictValue: "支付宝",
            dictKey: "2"
          },
          {
            dictValue: "银联",
            dictKey: "3"
          }
        ],
        idCardInfo: {

        },
        idCardType: [{
            dictValue: "公章",
            dictKey: "1"
          },
          {
            dictValue: "证件",
            dictKey: "2"
          },
        ]

      }
    },
    created() {
      this.loanbankinformation() // 贷款行
      this.enterpriseinformation() // 项目单位
      this.industrydictionary() // 行业字典信息
      this.projtypedictionary() // 类型字典信息
      this.projtypedstated() // 状态字典信息
      this.selectStoreHouses() // 仓库字典信息
    },
    methods: {
      backClick() {

        if (this.stepIndex > 1)
          this.stepIndex--

      },
      nextClick() {
        if (this.stepIndex < 5)
          this.stepIndex++

      },
      stepClick(index) {
        this.stepIndex = index
      },
      addImg() {
        console.log(6);
      },
      loanbankinformation() {
        req.getUserListByOrg().then((res) => {
          if (res.success) {
            console.log(">>>>>>>>>11111111", res.data)
            this.bankAllList = res.data
            this.bankList = []
            for (var i = 0; i < this.bankAllList.length; i++) {

              let bank = {
                dictValue: this.bankAllList[i].name,
                dictKey: this.bankAllList[i].sid,

              }
              this.bankList.push(bank)
            }

          }
        })
      },
      enterpriseinformation() {
        req.getEnterpriseinformation().then((res) => {
          if (res.success) {
            console.log(">>>>>>>>>2222222", res.data)
            this.enterpriseAllList = []
            for (var i = 0; i < res.data.length; i++) {

              let enterprise = {
                dictValue: res.data[i].enterpriseName,
                dictKey: res.data[i].sid,
                type: "担保企业",
                contacts: res.data[i].contacts,
                telephone: res.data[i].telephone,

              }
              this.enterpriseAllList.push(enterprise)
            }

          }
        })
      },
      industrydictionary() {
        req.getIndustrydictionary().then((res) => {
          if (res.success) {
            console.log(">>>>>>>>>3333333", res.data)
            this.industryAllList = res.data
            this.industryList = []
            for (var i = 0; i < this.industryAllList.length; i++) {

              let industry = {
                dictValue: this.industryAllList[i].industryName,
                dictKey: this.industryAllList[i].sid,

              }
              this.industryList.push(industry)
            }

          }
        })
      },
      projtypedictionary() {
        req.getProjtypedictionary().then((res) => {
          if (res.success) {
            console.log(">>>>>>>>>444444", res.data)
            this.typeAllList = res.data
            this.typeList = []
            for (var i = 0; i < this.typeAllList.length; i++) {

              let type = {
                dictValue: this.typeAllList[i].typeName,
                dictKey: this.typeAllList[i].sid,

              }
              this.typeList.push(type)
            }

          }
        })
      },
      projtypedstated() {
        req.getProjtypedstated().then((res) => {
          if (res.success) {
            console.log(">>>>>>>>>5555", res.data)
            this.stateAllList = res.data
            this.stateList = []
            for (var i = 0; i < this.stateAllList.length; i++) {
              let type = {
                dictValue: this.stateAllList[i].name,
                dictKey: this.stateAllList[i].sid,
                dictExplain: this.stateAllList[i].remarks,

              }
              this.stateList.push(type)
            }
          }
        })
      },
      getHangYe(value) {
        console.log(">>>>>>>>>getHangYe", value)
        const choose = this.industryList.filter((item) => item.dictKey === value)
        this.formobj.baseInfo.industryName = choose[0].dictValue
        this.formobj.baseInfo.industrySid = choose[0].dictKey
      },
      getType(value) {
        console.log(">>>>>>>>>getType", value)
        const choose = this.typeList.filter((item) => item.dictKey === value)
        this.formobj.baseInfo.typeName = choose[0].dictValue
        this.formobj.baseInfo.typeSid = choose[0].dictKey
      },
      getBank(value) {
        console.log(">>>>>>>>>getBank", value)
        const choose = this.bankList.filter((item) => item.dictKey === value)
        this.formobj.baseInfo.bankName = choose[0].dictValue
        this.formobj.baseInfo.bankSid = choose[0].dictKey

        let items = this.bankAllList.filter(
          // function(item) {
          // 	return item.id == val.id;
          item => {
            console.log('item: ' + JSON.parse(JSON.stringify(item)).sid)
            console.log('val: ' + value)
            if (JSON.parse(JSON.stringify(item)).sid == value) {
              return true
            }
          })
        console.log(">>>>>>>>>getBank", items)

        this.formobj.baseInfo.bmanagerName = ''
        this.formobj.baseInfo.managerSid = ''

        this.bManagerAllList = items[0].children
        this.bManagerList = []
        for (var i = 0; i < this.bManagerAllList.length; i++) {

          let bManager = {
            dictValue: this.bManagerAllList[i].name,
            dictKey: this.bManagerAllList[i].sid,

          }
          this.bManagerList.push(bManager)
        }

      },
      getBManager(value) {
        console.log(">>>>>>>>>getBManager", value)
        const choose = this.bManagerList.filter((item) => item.dictKey === value)
        this.formobj.baseInfo.bmanagerName = choose[0].dictValue
        this.formobj.baseInfo.managerSid = choose[0].dictKey

      },
      getEnterName(value) {

        console.log(">>>>>>>>>EnterName", value)
        const choose = this.enterpriseAllList.filter((item) => item.dictKey === value)

        this.enterprise.enterpriseSid = choose[0].dictKey
        this.enterprise.name = choose[0].dictValue
        this.enterprise.type = choose[0].type
        this.enterprise.contacts = choose[0].contacts
        this.enterprise.telephone = choose[0].telephone

      },

      addEnterprise() {
        var info = {
          enterpriseSid: this.enterprise.enterpriseSid,
          enterpriseName: this.enterprise.name,
          type: this.enterprise.type,
          contacts: this.enterprise.contacts,
          telephone: this.enterprise.telephone,
        }

        const choose = this.formobj.enterpriseList.filter((item) => item.enterpriseSid === info.enterpriseSid)
        console.log(">>>>>>>>>addCangku", choose)
        if (choose.length == 0) {
          this.formobj.enterpriseList.push(info)

          let enterprise = {
              dictValue: info.enterpriseName,
            dictKey: info.enterpriseSid,

        }
        this.enterpriseRelevanceList.push(enterprise)
      } else {
        this.$message({
          showClose: true,
          type: 'error',
          message: "请勿重复添加!"
        })
      }




    },
    doDel2(row) {
      console.log(">>>>>>>>>doDel", row)

      const index = this.formobj.enterpriseList.filter((item) => item.sid === row.sid)
      this.formobj.enterpriseList.splice(index, 1)

      const index2 = this.enterpriseRelevanceList.filter((item) => item.dictKey === row.sid)
      this.enterpriseRelevanceList.splice(index2, 1)
      console.log(">>>>>>>>>doDel", index2)
      console.log(">>>>>>>>>doDel", this.enterpriseRelevanceList)
    },

    getEnterpriseName(value) {
      console.log(">>>>>>>>>getBManager", value)
      const choose = this.enterpriseList.filter((item) => item.dictKey === value)
      this.formobj.baseInfo.enterpriseName = choose[0].dictValue
      this.formobj.baseInfo.enterpriseSid = choose[0].dictKey
      let items = this.enterpriseAllList.filter(
        // function(item) {
        // 	return item.id == val.id;
        item => {
          console.log('item: ' + JSON.parse(JSON.stringify(item)).sid)
          console.log('val: ' + value)
          if (JSON.parse(JSON.stringify(item)).sid == value) {
            return true
          }
        })
      console.log(">>>>>>>>>getBManager", items)
      this.formobj.baseInfo.econtacts = items[0].contacts
    },
    getStateName(value) {
      console.log(">>>>>>>>>getStatedName", value)
      const choose = this.stateList.filter((item) => item.dictKey === value)
      this.formobj.baseInfo.stateName = choose[0].dictValue
      this.formobj.baseInfo.stateSid = choose[0].dictKey
      this.formobj.baseInfo.stateRemarks = choose[0].dictExplain
    },
    saveOrUpdate() {
      console.log(">>>>>>>>>saveOrUpdate", this.formobj)

      var bankData = []
      var warehouseData = []
      var idCardData = []
      var enterpriseData = []

      for (var i = 0; i < this.formobj.bankList.length; i++) {
        var item = this.formobj.bankList[i]
        bankData.push({
          accountType: item.accountType,
          accountNumber: item.accountNumber,
          bank: item.bank,
          enterpriseSid: item.bankEnterpriseSid,
        })
      }

      for (var i = 0; i < this.formobj.warehouse.length; i++) {
        var item = this.formobj.warehouse[i]
        warehouseData.push({
          shSid: item.shSid,
        })
      }

      for (var i = 0; i < this.formobj.enterpriseList.length; i++) {
        var item = this.formobj.enterpriseList[i]
        enterpriseData.push({
          enterpriseSid: item.enterpriseSid,
        })
      }


      for (var i = 0; i < this.formobj.idCardList.length; i++) {
        var item = this.formobj.idCardList[i]

        var imgs = []

        for (var j = 0; j < item.urls.length; j++) {
          var img = item.urls[j]
          imgs.push(img.url)
        }

        idCardData.push({
          enterpriseSid: item.enterpriseSid,
          idCardType: item.idCardType,
          idCardName: item.idCardName,
          urls: imgs,
        })
      }

      var data = {
        sid: this.formobj.sid,
        baseInfo: this.formobj.baseInfo,
        enterpriseList: enterpriseData,
        bankList: bankData,
        warehouse: warehouseData,
        idCardList: idCardData

      }

      console.log(">>>>>>>>>", data)

      req.saveInfo(data)
        .then(resp => {
          if (resp.success) {
            this.$message({
              showClose: true,
              type: 'success',
              message: resp.msg
            })
            this.handleReturn("true")

            this.$refs.multipleTable.clearSelection();
          } else {
            // 根据resp.code进行异常情况处理
          }
        })
        .catch(() => {})

    },
    selectStoreHouses() {
      req.selectStoreHouse().then((res) => {
        if (res.success) {
          console.log(">>>>>>>>>selectStoreHouses", res.data)
          this.tableAllList = []
          for (var i = 0; i < res.data.length; i++) {
            let type = {
              dictValue: res.data[i].name,
              dictKey: res.data[i].sid,
              address: res.data[i].address,
              linkerName: res.data[i].linkerName,
              linkerPhone: res.data[i].linkerPhone,

            }
            this.tableAllList.push(type)
          }
        }
      })
    },

    handleReturn(isreload) {
      if (isreload === 'true') this.$emit('reloadlist')

      this.formobj = {
        sid: "",
        baseInfo: {
          entryName: "", // 项目名称
          industryName: "", // 行业名称
          industrySid: "",
          typeName: "", // 项目类型
          typeSid: "",
          bankPledgeRate: "", // 质押率
          creditLimit: "", // 授信额度
          bankName: "", // 贷款行
          bankSid: "",
          bmanagerName: '', // 客户经理
          managerSid: "",
          engaDate: "", // 授信日期
          loanDate: "", // 放款日期
          signingDate: "", // 签约日期
          remarks: "", // 项目说明
          regulatoryLeader: "", // 监管负责人
          regulatorySupervisor: "", // 监管部主管
          endDate: "", // 结束日期
          fillInDate: "", // 填表日期
          stateSid: "",
          stateName: "",
          stateRemarks: "",
        },
        warehouse: [],
        enterpriseList: [],
        bankList: [],
        idCardList: [],

      }
      this.stepIndex = 1
      this.cangKu.name = ''
      this.enterprise.name = ''
      this.bankInfo = {}
      this.idCardInfo = {}
      this.$emit('doback')
    },
    showAdd() {
      this.title = "【新增】项目信息"
    },
    showEdit(row) {
      this.title = "【修改】项目信息",
        req.getInfoBySid(row.sid)
        .then(resp => {
          if (resp.success) {
            console.log(">>>>>>>>>showEdit", resp.data)
            this.formobj = resp.data

            this.enterpriseRelevanceList = []
            for (var i = 0; i < this.formobj.enterpriseList.length; i++) {

              let enterprise = {
                dictValue: this.formobj.enterpriseList[i].enterpriseName,
                dictKey: this.formobj.enterpriseList[i].enterpriseSid,

              }
              this.enterpriseRelevanceList.push(enterprise)
            }

            //   this.formobj.entryName = resp.data.entryName
            //   this.formobj.sid = resp.data.sid
            //   this.formobj.industryName = resp.data.industryName
            //   this.formobj.industrySid = resp.data.industrySid
            //   this.formobj.bankPledgeRate = resp.data.bankPledgeRate
            //   this.formobj.typeName = resp.data.typeName
            //   this.formobj.typeSid = resp.data.typeSid
            //   this.formobj.creditLimit = resp.data.creditLimit
            //   this.formobj.bankName = resp.data.bankName
            //   this.formobj.bankSid = resp.data.bankSid
            //   this.formobj.bmanagerName = resp.data.bmanagerName
            //   this.formobj.managerSid = resp.data.managerSid
            //   this.formobj.engaDate = resp.data.engaDate
            //   this.formobj.useLimit = resp.data.useLimit
            //   this.formobj.loanDate = resp.data.loanDate
            //   this.formobj.useDate = resp.data.useDate
            //   this.formobj.signingDate = resp.data.signingDate
            //   this.formobj.enterpriseName = resp.data.enterpriseName
            //   this.formobj.enterpriseSid = resp.data.enterpriseSid
            //   this.formobj.econtacts = resp.data.econtacts
            //   this.formobj.remarks = resp.data.remarks
            //   this.formobj.regulatoryLeader = resp.data.regulatoryLeader
            //   this.formobj.generalManager = resp.data.generalManager
            //   this.formobj.endDate = resp.data.endDate
            //   this.formobj.fillInDate = resp.data.fillInDate
            //   this.Sidlists = resp.data.enterpriseProjectVoList
            //   this.enterSids.enterpriseSid = []
            //   for (let i = 0; i < this.Sidlists.length; i++) {
            //     this.enterSids.enterpriseSid.push(this.Sidlists[i].enterpriseSid)
            //   }
          }

        })
        .catch(e => {
          this.formobj = row
        })
    },
    getCangku(value) {
      console.log(">>>>>>>>>getCangku", value)
      const choose = this.tableAllList.filter((item) => item.dictKey === value)

      this.cangKu.name = choose[0].dictValue
      this.cangKu.sid = choose[0].dictKey
      this.cangKu.address = choose[0].address
      this.cangKu.linkerName = choose[0].linkerName
      this.cangKu.linkerPhone = choose[0].linkerPhone

    },
    addCangku() {
      var info = {
        shSid: this.cangKu.sid,
        name: this.cangKu.name,
        address: this.cangKu.address,
        linkerName: this.cangKu.linkerName,
        linkerPhone: this.cangKu.linkerPhone,
      }

      const choose = this.formobj.warehouse.filter((item) => item.shSid === info.shSid)
      console.log(">>>>>>>>>addCangku", choose)
      if (choose.length == 0)
        this.formobj.warehouse.push(info)
      else
        this.$message({
          showClose: true,
          type: 'error',
          message: "请勿重复添加!"
        })
    },
    doDel(row) {
      console.log(">>>>>>>>>doDel", row)

      const index = this.formobj.warehouse.filter((item) => item.sid === row.sid)
      this.formobj.warehouse.splice(index, 1)
    },
    addBanK() {
      console.log(">>>>>>>>>doDel", this.bankInfo)

      if (!this.bankInfo.bankType) {
        this.$message({
          showClose: true,
          type: 'error',
          message: "账户类型不能为空!"
        })
        return
      }

      if (!this.bankInfo.bankEnterprise) {
        this.$message({
          showClose: true,
          type: 'error',
          message: "所属企业不能为空!"
        })
        return
      }


      if (!this.bankInfo.bankNum) {
        this.$message({
          showClose: true,
          type: 'error',
          message: "银行账号不能为空!"
        })
        return
      }


      if (!this.bankInfo.bankName) {
        this.$message({
          showClose: true,
          type: 'error',
          message: "开户银行不能为空!"
        })
        return
      }


      var info = {
        accountType: this.bankInfo.bankType,
        bankTypeSid: this.bankInfo.bankTypeSid,
        enterpriseName: this.bankInfo.bankEnterprise,
        bankEnterpriseSid: this.bankInfo.bankEnterpriseSid,
        accountNumber: this.bankInfo.bankNum,
        bank: this.bankInfo.bankName,
      }

      const choose = this.formobj.bankList.filter((item) => item.accountNumber == info.accountNumber)
      console.log(">>>>>>>>>addCangku", choose)
      if (choose.length == 0)
        this.formobj.bankList.push(info)
      else
        this.$message({
          showClose: true,
          type: 'error',
          message: "请勿重复添加!"
        })


    },
    doDel3(row) {
      console.log(">>>>>>>>>doDel", row)

      const index = this.formobj.bankList.filter((item) => item.bankNum === row.bankNum)
      this.formobj.bankList.splice(index, 1)
    },
    getBankType(value) {
      console.log(">>>>>>>>>getBankType", value)
      const choose = this.bankType.filter((item) => item.dictKey === value)
      this.bankInfo.bankType = choose[0].dictValue
      this.bankInfo.bankTypeSid = choose[0].dictKey
    },
    getBankEnterprise(value) {
      console.log(">>>>>>>>>getCangku", value)
      const choose = this.enterpriseRelevanceList.filter((item) => item.dictKey === value)

      this.bankInfo.bankEnterprise = choose[0].dictValue
      this.bankInfo.bankEnterpriseSid = choose[0].dictKey
    },
    addIdCard() {
      console.log(">>>>>>>>>addIdCard", this.idCardInfo)

      if (!this.idCardInfo.idCardType) {
        this.$message({
          showClose: true,
          type: 'error',
          message: "章证类型不能为空!"
        })
        return
      }

      if (!this.idCardInfo.idCardEnterprise) {
        this.$message({
          showClose: true,
          type: 'error',
          message: "所属企业不能为空!"
        })
        return
      }


      if (!this.idCardInfo.name) {
        this.$message({
          showClose: true,
          type: 'error',
          message: "章证名称不能为空!"
        })
        return
      }


      if (this.imgList.length == 0) {
        this.$message({
          showClose: true,
          type: 'error',
          message: "章证图片不能为空!"
        })
        return
      }


      var info = {
        idCardType: this.idCardInfo.idCardType,
        idCardTypeSid: this.idCardInfo.idCardTypeSid,
        enterpriseName: this.idCardInfo.idCardEnterprise,
        enterpriseSid: this.idCardInfo.idCardEnterpriseSid,
        idCardName: this.idCardInfo.name,
        urls: this.imgList,
      }
      this.formobj.idCardList.push(info)

      console.log("idCardList", this.formobj.idCardList)

      this.imgList = []

    },
    doDel4(row) {
      console.log(">>>>>>>>>doDel", row)

      const index = this.formobj.idCardList.filter((item) => item.idCardName === row.idCardName)
      this.formobj.idCardList.splice(index, 1)
    },
    getIdCardType(value) {
      console.log(">>>>>>>>>getIdCardType", value)
      const choose = this.idCardType.filter((item) => item.dictKey === value)
      this.idCardInfo.idCardType = choose[0].dictValue
      this.idCardInfo.idCardTypeSid = choose[0].dictKey
    },
    getIdCardEnterprise(value) {
      console.log(">>>>>>>>>getIdCardEnterprise", value)
      const choose = this.enterpriseRelevanceList.filter((item) => item.dictKey === value)

      this.idCardInfo.idCardEnterprise = choose[0].dictValue
      this.idCardInfo.idCardEnterpriseSid = choose[0].dictKey
    },

    backData(value) {
      console.log(value, 999)
      console.log("imgList", this.imgList)
      // const aa = []
      // if (value.length > 0 && value != null && value != undefined) {
      //   for (var i = 0; i < value.length; i++) {
      //     aa.push(value[i].url)
      //   }
      // }
      // this.formobj.contractInfo.contractFiles = aa

    },

  }
  }
</script>
<style scoped>
  .trightb {
    display: flex;
    align-items: center;
    text-align: ;
    justify-content: center;
  }

  .trightb_item {
    padding-top: 5px;
  }

  .trightbs {
    display: flex;
    align-items: center;
    text-align: ;
    justify-content: center;
  }

  .span {
    margin-left: 50px;
    font-size: 15px;
    font-weight: 400;
  }

  /deep/ .el-collapse-item__header {
    height: 40px;
    padding: 10px;
    font-weight: bold;
    font-size: 20px;
    text-align: left;
    color: #ffffff;
    background-color: #0294d7;
  }

  /deep/ .el-collapse-item__content {
    padding-bottom: 0;
  }

  /* .el-row{
    border-bottom: 1px solid #e0e3eb;
  } */

  /deep/ .formadd .el-row .trightbs {
    border-top: 1px solid #e0e3eb;
  }


  /deep/ .formadd .el-row .trightb_items {
    border-top: 1px solid #e0e3eb;
  }

  .step2Item {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-left: 20px;
    padding-top: 15px;
    padding-bottom: 15px;

  }

  .step2ItemBtn {
    margin-left: 20px;
    color: #fff;
    background-color: #0294D7;
    padding: 5px 15px;
    border-radius: 5px;
  }

  .step4item {
    margin-left: 15px;
    margin-right: 15px;
    display: flex;
    flex-direction: row;
  }

  .step4item-lift {
    width: 25%;
    display: flex;
    flex-direction: column;
  }

  .step4item-lift-item {
    margin-top: 15px;
  }

  .item-title {
    font-size: 18px;
    color: #191919;
  }

  .item-text {
    font-size: 15px;
    color: #919191;
  }

  .item-text2 {
    font-size: 15px;
    color: #0294D7;
    border-bottom: 1px #0294D7 solid;
    padding: 2px;
  }

  .step4item-right {
    flex: 1;
  }

  .Images {
    width: 150px;
    height: 100px;
    margin: 10px 10px 30px 10px;
    float: left;
  }

  .Images img {
    width: 100px;
    height: 100px;
    margin-left: 24px;
  }

  .Images p {
    color: #B8B8B8;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    margin-top: -30px;
  }

  .Images:hover p {
    color: #b8b8b8b0;
  }



  .ImageX {
    width: 150px;
    height: 100px;
    float: left;
    margin: 10px 20px 40px 10px;
  }

  .ImageX img {
    width: 100%;
    height: 100%;
  }

  .ImageX p {
    color: #000;
    text-align: center;
    margin-top: -15px;
  }

  .ImageX p .Atext {
    text-decoration: none;
  }

  .ImageX {
    position: relative;
  }

  .ImageX i {
    font-size: 30px;
    color: #fff;
    position: absolute;
    top: 0;
    left: 120px;
  }

  .xxx {
    width: 150px;
    height: 100px;
  }

  .xxx img {
    width: 100%;
    height: 100%;
  }
</style>
