<!--
 * @Descripttion: 123
 * @version: 123
 * @Author: kangkang
 * @Date: 2020-09-30 21:48:44
 * @LastEditors: “wanyongkang” “937888580@qq.com”
 * @LastEditTime: 2024-02-06 14:57:54
-->
<template>
  <div v-loading="loading">
    <div class="heior_box">
       <el-button size="small" type="primary" icon="el-icon-sold-out" @click="dataExport" v-if="$local.isRoot()">导出</el-button>
      <div class="search-box">
       <el-date-picker
        v-model="search_month"
        type="daterange"
        align="right"
        size="small"
        style="margin-right:5px;width: 200px;"
        start-placeholder="开始日期"
        end-placeholder="结束日期">
      </el-date-picker>
      <el-select size="small" v-model="searchModel.type" placeholder="请选择">
          <el-option
            label="选择类型"
            value="0">
          </el-option>
           <el-option
            label="管理员充值"
            value="1">
          </el-option>
          <el-option
            label="管理员扣除"
            value="2">
          </el-option>
          <el-option
            label="淘宝充值"
            value="3">
          </el-option>
          <el-option
            label="淘宝退款"
            value="4">
          </el-option>
          <el-option
            label="账号退款"
            value="5">
          </el-option>
          <el-option
            label="账号付款"
            value="6">
          </el-option>
          <el-option
            label="用户充值"
            value="7">
          </el-option>
          <el-option
            label="用户提现扣除"
            value="8">
          </el-option>
          <el-option
            label="提现被拒退还"
            value="9">
          </el-option>
        </el-select>
        <el-input v-model="searchModel.keyWord" placeholder="请输入会员号/名称" clearable size="small">
          <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
        </el-input>
      </div>
    </div>
    <el-table :data="retData.Data" size="medium" :height="$getHeight(100)" row-key="Id" border>
      <el-table-column prop="CreateTime" label="日期"></el-table-column>
      <el-table-column prop="UserName" label="用户">
        <template slot-scope="scope">
          <phoneHide :text="scope.row.UserName"></phoneHide>
        </template>
      </el-table-column>
      <el-table-column prop="OperateUserName" label="操作人员"></el-table-column>
      <el-table-column prop="ScoreTypeName" label="资金项目"></el-table-column>
       <el-table-column prop="RestAmount1" label="操做前余额"></el-table-column>
      <el-table-column prop="ScoreValue" label="金额"></el-table-column>
       <el-table-column prop="RestAmount2" label="操做后余额"></el-table-column>
       <el-table-column prop="Remark" label="备注"></el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        v-if="retData.Data.length>0"
        @current-change="getAmountDetail"
        :page-size="50"
        :current-page.sync="searchModel.PageIndex"
        layout="total,prev, pager, next"
        :total="retData.TotalCount"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  name: 'userIndex',
  components: {
    cutTip: () => import('@/components/common/cutTip'),
    phoneHide: () => import('@/components/common/phonehide')
  },
  data () {
    return {
      loading: false,
      retData: { TotalCount: 0, Data: [] },
      searchModel: {
        type : '0',
        PageIndex: 1,
        keyWord: '',
        st: null,
        et: null,
      },
      search_month: '',
      detailAmountData: [],
      formatterCreateType (row, column, cellValue, index) {
        switch (cellValue) {
          case 1:
            return '管理员添加'
          case 2:
            return '用户注册'
          case 3:
            return '淘宝注册'
        }
        return ''
      }
    }
  },
  created () {
    this.$store.commit('setCurrentNav', '订单管理>>资金明细')
    this.getAmountDetail()
  },
  methods: {
    search () {
      if (this.search_month && this.search_month.length === 2) {
        this.searchModel.st = this.search_month[0]
        this.searchModel.et = this.search_month[1]
      }
      this.searchModel.PageIndex = 1
      this.getAmountDetail()
    },
    getAmountDetail () {
      this.loading = true
      this.$api
        .get(this.$api.phpURL + 'user/UserScore/get_all_list', this.searchModel)
        .then(res => {
          this.retData = res
          this.loading = false
          console.log(this.retData)
        })
    },
    dataExport () {
      if (this.search_month && this.search_month.length === 2) {
        this.searchModel.st = this.search_month[0]
        this.searchModel.et = this.search_month[1]
      }
      this.$api.getDownloadFile(this.$api.phpURL + 'user/UserScore/export', this.searchModel, '资金明细.csv')
    }
  }
}
</script>
<style scoped>
</style>
