index.vue 5.0 KB

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