diff --git a/src/components/table/index.vue b/src/components/table/index.vue index 0e9af81a80a51eec915a978b9f7e973207758e9c..c2fca438e877f2b9aa3406f1a34b559fe91cbcc7 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 feee4d3e9fedfbdf3e86a079e08eaa359ed2db9c..f43cfd3e545593db90028979f96cea0eddaeedd7 100644 --- a/src/pages/system/view/menu/MenuManagement.vue +++ b/src/pages/system/view/menu/MenuManagement.vue @@ -1,5 +1,5 @@