公众号前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

135 lines
5.3 KiB

  1. <template>
  2. <div class="mod-config">
  3. <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
  4. <el-form-item>
  5. <el-input v-model="dataForm.paramKey" placeholder="参数名" clearable></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button @click="getDataList()">查询</el-button>
  9. <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
  10. <el-button type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
  11. </el-form-item>
  12. </el-form>
  13. <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle" style="width: 100%;">
  14. <el-table-column type="selection" header-align="center" align="center" width="50">
  15. </el-table-column>
  16. <el-table-column prop="id" header-align="center" align="center" width="80" label="ID">
  17. </el-table-column>
  18. <el-table-column prop="paramKey" header-align="center" align="center" label="参数名">
  19. </el-table-column>
  20. <el-table-column prop="paramValue" header-align="center" align="center" label="参数值">
  21. </el-table-column>
  22. <el-table-column prop="remark" header-align="center" align="center" label="备注">
  23. </el-table-column>
  24. <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
  25. <template slot-scope="scope">
  26. <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
  27. <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
  28. </template>
  29. </el-table-column>
  30. </el-table>
  31. <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalCount" layout="total, sizes, prev, pager, next, jumper">
  32. </el-pagination>
  33. <!-- 弹窗, 新增 / 修改 -->
  34. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  35. </div>
  36. </template>
  37. <script>
  38. import AddOrUpdate from './config-add-or-update'
  39. export default {
  40. data() {
  41. return {
  42. dataForm: {
  43. paramKey: ''
  44. },
  45. dataList: [],
  46. pageIndex: 1,
  47. pageSize: 10,
  48. totalCount: 0,
  49. dataListLoading: false,
  50. dataListSelections: [],
  51. addOrUpdateVisible: false
  52. }
  53. },
  54. components: {
  55. AddOrUpdate
  56. },
  57. activated() {
  58. this.getDataList()
  59. },
  60. methods: {
  61. // 获取数据列表
  62. getDataList() {
  63. this.dataListLoading = true
  64. this.$http({
  65. url: this.$http.adornUrl('/sys/config/list'),
  66. method: 'get',
  67. params: this.$http.adornParams({
  68. 'page': this.pageIndex,
  69. 'limit': this.pageSize,
  70. 'paramKey': this.dataForm.paramKey
  71. })
  72. }).then(({ data }) => {
  73. if (data && data.code === 200) {
  74. this.dataList = data.page.list
  75. this.totalCount = data.page.totalCount
  76. } else {
  77. this.dataList = []
  78. this.totalCount = 0
  79. }
  80. this.dataListLoading = false
  81. })
  82. },
  83. // 每页数
  84. sizeChangeHandle(val) {
  85. this.pageSize = val
  86. this.pageIndex = 1
  87. this.getDataList()
  88. },
  89. // 当前页
  90. currentChangeHandle(val) {
  91. this.pageIndex = val
  92. this.getDataList()
  93. },
  94. // 多选
  95. selectionChangeHandle(val) {
  96. this.dataListSelections = val
  97. },
  98. // 新增 / 修改
  99. addOrUpdateHandle(id) {
  100. this.addOrUpdateVisible = true
  101. this.$nextTick(() => {
  102. this.$refs.addOrUpdate.init(id)
  103. })
  104. },
  105. // 删除
  106. deleteHandle(id) {
  107. var ids = id ? [id] : this.dataListSelections.map(item => item.id)
  108. this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
  109. confirmButtonText: '确定',
  110. cancelButtonText: '取消',
  111. type: 'warning'
  112. }).then(() => {
  113. this.$http({
  114. url: this.$http.adornUrl('/sys/config/delete'),
  115. method: 'post',
  116. data: this.$http.adornData(ids, false)
  117. }).then(({ data }) => {
  118. if (data && data.code === 200) {
  119. this.$message({
  120. message: '操作成功',
  121. type: 'success',
  122. duration: 1500,
  123. onClose: () => this.getDataList()
  124. })
  125. } else {
  126. this.$message.error(data.msg)
  127. }
  128. })
  129. }).catch(() => { })
  130. }
  131. }
  132. }
  133. </script>