Browse Source

fix:修改表单设计人员选择组件,学生时增加班级树

zcuishan 4 months ago
parent
commit
1ab0ef7c9f

+ 1 - 1
src/components/Designer/src/types/index.ts

@@ -968,7 +968,7 @@ export const infoComponents = [
       span: '',
       width: '100%',
       defaultValue: '',
-      userType:'',
+      userType:0,
       placeholder: t('请选择人员'),
       prefix: '',
       suffix: 'ant-design:setting-outlined',

+ 56 - 9
src/components/SelectOrganizational/src/SelectUser.vue

@@ -10,7 +10,20 @@
       @close="close"
     >
       <template #left>
-        <OrganizationalTree @select="handleSelect" />
+        <OrganizationalTree v-if="userType !== 3" @select="handleSelect" />
+        <div v-else style="overflow-y: scroll">
+          <BasicTree
+            expandOnSearch
+            :expanded-keys="treeExpandedKeys"
+            :auto-expand-parent="autoExpandParent"
+            @expand="onExpand"
+            title="班级列表"
+            :fieldNames="{ title: 'name', key: 'id' }"
+            search
+            :treeData="treeData"
+            @select="handleTreeSelect"
+          />
+        </div>
       </template>
       <!-- 已选 -->
       <Selected
@@ -28,7 +41,7 @@
       <div class="list-page-box" v-if="data.visible && data.list.length > 0">
         <UserCard
           :class="data.selectedIds.includes(item.id) ? 'picked' : 'not-picked'"
-          :disabled="props.disabledIds && props.disabledIds.includes(item.id) ? true : false"
+          :disabled="props.disabledIds && props.disabledIds.includes(item.id)"
           v-for="(item, index) in data.list"
           :key="index"
           :item="item"
@@ -62,10 +75,11 @@
   import { UserInfo } from '/@/api/system/user/model';
   import { cloneDeep } from 'lodash-es';
   import { useI18n } from '/@/hooks/web/useI18n';
-  import { useUserStore } from '/@/store/modules/user';
+  import { getStudentmanagerMajorGradeClassTree } from '/@/services/apis/StudentManagerController';
+  import BasicTree from '/@/components/Tree/src/Tree.vue';
   const { t } = useI18n();
-  const defaultSelectName = ref('');
-
+  const treeExpandedKeys = ref<any[]>([]);
+  const autoExpandParent = ref(true);
   const emits = defineEmits(['change', 'changeNames', 'close']);
   const props = withDefaults(
     defineProps<{
@@ -73,7 +87,7 @@
       disabledIds?: Array<string>;
       multiple?: Boolean;
       visible?: Boolean;
-      userType?: string;
+      userType?: Number;
     }>(),
     {
       selectedIds: () => {
@@ -84,6 +98,7 @@
       },
     },
   );
+  const treeData = ref<any[]>([]);
   let data: {
     visible: boolean;
     multiSelect: boolean;
@@ -94,6 +109,7 @@
     searchConfig: {
       keyword: string;
       deptId: string;
+      classId: string;
     };
   } = reactive({
     visible: false,
@@ -113,11 +129,14 @@
   });
 
   const paramRef = computed(() => {
+    console.log(data.searchConfig);
+
     return {
       limit: data.page.current,
       size: data.page.pageSize,
       departmentId: data.searchConfig.deptId,
       keyword: data.searchConfig.keyword,
+      classId: data.searchConfig.classId,
       userType: props.userType,
     };
   });
@@ -129,12 +148,36 @@
     },
   );
 
-  onMounted(() => {
+  onMounted(async () => {
     if (props.selectedIds && Array.isArray(props.selectedIds)) {
       data.selectedIds = cloneDeep(props.selectedIds);
-      getSelectedList();
+      await getSelectedList();
+    }
+    if (props.userType === 3) {
+      treeData.value = await getStudentmanagerMajorGradeClassTree({});
+      console.log(treeData.value);
     }
   });
+  const onExpand = (keys: string[]) => {
+    treeExpandedKeys.value = keys;
+    autoExpandParent.value = false;
+  };
+  function handleTreeSelect(e, { node }) {
+    console.log(node);
+    if (node.treeType !== 4) {
+      treeExpandedKeys.value = e;
+      autoExpandParent.value = true;
+      if (node.expanded) {
+        console.log(node);
+        treeExpandedKeys.value = [node.parentId];
+      }
+      return false;
+    }
+    data.page.current = 1;
+    data.searchConfig.classId = e[0];
+    data.searchConfig.keyword = '';
+    getList();
+  }
   async function show() {
     data.selectedIds = [];
     data.selectedList = [];
@@ -233,7 +276,11 @@
   }
   function handleSelect(deptId = '') {
     data.page.current = 1;
-    data.searchConfig.deptId = deptId;
+    if (props.userType === 3) {
+      data.searchConfig.classId = deptId[0];
+    } else {
+      data.searchConfig.deptId = deptId;
+    }
     data.searchConfig.keyword = '';
     getList();
   }