diff --git a/src/api/menu.js b/src/api/menu.js index 251636daf0df2c6f1339cc533b06a5254be845de..2e374afe7055427a7b3b16185ea5c1d5f0c6279d 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 818e4ca63f604b216da9d72984a142a1ad1f7173..14acc20a36249e46a803b4aa13c4846b5da94dd6 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 d3b657032b8ba7e6ed164222d01f20f287d671aa..b5921bf654eb00969392970d423b7c8caf665e83 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 b1435871875a050d139c0500105ba937ab7b3147..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..88560dffad35aa43035ee79a2359bb9c536c3d8d --- /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 dce01ed36f3c25f50760f7db9e2bd7ce6bc6a91d..ec2bc258ac26d166f0e9ac840007493194447659 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 bc74c1c8eb827bc30110efab33b66cf07e6fa462..c6774a1f55f30f5ebca0fa4e527493ceda81485b 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 0000000000000000000000000000000000000000..6507a715f460890492480e74c8686ff58cd64a14 --- /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 e29d93ff5fc182411c3d5bae5b06ef566f357624..f55826cbf856b638b3674176e77dff60bf58d315 100644 --- a/src/pages/user/components/todo.vue +++ b/src/pages/user/components/todo.vue @@ -1,3 +1,41 @@ + +