mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:59:20 +08:00
feat: 系统账户页改搜索表单布局,新增支持下拉选公司部门职位
This commit is contained in:
@@ -53,15 +53,19 @@ export async function deleteDepartmentApi(id: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部部门
|
||||
* 获取全部部门(超管可传 companyId 跨公司)
|
||||
*/
|
||||
export async function getAllDepartmentsApi() {
|
||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/all');
|
||||
export async function getAllDepartmentsApi(companyId?: number) {
|
||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/all', {
|
||||
params: companyId == null ? undefined : { companyId },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门树
|
||||
* 获取部门树(超管可传 companyId 跨公司)
|
||||
*/
|
||||
export async function getDepartmentTreeApi() {
|
||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/tree');
|
||||
export async function getDepartmentTreeApi(companyId?: number) {
|
||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/tree', {
|
||||
params: companyId == null ? undefined : { companyId },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,5 +35,7 @@ export namespace DepartmentDTO {
|
||||
parentId?: number;
|
||||
/** 状态 */
|
||||
status?: number;
|
||||
/** 公司ID(仅超管可跨公司) */
|
||||
companyId?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,7 @@ export namespace PositionDTO {
|
||||
name?: string;
|
||||
/** 状态 */
|
||||
status?: number;
|
||||
/** 公司ID(仅超管可跨公司) */
|
||||
companyId?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 超管账户表单:公司 / 部门 / 职位走列表接口下拉,不必手填 ID。
|
||||
*/
|
||||
import type { CompanyVO } from '#/api/company/types';
|
||||
import type { DepartmentVO } from '#/api/org/department';
|
||||
import type { PositionVO } from '#/api/org/position';
|
||||
import type {
|
||||
SuperAccountDTO,
|
||||
SuperAccountVO,
|
||||
} from '#/api/sys/account';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, message, Select } from 'ant-design-vue';
|
||||
import { Cascader, Form, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import { getCompanyPageApi } from '#/api/company';
|
||||
import { getDepartmentTreeApi } from '#/api/org/department';
|
||||
import { getPositionPageApi } from '#/api/org/position';
|
||||
import {
|
||||
super_createAccountApi,
|
||||
super_updateAccountApi,
|
||||
@@ -20,13 +29,25 @@ interface Emits {
|
||||
(e: 'success'): void;
|
||||
}
|
||||
|
||||
interface DepartmentCascaderOption {
|
||||
children?: DepartmentCascaderOption[];
|
||||
label: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
interface PositionSelectOption {
|
||||
departmentId?: number;
|
||||
label: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'SysAccountFormModal' });
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[500px]',
|
||||
class: 'w-[560px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
@@ -39,7 +60,16 @@ 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 companyOptionsLoading = ref(false);
|
||||
const departmentOptionsLoading = ref(false);
|
||||
const positionOptionsLoading = ref(false);
|
||||
const companyOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const departmentTreeOptions = ref<DepartmentCascaderOption[]>([]);
|
||||
const allPositionOptions = ref<PositionSelectOption[]>([]);
|
||||
const departmentPath = ref<number[]>([]);
|
||||
/** 已加载选项的公司,切换公司时重拉部门/职位 */
|
||||
const loadedOrgCompanyId = ref<number | undefined>(undefined);
|
||||
|
||||
const formData = ref<
|
||||
SuperAccountDTO.SuperCreateAccountDTO & { status?: number }
|
||||
@@ -48,7 +78,7 @@ const formData = ref<
|
||||
password: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
companyId: 0,
|
||||
companyId: undefined as unknown as number,
|
||||
departmentId: undefined,
|
||||
positionId: undefined,
|
||||
isSuper: 0,
|
||||
@@ -64,13 +94,54 @@ const statusOptions = [
|
||||
{ label: '停用', value: 0 },
|
||||
];
|
||||
|
||||
const positionOptions = computed(() => {
|
||||
const selectedDepartmentId = formData.value.departmentId;
|
||||
if (!selectedDepartmentId) return allPositionOptions.value;
|
||||
return allPositionOptions.value.filter(
|
||||
(item) => !item.departmentId || item.departmentId === selectedDepartmentId,
|
||||
);
|
||||
});
|
||||
|
||||
function buildDepartmentTreeOptions(
|
||||
departments: DepartmentVO.DepartmentInfoVO[],
|
||||
): DepartmentCascaderOption[] {
|
||||
return departments.map((item) => ({
|
||||
children:
|
||||
item.children && item.children.length > 0
|
||||
? buildDepartmentTreeOptions(item.children)
|
||||
: undefined,
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}));
|
||||
}
|
||||
|
||||
function findDepartmentPathById(
|
||||
options: DepartmentCascaderOption[],
|
||||
departmentId: number,
|
||||
currentPath: number[] = [],
|
||||
): null | number[] {
|
||||
for (const option of options) {
|
||||
const nextPath = [...currentPath, option.value];
|
||||
if (option.value === departmentId) return nextPath;
|
||||
if (option.children?.length) {
|
||||
const result = findDepartmentPathById(
|
||||
option.children,
|
||||
departmentId,
|
||||
nextPath,
|
||||
);
|
||||
if (result) return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formData.value = {
|
||||
username: '',
|
||||
password: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
companyId: presetCompany.value?.id ?? 0,
|
||||
companyId: undefined as unknown as number,
|
||||
departmentId: undefined,
|
||||
positionId: undefined,
|
||||
isSuper: 0,
|
||||
@@ -78,6 +149,7 @@ function resetForm() {
|
||||
remark: '',
|
||||
status: 1,
|
||||
};
|
||||
departmentPath.value = [];
|
||||
formRef.value?.resetFields();
|
||||
}
|
||||
|
||||
@@ -85,15 +157,147 @@ function handleCancel() {
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
function open(
|
||||
async function loadCompanyOptions() {
|
||||
try {
|
||||
companyOptionsLoading.value = true;
|
||||
const data = await getCompanyPageApi({
|
||||
page: 1,
|
||||
pageSize: 500,
|
||||
filters: {},
|
||||
});
|
||||
companyOptions.value = (data.records || []).map((item) => ({
|
||||
label: item.status === 1 ? item.name : `${item.name}(禁用)`,
|
||||
value: item.id,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('获取公司列表失败:', error);
|
||||
message.error('获取公司列表失败');
|
||||
companyOptions.value = [];
|
||||
} finally {
|
||||
companyOptionsLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDepartmentOptions(companyId: number) {
|
||||
try {
|
||||
departmentOptionsLoading.value = true;
|
||||
const data = await getDepartmentTreeApi(companyId);
|
||||
departmentTreeOptions.value = buildDepartmentTreeOptions(data || []);
|
||||
} catch (error) {
|
||||
console.error('获取部门树失败:', error);
|
||||
message.error('获取部门树失败');
|
||||
departmentTreeOptions.value = [];
|
||||
} finally {
|
||||
departmentOptionsLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPositionOptions(companyId: number) {
|
||||
try {
|
||||
positionOptionsLoading.value = true;
|
||||
const params: PageQueryDTO = {
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
filters: { companyId, status: 1 },
|
||||
};
|
||||
const data = await getPositionPageApi(params);
|
||||
allPositionOptions.value = (data.records || []).map(
|
||||
(item: PositionVO.PositionInfoVO) => ({
|
||||
departmentId: item.departmentId,
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('获取职位列表失败:', error);
|
||||
message.error('获取职位列表失败');
|
||||
allPositionOptions.value = [];
|
||||
} finally {
|
||||
positionOptionsLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadOrgOptionsForCompany(
|
||||
companyId: number,
|
||||
options?: { clearSelection?: boolean },
|
||||
) {
|
||||
if (!companyId) {
|
||||
departmentTreeOptions.value = [];
|
||||
allPositionOptions.value = [];
|
||||
loadedOrgCompanyId.value = undefined;
|
||||
return;
|
||||
}
|
||||
if (
|
||||
loadedOrgCompanyId.value === companyId &&
|
||||
!options?.clearSelection
|
||||
) {
|
||||
return;
|
||||
}
|
||||
await Promise.all([
|
||||
loadDepartmentOptions(companyId),
|
||||
loadPositionOptions(companyId),
|
||||
]);
|
||||
loadedOrgCompanyId.value = companyId;
|
||||
if (options?.clearSelection) {
|
||||
formData.value.departmentId = undefined;
|
||||
formData.value.positionId = undefined;
|
||||
departmentPath.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
function syncDepartmentPathByDepartmentId() {
|
||||
if (!formData.value.departmentId) {
|
||||
departmentPath.value = [];
|
||||
return;
|
||||
}
|
||||
const path = findDepartmentPathById(
|
||||
departmentTreeOptions.value,
|
||||
formData.value.departmentId,
|
||||
);
|
||||
departmentPath.value = path || [];
|
||||
}
|
||||
|
||||
function handleDepartmentChange(value: number[]) {
|
||||
departmentPath.value = value || [];
|
||||
const selectedDepartmentId = departmentPath.value.at(-1);
|
||||
const previousDepartmentId = formData.value.departmentId;
|
||||
formData.value.departmentId = selectedDepartmentId;
|
||||
|
||||
if (
|
||||
previousDepartmentId !== selectedDepartmentId &&
|
||||
formData.value.positionId &&
|
||||
!positionOptions.value.some(
|
||||
(item) => item.value === formData.value.positionId,
|
||||
)
|
||||
) {
|
||||
formData.value.positionId = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCompanyChange(companyId: number | undefined) {
|
||||
formData.value.companyId = companyId as number;
|
||||
if (!companyId) {
|
||||
departmentTreeOptions.value = [];
|
||||
allPositionOptions.value = [];
|
||||
formData.value.departmentId = undefined;
|
||||
formData.value.positionId = undefined;
|
||||
departmentPath.value = [];
|
||||
loadedOrgCompanyId.value = undefined;
|
||||
return;
|
||||
}
|
||||
await loadOrgOptionsForCompany(companyId, { clearSelection: true });
|
||||
}
|
||||
|
||||
async function open(
|
||||
accountData?: null | SuperAccountVO.AccountInfoVO,
|
||||
company?: CompanyVO.CompanyInfoVO | null,
|
||||
) {
|
||||
isEdit.value = !!accountData;
|
||||
currentAccountData.value = accountData || null;
|
||||
presetCompany.value = company || null;
|
||||
loadedOrgCompanyId.value = undefined;
|
||||
|
||||
resetForm();
|
||||
await loadCompanyOptions();
|
||||
|
||||
if (accountData) {
|
||||
formData.value = {
|
||||
@@ -101,7 +305,7 @@ function open(
|
||||
password: '',
|
||||
realName: accountData.realName,
|
||||
phone: accountData.phone || '',
|
||||
companyId: accountData.companyId || presetCompany.value?.id || 0,
|
||||
companyId: accountData.companyId as number,
|
||||
departmentId: accountData.departmentId,
|
||||
positionId: accountData.positionId,
|
||||
isSuper: accountData.isSuper ?? 0,
|
||||
@@ -109,8 +313,13 @@ function open(
|
||||
remark: accountData.remark || '',
|
||||
status: accountData.status ?? 1,
|
||||
};
|
||||
} else if (presetCompany.value) {
|
||||
formData.value.companyId = presetCompany.value.id;
|
||||
} else if (company?.id) {
|
||||
formData.value.companyId = company.id;
|
||||
}
|
||||
|
||||
if (formData.value.companyId) {
|
||||
await loadOrgOptionsForCompany(formData.value.companyId);
|
||||
syncDepartmentPathByDepartmentId();
|
||||
}
|
||||
|
||||
modalApi.open();
|
||||
@@ -126,7 +335,9 @@ async function handleSubmit() {
|
||||
await super_updateAccountApi(currentAccountData.value.id, updateData);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await super_createAccountApi(formData.value);
|
||||
// CreateSysAccountDTO 无 status,创建时剔除
|
||||
const { status: _status, ...createData } = formData.value;
|
||||
await super_createAccountApi(createData);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
@@ -146,12 +357,26 @@ watch(
|
||||
() => modalApi.useStore()?.value?.isOpen,
|
||||
(newVal) => {
|
||||
if (!newVal) {
|
||||
presetCompany.value = null;
|
||||
loadedOrgCompanyId.value = undefined;
|
||||
resetForm();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => formData.value.departmentId,
|
||||
() => {
|
||||
if (
|
||||
formData.value.positionId &&
|
||||
!positionOptions.value.some(
|
||||
(item) => item.value === formData.value.positionId,
|
||||
)
|
||||
) {
|
||||
formData.value.positionId = undefined;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
});
|
||||
@@ -165,8 +390,22 @@ defineExpose({
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item v-if="presetCompany" label="所属公司">
|
||||
<Input :value="presetCompany.name" disabled />
|
||||
<Form.Item
|
||||
label="所属公司"
|
||||
name="companyId"
|
||||
:rules="[{ required: true, message: '请选择所属公司' }]"
|
||||
>
|
||||
<Select
|
||||
:value="formData.companyId || undefined"
|
||||
:loading="companyOptionsLoading"
|
||||
:options="companyOptions"
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
placeholder="请选择公司"
|
||||
allow-clear
|
||||
class="w-full"
|
||||
@change="(v) => handleCompanyChange(v as number | undefined)"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -211,10 +450,6 @@ defineExpose({
|
||||
<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"
|
||||
@@ -226,32 +461,36 @@ defineExpose({
|
||||
<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 label="所属部门" name="departmentId">
|
||||
<Cascader
|
||||
:value="departmentPath"
|
||||
:options="departmentTreeOptions"
|
||||
:loading="departmentOptionsLoading"
|
||||
:disabled="!formData.companyId"
|
||||
placeholder="请先选择公司"
|
||||
:field-names="{
|
||||
label: 'label',
|
||||
value: 'value',
|
||||
children: 'children',
|
||||
}"
|
||||
change-on-select
|
||||
allow-clear
|
||||
class="w-full"
|
||||
@change="(value) => handleDepartmentChange((value || []) as number[])"
|
||||
/>
|
||||
</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
|
||||
<Form.Item label="职位" name="positionId">
|
||||
<Select
|
||||
v-model:value="formData.positionId"
|
||||
type="number"
|
||||
placeholder="请输入职位ID"
|
||||
:loading="positionOptionsLoading"
|
||||
:options="positionOptions"
|
||||
:disabled="!formData.companyId || positionOptionsLoading"
|
||||
placeholder="请先选择公司"
|
||||
allow-clear
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
class="w-full"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
@@ -270,12 +509,8 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="头像图片ID" name="avatarImageId">
|
||||
<Input
|
||||
v-model:value="formData.avatarImageId"
|
||||
type="number"
|
||||
placeholder="请输入头像图片ID"
|
||||
/>
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input v-model:value="formData.remark" placeholder="请输入备注" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item v-if="isEdit" label="状态" name="status">
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 系统账户:左栏筛公司,右栏用 Vxe 搜索表单 + toolbar 新增(对齐反馈页布局)。
|
||||
*/
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { CompanyVO } from '#/api/company/types';
|
||||
import type {
|
||||
@@ -14,10 +17,8 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Input,
|
||||
message,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Tag,
|
||||
} from 'ant-design-vue';
|
||||
@@ -46,13 +47,6 @@ const accountFormModalRef = ref();
|
||||
const selectedCompanyId = ref<number | undefined>(undefined);
|
||||
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
username: 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 },
|
||||
@@ -146,6 +140,52 @@ const accountTableColumns = computed(() =>
|
||||
: (accountTableBaseColumns ?? []),
|
||||
);
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '登录用户名',
|
||||
},
|
||||
fieldName: 'username',
|
||||
label: '用户名',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '真实姓名',
|
||||
},
|
||||
fieldName: 'realName',
|
||||
label: '姓名',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '手机号',
|
||||
},
|
||||
fieldName: 'phone',
|
||||
label: '手机号',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '全部',
|
||||
options: statusOptions,
|
||||
},
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
submitOnChange: true,
|
||||
}));
|
||||
|
||||
const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
columns: accountTableColumns.value,
|
||||
height: '100%',
|
||||
@@ -185,17 +225,17 @@ const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
query: async ({ page }, formValues: Record<string, any> = {}) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<SuperAccountDTO.AccountFilterDTO> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
username: searchForm.value.username || undefined,
|
||||
realName: searchForm.value.realName || undefined,
|
||||
phone: searchForm.value.phone || undefined,
|
||||
status: searchForm.value.status,
|
||||
username: formValues.username?.trim() || undefined,
|
||||
realName: formValues.realName?.trim() || undefined,
|
||||
phone: formValues.phone?.trim() || undefined,
|
||||
status: formValues.status,
|
||||
companyId: currentCompany.value?.id,
|
||||
},
|
||||
};
|
||||
@@ -219,7 +259,8 @@ const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '账户列表',
|
||||
});
|
||||
syncVxeGridColumns(gridApi, accountTableColumns);
|
||||
@@ -233,11 +274,8 @@ function refreshTable() {
|
||||
gridApi?.reload();
|
||||
}
|
||||
|
||||
/** 新增:不必先选左栏公司,表单内自选;左栏有选中时作默认值 */
|
||||
function handleAdd() {
|
||||
if (!currentCompany.value) {
|
||||
message.warning('请先选择具体公司,或在公司行点击「添加」');
|
||||
return;
|
||||
}
|
||||
accountFormModalRef.value?.open(undefined, currentCompany.value);
|
||||
}
|
||||
|
||||
@@ -310,71 +348,32 @@ watch(currentCompany, () => {
|
||||
}"
|
||||
>
|
||||
<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="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>
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button type="primary" size="small" @click="handleAdd">
|
||||
<PlusIcon class="mr-1 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<div
|
||||
class="text-muted-foreground shrink-0 border-t border-border px-4 py-2 text-xs"
|
||||
>
|
||||
当前:{{ selectedCompanyLabel }}
|
||||
<template v-if="currentCompany">
|
||||
<div class="flex min-w-0 items-center gap-2">
|
||||
<span class="text-base font-semibold">账户列表</span>
|
||||
<span class="text-muted-foreground truncate text-xs font-normal">
|
||||
当前:{{ selectedCompanyLabel }}
|
||||
</span>
|
||||
<Tag
|
||||
class="ml-2"
|
||||
v-if="currentCompany"
|
||||
class="m-0"
|
||||
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<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>
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-1 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</template>
|
||||
|
||||
<template #status="{ row }">
|
||||
|
||||
Reference in New Issue
Block a user