fix: 修复前端若干类型报错

This commit is contained in:
ah--desktop
2026-03-31 23:44:37 +08:00
parent 7f5803ddda
commit 6b434fbf63
38 changed files with 383 additions and 1981 deletions
@@ -127,7 +127,7 @@ function findDepartmentPathById(
options: DepartmentCascaderOption[],
departmentId: number,
currentPath: number[] = [],
): number[] | null {
): null | number[] {
for (const option of options) {
const nextPath = [...currentPath, option.value];
if (option.value === departmentId) return nextPath;
@@ -207,7 +207,9 @@ function handleDepartmentChange(value: number[]) {
if (
previousDepartmentId !== selectedDepartmentId &&
formData.value.positionId &&
!positionOptions.value.some((item) => item.value === formData.value.positionId)
!positionOptions.value.some(
(item) => item.value === formData.value.positionId,
)
) {
formData.value.positionId = undefined;
}
@@ -279,7 +281,9 @@ watch(
() => {
if (
formData.value.positionId &&
!positionOptions.value.some((item) => item.value === formData.value.positionId)
!positionOptions.value.some(
(item) => item.value === formData.value.positionId,
)
) {
formData.value.positionId = undefined;
}
@@ -345,7 +349,11 @@ defineExpose({
:options="departmentTreeOptions"
:loading="departmentOptionsLoading"
placeholder="请选择所属部门"
:field-names="{ label: 'label', value: 'value', children: 'children' }"
:field-names="{
label: 'label',
value: 'value',
children: 'children',
}"
change-on-select
class="w-full"
@change="(value) => handleDepartmentChange((value || []) as number[])"
@@ -48,6 +48,7 @@ const statusOptions = [
];
// 搜索表单配置
const gridReloadRef = ref<(() => void) | null>(null);
const formOptions = computed(() => ({
schemas: [
{
@@ -56,7 +57,7 @@ const formOptions = computed(() => ({
component: 'Input',
componentProps: {
placeholder: '请输入登录账号(回车搜索)',
onPressEnter: () => gridApi?.reload(),
onPressEnter: () => gridReloadRef.value?.(),
},
},
{
@@ -65,7 +66,7 @@ const formOptions = computed(() => ({
component: 'Input',
componentProps: {
placeholder: '请输入真实姓名(回车搜索)',
onPressEnter: () => gridApi?.reload(),
onPressEnter: () => gridReloadRef.value?.(),
},
},
{
@@ -74,7 +75,7 @@ const formOptions = computed(() => ({
component: 'Input',
componentProps: {
placeholder: '请输入手机号(回车搜索)',
onPressEnter: () => gridApi?.reload(),
onPressEnter: () => gridReloadRef.value?.(),
},
},
{
@@ -84,7 +85,7 @@ const formOptions = computed(() => ({
componentProps: {
options: statusOptions,
placeholder: '请选择状态',
onChange: () => gridApi?.reload(),
onChange: () => gridReloadRef.value?.(),
},
},
],
@@ -229,6 +230,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
showSearchForm: true,
tableTitle: '账户管理',
});
gridReloadRef.value = () => gridApi.reload();
// 计算属性
const hasSelected = computed(() => {