Explorar o código

修改权限分享组织树

wangfumin hai 1 mes
pai
achega
936774d16c
Modificáronse 1 ficheiros con 23 adicións e 37 borrados
  1. 23 37
      src/view/case/sceneShare.vue

+ 23 - 37
src/view/case/sceneShare.vue

@@ -2,14 +2,18 @@
   <div class="scene-share">
     <el-form label-width="160px">
       <el-form-item label="上级组织共享权限">
-        <el-cascader
+        <el-select
           class="org-picker"
-          :modelValue="superiorValue"
-          @update:modelValue="(val: string[]) => updateSuperiorValue(val)"
-          :options="organTrees"
-          :props="{ checkStrictly: true, label: 'name', value: 'id' }"
+          v-model="selectedParentId"
           placeholder="上级组织名称"
-        />
+        >
+          <el-option
+            v-for="item in organTrees"
+            :key="item.id"
+            :label="item.name"
+            :value="item.id"
+          />
+        </el-select>
       </el-form-item>
 
       <el-form-item label="权限">
@@ -26,10 +30,12 @@
 
 <script setup lang="ts">
 import { computed, onMounted, ref } from 'vue';
-import { Organization, getOrganizationTree } from '@/store/organization';
+import { Organization } from '@/store/organization';
 import { QuiskExpose } from '@/helper/mount';
 import { axios } from '@/request';
-import { sceneDeptShare, shareAuthList } from '@/request/urls';
+import { sceneDeptShare, shareAuthList, getHigherLevelDept } from '@/request/urls';
+import { ElMessage } from "element-plus";
+import { user } from "@/store/user";
 
 const props = defineProps<{ num?: string; isObj?: number; caseId?: number; fusionId?: number }>();
 
@@ -40,36 +46,12 @@ const selectedParentId = ref<string>('');
 // 权限:0 不共享;1 查看;2 编辑
 const isAuth = ref<number>(0);
 
-// 根据 id 计算级联选中路径
-const queryPathById = (
-  id: string,
-  current: Organization[]
-): string[] | null => {
-  for (const item of current) {
-    if (item.id === id) {
-      return [item.id];
-    } else if (item.children) {
-      const cItem = queryPathById(id, item.children);
-      if (cItem) {
-        return [item.id, ...cItem];
-      }
-    }
-  }
-  return null;
-};
-
-const superiorValue = computed(() => {
-  return selectedParentId.value
-    ? queryPathById(selectedParentId.value, organTrees.value) || []
-    : [];
-});
-
-const updateSuperiorValue = (value: string[]) => {
-  selectedParentId.value = value[value.length - 1];
-};
-
 defineExpose<QuiskExpose>({
   async submit() {
+    if(!selectedParentId.value) {
+      ElMessage.error('请选择上级组织');
+      return;
+    }
     const payload: any = {
       deptId: selectedParentId.value,
       isAuth: isAuth.value,
@@ -89,7 +71,11 @@ defineExpose<QuiskExpose>({
 
 onMounted(async () => {
   // 仅加载组织树,前端不做禁用控制,后端负责校验
-  organTrees.value = await getOrganizationTree('1');
+  // organTrees.value = await getOrganizationTree('1');
+  const deptId = user.value.info.deptId;
+  const treeRes = await axios.get(getHigherLevelDept, { params: { deptId } });
+  organTrees.value = treeRes.data as any;
+
   // 预取已设置的共享权限并回显(支持 num/isObj 或 caseId)
   try {
     let params = {}