index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="appMenuManage app-container">
  3. <div class="search">
  4. <div>
  5. <el-select
  6. v-model="query.belongType"
  7. size="small"
  8. clearable
  9. class="item-width-200"
  10. placeholder="请选择小程序类型"
  11. >
  12. <el-option
  13. v-for="item in options"
  14. :key="item.value"
  15. :label="item.label"
  16. :value="item.value"
  17. >
  18. </el-option>
  19. </el-select>
  20. <el-button
  21. class="ml10"
  22. type="primary"
  23. size="small"
  24. icon="el-icon-search"
  25. @click="handleSearch"
  26. >
  27. 搜索
  28. </el-button>
  29. </div>
  30. <el-button class="add-btn" type="primary" size="small" @click="handleAdd"
  31. >添加</el-button
  32. >
  33. </div>
  34. <el-table
  35. :data="tableData"
  36. tooltip-effect="dark"
  37. border
  38. v-loading="loading"
  39. style="width: 100%"
  40. >
  41. <el-table-column
  42. prop="imgUrl"
  43. align="center"
  44. label="图标"
  45. show-overflow-tooltip
  46. >
  47. <template slot-scope="scope">
  48. <img class="icon" :src="scope.row.imgUrl" alt="">
  49. </template>
  50. </el-table-column>
  51. <el-table-column
  52. prop="menuName"
  53. align="center"
  54. label="菜单名称"
  55. show-overflow-tooltip
  56. >
  57. </el-table-column>
  58. <el-table-column
  59. align="center"
  60. label="小程序"
  61. show-overflow-tooltip
  62. >
  63. <template slot-scope="scope">
  64. <span>{{scope.row.belongType ==2?'慧研学':'贵大'}}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column
  68. prop="sort"
  69. align="center"
  70. label="权重排序"
  71. show-overflow-tooltip
  72. >
  73. </el-table-column>
  74. <el-table-column
  75. prop="domainUrl"
  76. align="center"
  77. label="域名"
  78. show-overflow-tooltip
  79. >
  80. </el-table-column>
  81. <el-table-column
  82. prop="status"
  83. align="center"
  84. label="状态"
  85. show-overflow-tooltip
  86. >
  87. <template slot-scope="scope">
  88. <span :class="[scope.row.status == 1?'red':'green']">{{scope.row.status == 1?"隐藏 ":"显示"}}</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="address" align="center" label="操作">
  92. <template slot-scope="scope">
  93. <el-button type="text" size="small" v-if="$route.query.title != '二级菜单'" @click="handle(scope.row.id)">查看下级</el-button>
  94. <el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
  95. <el-button type="text" size="small" @click="handleDel(scope.row.id)">删除</el-button>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <div class="page-box">
  100. <el-pagination
  101. @size-change="handleSizeChange"
  102. @current-change="handleCurrentChange"
  103. background
  104. :current-page="query.currentPage"
  105. :page-sizes="[10, 20, 30, 40]"
  106. :page-size="query.pageSize"
  107. layout="total, sizes, prev, pager, next, jumper"
  108. :total="total"
  109. >
  110. </el-pagination>
  111. </div>
  112. </div>
  113. </template>
  114. <script>
  115. import { debounce } from "@/utils/index";
  116. import {getMenu,del} from '@/api/appConfig'
  117. export default {
  118. name: "appMenuManage",
  119. data() {
  120. return {
  121. tableData: [],
  122. loading: false,
  123. query: {
  124. status: "",
  125. menuName: "",
  126. parentId:'',
  127. belongType:null,
  128. currentPage: 1,
  129. pageSize: 10,
  130. },
  131. options:[
  132. {
  133. label:'贵大',
  134. value:'1'
  135. },
  136. {
  137. label:'慧研学',
  138. value:'2'
  139. },
  140. {
  141. label: "生活宝",
  142. value: '3',
  143. },
  144. ],
  145. title: "",
  146. total: 0,
  147. };
  148. },
  149. // watch: {
  150. // query: {
  151. // handler: debounce(function (val) {
  152. // this.getMenu()
  153. // }),
  154. // deep: true,
  155. // },
  156. // },
  157. methods: {
  158. handleSearch(){
  159. this.query.currentPage = 1
  160. this.getMenu();
  161. },
  162. handle(id){
  163. let title
  164. if(!this.$route.query.title){
  165. title = '二级菜单'
  166. }
  167. this.$router.push({
  168. path:'/operationManage/appMenuManage/index',
  169. query:{
  170. parentId:id,
  171. title
  172. }
  173. })
  174. },
  175. handleEdit(row){
  176. sessionStorage.setItem('menuItem',JSON.stringify(row))
  177. this.$router.push({
  178. path:'/operationManage/appMenuManage/addMenu',
  179. query:{
  180. title:'编辑菜单',
  181. }
  182. })
  183. },
  184. handleAdd(){
  185. this.$router.push({
  186. path:'/operationManage/appMenuManage/addMenu',
  187. query:{
  188. title:'新增菜单',
  189. parentId:this.$route.query.parentId,
  190. menuLevel:this.$route.query.title == '二级菜单'?2:1
  191. }
  192. })
  193. },
  194. // 点击删除
  195. handleDel(id) {
  196. this.$confirm(`此操作将删除该数据, 是否继续?`, '提示', {
  197. confirmButtonText: '确定',
  198. cancelButtonText: '取消',
  199. type: 'warning'
  200. }).then(() => {
  201. del({menuId:id}).then(res=>{
  202. if(res.state == 'Success'){
  203. this.$notify({
  204. title: '成功',
  205. message: '操作成功',
  206. type: 'success'
  207. });
  208. this.getMenu()
  209. }
  210. })
  211. })
  212. },
  213. handleSizeChange(val) {
  214. this.query.currentPage = 1;
  215. this.query.pageSize = val;
  216. this.getMenu()
  217. },
  218. handleCurrentChange(val) {
  219. this.query.currentPage = val;
  220. this.getMenu()
  221. },
  222. getMenu(){
  223. this.loading = true
  224. getMenu(this.query).then(res=>{
  225. this.loading = false
  226. if(res.state == 'Success'){
  227. this.tableData = res.content.records
  228. this.total = res.content.total
  229. }
  230. })
  231. }
  232. },
  233. created() {
  234. this.query.parentId = this.$route.query.parentId
  235. this.getMenu()
  236. },
  237. };
  238. </script>
  239. <style lang="scss" scoped>
  240. .appMenuManage {
  241. .search{
  242. justify-content: space-between;
  243. }
  244. .icon{
  245. width: 80px;
  246. height: 80px;
  247. }
  248. }
  249. </style>