fix: restore tenant filter on search reset in IM pages
BasicForm resetFields clears tenantId along with other fields, so the auto-query after reset hit the empty-list guard (or was rejected by the backend). Add a shared imSearchReset handler in imTenantOptions.ts that refills the tenant select with its first option (bound users keep their own tenant) before reloading, and wire it into the 9 IM list pages whose reset did not already refill the tenant condition.
This commit is contained in:
@@ -71,6 +71,31 @@ export function lockTenantSchema(schema?: FormSchema) {
|
||||
props.clearable = false;
|
||||
}
|
||||
|
||||
interface ImSearchFormRef {
|
||||
setFieldsValue: (values: Record<string, any>) => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一搜索重置回调:BasicForm 的 resetFields 会把包括 tenantId 在内的全部搜索字段清空,
|
||||
* 随后的自动查询因缺商户条件命中前端空列表 guard(或被后端以「请选择IM租户」拒绝)。
|
||||
* 此工厂返回的回调在 reset 之后把商户下拉回填为当前选项列表的第一项
|
||||
* (商户绑定账号=自己商户;平台账号=全部商户列表第一项),再触发查询——
|
||||
* 与各页面初始加载(onMounted 默认选中第一项)的行为保持一致。
|
||||
*/
|
||||
export function imSearchReset(
|
||||
searchFormRef: Ref<ImSearchFormRef | null>,
|
||||
tenantOptions: Ref<ImTenantOption[]>,
|
||||
reload: () => unknown,
|
||||
) {
|
||||
return async () => {
|
||||
const first = Number(tenantOptions.value[0]?.value || 0);
|
||||
if (first > 0) {
|
||||
await searchFormRef.value?.setFieldsValue({ tenantId: first });
|
||||
}
|
||||
await reload();
|
||||
};
|
||||
}
|
||||
|
||||
function toTenantOption(item: any): ImTenantOption {
|
||||
return {
|
||||
label: formatImTenantLabel(item),
|
||||
|
||||
Reference in New Issue
Block a user