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:
@@ -8,7 +8,7 @@
|
|||||||
ref="searchFormRef"
|
ref="searchFormRef"
|
||||||
@register="register"
|
@register="register"
|
||||||
@submit="reloadTable"
|
@submit="reloadTable"
|
||||||
@reset="reloadTable"
|
@reset="onSearchReset"
|
||||||
@keyup.enter="reloadTable"
|
@keyup.enter="reloadTable"
|
||||||
/>
|
/>
|
||||||
<BasicTable
|
<BasicTable
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
statusOptions,
|
statusOptions,
|
||||||
tenantOptions,
|
tenantOptions,
|
||||||
} from './model';
|
} from './model';
|
||||||
|
import { imSearchReset } from '../../imTenantOptions';
|
||||||
import { adaTableScrollX } from '@/utils/hotgo';
|
import { adaTableScrollX } from '@/utils/hotgo';
|
||||||
import CreateModal from './CreateModal.vue';
|
import CreateModal from './CreateModal.vue';
|
||||||
import BatchViewModal from './BatchViewModal.vue';
|
import BatchViewModal from './BatchViewModal.vue';
|
||||||
@@ -153,6 +154,9 @@
|
|||||||
actionRef.value?.reload();
|
actionRef.value?.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重置后回填商户下拉第一个选项再查询(避免 tenantId 被清空导致后端拒绝查询)
|
||||||
|
const onSearchReset = imSearchReset(searchFormRef, tenantOptions, reloadTable);
|
||||||
|
|
||||||
function selectedTenantId() {
|
function selectedTenantId() {
|
||||||
return Number(searchFormRef.value?.formModel?.tenantId || 0);
|
return Number(searchFormRef.value?.formModel?.tenantId || 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
ref="searchFormRef"
|
ref="searchFormRef"
|
||||||
@register="register"
|
@register="register"
|
||||||
@submit="reloadTable"
|
@submit="reloadTable"
|
||||||
@reset="reloadTable"
|
@reset="onSearchReset"
|
||||||
@keyup.enter="reloadTable"
|
@keyup.enter="reloadTable"
|
||||||
/>
|
/>
|
||||||
<BasicTable
|
<BasicTable
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
import { BasicForm, useForm } from '@/components/Form/index';
|
import { BasicForm, useForm } from '@/components/Form/index';
|
||||||
import { List } from '@/api/imDeadLetter';
|
import { List } from '@/api/imDeadLetter';
|
||||||
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
||||||
|
import { imSearchReset } from '../imTenantOptions';
|
||||||
import { adaTableScrollX } from '@/utils/hotgo';
|
import { adaTableScrollX } from '@/utils/hotgo';
|
||||||
import ViewModal from './view.vue';
|
import ViewModal from './view.vue';
|
||||||
|
|
||||||
@@ -89,6 +90,9 @@
|
|||||||
actionRef.value?.reload();
|
actionRef.value?.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重置后回填商户下拉第一个选项再查询(避免 tenantId 被清空导致列表为空)
|
||||||
|
const onSearchReset = imSearchReset(searchFormRef, tenantOptions, reloadTable);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadOptions();
|
loadOptions();
|
||||||
await loadTenantOptions();
|
await loadTenantOptions();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
ref="searchFormRef"
|
ref="searchFormRef"
|
||||||
@register="register"
|
@register="register"
|
||||||
@submit="reloadTable"
|
@submit="reloadTable"
|
||||||
@reset="reloadTable"
|
@reset="onSearchReset"
|
||||||
@keyup.enter="reloadTable"
|
@keyup.enter="reloadTable"
|
||||||
/>
|
/>
|
||||||
<BasicTable
|
<BasicTable
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
import { BasicForm, useForm } from '@/components/Form/index';
|
import { BasicForm, useForm } from '@/components/Form/index';
|
||||||
import { List } from '@/api/imGroup';
|
import { List } from '@/api/imGroup';
|
||||||
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
||||||
|
import { imSearchReset } from '../imTenantOptions';
|
||||||
import { adaTableScrollX } from '@/utils/hotgo';
|
import { adaTableScrollX } from '@/utils/hotgo';
|
||||||
import ViewModal from './view.vue';
|
import ViewModal from './view.vue';
|
||||||
import MembersModal from './members.vue';
|
import MembersModal from './members.vue';
|
||||||
@@ -104,6 +105,9 @@
|
|||||||
actionRef.value?.reload();
|
actionRef.value?.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重置后回填商户下拉第一个选项再查询(避免 tenantId 被清空导致列表为空)
|
||||||
|
const onSearchReset = imSearchReset(searchFormRef, tenantOptions, reloadTable);
|
||||||
|
|
||||||
// 查看详情
|
// 查看详情
|
||||||
function handleView(record: Recordable) {
|
function handleView(record: Recordable) {
|
||||||
viewRef.value.openModal(record);
|
viewRef.value.openModal(record);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
ref="searchFormRef"
|
ref="searchFormRef"
|
||||||
@register="register"
|
@register="register"
|
||||||
@submit="reloadTable"
|
@submit="reloadTable"
|
||||||
@reset="reloadTable"
|
@reset="onSearchReset"
|
||||||
@keyup.enter="reloadTable"
|
@keyup.enter="reloadTable"
|
||||||
/>
|
/>
|
||||||
<n-space class="table-toolbar">
|
<n-space class="table-toolbar">
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
import { BasicForm, useForm } from '@/components/Form/index';
|
import { BasicForm, useForm } from '@/components/Form/index';
|
||||||
import { CacheInvalidate, List, WorkbenchEvent } from '@/api/imKafkaCommand';
|
import { CacheInvalidate, List, WorkbenchEvent } from '@/api/imKafkaCommand';
|
||||||
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
||||||
|
import { imSearchReset } from '../imTenantOptions';
|
||||||
import { adaTableScrollX } from '@/utils/hotgo';
|
import { adaTableScrollX } from '@/utils/hotgo';
|
||||||
import ViewModal from './view.vue';
|
import ViewModal from './view.vue';
|
||||||
|
|
||||||
@@ -80,6 +81,9 @@
|
|||||||
actionRef.value?.reload();
|
actionRef.value?.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重置后回填商户下拉第一个选项再查询(避免 tenantId 被清空导致列表为空)
|
||||||
|
const onSearchReset = imSearchReset(searchFormRef, tenantOptions, reloadTable);
|
||||||
|
|
||||||
async function sendCacheInvalidate() {
|
async function sendCacheInvalidate() {
|
||||||
const tenant = getFirstTenant();
|
const tenant = getFirstTenant();
|
||||||
if (!tenant) {
|
if (!tenant) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
ref="searchFormRef"
|
ref="searchFormRef"
|
||||||
@register="register"
|
@register="register"
|
||||||
@submit="reloadTable"
|
@submit="reloadTable"
|
||||||
@reset="reloadTable"
|
@reset="onSearchReset"
|
||||||
/>
|
/>
|
||||||
<BasicTable
|
<BasicTable
|
||||||
ref="actionRef"
|
ref="actionRef"
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
import { BasicForm, useForm } from '@/components/Form/index';
|
import { BasicForm, useForm } from '@/components/Form/index';
|
||||||
import { List, Review } from '@/api/imRealname';
|
import { List, Review } from '@/api/imRealname';
|
||||||
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
||||||
|
import { imSearchReset } from '../imTenantOptions';
|
||||||
import { adaTableScrollX } from '@/utils/hotgo';
|
import { adaTableScrollX } from '@/utils/hotgo';
|
||||||
import ViewModal from './view.vue';
|
import ViewModal from './view.vue';
|
||||||
|
|
||||||
@@ -94,6 +95,9 @@
|
|||||||
actionRef.value?.reload();
|
actionRef.value?.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重置后回填商户下拉第一个选项再查询(避免 tenantId 被清空导致列表为空)
|
||||||
|
const onSearchReset = imSearchReset(searchFormRef, tenantOptions, reloadTable);
|
||||||
|
|
||||||
function handleReview(record: State, status: string, reviewReason = '') {
|
function handleReview(record: State, status: string, reviewReason = '') {
|
||||||
Review({ tenantId: record.tenantId, id: record.id, status, reviewReason }).then(() => {
|
Review({ tenantId: record.tenantId, id: record.id, status, reviewReason }).then(() => {
|
||||||
message.success('操作成功');
|
message.success('操作成功');
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
ref="searchFormRef"
|
ref="searchFormRef"
|
||||||
@register="register"
|
@register="register"
|
||||||
@submit="reload"
|
@submit="reload"
|
||||||
@reset="reload"
|
@reset="onSearchReset"
|
||||||
@keyup.enter="reload"
|
@keyup.enter="reload"
|
||||||
/>
|
/>
|
||||||
<BasicTable
|
<BasicTable
|
||||||
@@ -159,6 +159,7 @@
|
|||||||
parseJSON,
|
parseJSON,
|
||||||
policyTenantOptions,
|
policyTenantOptions,
|
||||||
} from '@/views/imPolicyShared';
|
} from '@/views/imPolicyShared';
|
||||||
|
import { imSearchReset } from '../imTenantOptions';
|
||||||
const dict = useDictStore(),
|
const dict = useDictStore(),
|
||||||
message = useMessage(),
|
message = useMessage(),
|
||||||
dialog = useDialog(),
|
dialog = useDialog(),
|
||||||
@@ -212,6 +213,11 @@
|
|||||||
? List({ ...searchFormRef.value?.formModel, ...res })
|
? List({ ...searchFormRef.value?.formModel, ...res })
|
||||||
: Promise.resolve({});
|
: Promise.resolve({});
|
||||||
const reload = () => tableRef.value?.reload();
|
const reload = () => tableRef.value?.reload();
|
||||||
|
// 重置后回填商户下拉再查询;回填跳过「全局默认」(value=0),与初始加载 getDefaultTenantValue 行为一致
|
||||||
|
const resetTenantOptions = computed(() =>
|
||||||
|
policyTenantOptions.value.filter((v) => Number(v.value) > 0)
|
||||||
|
);
|
||||||
|
const onSearchReset = imSearchReset(searchFormRef, resetTenantOptions, reload);
|
||||||
const actionColumn = reactive({
|
const actionColumn = reactive({
|
||||||
width: 150,
|
width: 150,
|
||||||
title: '操作',
|
title: '操作',
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
ref="searchFormRef"
|
ref="searchFormRef"
|
||||||
@register="register"
|
@register="register"
|
||||||
@submit="reloadTable"
|
@submit="reloadTable"
|
||||||
@reset="handleReset"
|
@reset="onSearchReset"
|
||||||
@keyup.enter="reloadTable"
|
@keyup.enter="reloadTable"
|
||||||
/>
|
/>
|
||||||
<BasicTable
|
<BasicTable
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
import { BasicTable } from '@/components/Table';
|
import { BasicTable } from '@/components/Table';
|
||||||
import { List } from '@/api/imTaskDashboard';
|
import { List } from '@/api/imTaskDashboard';
|
||||||
import { columns, loadOptions, loadTenantOptions, schemas, tenantOptions } from './model';
|
import { columns, loadOptions, loadTenantOptions, schemas, tenantOptions } from './model';
|
||||||
|
import { imSearchReset } from '../imTenantOptions';
|
||||||
import { adaTableScrollX } from '@/utils/hotgo';
|
import { adaTableScrollX } from '@/utils/hotgo';
|
||||||
|
|
||||||
const message = useMessage();
|
const message = useMessage();
|
||||||
@@ -58,10 +59,8 @@
|
|||||||
actionRef.value?.reload();
|
actionRef.value?.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleReset() {
|
// 重置后回填商户下拉第一个选项再查询(避免 tenantId 被清空导致后端拒绝查询)
|
||||||
await setFieldsValue({});
|
const onSearchReset = imSearchReset(searchFormRef, tenantOptions, reloadTable);
|
||||||
reloadTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadOptions();
|
loadOptions();
|
||||||
|
|||||||
@@ -71,6 +71,31 @@ export function lockTenantSchema(schema?: FormSchema) {
|
|||||||
props.clearable = false;
|
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 {
|
function toTenantOption(item: any): ImTenantOption {
|
||||||
return {
|
return {
|
||||||
label: formatImTenantLabel(item),
|
label: formatImTenantLabel(item),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
ref="searchFormRef"
|
ref="searchFormRef"
|
||||||
@register="register"
|
@register="register"
|
||||||
@submit="reloadTable"
|
@submit="reloadTable"
|
||||||
@reset="reloadTable"
|
@reset="onSearchReset"
|
||||||
@keyup.enter="reloadTable"
|
@keyup.enter="reloadTable"
|
||||||
/>
|
/>
|
||||||
<BasicTable
|
<BasicTable
|
||||||
@@ -236,6 +236,7 @@
|
|||||||
State,
|
State,
|
||||||
tenantOptions,
|
tenantOptions,
|
||||||
} from './model';
|
} from './model';
|
||||||
|
import { imSearchReset } from '../imTenantOptions';
|
||||||
import { DownloadOutlined, PlusOutlined, UploadOutlined } from '@vicons/antd';
|
import { DownloadOutlined, PlusOutlined, UploadOutlined } from '@vicons/antd';
|
||||||
import { adaTableScrollX } from '@/utils/hotgo';
|
import { adaTableScrollX } from '@/utils/hotgo';
|
||||||
import ViewModal from './view.vue';
|
import ViewModal from './view.vue';
|
||||||
@@ -380,6 +381,9 @@
|
|||||||
actionRef.value?.reload();
|
actionRef.value?.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重置后回填商户下拉第一个选项再查询(避免 tenantId 被清空导致列表为空)
|
||||||
|
const onSearchReset = imSearchReset(searchFormRef, tenantOptions, reloadTable);
|
||||||
|
|
||||||
// 查看详情
|
// 查看详情
|
||||||
function handleView(record: Recordable) {
|
function handleView(record: Recordable) {
|
||||||
viewRef.value.openModal(record);
|
viewRef.value.openModal(record);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
ref="searchFormRef"
|
ref="searchFormRef"
|
||||||
@register="register"
|
@register="register"
|
||||||
@submit="reloadTable"
|
@submit="reloadTable"
|
||||||
@reset="reloadTable"
|
@reset="onSearchReset"
|
||||||
@keyup.enter="reloadTable"
|
@keyup.enter="reloadTable"
|
||||||
/>
|
/>
|
||||||
<n-alert type="info" :show-icon="true" class="whitelist-summary">
|
<n-alert type="info" :show-icon="true" class="whitelist-summary">
|
||||||
@@ -241,6 +241,7 @@
|
|||||||
parseJSON,
|
parseJSON,
|
||||||
policyTenantOptions,
|
policyTenantOptions,
|
||||||
} from '@/views/imPolicyShared';
|
} from '@/views/imPolicyShared';
|
||||||
|
import { imSearchReset } from '../imTenantOptions';
|
||||||
|
|
||||||
const dict = useDictStore(),
|
const dict = useDictStore(),
|
||||||
message = useMessage(),
|
message = useMessage(),
|
||||||
@@ -298,6 +299,11 @@
|
|||||||
actionRef.value?.reload();
|
actionRef.value?.reload();
|
||||||
refreshLoginIPSummary();
|
refreshLoginIPSummary();
|
||||||
};
|
};
|
||||||
|
// 重置后回填商户下拉再查询;回填跳过「全局默认」(value=0),与初始加载 getDefaultTenantValue 行为一致
|
||||||
|
const resetTenantOptions = computed(() =>
|
||||||
|
policyTenantOptions.value.filter((v) => Number(v.value) > 0)
|
||||||
|
);
|
||||||
|
const onSearchReset = imSearchReset(searchFormRef, resetTenantOptions, reloadTable);
|
||||||
const actionColumn = reactive({
|
const actionColumn = reactive({
|
||||||
width: 300,
|
width: 300,
|
||||||
title: '操作',
|
title: '操作',
|
||||||
|
|||||||
Reference in New Issue
Block a user