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.

152 lines
4.4 KiB

5 years ago
5 years ago
5 years ago
  1. <template>
  2. <div class="mod-menu">
  3. <el-form :inline="true" :model="dataForm">
  4. <el-form-item>
  5. <el-button v-if="isAuth('sys:menu:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
  6. </el-form-item>
  7. </el-form>
  8. <el-table
  9. :data="dataList"
  10. row-key="menuId"
  11. border
  12. style="width: 100%; ">
  13. <el-table-column
  14. prop="name"
  15. header-align="center"
  16. min-width="150"
  17. label="名称" >
  18. </el-table-column>
  19. <el-table-column
  20. prop="parentName"
  21. header-align="center"
  22. align="center"
  23. width="120"
  24. label="上级菜单">
  25. </el-table-column>
  26. <el-table-column
  27. header-align="center"
  28. align="center"
  29. label="图标">
  30. <template slot-scope="scope">
  31. <icon-svg :name="scope.row.icon || ''"></icon-svg>
  32. </template>
  33. </el-table-column>
  34. <el-table-column
  35. prop="type"
  36. header-align="center"
  37. align="center"
  38. label="类型">
  39. <template slot-scope="scope">
  40. <el-tag v-if="scope.row.type === 0" size="small">目录</el-tag>
  41. <el-tag v-else-if="scope.row.type === 1" size="small" type="success">菜单</el-tag>
  42. <el-tag v-else-if="scope.row.type === 2" size="small" type="info">按钮</el-tag>
  43. </template>
  44. </el-table-column>
  45. <el-table-column
  46. prop="orderNum"
  47. header-align="center"
  48. align="center"
  49. label="排序号">
  50. </el-table-column>
  51. <el-table-column
  52. prop="url"
  53. header-align="center"
  54. align="center"
  55. width="150"
  56. :show-overflow-tooltip="true"
  57. label="菜单URL">
  58. </el-table-column>
  59. <el-table-column
  60. prop="perms"
  61. header-align="center"
  62. align="center"
  63. width="150"
  64. :show-overflow-tooltip="true"
  65. label="授权标识">
  66. </el-table-column>
  67. <el-table-column
  68. fixed="right"
  69. header-align="center"
  70. align="center"
  71. width="150"
  72. label="操作">
  73. <template slot-scope="scope">
  74. <a v-if="isAuth('sys:menu:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.menuId)">修改</a>
  75. <a v-if="isAuth('sys:menu:delete')" type="text" size="small" @click="deleteHandle(scope.row.menuId)">删除</a>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. <!-- 弹窗, 新增 / 修改 -->
  80. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  81. </div>
  82. </template>
  83. <script>
  84. import AddOrUpdate from './menu-add-or-update'
  85. import { treeDataTranslate } from '@/utils'
  86. export default {
  87. data () {
  88. return {
  89. dataForm: {},
  90. dataList: [],
  91. dataListLoading: false,
  92. addOrUpdateVisible: false
  93. }
  94. },
  95. components: {
  96. AddOrUpdate
  97. },
  98. activated () {
  99. this.getDataList()
  100. },
  101. methods: {
  102. // 获取数据列表
  103. getDataList () {
  104. this.dataListLoading = true
  105. this.$http({
  106. url: this.$http.adornUrl('/sys/menu/list/'+this.$i18n.locale),
  107. method: 'get',
  108. params: this.$http.adornParams()
  109. }).then(({data}) => {
  110. this.dataList = treeDataTranslate(data, 'menuId')
  111. this.dataListLoading = false
  112. })
  113. },
  114. // 新增 / 修改
  115. addOrUpdateHandle (id) {
  116. this.addOrUpdateVisible = true
  117. this.$nextTick(() => {
  118. this.$refs.addOrUpdate.init(id)
  119. })
  120. },
  121. // 删除
  122. deleteHandle (id) {
  123. this.$confirm(`确定对[id=${id}]进行[删除]操作?`, '提示', {
  124. confirmButtonText: '确定',
  125. cancelButtonText: '取消',
  126. type: 'warning'
  127. }).then(() => {
  128. this.$http({
  129. url: this.$http.adornUrl(`/sys/menu/delete/${id}`),
  130. method: 'post',
  131. data: this.$http.adornData()
  132. }).then(({data}) => {
  133. if (data && data.code === 0) {
  134. this.$message({
  135. message: '操作成功',
  136. type: 'success',
  137. duration: 1500,
  138. onClose: () => {
  139. this.getDataList()
  140. }
  141. })
  142. } else {
  143. this.$message.error(data.msg)
  144. }
  145. })
  146. }).catch(() => {})
  147. }
  148. }
  149. }
  150. </script>