index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <!--积分管理-->
  2. <template>
  3. <div class="app-container points-record">
  4. <div class="page-one-box" v-if="pageType == 1">
  5. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  6. <el-form-item label="关键字" prop="searchValue">
  7. <el-input
  8. v-model="queryParams.searchValue"
  9. placeholder="姓名/学号"
  10. clearable
  11. size="small"
  12. />
  13. </el-form-item>
  14. <el-form-item label="创建时间" prop="dateRange" style="margin-left:10px;">
  15. <el-date-picker
  16. :clearable="false"
  17. v-model="dateRange"
  18. size="small"
  19. style="width: 240px"
  20. value-format="yyyy-MM-dd"
  21. type="daterange"
  22. range-separator="-"
  23. start-placeholder="开始日期"
  24. end-placeholder="结束日期"
  25. ></el-date-picker>
  26. </el-form-item>
  27. <el-form-item>
  28. <p class="inquire-button-one" @click="handleQuery">查询</p>
  29. <p class="reset-button-one" @click="resetQuery">重置</p>
  30. </el-form-item>
  31. </el-form>
  32. <el-table v-loading="loading" border :data="recordList" @sort-change="handleSelectionChange">
  33. <el-table-column label="姓名" align="left" prop="nickName" />
  34. <el-table-column label="学号" align="left" prop="userName" />
  35. <el-table-column label="总积分" align="left" sortable="custom" prop="totalPoints" />
  36. <el-table-column label="信用分" align="left" sortable="custom" prop="creditScore" />
  37. <el-table-column label="奖励分" align="left" sortable="custom" prop="bonusPoints" />
  38. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="240" v-if="tableButtonType">
  39. <template slot-scope="scope">
  40. <div class="table-button-box">
  41. <p class="table-button-null"></p>
  42. <p class="table-button-p"
  43. v-hasPermi="['points:record:creditscore']"
  44. @click="goPage(2,scope.row)"
  45. >信用分明细</p>
  46. <p class="table-button-p"
  47. v-hasPermi="['points:record:bonuspoints']"
  48. @click="goPage(3,scope.row)"
  49. >奖励分明细</p>
  50. <p class="table-button-null"></p>
  51. </div>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <pagination :page-sizes="[20, 30, 40, 50]"
  56. v-show="total>0"
  57. :total="total"
  58. layout="total, prev, pager, next, sizes, jumper"
  59. :page.sync="queryParams.pageNum"
  60. :limit.sync="queryParams.pageSize"
  61. @pagination="getList"
  62. />
  63. </div>
  64. <credit-score-list v-if="pageType == 2" :propsData="propsData"></credit-score-list>
  65. <reward-points-list v-if="pageType == 3" :propsData="propsData"></reward-points-list>
  66. </div>
  67. </template>
  68. <script>
  69. import { listRecord, getRecord, delRecord, addRecord, updateRecord } from "@/api/exam/record";
  70. import creditScoreList from "./creditScoreList.vue";
  71. import rewardPointsList from "./rewardPointsList.vue";
  72. export default {
  73. name: "Record",
  74. components: {
  75. creditScoreList,
  76. rewardPointsList
  77. },
  78. data() {
  79. return {
  80. tableButtonType:this.hasPermiDom(['points:record:creditscore','points:record:bonuspoints']),
  81. // 遮罩层
  82. loading: true,
  83. // 选中数组
  84. ids: [],
  85. // 非单个禁用
  86. single: true,
  87. // 非多个禁用
  88. multiple: true,
  89. // 显示搜索条件
  90. showSearch: true,
  91. // 总条数
  92. total: 0,
  93. // 用户积分记录表格数据
  94. recordList: [],
  95. // 查询参数
  96. queryParams: {
  97. pageNum: 1,
  98. pageSize:20,
  99. searchValue: null,
  100. points: null,
  101. joinUserId: null,
  102. mode: null,
  103. deptName: null,
  104. deptId: null,
  105. userId: null,
  106. },
  107. pointsMode:[],
  108. // 日期范围
  109. dateRange: [],
  110. //页面状态
  111. pageType:1,
  112. //所选用户id
  113. propsData:{},
  114. };
  115. },
  116. created() {
  117. this.getList();
  118. this.getDicts("points_mode").then(response => {
  119. this.pointsMode = response.data;
  120. });
  121. },
  122. methods: {
  123. goPage(type,row){
  124. console.log("type",type)
  125. console.log("row",row)
  126. if(this.pageType!=type){
  127. if(type == 1){
  128. this.pageType = type;
  129. this.getList();
  130. }else {
  131. this.propsData.userId = row.id;
  132. this.propsData.allBonusPoints = row.allBonusPoints;
  133. this.propsData.consumeBonusPoints = row.consumeBonusPoints;
  134. this.propsData.bonusPoints = row.bonusPoints;
  135. this.pageType = type;
  136. }
  137. }
  138. },
  139. /** 查询用户积分记录列表 */
  140. getList() {
  141. this.loading = true;
  142. if(this.dateRange&&this.dateRange.length>0)
  143. {
  144. this.queryParams.beginTime=this.dateRange[0]
  145. this.queryParams.endTime=this.dateRange[1]
  146. }
  147. else
  148. {
  149. this.queryParams.beginTime=null;
  150. this.queryParams.endTime=null
  151. }
  152. if(this.pageType){
  153. this.queryParams.pointsType = 2
  154. }
  155. listRecord(this.queryParams).then( response => {
  156. this.recordList = response.rows;
  157. this.total = response.total;
  158. this.loading = false;
  159. });
  160. },
  161. // 行为字典翻译
  162. modeFormat(row, column) {
  163. return this.selectDictLabel(this.pointsMode, row.mode);
  164. },
  165. pointsFormat(row,a)
  166. {
  167. return row.recordType.code===1?`+ ${row.points}`:`- ${row.points}`
  168. },
  169. // 取消按钮
  170. cancel() {
  171. this.open = false;
  172. this.reset();
  173. },
  174. // 表单重置
  175. reset() {
  176. this.form = {
  177. id: null,
  178. points: null,
  179. joinUserId: null,
  180. mode: null,
  181. deptName: null,
  182. deptId: null,
  183. createTime: null,
  184. userId: null,
  185. createBy: null,
  186. updateTime: null,
  187. updateBy: null,
  188. remark: null
  189. };
  190. this.resetForm("form");
  191. },
  192. /** 搜索按钮操作 */
  193. handleQuery() {
  194. this.queryParams.pageNum = 1;
  195. this.getList();
  196. },
  197. /** 重置按钮操作 */
  198. resetQuery() {
  199. // this.resetForm("queryForm");
  200. this.$set(this,'queryParams',{
  201. pageNum: 1,
  202. pageSize:20,
  203. searchValue:"",
  204. });
  205. this.queryParams.searchValue='';
  206. this.dateRange=[];
  207. this.handleQuery();
  208. },
  209. // 排序监听
  210. handleSelectionChange(type) {
  211. if(type.order == 'ascending'){
  212. this.queryParams.order = type.prop;//降
  213. this.queryParams.orderType = 'asc';//升ascending
  214. }else if(type.order == 'descending'){
  215. this.queryParams.order = type.prop;//降
  216. this.queryParams.orderType = 'desc';//降
  217. }else{
  218. this.queryParams.order = null;//无
  219. this.queryParams.orderType = null;//无
  220. }
  221. this.getList();
  222. },
  223. /** 新增按钮操作 */
  224. handleAdd() {
  225. this.reset();
  226. this.open = true;
  227. this.title = "添加用户积分记录";
  228. },
  229. /** 修改按钮操作 */
  230. handleUpdate(row) {
  231. this.reset();
  232. const id = row.id || this.ids
  233. getRecord(id).then( response => {
  234. this.form = response.data;
  235. this.open = true;
  236. this.title = "修改用户积分记录";
  237. });
  238. },
  239. /** 提交按钮 */
  240. submitForm() {
  241. this.$refs["form"].validate(valid => {
  242. if (valid) {
  243. if (this.form.id != null) {
  244. updateRecord(this.form).then( response => {
  245. this.msgSuccess("修改成功");
  246. this.open = false;
  247. this.getList();
  248. });
  249. } else {
  250. addRecord(this.form).then( response => {
  251. this.msgSuccess("新增成功");
  252. this.open = false;
  253. this.getList();
  254. });
  255. }
  256. }
  257. });
  258. },
  259. /** 删除按钮操作 */
  260. handleDelete(row) {
  261. const ids = row.id || this.ids;
  262. this.$confirm('是否确认删除用户积分记录?', "警告", {
  263. confirmButtonText: "确定",
  264. cancelButtonText: "取消",
  265. type: "warning"
  266. }).then(function() {
  267. return delRecord(ids);
  268. }).then(() => {
  269. this.getList();
  270. this.msgSuccess("删除成功");
  271. }).catch(() => {});
  272. },
  273. /** 导出按钮操作 */
  274. handleExport() {
  275. this.download('exam/record/export', {
  276. ...this.queryParams
  277. }, `exam_record.xlsx`)
  278. }
  279. }
  280. };
  281. </script>
  282. <style scoped lang="scss">
  283. .points-record {
  284. display: flex!important;
  285. flex-direction: column;
  286. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  287. overflow: hidden;
  288. .page-one-box{
  289. flex:1;
  290. display: flex!important;
  291. flex-direction: column;
  292. overflow: hidden;
  293. padding:20px!important;
  294. }
  295. .el-row{
  296. margin-bottom:20px;
  297. }
  298. .button-box{
  299. width:250px;
  300. display: flex;
  301. }
  302. .form-box{
  303. display:flex;
  304. .null-p{
  305. flex:1;
  306. }
  307. }
  308. }
  309. </style>