From 42e2fa95210d4bf30cfa133a258cdfc091418013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B4=E8=90=BD=28YangLei=29?= Date: Fri, 25 Jun 2021 18:57:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/table/index.vue | 84 ++++++++++++++----- src/pages/system/view/menu/MenuManagement.vue | 39 +++++++-- src/utils/requestUtil.js | 1 - 3 files changed, 98 insertions(+), 26 deletions(-) diff --git a/src/components/table/index.vue b/src/components/table/index.vue index 0e9af81..c2fca43 100644 --- a/src/components/table/index.vue +++ b/src/components/table/index.vue @@ -47,25 +47,66 @@ import { request, METHOD } from '@/utils/requestUtil'; const data = [ { - key: '1', - name: 'John Brown', - age: 32, + key: 1, + name: 'John Brown sr.', + age: 60, address: 'New York No. 1 Lake Park', - tags: ['nice', 'developer'], - }, - { - key: '2', - name: 'Jim Green', - age: 42, - address: 'London No. 1 Lake Park', - tags: ['loser'], + children: [ + { + key: 11, + name: 'John Brown', + age: 42, + address: 'New York No. 2 Lake Park', + }, + { + key: 12, + name: 'John Brown jr.', + age: 30, + address: 'New York No. 3 Lake Park', + children: [ + { + key: 121, + name: 'Jimmy Brown', + age: 16, + address: 'New York No. 3 Lake Park', + }, + ], + }, + { + key: 13, + name: 'Jim Green sr.', + age: 72, + address: 'London No. 1 Lake Park', + children: [ + { + key: 131, + name: 'Jim Green', + age: 42, + address: 'London No. 2 Lake Park', + children: [ + { + key: 1311, + name: 'Jim Green jr.', + age: 25, + address: 'London No. 3 Lake Park', + }, + { + key: 1312, + name: 'Jimmy Green sr.', + age: 18, + address: 'London No. 4 Lake Park', + }, + ], + }, + ], + }, + ], }, { - key: '3', + key: 2, name: 'Joe Black', age: 32, address: 'Sidney No. 1 Lake Park', - tags: ['cool', 'teacher'], }, ]; @@ -79,6 +120,7 @@ export default { addBtn: { type: Object, }, + formatData: Function, }, data() { return { @@ -89,19 +131,21 @@ export default { }; }, mounted() { + console.log(this.addBtn); this.getData(); }, methods: { async getData() { - console.log('查询'); this.loading = true; - setTimeout(() => { - this.data = data; - this.loading = false; - }, 1000); - const res = await request(this.url, METHOD.GET); - console.log(res); + try { + const res = await request(this.url, METHOD.GET); + if (this.formatData) this.data = this.formatData(res); + else this.data = res; + } catch (error) { + // todo + } + this.loading = false; }, add() { this.addVisible = true; diff --git a/src/pages/system/view/menu/MenuManagement.vue b/src/pages/system/view/menu/MenuManagement.vue index feee4d3..f43cfd3 100644 --- a/src/pages/system/view/menu/MenuManagement.vue +++ b/src/pages/system/view/menu/MenuManagement.vue @@ -1,5 +1,5 @@