index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <basic-container>
  20. <avue-crud
  21. ref="crud"
  22. :page="page"
  23. :data="tableData"
  24. :permission="permissionList"
  25. :table-loading="tableLoading"
  26. :option="tableOption"
  27. @on-load="getList"
  28. @search-change="searchChange"
  29. @refresh-change="refreshChange"
  30. @size-change="sizeChange"
  31. @current-change="currentChange"
  32. @row-update="handleUpdate"
  33. @row-save="handleSave"
  34. @row-del="rowDel"/>
  35. </basic-container>
  36. </div>
  37. </template>
  38. <script>
  39. import {addObj, delObj, fetchList, putObj} from '@/api/pay/paynotifyrecord'
  40. import {tableOption} from '@/const/crud/pay/paynotifyrecord'
  41. import {mapGetters} from 'vuex'
  42. export default {
  43. name: 'Paynotifyrecord',
  44. data() {
  45. return {
  46. searchForm: {},
  47. tableData: [],
  48. page: {
  49. total: 0, // 总页数
  50. currentPage: 1, // 当前页数
  51. pageSize: 20 // 每页显示多少条
  52. },
  53. tableLoading: false,
  54. tableOption: tableOption
  55. }
  56. },
  57. computed: {
  58. ...mapGetters(['permissions']),
  59. permissionList() {
  60. return {
  61. addBtn: this.vaildData(this.permissions.generator_paynotifyrecord_add, false),
  62. delBtn: this.vaildData(this.permissions.generator_paynotifyrecord_del, false),
  63. editBtn: this.vaildData(this.permissions.generator_paynotifyrecord_edit, false)
  64. }
  65. }
  66. },
  67. methods: {
  68. getList(page, params) {
  69. this.tableLoading = true
  70. fetchList(Object.assign({
  71. descs: 'create_time',
  72. current: page.currentPage,
  73. size: page.pageSize
  74. }, params, this.searchForm)).then(response => {
  75. this.tableData = response.data.data.records
  76. this.page.total = response.data.data.total
  77. this.tableLoading = false
  78. }).catch(() => {
  79. this.tableLoading = false
  80. })
  81. },
  82. rowDel: function (row, index) {
  83. var _this = this
  84. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  85. confirmButtonText: '确定',
  86. cancelButtonText: '取消',
  87. type: 'warning'
  88. }).then(function () {
  89. return delObj(row.id)
  90. }).then(data => {
  91. _this.tableData.splice(index, 1)
  92. _this.$message({
  93. showClose: true,
  94. message: '删除成功',
  95. type: 'success'
  96. })
  97. this.getList(this.page)
  98. })
  99. },
  100. handleUpdate: function (row, index, done, loading) {
  101. putObj(row).then(data => {
  102. this.tableData.splice(index, 1, Object.assign({}, row))
  103. this.$message({
  104. showClose: true,
  105. message: '修改成功',
  106. type: 'success'
  107. })
  108. done()
  109. this.getList(this.page)
  110. }).catch(() => {
  111. loading()
  112. })
  113. },
  114. handleSave: function (row, done, loading) {
  115. addObj(row).then(data => {
  116. this.tableData.push(Object.assign({}, row))
  117. this.$message({
  118. showClose: true,
  119. message: '添加成功',
  120. type: 'success'
  121. })
  122. done()
  123. this.getList(this.page)
  124. }).catch(() => {
  125. loading()
  126. })
  127. },
  128. searchChange(form) {
  129. this.searchForm = form
  130. this.getList(this.page, form)
  131. },
  132. sizeChange(pageSize) {
  133. this.page.pageSize = pageSize
  134. },
  135. currentChange(current) {
  136. this.page.currentPage = current
  137. },
  138. refreshChange() {
  139. this.getList(this.page)
  140. }
  141. }
  142. }
  143. </script>