Przeglądaj źródła

feat: 修改用户

DESKTOP-USV654P\pc 1 rok temu
rodzic
commit
55983f5ef0

+ 5 - 0
apps/web-baicai/src/api/system/department.ts

@@ -1,3 +1,5 @@
+import type { BasicTreeOptionResult } from '../model';
+
 import { requestClient } from '#/api/request';
 
 export namespace DepartmentApi {
@@ -26,6 +28,9 @@ export namespace DepartmentApi {
       params: { id },
     });
 
+  export const getTreeOptions = () =>
+    requestClient.get<BasicTreeOptionResult[]>('/department/tree-options');
+
   export const addDetail = (data: BasicRecordItem) =>
     requestClient.post('/department', data);
 

+ 6 - 0
apps/web-baicai/src/api/system/post.ts

@@ -1,5 +1,6 @@
 import type {
   BasicFetchResult,
+  BasicOptionResult,
   BasicPageParams,
   StatusParams,
 } from '#/api/model';
@@ -31,6 +32,11 @@ export namespace PostApi {
       params: { id },
     });
 
+  export const getOptions = (id: number) =>
+    requestClient.get<BasicOptionResult[]>('/post/options', {
+      params: { id },
+    });
+
   export const addDetail = (data: BasicRecordItem) =>
     requestClient.post('/post', data);
 

+ 9 - 4
apps/web-baicai/src/components/form/components/api-select.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import type { SelectValue } from 'ant-design-vue/es/select';
+import type { DefaultOptionType, SelectValue } from 'ant-design-vue/es/select';
 
 import type { ApiConfig } from '../types';
 
@@ -70,7 +70,7 @@ const getOptions = computed(() => {
       disabled: item.disabled || false,
     });
   });
-  return res;
+  return res as DefaultOptionType[];
 });
 
 const emitChange = () => {
@@ -105,8 +105,13 @@ const handleFetch = async () => {
 const handelFilterOption = (input: string, option: any) => {
   const { fieldNames } = props;
   return (
-    option[fieldNames.value].toLowerCase().includes(input.toLowerCase()) ||
-    option[fieldNames.label].toLowerCase().includes(input.toLowerCase())
+    `${option[fieldNames.value]}`
+      .toLowerCase()
+      .includes(`${input}`.toLowerCase()) ||
+    option[fieldNames.label]
+      .toString()
+      .toLowerCase()
+      .includes(input.toLowerCase())
   );
 };
 

+ 2 - 4
apps/web-baicai/src/components/form/components/api-tree-select.vue

@@ -1,5 +1,4 @@
 <script setup lang="ts">
-import type { Recordable } from '@vben/types';
 import type { SelectValue } from 'ant-design-vue/es/select';
 
 import type { ApiConfig } from '../types';
@@ -53,7 +52,7 @@ const modelValue = useVModel(props, 'value', emit, {
   defaultValue: props.value,
   passive: true,
 });
-const treeData = ref<Recordable<any>[]>([]);
+const treeData = ref<Record<string, any>[]>([]);
 const loading = ref(false);
 const isFirstLoad = ref(true);
 const getTreeData = computed(() => {
@@ -71,7 +70,7 @@ const fetch = async () => {
     loading.value = true;
     const res = await api(props.api.params);
     if (Array.isArray(res)) {
-      treeData.value = (res as Recordable<any>[]) || [];
+      treeData.value = res || [];
     } else {
       treeData.value = props.api.result ? get(res, props.api.result) : [];
     }
@@ -108,7 +107,6 @@ watch(
     :show-search="showSearch"
     :tree-data="getTreeData"
     :tree-node-filter-prop="fieldNames.label"
-    v-bind="$attrs"
     class="w-full"
     @dropdown-visible-change="handleFetch"
   >

+ 40 - 10
apps/web-baicai/src/views/system/user/data.config.ts

@@ -1,7 +1,7 @@
 import type { VbenFormProps } from '#/adapter/form';
 import type { VxeGridProps } from '#/adapter/vxe-table';
 
-import { EnumApi, UserApi } from '#/api';
+import { DepartmentApi, EnumApi, PostApi, UserApi } from '#/api';
 import { formatterStatus } from '#/api/model';
 
 export const searchFormOptions: VbenFormProps = {
@@ -73,15 +73,6 @@ export const formOptions: VbenFormProps = {
     },
   },
   schema: [
-    {
-      component: 'Input',
-      componentProps: {
-        placeholder: '请输入组织',
-      },
-      fieldName: 'departmentId',
-      label: '组织',
-      rules: 'required',
-    },
     {
       component: 'Input',
       componentProps: {
@@ -162,6 +153,45 @@ export const formOptions: VbenFormProps = {
       label: '备注',
       formItemClass: 'col-span-2 items-baseline',
     },
+    {
+      fieldName: 'otherinfo',
+      label: '其他信息',
+      component: 'Divider',
+      formItemClass: 'col-span-2 items-baseline',
+      hideLabel: true,
+      renderComponentContent: () => {
+        return {
+          default: () => {
+            return '其他信息';
+          },
+        };
+      },
+    },
+    {
+      component: 'ApiTreeSelect',
+      componentProps: {
+        placeholder: '请输入组织',
+        api: {
+          url: DepartmentApi.getTreeOptions,
+        },
+        showSearch: true,
+      },
+      fieldName: 'departmentId',
+      label: '组织',
+      rules: 'required',
+    },
+    {
+      component: 'ApiSelect',
+      componentProps: {
+        placeholder: '请输入职位',
+        api: {
+          url: PostApi.getOptions,
+        },
+        showSearch: true,
+      },
+      fieldName: 'postId',
+      label: '职位',
+    },
   ],
   wrapperClass: 'grid-cols-2',
 };