From b38eb035c3782025257d9b582e5a0db45f7881b8 Mon Sep 17 00:00:00 2001 From: wangting <675591594@qq.com> Date: 星期二, 02 四月 2024 10:39:16 +0800 Subject: [PATCH] 菜单跳转 --- Source/ProjectWeb/src/api/system/menu.js | 4 Source/ProjectWeb/src/page/index/top/top-menu.vue | 4 Source/ProjectWeb/src/router/avue-router.js | 6 Source/ProjectWeb/src/components/dynamic-components/dynamic-custom.vue | 76 ++++---- Source/ProjectWeb/src/store/modules/dict.js | 4 Source/ProjectWeb/src/components/file/list.vue | 162 ++++++++++++++++++++ Source/ProjectWeb/src/store/modules/user.js | 22 +- Source/ProjectWeb/src/api/user.js | 2 Source/ProjectWeb/src/page/login/userlogin.vue | 10 Source/ProjectWeb/src/views/fileManage/index.vue | 16 ++ Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue | 3 Source/ProjectWeb/src/permission.js | 153 +++++++++--------- 12 files changed, 321 insertions(+), 141 deletions(-) diff --git a/Source/ProjectWeb/src/api/system/menu.js b/Source/ProjectWeb/src/api/system/menu.js index dabe86d..23b0ee5 100644 --- a/Source/ProjectWeb/src/api/system/menu.js +++ b/Source/ProjectWeb/src/api/system/menu.js @@ -93,12 +93,12 @@ } export const getTopMenu = () => request({ - url: '/api/blade-system/menu/top-menu', + url: '/api/smFunctionController/top-menu', method: 'get' }); export const getRoutes = (parentOid) => request({ - url: 'api/smFunctionController/treeMyMenu', + url: '/api/smFunctionController/treeMyMenu', method: 'get', params: { parentOid, diff --git a/Source/ProjectWeb/src/api/user.js b/Source/ProjectWeb/src/api/user.js index c869e41..b3d90d9 100644 --- a/Source/ProjectWeb/src/api/user.js +++ b/Source/ProjectWeb/src/api/user.js @@ -2,7 +2,7 @@ import website from "@/config/website"; export const loginByUsername = (tenantId, deptId, roleId, username, password, type, key) => request({ - url: '/api/blade-auth/oauth/token', + url: '/api/framework/loginController/login', method: 'post', headers: { 'Tenant-Id': tenantId, diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-custom.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-custom.vue index a1188ad..4ed2338 100644 --- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-custom.vue +++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-custom.vue @@ -2,15 +2,15 @@ <div class="UI-dynamic" :id="'UI-dynamic-'+areasName+componentVO.oid"> <div v-if="isError" style="color: #F56C6C">杩欎釜鑷畾涔夐〉闈㈢殑鍦板潃鏍煎紡涓嶆纭�傛帹鑽愪娇鐢╞s=?type=xxx&context=yyy&pparam=zzz杩欑褰㈠紡</div> <component v-else :is="currentComponent" - :btmType="customOptions.btmType" - :content="customOptions.content" + :btmType="btmType" + :content="content" :inDialog="true" :key="areasName+'customCom-'+componentVO.oid" :componentVO="componentVO" :sourceData="sourceData" :dataStore="dataStore" :areasName="areasName" - :paramVOS="customOptions.paramVOS"></component> + :paramVOS="urlParams"></component> </div> </template> @@ -57,6 +57,9 @@ }, data() { return { + btmType:'', + content:'', + urlParams:{}, height:'300px', customClass:this.componentVO.customClass, //bs=?type=xxx&context=yyy¶m=zzz 鎴栬�� bs=缁勪欢name?type=xxx&context=yyy¶m=zzz isError:false, //璺緞瑙f瀽澶辫触 @@ -73,46 +76,45 @@ } }, computed:{ - customOptions() { - if(this.customClass.indexOf("bs=") <0){ - this.isError=true; - return ; - } - this.customClass=this.componentVO.customClass.split("bs=")[1]; - if(this.customClass.indexOf("?") <0 || this.customClass.indexOf("type=") <0 || this.customClass.indexOf("context=") <0){ - this.isError=true; - return ; - } - if(this.customClass.split('?')[0]!='' && this.customClass.split('?')[0]!='UI' && this.customClass.split('?')[0]!='ui'){ - this.currentComponent=this.customClass.split('?')[0]; - } - this.customClass=this.componentVO.customClass.split("?")[1].split('&'); - let urlParams={}; - let btmType='' - let content='' - this.customClass.forEach(item=>{ - var preParam =item.split("="); - if(preParam[0]=='type'){ - btmType=preParam[1]; - }else if(preParam[0]=='context'){ - content=preParam[1]; - }else{ - urlParams[preParam[0]] = preParam[1]; - } - }) - return { - btmType:btmType, - content:content, - paramVOS:Object.assign(this.paramVOS,urlParams) - } - } }, created() { }, mounted() { + if(this.customClass.indexOf("bs=") <0){ + this.isError=true; + return ; + } + this.customClass=this.componentVO.customClass.split("bs=")[1]; + if(this.customClass.indexOf("?") <0 || this.customClass.indexOf("type=") <0 || this.customClass.indexOf("context=") <0){ + this.isError=true; + return ; + } + if(this.customClass.split('?')[0]!='' && this.customClass.split('?')[0]!='UI' && this.customClass.split('?')[0]!='ui'){ + this.currentComponent=this.customClass.split('?')[0]; + } + this.customClass=this.componentVO.customClass.split("?")[1].split('&'); + let urlParams={}; + let btmType='' + let content='' + this.customClass.forEach(item=>{ + var preParam =item.split("="); + if(preParam[0]=='type'){ + btmType=preParam[1]; + }else if(preParam[0]=='context'){ + content=preParam[1]; + }else{ + urlParams[preParam[0]] = preParam[1]; + } + }) + + + this.btmType=btmType, + this.content=content, + this.urlParams=Object.assign(this.paramVOS,urlParams) + //this.getHeight(this.$parent); - }, + }, methods:{ getHeight(el){ if(el.$el.clientHeight>50){ diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue index b2e6561..16d531f 100644 --- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue +++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue @@ -557,9 +557,6 @@ selectChange(row) { this.selectList = row; }, - TreeSelectChange(row) { - this.TreeSelectList = row; - }, searchChange(form,done){ console.log(form) done() diff --git a/Source/ProjectWeb/src/components/file/list.vue b/Source/ProjectWeb/src/components/file/list.vue new file mode 100644 index 0000000..1fee2bb --- /dev/null +++ b/Source/ProjectWeb/src/components/file/list.vue @@ -0,0 +1,162 @@ +<template> + <!--鏂囦欢鍒楄〃--> + <div style="height: 100%"> + <avue-crud ref="dataTable" + v-model="form" + :data="tableList" + :option="option" + :page.sync="pageType" + :table-loading="loading" + @row-click="rowClickChange" + @selection-change="selectChange"> + <!--top鍖哄煙鎸夐挳--> + <template slot="menuLeft" slot-scope="scope"> + <dynamic-button :butttonList="componentVO.buttons" :selectList="selectList" LocationType="top" + type="table"></dynamic-button> + </template> + + <!--menu鍖哄煙鎸夐挳--> + <template slot="menu" slot-scope="scope"> + <dynamic-button :butttonList="componentVO.buttons" :scope="scope" :selectList="selectList" LocationType="menu" + type="table"></dynamic-button> + </template> + </avue-crud> + </div> +</template> + +<script> +import {validatenull} from "@/util/validate"; + +export default { + name: "list", + props: { + componentVO: { + type: Object, + default: {} + }, + inDialog: { + type: Boolean, + default: false + }, + areasName: { + type: String, + default: ''//westArea瀵艰埅鍖� + }, + sourceData: { + //鑿滃崟婧愭暟鎹垨鑰呭脊绐楁椂鎸夐挳鎵�灞炲尯鍩熺殑涓婁竴鍖哄煙閫変腑鏁版嵁 + type: Object, + default: {} + }, + paramVOS: { + type: Object, + default: {} + }, + isShow: { + //鎵�鍦ㄥ尯鍩熸槸鍚﹀凡鏄剧ず锛岄拡瀵箃ab鍜宑ollapse + type: Boolean, + default: true + }, + dataStore: { + //寮圭獥鏃舵寜閽墍灞炲尯鍩熼�変腑鏁版嵁 + type: Array, + default: [] + } + }, + data() { + return { + parentHeight: '100%',//褰撳墠缁勪欢鏍硅妭鐐瑰厓绱犻珮搴� + form: {}, + loading: false, + page: { + pageSize: 10, + currentPage: 1, + total: 50, + }, + simplePage: { + currentPage: 1, + total: 100, + pagerCount: 4, + layout: "prev, pager, next" + }, + //琛ㄦ牸鏁版嵁 + tableList: [], + option: { + index: true, + addBtn: false, + editBtn: false, + delBtn: true, + selection: true, + tip: false, + height: '100%', + calcHeight: 15, + indexFixed: false, + menuFixed: false, + searchMenuSpan: 12, + searchShow: false, + column: [{ + field:'name', + title:'鏂囦欢鍚嶇О', + width:250 + },{ + field:'fileSize', + title:'澶у皬', + width:80, + templet:function(d){ + if(!d.fileSize || d.fileSize == null || d.fileSize*1 == 0 || isNaN(d.fileSize*1) ){ + return "鏈煡澶у皬"; + }else{ + //鍘熷澶у皬鏄疊 + var filesize = d.fileSize*1; + if(filesize>1024*1024*1024*1024){ + return parseInt(filesize/(1024*1024*1024*1024)) + "TB"; + }else if(filesize> 1024*1024*1024){ + return parseInt(filesize/(1024*1024*1024)) + "GB"; + }else if(filesize> 1024*1024){ + return parseInt(filesize/(1024*1024)) + "MB"; + }else if(filesize> 1024){ + return parseInt(filesize/1024) + "KB"; + }else { + return filesize + "B"; + } + } + } + },{ + field:'secretGradeText', + title:'瀵嗙骇', + hidden:(!configData.controlSecret), + width:60 + },{ + field:'fileDocClassifyName', + title:'鏂囨。绫诲瀷', + width:160 + },{ + field:'creator', + title:'涓婁紶浜�/鏃堕棿', + width:210, + templet:function(d){ + return d.creator + "(" + $webUtil.formateDateTimeNoSecond(d.createTime) + ")"; + } + }], + }, + selectList: [], + } + }, + computed: { + pageType() { + return this.areasName === 'westArea' ? this.simplePage : this.page; + } + }, + methods: { + rowClickChange(row) { + this.$refs.dataTable.toggleRowSelection(row); + }, + selectChange(row) { + this.selectList = row; + } + } +} +</script> + +<style scoped> + +</style> diff --git a/Source/ProjectWeb/src/page/index/top/top-menu.vue b/Source/ProjectWeb/src/page/index/top/top-menu.vue index 3add0bf..2749db6 100644 --- a/Source/ProjectWeb/src/page/index/top/top-menu.vue +++ b/Source/ProjectWeb/src/page/index/top/top-menu.vue @@ -54,9 +54,9 @@ this.index.openMenu(item) }, getMenu() { - this.$store.dispatch("GetTopMenu").then(res => { + /*this.$store.dispatch("GetTopMenu").then(res => { this.items = res; - }); + });*/ }, generateTitle(item) { return this.$router.$avueRouter.generateTitle( diff --git a/Source/ProjectWeb/src/page/login/userlogin.vue b/Source/ProjectWeb/src/page/login/userlogin.vue index 77a5801..6ef68e3 100644 --- a/Source/ProjectWeb/src/page/login/userlogin.vue +++ b/Source/ProjectWeb/src/page/login/userlogin.vue @@ -109,15 +109,15 @@ }; }, created() { - this.getTenant(); + // this.getTenant(); }, mounted() { //鍦╩ounted鑾峰彇棣栭〉涓嬫媺鑿滃崟鏁版嵁 - this.$axios.get('/api/blade-system/tenant/tenant-map').then(res=>{ + /*this.$axios.get('/api/blade-system/tenant/tenant-map').then(res=>{ if(res.data.code == 200){ this.loginForm.region=res.data.data } - }) + })*/ }, watch: { 'loginForm.deptId'() { @@ -175,8 +175,8 @@ }); this.$store.dispatch("LoginByUsername", this.loginForm).then(() => { if (this.website.switchMode) { - const deptId = this.userInfo.dept_id; - const roleId = this.userInfo.role_id; + const deptId = this.userInfo.deptOid; + const roleId = this.userInfo.userOid; if (deptId.includes(",") || roleId.includes(",")) { this.loginForm.deptId = deptId; this.loginForm.roleId = roleId; diff --git a/Source/ProjectWeb/src/permission.js b/Source/ProjectWeb/src/permission.js index 8d64cd5..0b8137a 100644 --- a/Source/ProjectWeb/src/permission.js +++ b/Source/ProjectWeb/src/permission.js @@ -1,76 +1,77 @@ -// /** -// * 鍏ㄧ珯鏉冮檺閰嶇疆 -// * -// */ -// import router from './router/router' -// import store from './store' -// import {validatenull} from '@/util/validate' -// import {getToken} from '@/util/auth' -// import NProgress from 'nprogress' // progress bar -// import 'nprogress/nprogress.css' // progress bar style -// NProgress.configure({showSpinner: false}); -// const lockPage = store.getters.website.lockPage; //閿佸睆椤� -// router.beforeEach((to, from, next) => { -// const meta = to.meta || {}; -// const isMenu = meta.menu === undefined ? to.query.menu : meta.menu; -// store.commit('SET_IS_MENU', isMenu === undefined); -// if (getToken()) { -// if (store.getters.isLock && to.path !== lockPage) { //濡傛灉绯荤粺婵�娲婚攣灞忥紝鍏ㄩ儴璺宠浆鍒伴攣灞忛〉 -// next({path: lockPage}) -// } else if (to.path === '/login') { //濡傛灉鐧诲綍鎴愬姛璁块棶鐧诲綍椤佃烦杞埌涓婚〉 -// next({path: '/'}) -// } else { -// //濡傛灉鐢ㄦ埛淇℃伅涓虹┖鍒欒幏鍙栫敤鎴蜂俊鎭紝鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛岃烦杞埌鐧诲綍椤� -// if (store.getters.token.length === 0) { -// store.dispatch('FedLogOut').then(() => { -// next({path: '/login'}) -// }) -// } else { -// const value = to.query.src || to.fullPath; -// const label = to.query.name || to.name; -// const meta = to.meta || router.$avueRouter.meta || {}; -// const i18n = to.query.i18n; -// if (to.query.target) { -// window.open(value) -// } else if (meta.isTab !== false && !validatenull(value) && !validatenull(label)) { -// store.commit('ADD_TAG', { -// label: label, -// value: value, -// params: to.params, -// query: to.query, -// meta: (() => { -// if (!i18n) { -// return meta -// } -// return { -// i18n: i18n -// } -// })(), -// group: router.$avueRouter.group || [] -// }); -// } -// next() -// } -// } -// } else { -// //鍒ゆ柇鏄惁闇�瑕佽璇侊紝娌℃湁鐧诲綍璁块棶鍘荤櫥褰曢〉 -// if (meta.isAuth === false) { -// next() -// } else { -// next('/login') -// } -// } -// }) -// -// router.afterEach(() => { -// NProgress.done(); -// let title = store.getters.tag.label; -// let i18n = store.getters.tag.meta.i18n; -// title = router.$avueRouter.generateTitle(title, i18n); -// //鍒ゆ柇鐧诲綍椤电殑鎯呭喌 -// if (router.history.current.fullPath === "/login") { -// title = "鐧诲綍"; -// } -// //鏍规嵁褰撳墠鐨勬爣绛句篃鑾峰彇label鐨勫�煎姩鎬佽缃祻瑙堝櫒鏍囬 -// router.$avueRouter.setTitle(title); -// }); + /** + * 鍏ㄧ珯鏉冮檺閰嶇疆 + * + */ + import router from './router/router' + import store from './store' + import {validatenull} from '@/util/validate' + import {getToken} from '@/util/auth' + import NProgress from 'nprogress' // progress bar + import 'nprogress/nprogress.css' // progress bar style + NProgress.configure({showSpinner: false}); + const lockPage = store.getters.website.lockPage; //閿佸睆椤� + router.beforeEach((to, from, next) => { + debugger; + const meta = to.meta || {}; + const isMenu = meta.menu === undefined ? to.query.menu : meta.menu; + store.commit('SET_IS_MENU', isMenu === undefined); + if (getToken()) { + if (store.getters.isLock && to.path !== lockPage) { //濡傛灉绯荤粺婵�娲婚攣灞忥紝鍏ㄩ儴璺宠浆鍒伴攣灞忛〉 + next({path: lockPage}) + } else if (to.path === '/login') { //濡傛灉鐧诲綍鎴愬姛璁块棶鐧诲綍椤佃烦杞埌涓婚〉 + next({path: '/'}) + } else { + //濡傛灉鐢ㄦ埛淇℃伅涓虹┖鍒欒幏鍙栫敤鎴蜂俊鎭紝鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛岃烦杞埌鐧诲綍椤� + if (store.getters.token.length === 0) { + store.dispatch('FedLogOut').then(() => { + next({path: '/login'}) + }) + } else { + const value = to.query.src || to.fullPath; + const label = to.query.name || to.name; + const meta = to.meta || router.$avueRouter.meta || {}; + const i18n = to.query.i18n; + if (to.query.target) { + window.open(value) + } else if (meta.isTab !== false && !validatenull(value) && !validatenull(label)) { + store.commit('ADD_TAG', { + label: label, + value: value, + params: to.params, + query: to.query, + meta: (() => { + if (!i18n) { + return meta + } + return { + i18n: i18n + } + })(), + group: router.$avueRouter.group || [] + }); + } + next() + } + } + } else { + //鍒ゆ柇鏄惁闇�瑕佽璇侊紝娌℃湁鐧诲綍璁块棶鍘荤櫥褰曢〉 + if (meta.isAuth === false) { + next() + } else { + next('/login') + } + } + }) + + router.afterEach(() => { + NProgress.done(); + let title = store.getters.tag.label; + let i18n = store.getters.tag.meta.i18n; + title = router.$avueRouter.generateTitle(title, i18n); + //鍒ゆ柇鐧诲綍椤电殑鎯呭喌 + if (router.history.current.fullPath === "/login") { + title = "鐧诲綍"; + } + //鏍规嵁褰撳墠鐨勬爣绛句篃鑾峰彇label鐨勫�煎姩鎬佽缃祻瑙堝櫒鏍囬 + router.$avueRouter.setTitle(title); + }); diff --git a/Source/ProjectWeb/src/router/avue-router.js b/Source/ProjectWeb/src/router/avue-router.js index 0e68bda..1f5f0a7 100644 --- a/Source/ProjectWeb/src/router/avue-router.js +++ b/Source/ProjectWeb/src/router/avue-router.js @@ -90,8 +90,7 @@ * first: 涓轰簡鍖哄垎澶栫晫 璋冪敤formatRoutes 鍜� 褰撳墠鏂囦欢璋冪敤 formatRoutes */ formatRoutes: function (aMenu = [], first) { - // window.console.log('aMenu') - // window.console.log(aMenu) + debugger; const aRouter = [] // 鑾峰彇鍒板叏灞�閰嶇疆涓殑 props const propsConfig = this.$website.menu.props; @@ -119,7 +118,8 @@ } })(), //鐗规畩澶勭悊缁勪欢 鎵ц瀹岃繖涓� component 涔熷氨鏄簿纭埌鍏蜂綋鐨勬枃浠朵簡 views鏂囦欢澶逛笅闈㈠氨鏄叿浣撶殑椤甸潰浠g爜 - component = 'views' + oMenu.path, + //component = 'views' + oMenu.path, + component = oMenu.path, name = oMenu[propsDefault.label], icon = oMenu[propsDefault.icon], children = oMenu[propsDefault.children], diff --git a/Source/ProjectWeb/src/store/modules/dict.js b/Source/ProjectWeb/src/store/modules/dict.js index 837dbe6..ef3bd98 100644 --- a/Source/ProjectWeb/src/store/modules/dict.js +++ b/Source/ProjectWeb/src/store/modules/dict.js @@ -9,12 +9,12 @@ actions: { FlowRoutes({commit}) { return new Promise((resolve, reject) => { - getDictionary({code: 'flow'}).then(res => { + /*getDictionary({code: 'flow'}).then(res => { commit('SET_FLOW_ROUTES', res.data.data); resolve(); }).catch(error => { reject(error) - }) + })*/ }) }, }, diff --git a/Source/ProjectWeb/src/store/modules/user.js b/Source/ProjectWeb/src/store/modules/user.js index 1bcbe7b..1a65fee 100644 --- a/Source/ProjectWeb/src/store/modules/user.js +++ b/Source/ProjectWeb/src/store/modules/user.js @@ -50,18 +50,19 @@ return new Promise((resolve, reject) => { loginByUsername(userInfo.tenantId, userInfo.deptId, userInfo.roleId, userInfo.username, md5(userInfo.password), userInfo.type, userInfo.key, ).then(res => { const data = res.data; - if (data.error_description) { - Message({ - message: data.error_description, - type: 'error' - }) - } else { - commit('SET_TOKEN', data.access_token); - commit('SET_REFRESH_TOKEN', data.refresh_token); + if(data.success){ + debugger; + commit('SET_TOKEN', data.obj.sessionInfo.token); + commit('SET_REFRESH_TOKEN', data.obj.sessionInfo.token); commit('SET_TENANT_ID', data.tenant_id); - commit('SET_USER_INFO', data); + commit('SET_USER_INFO', data.obj.sessionInfo); commit('DEL_ALL_TAG'); commit('CLEAR_LOCK'); + }else { + Message({ + message: data.msg, + type: 'error' + }) } resolve(); }).catch(error => { @@ -210,7 +211,7 @@ }); commit('SET_MENU_ALL', menu) commit('SET_MENU', menu) - dispatch('GetButtons'); + //dispatch('GetButtons'); resolve(menu) }) }) @@ -228,6 +229,7 @@ }, mutations: { SET_TOKEN: (state, token) => { + debugger; setToken(token); state.token = token; setStore({name: 'token', content: state.token}) diff --git a/Source/ProjectWeb/src/views/fileManage/index.vue b/Source/ProjectWeb/src/views/fileManage/index.vue new file mode 100644 index 0000000..093967c --- /dev/null +++ b/Source/ProjectWeb/src/views/fileManage/index.vue @@ -0,0 +1,16 @@ +<template> + <!--鏂囦粨绠$悊椤甸潰--> + <basic-container> + + </basic-container> +</template> + +<script> +export default { + name: "index" +} +</script> + +<style scoped> + +</style> -- Gitblit v1.9.3