fix: 完善IM用户状态与分组展示
This commit is contained in:
@@ -330,7 +330,7 @@
|
||||
type: record.state === 0 ? 'error' : 'default',
|
||||
onClick: handleBanToggle.bind(null, record),
|
||||
auth: [record.state === 0 ? '/imUser/ban' : '/imUser/unban'],
|
||||
ifShow: record.state !== 20,
|
||||
ifShow: record.state === 0 || record.state === 10,
|
||||
},
|
||||
{
|
||||
label: '强制下线',
|
||||
@@ -429,8 +429,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
function openAdjustGroup(record: State) {
|
||||
async function openAdjustGroup(record: State) {
|
||||
operationUser.value = record;
|
||||
await loadPolicyGroupOptions(record.tenantId);
|
||||
adjustGroupId.value = record.policyGroupId || null;
|
||||
groupVisible.value = true;
|
||||
}
|
||||
@@ -567,15 +568,17 @@
|
||||
|
||||
onMounted(async () => {
|
||||
loadOptions();
|
||||
let tenantId = currentTenantId();
|
||||
if (isPlatformAdmin.value) {
|
||||
await loadTenantOptions();
|
||||
if (tenantOptions.value.length > 0) {
|
||||
await setFieldsValue({ tenantId: tenantOptions.value[0].value });
|
||||
tenantId = Number(tenantOptions.value[0].value);
|
||||
await setFieldsValue({ tenantId });
|
||||
} else {
|
||||
message.warning('暂无可用租户');
|
||||
}
|
||||
}
|
||||
await loadPolicyGroupOptions(currentTenantId());
|
||||
await loadPolicyGroupOptions(tenantId);
|
||||
reloadTable();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { computed, h, ref } from 'vue';
|
||||
import { NAvatar, NImage, NTag } from 'naive-ui';
|
||||
import { NImage, NTag } from 'naive-ui';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { FormSchema } from '@/components/Form';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
import { List as TenantList } from '@/api/imTenant';
|
||||
import { List as PolicyGroupList } from '@/api/imUserPolicyGroup';
|
||||
import defaultAvatar from '@/assets/images/schoolboy.png';
|
||||
|
||||
const dict = useDictStore();
|
||||
|
||||
@@ -110,7 +111,7 @@ export const schemas = ref<FormSchema[]>([
|
||||
label: '状态',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: dict.getOption('ImUserStateOptions'),
|
||||
options: dict.getOption('ImUserListStateOptions'),
|
||||
placeholder: '全部',
|
||||
},
|
||||
},
|
||||
@@ -139,14 +140,14 @@ export const columns = [
|
||||
align: 'left',
|
||||
width: 80,
|
||||
render(row: State) {
|
||||
if (row.avatar) {
|
||||
return h(NImage, { width: 40, height: 40, src: row.avatar, objectFit: 'cover' });
|
||||
}
|
||||
return h(
|
||||
NAvatar,
|
||||
{ size: 40 },
|
||||
{ default: () => (row.nickname || row.username || '?').slice(0, 1) }
|
||||
);
|
||||
return h(NImage, {
|
||||
width: 40,
|
||||
height: 40,
|
||||
src: row.avatar || defaultAvatar,
|
||||
fallbackSrc: defaultAvatar,
|
||||
objectFit: 'cover',
|
||||
previewDisabled: !row.avatar,
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -243,7 +244,7 @@ export const deviceColumns = [
|
||||
|
||||
// 加载字典数据选项
|
||||
export function loadOptions() {
|
||||
dict.loadOptions(['ImUserStateOptions', 'ImUserRegisterTypeOptions']);
|
||||
dict.loadOptions(['ImUserStateOptions', 'ImUserListStateOptions', 'ImUserRegisterTypeOptions']);
|
||||
}
|
||||
|
||||
export async function loadTenantOptions() {
|
||||
@@ -256,7 +257,7 @@ export async function loadTenantOptions() {
|
||||
}
|
||||
|
||||
export async function loadPolicyGroupOptions(tenantId: number) {
|
||||
const res = await PolicyGroupList({ tenantId, page: 1, pageSize: 200 });
|
||||
const res = await PolicyGroupList({ tenantId, status: 1, page: 1, perPage: 200 });
|
||||
policyGroupOptions.value = (res?.list || []).map((item) => ({
|
||||
label: item.groupName,
|
||||
value: item.id,
|
||||
|
||||
Reference in New Issue
Block a user