| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <template>
- <div class="page-container">
- <el-card>
- <PageHeader slot="header" title="积分管理">
- <el-button type="primary" size="small" @click="handleRefresh" :loading="loading">刷新</el-button>
- </PageHeader>
- <!-- 搜索筛选 -->
- <el-form :inline="true" :model="searchForm" class="form-mb20">
- <el-form-item label="成员姓名">
- <el-input
- v-model="searchForm.keyword"
- placeholder="请输入成员姓名"
- clearable
- @keyup.enter.native="handleSearch"
- ></el-input>
- </el-form-item>
- <el-form-item label="家庭">
- <el-select
- v-model="searchForm.familyId"
- placeholder="全部家庭"
- clearable
- filterable
- class="select-220"
- @change="handleSearch"
- >
- <el-option
- v-for="f in familyOptions"
- :key="f.id"
- :label="f.name"
- :value="f.id"
- ></el-option>
- </el-select>
- </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>
- <!-- 积分流水列表 -->
- <div class="adm-table-wrap">
- <el-table :data="tableData" border v-loading="loading" class="table-full" height="100%">
- <el-table-column prop="id" label="ID" width="80">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('id', $event)">ID<span v-if="sortIndex('id') !== null" class="sort-index" :class="sortClass('id') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('id') }}</span>{{ sortIcon('id') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="memberName" label="成员姓名" width="140">
- <template slot-scope="scope">
- <span>{{ scope.row.memberName || '-' }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="familyName" label="所属家庭" min-width="180">
- <template slot-scope="scope">
- <span>{{ scope.row.familyName || '-' }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="amount" label="积分变动" width="120">
- <template slot-scope="scope">
- <span :style="{ color: scope.row.amount > 0 ? 'var(--adm-success)' : 'var(--adm-error)', fontWeight: 'bold' }">
- {{ scope.row.amount > 0 ? '+' : '' }}{{ scope.row.amount }}
- </span>
- </template>
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('amount', $event)">积分变动<span v-if="sortIndex('amount') !== null" class="sort-index" :class="sortClass('amount') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('amount') }}</span>{{ sortIcon('amount') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="type" label="类型" width="100">
- <template slot-scope="scope">
- <StatusTag :type="getTypeTag(scope.row.type)" :text="getTypeText(scope.row.type)" size="small" />
- </template>
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('type', $event)">类型<span v-if="sortIndex('type') !== null" class="sort-index" :class="sortClass('type') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('type') }}</span>{{ sortIcon('type') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="description" label="描述" min-width="200">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('description', $event)">描述<span v-if="sortIndex('description') !== null" class="sort-index" :class="sortClass('description') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('description') }}</span>{{ sortIcon('description') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="taskId" label="任务ID" width="100">
- <template slot-scope="scope">
- <span>{{ scope.row.taskId || '-' }}</span>
- </template>
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('taskId', $event)">任务ID<span v-if="sortIndex('taskId') !== null" class="sort-index" :class="sortClass('taskId') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('taskId') }}</span>{{ sortIcon('taskId') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="createdAt" label="时间" width="180">
- <template slot-scope="scope">
- {{ formatDate(scope.row.createdAt) }}
- </template>
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('createdAt', $event)">时间<span v-if="sortIndex('createdAt') !== null" class="sort-index" :class="sortClass('createdAt') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('createdAt') }}</span>{{ sortIcon('createdAt') }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 分页 -->
- <el-pagination
- class="pagination-right-20"
- @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 SortMixin from '@/mixins/SortMixin'
- import ListStateMixin from '@/mixins/ListStateMixin'
- import { getPointsLogs, getFamilyList } from '@/api/admin'
- export default {
- name: 'Points',
- mixins: [SortMixin, ListStateMixin],
- computed: {
- tableHeight() {
- return window.innerHeight - 340
- }
- },
- data() {
- return {
- loading: false,
- tableData: [],
- familyOptions: [],
- sortableColumns: { id: 'ID', amount: '积分变动', type: '类型', description: '描述', taskId: '任务ID', createdAt: '时间' },
- searchForm: {
- keyword: '',
- familyId: '',
- type: ''
- },
- pagination: {
- current: 1,
- size: 10,
- total: 0
- }
- }
- },
- mounted() {
- this.loadFamilyOptions()
- this.loadPointsLogs()
- },
- methods: {
- async loadFamilyOptions() {
- try {
- const res = await getFamilyList({ page: 1, size: 500 })
- this.familyOptions = (res.data && res.data.records) ? res.data.records : (res.data || [])
- } catch (error) {
- this.familyOptions = []
- }
- },
- loadList() {
- this.loadPointsLogs()
- },
- async loadPointsLogs() {
- this.loading = true
- try {
- const params = {
- page: this.pagination.current,
- size: this.pagination.size,
- ...this.searchForm
- }
- if (this.sortState.length > 0) params.sort = this.sortState
- 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 = {
- keyword: '',
- familyId: '',
- 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
- },
- }
- }
- </script>
- <style scoped>
- /* == C 批内联清理工具类 == */
- .form-mb20 { margin-bottom: 24px; }
- .select-220 { width: 220px; }
- .table-full { width: 100%; }
- .pagination-right-20 { margin-top: 24px; text-align: right; }
- </style>
|