index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. getObj,
  40. addObj,
  41. putObj,
  42. delObj
  43. } from '@/api/pay/paychannel'
  44. import {
  45. tableOption
  46. } from '@/const/crud/pay/paychannel'
  47. import {
  48. mapGetters
  49. } from 'vuex'
  50. export default {
  51. name: 'Paychannel',
  52. data() {
  53. return {
  54. tableData: [],
  55. page: {
  56. total: 0, // 总页数
  57. currentPage: 1, // 当前页数
  58. pageSize: 20 // 每页显示多少条
  59. },
  60. tableLoading: false,
  61. tableOption: tableOption
  62. }
  63. },
  64. computed: {
  65. ...mapGetters(['permissions']),
  66. permissionList() {
  67. return {
  68. addBtn: this.vaildData(this.permissions.pay_paychannel_add, false),
  69. delBtn: this.vaildData(this.permissions.pay_paychannel_del, false),
  70. editBtn: this.vaildData(this.permissions.pay_paychannel_edit, false)
  71. }
  72. }
  73. },
  74. methods: {
  75. getList(page, params) {
  76. this.tableLoading = true
  77. fetchList(Object.assign({
  78. current: page.currentPage,
  79. size: page.pageSize
  80. }, params)).then(response => {
  81. this.tableData = response.data.data.records
  82. this.page.total = response.data.data.total
  83. this.tableLoading = false
  84. }).catch(() => {
  85. this.tableLoading = false
  86. })
  87. },
  88. rowDel: function(row, index) {
  89. var _this = this
  90. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  91. confirmButtonText: '确定',
  92. cancelButtonText: '取消',
  93. type: 'warning'
  94. }).then(function() {
  95. return delObj(row.id)
  96. }).then(data => {
  97. _this.tableData.splice(index, 1)
  98. _this.$message({
  99. showClose: true,
  100. message: '删除成功',
  101. type: 'success'
  102. })
  103. this.getList(this.page)
  104. })
  105. },
  106. /**
  107. * @title 数据更新
  108. * @param row 为当前的数据
  109. * @param index 为当前更新数据的行数
  110. * @param done 为表单关闭函数
  111. *
  112. **/
  113. handleUpdate: function(row, index, done, loading) {
  114. putObj(row).then(data => {
  115. this.tableData.splice(index, 1, Object.assign({}, row))
  116. this.$message({
  117. showClose: true,
  118. message: '修改成功',
  119. type: 'success'
  120. })
  121. done()
  122. this.getList(this.page)
  123. }).catch(() => {
  124. loading()
  125. })
  126. },
  127. /**
  128. * @title 数据添加
  129. * @param row 为当前的数据
  130. * @param done 为表单关闭函数
  131. *
  132. **/
  133. handleSave: function(row, done, loading) {
  134. addObj(row).then(data => {
  135. this.tableData.push(Object.assign({}, row))
  136. this.$message({
  137. showClose: true,
  138. message: '添加成功',
  139. type: 'success'
  140. })
  141. done()
  142. this.getList(this.page)
  143. }).catch(() => {
  144. loading()
  145. })
  146. },
  147. /**
  148. * 搜索回调
  149. */
  150. searchChange(form) {
  151. this.getList(this.page, form)
  152. },
  153. /**
  154. * 刷新回调
  155. */
  156. refreshChange() {
  157. this.getList(this.page)
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. </style>