<style>
  @import "../css/cssReset.css";

  .page_CapitalAllocation .query-box {
    padding: 0;
    border: 0
  }

  .page_CapitalAllocation .form {
    padding-top: 25px;
  }

  .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 page-body">
    <div class="query-box" style="margin-bottom:20px;">
      <ul>
        <li>
          <em>{{$t('fnc.djbianhao')}}</em>&nbsp;
          <el-input v-model="msg.FrID"></el-input>
        </li>
        <li>
          <em>{{$t('system.table_company')}}</em>&nbsp;
          <el-select v-model="msg.RB_Branch_Id" :placeholder="$t('rule.company')" class="w220"
            @change="getDepartment(msg.RB_Branch_Id),msg.RB_Depart_Id = -2">
            <el-option :value="-1" :label="$t('pub.unlimitedSel')"></el-option>
            <el-option v-for='item in CompanyList' :label='item.SName' :value='item.SId' :key='item.SId'>
            </el-option>
          </el-select>
        </li>
        <li>
          <em>{{$t('admin.admin_Department')}}</em>&nbsp;
          <el-select v-model="msg.RB_Depart_Id" :placeholder="$t('rule.qxzbmen')" class="w220"
            @change="getEmployee(msg.RB_Depart_Id), msg.UpdateBy='-1'">
            <el-option :value="-2" :label="$t('pub.unlimitedSel')"></el-option>
            <el-option v-for='item in DepartmentList' :label='item.DeptName' :value='item.DeptId' :key='item.DeptId'>
            </el-option>
          </el-select>
        </li>
        <li>
          <em>{{$t('fnc.zhidanren')}}</em>&nbsp;
          <el-select filterable v-model='msg.UpdateBy' class="w220">
            <el-option value="-1" :label="$t('pub.unlimitedSel')"></el-option>
            <el-option v-for='item in EmployeeList' :label='item.EmployeeName' :value='item.Id' :key='item.Id'>
            </el-option>
          </el-select>
        </li>
        <li>
          <em>{{$t('fnc.zdriqi')}}</em>&nbsp;
          <el-date-picker @change="timeAdd(1)" v-model="productionDate" type="daterange" value-format="yyyy-MM-dd"
            range-separator="至">
          </el-date-picker>
        </li>
        <li>
          <em>{{$t('fnc.jiaoyiriqi')}}</em>&nbsp;
          <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>
        </li>
        <li>
          <em>{{$t('admin.admin_status')}}</em>&nbsp;
          <el-select v-model="msg.Status" filterable class="w220">
            <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>
        </li>
        <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')" /> -->
          <q-btn color="primary" size="11px" :label="$t('pub.addBtn')" @click="goURL('addCapitalAllocation')" style="marginRight:10px"/>
          <!-- <input type="button" class="hollowFixedBtn" :value="$t('pub.searchBtn')" @click="getList()" /> -->
          <q-btn color="primary" size="11px" :label="$t('pub.searchBtn')" @click="getList()" style="marginRight:10px"/>
          <!-- <input type="button" class="normalBtn" :value="$t('visa.v_daochu')" @click="method5()" /> -->
          <q-btn color="primary" size="11px" :label="$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="getDepartment(msg.RB_Branch_Id),msg.RB_Depart_Id = -2">
              <el-option :value="-1" :label="$t('pub.unlimitedSel')"></el-option>
              <el-option v-for='item in CompanyList'
                         :label='item.SName'
                         :value='item.SId'
                         :key='item.SId'>
              </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="getEmployee(msg.RB_Depart_Id), msg.UpdateBy='-1'">
              <el-option :value="-2" :label="$t('pub.unlimitedSel')"></el-option>
              <el-option v-for='item in DepartmentList'
                         :label='item.DeptName'
                         :value='item.DeptId'
                         :key='item.DeptId'>
              </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.EmployeeName'
                         :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.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>
  import {
    getSchoolPage
  } from '../../../api/school/index'
  import {
    queryEmployee
  } from '../../../api/users/user'
  import {
    getDeptPage,
  } from '../../../api/system/dept'

  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',
        },
        dataList: [],
        CompanyList: [],
        DepartmentList: [],
        productionDate: [],
        productionDate2: [],
        StatusList: [],
        EmployeeList: [],
        GetFinancLogList: [],
        loading: true,
        LogLoading: true,
        EmId: 0,
        total: 0,
        currentPage: 0,
        btnShow: false,
        schoolMsg: {
          pageIndex: 1,
          pageSize: 12,
          rowsPerPage: 12,
          SName: "",
          Status: '-1'
        }
      }
    },
    created() {
      this.getList()
      let userInfo = this.getLocalStorage(); // 读取缓存数据
      this.getCompanyMsg.RB_Group_Id = userInfo.Group_Id; // 集团ID
      this.EmId = userInfo.Id;
      let ActionMenuCode = userInfo.ActionMenuCode;
    },
    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.GetErpLocalFile("Financial_get_OutToFundTransfer", this.msg, this.$t('fnc.zjdbbiao') + ".xls");
      },
      getCompanyList: function () { //获取公司列表
        getSchoolPage(this.schoolMsg).then(res => {
          this.CompanyList = res.Data.PageData;
        }).catch(() => {

        })
      },
      getDepartment: function (id) { //获取部门列表
        let msg = {
          pageIndex: 1,
          pageSize: 999,
          rowsPerPage: 12,
          DeptName: "", //部门名称
          DeptId: 0, //部门编号
          Status: "-1",
          School_Id: 0,
          DeptTier: 0,
          ParentId: 0,
        }
        msg.School_Id = id;
        getDeptPage(msg).then(res => {
          this.DepartmentList = res.Data.PageData;
        }).catch(() => {})
      },
      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(id) { //员工
        var qMsg = {
          Dept_Id: 0
        }
        qMsg.Dept_Id = id;
        queryEmployee(qMsg).then(res => {
          if (res.Code == 1) {
            this.EmployeeList = res.Data;
          }
        }).catch(() => {

        })
      },
      goAddurl(url) {
        // this.$router.push({ name: url,query:{fengs: 1,blank: 'y', tab: '新增资金调拨'}})
        var tempStr = '/financial/financalDocument/' + url + '?fengs=1';
        this.$router.push({
          path: tempStr
        });
      },
      goURL: function (url, edit, id) {
        // this.$router.push({ name: url,query:{edit: edit, id: id, blank: 'y', tab: '新增资金调拨'}})
        var tempStr = '/financial/financalDocument/' + url + '?edit=' + edit + '&id=' + id;
        this.$router.push({
          path: tempStr
        });
      },
      goDetail: function (url, id) {
        // this.$router.push({ name: url,query:{id: id, blank: 'y', tab: '资金调拨详情'}})
        var tempStr = '/financial/financalDocument/' + url + '?id=' + id;
        this.$router.push({
          path: tempStr
        });
      },
      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(0)
      this.GetStatusList()
      this.getEmployee(0)
    }
  }

</script>
