fix: show bound tenant in im menus
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
import { BasicTable, TableAction } from '@/components/Table';
|
||||
import { BasicForm, useForm } from '@/components/Form/index';
|
||||
import { usePermission } from '@/hooks/web/usePermission';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { Dead, List, Retry } from '@/api/imOutbox';
|
||||
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
||||
import { adaTableScrollX } from '@/utils/hotgo';
|
||||
@@ -40,15 +39,13 @@
|
||||
const message = useMessage();
|
||||
const dialog = useDialog();
|
||||
const { hasPermission } = usePermission();
|
||||
const userStore = useUserStore();
|
||||
const isPlatformAdmin = computed(() => userStore.isCompanyDept);
|
||||
const actionRef = ref();
|
||||
const searchFormRef = ref<any>({});
|
||||
const viewRef = ref();
|
||||
|
||||
const tenantSchema = schemas.value.find((item) => item.field === 'tenantId');
|
||||
if (tenantSchema) {
|
||||
tenantSchema.ifShow = () => isPlatformAdmin.value;
|
||||
tenantSchema.ifShow = () => true;
|
||||
}
|
||||
|
||||
const actionColumn = reactive({
|
||||
@@ -94,7 +91,7 @@
|
||||
|
||||
const loadDataTable = async (res) => {
|
||||
const params = { ...searchFormRef.value?.formModel, ...res };
|
||||
if (isPlatformAdmin.value && !params.tenantId)
|
||||
if (!params.tenantId)
|
||||
return { list: [], page: 1, pageCount: 0, totalCount: 0 };
|
||||
if (!params.source) params.source = 'business';
|
||||
return await List(params);
|
||||
@@ -106,7 +103,7 @@
|
||||
|
||||
async function handleReset() {
|
||||
const defaults: Recordable = { source: 'business' };
|
||||
if (isPlatformAdmin.value && tenantOptions.value.length > 0)
|
||||
if (tenantOptions.value.length > 0)
|
||||
defaults.tenantId = tenantOptions.value[0].value;
|
||||
await setFieldsValue(defaults);
|
||||
reloadTable();
|
||||
@@ -143,13 +140,11 @@
|
||||
onMounted(async () => {
|
||||
loadOptions();
|
||||
await setFieldsValue({ source: 'business' });
|
||||
if (isPlatformAdmin.value) {
|
||||
await loadTenantOptions();
|
||||
if (tenantOptions.value.length > 0) {
|
||||
await setFieldsValue({ tenantId: tenantOptions.value[0].value });
|
||||
} else {
|
||||
message.warning('暂无可用商户');
|
||||
}
|
||||
await loadTenantOptions();
|
||||
if (tenantOptions.value.length > 0) {
|
||||
await setFieldsValue({ tenantId: tenantOptions.value[0].value });
|
||||
} else {
|
||||
message.warning('暂无可用商户');
|
||||
}
|
||||
reloadTable();
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { cloneDeep } from 'lodash-es';
|
||||
import { FormSchema } from '@/components/Form';
|
||||
import { defRangeShortcuts } from '@/utils/dateUtil';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
import { List as TenantList } from '@/api/imTenant';
|
||||
import { loadImTenantOptions } from '@/views/imTenantOptions';
|
||||
|
||||
const dict = useDictStore();
|
||||
|
||||
@@ -139,10 +139,5 @@ export function loadOptions() {
|
||||
}
|
||||
|
||||
export async function loadTenantOptions() {
|
||||
const res = await TenantList({ page: 1, perPage: 20 });
|
||||
tenantOptions.value = (res?.list || []).map((item) => ({
|
||||
label: `${item.name}(${item.code})`,
|
||||
value: item.id,
|
||||
}));
|
||||
return tenantOptions.value;
|
||||
return loadImTenantOptions(tenantOptions, { page: 1, perPage: 20 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user