| | |
| | | </template> |
| | | |
| | | <script> |
| | | //import io from 'socket.io-client'; |
| | | export default { |
| | | data() { |
| | | return { |
| | | socket: null, |
| | | userType: 'admin', |
| | | form: { |
| | | user: "admin", |
| | | password: "123456", |
| | | user: "", |
| | | password: "", |
| | | autologin: false |
| | | }, |
| | | rules: { |
| | |
| | | grant_type: "password", |
| | | scope: "all" |
| | | } |
| | | var isToken = false; |
| | | await this.$HTTP.postJ("/api/blade-auth/oauth/token?" + this.$TOOL.qsStringify(data)).then(res => { |
| | | this.islogin = false; |
| | | if (res.user_id) { |
| | | isToken = true; |
| | | //获取token |
| | | this.$TOOL.cookie.set("TOKEN", res.access_token, { |
| | | expires: this.form.autologin ? 24 * 60 * 60 : 0 |
| | |
| | | res.dashboard = "0"; |
| | | res.userId = "1"; |
| | | this.$TOOL.data.set("USER_INFO", res); |
| | | this.islogin = false; |
| | | } else { |
| | | this.$message({ |
| | | showClose: true, |
| | | message: res.error_description, |
| | | message: res.msg || res.error_description, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | }) |
| | | if (!isToken) return; |
| | | //获取菜单 |
| | | await this.$HTTP.get("/api/blade-system/menu/routes?" + this.$TOOL.qsStringify({ "appCode": "CPS" })).then(res => { |
| | | if (res.data.length == 0) { |
| | |
| | | // 如果没有 children 属性,说明是最后一级,添加 component 对象 |
| | | var len = clonedItem.path.length; |
| | | if (item.name == "任务调度") { |
| | | //clonedItem.component = clonedItem.path; //有component不可以使用iframe |
| | | clonedItem.origin = item.path; |
| | | clonedItem.component = "myiframe/urlPath"; //有component不可以使用iframe |
| | | clonedItem.path = "/myiframe/urlPath"; |
| | | } else { |
| | | clonedItem.component = clonedItem.path.substring(1, len); |
| | | } |
| | | } |
| | | if (item.name == "任务调度") { |
| | | clonedItem.meta = { title: clonedItem.name, icon: "el-icon-takeaway-box", type: "iframe" } |
| | | } else { |
| | | clonedItem.meta = { title: clonedItem.name, icon: "el-icon-takeaway-box", type: "menu" } |
| | | } |
| | | clonedItem.meta = { title: clonedItem.name, icon: "el-icon-takeaway-box", type: "menu" } |
| | | return clonedItem; |
| | | }); |
| | | } |
| | |
| | | //获取多个工作台 |
| | | this.$HTTP.get("/api/blade-system/workbench/list?status=1").then(resp => { |
| | | if (resp.data.length) { |
| | | //console.log(resp.data,resp.data[0].name,333); |
| | | resp.data.forEach((item, index) => { |
| | | item.component = "home"; |
| | | item.meta = { title: item.name, icon: 'el-icon-menu', affix: true }; |
| | | item.path = "/dashboard"; |
| | | item.parentId = item.id; |
| | | }) |
| | | transformedArray[0].path = "/home"; |
| | | transformedArray[0].children = resp.data; |
| | | transformedArray.unshift({ |
| | | children: resp.data, |
| | | code: "desk", |
| | | component: "console/desk", |
| | | id: "001", |
| | | meta: {title: '首页', icon: 'el-icon-takeaway-box', type: 'menu'}, |
| | | name: "首页", |
| | | path: "/home" |
| | | }); |
| | | transformedArray.forEach((item,index)=>{ |
| | | if(item.name == "仪表板") { |
| | | transformedArray.splice(1,index); |
| | | } |
| | | }) |
| | | var obj = { |
| | | dashboardGrid: ["welcome", "ver", "time", "progress", "echarts", "about"], |
| | | dashboardGrid: ["Access", "deskNotice", "Entrance"], |
| | | menu: transformedArray, |
| | | permissions: ["list.add", "list.edit", "list.delete", "user.add", "user.edit", "user.delete"] |
| | | } |
| | | this.$TOOL.data.set("MENU", obj.menu) |
| | | this.$TOOL.data.set("MENU", obj.menu); |
| | | console.log(obj.menu, 'menu') |
| | | this.$TOOL.data.set("PERMISSIONS", obj.permissions) |
| | | this.$TOOL.data.set("DASHBOARDGRID", obj.dashboardGrid) |
| | | console.log(transformedArray, 222) |
| | | |
| | | this.$router.replace({ |
| | | path: '/' |