<style scoped>
    .CostType .addCompany {width: 440px;}
    /* 币种管理 */
    .cm_content{padding: 0 0;overflow-x: auto;}
    .cmc_item{float: left;width:205px;height: 123px;background:rgba(255,255,255,1);border-radius:4px;overflow: hidden;margin: 15px 15px 15px 0;border: 1px solid #ebebeb;position: relative;}
    .cmci_top{background-color: #47BF8C;padding: 14px 20px 0 20px;font-size: 14px;color: #FFFFFF}
    .cmci_top p._tit{border-bottom: 1px solid #3FB382;padding-bottom: 14px}
    .fc_red{color: #E95252 !important}
    .cmc_item:hover{box-shadow:0px 0px 20px rgba(191,191,191,1);transition: all linear 0.5s;}
    ._underline{text-decoration: underline;cursor: pointer;}
    .CostType ._vMG_edit{display: none;position:absolute;bottom:0;font-family: 'PingFangSc-Fine';left: 0;border-top:3px solid #38425d;background-color:#fff;padding:10px;width: 100%;z-index: 999}
    .CostType ._vMG_edit ._tit{padding-left: 10px;border-left: 3px solid #E95252; font-size: 16px;color: #000000}
    .CostType ._vMG_edit ._tit span{color: #666666;font-size: 14px}
    ._edHeight{height:400px;}
    .edHeight{display: block !important;min-height: 230px;}
    ._scrollbar::-webkit-scrollbar{width: 4px;height: 8px;}
    ._scrollbar::-webkit-scrollbar-thumb{border-radius: 4px;-webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);background: #c9c9c9;}
    ._scrollbar::-webkit-scrollbar-track{-webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);border-radius: 4px;background: #EDEDED;}
    .CostType ._info_box ul{margin-top: 15px}
    .CostType ._info_box ul li{float: left;}
    ._max_width{max-width:100%; overflow:hidden;text-overflow: ellipsis;white-space: nowrap;display: inline-block;vertical-align:top;}
    ._bumen{padding: 20px 0;text-align: left;height: 75px;}
    ._bumen p:nth-child(1){font-size: 14px;cursor: pointer;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
    ._bumen p.no_bumen{font-size: 12px; color: #ADE4CD}
    ._b_edit{position: absolute;right: 20px;top: 13px;z-index: 100;width: 32%;height: 35%;border-radius: 4px;text-align: right;opacity: 0;-webkit-transition: all linear 0.5s;transition: all linear 0.5s;}
    ._b_edit .el-button--danger{background-color: rgba(255,255,255,0.5);color: #FFFFFF;border: none}
    ._b_edit .el-button--primary{background:rgba(255,255,255,0.5);color: #FFFFFF;border: none}
    ._b_edit .el-button--danger:hover,._b_edit .el-button--primary:hover{background-color: #FFFFFF;color: #E95252}
    ._bumen:hover ._b_edit{opacity: 1;}
    .multiple_input .el-input {height: auto !important;}
    ._cmci_img{width: 48px;height: 48px;position: absolute;right: 15px;top: 30px;}
    .upload-demo {text-align: center;}
    .CostType ._add_saveBtn{text-align: right;margin-bottom: 20px;}
    .CostType .query-box{padding:20px 0 0 0}
    .CostType .el-radio+.el-radio{margin-left: 15px;}
    .CostType ._yuan{
        width:12px;
        height:12px;
        background:rgba(233,82,82,1);
        border-radius:50%;
        display: inline-block;
    }
    .CostType ._yuan._yuan_red{
        background:#47BF8C;
    }
    .CostType .po_content,.CostType .po_content_item{
    border-collapse: collapse;
}
.CostType .po_content{
    width: 100%;
}
.CostType .po_content tr:first-child{
    font-size: 12px;
    color: #666666;
}
.CostType .po_content tr th,.CostType .po_content tr td{
    padding: 10px 20px;
    text-align: left;
}
.CostType .po_content tr td{
    color: #333333;
    font-size: 14px;
    border:1px solid #E6E6E6;
}
.CostType .po_content tr td .iconfont{
    font-size: 14px;
    padding: 4px;
}
.CostType .query-box .iconfont{
    cursor: pointer;
    background-color: #E95252;
    color: white;
    width: 30px;
    height: 30px;
    display: inline-block;
    text-align: center;
    line-height: 30px;
    border-radius: 50%;
    margin-left: 10px;
}
.po_content_item tr td:last-child{
    border-right: 0px !important;
}
.po_content_item_str tr:first-child td,.po_content_item_two tr:first-child td{
    border-top: 0px !important;
}
.po_content_item_str tr:last-child td,.po_content_item_two tr:last-child td{
    border-bottom: 0px !important;
}
.po_content_item_str tr td:first-child,.po_content_item_two tr td:first-child{
    border-left: 0px !important;
}
  .cursorpointer_last:hover i{
    display: inline-block;
    margin-left: 10px;
  }
  .cursorpointer_last i{
    color: red;
    display: none;
  }
  .ct_Edit{
      position: absolute;
      right:10px;
      top:5px;
      color:#fff;
      cursor: pointer;
      z-index:999;
  }
  .ct_Edit:hover{
      color:#E95252;
  }
</style>
<template>
  <div class="flexOne CostType">
       <div class="query-box">
           <el-form class="_info_box clearfix"  label-width="110px">
               <el-row v-if="transitionShow2">
                    <el-col :span="4" :gutter="35">
                        <el-form-item :label="$t('fnc.fylxmingcheng')">
                            <el-input placeholder=""  v-model="msg.Name" @keyup.enter.native="initTableInfo()"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4" :gutter="35">
                        <el-form-item :label="$t('fnc.cjleixing')">
                            <el-select   v-model="msg.Tier" @change="getCostTypeList(1)">
                                <el-option :label='$t("pub.unlimitedSel")' :value='0'></el-option>
                                <el-option :label='$t("fnc.yiji")' :value='1'></el-option>
                                <el-option :label='$t("fnc.erji")' :value='2'></el-option>
                                <el-option :label='$t("fnc.sanji")' :value='3'></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4" :gutter="35">
                        <el-form-item :label="$t('fnc.shangjileixing')">
                            <el-select   v-model="msg.ParentId">
                                <el-option v-for="(item,index) in CostTypeList2" :label='item.Name' :key="item.ID" :value='item.ID' ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="4" :gutter="35">
                        <el-form-item label="适用部门">
                            <el-select  filterable  v-model='msg.DepartIDs' >
                                <el-option label='不限' value=''></el-option>
                                <el-option label='通用' value='0'></el-option>
                                <el-option v-for='item in departmentList'
                                    :label='item.DepartmentName'
                                    :value='item.DepartmentID'
                                    :key='item.DepartmentID'>
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col> -->
                </el-row>
           </el-form>
           <ul>
               <li>
                    <button class="hollowFixedBtn" @click="resetPageIndex(),initTableInfo()">{{$t('pub.searchBtn')}}</button>
                    <!-- <button type="button" class="normalBtn" @click="outerVisible=true">导入</button>
                    <button type="button" class="normalBtn" @click="downMuban()">下载导入模板</button> -->
                    <button class="normalBtn" @click="addShow=true,text=$t('pub.addBtn'),addFun(),resetInfo()" >{{$t('pub.addBtn')}}</button>
                    <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>
                    <!-- <button type="button" class="normalBtn" @click="method5()">导出</button> -->
               </li>
           </ul>
        </div>
        <div class="cm_content _scrollbar" :style="{height:transitionShow2?contenHeight+'px':''}" :class="addShow==true?'_edHeight':''">
            <div class="clearfix" v-if="transitionShow2" >
                <div class="cmc_item" v-for="(item,index) in tableInfo" v-loading='loading'>
                    <div class="cmci_top">
                        <p class="_tit">
                            <span class="_max_width">{{item.Name}}</span>
                            <img class="_cmci_img" v-if="item.Type===1" src="../../assets/img/f_shou.png" alt="">
                            <img class="_cmci_img" v-if="item.Type===2" src="../../assets/img/f_zhi.png" alt="">
                            <img class="_cmci_img" v-if="item.Type===3" src="../../assets/img/f_shouzhi.png" alt="">
                        </p>
                        <div class="_bumen" >
                            <p>{{$t('fnc.tanzhang')}}:{{item.IsShareAccount===0?$t('fnc.feitanzhang'): $t('fnc.tanzhang')}}</p>
                            <p>{{$t('fnc.ysbaobiao')}}:{{item.Is_Report===0? $t('fnc.bujinru') : $t('fnc.jinru')}}</p>
                            <p class="_b_edit">
                                <!-- <button type="button" class="el-button el-tooltip item el-button--danger is-circle" aria-describedby="el-tooltip-694" tabindex="0" @click="financeinfoRemove(item.ID,item.Name)"><i class="el-icon-delete"></i></button> -->
                                <button v-if="msg.EmployeeID==910" type="button" class="el-button el-tooltip item el-button--primary is-circle" aria-describedby="el-tooltip-5781" tabindex="0" @click="editCurency(item.ID),text='修改'"><i class="el-icon-edit"></i></button>
                            </p>
                        </div>
                    </div>
                    <div class="ct_Edit" @click="getEditInfo(item.ID)">
                        <i class="iconfont icon-xiugai"></i>
                    </div>
                </div>
            </div>
            <table class="po_content singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0" v-if="transitionShow" >
                <thead>
                    <tr>
                        <th width="200px">{{$t('fnc.yijimingcheng')}}</th>
                        <th width="150px">{{$t('fnc.erjimingcheng')}}</th>
                        <th width="150px">{{$t('fnc.sanjimingcheng')}}</th>
                        <th width="150px">{{$t('fnc.sygongsi')}}</th>
                        <th width="150px">{{$t('fnc.sybumen')}}</th>
                        <th width="150px">{{$t('fnc.sygangwei')}}</th>
                        <th width="150px">{{$t('fnc.syrenyuan')}}</th>
                        <th>{{$t('fnc.feiyongfangxiang')}}</th>
                        <th>{{$t('fnc.tanzhang')}}</th>
                    </tr>
                </thead>
                <tbody class="po_content_item">
                    <tr v-for="(item,index) in CostTypeTreeList" :key="index" v-loading="loading">
                        <td width="200px">
                            <span class="cursorpointer" v-if="msg.EmployeeID==910"  @click="editCurency(item.ID),text=$t('pub.updateMsg')">{{item.Name}}</span>
                            <span class="cursorpointer" v-else>{{item.Name}}</span>
                        </td>
                        <template v-if="item.ChildList.length>0">
                            <td colspan="8" style="padding:0">
                                <table class="po_content_item po_content_item_two" style="width: 100%;" cellspacing="0" cellpadding="0">
                                    <tbody>
                                        <tr v-for="(son,sIndex) in item.ChildList">
                                            <td style=""  width="150px">
                                            <span class="cursorpointer" v-if='msg.EmployeeID==910' @click="editCurency(son.ID),text=$t('pub.updateMsg')">{{son.Name}}</span>
                                            <span class="cursorpointer" v-else>{{son.Name}}</span></td>
                                            <template v-if="son.ChildList.length>0">
                                                <td colspan="7" style="padding:0">
                                                    <table class="po_content_item po_content_item_str" style="width: 100%" cellspacing="0" cellpadding="0">
                                                        <tbody>
                                                            <tr v-for="(grSon,gsIndex) in son.ChildList">
                                                                <td class="cursorpointer_last"  width="150px">
                                                                    <span class="cursorpointer" v-if='msg.EmployeeID==910' @click="editCurency(grSon.ID),text=$t('pub.updateMsg')">{{grSon.Name}} <i @click.stop="financeinfoRemove(grSon.ID,grSon.Name)" class="el-icon-delete"></i></span>
                                                                    <span class="cursorpointer" v-else>{{grSon.Name}}</span></td>
                                                              <td width="150px">{{grSon.BName}}</td>
                                                              <td width="150px">{{grSon.DeName}}</td>
                                                              <td width="150px">{{grSon.PName}}</td>
                                                              <td width="150px">{{grSon.RName}}</td>
                                                                <td style="">
                                                                    <span v-if="grSon.Type===1">{{$t('restaurant.res_income')}}</span>
                                                                    <span v-if="grSon.Type===2">{{$t('restaurant.res_outcome')}}</span>
                                                                    <span v-if="grSon.Type===3">{{$t('fnc.shouzhi')}}</span>
                                                                </td>
                                                                <td style="">
                                                                    <span class="_yuan" v-if="grSon.Type==1"></span>
                                                                    <span class="_yuan _yuan_red" v-if="grSon.Type!=1"></span>
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </td>
                                            </template>
                                            <template v-else>
                                                <td width="150px"></td>
                                              <td width="150px">{{son.BName}}</td>
                                              <td width="150px">{{son.DeName}}</td>
                                              <td width="150px">{{son.PName}}</td>
                                              <td width="150px">{{son.RName}}</td>
                                                <td style="">
                                                    <span v-if="son.Type===1">{{$t('restaurant.res_income')}}</span>
                                                    <span v-if="son.Type===2">{{$t('restaurant.res_outcome')}}</span>
                                                    <span v-if="son.Type===3">{{$t('fnc.shouzhi')}}</span>
                                                </td>
                                                <td style="">
                                                    <span class="_yuan" v-if="son.Type==1"></span>
                                                    <span class="_yuan _yuan_red" v-if="son.Type!=1"></span>
                                                </td>
                                            </template>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </template>
                        <template v-else>
                            <td width="150px"></td>
                            <td width="150px"></td>
                            <td width="150px">{{item.BName}}</td>
                            <td width="150px">{{item.DeName}}</td>
                            <td width="150px">{{item.PName}}</td>
                            <td width="150px">{{item.RName}}</td>
                            <td>
                                <span v-if="item.Type===1">{{$t('restaurant.res_income')}}</span>
                                <span v-if="item.Type===2">{{$t('restaurant.res_outcome')}}</span>
                                <span v-if="item.Type===3">{{$t('fnc.shouzhi')}}</span>
                            </td>
                            <td>
                                <span class="_yuan" v-if="item.Type==1"></span>
                                <span class="_yuan _yuan_red" v-if="item.Type!=1"></span>
                            </td>
                        </template>
                        <!-- <td>{{item.Name}}</td>
                        <td>{{'层级类型'}}</td>
                        <td>{{'上级类型'}}</td>
                        <td>{{'适用公司'}}</td>
                        <td>{{'适用部门'}}</td>
                        <td>{{'适用岗位'}}</td>
                        <td>{{'适用人员'}}</td>
                        <td>
                            <span v-if="item.Type===1">收入</span>
                            <span v-if="item.Type===2">支出</span>
                            <span v-if="item.Type===3">收支</span>
                        </td>
                        <td>
                            <span class="_yuan" v-if="item.Type==1"></span>
                            <span class="_yuan _yuan_red" v-if="item.Type!=1"></span>
                        </td>
                        <td>
                            <el-row>
                                <el-tooltip class="item" effect="dark" content="修改" placement="top-start">
                                    <el-button type="primary" class="iconfont icon-bianji-smal" circle @click="editCurency(item.ID),text='修改'"></el-button>
                                </el-tooltip>
                                <el-tooltip class="item" effect="dark" content="删除" placement="top-start">
                                    <el-button type="danger" class="iconfont icon-img_delete_small" circle @click="financeinfoRemove(item.ID,item.Name)"></el-button>
                                </el-tooltip>
                            </el-row>
                        </td> -->
                    </tr>
                </tbody>
            </table>
            <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.feiyongleixing')}}</p>
                </el-col>
                <el-col :span="4" class="_add_saveBtn">
                    <button type="button" class="normalBtn" @click="submitForm('addMsg')">{{$t('pub.saveBtn')}}</button>
                    <button class="hollowFixedBtn" type="button" @click="cancelEdit(),resetForm('addMsg'),addShow=false">{{$t('pub.cancelBtn')}}</button>
                </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('fnc.Name')" prop="Name">
                            <el-input v-model="addMsg.Name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item :label="$t('fnc.cjleixing')" prop="Tier">
                            <el-select  filterable  v-model='addMsg.Tier' @change="getCostTypeList(2)">
                                <el-option :label="$t('fnc.yiji')" :value='1'></el-option>
                                <el-option :label="$t('fnc.erji')" :value='2'></el-option>
                                <el-option :label="$t('fnc.sanji')" :value='3'></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item :label="$t('fnc.shangjileixing') + ':'">
                            <el-select  filterable  v-model='addMsg.ParentId' >
                                <el-option v-for="(item,index) in CostTypeList" :label='item.Name' :key="item.ID" :value='item.ID' ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item :label="$t('system.table_rank')+':'">
                            <el-input v-model="addMsg.Sort"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item :label="$t('fnc.sygongsi') + ':'">
                            <el-select filterable   v-model='addMsg.BranchId' >
                            <!--<el-select filterable   v-model='addMsg.BranchId' @change="getDepartmentList()">-->
                                <el-option :label="$t('active.cl_tongyong')" :value='-1'></el-option>
                                <el-option v-for='item in companyList'
                                    :label='item.BName'
                                    :value='item.Id'
                                    :key='item.Id'>
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item :label="$t('fnc.sybumen')">
                            <!--<el-select filterable   v-model='addMsg.DepartmentID' @change="getPostList()">-->
                            <el-select filterable   v-model='addMsg.DepartmentID' >
                                <el-option :label="$t('active.cl_tongyong')" :value='-1'></el-option>
                                <el-option v-for='item in DepartmentList'
                                    :label='item.DepartmentName'
                                    :value='item.DepartmentID'
                                    :key='item.DepartmentID'>
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item :label="$t('fnc.sygangwei') + ':'">
                            <el-select filterable   v-model='addMsg.PostID' >
                            <!--<el-select filterable   v-model='addMsg.PostID' @change="getEmployeeList()">-->
                                <el-option :label="$t('active.cl_tongyong')" :value='-1'></el-option>
                                <el-option v-for='item in PostList'
                                    :label='item.PostName'
                                    :value='item.PostId'
                                    :key='item.PostId'>
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item :label="$t('fnc.syrenyuan') + ':'">
                            <el-select filterable multiple v-model='EmployeeIDList' @change="EmployeeIDRule">
                                <el-option :label="$t('active.cl_tongyong')" :value='-1'></el-option>
                                <el-option v-for='item in EmployeeList'
                                    :disabled = 'item.disabled'
                                    :label='item.EmName'
                                    :value='item.EmployeeId'
                                    :key='item.EmployeeId'>
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="$t('fnc.feiyongfangxiang') + ':'">
                            <el-radio v-model="addMsg.Type" :label="1">{{$t('restaurant.res_income')}}</el-radio>
                            <el-radio v-model="addMsg.Type" :label="2">{{$t('restaurant.res_outcome')}}</el-radio>
                            <el-radio v-model="addMsg.Type" :label="3">{{$t('fnc.shouzhi')}}</el-radio>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item :label="$t('fnc.tanzhang') + ':'">
                            <el-radio v-model="addMsg.IsShareAccount" :label="1">{{$t('fnc.yes')}}</el-radio>
                            <el-radio v-model="addMsg.IsShareAccount" :label="0">{{$t('fnc.fou')}}</el-radio>
                        </el-form-item>
                    </el-col>
                  <el-col :span="6">
                    <el-form-item :label="$t('fnc.ysbaobiao') + ':'">
                      <el-radio v-model="addMsg.Is_Report" :label="0">{{$t('fnc.bujinru')}}</el-radio>
                      <el-radio v-model="addMsg.Is_Report" :label="1">{{$t('fnc.jinru')}}</el-radio>
                    </el-form-item>
                  </el-col>
                </el-row>
            </el-form>
        </div>
        <div class="noData" v-show="noData">
            {{$t('system.content_noData')}}
        </div>
        <div v-if="transitionShow2">
            <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>
        <el-dialog custom-class='w700' :title="$t('Airticket.Air_bulkImport')" :visible.sync="outerVisible" center>
            <el-upload drag class="upload-demo" ref="upload" :action="getImportFileUrl()" :on-success="handleAvatarSuccess"
                :before-upload="beforeAvatarUpload">
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">{{$t('tips.tuodongwenjian')}}<em>{{$t('tips.dianjishanhcuan')}}</em></div>
                <div slot="tip" class="el-upload__tip">{{$t('fnc.znengExcel')}}</div>
            </el-upload>
        </el-dialog>
    </div>
</template>
<script>
    import Treeselect from '@riophae/vue-treeselect'
    import '@riophae/vue-treeselect/dist/vue-treeselect.css'
	export default {
        components: { Treeselect },
		data() {
			return {
                value: null,
                // define optionsoptions
                normalizer(node) {
                    return {
                        id: node.DepartmentId,
                        label: node.DepartmentName,
                        children: node.ChildList,
                    }
                },
                msg:{
                    pageIndex:1,
                    pageSize:21,
                    DepartIDs:'',
                    Name:'',
                    Tier:0,
                    ParentId:'',
                    EmployeeID:-1,
                },
                addMsg:{
                  ID:0,
                  Name:'',
                  Type:1, // 1收 2支 3收支
                  Tier:1,
                  ParentId:'',
                  IsShareAccount:0,
                  Sort:'0',
                  BranchId:-1,
                  PostID:-1,
                  DepartmentID:-1,
                  EmployeeID: -1,
                  list:[],
                  Is_Report:0
                },
                EmployeeIDList:[],
                text:'',
                total:0,
                currentPage: 1,
                loading:true,
                airlineList:'',
                tableInfo:'',
                addShow:false,
                noData:false,
                dialogTitle: '',
                deleteID:'',
                ProfitLossList:[],
                departmentList:[],
                DepartmentTreeList:[],
                showBtnID:-1,
                pickerOptions1:{
                    disabledDate(time) {
                        //  return time.getTime()==time.getTime();
                    }
                },
                departmentMsg: {
					RB_Group_Id: '0',
					RB_Branch_Id:'-1',
					Status:'0',
					ParentId:'-1',
					Tier:'0',
				},
                rules: {//表单必填验证
                    Name: [
                        { required: true, message: this.$t('rule.qtxfymingcheng'), trigger: 'blur' }
                    ],
                    Tier: [
                        { required: true, message: this.$t('rule.qxzlxcengji'), trigger: 'change' }
                    ]
                },
                outerVisible: false,
                CostTypeList:[],
                companyList:[],
                companyMsg:{
					RB_Group_Id:"0",
					Status:0,
                },
                getDepartmentMsg:{
                    RB_Group_Id: '0',
					RB_Branch_Id:'-1',
					Status:'0',
					ParentId:'-1',
					Tier:'0',
                },
                DepartmentList:[],
                getPostMsg:{
                    RB_Department_Id:'',
                    RB_Branch_Id:'',
                    PostName:'',
                    RB_Group_Id:''
                },
                PostList:[],
                getEmployeeMsg:{
                    GroupId:'',
                    BranchId:'',
                    DepartmentId:'',
                    PostId:'',
                    IsLeave:0,
                },
                EmployeeList:[],
                CostTypeList2:[],
                CostTypeTreeList:[],
                transitionShow:false,
                transitionShow2:true,
                contenWidth:0,
                contenHeight:0,
                tableSize:0,
                blockSize:0,
			}
        },created(){
            let allH,allW,cH,cW;
            allH = document.documentElement.clientHeight;
            allW = document.documentElement.clientWidth;
            cW = allW-90;
            cH = allH-260; //298 = 顶部导航 50 面包屑83 查询框75 table表头41 分页49
            this.contenWidth = cW;
            this.contenHeight = cH;
            this.tableSize = parseInt(cH/45);
            this.msg.pageSize = parseInt(this.contenWidth/220) * parseInt(this.contenHeight/153);
        },
		methods: {
      EmployeeIDRule: function (val) {
        if (val.length === 0) {
          this.EmployeeList.forEach(y=>{
            y.disabled = false;
          });
          return;
        }
        val.forEach(x=>{
          if (x === -1) {
            this.EmployeeList.forEach(y=>{
              y.disabled = true;
              this.EmployeeIDList = [-1];
            })
          }
        })
      },
            getCostTypeTreeList(){  // 获取费用类型
                this.apipost('Financial_post_GetTreeList',{Type:0},res=>{
                    if(res.data.resultCode==1){
                        this.CostTypeTreeList=res.data.data;
                        this.$forceUpdate();
                    }else{}
                },err=>{})
            },
            switchMethod(t){
                this.msg.pageIndex = 1;
                if(t===1){
                    this.transitionShow = false;
                    this.transitionShow2 = true;
                  let cont = parseInt(this.contenWidth/220) * parseInt(this.contenHeight/153);
                  this.msg.pageSize = cont;
                }else if(t===2){
                    this.transitionShow = true;
                    this.transitionShow2 = false;
                    // 宽 220 高 153

                  this.msg.pageSize = this.tableSize;
                }
                this.initTableInfo();
                this.getCostTypeTreeList();
            },
            getEmployeeList(all){ //根据公司获、部门、岗位 获取员工
                if(this.addMsg.PostID==-1 && !all){
                    this.addMsg.EmployeeID=-1;
                    return
                }
                this.addMsg.EmployeeID = '';
                this.getEmployeeMsg.GroupId = all ? -1 : this.companyMsg.RB_Group_Id;
                this.getEmployeeMsg.BranchId = all ? -1 : this.addMsg.BranchId;
                this.getEmployeeMsg.DepartmentId = all ? -1 : this.addMsg.DepartmentID;
                this.getEmployeeMsg.PostId = all ? -1 : this.addMsg.PostID;
                this.apipost('admin_get_EmployeeGetList',this.getEmployeeMsg, res => {
				    this.EmployeeList = res.data.data;
				}, err => {})
            },
            getPostList(all){ //根据公司获、部门 获取岗位
                if(this.addMsg.DepartmentID==-1 && !all){
                    this.addMsg.PostID=-1;
                    this.addMsg.EmployeeID=-1;
                    return
                }
                if (!all) {
                  this.EmployeeList = [];
                  this.EmployeeIDList = [];
                }
                this.addMsg.PostID = '';
                this.addMsg.EmployeeID = '';
                this.getPostMsg.RB_Group_Id = all ? -1 : this.companyMsg.RB_Group_Id;
                this.getPostMsg.RB_Branch_Id = all ? -1 : this.addMsg.BranchId;
                this.getPostMsg.RB_Department_Id = all ? -1 : this.addMsg.DepartmentID;
                this.apipost('admin_get_PostGetList',this.getPostMsg, res => {
				    this.PostList = res.data.data;
				}, err => {})
            },
            getDepartmentList(all){  //根据公司获取 部门
                if(this.addMsg.BranchId==-1 && !all){
                    this.addMsg.DepartmentID=-1;
                    this.addMsg.PostID=-1;
                    this.addMsg.EmployeeID=-1;
                    return
                }
              if (!all) {
                this.EmployeeList = [];
                this.PostList = [];
                this.EmployeeIDList = [];
              }
                this.addMsg.PostID = '';
                this.addMsg.DepartmentID = '';
                this.addMsg.EmployeeID = '';
                this.getDepartmentMsg.RB_Group_Id = all ? -1 : this.companyMsg.RB_Group_Id;
                this.getDepartmentMsg.RB_Branch_Id = all ? -1 : this.addMsg.BranchId;
                this.apipost('admin_get_DepartmentGetList',this.getDepartmentMsg, res => {
				    this.DepartmentList = res.data.data;
				}, err => {})
            },
            getCompany(){ //公司
                this.EmployeeList = [];
                this.PostList = [];
                this.DepartmentList = [];
				this.apipost('admin_get_BranchGetList', this.companyMsg, res => {
				    this.companyList = res.data.data;
				}, err => {})
			},
            getCostTypeList(t,x){
                if(!x){
                    this.addMsg.ParentId = '';
                }
                let msg = {
                    Name:'',
                    Type:0,
                    DepartIDs:'',
                    Tier:t===1?this.msg.Tier-1:this.addMsg.Tier-1,
                }
                this.apipost('financeinfo_post_GetCostTypeList',msg,r=>{
                    if(r.data.resultCode==1){
                        if(t===1){
                            this.msg.ParentId ='';
                            this.CostTypeList2 = r.data.data;
                        }else{
                            this.CostTypeList = r.data.data;
                        }
                    }else{

                    }
                },null)
            },
            getImportFileUrl() {
                let url =this.domainManager().UploadFileUrl + "?cmd=dmc_post_LocalFileUpload&fileType=1&fileLimit=10&uid=2&Type=3"
                return url;
            },
            beforeAvatarUpload(file) {
                const excel = file.type === "application/vnd.ms-excel";
                if (!excel) {
                    this.Error(this.$t('tips.shangchuanExcel'));
                }
                return excel;
            },
            handleAvatarSuccess(res, file) {
                if (res.resultCode == 1) {
                    this.Success(res.message);
                    this.outerVisible = false;
                    this.initTableInfo();
                    this.$refs.upload.clearFiles()
                }
            },
            downMuban(){
                this.apipost('financeinfo_post_DownCostType',{},res=>{
					if(res.data.resultCode==1){
		                const link = document.createElement('a');
		                let _loadUrl=this.domainManager().DomainUrl;
                        link.href = _loadUrl+res.data.data.FileUrl;
		                document.body.appendChild(link);
		                link.click();
					}
				},err=>{})
            },
            getDepartment() {  //获取部门
				this.apipost('admin_get_DepartmentGetList', this.departmentMsg, res => {
					if(res.data.resultCode == 1) {
						this.departmentList = res.data.data;
					}
				}, err => {})
			},
            getProfitLossList(id){// 获取禁用时间
                this.apipost('FinanceInfo_post_GetProfitLossList',{CurrencyId:id}, res => {
                    if(res.data.resultCode == 1) {
                        this.ProfitLossList = res.data.data
                        // new Date(this.ProfitLossList[0].TermNum).getTime()
                    } else {
                        this.tips(res.data.message,'error');
                    }
                }, err => {})
            },
            regNum(n,t){  // 判断数字    n 值 t 类型
                let reg = /^\d+(\.\d{0,6})?$/
                if(!n)return 0
                if(t==2){
                    if(reg.test(n)){
                        return Number(n)
                    }
                    return 0;
                }else if(t==1){
                    if(reg.test(n)){
                        return Number(n)
                    }
                    return 0
                }
            },
            financeinfoRemove(id,text){  // 删除货币
                this.$confirm(this.$t('tips.qrsc')+text+this.$t('fnc.feiyongleixing'), '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                   this.apipost('financeinfo_post_RemoveCostType',{ID:id}, res => {
                        if(res.data.resultCode == 1) {
                           this.initTableInfo();
                            this.getCostTypeTreeList();
                           this.tips(res.data.message,'success');
                        } else {
                            this.tips(res.data.message,'error');
                        }
                    }, err => {})
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });
            },
            //导出费用类型明细报表
             method5: function() {
                this.GetLocalFile("financeinfo_post_OutToCostTypeExcel", this.msg,"费用类型明细报表.xls");
                } ,
            editCurency(id){  //  修改信息
                this.apipost('financeinfo_post_GetCostType',{ID:id}, res => {
                    if(res.data.resultCode == 1) {
                        let data = res.data.data
                        // PostID
                        // DepartmentID
                        // EmployeeID
                        let Type1 = false,
                         Type2 = false,
                         Type3 = false;
                        if (data.DepartList && data.DepartList.length>0){
                          this.EmployeeIDList = [];
                          data.DepartList.forEach(x =>{
                            if(x.Type==1){
                              Type1 = true;
                              data.BranchId = x.departmentId;
                              this.addMsg.BranchId = x.departmentId;
                              if(x.departmentId!=-1){
                                this.getPostList()
                              }
                            }
                            if(x.Type==3){
                              Type2 = true;
                              data.PostID = x.departmentId;
                              this.addMsg.PostID = x.departmentId;
                              if(x.departmentId!=-1){
                                this.getPostList()
                              }
                            }
                            if(x.Type==2){
                              Type3 = true;
                              data.DepartmentID = x.departmentId;
                              this.addMsg.DepartmentID = x.departmentId;
                              if(x.departmentId!=-1){
                                this.getDepartmentList()
                              }
                            }
                            if(x.Type==4){
                              data.EmployeeID = x.departmentId;
                              this.addMsg.EmployeeID = x.departmentId;
                              this.EmployeeIDList.push(x.departmentId);
                              // if(x.departmentId!=-1){
                              //     this.getEmployeeList()
                              // }
                            }
                          });
                        }
                        if (!Type1 && !Type2 && !Type3) {
                          this.getEmployeeList('all');
                          this.getDepartmentList('all');
                          this.getPostList('all');
                        } else {
                          this.getEmployeeList()
                        }
                        data.list = [];
                        data.IsShareAccount = data.IsShareAccount;
                        this.addShow = true;
                        this.addMsg = data;
                        if(data.Tier>1){
                            this.getCostTypeList(2,1);
                        }
                    } else {
                        this.tips(res.data.message,'error');
                    }
                }, err => {})
            },
            cancelEdit(t){  // 取消修改、新增
                this.addMsg = {
                    ID:0,
                    Name:'',
                    Type:1,
                    Tier:'',
                    ParentId:'',
                    IsShareAccount:0,
                    Sort:'0',
                    BranchId:-1,
                    PostID:-1,
                    DepartmentID:-1,
                    EmployeeID:-1,
                    list:[],
                  Is_Report:0
                }
                if(!t){
                    this.addShow=false
                }
                this.DepartmentList=[];
                this.PostList=[];
                this.EmployeeList=[];
                this.CostTypeList = [];
            },
            initTableInfo(){//获取数据
                this.tableInfo = [];
                this.loading = true;
                this.apipost('financeinfo_post_GetCostTypePageList',this.msg, res => {
						if(res.data.resultCode == 1) {
                            this.tableInfo = res.data.data.pageData;
                            this.total = res.data.data.count;
                            if(this.total>0){
                                this.noData =false;
                            }else{
                                this.noData =true;
                            }
                            this.loading = false;
						} else {
                            this.tips(res.data.message,'error');
						}
                }, err => {})
            },
            handleCurrentChange(val) {
				this.msg.pageIndex = val;
				this.initTableInfo();
            },
            resetPageIndex(){
                this.msg.pageIndex=1;
                this.currentPage = 1
            },
            //点击修改
            getEditInfo(ID){
                let msg = {
                    ID:ID
                }
                this.apipost('financeinfo_post_GetCostType',msg, res => {
                    if(res.data.resultCode == 1) {
                        this.addShow=true;
                        var dataList = res.data.data;
                        this.getPostList();
                        this.getDepartmentList();
                        this.getEmployeeList('all');
                        this.getPostList('all');
                        this.EmployeeIDList=[];
                        this.addMsg.ID = dataList.ID;
                        this.addMsg.Name = dataList.Name;
                        this.addMsg.Type = dataList.Type;
                        this.addMsg.Tier = dataList.Tier;
                        this.addMsg.ParentId = dataList.ParentId;
                        this.addMsg.IsShareAccount = dataList.IsShareAccount;
                        this.addMsg.Sort = dataList.Sort;
                        this.addMsg.Is_Report = dataList.Is_Report;
                        // this.addMsg = dataList;
                        if(dataList.DepartList.length>0){
                            dataList.DepartList.forEach(x=>{
                                switch(x.Type){
                                    case 1:
                                        this.addMsg.BranchId = x.departmentId;
                                    break;
                                    case 2:
                                        this.addMsg.PostID = x.departmentId;
                                    break;
                                    case 3:
                                        this.addMsg.DepartmentID = x.departmentId;
                                    break;
                                    case 4:
                                        this.addMsg.EmployeeID = x.departmentId;
                                        this.EmployeeIDList.push(x.departmentId);
                                    break;
                                    case 5:
                                        this.addMsg.BranchId = -1;
                                        this.addMsg.PostID = -1;
                                        this.addMsg.DepartmentID = -1;
                                        this.addMsg.EmployeeID = -1;
                                        this.EmployeeIDList.push(-1);
                                }
                            })
                        }
                    } else {
                        this.Error(res.data.message);
                    }
                }, err => {})
            },
            //重置表单
            resetInfo(){
                var msg = {
                    ID:0,
                    Name:'',
                    Type:1, // 1收 2支 3收支
                    Tier:1,
                    ParentId:'',
                    IsShareAccount:0,
                    Sort:'0',
                    BranchId:-1,
                    PostID:-1,
                    DepartmentID:-1,
                    EmployeeID: -1,
                    list:[],
                    Is_Report:0
                }
                this.addMsg = msg;
            },
            addFlightmodule(){//添加
                this.addMsg.list = [];
                if(this.addMsg.Tier===1){
                    this.addMsg.ParentId=0;
                }else if(this.addMsg.Tier!=1&&this.addMsg.ParentId==''){
                    return this.$message.error('请选择上级类型')
                }
                if(this.addMsg.BranchId!=null&&this.addMsg.BranchId!=-1){
                    let obj = {
                        ID:0,
                        Type:1,
                        departmentId:this.addMsg.BranchId
                    }
                    this.addMsg.list.push(obj)
                }
                if(this.addMsg.PostID&&this.addMsg.PostID!=-1){
                    let obj = {
                        ID:0,
                        Type:2,
                        departmentId:this.addMsg.PostID
                    }
                    this.addMsg.list.push(obj)
                }
                if(this.addMsg.DepartmentID&&this.addMsg.DepartmentID!=-1){
                    let obj = {
                        ID:0,
                        Type:3,
                        departmentId:this.addMsg.DepartmentID
                    }
                    this.addMsg.list.push(obj)
                }
                if(this.EmployeeIDList.length > 0){
                  this.EmployeeIDList.forEach(x=>{
                    let obj = {
                      ID:0,
                      Type:4,
                      departmentId:x
                    };
                    this.addMsg.list.push(obj)
                  });
                }
                // if(this.addMsg.EmployeeID&&this.addMsg.EmployeeID!=-1){
                //     let obj = {
                //         ID:0,
                //         Type:4,
                //         departmentId:this.addMsg.EmployeeID
                //     }
                //     this.addMsg.list.push(obj)
                // }
                if(this.EmployeeIDList[0]===-1&&this.addMsg.DepartmentID===-1&&this.addMsg.PostID===-1&&this.addMsg.BranchId===-1){
                    let obj = {
                        ID:0,
                        Type:5,
                        departmentId:0
                    }
                    this.addMsg.list.push(obj)
                }
                this.apipost('financeinfo_post_SetCostType',this.addMsg, res => {
                    if(res.data.resultCode == 1) {
                      this.tips(res.data.message,'success');
                      this.initTableInfo();
                      this.addShow =false;
                      this.cancelEdit();
                      this.getCostTypeTreeList();
                      this.EmployeeIDList = [];
                    } else {
                        this.tips(res.data.message,'error');
                    }
                }, err => {})
            },
            submitForm(addMsg) {//提交创建、修改表单
                let that = this;
                that.$refs[addMsg].validate((valid) => {
                    if (valid) {
                        that.addFlightmodule()
                    } else {
                        return false;
                    }
                });
            },
            resetForm(formName) {//弹出框取消 初始化谈框内表单
                this.$refs[formName].resetFields();
            },
            tips(msg,type) {
                this.$message({
                    message: msg,
                    duration:2000,
                    type: type
                });
            },
            addFun: function () {
              this.getDepartmentList('all');
              this.getPostList('all');
              this.getEmployeeList('all');
              this.EmployeeIDList=[];
              this.EmployeeIDList.push(-1);
            }
        },
        mounted(){
            this.initTableInfo();
            let userInfo = this.getLocalStorage();
            this.departmentMsg.RB_Group_Id = this.companyMsg.RB_Group_Id = userInfo.RB_Group_id; //集团
            this.msg.EmployeeID=userInfo.EmployeeId;
            this.getDepartment();
            this.getCompany();
            this.getCostTypeTreeList();
            this.getDepartmentList('all');
            this.getPostList('all');
            this.getEmployeeList('all');

        }
	}
</script>