mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 05:49:20 +08:00
feat: 系统账户页接入 CompanyColPage 共用公司侧栏
This commit is contained in:
@@ -8,11 +8,16 @@ import CompanySidebarList from '#/views/company/components/CompanySidebarList.vu
|
||||
|
||||
defineOptions({ name: 'CompanyColPage' });
|
||||
|
||||
/** 公司侧栏:展开/宽度走全局持久化,菜单分配与权限页跨页共用 */
|
||||
/** 公司侧栏:展开/宽度走全局持久化,菜单/权限/账户等跨页共用 */
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
selectedCompanyId?: number;
|
||||
showAllOption?: boolean;
|
||||
allOptionLabel?: string;
|
||||
allOptionHint?: string;
|
||||
showAddAction?: boolean;
|
||||
addPermissionCode?: string;
|
||||
autoContentHeight?: boolean;
|
||||
leftMinWidth?: number;
|
||||
leftMaxWidth?: number;
|
||||
@@ -23,6 +28,11 @@ withDefaults(
|
||||
splitLine?: boolean;
|
||||
}>(),
|
||||
{
|
||||
showAllOption: false,
|
||||
allOptionLabel: '全部公司',
|
||||
allOptionHint: '全部记录',
|
||||
showAddAction: false,
|
||||
addPermissionCode: undefined,
|
||||
autoContentHeight: true,
|
||||
leftMinWidth: 16,
|
||||
leftMaxWidth: 36,
|
||||
@@ -36,7 +46,8 @@ withDefaults(
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:selectedCompanyId': [id: number | undefined];
|
||||
select: [company: CompanyVO.CompanyInfoVO];
|
||||
select: [company: CompanyVO.CompanyInfoVO | null];
|
||||
addForCompany: [company: CompanyVO.CompanyInfoVO];
|
||||
}>();
|
||||
|
||||
const { width: leftWidth, collapsed: leftCollapsed } =
|
||||
@@ -73,10 +84,16 @@ const { width: leftWidth, collapsed: leftCollapsed } =
|
||||
:collapsed="!!isCollapsed"
|
||||
show-collapse-action
|
||||
:selected-company-id="selectedCompanyId"
|
||||
:show-all-option="showAllOption"
|
||||
:all-option-label="allOptionLabel"
|
||||
:all-option-hint="allOptionHint"
|
||||
:show-add-action="showAddAction"
|
||||
:add-permission-code="addPermissionCode"
|
||||
@collapse="collapse"
|
||||
@expand="expand"
|
||||
@update:selected-company-id="emit('update:selectedCompanyId', $event)"
|
||||
@select="emit('select', $event)"
|
||||
@add-for-company="emit('addForCompany', $event)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -18,12 +18,14 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getCompanyPageApi } from '#/api/company';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import CompanyLogoAvatar from '#/views/company/components/CompanyLogoAvatar.vue';
|
||||
|
||||
defineOptions({ name: 'CompanySidebarList' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** undefined = 未选 / 全部(需 showAllOption) */
|
||||
selectedCompanyId?: number;
|
||||
/** 填满父容器宽度(ColPage 左栏);默认固定 320px */
|
||||
fluid?: boolean;
|
||||
@@ -31,23 +33,39 @@ const props = withDefaults(
|
||||
showCollapseAction?: boolean;
|
||||
/** 窄栏模式:仅展示 logo 列表(ColPage 收起态) */
|
||||
collapsed?: boolean;
|
||||
/** 展示「全部」筛选项(如账户页) */
|
||||
showAllOption?: boolean;
|
||||
allOptionLabel?: string;
|
||||
allOptionHint?: string;
|
||||
/** 行内「添加」快捷按钮 */
|
||||
showAddAction?: boolean;
|
||||
/** 添加按钮权限码;不传则仅看 showAddAction */
|
||||
addPermissionCode?: string;
|
||||
}>(),
|
||||
{
|
||||
selectedCompanyId: undefined,
|
||||
fluid: false,
|
||||
showCollapseAction: false,
|
||||
collapsed: false,
|
||||
showAllOption: false,
|
||||
allOptionLabel: '全部公司',
|
||||
allOptionHint: '全部记录',
|
||||
showAddAction: false,
|
||||
addPermissionCode: undefined,
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:selectedCompanyId': [id: number | undefined];
|
||||
select: [company: CompanyVO.CompanyInfoVO];
|
||||
/** 选中公司;null 表示「全部」 */
|
||||
select: [company: CompanyVO.CompanyInfoVO | null];
|
||||
addForCompany: [company: CompanyVO.CompanyInfoVO];
|
||||
collapse: [];
|
||||
expand: [];
|
||||
}>();
|
||||
|
||||
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const PanelCloseIcon = createIconifyIcon('lucide:panel-left-close');
|
||||
const PanelOpenIcon = createIconifyIcon('lucide:panel-left-open');
|
||||
const ChevronUpIcon = createIconifyIcon('lucide:chevron-up');
|
||||
@@ -67,6 +85,10 @@ const companyTotalPages = computed(() => {
|
||||
return Math.max(1, Math.ceil(total / pageSize) || 1);
|
||||
});
|
||||
|
||||
const allSelected = computed(
|
||||
() => props.showAllOption && props.selectedCompanyId === undefined,
|
||||
);
|
||||
|
||||
async function searchCompanies(resetPage = false) {
|
||||
if (resetPage) {
|
||||
companyPagination.value.current = 1;
|
||||
@@ -103,11 +125,22 @@ function goCompanyPage(page: number) {
|
||||
void searchCompanies();
|
||||
}
|
||||
|
||||
function selectAll() {
|
||||
emit('update:selectedCompanyId', undefined);
|
||||
emit('select', null);
|
||||
}
|
||||
|
||||
function selectCompany(company: CompanyVO.CompanyInfoVO) {
|
||||
emit('update:selectedCompanyId', company.id);
|
||||
emit('select', company);
|
||||
}
|
||||
|
||||
function onAddForCompany(company: CompanyVO.CompanyInfoVO, event: Event) {
|
||||
event.stopPropagation();
|
||||
selectCompany(company);
|
||||
emit('addForCompany', company);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void searchCompanies();
|
||||
});
|
||||
@@ -127,13 +160,36 @@ onMounted(() => {
|
||||
<div
|
||||
class="flex min-h-0 w-full flex-1 flex-col items-center gap-1.5 overflow-y-auto px-1.5 pb-1 pt-2"
|
||||
>
|
||||
<Tooltip v-if="showAllOption" :title="allOptionLabel">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||
:class="
|
||||
allSelected
|
||||
? 'ring-2 ring-primary ring-offset-1 ring-offset-background'
|
||||
: undefined
|
||||
"
|
||||
@click="selectAll"
|
||||
>
|
||||
<div
|
||||
class="flex h-9 w-9 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||
>
|
||||
<BuildingIcon class="h-4 w-4 text-muted-foreground" />
|
||||
</div>
|
||||
</button>
|
||||
</Tooltip>
|
||||
|
||||
<Spin
|
||||
:spinning="companiesLoading"
|
||||
size="small"
|
||||
wrapper-class-name="company-sidebar-collapsed-spin"
|
||||
>
|
||||
<div class="flex w-full flex-col items-center gap-1.5">
|
||||
<Tooltip v-for="company in companies" :key="company.id" :title="company.name">
|
||||
<Tooltip
|
||||
v-for="company in companies"
|
||||
:key="company.id"
|
||||
:title="company.name"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||
@@ -175,7 +231,9 @@ onMounted(() => {
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-6 !px-1"
|
||||
:disabled="companyPagination.current >= companyTotalPages || companiesLoading"
|
||||
:disabled="
|
||||
companyPagination.current >= companyTotalPages || companiesLoading
|
||||
"
|
||||
@click="goCompanyPage(companyPagination.current + 1)"
|
||||
>
|
||||
<ChevronDownIcon class="h-3.5 w-3.5" />
|
||||
@@ -240,20 +298,50 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||
<Spin :spinning="companiesLoading">
|
||||
<div class="flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto">
|
||||
<Card
|
||||
v-if="showAllOption"
|
||||
size="small"
|
||||
:body-style="{ padding: '10px 12px' }"
|
||||
class="cursor-pointer !shadow-none hover:border-primary"
|
||||
:class="allSelected ? 'border-primary bg-primary/5' : undefined"
|
||||
@click="selectAll"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<div
|
||||
class="flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||
>
|
||||
<BuildingIcon class="h-4 w-4 text-muted-foreground" />
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<span class="min-w-0 truncate text-sm font-medium">
|
||||
{{ allOptionLabel }}
|
||||
</span>
|
||||
<span class="shrink-0 text-xs text-muted-foreground">
|
||||
{{ allOptionHint }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Spin
|
||||
:spinning="companiesLoading"
|
||||
wrapper-class-name="company-sidebar-list-spin"
|
||||
>
|
||||
<Empty
|
||||
v-if="!companiesLoading && companies.length === 0"
|
||||
class="py-8"
|
||||
description="暂无公司"
|
||||
/>
|
||||
<template v-else>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<Card
|
||||
v-for="company in companies"
|
||||
:key="company.id"
|
||||
size="small"
|
||||
:body-style="{ padding: '10px 12px' }"
|
||||
class="mb-2 cursor-pointer !shadow-none last:mb-0 hover:border-primary"
|
||||
class="group cursor-pointer !shadow-none hover:border-primary"
|
||||
:class="
|
||||
selectedCompanyId === company.id
|
||||
? 'border-primary bg-primary/5'
|
||||
@@ -267,20 +355,50 @@ onMounted(() => {
|
||||
:name="company.name"
|
||||
:size="36"
|
||||
/>
|
||||
<div class="flex min-w-0 flex-1 items-center justify-between gap-2">
|
||||
<div
|
||||
class="flex min-w-0 flex-1 items-center justify-between gap-2"
|
||||
>
|
||||
<span class="min-w-0 truncate text-sm font-medium">
|
||||
{{ company.name }}
|
||||
</span>
|
||||
<Tag
|
||||
class="m-0 shrink-0"
|
||||
:color="company.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<Tag
|
||||
class="m-0"
|
||||
:color="company.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
<template v-if="showAddAction">
|
||||
<PermissionGate
|
||||
v-if="addPermissionCode"
|
||||
:code="addPermissionCode"
|
||||
>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
class="!h-7 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
|
||||
@click="onAddForCompany(company, $event)"
|
||||
>
|
||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||
添加
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<Button
|
||||
v-else
|
||||
type="link"
|
||||
size="small"
|
||||
class="!h-7 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
|
||||
@click="onAddForCompany(company, $event)"
|
||||
>
|
||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||
添加
|
||||
</Button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
</div>
|
||||
</Spin>
|
||||
</div>
|
||||
|
||||
@@ -332,4 +450,12 @@ onMounted(() => {
|
||||
align-items: center;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
:deep(.company-sidebar-list-spin),
|
||||
:deep(.company-sidebar-list-spin .ant-spin-container) {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -67,7 +67,8 @@ const stats = computed(() => ({
|
||||
changed: selectedMenuIds.value.length !== companyMenuIds.value.length,
|
||||
}));
|
||||
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO) {
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO | null) {
|
||||
if (!company) return;
|
||||
currentCompany.value = company;
|
||||
selectedCompanyId.value = company.id;
|
||||
void loadCompanyMenus();
|
||||
|
||||
@@ -102,7 +102,8 @@ function collectExpandableKeys(nodes: PermissionVO.PermissionInfoVO[]): number[]
|
||||
return keys;
|
||||
}
|
||||
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO) {
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO | null) {
|
||||
if (!company) return;
|
||||
currentCompany.value = company;
|
||||
selectedCompanyId.value = company.id;
|
||||
void loadCompanyPermissions();
|
||||
|
||||
@@ -7,65 +7,43 @@ import type {
|
||||
} from '#/api/sys/account';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Empty,
|
||||
Flex,
|
||||
Input,
|
||||
message,
|
||||
Pagination,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Tag,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getCompanyPageApi } from '#/api/company';
|
||||
import {
|
||||
super_deleteAccountApi,
|
||||
super_getAccountPageApi,
|
||||
} from '#/api/sys/account';
|
||||
|
||||
import AccountFormModal from './components/AccountFormModal.vue';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
import {
|
||||
SIDEBAR_LIST_SHELL_CLASS,
|
||||
sidebarListRowClass,
|
||||
} from '#/utils/sidebar-list-styles';
|
||||
import CompanyColPage from '#/views/company/components/CompanyColPage.vue';
|
||||
|
||||
import AccountFormModal from './components/AccountFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'SysAccountManagement' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
||||
|
||||
const loading = ref(false);
|
||||
const accountFormModalRef = ref();
|
||||
|
||||
const companySearchForm = ref({
|
||||
name: '',
|
||||
status: undefined as number | undefined,
|
||||
});
|
||||
|
||||
const companyList = ref<CompanyVO.CompanyInfoVO[]>([]);
|
||||
const companyLoading = ref(false);
|
||||
const companyPagination = ref({
|
||||
current: 1,
|
||||
pageSize: 20,
|
||||
total: 0,
|
||||
});
|
||||
|
||||
const selectedCompanyId = ref<number | undefined>(undefined);
|
||||
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
@@ -246,44 +224,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
syncVxeGridColumns(gridApi, accountTableColumns);
|
||||
|
||||
async function searchCompanies() {
|
||||
companyLoading.value = true;
|
||||
try {
|
||||
const result = await getCompanyPageApi({
|
||||
page: companyPagination.value.current,
|
||||
pageSize: companyPagination.value.pageSize,
|
||||
filters: {
|
||||
name: companySearchForm.value.name || undefined,
|
||||
status: companySearchForm.value.status,
|
||||
},
|
||||
});
|
||||
companyList.value = result.records;
|
||||
companyPagination.value.total = result.total;
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '获取公司列表失败');
|
||||
} finally {
|
||||
companyLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function resetCompanySearch() {
|
||||
companySearchForm.value = { name: '', status: undefined };
|
||||
companyPagination.value.current = 1;
|
||||
searchCompanies();
|
||||
}
|
||||
|
||||
function handleCompanyPageChange(page: number, pageSize: number) {
|
||||
companyPagination.value.current = page;
|
||||
companyPagination.value.pageSize = pageSize;
|
||||
searchCompanies();
|
||||
}
|
||||
|
||||
function selectCompanyAll() {
|
||||
currentCompany.value = null;
|
||||
}
|
||||
|
||||
function selectCompany(company: CompanyVO.CompanyInfoVO) {
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO | null) {
|
||||
currentCompany.value = company;
|
||||
selectedCompanyId.value = company?.id;
|
||||
}
|
||||
|
||||
function refreshTable() {
|
||||
@@ -299,7 +242,8 @@ function handleAdd() {
|
||||
}
|
||||
|
||||
function handleAddForCompany(company: CompanyVO.CompanyInfoVO) {
|
||||
selectCompany(company);
|
||||
currentCompany.value = company;
|
||||
selectedCompanyId.value = company.id;
|
||||
accountFormModalRef.value?.open(undefined, company);
|
||||
}
|
||||
|
||||
@@ -339,251 +283,125 @@ function getStatusColor(status: number) {
|
||||
return colorMap[status] || 'default';
|
||||
}
|
||||
|
||||
function companyRowClass(id: number | 'all') {
|
||||
const active =
|
||||
id === 'all'
|
||||
? currentCompany.value === null
|
||||
: currentCompany.value?.id === id;
|
||||
const layout =
|
||||
id === 'all'
|
||||
? 'mb-1.5 flex w-full cursor-pointer items-center gap-2 text-left'
|
||||
: 'group flex w-full cursor-pointer items-center gap-2';
|
||||
return sidebarListRowClass(active, layout);
|
||||
}
|
||||
|
||||
watch(currentCompany, () => {
|
||||
gridApi.reload();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
searchCompanies();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="系统账户管理" :auto-content-height="true">
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
左侧选择公司筛选右侧账户;首项「全部账户」展示所有账户,可在公司行快捷新增。
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<Space>
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<Flex gap="middle" class="h-full min-h-0">
|
||||
<Card
|
||||
class="flex h-full w-[420px] shrink-0 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
minHeight: 0,
|
||||
padding: '12px',
|
||||
}"
|
||||
>
|
||||
<template #title>
|
||||
<span class="flex items-center gap-2 text-base font-semibold">
|
||||
<BuildingIcon class="h-4 w-4" />
|
||||
公司
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<Flex wrap="wrap" align="center" class="shrink-0 gap-2">
|
||||
<CompanyColPage
|
||||
:selected-company-id="selectedCompanyId"
|
||||
show-all-option
|
||||
all-option-label="全部账户"
|
||||
all-option-hint="全部记录"
|
||||
show-add-action
|
||||
add-permission-code="sys:account:create"
|
||||
@select="onCompanySelect"
|
||||
@add-for-company="handleAddForCompany"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}"
|
||||
>
|
||||
<template #title>
|
||||
<span class="text-base font-semibold">账户列表</span>
|
||||
</template>
|
||||
<template #extra>
|
||||
<Space wrap size="small" class="max-w-[min(100%,48rem)]">
|
||||
<Input
|
||||
v-model:value="companySearchForm.name"
|
||||
placeholder="公司名称"
|
||||
v-model:value="searchForm.username"
|
||||
allow-clear
|
||||
class="min-w-[140px] flex-1"
|
||||
@press-enter="searchCompanies"
|
||||
placeholder="登录用户名"
|
||||
class="w-[120px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="searchForm.realName"
|
||||
allow-clear
|
||||
placeholder="姓名"
|
||||
class="w-[100px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="searchForm.phone"
|
||||
allow-clear
|
||||
placeholder="手机号"
|
||||
class="w-[120px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="companySearchForm.status"
|
||||
placeholder="状态"
|
||||
v-model:value="searchForm.status"
|
||||
allow-clear
|
||||
class="w-[88px]"
|
||||
:options="[
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 },
|
||||
]"
|
||||
placeholder="状态"
|
||||
class="min-w-[88px]"
|
||||
:options="statusOptions"
|
||||
@change="refreshTable"
|
||||
/>
|
||||
<Button type="primary" size="small" @click="searchCompanies">
|
||||
搜索
|
||||
</Button>
|
||||
<Button size="small" @click="resetCompanySearch">重置</Button>
|
||||
</Flex>
|
||||
<Button size="small" @click="refreshTable">查询</Button>
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button type="primary" size="small" @click="handleAdd">
|
||||
<PlusIcon class="mr-1 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<Spin :spinning="companyLoading" class="flex min-h-0 flex-1 flex-col">
|
||||
<div :class="SIDEBAR_LIST_SHELL_CLASS">
|
||||
<button
|
||||
type="button"
|
||||
:class="companyRowClass('all')"
|
||||
@click="selectCompanyAll"
|
||||
>
|
||||
<span class="min-w-0 flex-1 truncate">全部账户</span>
|
||||
<span class="shrink-0 text-xs font-normal text-muted-foreground">
|
||||
全部记录
|
||||
</span>
|
||||
</button>
|
||||
<Empty
|
||||
v-if="!companyLoading && companyList.length === 0"
|
||||
class="py-8"
|
||||
description="暂无公司"
|
||||
/>
|
||||
<div v-else class="space-y-1">
|
||||
<div
|
||||
v-for="company in companyList"
|
||||
:key="company.id"
|
||||
:class="companyRowClass(company.id)"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="min-w-0 flex-1 truncate text-left"
|
||||
@click="selectCompany(company)"
|
||||
>
|
||||
<span class="block truncate">{{ company.name }}</span>
|
||||
<span
|
||||
class="mt-0.5 block truncate text-xs font-normal text-muted-foreground"
|
||||
>
|
||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
||||
</span>
|
||||
</button>
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
class="!h-7 shrink-0 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
|
||||
@click.stop="handleAddForCompany(company)"
|
||||
>
|
||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||
添加
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Flex justify="center" class="mt-2 shrink-0 pt-1">
|
||||
<Pagination
|
||||
v-model:current="companyPagination.current"
|
||||
v-model:page-size="companyPagination.pageSize"
|
||||
:total="companyPagination.total"
|
||||
size="small"
|
||||
:show-size-changer="true"
|
||||
:show-quick-jumper="true"
|
||||
@change="handleCompanyPageChange"
|
||||
/>
|
||||
</Flex>
|
||||
</Spin>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}"
|
||||
<div
|
||||
class="text-muted-foreground shrink-0 border-t border-border px-4 py-2 text-xs"
|
||||
>
|
||||
<template #title>
|
||||
<span class="text-base font-semibold">账户列表</span>
|
||||
</template>
|
||||
<template #extra>
|
||||
<Space wrap size="small" class="max-w-[min(100%,42rem)]">
|
||||
<Input
|
||||
v-model:value="searchForm.username"
|
||||
allow-clear
|
||||
placeholder="登录用户名"
|
||||
class="w-[120px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="searchForm.realName"
|
||||
allow-clear
|
||||
placeholder="姓名"
|
||||
class="w-[100px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="searchForm.phone"
|
||||
allow-clear
|
||||
placeholder="手机号"
|
||||
class="w-[120px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="searchForm.status"
|
||||
allow-clear
|
||||
placeholder="状态"
|
||||
class="min-w-[88px]"
|
||||
:options="statusOptions"
|
||||
@change="refreshTable"
|
||||
/>
|
||||
<Button size="small" @click="refreshTable">查询</Button>
|
||||
</Space>
|
||||
当前:{{ selectedCompanyLabel }}
|
||||
<template v-if="currentCompany">
|
||||
<Tag
|
||||
class="ml-2"
|
||||
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="shrink-0 border-t border-border px-4 py-2 text-xs text-muted-foreground"
|
||||
>
|
||||
当前:{{ selectedCompanyLabel }}
|
||||
<template v-if="currentCompany">
|
||||
<Tag
|
||||
class="ml-2"
|
||||
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
||||
<div
|
||||
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-0 sm:px-3 sm:pb-3"
|
||||
>
|
||||
<Grid :loading="loading" class="h-full min-h-0">
|
||||
<template #toolbar-tools>
|
||||
<span class="text-muted-foreground text-xs">
|
||||
左侧筛选公司;表格在区域内滚动
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #status="{ row }">
|
||||
<Tag :color="getStatusColor(row.status)">
|
||||
{{ getStatusText(row.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-0 sm:px-3 sm:pb-3"
|
||||
>
|
||||
<Grid :loading="loading" class="h-full min-h-0">
|
||||
<template #toolbar-tools>
|
||||
<span class="text-xs text-muted-foreground">
|
||||
使用上方筛选条件查询;表格在区域内滚动
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #status="{ row }">
|
||||
<Tag :color="getStatusColor(row.status)">
|
||||
{{ getStatusText(row.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<template v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="sys:account:update">
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="sys:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</Card>
|
||||
</Flex>
|
||||
<template v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="sys:account:update">
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="sys:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<AccountFormModal ref="accountFormModalRef" @success="handleModalSuccess" />
|
||||
</Page>
|
||||
</CompanyColPage>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user