| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <template>
- <div class="page-container">
- <el-card>
- <div slot="header">
- <span>积分管理</span>
- <el-button
- type="primary"
- size="small"
- style="float: right"
- @click="handleRefresh"
- :loading="loading"
- >
- 刷新
- </el-button>
- </div>
- <!-- 搜索筛选 -->
- <el-form :inline="true" :model="searchForm" style="margin-bottom: 20px">
- <el-form-item label="孩子ID">
- <el-input
- v-model="searchForm.memberId"
- placeholder="请输入孩子ID"
- clearable
- @keyup.enter.native="handleSearch"
- ></el-input>
- </el-form-item>
- <el-form-item label="类型">
- <el-select v-model="searchForm.type" placeholder="全部类型" clearable @change="handleSearch">
- <el-option label="获得" value="earn"></el-option>
- <el-option label="消耗" value="spend"></el-option>
- <el-option label="奖励" value="bonus"></el-option>
- <el-option label="扣罚" value="penalty"></el-option>
- <el-option label="调整" value="adjust"></el-option>
- <el-option label="退还" value="refund"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="handleSearch">搜索</el-button>
- <el-button @click="handleReset">重置</el-button>
- </el-form-item>
- </el-form>
- <!-- 积分流水列表 -->
- <el-table :data="tableData" border v-loading="loading" style="width: 100%" :max-height="tableHeight">
- <el-table-column prop="id" label="ID" width="80"></el-table-column>
- <el-table-column prop="childId" label="孩子ID" width="100"></el-table-column>
- <el-table-column prop="amount" label="积分变动" width="120">
- <template slot-scope="scope">
- <span :style="{ color: scope.row.amount > 0 ? '#67C23A' : '#F56C6C', fontWeight: 'bold' }">
- {{ scope.row.amount > 0 ? '+' : '' }}{{ scope.row.amount }}
- </span>
- </template>
- </el-table-column>
- <el-table-column prop="type" label="类型" width="100">
- <template slot-scope="scope">
- <el-tag :type="getTypeTag(scope.row.type)" size="small">
- {{ getTypeText(scope.row.type) }}
- </el-tag>
- </template>
- </el-table-column>
- <el-table-column prop="description" label="描述" min-width="200"></el-table-column>
- <el-table-column prop="taskId" label="任务ID" width="100">
- <template slot-scope="scope">
- <span>{{ scope.row.taskId || '-' }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="createdAt" label="时间" width="180">
- <template slot-scope="scope">
- {{ formatDate(scope.row.createdAt) }}
- </template>
- </el-table-column>
- </el-table>
- <!-- 分页 -->
- <el-pagination
- style="margin-top: 20px; text-align: right"
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="pagination.current"
- :page-sizes="[10, 20, 50, 100]"
- :page-size="pagination.size"
- :total="pagination.total"
- layout="total, sizes, prev, pager, next, jumper"
- ></el-pagination>
- </el-card>
- </div>
- </template>
- <script>
- import { getPointsLogs } from '@/api/admin'
- export default {
- name: 'Points',
- computed: {
- tableHeight() {
- return window.innerHeight - 340
- }
- },
- data() {
- return {
- loading: false,
- tableData: [],
- searchForm: {
- memberId: '',
- type: ''
- },
- pagination: {
- current: 1,
- size: 10,
- total: 0
- }
- }
- },
- mounted() {
- this.loadPointsLogs()
- },
- methods: {
- async loadPointsLogs() {
- this.loading = true
- try {
- const params = {
- page: this.pagination.current,
- size: this.pagination.size,
- ...this.searchForm
- }
- const res = await getPointsLogs(params)
- this.tableData = res.data.records || res.data || []
- this.pagination.total = res.data.total || this.tableData.length
- } catch (error) {
- this.$message.error(error.message || '加载积分流水失败')
- } finally {
- this.loading = false
- }
- },
- handleSearch() {
- this.pagination.current = 1
- this.loadPointsLogs()
- },
- handleReset() {
- this.searchForm = {
- memberId: '',
- type: ''
- }
- this.handleSearch()
- },
- handleRefresh() {
- this.loadPointsLogs()
- },
- handleSizeChange(val) {
- this.pagination.size = val
- this.pagination.current = 1
- this.loadPointsLogs()
- },
- handleCurrentChange(val) {
- this.pagination.current = val
- this.loadPointsLogs()
- },
- getTypeTag(type) {
- const tags = {
- earn: 'success',
- spend: 'warning',
- bonus: 'success',
- penalty: 'danger',
- adjust: 'info',
- reset: 'warning',
- refund: 'success'
- }
- return tags[type] || 'info'
- },
- getTypeText(type) {
- const texts = {
- earn: '获得',
- spend: '消耗',
- bonus: '奖励',
- penalty: '扣罚',
- adjust: '调整',
- reset: '清零',
- refund: '退还'
- }
- return texts[type] || type
- },
- formatDate(dateStr) {
- if (!dateStr) return '-'
- const date = new Date(dateStr)
- return date.toLocaleString('zh-CN')
- }
- }
- }
- </script>
- <style scoped>
- </style>
|