| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <div class="challenge-score-config admin-page">
- <PageHeader title="挑战评分配置" subtitle="家庭挑战 发起/同意/拒绝 的方向性关系评分与能量增减(可正可负)" />
- <div class="adm-table-wrap">
- <el-table :data="matrix" v-loading="loading" border stripe height="100%">
- <el-table-column label="动作" width="120">
- <template slot-scope="{ row }">
- <StatusTag size="mini" :type="row.action === 'reject' ? 'danger' : 'success'" :text="actionLabel(row.action)" />
- </template>
- </el-table-column>
- <el-table-column label="能量(行维度)" width="140">
- <template slot-scope="{ row }">
- <el-input-number v-model="row.energy" :min="-10" :max="10" size="mini" />
- </template>
- </el-table-column>
- <el-table-column label="信任(方向)" width="140">
- <template slot-scope="{ row }">
- <el-input-number v-model="row.trust" :min="-10" :max="10" size="mini" />
- </template>
- </el-table-column>
- <el-table-column label="亲近(方向)" width="140">
- <template slot-scope="{ row }">
- <el-input-number v-model="row.intimacy" :min="-10" :max="10" size="mini" />
- </template>
- </el-table-column>
- <el-table-column label="沟通(方向)" width="140">
- <template slot-scope="{ row }">
- <el-input-number v-model="row.communication" :min="-10" :max="10" size="mini" />
- </template>
- </el-table-column>
- <el-table-column label="操作" width="120" fixed="right">
- <template slot-scope="{ row }">
- <el-button size="mini" type="primary" @click="saveRow(row)">保存</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div class="footer-tip">注:reject 的沟通方向由代码固定(拒绝人→发起人 +、发起人→拒绝人 -、已同意成员→拒绝人 -),此处的值为增减幅度。信任/亲近为单向扣减(发起人→拒绝人)。</div>
- </div>
- </template>
- <script>
- import { getChallengeScoreConfigList, updateChallengeScoreConfig } from '@/api/challengeScore'
- export default {
- name: 'ChallengeScoreConfig',
- data() {
- return {
- loading: false,
- matrix: []
- }
- },
- created() {
- this.loadList()
- },
- methods: {
- actionLabel: function(action) {
- var map = { initiate: '发起', agree: '同意', reject: '拒绝' }
- return map[action] || action
- },
- loadList: function() {
- var self = this
- self.loading = true
- getChallengeScoreConfigList().then(function(res) {
- var list = (res && res.data) || []
- var matrix = []
- var actions = ['initiate', 'agree', 'reject']
- for (var i = 0; i < actions.length; i++) {
- var row = { action: actions[i], energy: 0, trust: 0, intimacy: 0, communication: 0 }
- for (var j = 0; j < list.length; j++) {
- var item = list[j]
- if (item.action !== row.action) continue
- if (item.scoreType === 'energy') row.energy = item.value
- if (item.scoreType === 'trust') row.trust = item.value
- if (item.scoreType === 'intimacy') row.intimacy = item.value
- if (item.scoreType === 'communication') row.communication = item.value
- }
- matrix.push(row)
- }
- self.matrix = matrix
- }).catch(function() {
- self.matrix = []
- }).finally(function() {
- self.loading = false
- })
- },
- saveRow: function(row) {
- var self = this
- var items = [
- { action: row.action, scoreType: 'energy', value: row.energy },
- { action: row.action, scoreType: 'trust', value: row.trust },
- { action: row.action, scoreType: 'intimacy', value: row.intimacy },
- { action: row.action, scoreType: 'communication', value: row.communication }
- ]
- var promises = items.map(function(item) {
- return updateChallengeScoreConfig(item)
- })
- Promise.all(promises).then(function() {
- self.$message.success(row.action + ' 配置已保存')
- }).catch(function() {
- self.$message.error('保存失败')
- })
- }
- }
- }
- </script>
- <style scoped>
- .footer-tip { margin-top: 12px; color: var(--adm-text-45); font-size: 12px; line-height: 1.6; }
- </style>
|