杨磊
2025-05-26 96be59a64cc1d8fcaf1034e787717663c68df4a7
src/views/system/roleManage.vue
@@ -12,138 +12,319 @@
        </li>
      </ul>
    </div>
    <div class="content" v-if="tabActive == 'menu'">
    <div class="list">
      <div>
        <el-tree
          :data="dataList"
          show-checkbox
          node-key="id"
          default-expand-all
          :props="defaultProps"
        <div class="firstLvBox">
          <el-checkbox
            v-model="checkObject.modelManagement"
            label="模型管理"
            size="large"
        />
      </div>
        <div class="secondLvBox">
          <el-checkbox
            v-model="checkObject.newModelAdded"
            label="新增型号"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.editType"
            label="编辑型号"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.deleteType"
            label="删除型号"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.addNewModel"
            label="新增模型"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.editModel"
            label="编辑模型"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.deleteModel"
            label="删除模型"
            size="large"
          />
        </div>
        <div class="firstLvBox">
          <el-checkbox
            v-model="checkObject.visualSimulation"
            label="可视化仿真"
            size="large"
          />
        </div>
        <div class="secondLvBox">
          <el-checkbox
            v-model="checkObject.testSimulation"
            label="测试仿真"
            size="large"
          />
        </div>
        <div class="thirdlyLvBox">
          <el-checkbox
            v-model="checkObject.modelRetrieval"
            label="模型检索"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.modelPreview"
            label="模型预览"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.viewModelProperties"
            label="模型属性查看"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.modelSimulation"
            label="模型仿真"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.testReport"
            label="测试报告"
            size="large"
          />
        </div>
      </div>
      <div>
        <el-button type="primary" @click="updateRightConfigFun">保存</el-button>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { ref, onMounted, watch, inject, reactive } from "vue";
const checked1 = ref(false);
const tabList = ref([
  {
    lable:'菜单/功能访问权限',
    value:'menu'
    lable: "菜单/功能访问权限",
    value: "menu",
  },
  {
    lable:'模型访问权限',
    value:'model'
  }
])
const tabActive = ref('menu')
const dataList = ref([])
    lable: "模型访问权限",
    value: "model",
  },
]);
const tabActive = ref("menu");
const dataList = ref([]);
import { curStoreInfo } from "@/store/index";
const seleStore = curStoreInfo();
import { useUserStore } from "@/store/index";
import { ElMessage } from "element-plus";
const checkObject = reactive({
  newModelAdded: false,
  editType: false,
  deleteType: false,
  addNewModel: false,
  editModel: false,
  deleteModel: false,
  testSimulation: false,
  modelRetrieval: false,
  modelPreview: false,
  visualSimulation: false,
  viewModelProperties: false,
  modelSimulation: false,
  testReport: false,
  modelManagement: false,
});
const curRoleConfig = ref(null);
const userStore = useUserStore();
import emitter from "../eventBus.js";
onMounted(() => {
  getData();
});
const MG: any = inject("MG");
const config: any = inject("config");
watch(
  () => seleStore.curSelectRole,
  (newRoute) => {
    if (newRoute) {
      console.log(newRoute, "curSelectRole");
      getRoleRightList();
    }
  },
  { deep: true }
);
const saveConfig = async () => {
  const body = {
    appId: config.appId,
    name: seleStore.curSelectRole?.name,
    description: seleStore.curSelectRole?.description,
    icon: "",
    type: "Normal",
    state: "Normal",
    scope: config.appId + "",
    domain: "roleRights",
    control: true,
    edit: true,
    read: true,
    view: true,
    ban: true,
    beginDate: "2023-08-30T09:09:23.367Z",
    endDate: "2023-08-30T09:09:23.367Z",
    configDomain: "roleRights",
    configScope: config.appId + "",
    config: "[]",
    orgIds: [seleStore.OrgInfo.id],
    departmentIds: [],
    userIds: [userStore.userInfo?.id],
    roleIds: [seleStore.curSelectRole?.id],
  };
  const res = await MG.dps5.NewRightsConfig(body);
  console.log(res, "NewRightsConfig");
  return res;
};
const updateRightConfigFun = async () => {
  let configId = null;
  if (curRoleConfig) {
    configId = await saveConfig();
  }
  const body = {
    config: JSON.stringify(checkObject),
    configDomain: "roleRights",
    configId: configId ? configId : curRoleConfig.value.configId,
    configScope: config.appId + "",
  };
  const res = await MG.dps5.UpdateRightsConfig(body);
  emitter.emit("refreshTree");
  if (res) {
    ElMessage({
      message: "权限编辑成功",
      type: "success",
    });
  }
};
const getRoleRightList = async () => {
  const body = {
    appId: config.appId,
    roleId: seleStore.curSelectRole.id,
  };
  let res = await MG.dps5.GetRoleRightsConfigList(body);
  if (res && res.length > 0) {
    curRoleConfig.value = res[0];
    const config = JSON.parse(res[0].configDto.config);
    if (config instanceof Array) {
      for (let key in checkObject) {
        checkObject[key] = false;
      }
    } else {
      for (let key in config) {
        checkObject[key] = config[key];
      }
    }
  }
};
const defaultProps = {
  children: 'children',
  label: 'name',
}
  children: "children",
  label: "name",
};
const getData = () =>{
  let list = [
    {
      name:'模型管理',
      sysType:'cmsFolder',
      productLinkPath:'111',
      name: "模型管理",
      sysType: "cmsFolder",
      productLinkPath: "111",
      children:[
        {
          name:'新增型号',
          sysType:'cmsItem',
          productLinkPath:'211',
          name: "新增型号",
          sysType: "cmsItem",
          productLinkPath: "211",
        },
        {
          name:'编辑型号',
          sysType:'cmsItem',
          productLinkPath:'212',
          name: "编辑型号",
          sysType: "cmsItem",
          productLinkPath: "212",
        },
        {
          name:'删除型号',
          sysType:'cmsItem',
          productLinkPath:'213',
          name: "删除型号",
          sysType: "cmsItem",
          productLinkPath: "213",
        },
        {
          name:'新增模型',
          sysType:'cmsItem',
          productLinkPath:'214',
        },{
          name:'删除模型',
          sysType:'cmsItem',
          productLinkPath:'215',
        },{
          name:'删除模型',
          sysType:'cmsItem',
          productLinkPath:'216',
        }
      ]
          name: "新增模型",
          sysType: "cmsItem",
          productLinkPath: "214",
    },
    {
      name:'可视化仿真',
      sysType:'cmsFolder',
      productLinkPath:'112',
          name: "删除模型",
          sysType: "cmsItem",
          productLinkPath: "215",
        },
        {
          name: "删除模型",
          sysType: "cmsItem",
          productLinkPath: "216",
        },
      ],
    },
    {
      name: "可视化仿真",
      sysType: "cmsFolder",
      productLinkPath: "112",
      children:[
        {
          name:'测试仿真',
          sysType:'cmsFolder',
          productLinkPath:'221',
          name: "测试仿真",
          sysType: "cmsFolder",
          productLinkPath: "221",
          children:[
            {
              name:'检索模型',
              sysType:'cmsItem',
              productLinkPath:'231',
              name: "检索模型",
              sysType: "cmsItem",
              productLinkPath: "231",
            },
            {
              name:'模型预览',
              sysType:'cmsItem',
              productLinkPath:'232',
              name: "模型预览",
              sysType: "cmsItem",
              productLinkPath: "232",
            },
            {
              name:'模型属性查看',
              sysType:'cmsItem',
              productLinkPath:'233',
              name: "模型属性查看",
              sysType: "cmsItem",
              productLinkPath: "233",
            },
            {
              name:'模型仿真',
              sysType:'cmsItem',
              productLinkPath:'234',
              name: "模型仿真",
              sysType: "cmsItem",
              productLinkPath: "234",
            },
            {
              name:'测试报告',
              sysType:'cmsItem',
              productLinkPath:'235',
              name: "测试报告",
              sysType: "cmsItem",
              productLinkPath: "235",
            },
          ]
          ],
        },
        {
          name:'测试报告',
          sysType:'cmsFolder',
          productLinkPath:'221',
          name: "测试报告",
          sysType: "cmsFolder",
          productLinkPath: "221",
        },
      ]
    }
  ]
  dataList.value = list
}
      ],
    },
  ];
  dataList.value = list;
};
const handleClick = (item) => {
  tabActive.value = item.value
  tabActive.value = item.value;
};
</script>
@@ -163,4 +344,17 @@
    border-bottom:2px solid #1890ff;
  }
}
.list {
  margin-top: 20px;
}
.secondLvBox {
  margin-left: 20px;
}
.thirdlyLvBox {
  margin-left: 40px;
}
.content {
  display: flex;
  justify-content: space-between;
}
</style>