<style>
.page_CapitalAllocation .query-box{
  padding: 0;
}
.page_CapitalAllocation .form{
  padding-top: 15px;
}
.page_CapitalAllocation .el-date-editor .el-range-separator {
  padding: 0;
  line-height: 29px;
}
.page_CapitalAllocation .el-select{
  width: 100%;
}
.page_CapitalAllocation .page_CapitalAllocation_list {
  width: 100%;
}
.page_CapitalAllocation i.icon-sousuo,.page_CapitalAllocation i.el-icon-edit{
    width: 30px;
    height: 30px;
    display: inline-block;
    color: white !important;
    border-radius: 50%;
    text-align: center;
    line-height: 30px;
    margin-right: 10px;
    cursor: pointer;
    outline: none;
}
.page_CapitalAllocation i.el-icon-edit{background-color: #00C6FF;font-size: 16px;}
.page_CapitalAllocation i.el-icon-edit:hover{background-color: #59daff}
.page_CapitalAllocation i.el-icon-edit:active{background-color: #00b8ec}
.page_CapitalAllocation i.icon-sousuo{background-color: #47BF8C;}
.page_CapitalAllocation i.icon-sousuo:hover{background-color: #66bb97}
.page_CapitalAllocation i.icon-sousuo:active{background-color: #35ab79}
.page_CapitalAllocation ._btn_group{font-size: 14px;}
.page_CapitalAllocation .icon-daiqueren{color: #4BCA81}
.page_CapitalAllocation .icon-yiqueren{color: #4BCA81}
.page_CapitalAllocation .icon-yiquxiao{color: #959595}
.page_CapitalAllocation .icon-shenhebohui{color: #E95252}
.page_CapitalAllocation .icon-icon-zancun{color: #FF9C01}
.page_CapitalAllocation .text_d{text-decoration: underline;cursor: pointer;}
.InfoChangeLog{height: auto;max-height: 220px;background-color: #FFFFFF;}
.changLogList{padding-left: 20px;max-height: 180px;overflow: auto;}
.changLogList_l{border-left: 1px solid #E9E9E9;position: relative;padding-bottom: 10px;padding-left: 20px;padding-top: 10px;}
._radius_green{background-color: #47BF8C;width: 7px;height: 7px;border-radius: 50%;display: inline-block;position: absolute;left: -4px;top: 19px;}
.changLog_time{color: #666666;font-size: 12px;display: inline-block;padding-right: 10px}
</style>
<template>
  <div class="page_CapitalAllocation">
    <div class="query-box">
      <ul>
        <li>
          <input v-if="btnShow" type="button" class="normalBtn" :value="$t('op.fgszjdb')" @click="goAddurl('addCapitalAllocation')"/>
          <input type="button" class="normalBtn" :value="$t('pub.addBtn')" @click="goURL('addCapitalAllocation')"/>
          <input type="button" class="hollowFixedBtn" :value="$t('pub.searchBtn')" @click="getList()"/>
          <input type="button" class="normalBtn" :value="$t('visa.v_daochu')" @click="method5()"/>
        </li>
      </ul>
    </div>
    <el-form label-width="100px" class="form">
      <el-row :gutter="20">
        <el-col :span="4">
          <el-form-item :label="$t('fnc.djbianhao')">
            <el-input v-model="msg.FrID"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item :label="$t('system.table_company')">
            <el-select v-model="msg.RB_Branch_Id" :placeholder="$t('rule.company')" @change="getDepartmentMsg.RB_Branch_Id = msg.RB_Branch_Id, getDepartment(),msg.RB_Depart_Id = -2">
              <el-option :value="-1" :label="$t('pub.unlimitedSel')"></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('admin.admin_Department')">
            <el-select v-model="msg.RB_Depart_Id" :placeholder="$t('rule.qxzbmen')" @change="employeeMsg.DepartmentId = msg.RB_Depart_Id, getEmployee(), msg.UpdateBy='-1'">
              <el-option :value="-2" :label="$t('pub.unlimitedSel')"></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.zhidanren')">
            <el-select  filterable  v-model='msg.UpdateBy'>
              <el-option value="-1" :label="$t('pub.unlimitedSel')"></el-option>
              <el-option v-for='item in EmployeeList'
                :label='item.EmName'
                :value='item.EmployeeId'
                :key='item.EmployeeId'>
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('fnc.zdriqi')">
            <el-date-picker
              @change="timeAdd(1)"
              v-model="productionDate"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="4">
          <el-form-item :label="$t('admin.admin_status')">
            <el-select  v-model="msg.Status" filterable>
              <el-option value="-1" :label="$t('pub.unlimitedSel')"></el-option>
              <el-option v-for='item in StatusList'
                :label='item.Name'
                :value='item.ID'
                :key='item.ID'>
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('fnc.jiaoyiriqi')">
            <el-date-picker
              @change="timeAdd(2)"
              v-model="productionDate2"
              type="daterange"
              value-format="yyyy-MM-dd"
              :range-separator="$t('restaurant.res_To')">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="page_CapitalAllocation_list">
      <table class="singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0" v-loading="loading">
        <tr>
          <th>{{$t('fnc.danhao')}}</th>
          <th>{{$t('fnc.jine')}}</th>
          <!-- <th>实付</th> -->
          <!-- <th>原币金额</th> -->
          <!-- <th>交易日期</th> -->
          <th>{{$t('fnc.cjshijian')}}</th>
          <th>{{$t('active.cl_addPp')}}</th>
          <!-- <th>备注</th> -->
          <th>{{$t('admin.admin_status')}}</th>
          <th>{{$t('system.table_operation')}}</th>
        </tr>
        <tr v-for="(item, index) in dataList">
          <td style="cursor:pointer" @click="goDetail('CapitalAllocationDetail', item.FrID)">{{item.FrID}}</td>
          <td>{{item.Money}}</td>
          <!-- <td>{{item.PayMoney}}</td> -->
          <!-- <td>{{item.OriginalMoney}}</td> -->
          <!-- <td>{{item.TradeDate}}</td> -->
          <td>{{item.CreateDate}}</td>
          <td>{{item.EmName}}</td>
          <!-- <td>{{item.Description}}</td> -->
          <td>
            <i v-if="item.Status==1" class="iconfont icon-daiqueren"></i>
            <i v-if="item.Status==4" class="iconfont icon-yiquxiao"></i>
            <i v-if="item.Status==2" class="iconfont icon-yiqueren"></i>
            <i  v-if="item.Status==3" class="iconfont icon-shenhebohui"></i>
            <i  v-if="item.Status==0 || item.Status==5" class="iconfont icon-zancun"></i>
            <el-popover
              popper-class="detailsIT_Journal"
              width="250"
              trigger="click">
                <div class="InfoChangeLog" >
                  <div class="changLog">
                    <p class="_log_t">{{$t('fnc.lcrizhi')}}</p>
                    <ul class="changLogList" v-if="GetFinancLogList" v-loading='LogLoading'>
                      <li class="changLogList_l" v-for="(log,li) in GetFinancLogList">
                          <span style="background-color: #47BF8C"  class="_radius_green"></span>
                          <p> <span class="_color_blue">{{log.EmName}}</span>  <span class="fr changLog_time">{{log.UpdateDate}}</span> </p>
                          <p class="_dtel">{{log.StartValue}}</p>
                      </li>
                    </ul>
                    <ul v-else>
                      <li>{{$t('hotel.hotel_zanwu')}}</li>
                    </ul>
                  </div>
                </div>
              <span slot="reference" class="text_d _font_init"  @click="Financial_post_GetFinancLogList(item.FrID)">{{item.StatusStr}}</span>
            </el-popover>
          </td>
          <td>
            <el-tooltip class="item" effect="dark" :content="$t('pub.updateMsg')"  placement="top" v-if="(item.Status===1 || item.Status===3) && item.CreateBy===EmId && item.InOrNotProcess===-1">
              <i class="edit el-icon-edit" @click="goURL('addCapitalAllocation', 1, item.FrID)"></i>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="$t('fnc.xiangqing')"  placement="top">
              <i class="iconfont icon-sousuo" @click="goDetail('CapitalAllocationDetail', item.FrID)"></i>
            </el-tooltip>
          </td>
        </tr>
      </table>
      <div class="noDataNotice" v-if="dataList.length<1"><i class="iconfont icon-kong"></i> <p>{{$t('active.ld_noData')}}</p></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>
</template>
<script>
export default {
  data(){
    return {
      msg: {
        pageIndex: 1,
        pageSize: 15,
        FrID: '0',
        UpdateBy: '-1',
        RB_Branch_Id: -1,
        RB_Depart_Id: -2,
        sDate: '',
        eDate: '',
        Status: '-1',
        sTradeDate: '',
        eTradeDate: '',
        EmployeeId:0
      },
      getCompanyMsg:{  // 公司
        RB_Group_Id:'0',
        Status:'0',
      },
      getDepartmentMsg:{// 部门
        RB_Group_Id:'',
        RB_Branch_Id:'',
        Status:0,
        ParentId:-1,
        Tier:0,
      },
      employeeMsg:{ // 员工
        GroupId:'',
        BranchId:-1,
        DepartmentId:0,
        PostId:0,
        IsLeave:0,
      },
      dataList: [],
      CompanyList: [],
      DepartmentList: [],
      productionDate: [],
      productionDate2: [],
      StatusList: [],
      EmployeeList: [],
      GetFinancLogList: [],
      loading: true,
      LogLoading: true,
      EmId:0,
      total: 0,
      currentPage: 0,
      btnShow:false,
    }
  },
  created(){
    this.getList()
    let userInfo = this.getLocalStorage();    // 读取缓存数据
    this.getCompanyMsg.RB_Group_Id = this.employeeMsg.GroupId = this.getDepartmentMsg.RB_Group_Id = userInfo.RB_Group_id;    // 集团ID
    this.EmId=userInfo.EmployeeId;
    let ActionMenuCode=userInfo.ActionMenuCode;
    if(ActionMenuCode.indexOf('F_CreateBranchMoneyAllot')!=-1){
      this.btnShow=true;
    }
  },
  methods:{
    getList: function () {  // 获取列表数据
      if (this.msg.FrID === '') {
        this.msg.FrID = 0
      }
      this.loading= true
      this.apipost('Financial_get_GetFundTransferPageList', this.msg, res=>{
        if (res.data.resultCode===1){
          this.dataList = res.data.data.pageData;
          this.total = res.data.data.count;
        } else {
          this.$message.error(res.data.message)
        }
        if (this.msg.FrID===0) {
          this.msg.FrID = ''
        }
        this.loading= false
      }, null)
    },
     handleCurrentChange(val) { //翻页
            this.msg.pageIndex = val;
            this.getList();
        },
        resetPageIndex(){  // 重置页码
            this.msg.pageIndex=1;
            this.currentPage = 1;
        },
   //导出
   method5: function() {
            if(!this.msg.RB_Branch_Id)this.msg.RB_Branch_Id=-1;
            if(!this.msg.RB_Depart_Id)this.msg.RB_Depart_Id=0;
            if(!this.msg.UpdateBy)this.msg.UpdateBy=0;
            if(!this.msg.Status)this.msg.Status=0;
            if(!this.msg.FrID)this.msg.FrID=0;
            this.msg.EmployeeId=this.EmId;
            this.GetLocalFile("Financial_get_OutToFundTransfer", this.msg,this.$t('fnc.zjdbbiao')+".xls");} ,        
    getCompanyList: function () { //获取公司列表
      this.apipost('admin_get_BranchGetList',this.getCompanyMsg,res=>{
        if(res.data.resultCode==1){
          this.CompanyList=res.data.data;
        }else{}
      },err=>{})
    },
    getDepartment: function () {  //获取部门列表
      this.apipost('admin_get_DepartmentGetList', this.getDepartmentMsg, res => {
        if(res.data.resultCode == 1) {
          this.DepartmentList = res.data.data;
        }
      }, err => {})
    },
    timeAdd: function (t) {  // 日期格式
      if (t===1) {
        if(!this.productionDate){
          this.msg.sDate = '';
          this.msg.eDate = '';
          return
        }
        this.msg.sDate = this.productionDate[0];
        this.msg.eDate = this.productionDate[1];
      } else if (t===2){
        if(!this.productionDate2){
          this.msg.sTradeDate = '';
          this.msg.eTradeDate = '';
          return
        }
        this.msg.sTradeDate = this.productionDate2[0];
        this.msg.eTradeDate = this.productionDate2[1];
      }
    },
    GetStatusList: function () {  // 获取审核状态枚举
      this.apipost('FinancialFlowTemplate_post_GetStatusList',{}, res => {
        if(res.data.resultCode == 1) {
          this.StatusList = res.data.data;
        }
      }, err => {})
    },
    getEmployee() { //员工
      this.apipost('admin_get_EmployeeGetList', this.employeeMsg, res => {
        if(res.data.resultCode == 1) {
          this.EmployeeList = res.data.data;
        }
      }, err => {})
    },
    goAddurl(url){
       this.$router.push({ name: url,query:{fengs: 1,blank: 'y', tab: '新增资金调拨'}})
    },
    goURL: function (url, edit, id) {
       this.$router.push({ name: url,query:{edit: edit, id: id, blank: 'y', tab: '新增资金调拨'}})
    },
    goDetail:function(url,id){
       this.$router.push({ name: url,query:{id: id, blank: 'y', tab: '资金调拨详情'}})
    },
    Financial_post_GetFinancLogList: function(id){  // 获取单据日志
      if(this.checkboxShow) return
      this.LogLoading = true;
      this.apipost('Financial_post_GetFinancLogList',{ID:id,Type:2}, res => {
        if(res.data.resultCode == 1) {
          let data = res.data.data;
          data.forEach(x=>{
              x.UpdateDate = this.$commonUtils.formatMsgTime(x.UpdateDate)
          })
          this.LogLoading = false;
          this.GetFinancLogList = data;
        }
      }, err => {})
    },
  },
  mounted(){
    this.getCompanyList()
    this.getDepartment()
    this.GetStatusList()
    this.getEmployee()
  }
}
</script>
