mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 09:49:20 +08:00
refactor(web-antd): 超管账户与公司菜单/权限页改为两栏布局,并统一左侧列表托盘与卡片样式
This commit is contained in:
+26
-25
@@ -1,4 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CompanyVO } from '#/api/organization/company/types';
|
||||
import type {
|
||||
SuperAccountDTO,
|
||||
SuperAccountVO,
|
||||
@@ -23,7 +24,6 @@ defineOptions({ name: 'SuperAccountFormModal' });
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[500px]',
|
||||
@@ -35,13 +35,12 @@ const [Modal, modalApi] = useVbenModal({
|
||||
},
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const formRef = ref();
|
||||
const loading = ref(false);
|
||||
const isEdit = ref(false);
|
||||
const currentAccountData = ref<null | SuperAccountVO.AccountInfoVO>(null);
|
||||
const presetCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<
|
||||
SuperAccountDTO.SuperCreateAccountDTO & { status?: number }
|
||||
>({
|
||||
@@ -55,70 +54,68 @@ const formData = ref<
|
||||
role: '',
|
||||
avatarImageId: undefined,
|
||||
remark: '',
|
||||
status: 0,
|
||||
status: 1,
|
||||
});
|
||||
|
||||
// 模态框标题
|
||||
const modalTitle = computed(() => (isEdit.value ? '编辑账户' : '添加账户'));
|
||||
|
||||
// 状态选项
|
||||
const statusOptions = [
|
||||
{ label: '正常', value: 0 },
|
||||
{ label: '删除', value: 1 },
|
||||
{ label: '停用', value: 2 },
|
||||
{ label: '冻结', value: 3 },
|
||||
{ label: '正常', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
];
|
||||
|
||||
// 重置表单
|
||||
function resetForm() {
|
||||
formData.value = {
|
||||
loginCode: '',
|
||||
password: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
companyId: 0,
|
||||
companyId: presetCompany.value?.id ?? 0,
|
||||
departmentId: undefined,
|
||||
positionId: undefined,
|
||||
role: '',
|
||||
avatarImageId: undefined,
|
||||
remark: '',
|
||||
status: 0,
|
||||
status: 1,
|
||||
};
|
||||
formRef.value?.resetFields();
|
||||
}
|
||||
|
||||
// 处理模态框关闭
|
||||
function handleCancel() {
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
// 暴露给父组件的方法
|
||||
function open(accountData?: null | SuperAccountVO.AccountInfoVO) {
|
||||
function open(
|
||||
accountData?: null | SuperAccountVO.AccountInfoVO,
|
||||
company?: CompanyVO.CompanyInfoVO | null,
|
||||
) {
|
||||
isEdit.value = !!accountData;
|
||||
currentAccountData.value = accountData || null;
|
||||
presetCompany.value = company || null;
|
||||
|
||||
resetForm();
|
||||
|
||||
if (accountData) {
|
||||
formData.value = {
|
||||
loginCode: accountData.loginCode,
|
||||
password: '', // 编辑时密码为空
|
||||
password: '',
|
||||
realName: accountData.realName,
|
||||
phone: accountData.phone || '',
|
||||
companyId: accountData.companyId || 0,
|
||||
companyId: accountData.companyId || presetCompany.value?.id || 0,
|
||||
departmentId: accountData.departmentId,
|
||||
positionId: accountData.positionId,
|
||||
role: accountData.role || '',
|
||||
avatarImageId: accountData.avatarImageId,
|
||||
remark: accountData.remark || '',
|
||||
status: accountData.status,
|
||||
status: accountData.status ?? 1,
|
||||
};
|
||||
} else if (presetCompany.value) {
|
||||
formData.value.companyId = presetCompany.value.id;
|
||||
}
|
||||
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
// 处理表单提交
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
@@ -137,25 +134,24 @@ async function handleSubmit() {
|
||||
modalApi.close();
|
||||
} catch (error: any) {
|
||||
console.error('保存账户失败:', error);
|
||||
const errorMessage =
|
||||
error?.response?.data?.message || error?.message || '保存账户失败';
|
||||
message.error(errorMessage);
|
||||
message.error(
|
||||
error?.response?.data?.message || error?.message || '保存账户失败',
|
||||
);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 监听 modal 关闭状态
|
||||
watch(
|
||||
() => modalApi.useStore()?.value?.isOpen,
|
||||
(newVal) => {
|
||||
if (!newVal) {
|
||||
presetCompany.value = null;
|
||||
resetForm();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
open,
|
||||
});
|
||||
@@ -169,6 +165,10 @@ defineExpose({
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item v-if="presetCompany" label="所属公司">
|
||||
<Input :value="presetCompany.name" disabled />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="登录账号"
|
||||
name="loginCode"
|
||||
@@ -224,6 +224,7 @@ defineExpose({
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
v-if="!presetCompany"
|
||||
label="公司ID"
|
||||
name="companyId"
|
||||
:rules="[{ required: true, message: '请输入公司ID' }]"
|
||||
|
||||
@@ -1,144 +1,131 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { CompanyVO } from '#/api/organization/company/types';
|
||||
import type {
|
||||
SuperAccountDTO,
|
||||
SuperAccountVO,
|
||||
} from '#/api/organization/account-super';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
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/organization/company';
|
||||
import {
|
||||
super_deleteAccountApi,
|
||||
super_getAccountPageApi,
|
||||
} from '#/api/organization/account-super';
|
||||
|
||||
import SuperAccountFormModal from './components/SuperAccountFormModal.vue';
|
||||
import {
|
||||
SIDEBAR_LIST_SHELL_CLASS,
|
||||
sidebarListRowClass,
|
||||
} from '#/utils/sidebar-list-styles';
|
||||
|
||||
defineOptions({ name: 'SuperAccountManagement' });
|
||||
|
||||
// 创建图标组件
|
||||
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 currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
loginCode: undefined as string | undefined,
|
||||
realName: undefined as string | undefined,
|
||||
phone: undefined as string | undefined,
|
||||
companyId: undefined as number | undefined,
|
||||
departmentId: undefined as number | undefined,
|
||||
positionId: undefined as number | undefined,
|
||||
role: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
});
|
||||
|
||||
// 状态选项
|
||||
const statusOptions = [
|
||||
{ label: '正常', value: 0 },
|
||||
{ label: '删除', value: 1 },
|
||||
{ label: '停用', value: 2 },
|
||||
{ label: '冻结', value: 3 },
|
||||
{ label: '正常', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
];
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schemas: [
|
||||
{
|
||||
fieldName: 'loginCode',
|
||||
label: '登录账号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入登录账号(回车搜索)',
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'realName',
|
||||
label: '真实姓名',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入真实姓名(回车搜索)',
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'phone',
|
||||
label: '手机号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入手机号(回车搜索)',
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: statusOptions,
|
||||
placeholder: '请选择状态',
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
const selectedCompanyLabel = computed(() => {
|
||||
if (!currentCompany.value) {
|
||||
return '全部账户';
|
||||
}
|
||||
return currentCompany.value.name;
|
||||
});
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
title: '序号',
|
||||
},
|
||||
{ type: 'seq' as const, minWidth: 56, title: '序号' },
|
||||
{
|
||||
field: 'loginCode',
|
||||
title: '登录账号',
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'realName',
|
||||
title: '真实姓名',
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'phone',
|
||||
title: '手机号',
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'companyName',
|
||||
title: '公司',
|
||||
minWidth: 150,
|
||||
minWidth: 140,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'departmentName',
|
||||
title: '部门',
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'positionName',
|
||||
title: '职位',
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'role',
|
||||
title: '角色',
|
||||
minWidth: 100,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
@@ -150,15 +137,16 @@ const gridOptions: VxeGridProps<any> = {
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 160,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
minWidth: 140,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
height: '100%',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true },
|
||||
@@ -193,7 +181,6 @@ const gridOptions: VxeGridProps<any> = {
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
@@ -202,7 +189,13 @@ const gridOptions: VxeGridProps<any> = {
|
||||
const params: PageQueryDTO<SuperAccountDTO.AccountFilterDTO> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...searchForm.value,
|
||||
filters: {
|
||||
loginCode: searchForm.value.loginCode || undefined,
|
||||
realName: searchForm.value.realName || undefined,
|
||||
phone: searchForm.value.phone || undefined,
|
||||
status: searchForm.value.status,
|
||||
companyId: currentCompany.value?.id,
|
||||
},
|
||||
};
|
||||
const response = await super_getAccountPageApi(params);
|
||||
return {
|
||||
@@ -210,14 +203,10 @@ const gridOptions: VxeGridProps<any> = {
|
||||
total: response.total,
|
||||
};
|
||||
} catch (error: any) {
|
||||
console.error('查询数据失败:', error);
|
||||
const errorMessage =
|
||||
error?.response?.data?.message || error?.message || '查询数据失败';
|
||||
message.error(errorMessage);
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
message.error(
|
||||
error?.response?.data?.message || error?.message || '查询数据失败',
|
||||
);
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -226,145 +215,344 @@ const gridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
|
||||
// 表格实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '超级账户管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 计算属性
|
||||
const hasSelected = computed(() => {
|
||||
const vxeTable = (gridApi as any).grid;
|
||||
return vxeTable?.getCheckboxRecords?.()?.length > 0;
|
||||
showSearchForm: false,
|
||||
tableTitle: '账户列表',
|
||||
});
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
if (gridApi) {
|
||||
gridApi.reload();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
const handleAdd = () => {
|
||||
accountFormModalRef.value?.open();
|
||||
};
|
||||
function resetCompanySearch() {
|
||||
companySearchForm.value = { name: '', status: undefined };
|
||||
companyPagination.value.current = 1;
|
||||
searchCompanies();
|
||||
}
|
||||
|
||||
const handleEdit = (row: SuperAccountVO.AccountInfoVO) => {
|
||||
accountFormModalRef.value?.open(row);
|
||||
};
|
||||
function handleCompanyPageChange(page: number, pageSize: number) {
|
||||
companyPagination.value.current = page;
|
||||
companyPagination.value.pageSize = pageSize;
|
||||
searchCompanies();
|
||||
}
|
||||
|
||||
const handleDelete = async (row: SuperAccountVO.AccountInfoVO) => {
|
||||
function selectCompanyAll() {
|
||||
currentCompany.value = null;
|
||||
}
|
||||
|
||||
function selectCompany(company: CompanyVO.CompanyInfoVO) {
|
||||
currentCompany.value = company;
|
||||
}
|
||||
|
||||
function refreshTable() {
|
||||
gridApi?.reload();
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
if (!currentCompany.value) {
|
||||
message.warning('请先选择具体公司,或在公司行点击「添加」');
|
||||
return;
|
||||
}
|
||||
accountFormModalRef.value?.open(undefined, currentCompany.value);
|
||||
}
|
||||
|
||||
function handleAddForCompany(company: CompanyVO.CompanyInfoVO) {
|
||||
selectCompany(company);
|
||||
accountFormModalRef.value?.open(undefined, company);
|
||||
}
|
||||
|
||||
function handleEdit(row: SuperAccountVO.AccountInfoVO) {
|
||||
accountFormModalRef.value?.open(row, currentCompany.value);
|
||||
}
|
||||
|
||||
async function handleDelete(row: SuperAccountVO.AccountInfoVO) {
|
||||
try {
|
||||
await super_deleteAccountApi(row.id);
|
||||
message.success('删除成功');
|
||||
refreshTable();
|
||||
} catch (error: any) {
|
||||
console.error('删除失败:', error);
|
||||
const errorMessage =
|
||||
error?.response?.data?.message || error?.message || '删除失败';
|
||||
message.error(errorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
const handleBatchDelete = async () => {
|
||||
const vxeTable = (gridApi as any).grid;
|
||||
const selectedRows = vxeTable?.getCheckboxRecords?.();
|
||||
if (!selectedRows?.length) {
|
||||
message.warning('请选择要删除的数据');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const deletePromises = selectedRows.map(
|
||||
(row: SuperAccountVO.AccountInfoVO) => super_deleteAccountApi(row.id),
|
||||
message.error(
|
||||
error?.response?.data?.message || error?.message || '删除失败',
|
||||
);
|
||||
await Promise.all(deletePromises);
|
||||
message.success(`成功删除 ${selectedRows.length} 条记录`);
|
||||
refreshTable();
|
||||
} catch (error: any) {
|
||||
console.error('批量删除失败:', error);
|
||||
const errorMessage =
|
||||
error?.response?.data?.message || error?.message || '批量删除失败';
|
||||
message.error(errorMessage);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 处理模态框成功回调
|
||||
function handleModalSuccess() {
|
||||
refreshTable();
|
||||
}
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status: number) => {
|
||||
const statusMap = {
|
||||
0: '正常',
|
||||
1: '删除',
|
||||
2: '停用',
|
||||
3: '冻结',
|
||||
function getStatusText(status: number) {
|
||||
const statusMap: Record<number, string> = {
|
||||
0: '停用',
|
||||
1: '正常',
|
||||
};
|
||||
return statusMap[status as keyof typeof statusMap] || '未知';
|
||||
};
|
||||
return statusMap[status] || '未知';
|
||||
}
|
||||
|
||||
// 获取状态颜色
|
||||
const getStatusColor = (status: number) => {
|
||||
const colorMap = {
|
||||
0: 'green',
|
||||
1: 'red',
|
||||
2: 'orange',
|
||||
3: 'purple',
|
||||
function getStatusColor(status: number) {
|
||||
const colorMap: Record<number, string> = {
|
||||
0: 'orange',
|
||||
1: 'green',
|
||||
};
|
||||
return colorMap[status as keyof typeof colorMap] || 'default';
|
||||
};
|
||||
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>
|
||||
<Page title="超级账户管理" :auto-content-height="true">
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理超级管理员账户信息,支持账户的增删改查操作
|
||||
左侧选择公司筛选右侧账户;首项「全部账户」展示所有账户,可在公司行快捷新增。
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- VbenVxeGrid 表格 -->
|
||||
<Grid :loading="loading">
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加账户
|
||||
<template #extra>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
</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">
|
||||
<Input
|
||||
v-model:value="companySearchForm.name"
|
||||
placeholder="公司名称"
|
||||
allow-clear
|
||||
class="min-w-[140px] flex-1"
|
||||
@press-enter="searchCompanies"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="companySearchForm.status"
|
||||
placeholder="状态"
|
||||
allow-clear
|
||||
class="w-[88px]"
|
||||
:options="[
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 },
|
||||
]"
|
||||
/>
|
||||
<Button type="primary" size="small" @click="searchCompanies">
|
||||
搜索
|
||||
</Button>
|
||||
<Button v-if="hasSelected" danger @click="handleBatchDelete">
|
||||
批量删除
|
||||
</Button>
|
||||
</Space>
|
||||
</template>
|
||||
<Button size="small" @click="resetCompanySearch">重置</Button>
|
||||
</Flex>
|
||||
|
||||
<!-- 状态列 -->
|
||||
<template #status="{ row }">
|
||||
<Tag :color="getStatusColor(row.status)">
|
||||
{{ getStatusText(row.status) }}
|
||||
</Tag>
|
||||
</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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
<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',
|
||||
}"
|
||||
>
|
||||
<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.loginCode"
|
||||
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>
|
||||
</template>
|
||||
|
||||
<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 ? '启用' : '禁用' }}
|
||||
</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 #action="{ row }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</Card>
|
||||
</Flex>
|
||||
|
||||
<!-- 账户表单弹窗 -->
|
||||
<SuperAccountFormModal
|
||||
ref="accountFormModalRef"
|
||||
@success="handleModalSuccess"
|
||||
|
||||
Reference in New Issue
Block a user