index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 ref="crud"
  21. :page="page"
  22. :data="tableData"
  23. :permission="permissionList"
  24. :table-loading="tableLoading"
  25. :option="tableOption"
  26. @on-load="getList"
  27. @search-change="searchChange"
  28. @refresh-change="refreshChange"
  29. @row-update="handleUpdate"
  30. @row-save="handleSave"
  31. @row-del="rowDel">
  32. </avue-crud>
  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. tableData: [],
  45. page: {
  46. total: 0, // 总页数
  47. currentPage: 1, // 当前页数
  48. pageSize: 20 // 每页显示多少条
  49. },
  50. tableLoading: false,
  51. tableOption: tableOption
  52. }
  53. },
  54. created() {
  55. },
  56. mounted: function () {
  57. },
  58. computed: {
  59. ...mapGetters(['permissions']),
  60. permissionList() {
  61. return {
  62. addBtn: this.vaildData(this.permissions.admin_syspublicparam_add, false),
  63. delBtn: this.vaildData(this.permissions.admin_syspublicparam_del, false),
  64. editBtn: this.vaildData(this.permissions.admin_syspublicparam_edit, false)
  65. };
  66. }
  67. },
  68. methods: {
  69. getList(page, params) {
  70. this.tableLoading = true
  71. fetchList(Object.assign({
  72. descs: 'create_time',
  73. current: page.currentPage,
  74. size: page.pageSize
  75. }, params)).then(response => {
  76. this.tableData = response.data.data.records
  77. this.page.total = response.data.data.total
  78. this.tableLoading = false
  79. })
  80. },
  81. rowDel: function(row, index) {
  82. var _this = this
  83. this.$confirm('是否确认删除ID为' + row.publicId, '提示', {
  84. confirmButtonText: '确定',
  85. cancelButtonText: '取消',
  86. type: 'warning'
  87. }).then(function() {
  88. return delObj(row.publicId)
  89. }).then(data => {
  90. this.getList(this.page)
  91. _this.$message({
  92. showClose: true,
  93. message: '删除成功',
  94. type: 'success'
  95. })
  96. }).catch(function(err) { })
  97. },
  98. /**
  99. * @title 数据更新
  100. * @param row 为当前的数据
  101. * @param index 为当前更新数据的行数
  102. * @param done 为表单关闭函数
  103. *
  104. **/
  105. handleUpdate: function(row, index, done) {
  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. })
  116. },
  117. /**
  118. * @title 数据添加
  119. * @param row 为当前的数据
  120. * @param done 为表单关闭函数
  121. *
  122. **/
  123. handleSave: function(row, done) {
  124. addObj(this.filterForm(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. })
  134. },
  135. /**
  136. * 搜索回调
  137. */
  138. searchChange(form) {
  139. this.getList(this.page, this.filterForm(form))
  140. },
  141. /**
  142. * 刷新回调
  143. */
  144. refreshChange() {
  145. this.getList(this.page)
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. </style>