// 用户权限 import { useRoute } from 'vue-router'; import { GetUserLimit } from "@/apis/user"; // const testData = { // "sysType": "MA==", // "userId": "NTMwMw==", // "type": "eXc=" // } //userId=NTMwMw==&sysType=W29iamVjdCBPYmplY3Rd&digitalTwainType=eXM= // const res ={ // data:{ // Rows:[ // { // "id": "6291", // "name": "数字孪生", // "parentId": "0" // }, // { // "id": "6602", // "name": "数字孪生业务版", // "parentId": "6291" // }, // { // "id": "8445", // "name": "航道疏浚", // "parentId": "6602" // }, // { // "id": "8446", // "name": "图层", // "parentId": "6602" // }, // { // "id": "8441", // "name": "水上客运", // "parentId": "6602" // }, // { // "id": "8442", // "name": "交通安全", // "parentId": "6602" // }, // { // "id": "8443", // "name": "卡口监控", // "parentId": "6602" // }, // { // "id": "8444", // "name": "运营监管", // "parentId": "6602" // }, // { // "id": "8461", // "name": "锚地", // "parentId": "8446" // }, // { // "id": "8462", // "name": "掉头区", // "parentId": "8446" // }, // { // "id": "8466", // "name": "水下地形", // "parentId": "8446" // }, // { // "id": "8464", // "name": "水上绿色综合服务区", // "parentId": "8446" // }, // { // "id": "8465", // "name": "航标", // "parentId": "8446" // }, // { // "id": "8453", // "name": "船舶", // "parentId": "8446" // }, // { // "id": "8454", // "name": "视频融合", // "parentId": "8446" // }, // { // "id": "8455", // "name": "码头泊位", // "parentId": "8446" // }, // { // "id": "8456", // "name": "客运码头", // "parentId": "8446" // }, // { // "id": "8458", // "name": "两岸精模", // "parentId": "8446" // }, // { // "id": "8459", // "name": "两岸白模", // "parentId": "8446" // }, // { // "id": "8460", // "name": "航道", // "parentId": "8446" // }, // { // "id": "8463", // "name": "警戒区", // "parentId": "8446" // }, // ] // } // } /** * @params nameList-按钮列表 */ export function GetUserPrivilege(nameList) { let userData = useRoute().query // console.log(userData) if(userData.digitalTwainType){ userData.type = userData.digitalTwainType delete userData.digitalTwainType } // userData.sysType = "MA==" // console.log(userData) GetUserLimit(userData).then((res) => { console.log(res) let parentId = [] let limitArr = [] res.data.Rows.forEach((item) => { if (item.name.includes('数字孪生业务版') || item.name.includes('数字孪生演示版')) { res.data.Rows.forEach((item) => { parentId.push(item.id) }) // console.log(parentId) } if (parentId.includes(item.parentId)) { limitArr.push(item.name) // console.log(limitArr) } }) nameList.data = nameList.data.filter((item) => { if (limitArr.includes(item.name)) { // console.log(nameList) return true } }) }) }