• el-tree实现表格方式菜单


    1. <script>
    2. export default {
    3. data () {
    4. return {
    5. list: [
    6. {
    7. "menuId": 1,
    8. "menuName": "首页(首页)",
    9. "menuCode": "首页",
    10. "parentId": 0,
    11. "orderNum": 0,
    12. "path": "/page",
    13. "component": null,
    14. "query": null,
    15. "isFrame": 0,
    16. "isCache": 0,
    17. "menuType": 0,
    18. "visible": 1,
    19. "perms": null,
    20. "icon": "iconfont icon-shouye",
    21. "status": 1,
    22. "remark": null,
    23. "roleId": null,
    24. "selected": true,
    25. "level": 1,
    26. "children": [
    27. {
    28. "menuId": 2,
    29. "menuName": "首页(首页)",
    30. "menuCode": "首页",
    31. "parentId": 1,
    32. "orderNum": 1,
    33. "path": "/welcome",
    34. "component": null,
    35. "query": null,
    36. "isFrame": 0,
    37. "isCache": 0,
    38. "menuType": 1,
    39. "visible": 1,
    40. "perms": null,
    41. "icon": "",
    42. "status": 1,
    43. "remark": null,
    44. "roleId": null,
    45. "selected": true,
    46. "level": 2,
    47. "children": null
    48. }
    49. ]
    50. },
    51. {
    52. "menuId": 3,
    53. "menuName": "随访数据查询(随访数据查询)",
    54. "menuCode": "随访数据查询",
    55. "parentId": 0,
    56. "orderNum": 1,
    57. "path": "/followUpDataQuery",
    58. "component": null,
    59. "query": null,
    60. "isFrame": 0,
    61. "isCache": 0,
    62. "menuType": 0,
    63. "visible": 1,
    64. "perms": null,
    65. "icon": "iconfont icon-shengwuxuejiance",
    66. "status": 1,
    67. "remark": null,
    68. "roleId": null,
    69. "selected": true,
    70. "level": 1,
    71. "children": [
    72. {
    73. "menuId": 4,
    74. "menuName": "随访数据查询(随访数据查询)",
    75. "menuCode": "随访数据查询",
    76. "parentId": 3,
    77. "orderNum": 1,
    78. "path": "index",
    79. "component": null,
    80. "query": null,
    81. "isFrame": 0,
    82. "isCache": 0,
    83. "menuType": 1,
    84. "visible": 1,
    85. "perms": null,
    86. "icon": "",
    87. "status": 1,
    88. "remark": null,
    89. "roleId": null,
    90. "selected": true,
    91. "level": 2,
    92. "children": null
    93. },
    94. {
    95. "menuId": 5,
    96. "menuName": "随访详情(随访详情)",
    97. "menuCode": "随访详情",
    98. "parentId": 3,
    99. "orderNum": 2,
    100. "path": "detail",
    101. "component": null,
    102. "query": null,
    103. "isFrame": 0,
    104. "isCache": 0,
    105. "menuType": 1,
    106. "visible": 1,
    107. "perms": null,
    108. "icon": "",
    109. "status": 1,
    110. "remark": null,
    111. "roleId": null,
    112. "selected": true,
    113. "level": 2,
    114. "children": null
    115. }
    116. ]
    117. },
    118. {
    119. "menuId": 21,
    120. "menuName": "此单名称(11)",
    121. "menuCode": "11",
    122. "parentId": 0,
    123. "orderNum": 1,
    124. "path": "请问请问饿```",
    125. "component": null,
    126. "query": null,
    127. "isFrame": 0,
    128. "isCache": 0,
    129. "menuType": 0,
    130. "visible": 1,
    131. "perms": null,
    132. "icon": "321",
    133. "status": 1,
    134. "remark": null,
    135. "roleId": null,
    136. "selected": true,
    137. "level": 1,
    138. // "children": null
    139. },
    140. {
    141. "menuId": 6,
    142. "menuName": "调查数据查询(调查数据查询)",
    143. "menuCode": "调查数据查询",
    144. "parentId": 0,
    145. "orderNum": 2,
    146. "path": "/surveyDataQuery",
    147. "component": null,
    148. "query": null,
    149. "isFrame": 0,
    150. "isCache": 0,
    151. "menuType": 0,
    152. "visible": 1,
    153. "perms": null,
    154. "icon": "iconfont icon-shaichaxinxichaxun",
    155. "status": 1,
    156. "remark": null,
    157. "roleId": null,
    158. "selected": true,
    159. "level": 1,
    160. "children": [
    161. {
    162. "menuId": 7,
    163. "menuName": "调查数据查询(调查数据查询)",
    164. "menuCode": "调查数据查询",
    165. "parentId": 6,
    166. "orderNum": 1,
    167. "path": "index",
    168. "component": null,
    169. "query": null,
    170. "isFrame": 0,
    171. "isCache": 0,
    172. "menuType": 1,
    173. "visible": 1,
    174. "perms": null,
    175. "icon": "",
    176. "status": 1,
    177. "remark": null,
    178. "roleId": null,
    179. "selected": true,
    180. "level": 2,
    181. "children": null
    182. },
    183. {
    184. "menuId": 8,
    185. "menuName": "新建问卷(新建问卷)",
    186. "menuCode": "新建问卷",
    187. "parentId": 6,
    188. "orderNum": 2,
    189. "path": "evaluationreport",
    190. "component": null,
    191. "query": null,
    192. "isFrame": 0,
    193. "isCache": 0,
    194. "menuType": 1,
    195. "visible": 1,
    196. "perms": null,
    197. "icon": "",
    198. "status": 1,
    199. "remark": null,
    200. "roleId": null,
    201. "selected": true,
    202. "level": 2,
    203. "children": null
    204. },
    205. {
    206. "menuId": 9,
    207. "menuName": "随访详情(随访详情)",
    208. "menuCode": "随访详情",
    209. "parentId": 6,
    210. "orderNum": 3,
    211. "path": "evaluationlook",
    212. "component": null,
    213. "query": null,
    214. "isFrame": 0,
    215. "isCache": 0,
    216. "menuType": 1,
    217. "visible": 1,
    218. "perms": null,
    219. "icon": "",
    220. "status": 1,
    221. "remark": null,
    222. "roleId": null,
    223. "selected": true,
    224. "level": 2,
    225. "children": null
    226. }
    227. ]
    228. },
    229. {
    230. "menuId": 10,
    231. "menuName": "任务配置(任务配置)",
    232. "menuCode": "任务配置",
    233. "parentId": 0,
    234. "orderNum": 3,
    235. "path": "/taskSet",
    236. "component": null,
    237. "query": null,
    238. "isFrame": 0,
    239. "isCache": 0,
    240. "menuType": 0,
    241. "visible": 1,
    242. "perms": null,
    243. "icon": "iconfont icon-renwuguanli",
    244. "status": 1,
    245. "remark": null,
    246. "roleId": null,
    247. "selected": true,
    248. "level": 1,
    249. "children": [
    250. {
    251. "menuId": 11,
    252. "menuName": "任务配置(任务配置)",
    253. "menuCode": "任务配置",
    254. "parentId": 10,
    255. "orderNum": 1,
    256. "path": "index",
    257. "component": null,
    258. "query": null,
    259. "isFrame": 0,
    260. "isCache": 0,
    261. "menuType": 1,
    262. "visible": 1,
    263. "perms": null,
    264. "icon": "",
    265. "status": 1,
    266. "remark": null,
    267. "roleId": null,
    268. "selected": true,
    269. "level": 2,
    270. "children": null
    271. }
    272. ]
    273. },
    274. {
    275. "menuId": 12,
    276. "menuName": "数据统计(数据统计)",
    277. "menuCode": "数据统计",
    278. "parentId": 0,
    279. "orderNum": 4,
    280. "path": "/dataStatistics",
    281. "component": null,
    282. "query": null,
    283. "isFrame": 0,
    284. "isCache": 0,
    285. "menuType": 0,
    286. "visible": 1,
    287. "perms": null,
    288. "icon": "iconfont icon-shujutongji",
    289. "status": 1,
    290. "remark": null,
    291. "roleId": null,
    292. "selected": true,
    293. "level": 1,
    294. "children": [
    295. {
    296. "menuId": 13,
    297. "menuName": "数据统计(数据统计)",
    298. "menuCode": "数据统计",
    299. "parentId": 12,
    300. "orderNum": 1,
    301. "path": "index",
    302. "component": null,
    303. "query": null,
    304. "isFrame": 0,
    305. "isCache": 0,
    306. "menuType": 1,
    307. "visible": 1,
    308. "perms": null,
    309. "icon": "",
    310. "status": 1,
    311. "remark": null,
    312. "roleId": null,
    313. "selected": true,
    314. "level": 2,
    315. "children": null
    316. }
    317. ]
    318. },
    319. {
    320. "menuId": 14,
    321. "menuName": "数据导出(数据导出)",
    322. "menuCode": "数据导出",
    323. "parentId": 0,
    324. "orderNum": 5,
    325. "path": "/dataExport",
    326. "component": null,
    327. "query": null,
    328. "isFrame": 0,
    329. "isCache": 0,
    330. "menuType": 0,
    331. "visible": 1,
    332. "perms": null,
    333. "icon": "iconfont icon-suifangrenwuguanli",
    334. "status": 1,
    335. "remark": null,
    336. "roleId": null,
    337. "selected": true,
    338. "level": 1,
    339. "children": [
    340. {
    341. "menuId": 15,
    342. "menuName": "数据导出(数据导出)",
    343. "menuCode": "数据导出",
    344. "parentId": 14,
    345. "orderNum": 1,
    346. "path": "index",
    347. "component": null,
    348. "query": null,
    349. "isFrame": 0,
    350. "isCache": 0,
    351. "menuType": 1,
    352. "visible": 1,
    353. "perms": null,
    354. "icon": "",
    355. "status": 1,
    356. "remark": null,
    357. "roleId": null,
    358. "selected": true,
    359. "level": 2,
    360. "children": null
    361. }
    362. ]
    363. },
    364. {
    365. "menuId": 16,
    366. "menuName": "系统管理(系统管理)",
    367. "menuCode": "系统管理",
    368. "parentId": 0,
    369. "orderNum": 6,
    370. "path": "/systemManage",
    371. "component": null,
    372. "query": null,
    373. "isFrame": 0,
    374. "isCache": 0,
    375. "menuType": 0,
    376. "visible": 1,
    377. "perms": null,
    378. "icon": "iconfont icon-xitongguanli",
    379. "status": 1,
    380. "remark": null,
    381. "roleId": null,
    382. "selected": true,
    383. "level": 1,
    384. "children": [
    385. {
    386. "menuId": 17,
    387. "menuName": "用户管理(用户管理)",
    388. "menuCode": "用户管理",
    389. "parentId": 16,
    390. "orderNum": 1,
    391. "path": "usersManage",
    392. "component": null,
    393. "query": null,
    394. "isFrame": 0,
    395. "isCache": 0,
    396. "menuType": 1,
    397. "visible": 1,
    398. "perms": null,
    399. "icon": "",
    400. "status": 1,
    401. "remark": null,
    402. "roleId": null,
    403. "selected": true,
    404. "level": 2,
    405. "children": null
    406. },
    407. {
    408. "menuId": 18,
    409. "menuName": "角色管理(角色管理)",
    410. "menuCode": "角色管理",
    411. "parentId": 16,
    412. "orderNum": 2,
    413. "path": "roleManage",
    414. "component": null,
    415. "query": null,
    416. "isFrame": 0,
    417. "isCache": 0,
    418. "menuType": 1,
    419. "visible": 1,
    420. "perms": null,
    421. "icon": "",
    422. "status": 1,
    423. "remark": null,
    424. "roleId": null,
    425. "selected": true,
    426. "level": 2,
    427. "children": null
    428. },
    429. {
    430. "menuId": 19,
    431. "menuName": "权限配置(权限配置)",
    432. "menuCode": "权限配置",
    433. "parentId": 16,
    434. "orderNum": 3,
    435. "path": "permissionSetting",
    436. "component": null,
    437. "query": null,
    438. "isFrame": 0,
    439. "isCache": 0,
    440. "menuType": 1,
    441. "visible": 1,
    442. "perms": null,
    443. "icon": "",
    444. "status": 1,
    445. "remark": null,
    446. "roleId": null,
    447. "selected": true,
    448. "level": 2,
    449. "children": null
    450. },
    451. {
    452. "menuId": 20,
    453. "menuName": "菜单管理(菜单管理)",
    454. "menuCode": "菜单管理",
    455. "parentId": 16,
    456. "orderNum": 4,
    457. "path": "menuManage",
    458. "component": null,
    459. "query": null,
    460. "isFrame": 0,
    461. "isCache": 0,
    462. "menuType": 1,
    463. "visible": 1,
    464. "perms": null,
    465. "icon": "",
    466. "status": 1,
    467. "remark": null,
    468. "roleId": null,
    469. "selected": true,
    470. "level": 2,
    471. "children": null
    472. }
    473. ]
    474. }
    475. ],
    476. defaultProps: {
    477. children: 'children', // 子级
    478. label: 'menuName' // 名称
    479. }
    480. }
    481. },
    482. mounted () {
    483. // 回显菜单
    484. this.setCheckedKeys()
    485. },
    486. methods: {
    487. // 提交数据
    488. getCheckedKeys () {
    489. // 获取子级的key
    490. const childMenu = this.$refs.tree.getCheckedKeys()
    491. // 获取父级的key
    492. const partMenu = this.$refs.tree.getHalfCheckedKeys()
    493. // 合并数据
    494. const menu = partMenu.concat(childMenu)
    495. console.log(menu)
    496. },
    497. // 回显菜单
    498. setCheckedKeys () {
    499. // 一般是调接口,拿到菜单数据和回显的菜单数组
    500. // 如果default-expand-all没有展开列表时,可以使用下面代码,设置展开所有行,
    501. // const nodesMap = this.$refs.tree.store.nodesMap
    502. // const keys = Object.keys(nodesMap)
    503. // keys.forEach(key => {
    504. // nodesMap[key].expanded = true
    505. // })
    506. // 设置回显的菜单
    507. this.$nextTick(() => {
    508. this.$refs.tree.setCheckedKeys([3])
    509. })
    510. },
    511. }
    512. }
    513. script>
    514. <style lang="less" scoped>
    515. .table {
    516. padding: 20px;
    517. min-height: 88vh;
    518. background: #fff;
    519. margin: 20px;
    520. }
    521. .menu-list {
    522. ::v-deep .el-tree {
    523. border-top: 1px solid #ebeef5;
    524. border-left: 1px solid #ebeef5;
    525. border-right: 1px solid #ebeef5;
    526. .el-tree-node__expand-icon {
    527. display: none !important;
    528. }
    529. .el-tree-node {
    530. &.is-expanded,
    531. &.is-current,
    532. &.is-focusable {
    533. background-color: transparent !important;
    534. }
    535. .el-tree-node__content {
    536. background-color: transparent !important;
    537. &:hover {
    538. background-color: transparent !important;
    539. }
    540. }
    541. }
    542. > .el-tree-node {
    543. display: flex;
    544. align-items: center;
    545. border-bottom: 1px solid #ebeef5;
    546. position: relative;
    547. > .el-tree-node__content {
    548. width: 300px;
    549. height: 100%;
    550. padding-left: 20px !important;
    551. }
    552. .el-tree-node__children {
    553. position: relative;
    554. &::after {
    555. content: ' ';
    556. display: block;
    557. width: 1px;
    558. height: 100%;
    559. border-left: 1px solid #ebeef5;
    560. position: absolute;
    561. left: 0px;
    562. top: 0px;
    563. }
    564. .el-tree-node {
    565. width: 350px;
    566. padding: 10px 0px;
    567. }
    568. }
    569. }
    570. }
    571. }
    572. style>

  • 相关阅读:
    Vue(第十七课)AXIOS对JSON数据的增删改查
    Java-基于SSM的体育竞赛成绩管理系统
    antv x6让拖拽控件工具箱悬浮在画布上,工具箱区域鼠标按下不生成节点
    高效解决git中的冲突
    Flink 启用与配置检查点 Checkpoint
    Git Gui的使用+关于SSH协议和克隆对应文件代码+IDEA集成Git等
    Rasa 使用ResponseSelector实现FAQ和闲聊
    一个惊为天人的验证思路(验证数学公式是否正确)
    springboot水环境检测系统的设计与实现毕业设计源码041446
    基于matlab的精馏塔作业模拟仿真
  • 原文地址:https://blog.csdn.net/qq_41588991/article/details/133243951