|
- <template>
- <div class="__reward-pointer-c">
- <div class="ui container" style="width:80%">
- <div class="__r_p_header">
- <div>
- <p class="__title">算力积分明细</p>
- </div>
- <div style="padding: 0 5px; font-size: 14px">
- <el-button @click="operatePoint(1)">+</el-button>
- <el-button @click="operatePoint(0)">-</el-button>
- <span>
- <i class="question circle icon link" style="color: rgba(3, 102, 214, 1)" data-position="right center"
- data-variation="mini"></i>
- <a href="" target="_blank" style="color: rgba(3, 102, 214, 1)">积分获取说明</a>
- </span>
- </div>
- </div>
- <div class="__r_p_summary">
- <div class="__r_p_summary_item-c __flex-1">
- <div class="__val">{{ summaryInfo.available }}</div>
- <div class="__exp">当前可用算力积分(分)</div>
- </div>
- <div class="__r_p_summary_line"></div>
- <div class="__r_p_summary_item-c __flex-1">
- <div class="__val">{{ summaryInfo.gain }}</div>
- <div class="__exp">总获取算力积分(分)</div>
- </div>
- <div class="__r_p_summary_item-c __flex-1">
- <div class="__val">{{ summaryInfo.used }}</div>
- <div class="__exp">总消耗算力积分(分)</div>
- </div>
- </div>
- <div class="__r_p_tab">
- <div class="__r_p_tab-item" :class="tabIndex === 0 ? '__focus' : ''" style="border-radius: 5px 0px 0px 5px"
- @click="tabChange(0)">
- 总获取明细
- </div>
- <div class="__r_p_tab-item" :class="tabIndex === 1 ? '__focus' : ''" style="border-radius: 0px 5px 5px 0px"
- @click="tabChange(1)">
- 总消耗明细
- </div>
- </div>
- <div class="__r_p_table">
- <div>
- <el-table :data="tableData" style="width: 100%" v-loading="loading" stripe>
- <el-table-column prop="sn" label="流水号" align="center" header-align="center" width="180"></el-table-column>
- <el-table-column prop="date" label="时间" align="center" header-align="center" width="180"></el-table-column>
- <el-table-column v-if="tabIndex === 1" prop="status" label="状态" align="center" header-align="center"
- width="120">
- <template slot-scope="scope">
- <span :style="{ color: scope.row.statusColor }">{{ scope.row.status }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="sourceType" label="场景" align="center" header-align="center" width="180">
- </el-table-column>
- <el-table-column v-if="tabIndex === 1" prop="duration" label="运行时长" align="center" header-align="center"
- width="150">
- </el-table-column>
- <el-table-column v-if="tabIndex === 0" prop="action" label="积分行为" align="center" header-align="center"
- width="200">
- </el-table-column>
- <el-table-column prop="remark" label="说明" align="left" header-align="center">
- </el-table-column>
- <el-table-column v-if="tabIndex === 1" prop="taskName" label="任务名称" align="center" header-align="center">
- </el-table-column>
- <el-table-column prop="amount" label="积分" align="center" header-align="center" width="120">
- </el-table-column>
- <template slot="empty">
- <span>{{ loading ? "加载加..." : "暂无数据" }}</span>
- </template>
- </el-table>
- </div>
- <div class="__r_p_pagination">
- <div style="margin-top: 2rem">
- <div class="center">
- <el-pagination background @current-change="currentChange" :current-page="pageInfo.curpage"
- :page-sizes="pageInfo.pageSizes" :page-size="pageInfo.pageSize"
- layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total">
- </el-pagination>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
-
- <script>
- import { formatDate } from 'element-ui/lib/utils/date-util';
- import { getPoint, getPointAccount, getPointList, setPointOperate } from "../../../apis/modules/point";
- import { SOURCE_TYPE, CONSUME_STATUS, POINT_ACTIONS } from './const';
- export default {
- data() {
- return {
- loading: false,
- summaryInfo: {
- available: 0,
- gain: 0,
- used: 0,
- },
- tabIndex: 0,
- tableData: [],
- pageInfo: {
- curpage: 1,
- pageSize: 10,
- pageSizes: [10],
- total: 100,
- },
- };
- },
- components: {},
- methods: {
- getSourceType: function (key) {
- const find = SOURCE_TYPE.filter(item => item.k === key);
- return find.length ? find[0].v : key;
- },
- getConsumeStatus: function (key) {
- const find = CONSUME_STATUS.filter(item => item.k === key);
- return find.length ? find[0].v : key;
- },
- getPointAction: function (key) {
- const find = POINT_ACTIONS.filter(item => item.k === key);
- return find.length ? find[0].v : key;
- },
- currentChange: function (val) {
- this.pageInfo.curpage = val;
- this.getTableData();
- },
- tabChange: function (index) {
- if (this.tabIndex === index) return;
- this.tabIndex = index;
- this.pageInfo.curpage = 1;
- this.pageInfo.total = 0;
- this.getTableData();
- },
- getTableData: function () {
- this.loading = true;
- getPointList({
- operate: this.tabIndex === 0 ? 'INCREASE' : 'DECREASE',
- pageSize: this.pageInfo.pageSize,
- page: this.pageInfo.curpage,
- })
- .then((res) => {
- this.loading = false;
- const tableData = [];
- if (res.data && res.data.Code === 0) {
- const data = res.data.Data;
- const records = data.Records;
- for (let i = 0, iLen = records.length; i < iLen; i++) {
- const record = records[i];
- tableData.push({
- sn: record.SerialNo,
- date: formatDate(new Date(record.LastOperateDate * 1000), 'yyyy-MM-DD HH:mm:ss'),
- _status: record.Status,
- status: this.getConsumeStatus(record.Status) || '--',
- statusColor: record.Status === 'OPERATING' ? 'rgb(33, 186, 69)' : '',
- _sourceType: record.SourceType,
- sourceType: this.getSourceType(record.SourceType),
- duration: record?.Cloudbrain?.Duration || '--',
- taskName: record?.Cloudbrain?.DisplayJobName || '--',
- taskId: record?.Cloudbrain?.ID,
- action: record?.Action?.OpType ? this.getPointAction(record.Action.OpType) : '--',
- remark: record.Remark,
- amount: record.Amount,
- });
- }
- this.tableData.splice(0, Infinity, ...tableData);
- this.pageInfo.total = data.Total;
- }
- })
- .catch((err) => {
- console.log(err);
- this.loading = false;
- this.tableData.splice(0, Infinity);
- });
- },
- operatePoint: function (type) {
- setPointOperate({
- TargetUserId: 369,
- OperateType: type === 1 ? 'INCREASE' : 'DECREASE',
- Amount: 1,
- Remark: 'Remark: ' + (type === 1 ? 'INCREASE' : 'DECREASE') + ' 1.',
- RewardType: 'POINT',
- }).then(res => {
- console.log(res);
- }).catch(err => {
- console.log(err);
- })
- }
- },
- mounted: function () {
- getPointAccount().then(res => {
- if (res.data && res.data.Code === 0) {
- const data = res.data.Data;
- this.summaryInfo.available = data.Balance;
- this.summaryInfo.gain = data.TotalEarned;
- this.summaryInfo.used = data.TotalConsumed;
- }
- }).catch(err => {
- console.log(err);
- })
- this.getTableData();
- },
- computed: {},
- };
- </script>
-
- <style scoped lang="less">
- .__flex-1 {
- flex: 1;
- }
-
- .__reward-pointer-c {
- .__r_p_header {
- height: 30px;
- margin: 10px 0;
- display: flex;
- align-items: center;
- justify-content: space-between;
-
- .__title {
- font-weight: 400;
- font-size: 18px;
- color: rgb(16, 16, 16);
- line-height: 26px;
- }
- }
-
- .__r_p_summary {
- display: flex;
- align-items: center;
- height: 100px;
- background-color: rgb(245, 245, 246);
-
- .__r_p_summary_item-c {
- .__val {
- text-align: center;
- margin: 12px 0;
- font-weight: 400;
- font-size: 28px;
- color: rgb(16, 16, 16);
- }
-
- .__exp {
- text-align: center;
- font-weight: 400;
- font-size: 14px;
- color: rgba(54, 56, 64, 1);
- }
- }
- }
- }
-
- .__r_p_summary_line {
- width: 1px;
- height: 80%;
- background-color: rgb(212, 212, 213);
- }
-
- .__r_p_tab {
- display: flex;
- margin: 18px 0;
-
- .__r_p_tab-item {
- width: 115px;
- height: 38px;
- display: flex;
- justify-content: center;
- align-items: center;
- border: 1px solid rgb(225, 227, 230);
- color: #101010;
- box-sizing: border-box;
- cursor: pointer;
-
- &.__focus {
- border-color: rgb(50, 145, 248);
- color: rgb(50, 145, 248);
- cursor: default;
- }
- }
- }
-
- .__r_p_table {
- /deep/ .el-table__header {
- th {
- background: rgb(245, 245, 246);
- color: rgb(96, 98, 102);
- font-weight: 400;
- font-size: 14px;
- }
- }
- }
- </style>
|