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 10 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 v-show="tabIndex === 0">
  45. <el-table :data="tableData" row-key="sn" style="width: 100%" v-loading="loading" stripe>
  46. <el-table-column column-key="sn" prop="sn" label="流水号" align="center" header-align="center" width="180">
  47. </el-table-column>
  48. <el-table-column column-key="date" prop="date" label="时间" align="center" header-align="center" width="180">
  49. </el-table-column>
  50. <el-table-column column-key="sourceType" prop="sourceType" label="场景" align="center" header-align="center"
  51. width="180"></el-table-column>
  52. <el-table-column column-key="action" prop="action" label="积分行为" align="center" header-align="center"
  53. width="200"></el-table-column>
  54. <el-table-column column-key="remark" prop="remark" label="说明" align="left" header-align="center">
  55. <template slot-scope="scope">
  56. <span v-html="scope.row.remark"></span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column column-key="amount" prop="amount" label="积分" align="center" header-align="center"
  60. width="120"></el-table-column>
  61. <template slot="empty">
  62. <span>{{ loading ? "加载加..." : "暂无数据" }}</span>
  63. </template>
  64. </el-table>
  65. </div>
  66. <div v-show="tabIndex === 1">
  67. <el-table :data="tableData" row-key="sn" style="width: 100%" v-loading="loading" stripe>
  68. <el-table-column column-key="sn" prop="sn" label="流水号" align="center" header-align="center" width="180">
  69. </el-table-column>
  70. <el-table-column column-key="date" prop="date" label="时间" align="center" header-align="center" width="180">
  71. </el-table-column>
  72. <el-table-column column-key="status" prop="status" label="状态" align="center" header-align="center"
  73. width="120">
  74. <template slot-scope="scope">
  75. <span :style="{ color: scope.row.statusColor }">{{ scope.row.status }}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column column-key="sourceType" prop="sourceType" label="场景" align="center" header-align="center"
  79. width="180"></el-table-column>
  80. <el-table-column column-key="duration" prop="duration" label="运行时长" align="center" header-align="center"
  81. width="150"></el-table-column>
  82. <el-table-column column-key="remark" prop="remark" label="说明" align="left" header-align="center">
  83. <template slot-scope="scope">
  84. <span v-html="scope.row.remark"></span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column column-key="taskName" prop="taskName" label="任务名称" align="center" header-align="center">
  88. </el-table-column>
  89. <el-table-column column-key="amount" prop="amount" label="积分" align="center" header-align="center"
  90. width="120"></el-table-column>
  91. <template slot="empty">
  92. <span>{{ loading ? "加载加..." : "暂无数据" }}</span>
  93. </template>
  94. </el-table>
  95. </div>
  96. <div class="__r_p_pagination">
  97. <div style="margin-top: 2rem">
  98. <div class="center">
  99. <el-pagination background @current-change="currentChange" :current-page="pageInfo.curpage"
  100. :page-sizes="pageInfo.pageSizes" :page-size="pageInfo.pageSize"
  101. layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total">
  102. </el-pagination>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. </template>
  110. <script>
  111. import { formatDate } from 'element-ui/lib/utils/date-util';
  112. import { getPoint, getPointAccount, getPointList, setPointOperate } from "../../../apis/modules/point";
  113. import { getRewardPointRecordInfo } from './utils';
  114. export default {
  115. data() {
  116. return {
  117. loading: false,
  118. summaryInfo: {
  119. available: 0,
  120. gain: 0,
  121. used: 0,
  122. },
  123. tabIndex: 0,
  124. tableData: [],
  125. pageInfo: {
  126. curpage: 1,
  127. pageSize: 10,
  128. pageSizes: [10],
  129. total: 100,
  130. },
  131. eventSource: null,
  132. };
  133. },
  134. components: {},
  135. methods: {
  136. currentChange: function (val) {
  137. this.pageInfo.curpage = val;
  138. this.getTableData();
  139. },
  140. tabChange: function (index) {
  141. if (this.tabIndex === index) return;
  142. this.tabIndex = index;
  143. this.pageInfo.curpage = 1;
  144. this.pageInfo.total = 0;
  145. this.getTableData();
  146. },
  147. getSummaryInfo: function () {
  148. getPointAccount().then(res => {
  149. if (res.data && res.data.Code === 0) {
  150. const data = res.data.Data;
  151. this.summaryInfo.available = data.Balance;
  152. this.summaryInfo.gain = data.TotalEarned;
  153. this.summaryInfo.used = data.TotalConsumed;
  154. }
  155. }).catch(err => {
  156. console.log(err);
  157. })
  158. },
  159. getTableData: function () {
  160. this.loading = true;
  161. getPointList({
  162. operate: this.tabIndex === 0 ? 'INCREASE' : 'DECREASE',
  163. pageSize: this.pageInfo.pageSize,
  164. page: this.pageInfo.curpage,
  165. })
  166. .then((res) => {
  167. this.loading = false;
  168. const tableData = [];
  169. if (res.data && res.data.Code === 0) {
  170. const data = res.data.Data;
  171. const records = data.Records;
  172. for (let i = 0, iLen = records.length; i < iLen; i++) {
  173. const record = records[i];
  174. tableData.push(getRewardPointRecordInfo(record));
  175. }
  176. this.tableData.splice(0, Infinity, ...tableData);
  177. this.pageInfo.total = data.Total;
  178. }
  179. })
  180. .catch((err) => {
  181. console.log(err);
  182. this.loading = false;
  183. this.tableData.splice(0, Infinity);
  184. });
  185. },
  186. operatePoint: function (type) {
  187. setPointOperate({
  188. TargetUserId: 369,
  189. OperateType: type === 1 ? 'INCREASE' : 'DECREASE',
  190. Amount: 1,
  191. Remark: 'Remark: ' + (type === 1 ? 'INCREASE' : 'DECREASE') + ' 1.',
  192. RewardType: 'POINT',
  193. }).then(res => {
  194. console.log(res);
  195. }).catch(err => {
  196. console.log(err);
  197. })
  198. }
  199. },
  200. mounted: function () {
  201. this.getSummaryInfo();
  202. this.getTableData();
  203. const { AppSubUrl, csrf, NotificationSettings } = window.config;
  204. if (NotificationSettings.EventSourceUpdateTime > 0 && !!window.EventSource) {
  205. const source = new EventSource(`${AppSubUrl}/user/events`);
  206. source.addEventListener('reward-operation', (e) => {
  207. try {
  208. this.getSummaryInfo();
  209. this.getTableData();
  210. } catch (err) {
  211. console.error(err);
  212. }
  213. });
  214. this.eventSource = source;
  215. }
  216. },
  217. beforeDestroy: function () {
  218. this.eventSource && this.eventSource.close();
  219. },
  220. };
  221. </script>
  222. <style scoped lang="less">
  223. .__flex-1 {
  224. flex: 1;
  225. }
  226. .__reward-pointer-c {
  227. .__r_p_header {
  228. height: 30px;
  229. margin: 10px 0;
  230. display: flex;
  231. align-items: center;
  232. justify-content: space-between;
  233. .__title {
  234. font-weight: 400;
  235. font-size: 18px;
  236. color: rgb(16, 16, 16);
  237. line-height: 26px;
  238. }
  239. }
  240. .__r_p_summary {
  241. display: flex;
  242. align-items: center;
  243. height: 100px;
  244. background-color: rgb(245, 245, 246);
  245. .__r_p_summary_item-c {
  246. .__val {
  247. text-align: center;
  248. margin: 12px 0;
  249. font-weight: 400;
  250. font-size: 28px;
  251. color: rgb(16, 16, 16);
  252. }
  253. .__exp {
  254. text-align: center;
  255. font-weight: 400;
  256. font-size: 14px;
  257. color: rgba(54, 56, 64, 1);
  258. }
  259. }
  260. }
  261. }
  262. .__r_p_summary_line {
  263. width: 1px;
  264. height: 80%;
  265. background-color: rgb(212, 212, 213);
  266. }
  267. .__r_p_tab {
  268. display: flex;
  269. margin: 18px 0;
  270. .__r_p_tab-item {
  271. width: 115px;
  272. height: 38px;
  273. display: flex;
  274. justify-content: center;
  275. align-items: center;
  276. border: 1px solid rgb(225, 227, 230);
  277. color: #101010;
  278. box-sizing: border-box;
  279. cursor: pointer;
  280. &.__focus {
  281. border-color: rgb(50, 145, 248);
  282. color: rgb(50, 145, 248);
  283. cursor: default;
  284. }
  285. }
  286. }
  287. .__r_p_table {
  288. /deep/ .el-table__header {
  289. th {
  290. background: rgb(245, 245, 246);
  291. color: rgb(96, 98, 102);
  292. font-weight: 400;
  293. font-size: 14px;
  294. }
  295. }
  296. }
  297. </style>