<style scoped>
/deep/.el-table th.el-table__cell{
  background-color: #E6E6E6;
}
</style>

<template >
  <div class="page_fnDm page_RecPayQuery"  @keyup.enter="resetPageIndex()">
      <div class="query-box" style="margin-bottom: 0px;">
          <el-form class="_info_box clearfix"  label-width="110px">
              <el-row style="padding:15px 20px 0 0;">
                  <el-col :span="4">
                      <el-form-item label="客户/电话:">
                          <el-input placeholder="" class="" v-model="msg.RemitterName" @keyup.native="checkInteger(msg,'FrID')" maxlength="8"></el-input>
                      </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="使用日期:">
                      <el-date-picker class="h34"
                        @change="timeAdd(1)"
                        v-model="productionDate"
                        type="daterange"
                        value-format="yyyy-MM-dd">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col :span="4">
                    <el-form-item label="公司别">
                      <el-select :placeholder="$t('pub.pleaseSel')" filterable v-model="msg.RB_Branch_Id">
                        <el-option :label="$t('pub.unlimitedSel')" :value="-1"></el-option>
                        <el-option v-for="(item,index) in branchList" :key="index" :label="item.BName" :value="item.Id">
                        </el-option>
                      </el-select>
                  </el-form-item>
                  </el-col>
              </el-row>
          </el-form>
          <ul class="clearfix">
              <li class="hight_query">
                  <button class="hollowFixedBtn" @click="resetPageIndex()">{{$t('pub.searchBtn')}}</button>
                  <button class="normalBtn" @click="method5()">导出</button>
              </li>
          </ul>
      </div>
      <div style="color: red;font-size: 13px;text-align: right;padding: 10px 0;">注:待存入是未出纳审核,不计入已存入</div>
      <div class="_fnDm_content" v-loading='loading'>
        <el-table
          ref="multipleTable"
          :data="DataList"
          tooltip-effect="dark"
          style="width: 100%"
         >
          <el-table-column prop="CustomerName" label="客户"></el-table-column>
          <el-table-column
            prop="CustomerName"
            label="联系人/电话">
            <template slot-scope="scope">
              {{ scope.row.Contact+'/'+scope.row.ContactNumber }}
            </template>
          </el-table-column>
          <el-table-column prop="" label="已存入">
            <template slot-scope="scope">
              <span style="cursor: pointer;color: #00C6FF;" @click="seeDeta(scope.row)">{{ scope.row.Income }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="" label="待存入">
            <template slot-scope="scope">
              <span style="cursor: pointer;color: #00C6FF;" @click="seeDeta(scope.row)">{{ scope.row.WaitIncome }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="Refund" label="退款">
            <template slot-scope="scope">
              <span style="cursor: pointer;color: #00C6FF;" @click="seeDeta(scope.row)">{{ scope.row.Refund }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="UseMoney" label="已使用">
            <template slot-scope="scope">
              <span style="cursor: pointer;color: #00C6FF;" @click="seeDeta(scope.row)">{{ scope.row.UseMoney }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="" label="期末余额">
            <template slot-scope="scope">
              <template v-if="scope.row.DepositMoney">
                {{ scope.row.DepositMoney+'('+scope.row.DepositCurrencyName+')' }}
              </template>
              <template v-else>
                -
              </template>
            </template>
          </el-table-column>
          <el-table-column :label="$t('system.table_operation')">
            <template slot-scope="scope">
              <span style="cursor: pointer;color: #00C6FF;" @click="downloadDetail(scope.row)">下载明细</span>
            </template>
          </el-table-column>
        </el-table>
          <div style="padding-bottom:15px">
              <el-pagination background @current-change="handleCurrentChange"
              layout="total,prev, pager, next, jumper" :page-size="msg.pageSize" :total='total'>
          </el-pagination>
          </div>
      </div>
      <detailList v-if="showdetail" :ClientId="detailObj&&detailObj.CustomerId" @cancel="showdetail=false"></detailList>
  </div>
</template>
<script>
import Vue from 'vue'
import detailList from "./components/detailList.vue";
export default {
  components: {
    detailList
  },
  data(){
      return{
        detailObj: null,
        showdetail: false,
        DataList:[],
        msg:{
            pageIndex:1,
            pageSize: 10,
            RemitterName:'',
            ClientIdStr:'',
            QStartDate:'',
            QEndDate:'',
            RB_Branch_Id:-1,
            EmployeeId:'',
        },
        loading: false,
        total: 0,
        productionDate:[],
        branchList:[]
      }
  },
  created(){

  },
  mounted(){
      let userInfo=this.getLocalStorage();
      this.msg.EmployeeId= userInfo.EmployeeId;
      this.getPageList();
      this.getBranchList();
      this.msg.ClientIdStr = this.$route.query.ClientIdStr?this.$route.query.ClientIdStr:""
      if(this.$route.query.startDate&&this.$route.query.endDate){
        this.productionDate = this.$route.query.startDate?[this.$route.query.startDate,this.$route.query.endDate]:[]
        this.msg.QStartDate = this.productionDate?this.productionDate[0]:''
        this.msg.QEndDate = this.productionDate?this.productionDate[1]:''
      }
      var that = this;
  },
  methods:{
      seeDeta(row){
        this.detailObj = row
        this.showdetail = true
      },
      getPageList(){  // 获取列表数据
          this.loading= true;
          this.apipost('Financial_post_GetFinanceDepositPageList',this.msg,res=>{
              if(res.data.resultCode == 1) {
                  let data = res.data.data.pageData;
                  this.total = res.data.data.count;
                  if(this.total==0){
                      this.DataList=[];
                  }else{
                      this.DataList = data;
                  }
                  this.loading=false;
              }else{
                  this.loading= false;
                  this.$message.error(res.data.message);
              }
          },err=>{})
      },
      timeAdd(){  // 日期格式
          if(!this.productionDate){
              this.msg.QStartDate = '';
              this.msg.QEndDate = '';
              return
          }
          this.msg.QStartDate = this.productionDate[0];
          this.msg.QEndDate = this.productionDate[1];
      },
      method5() {
          let time = this.getBeforeDate(0,new Date().Format("yyyy-MM-dd"))
          var fileName = `客户预存余额${time}.xls`;          
          this.GetLocalFile("Financial_post_DownLoadFinanceDeposit", this.msg,fileName);
      },
      downloadDetail(item) {
          let time = this.getBeforeDate(0,new Date().Format("yyyy-MM-dd"))
          var fileName = `客户预存明细${time}.xls`;          
          this.GetLocalFile("Financial_post_DownLoadFinanceDepositLog", {DepositCustomerId:item.CustomerId,EmployeeId:this.msg.EmployeeId},fileName);
      } ,
      handleCurrentChange(val) { //翻页
          this.msg.pageIndex = val;
          this.getPageList();
      },
      resetPageIndex(){  // 重置页码
          this.msg.pageIndex=1;
          this.getPageList();
      },
      getBranchList(){  // 获取列表数据
        let userInfo=this.getLocalStorage();          
          this.apipost('admin_get_BranchGetList',{RB_Group_Id: userInfo.RB_Group_Id, Status: "0"},res=>{
              if(res.data.resultCode == 1) {
                  this.branchList = res.data.data;
              }else{
                  this.$message.error(res.data.message);
              }
          },err=>{})
      },
    }
}
</script>