index.vue 4.2 KB

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