From 96be59a64cc1d8fcaf1034e787717663c68df4a7 Mon Sep 17 00:00:00 2001
From: 杨磊 <505174330@qq.com>
Date: 星期一, 26 五月 2025 10:39:58 +0800
Subject: [PATCH] 2025-5-26提交

---
 src/views/system/roleManage.vue |  384 +++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 289 insertions(+), 95 deletions(-)

diff --git a/src/views/system/roleManage.vue b/src/views/system/roleManage.vue
index d455c20..44f9a7a 100644
--- a/src/views/system/roleManage.vue
+++ b/src/views/system/roleManage.vue
@@ -12,138 +12,319 @@
         </li>
       </ul>
     </div>
-    <div class="list">
-      <div>
-        <el-tree
-          :data="dataList"
-          show-checkbox
-          node-key="id"
-          default-expand-all
-          :props="defaultProps"
-        />
-
+    <div class="content" v-if="tabActive == 'menu'">
+      <div class="list">
+        <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 = () =>{
+const getData = () => {
   let list = [
     {
-      name:'妯″瀷绠$悊',
-      sysType:'cmsFolder',
-      productLinkPath:'111',
-      children:[
+      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: "cmsItem",
+          productLinkPath: "215",
+        },
+        {
+          name: "鍒犻櫎妯″瀷",
+          sysType: "cmsItem",
+          productLinkPath: "216",
+        },
+      ],
     },
     {
-      name:'鍙鍖栦豢鐪�',
-      sysType:'cmsFolder',
-      productLinkPath:'112',
-      children:[
+      name: "鍙鍖栦豢鐪�",
+      sysType: "cmsFolder",
+      productLinkPath: "112",
+      children: [
         {
-          name:'娴嬭瘯浠跨湡',
-          sysType:'cmsFolder',
-          productLinkPath:'221',
-          children:[
+          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>
 
@@ -151,16 +332,29 @@
 .user-manage {
   padding: 20px;
 }
-.tabs{
-  li{
-    width:140px;
+.tabs {
+  li {
+    width: 140px;
     text-align: center;
     padding: 5px 0;
-    margin:0 15px;
+    margin: 0 15px;
     cursor: pointer;
   }
-  .activeItem{
-    border-bottom:2px solid #1890ff;
+  .activeItem {
+    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>

--
Gitblit v1.9.1