mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 01:09:19 +08:00
refactor: 拆分公司/系统账户权限与模块,系统账户迁至 sys/account 并更新菜单
This commit is contained in:
-287
@@ -1,287 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CompanyVO } from '#/api/company/types';
|
||||
import type {
|
||||
SuperAccountDTO,
|
||||
SuperAccountVO,
|
||||
} from '#/api/sys/account';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
super_createAccountApi,
|
||||
super_updateAccountApi,
|
||||
} from '#/api/sys/account';
|
||||
|
||||
interface Emits {
|
||||
(e: 'success'): void;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'SuperAccountFormModal' });
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[500px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleSubmit();
|
||||
},
|
||||
});
|
||||
|
||||
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 }
|
||||
>({
|
||||
loginCode: '',
|
||||
password: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
companyId: 0,
|
||||
departmentId: undefined,
|
||||
positionId: undefined,
|
||||
isSuper: 0,
|
||||
avatarImageId: undefined,
|
||||
remark: '',
|
||||
status: 1,
|
||||
});
|
||||
|
||||
const modalTitle = computed(() => (isEdit.value ? '编辑账户' : '添加账户'));
|
||||
|
||||
const statusOptions = [
|
||||
{ label: '正常', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
];
|
||||
|
||||
function resetForm() {
|
||||
formData.value = {
|
||||
loginCode: '',
|
||||
password: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
companyId: presetCompany.value?.id ?? 0,
|
||||
departmentId: undefined,
|
||||
positionId: undefined,
|
||||
isSuper: 0,
|
||||
avatarImageId: undefined,
|
||||
remark: '',
|
||||
status: 1,
|
||||
};
|
||||
formRef.value?.resetFields();
|
||||
}
|
||||
|
||||
function handleCancel() {
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
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: '',
|
||||
realName: accountData.realName,
|
||||
phone: accountData.phone || '',
|
||||
companyId: accountData.companyId || presetCompany.value?.id || 0,
|
||||
departmentId: accountData.departmentId,
|
||||
positionId: accountData.positionId,
|
||||
isSuper: accountData.isSuper ?? 0,
|
||||
avatarImageId: accountData.avatarImageId,
|
||||
remark: accountData.remark || '',
|
||||
status: accountData.status ?? 1,
|
||||
};
|
||||
} else if (presetCompany.value) {
|
||||
formData.value.companyId = presetCompany.value.id;
|
||||
}
|
||||
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
loading.value = true;
|
||||
|
||||
if (isEdit.value && currentAccountData.value) {
|
||||
const { password: _, ...updateData } = formData.value;
|
||||
await super_updateAccountApi(currentAccountData.value.id, updateData);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await super_createAccountApi(formData.value);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
} catch (error: any) {
|
||||
console.error('保存账户失败:', error);
|
||||
message.error(
|
||||
error?.response?.data?.message || error?.message || '保存账户失败',
|
||||
);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => modalApi.useStore()?.value?.isOpen,
|
||||
(newVal) => {
|
||||
if (!newVal) {
|
||||
presetCompany.value = null;
|
||||
resetForm();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="modalTitle" :confirm-loading="loading">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
: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"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入登录账号' },
|
||||
{ min: 3, max: 20, message: '登录账号长度为3-20个字符' },
|
||||
{
|
||||
pattern: /^[a-zA-Z0-9_]+$/,
|
||||
message: '登录账号只能包含字母、数字和下划线',
|
||||
},
|
||||
]"
|
||||
>
|
||||
<Input
|
||||
v-model:value="formData.loginCode"
|
||||
placeholder="请输入登录账号"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
v-if="!isEdit"
|
||||
label="密码"
|
||||
name="password"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入密码' },
|
||||
{ min: 6, max: 20, message: '密码长度为6-20个字符' },
|
||||
]"
|
||||
>
|
||||
<Input
|
||||
v-model:value="formData.password"
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="真实姓名"
|
||||
name="realName"
|
||||
:rules="[{ required: true, message: '请输入真实姓名' }]"
|
||||
>
|
||||
<Input v-model:value="formData.realName" placeholder="请输入真实姓名" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input v-model:value="formData.remark" placeholder="请输入备注" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="手机号"
|
||||
name="phone"
|
||||
:rules="[{ pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号' }]"
|
||||
>
|
||||
<Input v-model:value="formData.phone" placeholder="请输入手机号" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
v-if="!presetCompany"
|
||||
label="公司ID"
|
||||
name="companyId"
|
||||
:rules="[{ required: true, message: '请输入公司ID' }]"
|
||||
>
|
||||
<Input
|
||||
v-model:value="formData.companyId"
|
||||
type="number"
|
||||
placeholder="请输入公司ID"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="部门ID" name="departmentId">
|
||||
<Input
|
||||
v-model:value="formData.departmentId"
|
||||
type="number"
|
||||
placeholder="请输入部门ID"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="职位ID" name="positionId">
|
||||
<Input
|
||||
v-model:value="formData.positionId"
|
||||
type="number"
|
||||
placeholder="请输入职位ID"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="是否超管"
|
||||
name="isSuper"
|
||||
:rules="[{ required: true, message: '请选择是否超管' }]"
|
||||
>
|
||||
<Select
|
||||
v-model:value="formData.isSuper"
|
||||
placeholder="请选择是否超管"
|
||||
:options="[
|
||||
{ label: '否', value: 0 },
|
||||
{ label: '是', value: 1 },
|
||||
]"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="头像图片ID" name="avatarImageId">
|
||||
<Input
|
||||
v-model:value="formData.avatarImageId"
|
||||
type="number"
|
||||
placeholder="请输入头像图片ID"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item v-if="isEdit" label="状态" name="status">
|
||||
<Select
|
||||
v-model:value="formData.status"
|
||||
placeholder="请选择状态"
|
||||
:options="statusOptions"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -1,594 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { CompanyVO } from '#/api/company/types';
|
||||
import type {
|
||||
SuperAccountDTO,
|
||||
SuperAccountVO,
|
||||
} from '#/api/sys/account';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, 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 SuperAccountFormModal from './components/SuperAccountFormModal.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';
|
||||
|
||||
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,
|
||||
status: undefined as number | undefined,
|
||||
});
|
||||
|
||||
const statusOptions = [
|
||||
{ label: '正常', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
];
|
||||
|
||||
const selectedCompanyLabel = computed(() => {
|
||||
if (!currentCompany.value) {
|
||||
return '全部账户';
|
||||
}
|
||||
return currentCompany.value.name;
|
||||
});
|
||||
|
||||
const accountActionCodes = [
|
||||
'org:account:create',
|
||||
'org:account:update',
|
||||
'org:account:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(accountActionCodes);
|
||||
|
||||
const accountTableBaseColumns: VxeGridProps<SuperAccountVO.AccountInfoVO>['columns'] =
|
||||
[
|
||||
{ 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: 140,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'departmentName',
|
||||
title: '部门',
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'positionName',
|
||||
title: '职位',
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'isSuperName',
|
||||
title: '超管',
|
||||
minWidth: 100,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
minWidth: 80,
|
||||
slots: { default: 'status' },
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 160,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
];
|
||||
|
||||
const accountActionColumn: NonNullable<
|
||||
VxeGridProps<SuperAccountVO.AccountInfoVO>['columns']
|
||||
>[number] = {
|
||||
title: '操作',
|
||||
minWidth: 140,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const accountTableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(accountTableBaseColumns ?? []), accountActionColumn]
|
||||
: (accountTableBaseColumns ?? []),
|
||||
);
|
||||
|
||||
const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
columns: accountTableColumns.value,
|
||||
height: '100%',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true },
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
data: [],
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<SuperAccountDTO.AccountFilterDTO> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
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 {
|
||||
items: response.records,
|
||||
total: response.total,
|
||||
};
|
||||
} catch (error: any) {
|
||||
message.error(
|
||||
error?.response?.data?.message || error?.message || '查询数据失败',
|
||||
);
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
tableTitle: '账户列表',
|
||||
});
|
||||
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) {
|
||||
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) {
|
||||
message.error(
|
||||
error?.response?.data?.message || error?.message || '删除失败',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function handleModalSuccess() {
|
||||
refreshTable();
|
||||
}
|
||||
|
||||
function getStatusText(status: number) {
|
||||
const statusMap: Record<number, string> = {
|
||||
0: '停用',
|
||||
1: '正常',
|
||||
};
|
||||
return statusMap[status] || '未知';
|
||||
}
|
||||
|
||||
function getStatusColor(status: number) {
|
||||
const colorMap: Record<number, string> = {
|
||||
0: 'orange',
|
||||
1: 'green',
|
||||
};
|
||||
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="org: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">
|
||||
<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 size="small" @click="resetCompanySearch">重置</Button>
|
||||
</Flex>
|
||||
|
||||
<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="org: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',
|
||||
}"
|
||||
>
|
||||
<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 v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="org:account:update">
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</Card>
|
||||
</Flex>
|
||||
|
||||
<SuperAccountFormModal
|
||||
ref="accountFormModalRef"
|
||||
@success="handleModalSuccess"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -57,9 +57,9 @@ const statusOptions = [
|
||||
];
|
||||
|
||||
const accountActionCodes = [
|
||||
'org:account:create',
|
||||
'org:account:update',
|
||||
'org:account:delete',
|
||||
'org:company:account:create',
|
||||
'org:company:account:update',
|
||||
'org:company:account:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(accountActionCodes);
|
||||
|
||||
@@ -374,13 +374,13 @@ function handleModalSuccess() {
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<PermissionGate code="org:account:create">
|
||||
<PermissionGate code="org:company:account:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:account:delete">
|
||||
<PermissionGate code="org:company:account:delete">
|
||||
<Button v-if="hasSelected" danger @click="handleBatchDelete">
|
||||
批量删除
|
||||
</Button>
|
||||
@@ -405,10 +405,10 @@ function handleModalSuccess() {
|
||||
<!-- 操作列 -->
|
||||
<template v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="org:account:update">
|
||||
<PermissionGate code="org:company:account:update">
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:account:delete">
|
||||
<PermissionGate code="org:company:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
|
||||
Reference in New Issue
Block a user