|
|
@@ -3,7 +3,7 @@
|
|
|
<div class="header">
|
|
|
<h2>CF值(平台积分)管理</h2>
|
|
|
<div class="filters">
|
|
|
- <el-input v-model="searchUserId" placeholder="用户ID搜索" style="width: 200px;" clearable @keyup.enter.native="searchBalance" />
|
|
|
+ <el-input v-model="searchUserId" placeholder="用户ID/用户名搜索" style="width: 200px;" clearable @keyup.enter.native="searchBalance" />
|
|
|
<el-button type="primary" @click="searchBalance">查询余额</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -12,7 +12,9 @@
|
|
|
<el-tab-pane label="余额列表" name="balances">
|
|
|
<el-table :data="balanceList" v-loading="loadingBalance" border stripe>
|
|
|
<el-table-column prop="id" label="ID" width="70" />
|
|
|
- <el-table-column prop="userId" label="用户ID" width="100" />
|
|
|
+ <el-table-column label="用户" width="140">
|
|
|
+ <template slot-scope="{ row }">{{ row.userName || '用户' + row.userId }}</template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="familyId" label="家庭ID" width="100" />
|
|
|
<el-table-column prop="totalEarned" label="累计获得" width="100" />
|
|
|
<el-table-column prop="available" label="可用" width="80" />
|
|
|
@@ -35,7 +37,9 @@
|
|
|
</div>
|
|
|
<el-table :data="logList" v-loading="loadingLog" border stripe>
|
|
|
<el-table-column prop="id" label="ID" width="70" />
|
|
|
- <el-table-column prop="userId" label="用户ID" width="80" />
|
|
|
+ <el-table-column label="用户" width="120">
|
|
|
+ <template slot-scope="{ row }">{{ row.userName || '用户' + row.userId }}</template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="type" label="类型" width="100">
|
|
|
<template slot-scope="{ row }">
|
|
|
<el-tag :type="typeTag(row.type)" size="small">{{ row.type }}</el-tag>
|
|
|
@@ -55,7 +59,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getCfValueBalance, getCfValueLogs, getCfValueAllBalances } from '@/api/admin'
|
|
|
+import { getCfValueBalance, getCfValueLogs, getCfValueAllBalances, searchUsers } from '@/api/admin'
|
|
|
|
|
|
export default {
|
|
|
data() {
|
|
|
@@ -81,16 +85,44 @@ export default {
|
|
|
this.loadBalances()
|
|
|
},
|
|
|
methods: {
|
|
|
+ resolveUserNames(items, idField) {
|
|
|
+ if (!items || items.length === 0) return Promise.resolve()
|
|
|
+ var ids = []
|
|
|
+ items.forEach(function(item) {
|
|
|
+ if (item[idField] && ids.indexOf(item[idField]) === -1) ids.push(item[idField])
|
|
|
+ })
|
|
|
+ var nameMap = {}
|
|
|
+ var self = this
|
|
|
+ return Promise.all(ids.map(function(id) {
|
|
|
+ return searchUsers({ keyword: String(id) })
|
|
|
+ .then(function(res) {
|
|
|
+ if (res.data && res.data.length > 0) {
|
|
|
+ var u = res.data[0]
|
|
|
+ nameMap[id] = u.nickname || u.realName || '用户' + id
|
|
|
+ } else {
|
|
|
+ nameMap[id] = '用户' + id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(function() {
|
|
|
+ nameMap[id] = '用户' + id
|
|
|
+ })
|
|
|
+ })).then(function() {
|
|
|
+ items.forEach(function(item) {
|
|
|
+ item.userName = nameMap[item[idField]] || '用户' + item[idField]
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
typeTag(type) {
|
|
|
const map = { earn: 'success', spend: 'warning', freeze: 'info', unfreeze: 'info', withdraw: 'primary' }
|
|
|
return map[type] || 'info'
|
|
|
},
|
|
|
loadBalances() {
|
|
|
this.loadingBalance = true
|
|
|
- getCfValueAllBalances({ page: this.balancePage, size: this.balanceSize }).then(res => {
|
|
|
+ getCfValueAllBalances({ page: this.balancePage, size: this.balanceSize }).then(async res => {
|
|
|
if (res.code === 200) {
|
|
|
this.balanceList = res.data.records || []
|
|
|
this.balanceTotal = res.data.total || 0
|
|
|
+ await this.resolveUserNames(this.balanceList, 'userId')
|
|
|
}
|
|
|
}).finally(() => { this.loadingBalance = false })
|
|
|
},
|
|
|
@@ -101,12 +133,13 @@ export default {
|
|
|
searchBalance() {
|
|
|
if (!this.searchUserId) { this.loadBalances(); return }
|
|
|
this.loadingBalance = true
|
|
|
- getCfValueBalance({ userId: this.searchUserId }).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.balanceList = [res.data]
|
|
|
- this.balanceTotal = 1
|
|
|
- }
|
|
|
- }).finally(() => { this.loadingBalance = false })
|
|
|
+getCfValueBalance({ userId: this.searchUserId }).then(async res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.balanceList = [res.data]
|
|
|
+ this.balanceTotal = 1
|
|
|
+ await this.resolveUserNames(this.balanceList, 'userId')
|
|
|
+ }
|
|
|
+ }).finally(() => { this.loadingBalance = false })
|
|
|
},
|
|
|
viewLogs(userId) {
|
|
|
this.logUserId = String(userId)
|
|
|
@@ -117,12 +150,13 @@ export default {
|
|
|
if (!this.logUserId) return
|
|
|
this.loadingLog = true
|
|
|
this.logPage = 1
|
|
|
- getCfValueLogs({ userId: this.logUserId, page: 1, size: this.logSize }).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.logList = res.data.records || []
|
|
|
- this.logTotal = res.data.total || 0
|
|
|
- }
|
|
|
- }).finally(() => { this.loadingLog = false })
|
|
|
+getCfValueLogs({ userId: this.logUserId, page: 1, size: this.logSize }).then(async res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.logList = res.data.records || []
|
|
|
+ this.logTotal = res.data.total || 0
|
|
|
+ await this.resolveUserNames(this.logList, 'userId')
|
|
|
+ }
|
|
|
+ }).finally(() => { this.loadingLog = false })
|
|
|
},
|
|
|
pageLogs(page) {
|
|
|
this.logPage = page
|