From c351dac8ebbcb79026c8a3f25ba8364484802436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B4=E8=90=BD=28YangLei=29?= Date: Fri, 2 Jul 2021 10:30:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/menu.js | 8 ++ src/components/action_button/index.vue | 9 +- src/components/table/table.vue | 83 ++++++++++++++++--- src/components/table/tableDrawer.vue | 22 ----- src/components/table/wraper.vue | 52 ++++++++++++ src/pages/system/view/menu/MenuManagement.vue | 17 ++-- src/pages/system/view/menu/add_com.vue | 70 +++++++++++++++- src/pages/user/components/form.vue | 14 ++++ src/pages/user/components/todo.vue | 40 ++++++++- 9 files changed, 272 insertions(+), 43 deletions(-) delete mode 100644 src/components/table/tableDrawer.vue create mode 100644 src/components/table/wraper.vue create mode 100644 src/pages/user/components/form.vue diff --git a/src/api/menu.js b/src/api/menu.js index 251636d..2e374af 100644 --- a/src/api/menu.js +++ b/src/api/menu.js @@ -35,3 +35,11 @@ export function getRoleApi(id) { export function updateRoleApi(data) { return putReq('/api/v1/roles', data); } + +export function getMenuComponentApi(id) { + return getReq(`/api/v1/menus/${id}/components`); +} + +export function addMenuComponentApi(id, data) { + return postReq(`/api/v1/menus/${id}/components`, data); +} diff --git a/src/components/action_button/index.vue b/src/components/action_button/index.vue index 818e4ca..14acc20 100644 --- a/src/components/action_button/index.vue +++ b/src/components/action_button/index.vue @@ -9,7 +9,7 @@ :onOk="btn.onOk" :label="btn.label" /> - {{ btn.label }} + {{ btn.label }} @@ -26,7 +26,7 @@ :onOk="btn.onOk" :label="btn.label" /> - {{ btn.label }} + {{ btn.label }} @@ -62,6 +62,7 @@ export default { }, created() { this.init(); + console.log(this.buttonsArr); }, computed: { basicBtns() { @@ -77,10 +78,10 @@ export default { return url; }, init() { - this.buttons.map((i) => { + this.buttons.map(i => { i.__hidden__ = i.isHidden && i.isHidden(this.row); }); - this.buttonsArr = this.buttons.filter((i) => !i.__hidden__); + this.buttonsArr = this.buttons.filter(i => !i.__hidden__); }, }, }; diff --git a/src/components/table/table.vue b/src/components/table/table.vue index d3b6570..b5921bf 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -15,10 +15,14 @@ - - - + + + + {{ typeof addBtn === 'object' ? addBtn.text : '新增' }} + + + + + + + + + + @@ -43,6 +65,10 @@ const initQuery = { export default { props: { url: String, + addBtn: [Object, Boolean], + buttons: Array, + noPage: Boolean, + formatData: Function, }, data() { @@ -54,6 +80,17 @@ export default { queryForm: {}, loading: false, total: 0, + visible: false, + title: '新增', + drawerStyle: { + display: 'flex', + flexDirection: 'column', + overflowY: 'hidden', + }, + bodyStyle: { + flex: 1, + overflow: 'hidden', + }, }; }, @@ -63,12 +100,14 @@ export default { computed: { pagination() { - return { - current: this.initQuery.pageNum, - pageSize: this.initQuery.pageSize, - total: this.total, - showQuickJumper: true, - }; + return this.noPage + ? false + : { + current: this.initQuery.pageNum, + pageSize: this.initQuery.pageSize, + total: this.total, + showQuickJumper: true, + }; }, }, @@ -76,7 +115,7 @@ export default { async getData() { this.loading = true; try { - await this.getDataWithPage(); + this.noPage ? await this.getDataNoPage() : await this.getDataWithPage(); } catch (error) { // todo } @@ -90,10 +129,34 @@ export default { else this.data = res.records; }, + async getDataNoPage() { + const res = await request(this.url, METHOD.GET, this.queryForm); + if (this.formatData) this.data = this.formatData(res); + else this.data = res; + }, + pageChange(page) { this.initQuery.pageNum = page.current; this.getData(); }, + + hidden() { + this.visible = false; + }, + show({ title } = {}) { + this.visible = true; + if (title) this.title = title; + }, + reset() { + this.queryForm = {}; + this.initQuery = { ...initQuery }; + this.getData(); + }, + addBtnClick() { + const { click } = typeof this.addBtn === 'object' ? this.addBtn : {}; + click && click(); + this.visible = true; + }, }, }; diff --git a/src/components/table/tableDrawer.vue b/src/components/table/tableDrawer.vue deleted file mode 100644 index b143587..0000000 --- a/src/components/table/tableDrawer.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/src/components/table/wraper.vue b/src/components/table/wraper.vue new file mode 100644 index 0000000..88560df --- /dev/null +++ b/src/components/table/wraper.vue @@ -0,0 +1,52 @@ + + + diff --git a/src/pages/system/view/menu/MenuManagement.vue b/src/pages/system/view/menu/MenuManagement.vue index dce01ed..ec2bc25 100644 --- a/src/pages/system/view/menu/MenuManagement.vue +++ b/src/pages/system/view/menu/MenuManagement.vue @@ -8,7 +8,7 @@ ref="table" > @@ -33,24 +33,31 @@ import AddCom from './add_com.vue'; export default { data: vm => ({ addCom: false, + currentClickRow: null, addBtn: { text: '新建', onOk() { - return vm.$refs['addForm']?.submit(); + console.log(vm.addCom); + return vm.addCom ? vm.$refs['addCom']?.submit() : vm.$refs['addForm']?.submit(); }, onCancel() { vm.addCom = false; + vm.currentClickRow = null; }, }, sortOrder: 'ascend', buttons: [ { label: '新增组件', - click() { + option: { + type: 'danger', + }, + click(row) { vm.show(); vm.addCom = true; + vm.currentClickRow = row; }, - isHidden: row => row.menuType === 'MENU', + isHidden: row => row.menuType !== 'MENU', }, { label: '编辑', click: vm.edit }, { type: 'confirm', url: row => `/api/v1/menus/${row.menuId}`, after: vm.refreshTable }, @@ -74,7 +81,7 @@ export default { }); }, show() { - this.$refs['table'].show(); + this.$refs['table'].show({ title: '菜单组件' }); }, }, }; diff --git a/src/pages/system/view/menu/add_com.vue b/src/pages/system/view/menu/add_com.vue index bc74c1c..c6774a1 100644 --- a/src/pages/system/view/menu/add_com.vue +++ b/src/pages/system/view/menu/add_com.vue @@ -1,3 +1,71 @@ + + diff --git a/src/pages/user/components/form.vue b/src/pages/user/components/form.vue new file mode 100644 index 0000000..6507a71 --- /dev/null +++ b/src/pages/user/components/form.vue @@ -0,0 +1,14 @@ + + + diff --git a/src/pages/user/components/todo.vue b/src/pages/user/components/todo.vue index e29d93f..f55826c 100644 --- a/src/pages/user/components/todo.vue +++ b/src/pages/user/components/todo.vue @@ -1,3 +1,41 @@ + + -- GitLab