dev
This commit is contained in:
parent
c2b791e784
commit
c76999b3d3
|
|
@ -12,8 +12,8 @@
|
||||||
<el-input v-model="search.resperName" placeholder="负责人姓名" style="width: 200px"></el-input>
|
<el-input v-model="search.resperName" placeholder="负责人姓名" style="width: 200px"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-cascader :props="{ checkStrictly: true }" v-model="search.caty" :options="options"
|
<!-- <el-cascader :props="{ checkStrictly: true }" v-model="search.caty" :options="options"-->
|
||||||
placeholder="科室类别"/>
|
<!-- placeholder="科室类别"/>-->
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -72,7 +72,6 @@ import {post} from "@/utils/request.ts";
|
||||||
import deptsObj from '@/assets/config/directory/depts.json'
|
import deptsObj from '@/assets/config/directory/depts.json'
|
||||||
|
|
||||||
import {formatDate} from '@/utils/dateUtils.ts'
|
import {formatDate} from '@/utils/dateUtils.ts'
|
||||||
import depts from "@/assets/config/directory/depts.json";
|
|
||||||
import {Plus} from "@element-plus/icons-vue";
|
import {Plus} from "@element-plus/icons-vue";
|
||||||
|
|
||||||
const id = ref<any>("")
|
const id = ref<any>("")
|
||||||
|
|
@ -112,32 +111,33 @@ const pageSize = ref(20);
|
||||||
const page = ref(1);
|
const page = ref(1);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
const search = ref<any>({})
|
const search = ref<any>({})
|
||||||
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 = () => {
|
const resetSearch = () => {
|
||||||
search.value = {}
|
search.value = {}
|
||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
// 修改 depts 的类型定义,允许字符串索引
|
// 在 script setup 中添加如下类型定义
|
||||||
interface DeptMap {
|
interface DeptChildren {
|
||||||
[key: string]: string | { name: string; children?: { [key: string]: string } };
|
[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 => {
|
const getDeptDisplayName = (code: string): string => {
|
||||||
if (!code) return '未知科室'
|
if (!code) return '未知科室'
|
||||||
|
|
||||||
const dept = (depts as DeptMap)[code]
|
const dept = depts[code]
|
||||||
|
|
||||||
// 如果是一级科室,并且是字符串类型
|
// 如果是一级科室,并且是字符串类型
|
||||||
if (typeof dept === 'string') {
|
if (typeof dept === 'string') {
|
||||||
|
|
@ -151,7 +151,7 @@ const getDeptDisplayName = (code: string): string => {
|
||||||
|
|
||||||
// 如果是二级科室,尝试查找父级下的 value
|
// 如果是二级科室,尝试查找父级下的 value
|
||||||
for (const key in depts) {
|
for (const key in depts) {
|
||||||
const parentDept = depts[key]
|
const parentDept = depts[key] as DeptItem; // 类型断言确保类型正确
|
||||||
if (
|
if (
|
||||||
typeof parentDept === 'object' &&
|
typeof parentDept === 'object' &&
|
||||||
parentDept !== null &&
|
parentDept !== null &&
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue