index.vue 4.4 KB

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