diff --git a/src/views/settings/section.vue b/src/views/settings/section.vue
index d609c1d..acb2e35 100644
--- a/src/views/settings/section.vue
+++ b/src/views/settings/section.vue
@@ -12,8 +12,8 @@
-
+
+
@@ -72,7 +72,6 @@ import {post} from "@/utils/request.ts";
import deptsObj from '@/assets/config/directory/depts.json'
import {formatDate} from '@/utils/dateUtils.ts'
-import depts from "@/assets/config/directory/depts.json";
import {Plus} from "@element-plus/icons-vue";
const id = ref("")
@@ -112,32 +111,33 @@ const pageSize = ref(20);
const page = ref(1);
const total = ref(0);
const search = ref({})
-const options = Object.entries(depts).map(([key, value]) => {
- if (typeof value === 'string') {
- return {value: key, label: value};
- } else {
- return {
- value: key,
- label: value.name,
- children: Object.entries(value.children).map(([childKey, childValue]) => ({
- value: childKey,
- label: childValue,
- })),
- };
- }
-});
+
const resetSearch = () => {
search.value = {}
init()
}
-// 修改 depts 的类型定义,允许字符串索引
-interface DeptMap {
- [key: string]: string | { name: string; children?: { [key: string]: string } };
+// 在 script setup 中添加如下类型定义
+interface DeptChildren {
+ [key: string]: string;
}
+
+interface DeptItem {
+ name: string;
+ children?: DeptChildren;
+}
+
+type DeptsType = {
+ [key: string]: string | DeptItem;
+};
+
+// 将 depts 类型显式声明为 DeptsType
+const depts: DeptsType = deptsObj;
+
+// 修改 getDeptDisplayName 函数中的类型引用
const getDeptDisplayName = (code: string): string => {
if (!code) return '未知科室'
- const dept = (depts as DeptMap)[code]
+ const dept = depts[code]
// 如果是一级科室,并且是字符串类型
if (typeof dept === 'string') {
@@ -151,7 +151,7 @@ const getDeptDisplayName = (code: string): string => {
// 如果是二级科室,尝试查找父级下的 value
for (const key in depts) {
- const parentDept = depts[key]
+ const parentDept = depts[key] as DeptItem; // 类型断言确保类型正确
if (
typeof parentDept === 'object' &&
parentDept !== null &&