You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

vp-point.vue 9.5 kB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <div class="__reward-pointer-c">
  3. <div class="ui container" style="width:80%">
  4. <div class="__r_p_header">
  5. <div>
  6. <p class="__title">算力积分明细</p>
  7. </div>
  8. <div style="padding: 0 5px; font-size: 14px">
  9. <el-button @click="operatePoint(1)">+</el-button>
  10. <el-button @click="operatePoint(0)">-</el-button>
  11. <span>
  12. <i class="question circle icon link" style="color: rgba(3, 102, 214, 1)" data-position="right center"
  13. data-variation="mini"></i>
  14. <a href="" target="_blank" style="color: rgba(3, 102, 214, 1)">积分获取说明</a>
  15. </span>
  16. </div>
  17. </div>
  18. <div class="__r_p_summary">
  19. <div class="__r_p_summary_item-c __flex-1">
  20. <div class="__val">{{ summaryInfo.available }}</div>
  21. <div class="__exp">当前可用算力积分(分)</div>
  22. </div>
  23. <div class="__r_p_summary_line"></div>
  24. <div class="__r_p_summary_item-c __flex-1">
  25. <div class="__val">{{ summaryInfo.gain }}</div>
  26. <div class="__exp">总获取算力积分(分)</div>
  27. </div>
  28. <div class="__r_p_summary_item-c __flex-1">
  29. <div class="__val">{{ summaryInfo.used }}</div>
  30. <div class="__exp">总消耗算力积分(分)</div>
  31. </div>
  32. </div>
  33. <div class="__r_p_tab">
  34. <div class="__r_p_tab-item" :class="tabIndex === 0 ? '__focus' : ''" style="border-radius: 5px 0px 0px 5px"
  35. @click="tabChange(0)">
  36. 总获取明细
  37. </div>
  38. <div class="__r_p_tab-item" :class="tabIndex === 1 ? '__focus' : ''" style="border-radius: 0px 5px 5px 0px"
  39. @click="tabChange(1)">
  40. 总消耗明细
  41. </div>
  42. </div>
  43. <div class="__r_p_table">
  44. <div>
  45. <el-table :data="tableData" style="width: 100%" v-loading="loading" stripe>
  46. <el-table-column prop="sn" label="流水号" align="center" header-align="center" width="180"></el-table-column>
  47. <el-table-column prop="date" label="时间" align="center" header-align="center" width="180"></el-table-column>
  48. <el-table-column v-if="tabIndex === 1" prop="status" label="状态" align="center" header-align="center"
  49. width="120">
  50. <template slot-scope="scope">
  51. <span :style="{ color: scope.row.statusColor }">{{ scope.row.status }}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="sourceType" label="场景" align="center" header-align="center" width="180">
  55. </el-table-column>
  56. <el-table-column v-if="tabIndex === 1" prop="duration" label="运行时长" align="center" header-align="center"
  57. width="150">
  58. </el-table-column>
  59. <el-table-column v-if="tabIndex === 0" prop="action" label="积分行为" align="center" header-align="center"
  60. width="200">
  61. </el-table-column>
  62. <el-table-column prop="remark" label="说明" align="left" header-align="center">
  63. </el-table-column>
  64. <el-table-column v-if="tabIndex === 1" prop="taskName" label="任务名称" align="center" header-align="center">
  65. </el-table-column>
  66. <el-table-column prop="amount" label="积分" align="center" header-align="center" width="120">
  67. </el-table-column>
  68. <template slot="empty">
  69. <span>{{ loading ? "加载加..." : "暂无数据" }}</span>
  70. </template>
  71. </el-table>
  72. </div>
  73. <div class="__r_p_pagination">
  74. <div style="margin-top: 2rem">
  75. <div class="center">
  76. <el-pagination background @current-change="currentChange" :current-page="pageInfo.curpage"
  77. :page-sizes="pageInfo.pageSizes" :page-size="pageInfo.pageSize"
  78. layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total">
  79. </el-pagination>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import { formatDate } from 'element-ui/lib/utils/date-util';
  89. import { getPoint, getPointAccount, getPointList, setPointOperate } from "../../../apis/modules/point";
  90. import { SOURCE_TYPE, CONSUME_STATUS, POINT_ACTIONS } from './const';
  91. export default {
  92. data() {
  93. return {
  94. loading: false,
  95. summaryInfo: {
  96. available: 0,
  97. gain: 0,
  98. used: 0,
  99. },
  100. tabIndex: 0,
  101. tableData: [],
  102. pageInfo: {
  103. curpage: 1,
  104. pageSize: 10,
  105. pageSizes: [10],
  106. total: 100,
  107. },
  108. };
  109. },
  110. components: {},
  111. methods: {
  112. getSourceType: function (key) {
  113. const find = SOURCE_TYPE.filter(item => item.k === key);
  114. return find.length ? find[0].v : key;
  115. },
  116. getConsumeStatus: function (key) {
  117. const find = CONSUME_STATUS.filter(item => item.k === key);
  118. return find.length ? find[0].v : key;
  119. },
  120. getPointAction: function (key) {
  121. const find = POINT_ACTIONS.filter(item => item.k === key);
  122. return find.length ? find[0].v : key;
  123. },
  124. currentChange: function (val) {
  125. this.pageInfo.curpage = val;
  126. this.getTableData();
  127. },
  128. tabChange: function (index) {
  129. if (this.tabIndex === index) return;
  130. this.tabIndex = index;
  131. this.pageInfo.curpage = 1;
  132. this.pageInfo.total = 0;
  133. this.getTableData();
  134. },
  135. getTableData: function () {
  136. this.loading = true;
  137. getPointList({
  138. operate: this.tabIndex === 0 ? 'INCREASE' : 'DECREASE',
  139. pageSize: this.pageInfo.pageSize,
  140. page: this.pageInfo.curpage,
  141. })
  142. .then((res) => {
  143. this.loading = false;
  144. const tableData = [];
  145. if (res.data && res.data.Code === 0) {
  146. const data = res.data.Data;
  147. const records = data.Records;
  148. for (let i = 0, iLen = records.length; i < iLen; i++) {
  149. const record = records[i];
  150. tableData.push({
  151. sn: record.SerialNo,
  152. date: formatDate(new Date(record.LastOperateDate * 1000), 'yyyy-MM-DD HH:mm:ss'),
  153. _status: record.Status,
  154. status: this.getConsumeStatus(record.Status) || '--',
  155. statusColor: record.Status === 'OPERATING' ? 'rgb(33, 186, 69)' : '',
  156. _sourceType: record.SourceType,
  157. sourceType: this.getSourceType(record.SourceType),
  158. duration: record?.Cloudbrain?.Duration || '--',
  159. taskName: record?.Cloudbrain?.DisplayJobName || '--',
  160. taskId: record?.Cloudbrain?.ID,
  161. action: record?.Action?.OpType ? this.getPointAction(record.Action.OpType) : '--',
  162. remark: record.Remark,
  163. amount: record.Amount,
  164. });
  165. }
  166. this.tableData.splice(0, Infinity, ...tableData);
  167. this.pageInfo.total = data.Total;
  168. }
  169. })
  170. .catch((err) => {
  171. console.log(err);
  172. this.loading = false;
  173. this.tableData.splice(0, Infinity);
  174. });
  175. },
  176. operatePoint: function (type) {
  177. setPointOperate({
  178. TargetUserId: 369,
  179. OperateType: type === 1 ? 'INCREASE' : 'DECREASE',
  180. Amount: 1,
  181. Remark: 'Remark: ' + (type === 1 ? 'INCREASE' : 'DECREASE') + ' 1.',
  182. RewardType: 'POINT',
  183. }).then(res => {
  184. console.log(res);
  185. }).catch(err => {
  186. console.log(err);
  187. })
  188. }
  189. },
  190. mounted: function () {
  191. getPointAccount().then(res => {
  192. if (res.data && res.data.Code === 0) {
  193. const data = res.data.Data;
  194. this.summaryInfo.available = data.Balance;
  195. this.summaryInfo.gain = data.TotalEarned;
  196. this.summaryInfo.used = data.TotalConsumed;
  197. }
  198. }).catch(err => {
  199. console.log(err);
  200. })
  201. this.getTableData();
  202. },
  203. computed: {},
  204. };
  205. </script>
  206. <style scoped lang="less">
  207. .__flex-1 {
  208. flex: 1;
  209. }
  210. .__reward-pointer-c {
  211. .__r_p_header {
  212. height: 30px;
  213. margin: 10px 0;
  214. display: flex;
  215. align-items: center;
  216. justify-content: space-between;
  217. .__title {
  218. font-weight: 400;
  219. font-size: 18px;
  220. color: rgb(16, 16, 16);
  221. line-height: 26px;
  222. }
  223. }
  224. .__r_p_summary {
  225. display: flex;
  226. align-items: center;
  227. height: 100px;
  228. background-color: rgb(245, 245, 246);
  229. .__r_p_summary_item-c {
  230. .__val {
  231. text-align: center;
  232. margin: 12px 0;
  233. font-weight: 400;
  234. font-size: 28px;
  235. color: rgb(16, 16, 16);
  236. }
  237. .__exp {
  238. text-align: center;
  239. font-weight: 400;
  240. font-size: 14px;
  241. color: rgba(54, 56, 64, 1);
  242. }
  243. }
  244. }
  245. }
  246. .__r_p_summary_line {
  247. width: 1px;
  248. height: 80%;
  249. background-color: rgb(212, 212, 213);
  250. }
  251. .__r_p_tab {
  252. display: flex;
  253. margin: 18px 0;
  254. .__r_p_tab-item {
  255. width: 115px;
  256. height: 38px;
  257. display: flex;
  258. justify-content: center;
  259. align-items: center;
  260. border: 1px solid rgb(225, 227, 230);
  261. color: #101010;
  262. box-sizing: border-box;
  263. cursor: pointer;
  264. &.__focus {
  265. border-color: rgb(50, 145, 248);
  266. color: rgb(50, 145, 248);
  267. cursor: default;
  268. }
  269. }
  270. }
  271. .__r_p_table {
  272. /deep/ .el-table__header {
  273. th {
  274. background: rgb(245, 245, 246);
  275. color: rgb(96, 98, 102);
  276. font-weight: 400;
  277. font-size: 14px;
  278. }
  279. }
  280. }
  281. </style>