<style>
  @import url('./css/CashierWork.css');
  @import "./css/cssReset.css";

</style>
<template>
  <div class="page_CashierWork page-body">
    <div class="query-box">
      <ul>
        <li>
          <!-- <button class="normalBtn" @click="addShow=true,text=$t('pub.addBtn')">{{$t('pub.addBtn')}}</button> -->
          <q-btn color="primary" size="11px" :label="$t('pub.addBtn')" @click="addShow=true,text=$t('pub.addBtn')"/>
          <el-tooltip class="item" effect="dark" :content="$t('fnc.qhpaiban')" placement="top-end">
            <i v-if="transitionShow" class="iconfont icon-biaoge" @click="switchMethod(1)"></i>
            <i v-if="transitionShow2" class="iconfont icon-icon-ssan" @click="switchMethod(2)"></i>
          </el-tooltip>
        </li>
      </ul>
    </div>
    <div>
      <p class="_cashierWorl_tit">{{$t('tips.accWorkTips')}}</p>
      <div class="cm_content _scrollbar" :class="addShow==true?'_edHeight':''">
        <table class="po_content singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0"
          v-loading="loading" v-if="transitionShow2">
          <tr>
            <th>{{$t('fnc.w_ckmingcheng')}}</th>
            <th>{{$t('fnc.w_ywrenyuan')}}</th>
            <th>{{$t('fnc.w_sqzhanghu')}}</th>
            <th>{{$t('fnc.w_ycldanju')}}</th>
            <th>{{$t('fnc.w_dcldanju')}}</th>
            <th>{{$t('system.table_operation')}}</th>
          </tr>
          <tr v-for="(item,index) in dataList" :key="index">
            <td>{{item.Name}}</td>
            <td>
              <span v-for="(i,ix) in item.emList">{{i.emName}} <span v-if="ix!=item.emList.length-1">,</span> </span>
            </td>
            <td>
              {{$t('fnc.fkuanzhanghu')}}：
              <el-popover placement="bottom" popper-class="CashierWork_tripDetails" trigger="click">
                <div class="">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="popTable">
                    <tr class="_color_666">
                      <th>{{$t('fnc.w_zhbieming')}}</th>
                      <th>{{$t('fnc.shoukuan')}}</th>
                      <th>{{$t('fnc.zhikuan')}}</th>
                    </tr>
                    <tr v-for="(son,sIndex) in shouList" v-loading="shouListLoading">
                      <td>
                        <span class="_fangkuang" v-if="son.Is_Public===1">{{$t('fnc.w_gsdgong')}}</span>
                        <span class="_fangkuang _fangkuang_si" v-if="son.Is_Public===0">{{$t('fnc.w_gsdsi')}}</span>
                        <span>{{son.Alias}}</span>
                      </td>
                      <td><input v-model="son.Is_Income" disabled type="checkbox"></td>
                      <td><input v-model="son.Is_Outcome" disabled type="checkbox"></td>
                    </tr>
                  </table>
                </div>
                <span slot="reference" @click="Window_post_GetList(item.ID,1)"
                  class="_underline _color_red">{{item.InCount}}</span>
              </el-popover>
              <span>{{$t('fnc.fkzhanghu')}}：
                <el-popover placement="bottom" popper-class="CashierWork_tripDetails" trigger="click">
                  <div class="">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="popTable">
                      <tr class="_color_666">
                        <th>{{$t('fnc.w_zhbieming')}}</th>
                        <th>{{$t('fnc.shoukuan')}}</th>
                        <th>{{$t('fnc.zhikuan')}}</th>
                      </tr>
                      <tr v-for="(son,sIndex) in shouList" v-loading="shouListLoading">
                        <td>
                          <span class="_fangkuang" v-if="son.Is_Public===1">{{$t('fnc.w_gsdgong')}}</span>
                          <span class="_fangkuang _fangkuang_si" v-if="son.Is_Public===0">{{$t('fnc.w_gsdsi')}}</span>
                          <span>{{son.Alias}}</span>
                        </td>
                        <td><input v-model="son.Is_Income" disabled type="checkbox"></td>
                        <td><input v-model="son.Is_Outcome" disabled type="checkbox"></td>
                      </tr>
                    </table>
                  </div>
                  <span slot="reference" @click="Window_post_GetList(item.ID,2)"
                    class="_underline _color_blue">{{item.OutCount}}</span>
                </el-popover>
              </span>
            </td>
            <td>
              <span class="_underline" @click="goUrl('FinancialDocuments',2)">{{item.DealCount}}</span>
            </td>
            <td>
              <span class="_underline" @click="goUrl('FinancialDocuments',3)">{{item.NoDealCount}}</span>
            </td>
            <td>
              <el-row>
                <el-tooltip class="item" effect="dark" :content="$t('pub.updateMsg')" placement="top-start">
                  <el-button type="primary" class="iconfont icon-bianji-smal" circle
                    @click="editCurency(item.ID),text=$t('pub.updateMsg')"></el-button>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" :content="$t('fnc.w_djxinxi')" placement="top-start">
                  <el-button type="danger" class="iconfont icon-img-rili" circle
                    @click="goUrlDetail('CashierWorkDetail',1,item.Name,item.ID)"></el-button>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" :content="$t('system.table_delete')" placement="top-start">
                  <el-button type="danger" class="iconfont icon-img_delete_small" circle
                    @click="financeinfoRemove(item.ID,item.ID)"></el-button>
                </el-tooltip>
              </el-row>
            </td>
          </tr>
        </table>
        <div v-if="transitionShow" class="clearfix">
          <div class="po_content_list_item" v-for="(item,index) in dataList" :key="index">
            <div class="po_content_list_item_top">
              <span class="_item_top_name">{{item.Name}}</span>
              <span class="_item_top_icon">
                <i class="iconfont icon-rizhi1" @click="goUrlDetail('CashierWorkDetail',1,item.Name,item.ID)"></i>
                <i class="iconfont icon-bianji-smal" @click="editCurency(item.ID),text=$t('system.table_edit')"></i>
                <i class="iconfont icon-img_delete_small" @click="financeinfoRemove(item.ID,item.ID)"></i>
              </span>
            </div>
            <div class="po_content_list_item_bottom">
              <p>
                <span>{{$t('fnc.w_ywrenyuan')}}</span>
                <template v-if="item.emList.length>0">
                  <span v-if="item.emList.length==1">
                    {{item.emList[0].emName}}
                  </span>
                  <div v-else>
                    <el-popover placement="bottom" popper-class="CashierWork_tripDetails" trigger="click">
                      <div class="">
                        <span class="_all_name" v-for="(i,io) in item.emList">{{i.emName}}</span>
                      </div>
                      <span slot="reference" @click="" class="_underline">{{item.emList[0].emName}}
                        {{$t('fnc.w_gong')}}（{{item.emList.length}}）{{$t('hotel.hotel_people')}}</span>
                    </el-popover>
                  </div>
                </template>
                <template v-else>
                  <span>{{$t('fnc.no')}}</span>
                </template>

              </p>
              <p>
                <span>{{$t('fnc.fkuanzhanghu')}}</span>
                <el-popover placement="bottom" popper-class="CashierWork_tripDetails" trigger="click">
                  <div class="">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="popTable">
                      <tr class="_color_666">
                        <th>{{$t('fnc.w_zhbieming')}}</th>
                        <th>{{$t('fnc.shoukuan')}}</th>
                        <th>{{$t('fnc.zhikuan')}}</th>
                      </tr>
                      <tr v-for="(son,sIndex) in shouList" v-loading="shouListLoading">
                        <td>
                          <span class="_fangkuang" v-if="son.Is_Public===1">{{$t('fnc.w_gsdgong')}}</span>
                          <span class="_fangkuang _fangkuang_si" v-if="son.Is_Public===0">{{$t('fnc.w_gsdsi')}}</span>
                          <span>{{son.Alias}}</span>
                        </td>
                        <td><input v-model="son.Is_Income" disabled type="checkbox"></td>
                        <td><input v-model="son.Is_Outcome" disabled type="checkbox"></td>
                      </tr>
                    </table>
                  </div>
                  <span slot="reference" @click="Window_post_GetList(item.ID,1)"
                    class="_underline">{{item.InCount}}</span>
                </el-popover>
              </p>
              <p>
                <span>{{$t('fnc.fkzhanghu')}}</span>
                <el-popover placement="bottom" popper-class="CashierWork_tripDetails" trigger="click">
                  <div class="">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="popTable">
                      <tr class="_color_666">
                        <th>{{$t('fnc.w_zhbieming')}}</th>
                        <th>{{$t('fnc.shoukuan')}}</th>
                        <th>{{$t('fnc.zhikuan')}}</th>
                      </tr>
                      <tr v-for="(son,sIndex) in shouList" v-loading="shouListLoading">
                        <td>
                          <span class="_fangkuang" v-if="son.Is_Public===1">{{$t('fnc.w_gsdgong')}}</span>
                          <span class="_fangkuang _fangkuang_si" v-if="son.Is_Public===0">{{$t('fnc.w_gsdsi')}}</span>
                          <span>{{son.Alias}}</span>
                        </td>
                        <td><input v-model="son.Is_Income" disabled type="checkbox"></td>
                        <td><input v-model="son.Is_Outcome" disabled type="checkbox"></td>
                      </tr>
                    </table>
                  </div>
                  <span slot="reference" @click="Window_post_GetList(item.ID,2)"
                    class="_underline">{{item.OutCount}}</span>
                </el-popover>
              </p>
              <p>
                <span>{{$t('fnc.w_ycldanju')}}</span>
                <span class="_underline" @click="goUrl('FinancialDocuments',2)">{{item.DealCount}}</span>
              </p>
              <p>
                <span>{{$t('fnc.w_dcldanju')}}</span>
                <span class="_underline" @click="goUrl('FinancialDocuments',3)">{{item.NoDealCount}}</span>
              </p>
            </div>
          </div>
        </div>
        <div class="noData" v-show="noData">
          {{$t('system.content_noData')}}
        </div>
        <div>
          <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>
      </div>
      <div class="_vMG_edit" :class="addShow==true?'edHeight':''">
        <el-row>
          <el-col :span="20">
            <p class="_tit">{{text}}{{$t('fnc.w_chuangkou')}}</p>
          </el-col>
          <el-col :span="4" class="_add_saveBtn">
            <!-- <button type="button" class="normalBtn" @click="submitForm('addMsg',1)">{{$t('pub.saveBtn')}}</button> -->
            <q-btn color="primary" size="11px" :label="$t('pub.saveBtn')" @click="submitForm('addMsg',1)" style="marginRight:10px"/>
            <!-- <button class="hollowFixedBtn" type="button"
              @click="cancelEdit(),resetForm('addMsg'),addShow=false">{{$t('pub.cancelBtn')}}</button> -->
              <q-btn text-color="primary" size="11px" :label="$t('pub.cancelBtn')"  @click="cancelEdit(),resetForm('addMsg'),addShow=false" style="marginRight:10px"/>
          </el-col>
        </el-row>
        <el-form class=" clearfix" :model="addMsg" ref="addMsg" :rules="rules" label-width="100px">
          <el-row>
            <el-col :span="4">
              <el-form-item :label="$t('system.query_airName')+'：'" prop="Name">
                <el-input v-model="addMsg.Name"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item :label="$t('fnc.w_ywrenyuan')+'：'" prop="listArr">
                <el-select v-model="addMsg.listArr" filterable remote multiple reserve-keyword placeholder="请输入"
                  :placeholder="$t('pub.pleaseImport')" :remote-method="remoteMethod" @change="$forceUpdate()"
                  @remove-tag="removeTag" :loading="loading2">
                  <el-option v-for="item in searchList" :key="item.Id" :label="item.EmployeeName" :value="item.Id">
                    <span style="float: left">{{ item.EmployeeName }}</span>
                    <span style="float: right; color: #8492a6; font-size: 13px">{{ item.postName }}</span>
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row class="_caozuo_btn">
            <span>{{$t('fnc.w_kscaozuo')}}：</span>
            <span @click="accType(1)" :class="type==1?'_active':''">{{$t('fnc.w_sygongzhang')}}</span>
            <span @click="accType(2)" :class="type==2?'_active':''">{{$t('fnc.w_sysizhang')}}</span>
            <span @click="accType(3)" :class="type==3?'_active':''">{{$t('fnc.w_sypingtai')}}</span>
            <span @click="accType(4)" :class="type==4?'_active':''">{{$t('fnc.w_syzjinchi')}}</span>
            <span @click="accType(5)" :class="type==5?'_active':''">{{$t('fnc.w_syyhzhu')}}</span>
            <span @click="accType(6)" :class="type==6?'_active':''">{{$t('fnc.w_syxjzhanghu')}}</span>
          </el-row>
          <el-row class="_row_table">
            <el-col :span="14">
              <table class="singeRowTable" cellspacing="0" cellpadding="0" v-loading="loading">
                <thead>
                  <tr>
                    <th>{{$t('fnc.acc')}}</th>
                    <th width="150px">{{$t('fnc.shoukuan')}} <input type="checkbox" v-model="shouChe"
                        @change="isCheckAll(1)"><span class="_check_all">全选</span></th>
                    <th width="150px">{{$t('fnc.zhikuan')}} <input type="checkbox" v-model="zhiChe"
                        @change="isCheckAll(2)"><span class="_check_all">全选</span></th>
                    <th width="90px">{{$t('system.table_operation')}}</th>
                  </tr>
                </thead>
                <tbody>
                  <tr v-for="(item,index) in addMsg.list">
                    <td>
                      <span class="_fangkuang" v-if="item.IsPublic===1">{{$t('fnc.w_gsdgong')}}</span>
                      <span class="_fangkuang _fangkuang_si" v-if="item.IsPublic===0">{{$t('fnc.w_gsdsi')}}</span>
                      <span class="_accname">{{item.Name}}</span>
                    </td>
                    <td width="150px">
                      <input v-model="item.isInCheckbox" type="checkbox">
                    </td>
                    <td width="150px">
                      <input v-model="item.isOutCheckbox" type="checkbox">
                    </td>
                    <td width="90px">
                      <el-button type="danger" @click="deleteItem(index)" class="iconfont icon-img_delete_small" circle>
                      </el-button>
                    </td>
                  </tr>
                  <tr>
                    <td>
                      <el-cascader v-model="selectVal" :options="AccList" :show-all-levels="false" :props="AccListProps"
                        @change="handleItemChange">
                      </el-cascader>
                    </td>
                    <td width="150px">

                    </td>
                    <td width="150px">

                    </td>
                    <td width="90px">

                    </td>
                  </tr>
                </tbody>
              </table>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
  </div>
</template>
<script>
  import {
    queryEmployee
  } from '../../api/users/user'

  export default {
    data() {
      return {
        msg: {
          pageIndex: 1,
          pageSize: 15
        },
        addMsg: {
          ID: 0,
          Name: '',
          list: [],
          emList: [],
          listArr: [],
          BranchId: -1,
        },
        getAccListMsg: {
          IsPublic: -1,
          BankType: 0,
        },
        type: -1,
        addShow: false,
        loading: false,
        loading2: false,
        noData: false,
        zhiChe: false,
        shouChe: false,
        total: 0,
        currentPage: 1,
        text: '',
        dataList: [],
        searchList: [],
        AccList: [],
        rules: { //表单必填验证
          Name: [{
            required: true,
            message: '请填写窗口名称',
            trigger: 'blur'
          }],
          listArr: [{
            type: 'array',
            required: true,
            message: '请选择业务员',
            trigger: 'blur'
          }]
        },
        AccListProps: {
          value: 'Num',
          label: 'Name',
          children: 'children'
        },
        selectVal: [],
        transitionShow: false,
        transitionShow2: true,
        contenWidth: 0,
        contenHeight: 0,
        tableSize: 0,
        blockSize: 0,
        shouList: [],
        shouListLoading: false,
      }
    },
    created() {
      let allH, allW, cH, cW;
      allH = document.documentElement.clientHeight;
      allW = document.documentElement.clientWidth;
      cW = allW - 90;
      cH = allH - 187; //255 = 50 40 21 36 40
      this.contenWidth = cW;
      this.contenHeight = cH;
      this.msg.pageSize = parseInt(cH / 40) - 1;
      this.tableSize = this.msg.pageSize = parseInt(cH / 45);
    },
    methods: {
      switchMethod(t) {
        this.msg.pageIndex = 1;
        if (t === 1) {
          this.transitionShow = false;
          this.transitionShow2 = true;
          this.msg.pageSize = this.tableSize;
          this.getList();
        } else if (t === 2) {
          this.transitionShow = true;
          this.transitionShow2 = false;
          // 宽 235 高 206
          let cont = parseInt(this.contenWidth / 235) * parseInt(this.contenHeight / 236);
          this.msg.pageSize = cont;
          this.getList();
        }
      },
      Window_post_GetList(id, type) {
        this.shouList = [];
        this.shouListLoading = true;
        let msg = {
          ID: id,
          Direct: type,
        }
        this.apipost('Window_post_GetList', msg, r => {
          this.shouListLoading = false;
          if (r.data.resultCode == 1) {
            this.shouList = r.data.data;
          } else {

          }
        }, null)
      },
      goUrl(path, g) {
        this.$router.push({
          path:'/financial/financalDocument/'+ path,
          query: {
            Conditon: g,
            blank: 'y'
          }
        })
      },
      goUrlDetail(path, type, name, id) {
        this.$router.push({
          path: path,
          query: {
            WindowType: type,
            name: name,
            id: id,
            blank: 'y',
            tab: '出纳窗口单据信息'
          }
        })
      },
      removeTag(id) {
        this.addMsg.emList.forEach((x, index) => {
          if (x.EmId === id) {
            this.addMsg.emList.splice(index, 1)
          }
        })
      },
      mergeArray(list3, list1) {
        for (var i = 0; i < list3.length; i++) {
          for (var j = 0; j < list1.length; j++) {
            if (list3[i].EmId === list1[j].EmId) {
              list3.splice(i, 1);
            }
          }
        }
        for (var i = 0; i < list1.length; i++) {
          list3.push(list1[i]);
        }
        return list3;
      },
      addCashierWork() { // 提交保存
        if (this.addMsg.list.length == 0) return this.$message.error('请选择至少一个账户!')
        let sub = true;
        for (let i = 0; i < this.addMsg.list.length; i++) {
          let x = this.addMsg.list[i];
          if (!x.isInCheckbox && !x.isOutCheckbox) {
            sub = false;
            break;
          } else {
            if (x.isInCheckbox && x.isOutCheckbox) {
              x.Direct = 3;
            } else if (x.isInCheckbox) {
              x.Direct = 1;
            } else if (x.isOutCheckbox) {
              x.Direct = 2;
            }
          }
        }
        if (!sub) return this.$message.error('请选择出纳类型!')

        let emList = this.addMsg.listArr;
        let arr = [];
        emList.forEach(x => {
          this.searchList.forEach(y => {
            if (x == y.Id) {
              let obj = {
                'EmId': y.Id,
                'ID': 0,
                'WindowId': 0,
                'EmIdName': y.EmployeeName
              }
              arr.push(obj);
            }
          })
        });
        let list4 = this.mergeArray(arr, this.addMsg.emList);
        this.addMsg.emList = list4;
        this.apipost('Window_post_Set', this.addMsg, r => {
          if (r.data.resultCode == 1) {
            this.$message.success(r.data.message);
            this.getList();
            this.addShow = false;
            this.cancelEdit();
          } else {
            this.$message.error(r.data.message);
          }
        }, null)
      },
      submitForm(addMsg) { //提交创建、修改表单
        this.$refs[addMsg].validate((valid) => {
          if (valid) {
            this.addCashierWork();
          } else {
            return false;
          }
        });
      },
      isCheckAll(t) { //1 shou  2 zhi 全选
        if (t === 1) {
          if (this.shouChe) {
            this.addMsg.list.forEach(x => {
              x.isInCheckbox = true
            })
          } else {
            this.addMsg.list.forEach(x => {
              x.isInCheckbox = false
            })
          }
        } else {
          if (this.zhiChe) {
            this.addMsg.list.forEach(x => {
              x.isOutCheckbox = true
            })
          } else {
            this.addMsg.list.forEach(x => {
              x.isOutCheckbox = false
            })
          }
        }
      },
      deleteItem(i) {
        this.addMsg.list.splice(i, 1);
      },
      handleItemChange(obj) {
        let obj1 = this.AccList[obj[0]],
          obj2 = this.AccList[obj[0]].children[obj[1]],
          obj3 = this.AccList[obj[0]].children[obj[1]].children[obj[2]];
        let addMsgList = {
          ID: 0,
          AccountId: obj3.ID,
          Type: obj2.ID,
          AccountType: obj1.ID,
          Direct: 0,
          Name: obj3.Name + (obj3.BankNo ? obj3.BankNo : ''),
          IsPublic: obj1.IsPublic,
          isInCheckbox: obj3.Is_Income ? true : false,
          isOutCheckbox: obj3.Is_Outcome ? true : false,
          allName: obj3.Name + (obj3.BankNo ? obj3.BankNo : ''),
        }
        this.addMsg.list.push(addMsgList);
        this.selectVal = [];
      },
      getAccList() {
        this.apipost('BankAccount_post_GetTreeAccountList', this.getAccListMsg, r => {
          if (r.data.resultCode == 1) {
            function addNum(obj) {
              for (let i = 0; i < obj.length; i++) {
                obj[i]['Num'] = i;
                if (obj[i].hasOwnProperty('children')) {
                  obj[i].children = addNum(obj[i].children)
                }
              }
              return obj
            }
            this.AccList = addNum(r.data.data)
          } else {

          }
        }, null)
      },
      accType(t) {
        this.selectVal = [];
        if (this.type === t) {
          this.type = -1;
          this.getAccListMsg = {
            IsPublic: -1,
            BankType: 0,
          };
          this.getAccList();
        } else {
          this.type = t;
          let msg = {
            IsPublic: -1,
            BankType: 0,
          }
          if (t === 1) { //  1公 2私
            msg.IsPublic = 1;
            this.getAccListMsg = msg;
            this.getAccList();
          } else if (t === 2) {
            msg.IsPublic = 0;
            this.getAccListMsg = msg;
            this.getAccList();
          } else if (t === 3) {
            msg.BankType = 2;
            this.getAccListMsg = msg;
            this.getAccList();
          } else if (t === 4) {
            msg.BankType = 4;
            this.getAccListMsg = msg;
            this.getAccList();
          } else if (t === 5) {
            msg.BankType = 1;
            this.getAccListMsg = msg;
            this.getAccList();
          } else if (t === 6) {
            msg.BankType = 3;
            this.getAccListMsg = msg;
            this.getAccList();
          }
        }
      },
      financeinfoRemove(id, text) { // 删除货币
        this.$confirm('确定删除' + text + '出纳窗口？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.apipost('Window_post_Remove', {
            ID: id
          }, res => {
            if (res.data.resultCode == 1) {
              this.getList()
              this.$message.success(res.data.message);
            } else {
              this.$message.error(res.data.message);
            }
          }, err => {})
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
      },
      handleSelect(item) {
        this.addMsg.EmId = item.empId;
      },
      remoteMethod(query) {
        var qMsg = {
          EmployeeName: query
        }
        queryEmployee(qMsg).then(res => {
          if (res.Code == 1) {
            this.searchList = res.Data;
          }
        }).catch(() => {

        })
      },
      getList() {
        this.loading = true;
        this.apipost('Window_post_GetPageList', this.msg, res => {
          if (res.data.resultCode == 1) {
            this.dataList = res.data.data.pageData;
            this.total = res.data.data.count;
            if (this.total > 0) {
              this.noData = false;
            } else {
              this.noData = true;
            }
          } else {
            this.$message.error(res.data.message);
          }
          this.loading = false;
        }, err => {
          this.loading = false;
        })
      },
      editCurency(id) { //  修改  根据id 获取信息
        this.apipost('Window_post_Get', {
          ID: id
        }, res => {
          if (res.data.resultCode == 1) {
            let data = res.data.data;
            let arr = [];
            arr.push(data.AccountType);
            arr.push(data.Type);
            arr.push(data.AccountId);
            data.list.forEach(x => {
              if (x.Direct == 3) {
                x.isInCheckbox = true;
                x.isOutCheckbox = true;
              } else if (x.Direct == 1) {
                x.isInCheckbox = true;
                x.isOutCheckbox = false;
              } else if (x.Direct == 2) {
                x.isInCheckbox = false;
                x.isOutCheckbox = true;
              }
              x.Name = x.Alias;
              x.IsPublic = x.Is_Public;
            });
            this.addMsg = data;
            this.addMsg.listArr = [];
            if (data.emList && data.emList.length > 0) {
              data.emList.forEach(x => {
                this.remoteMethod('');
                this.addMsg.listArr.push(x.EmId)
              })
            }
            this.selectVal = arr;
            this.addShow = true;
          } else {
            this.tips(res.data.message, 'error');
          }
        }, err => {})
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      cancelEdit() { // 取消修改、新增
        this.addMsg = {
          ID: 0,
          Name: '',
          list: [],
          emList: [],
          listArr: [],
          BranchId: -1,
        }
      },
      resetForm(formName) { //弹出框取消 初始化谈框内表单
        this.$refs[formName].resetFields();
      },
      getEmployee() {
        queryEmployee({}).then(res => {
          if (res.Code == 1) {
            this.searchList = res.Data;
          }
        }).catch(() => {

        })
      }
    },
    mounted() {
      this.getList();
      this.getAccList();
      this.getEmployee();
    }
  }

</script>
