<style>
  .empBankAccountTableLayer {
    overflow: auto;
    position: fixed;
    height: 200px;
    z-index: 50;
    bottom: 0;
    left: 50px;
    border-top: 3px solid #38425d;
    background-color: #FFFFFF;
    padding: 10px 10px 0;
    width: 100%;
  }

  .empBankAccountTableLayer .el-form-item__label {
    font-size: 12px !important;
  }

  .empBankAccountTableLayer>p {
    border-left: 3px solid #E95252;
    text-indent: 15px;
    height: 16px;
    padding-right: 50px;
    font-family: 'PingFangSc-Fine';
    font-size: 16px;
    margin-bottom: 20px;
    line-height: 14px;
    color: #000;
  }

  .empBankAccountTable {
    width: 100%;
    min-width: 1500px;
    font-size: 14px;
    color: #333;
    background: #ccc;
  }

  .empBankAccountTable tr {
    border-bottom: 2px solid #333;
  }

  .empBankAccountTable tr th {
    background: #BDBDBD;
    height: 30px;
    font-size: 12px;
    text-align: left;
    text-indent: 20px;
  }

  .empBankAccountTable tr {
    background: #fff;
    text-align: left;
  }

  .empBankAccountTable tr:nth-child(2n+1) {
    background: #E5E5E5;
  }

  .empBankAccountTable tr td {
    height: 60px;
    padding-left: 20px;
    border-right: 1px solid #DCDCDC;
    border-bottom: 1px solid #DCDCDC;
  }

  .popTable {
    width: 80%;
    font-size: 14px;
    color: #333;
    background: #ccc;
  }

  .popTable tr {
    border-bottom: 2px solid #333;
  }

  .popTable tr th {
    background: #BDBDBD;
    height: 30px;
    font-size: 12px;
    text-align: left;
    text-indent: 20px;
  }

  .popTable tr {
    background: #fff;
    text-align: left;
  }

  .popTable tr:nth-child(2n+1) {
    background: #E5E5E5;
  }

  .popTable tr td {
    height: 60px;
    padding-left: 20px;
    border-right: 1px solid #DCDCDC;
    border-bottom: 1px solid #DCDCDC;
  }

  .empBankAccountIcon button {
    width: 30px;
    height: 30px;
    border-radius: 4px;
  }

  .empBankAccountIcon .el-button--primary {
    padding: 5px;
    margin: 0;
    font-size: 14px !important;
  }

  .empBankAccountIcon .el-button+.el-button {
    margin-left: 0 !important;
  }

</style>
<template>
  <div class="flexOne">
    <div class="empBankAccountTableLayer" v-show="outerVisible"
      :style="{'height':accountList.length>0?'355px':'188px'}">
      <p>
        {{dialogTitle}}
        <span style="font-size:12px;color:red;">*{{$t('objFill.ruguosgrzwxsh')}}</span>
        <span class="fr">
          <button class="hollowFixedBtn"
            @click="outerVisible = false,resetForm('addMsg')">{{$t('pub.cancelBtn')}}</button>
          <button class="normalBtn" type="primary" @click="submitForm('addMsg')">{{$t('pub.saveBtn')}}</button>
        </span>
      </p>
      <el-form :model="addMsg" :rules="rules" ref="addMsg" label-width="90px" style="padding-right: 80px">
        <el-row>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.zhfenlei')" prop="AccountClassify">
              <el-select v-model='addMsg.AccountClassify' :placeholder="$t('pub.pleaseSel')" @change='changeTitle'>
                <el-option :label='$t("fnc.yinhang")' value='2' key='2'></el-option>
                <el-option :label='$t("ground.xunizhanghu")' value='3' key='3'></el-option>
                <el-option :label="$t('objFill.weixinzfb')" value='4' key='4'></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" v-if='addMsg.AccountClassify==2' :gutter="35">
            <el-form-item :label="$t('fnc.ssjigou')" prop="BankName">
              <el-input type="text" v-model="addMsg.BankName" :placeholder="$t('ground.liruicbc')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" v-if='addMsg.AccountClassify!=3 && addMsg.AccountClassify!=4' :gutter="35">

            <el-form-item :label="addMsg.AccountClassify!=2?nameA:$t('fnc.khuhang')" prop="OpenBankName">
              <el-input type="text" v-model="addMsg.OpenBankName" :placeholder="$t('ground.liruzhihang')"></el-input>
            </el-form-item>

          </el-col>
          <el-col :span="4" v-if='addMsg.AccountClassify!=3 && addMsg.AccountClassify!=4' :gutter="35">
            <el-form-item :label="nameB" prop="AccountHolder">
              <el-input type="text" v-model="addMsg.AccountHolder" :placeholder="$t('objFill.v101.administrative.lierzszhm')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="nameC" prop="CardNum">
              <el-input type="text" v-model="addMsg.CardNum" onkeyup="value=value.replace(/[^0-9]/g, ''),value=value.replace(/ /g, '')"
                :placeholder="$t('objFill.kaihaoznsrsz')">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="nameD" prop="AccountAlias">
              <el-input type="text" v-model="addMsg.AccountAlias" :placeholder="$t('objFill.v101.administrative.lierdyzs')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35" v-if="ClientTypeList&&ClientTypeList.length>0">
            <el-form-item :label="$t('fnc.khleixing')" prop="Type">
              <el-select filterable v-model="addMsg.Type" :placeholder="$t('fnc.khleixing')" @change="getType">
                <el-option v-for="item in ClientTypeList" :label="item.Name" :value="item.ID" :key="item.ID">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35" v-if="addMsg.Type!=0&&addMsg.Type!=10&&ClientTypeList.length>0">
            <el-form-item :label="$t('fnc.khmingcheng')" prop="ObjID">
              <el-select filterable remote reserve-keyword v-model="addMsg.ObjID" :remote-method="remoteMethod"
                @change="getObjName" :loading="supplierLoading" :placeholder="$t('pub.PleaseKeyWords')">
                <el-option v-for="(item,index) in supplierList" :label="item.Name" :value="item.ID" :key="index">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('ios.shuihao')" prop="DutyNo">
              <el-input type="text" v-model="addMsg.DutyNo"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('hotel.hotel_Supplier')" prop="SupplierName">
              <el-input type="text" v-model="addMsg.SupplierName" :disabled="$route.query.FeatureType?true:false">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div v-if="accountList.length"
        style="padding: 20px; display: flex; justify-content: center; align-items: center;flex-direction: column">
        <div style="padding: 10px">{{$t('objFill.yicunzaixtdzh')}}</div>
        <table class="popTable" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <th>{{$t("ground.zhanghumingcheng")}}</th>
            <th>{{$t("fnc.w_zhbieming")}}</th>
            <th>{{$t("ground.zhanghuleibie")}}</th>
            <th>{{$t("ground.suoshujigou")}}</th>
            <th>{{$t("fnc.acc")}}</th>
            <th>{{ $t("fnc.khleixing") }}</th>
            <th>{{$t('active.cl_addPp')}}</th>
            <th>{{$t("admin.admin_status")}}</th>
            <th v-if="addMsg.Type==8">{{ $t("admin.admin_operate") }}</th>
          </tr>
          <tr v-for="(item,index) in accountList">
            <td>{{item.OpenBankName}}</td>
            <td>{{item.AccountAlias}}</td>
            <td>
              <span v-if="item.AccountClassify==1">{{$t('fnc.a_ptzhanghu')}}</span>
              <span v-if="item.AccountClassify==2">{{$t('fnc.a_yhzhanghu')}}</span>
              <span v-if="item.AccountClassify==3">{{$t('objFill.xulizhanghu')}}</span>
              <span v-if="item.AccountClassify==4">{{$t('objFill.weixinzfb')}}</span>
            </td>
            <td>{{item.BankName}}</td>
            <td>{{item.CardNum}}
              <br />{{item.AccountHolder}}</td>
            <td>{{ item.TypeName }}</td>
            <td>
              {{item.CreateByName?item.CreateByName:'-'}}
              <p>{{item.CreateDate?item.CreateDate:'-'}}</p>
            </td>
            <td>
              <span v-if='item.Status!=0' style="color: #E95252;">{{$t('pub.fressSel')}}</span>
              <span v-if='item.Status==0' style="color: #09D49D;">{{$t('pub.normalSel')}}</span>
            </td>
            <td class="empBankAccountIcon" v-if="addMsg.Type==8">
              <el-button-group>
                <el-tooltip class="item" effect="dark" :content="$t('objFill.bangding')" placement="top-start">
                  <el-button v-if="item.Type == 10" @click="bindData(item.ID)" type="primary"
                    style="background: #09d49d; border-color: #09d49d" icon="iconfont icon-bianji-smal"></el-button>
                </el-tooltip>
              </el-button-group>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <div class="query-box">
      <ul>
        <li>
          <span style="margin-left: 80px"><em>{{$t('fnc.zhfenlei')}}</em>
            <el-select v-model="msg.AccountClassify" :placeholder="$t('pub.pleaseSel')" @change="changeTitle">
              <el-option :label="$t('pub.unlimitedSel')" value="" key="0"> </el-option>
              <el-option :label="$t('fnc.yinhang')" value="2" key="2"></el-option>
              <el-option :label="$t('ground.xunizhanghu')" value="3" key="3"></el-option>
              <el-option :label="$t('objFill.weixinzfb')" value="4" key="4"></el-option>
            </el-select>
          </span>
        </li>
        <li>
          <span><em>{{$t('salesModule.keyWords')}}</em>
            <el-input type="text" v-model="msg.KeyWord"></el-input>
          </span>
        </li>
        <li>
          <input type="button" @click="getList" class="normalBtn" :value="$t('pub.searchBtn')" />
          <input type="button" @click="AddAccountBank" class="normalBtn" :value="$t('pub.addBtn')" />
        </li>
      </ul>
    </div>
    <table class="empBankAccountTable" border="0" cellspacing="0" cellpadding="0" v-loading="loading">
      <tr>
        <th>{{$t("ground.zhanghumingcheng")}}</th>
        <th>{{$t("fnc.w_zhbieming")}}</th>
        <th>{{$t("ground.zhanghuleibie")}}</th>
        <th>{{$t("ground.suoshujigou")}}</th>
        <th>{{$t("fnc.acc")}}</th>
        <th>{{$t("admin.admin_status")}}</th>
        <th>{{$t("ground.leijijiaoyi")}}</th>
        <th>{{$t("admin.admin_operate")}}</th>
      </tr>
      <tr v-for="(item,index) in list">
        <td>{{item.OpenBankName}}</td>
        <td>{{item.AccountAlias}}</td>
        <td>
          <span v-if="item.AccountClassify==1">{{$t('fnc.a_ptzhanghu')}}</span>
          <span v-if="item.AccountClassify==2">{{$t('fnc.a_yhzhanghu')}}</span>
          <span v-if="item.AccountClassify==3">{{$t('objFill.xulizhanghu')}}</span>
          <span v-if="item.AccountClassify==4">{{$t('objFill.weixinzfb')}}</span>
        </td>
        <td>{{item.BankName}}</td>
        <td>{{item.CardNum}}
          <br />{{item.AccountHolder}}</td>
        <td>
          <span v-if='item.Status!=0' style="color: #E95252;">{{$t('pub.fressSel')}}</span>
          <span v-if='item.Status==0' style="color: #09D49D;">{{$t('pub.normalSel')}}</span>
        </td>
        <td style="color: #FF9C00;">¥{{moneyFormat(item.PayMoney)}}</td>
        <td class="empBankAccountIcon">
          <el-button-group>
            <el-tooltip class="item" effect="dark" :content="$t('pub.updateMsg')" placement="top-start">
              <el-button @click="outerVisible = true,dialogTitle=$t('ground.xiugaizhanghu'),updateData(item.ID)"
                type="primary" style='background:#409EFF; border-color:#409EFF' icon="iconfont icon-bianji-smal">
              </el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="item.Status=='1'? $t('fnc.qiyong'):$t('pub.fressSel')"
              placement="top-start">
              <el-button v-if='item.Status==1' @click="deleteData(item.ID)" type="primary"
                style='background:#09D49D; border-color:#09D49D' icon="iconfont icon-qidong"></el-button>
              <el-button v-if='item.Status==0' @click="deleteData(item.ID)" type="primary"
                style='background:#E95252; border-color:#E95252' icon="iconfont icon-dongjie"></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="$t('ground.mingxi')" placement="top-start">
              <el-button type="primary" style='background:#E6A014; border-color:#E6A014' icon="iconfont icon-rizhi1">
              </el-button>
            </el-tooltip>
          </el-button-group>
        </td>
      </tr>
    </table>
    <el-pagination background @current-change="handleCurrentChange" :current-page.sync="currentPage"
      layout="total,prev, pager, next, jumper" :page-size=msg.pageSize :total=total>
    </el-pagination>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        ClientTypeList: [],
        supplierLoading: false,
        supplierList: [],
        supplierMsg: {
          pageIndex: 1,
          pageSize: 1000,
          Name: "",
          Contact: "",
          Type: "",
          CountryStr: "",
          ProvinceStr: "",
          CityStr: "",
          DistrictStr: "",
          ID :0
        },
        loading: true,
        accountList: [],
        nameA: this.$t("ground.zhanghumingcheng2"),
        nameB: this.$t("fnc.khuren"),
        nameC: this.$t("ground.kahao"),
        nameD: this.$t("fnc.accBming"),
        switchValue: '1',
        dialogTitle: '',
        insideDialogTxt: this.$t("tips.saveYes"),
        outerVisible: false,
        innerVisible: false,
        isRight: true,
        versions: [],
        total: 0,
        currentPage: 1,
        //请求数据
        msg: {
          BranchId: '-1',
          EmpId: '-1',
          BankId: '',
          AccountHolder: '',
          AccountAlias: '',
          pageIndex: 1,
          pageSize: 15,
          Type: '',
          AccountClassify: '',
          KeyWord: ''
        },
        getCompanyMsg: {
          RB_Group_Id: '0',
          Status: '0',
        },
        getUserMsg: {
          RB_Branch_id: '-1',
        },
        //返回数据
        list: [],
        bankList: [],
        layerItem: [],
        addMsg: {
          Id: '0',
          ObjID: '-1',
          BankId: '-1',
          OpenBankName: '',
          BankName: '',
          AccountHolder: '',
          CardNum: '',
          AccountAlias: '',
          AccountType: '1',
          AccountClassify: '2',
          Type: '9',
          DutyNo: '',
          SupplierName: ''
        },
        rules: {
          BankName: [{
            required: true,
            message: this.$t("ground.qingtianxieyh"),
            trigger: 'blur'
          }],
          Type: [{
            required: true,
            message: this.$t('objFill.qingxuanzhekhlx'),
            trigger: "chang",
          }, ],
          ObjID: [{
            required: true,
            message: this.$t('rule.qxzkhmingcheng'),
            trigger: "chang",
          }, ]
        }
      }
    },
    mounted() {
      let userInfo = this.getLocalStorage();
      this.getUserMsg.RB_Group_id = this.getCompanyMsg.RB_Group_Id = userInfo.RB_Group_id; //集团ID
      this.msg.EmpId = this.$route.query.id;
      this.msg.Type = this.$route.query.type;
      this.addMsg.Type = Number(this.$route.query.type);
      if (this.$route.query.type == 10) {
        this.financeinfo_post_GetClientTypeList()
      }
      this.getBank();
      this.getList();
      this.changeTitle()
    },
    methods: {
      // 车系统 添加账户
      getCarDatas() {
        if (this.$route.query.FeatureType) {
          this.addMsg.ObjID = this.$route.query.ObjID
          this.addMsg.ObjIdStr = this.$route.query.SupplierName
          this.addMsg.SupplierName = this.$route.query.SupplierName
          this.addMsg.RB_Group_Id = this.$route.query.id
        }
      },
      //替换卡号里面的空格
      replaceSpace(event) {
        // onkeyup="value=value.replace(/[^\w\u4E00-\u9FA5]/g,'')"
        this.addMsg.CardNum = event.target.value.replace(/ /g, ''); // 将所有空格替换为空字符串
      },
      // 获取客户类型
      getType() {
        this.supplierList = []
        if (this.addMsg.Type == 4) {
          this.supplierMsg.Type = 5
        } else {
          this.supplierMsg.Type = this.addMsg.Type
        }
        if (this.addMsg.Type != 10) {
          this.addMsg.ObjID = null
          this.addMsg.ObjIdStr = ''
          this.supplierMsg.Name = ''
        } else {
          this.addMsg.ObjID = this.$route.query.id
        }
      },
      getObjName() {
        this.supplierList.filter(x => {
          if (x.ID == this.addMsg.ObjID) {
            this.addMsg.ObjIdStr = x.Name
            this.addMsg.SupplierName = x.Name
          }
        })
      },
      remoteMethod(query) {
        if (query !== '') {
          this.addMsg.ObjID = null
          this.supplierMsg.Name = query
          this.supplierList = [];
          this.getSupplierGetPageList()
        } else {
          this.supplierMsg.Name = ''
          this.supplierList = [];
        }
      },
      getSupplierGetPageList() {
        if (this.addMsg.Type == 10) {
          return
        }
        let url = "supplier_get_GetPageList"
        let msg = JSON.parse(JSON.stringify(this.supplierMsg))
        if (this.addMsg.Type == 5) {
          url = "dmc_post_visa_GetCommuneInfoPageList"
          msg = {
            pageIndex: 1,
            pageSize: this.supplierMsg.pageSize,
            Name: this.supplierMsg.Name,
            PersonInCharge: "",
            Country: "",
            City: "",
            District: "",
            Province: ""
          }
        }
        if (this.addMsg.Type == 7) {
          url = "leader_post_GetPageList"
          msg = {
            Type: "0",
            ID: this.supplierMsg.ID,
            FullName: this.supplierMsg.ID>0?'': this.supplierMsg.Name,
            RB_Branch_id: -1,
            pageIndex: 1,
            pageSize: 20,
            total: 0,
            currentPage: 1,
            QueryType: 0,
            LeaderGuidClass: -1
          }
          this.supplierMsg.ID=0;
        }
        if (this.addMsg.Type == 8) {
          url = "app_customer_GetCustomerListForCareOf"
          msg = {
            pageIndex: 1,
            pageSize: this.supplierMsg.pageSize,
            CustomerName: this.supplierMsg.Name,
            CreateBy: "-1",
            DepartmentId: "-2",
            Brand: -1,
            allDepartment: 1,
            CustomerStatus: "",
            OperationStatus: "",
            jySort: "desc",
            rtsSort: "",
            orderBy: "TradeMoney desc",
            ExceptionCount: 0,
          }
        }
        if (this.addMsg.Type == 9) {
          url = "admin_get_EmployeeList"
          msg = {
            pageIndex: 1,
            pageSize: this.supplierMsg.pageSize,
            EmName: this.supplierMsg.Name,
            EmAccount: "",
            RB_Group_id: 2,
            RB_Branch_id: -1,
            RB_Department_Id: "0",
            RB_Post_Id: "0",
            Status: "0",
            sEmEntry: "",
            eEmEntry: "",
            sEmLeave: "",
            eEmLeave: "",
            IsParentCompany: 1
          }
        }
        if (this.addMsg.Type == 11) {
          url = "travel_get_GetGroundingSupplierPageList"
          msg = {
            pageIndex: 1,
            pageSize: this.supplierMsg.pageSize,
            Name: this.supplierMsg.Name,
            GroundingType: "",
            LineInfo: "",
            LineId: "0",
            Id: ""
          }
        }
        if (this.addMsg.Type == 6) {
          url = "airline_post_GetPageList"
          msg = {
            pageIndex: 1,
            pageSize: this.supplierMsg.pageSize,
            AlName: this.supplierMsg.Name,
            AlCode: "",
            TicketCode: "",
          }
        }
        this.supplierLoading = true
        this.apipost(
          url,
          msg,
          (res) => {
            if (res.data.resultCode == 1) {
              let dataList
              if (res.data.data.pageData && res.data.data.pageData.length > 0) {
                dataList = res.data.data.pageData
              }
              if (res.data.data.pages && res.data.data.pages.pageData.length > 0) {
                dataList = res.data.data.pages.pageData
              }
              dataList && dataList.forEach(x => {
                let Obj = {
                  Name: '',
                  ID: 0
                }
                if (this.addMsg.Type == 9) {
                  Obj = {
                    Name: x.EmName,
                    ID: x.EmployeeId
                  }
                } else if (this.addMsg.Type == 8) {
                  Obj = {
                    Name: x.CustomerName,
                    ID: x.CustomerId
                  }
                } else if (this.addMsg.Type == 7) {
                  Obj = {
                    Name: x.Surname + x.Name + x.MobilePhone,
                    ID: x.ID
                  }
                } else if (this.addMsg.Type == 6) {
                  Obj = {
                    Name: x.AlName,
                    ID: x.AirLineId
                  }
                } else if (this.addMsg.Type == 11) {
                  Obj = {
                    Name: x.Name,
                    ID: x.Id
                  }
                } else {
                  Obj = {
                    Name: x.Name,
                    ID: x.ID
                  }
                }
                this.supplierList.push(Obj)
              })
              if (this.addMsg.ObjIdStr && this.supplierList.length > 0) {
                this.addMsg.ObjID = Number(this.supplierList[0].ID)
              }
            }
            this.supplierLoading = false
          },
          (err) => {
            this.supplierLoading = false
          })
      },
      financeinfo_post_GetClientTypeList() {
        // 获取对象类型
        this.apipost(
          "financeinfo_post_GetClientTypeList", {},
          (res) => {
            if (res.data.resultCode == 1) {

              this.ClientTypeList = res.data.data;
            }
          })
      },
      AddAccountBank() {
        this.outerVisible = true
        this.dialogTitle = this.$t('ground.xinzengzhanghu')
        this.resetForm('addMsg')
        this.getCarDatas()
      },
      changeTitle() {
        if (this.addMsg.AccountClassify == 1) {
          this.nameA = this.$t("ground.pingtaimingcheng")
          this.nameB = this.$t("ground.yonghumingcheng")
          this.nameC = this.$t("fnc.ptAcc")
          this.nameD = this.$t("fnc.accBming")
          this.addMsg.AccountType = '1'
        } else if (this.addMsg.AccountClassify == 2) {
          this.nameA = this.$t("ground.zhanghumingcheng2")
          this.nameB = this.$t("fnc.khuren")
          this.nameC = this.$t("ground.kahao")
          this.nameD = this.$t("fnc.accBming")
        } else if (this.addMsg.AccountClassify == 3) {
          this.nameA = this.$t("ground.pingtaimingcheng")
          this.nameB = this.$t("ground.yonghumingcheng")
          this.nameC = this.$t("fnc.ptAcc")
          this.nameD = this.$t("fnc.accBming")
        } else if (this.addMsg.AccountClassify == 4) {
          this.nameA = this.$t("ground.pingtaimingcheng")
          this.nameB = this.$t("ground.yonghumingcheng")
          this.nameC = this.$t('system.table_acc')
          this.nameD = this.$t('system.query_airName')
        }
      },
      getList() { //获取列表数据
        this.loading = true
        this.apipost("admin_get_GetEmpBankAccountPageList", this.msg, res => {
          if (res.data.resultCode == 1) {
            this.list = res.data.data.pageData;
            this.total = res.data.data.count;
          } else {}
          this.loading = false
        }, err => {})
      },
      getBank() {
        this.apipost('FinancialInstitutions_post_GetList', {
          Type: 0
        }, res => {
          if (res.data.resultCode == 1) {
            this.bankList = res.data.data;
          } else {}
        }, err => {})
      },
      addData() {
        if (this.addMsg.ObjID == null && this.addMsg.Type != 10) {
          this.$message.error(this.$t('rule.qxzkhmingcheng'))
          return
        }
        if (this.addMsg.Type != 7 && this.addMsg.Type != 9 && this.addMsg.Type != 10 && this.addMsg.Type != 12) {
          if (this.addMsg.DutyNo == '' || this.addMsg.DutyNo == undefined) {
            this.$message.error(this.$t('objFill.qingtxsh'))
            return
          }
        }
        this.addMsg.ObjID = this.addMsg.ObjID != '-1' && this.addMsg.ObjID != null ? this.addMsg.ObjID : this.$route
          .query.id
        if (this.addMsg.AccountClassify != '3' && this.addMsg.AccountClassify != '4') {
          if (this.addMsg.OpenBankName == '') {
            this.$message.error(this.$t('visaT.Pleasefillin') + this.nameA)
            return
          }
          if (this.addMsg.AccountHolder == '') {
            this.$message.error(this.$t('visaT.Pleasefillin') + this.nameB)
            return
          }
        }
        if (this.addMsg.CardNum == '') {
          this.$message.error(this.$t('visaT.Pleasefillin') + this.nameC)
          return
        }
        if (this.addMsg.AccountAlias == '') {
          this.$message.error(this.$t('visaT.Pleasefillin') + this.nameD)
          return
        }
        this.checkCanAdd()

      },
      addAccount() {
        this.apipost("admin_post_SetEmpBankAccount", this.addMsg, res => {
          if (res.data.resultCode == 1) {
            this.$message.success(res.data.message)
            this.outerVisible = false;
            this.getList()
            this.resetForm('addMsg');
          } else {
            this.getList();
            this.$message.error(res.data.message)
          }
        }, err => {})
      },
      checkCanAdd() {
        this.$confirm(this.$t('objFill.kehulxshbtzq'), this.$t('tips.tips'), {
            confirmButtonText: this.$t('pub.sureBtn'),
            cancelButtonText: this.$t('pub.cancelBtn'),
            type: "warning"
          })
          .then(() => {
            this.apipost('admin_post_GetBackAccount', {
              RB_Group_Id: this.addMsg.ObjID,
              ...this.addMsg
            }, res => {
              if (res.data.resultCode == 1) {
                if (res.data.data && res.data.data.length) {
                  this.accountList = res.data.data
                } else {
                  this.addAccount()
                }
              } else {
                this.$message.error(res.data.message)
              }
            }, err => {})
          })
          .catch(() => {});
      },
      updateData(id) { //修改角色
        this.apipost('admin_get_GetEmpBackAccount', {
          BAId: id
        }, res => {
          if (res.data.resultCode == 1) {
            this.addMsg = res.data.data;
            this.addMsg.AccountType = res.data.data.AccountType.toString();
            this.addMsg.AccountClassify = res.data.data.AccountClassify.toString();
            this.addMsg.BankId = res.data.data.BankId
            this.addMsg.IsOtherEdit = 1
            this.supplierMsg.Type = this.addMsg.Type
            this.addMsg.DutyNo = res.data.data.DutyNo
            this.addMsg.SupplierName = res.data.data.SupplierName
            if (this.addMsg.ObjIdStr) {
              this.supplierMsg.Name = this.addMsg.ObjIdStr
              this.supplierMsg.ID = this.addMsg.ObjID
              this.getSupplierGetPageList()
            } else {
              this.addMsg.ObjID = null
            }
            this.changeTitle()
          } else {}
        }, err => {})
      },
      deleteData(id) {
        let that = this
        this.$confirm(that.$t('ground.querenqiyong'), this.$t('tips.tips'), {
          confirmButtonText: that.$t('pub.sureBtn'),
          cancelButtonText: that.$t('pub.cancelBtn'),
          type: 'warning'
        }).then(() => {
          this.apipost('admin_post_DelEmpBankAccount', {
            BAId: id
          }, res => {
            if (res.data.resultCode == 1) {
              that.$message.success(this.$t('tips.czchenggong'))
              that.getList();
            } else {
              that.$message.info(this.$t('objFill.chaozuosib'))
            }
          }, err => {})

        }).catch(() => {
          that.$message.info(this.$t('objFill.chaozuosib'))
        });
      },
      bindData(id) {
        let that = this
        this.$confirm(this.$t('objFill.shifoubddqfkdx'), this.$t('tips.tips'), {
          confirmButtonText: that.$t('pub.sureBtn'),
          cancelButtonText: that.$t('pub.cancelBtn'),
          type: 'warning'
        }).then(() => {
          this.apipost('admin_post_BindEmpBankAccount', {
            BAId: id,
            ObjID: this.$route.query.id,
            Type: this.$route.query.type
          }, res => {
            if (res.data.resultCode == 1) {
              that.$message.success(this.$t('tips.czchenggong'))
              this.outerVisible = false;
              that.getList();
            } else {
              that.$message.info(this.$t('objFill.chaozuosib'))
            }
          }, err => {})

        }).catch(() => {
          that.$message.info(this.$t('objFill.chaozuosib'))
        });
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      resetPageIndex() {
        this.msg.pageIndex = 1;
        this.currentPage = 1
      },
      submitForm(addMsg) { //提交创建、修改表单
        this.$refs[addMsg].validate((valid) => {
          if (valid) {
            this.addData();
          } else {
            return false;
          }
        });
      },
      closeChangeMachie(done) { //弹出框关闭初始化弹框内表单
        done();
        this.resetForm('addMsg');
      },
      resetForm(formName) { //弹出框取消 初始化谈框内表单
        this.accountList = []
        this.$refs[formName].resetFields();
        this.addMsg.AccountType = '1';
        this.addMsg.AccountClassify = '2';
        this.addMsg.Id = '0';
        this.addMsg.ObjID = '-1';
        this.addMsg.BankId = '-1';
        this.addMsg.OpenBankName = '';
        this.addMsg.BankName = '';
        this.addMsg.AccountHolder = '';
        this.addMsg.CardNum = '';
        this.addMsg.AccountAlias = '';
      }
    }
  }

</script>