index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. @row-update="handleUpdate"
  31. @row-save="handleSave"
  32. @row-del="rowDel"/>
  33. </basic-container>
  34. </div>
  35. </template>
  36. <script>
  37. import {
  38. fetchList,
  39. addObj,
  40. putObj,
  41. delObj
  42. } from '@/api/pay/paynotifyrecord'
  43. import {
  44. tableOption
  45. } from '@/const/crud/pay/paynotifyrecord'
  46. import {
  47. mapGetters
  48. } from 'vuex'
  49. export default {
  50. name: 'Paynotifyrecord',
  51. data() {
  52. return {
  53. tableData: [],
  54. page: {
  55. total: 0, // 总页数
  56. currentPage: 1, // 当前页数
  57. pageSize: 20 // 每页显示多少条
  58. },
  59. tableLoading: false,
  60. tableOption: tableOption
  61. }
  62. },
  63. computed: {
  64. ...mapGetters(['permissions']),
  65. permissionList() {
  66. return {
  67. addBtn: this.vaildData(this.permissions.generator_paynotifyrecord_add, false),
  68. delBtn: this.vaildData(this.permissions.generator_paynotifyrecord_del, false),
  69. editBtn: this.vaildData(this.permissions.generator_paynotifyrecord_edit, false)
  70. }
  71. }
  72. },
  73. methods: {
  74. getList(page, params) {
  75. this.tableLoading = true
  76. fetchList(Object.assign({
  77. current: page.currentPage,
  78. size: page.pageSize
  79. }, params)).then(response => {
  80. this.tableData = response.data.data.records
  81. this.page.total = response.data.data.total
  82. this.tableLoading = false
  83. }).catch(() => {
  84. this.tableLoading = false
  85. })
  86. },
  87. rowDel: function(row, index) {
  88. var _this = this
  89. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  90. confirmButtonText: '确定',
  91. cancelButtonText: '取消',
  92. type: 'warning'
  93. }).then(function() {
  94. return delObj(row.id)
  95. }).then(data => {
  96. _this.tableData.splice(index, 1)
  97. _this.$message({
  98. showClose: true,
  99. message: '删除成功',
  100. type: 'success'
  101. })
  102. this.getList(this.page)
  103. })
  104. },
  105. handleUpdate: function(row, index, done, loading) {
  106. putObj(row).then(data => {
  107. this.tableData.splice(index, 1, Object.assign({}, row))
  108. this.$message({
  109. showClose: true,
  110. message: '修改成功',
  111. type: 'success'
  112. })
  113. done()
  114. this.getList(this.page)
  115. }).catch(() => {
  116. loading()
  117. })
  118. },
  119. handleSave: function(row, done, loading) {
  120. addObj(row).then(data => {
  121. this.tableData.push(Object.assign({}, row))
  122. this.$message({
  123. showClose: true,
  124. message: '添加成功',
  125. type: 'success'
  126. })
  127. done()
  128. this.getList(this.page)
  129. }).catch(() => {
  130. loading()
  131. })
  132. },
  133. searchChange(form) {
  134. this.getList(this.page, form)
  135. },
  136. refreshChange() {
  137. this.getList(this.page)
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. </style>