<style>
.page_FinancialAccounting .query-box{
  padding: 0;
}
.page_FinancialAccounting .form{
  padding-top: 15px;
}
.page_FinancialAccounting .el-date-editor .el-range-separator {
  padding: 0;
  line-height: 29px;
}
.page_FinancialAccounting .el-select{
  width: 100%;
}
.page_FinancialAccounting .page_FinancialAccounting_list {
  width: 100%;
}
.page_FinancialAccounting i.icon-sousuo,.page_FinancialAccounting i.edit,.page_FinancialAccounting .icon-ico_commodity_defaul{
    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_FinancialAccounting i.edit{background-color: #00C6FF;font-size: 16px;}
.page_FinancialAccounting i.edit:hover{background-color: #59daff}
.page_FinancialAccounting i.edit:active{background-color: #00b8ec}
.page_FinancialAccounting i.icon-sousuo{background-color: #47BF8C;}
.page_FinancialAccounting i.icon-sousuo:hover{background-color: #66bb97}
.page_FinancialAccounting i.icon-sousuo:active{background-color: #35ab79}
.page_FinancialAccounting ._btn_group{font-size: 14px;}
.page_FinancialAccounting .icon-daiqueren{color: #4BCA81}
.page_FinancialAccounting .icon-yiqueren{color: #4BCA81}
.page_FinancialAccounting .icon-yiquxiao{color: #959595}
.page_FinancialAccounting .icon-shenhebohui{color: #E95252}
.page_FinancialAccounting .icon-icon-zancun{color: #FF9C01}
.page_FinancialAccounting .text_d{text-decoration: underline;cursor: pointer;}
.InfoChangeLog{height: auto;max-height: 220px;background-color: #FFFFFF;}
._icon_btn i.icon-ico_commodity_defaul{background-color: #F16C3C;}
._icon_btn i.icon-ico_commodity_defaul:hover{background-color: #e87c54}
._icon_btn i.icon-ico_commodity_defaul:active{background-color: #f76630}
.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}
.page_FinancialAccounting ._AllCont{
  display: flex;
  font-size: 12px;
}
.page_FinancialAccounting ._AllCont p{
  padding: 0 20px 15px;
}
.page_FinancialAccounting ._AllCont p._allcont_zhi span{
  color: #106BAF
}
.page_FinancialAccounting ._AllCont p._allcont_zhi span{
  color: #E95252
}
</style>
<template>
  <div class="page_FinancialAccounting">
    <div class="query-box">
      <ul>
        <li>
          <input type="button" class="normalBtn" :value="$t('pub.addBtn')" @click="goURL('ChoiceAddFinancialDocuments2')"/>
          <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="单据编号">
            <el-input v-model="msg.FrID"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="公司">
            <el-select v-model="msg.RB_Branch_Id" placeholder="请选择公司" @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="部门">
            <el-select v-model="msg.RB_Depart_Id" placeholder="请选择部门" @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="制单人">
            <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="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="4">
          <el-form-item label="挂账对象">
            <el-select  v-model="msg.ClientType" filterable>
              <el-option :value="0" :label="$t('pub.unlimitedSel')"></el-option>
              <el-option v-for='item in ClientTypeList'
                  :label='item.Name'
                  :value='item.ID'
                  :key='item.ID'>
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="制单日期">
            <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-form>
    <div class="_AllCont">
      <p>挂账总金额:{{moneyFormat(AllCont.Income - AllCont.Expend)}}</p>
      <p class="_allcont_zhi">挂账总支出:<span>{{moneyFormat(AllCont.Expend)}}</span></p>
      <p class="_allcont_shou">挂账总收入:<span>{{moneyFormat(AllCont.Income)}}</span></p>
    </div>
    <div class="page_FinancialAccounting_list">
      <table class="singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0" v-loading="loading">
        <tr>
          <th>单号</th>
          <th>金额</th>
          <!-- <th>实付</th> -->
          <!-- <th>原币金额</th> -->
          <!-- <th>交易日期</th> -->
          <th>创建时间</th>
          <th>创建人</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('FinancialDocumentsDetail', 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">流程日志</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>暂无修改日志</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 class="_icon_btn">
            <el-tooltip class="item" effect="dark" content="修改"  placement="top" v-if="(item.Status===1 || item.Status===3) && item.CreateBy===EmId && item.InOrNotProcess !== 1">
              <i class="edit el-icon-edit" @click="goURL('addFinancialGZDocuments', item.FrID)"></i>
            </el-tooltip>
            <el-tooltip class="item"  effect="dark" :content="$t('fnc.shenhe')"   placement="top">
                <i v-if="item.Status==1" class="iconfont icon-ico_commodity_defaul" @click="goURL('BasicDocuments',item.FrID)"></i>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="详情"  placement="top">
              <i class="iconfont icon-sousuo" @click="goDetail('FinancialDocumentsDetail', item.FrID)"></i>
            </el-tooltip>
          </td>
        </tr>
      </table>
      <div class="noDataNotice" v-if="dataList.length<1"><i class="iconfont icon-kong"></i> <p>没有找到你需要的数据</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: '',
        UpdateBy: '-1',
        RB_Branch_Id: -1,
        RB_Depart_Id: -2,
        sDate: '',
        eDate: '',
        Status: '-1',
        sTradeDate: '',
        eTradeDate: '',
        EmployeeId:0,
        ClientType: 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: [],
      StatusList: [],
      EmployeeList: [],
      GetFinancLogList: [],
      loading: true,
      LogLoading: true,
      EmId:0,
      total: 0,
      currentPage: 0,
      ClientTypeList: [],
      AllCont: {
        Income: 0,
        Expend: 0,
      },
    }
  },
  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;
  },
  methods:{
    getAllCont: function () {
      this.apipost('Financial_post_GetHangingAccountTotalPrice', this.msg, res=>{
        if (res.data.resultCode===1){
          this.AllCont = res.data.data;
        } else {
          this.$message.error(res.data.message)
        }
        if (this.msg.FrID===0) {
          this.msg.FrID = ''
        }
        this.loading= false
      }, null)
    },
    getList: function () {  // 获取列表数据
      if (this.msg.FrID === '') {
        this.msg.FrID = 0
      }
      this.loading= true
      this.apipost('InvoiceApply_get_GetFundTransferPageList', this.msg, res=>{
        if (res.data.resultCode===1){
          this.dataList = res.data.data.pageData;
          this.total = res.data.data.count;
          this.getAllCont()
        } else {
          this.$message.error(res.data.message)
        }
      }, 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("InvoiceApply_get_HangingAccountImport", this.msg,"挂账报表.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 => {})
    },
    goURL: function (url, frID) {
      if (url === 'ChoiceAddFinancialDocuments2'){
        this.$router.push({ name: url,query:{Type: 3, blank: 'y'}})
      } else if (url === 'addFinancialGZDocuments') {
        this.$router.push({ name: url,query:{"FrID":frID,"edit": 1, blank: 'y'}})
      } else{
        this.$router.push({ name: url,query:{"id":frID,"ISGZ": 1, blank: 'y'}})
      }
      
    },
    goDetail:function(url,id){
       this.$router.push({ name: url,query:{id: id, "ISGZ": 1, blank: 'y',}})
    },
    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 => {})
    },
    financeinfo_post_GetClientTypeList: function() {  // 获取对象类型
            this.apipost('financeinfo_post_GetClientTypeList',{}, res => {
                if(res.data.resultCode == 1) {
                    this.ClientTypeList = res.data.data;
                }
            }, err => {})
        },
  },
  mounted(){
    this.getCompanyList()
    this.getDepartment()
    this.GetStatusList()
    this.getEmployee()
    this.financeinfo_post_GetClientTypeList()
  }
}
</script>