<template>
  <div style="padding: 10px;background-color:#F2F3F5">
    <div class="record">
      <div style="height:58px;line-height:58px;">
        <div style="color:#0006"> <span>积分管理</span>   <span style="padding:0 5px;">></span>  <span style="color:#000000e6">积分记录</span></div>
      </div>
      <div class="content">
        <!-- 顶部搜索 -->
        <div class="toolbar">
          <el-form ref="formParams" :inline="true" :model="formParams" :rules="rules">
            <el-form-item label="用户ID/用户昵称" prop="search">
              <el-input v-model="formParams.search" placeholder="请输入用户ID/用户昵称"  />
            </el-form-item>
            <el-form-item label-width="0">
              <el-button   @click="search('formParams')"  style="background-color: #3F9B6A;color: #fff">查询</el-button>
              <el-button  @click="clear('formParams')"  class="buttonHover"
            style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;">重置</el-button>
            </el-form-item>
          </el-form>
        </div>
        <!-- 表格 -->
        <div class="content_table">
          <div class="table">
            <el-table
              :data="list"
            :header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}"
            >
              <el-table-column prop="buyerUserId" label="用户ID" />
              <el-table-column prop="name" label="用户昵称" />
              <el-table-column prop="phone" label="用户手机号" />
              <el-table-column prop="recordContent" label="账单标题" />
              <el-table-column prop="recordType" label="类型">
                <template slot-scope="scope">
                  <span>{{ scope.row.recordType===1?'收入':scope.row.recordType===2?'支出':'' }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="credit" label="数字明细" />
              <el-table-column prop="remainCredit" label="剩余积分" />
            </el-table>
          </div>
          <!-- 分页 -->
          <div class="fenye">
            <el-pagination
              :current-page="formParams.page"
              :page-sizes="[10, 20, 50, 100]"
              :page-size="10"
              background
              small
              layout="total, sizes, prev, pager, next, jumper"
              :total="total"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { recordGetAll } from '@/api/sign'
export default {
  data () {
    return {
      list: [],
      total: 1,
      formParams: {
        page: 1,
        pageSize: 10,
        search: ''
      },
      rules: {
        noticeType: [
          { required: true, message: '请选择消息类型', trigger: 'change' }
        ]
      }
    }
  },
  mounted () {
    this.getAll()
  },
  methods: {
    // 历史消息列表
    async getAll () {
      const res = await recordGetAll(this.formParams)
      this.list = res.data.list
      this.total = res.data.total

    },
    // 查询
    async search (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.total = 1
          this.formParams.page = 1
          this.formParams.search = this.formParams.search.trim()
          this.getAll()
        } else {
          return false
        }
      })
    },
    // 重置表单
    async clear (formName) {
      this.$refs[formName].resetFields()
      this.getAll()
    },
    // 更改页数
    async handleSizeChange (val) {
      this.formParams.pageSize = val
      this.getAll()
    },
    // 翻页
    async handleCurrentChange (val) {
      this.formParams.page = val
      this.getAll()
    },
    // 关闭消息详情
    async handleClose () {
      this.dialogVisible = false
    }
  }
}
</script>

<style lang='scss' scoped>
@import url("../../styles/elDialog.scss");
.record{
  padding:  0 20px 20px 20px;
    min-height: calc(100vh - 50px - 20px);
    background-color:#fff;
  }
  ::v-deep .el-form-item__label{
         font-weight: normal;
          font-size: 14px;

        }
           ::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
            background-color: #3F9B6A;
          }
          ::v-deep .el-input__inner:focus {
               border: #3F9B6A 1px solid;
            }
            ::v-deep .buttonHover:hover{
              color:#3f9b6a !important;
              border-color: #c5e1d2 !important;
              background-color: #ecf5f0 !important;
              outline: none;
            }
            ::v-deep .el-pagination__total {
                position: absolute;
                left: 10px;
              }
</style>

<style scoped>
.record /deep/ .el-table .cell.el-tooltip img {
  max-height: 100px;
}
</style>
