|
@@ -1,27 +1,20 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
-import { useAccess } from '@vben/access';
|
|
|
|
|
|
|
+import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter';
|
|
|
|
|
+
|
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
|
|
|
|
|
|
|
import { useClipboard } from '@vueuse/core';
|
|
import { useClipboard } from '@vueuse/core';
|
|
|
import { Button, message, Modal } from 'ant-design-vue';
|
|
import { Button, message, Modal } from 'ant-design-vue';
|
|
|
|
|
|
|
|
-import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
|
|
|
|
|
+import { useTableGridOptions, useVbenVxeGrid } from '#/adapter';
|
|
|
import { RoleApi, UserApi } from '#/api';
|
|
import { RoleApi, UserApi } from '#/api';
|
|
|
import { SelectCard } from '#/components/select-card';
|
|
import { SelectCard } from '#/components/select-card';
|
|
|
-import { TableAction } from '#/components/table-action';
|
|
|
|
|
|
|
|
|
|
import FormEdit from './components/edit.vue';
|
|
import FormEdit from './components/edit.vue';
|
|
|
-import { gridOptions, searchFormOptions } from './data.config';
|
|
|
|
|
-
|
|
|
|
|
-const { hasAccessByCodes } = useAccess();
|
|
|
|
|
|
|
+import { useColumns, useSearchSchema } from './data.config';
|
|
|
|
|
|
|
|
const { copy } = useClipboard({ legacy: true });
|
|
const { copy } = useClipboard({ legacy: true });
|
|
|
|
|
|
|
|
-const [Grid, { reload }] = useVbenVxeGrid({
|
|
|
|
|
- formOptions: searchFormOptions,
|
|
|
|
|
- gridOptions,
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
const [FormEditModal, formEditApi] = useVbenModal({
|
|
const [FormEditModal, formEditApi] = useVbenModal({
|
|
|
connectedComponent: FormEdit,
|
|
connectedComponent: FormEdit,
|
|
|
});
|
|
});
|
|
@@ -30,39 +23,23 @@ const [SelectCardModal, selectCardApi] = useVbenModal({
|
|
|
connectedComponent: SelectCard,
|
|
connectedComponent: SelectCard,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-const handelResetPassword = (id: number) => {
|
|
|
|
|
- Modal.confirm({
|
|
|
|
|
- iconType: 'info',
|
|
|
|
|
- title: '重置密码提示',
|
|
|
|
|
- content: `确定要重置选择的记录吗?`,
|
|
|
|
|
- cancelText: `关闭`,
|
|
|
|
|
- onOk: async () => {
|
|
|
|
|
- const data = await UserApi.resetPassword([id]);
|
|
|
|
|
- Modal.success({
|
|
|
|
|
- title: '重置成功',
|
|
|
|
|
- content: `新密码为:${data}`,
|
|
|
|
|
- okText: `复制密码`,
|
|
|
|
|
- onOk: () => {
|
|
|
|
|
- copy(data);
|
|
|
|
|
- message.success('密码复制成功!');
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
|
|
+const handelResetPassword = async (id: number) => {
|
|
|
|
|
+ const data = await UserApi.resetPassword([id]);
|
|
|
|
|
+ Modal.success({
|
|
|
|
|
+ title: '重置成功',
|
|
|
|
|
+ content: `新密码为:${data}`,
|
|
|
|
|
+ okText: `复制密码`,
|
|
|
|
|
+ onOk: () => {
|
|
|
|
|
+ copy(data);
|
|
|
|
|
+ message.success('密码复制成功!');
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const handleDelete = (id: number) => {
|
|
|
|
|
- Modal.confirm({
|
|
|
|
|
- iconType: 'info',
|
|
|
|
|
- title: '删除提示',
|
|
|
|
|
- content: `确定要删除选择的记录吗?`,
|
|
|
|
|
- cancelText: `关闭`,
|
|
|
|
|
- onOk: async () => {
|
|
|
|
|
- await UserApi.deleteDetail(id);
|
|
|
|
|
- message.success('数据删除成功');
|
|
|
|
|
- reload();
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
|
|
+const handleDelete = async (id: number) => {
|
|
|
|
|
+ await UserApi.deleteDetail(id);
|
|
|
|
|
+ message.success('数据删除成功');
|
|
|
|
|
+ reload();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleUpdateStatus = async (record: any) => {
|
|
const handleUpdateStatus = async (record: any) => {
|
|
@@ -74,35 +51,35 @@ const handleUpdateStatus = async (record: any) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleEdit = (record: any, isUpdate: boolean) => {
|
|
const handleEdit = (record: any, isUpdate: boolean) => {
|
|
|
- formEditApi.setData({
|
|
|
|
|
- isUpdate,
|
|
|
|
|
- baseData: { id: record.id },
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- formEditApi.open();
|
|
|
|
|
|
|
+ formEditApi
|
|
|
|
|
+ .setData({
|
|
|
|
|
+ isUpdate,
|
|
|
|
|
+ baseData: { id: record.id },
|
|
|
|
|
+ })
|
|
|
|
|
+ .open();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handelGrantRole = async (id: number) => {
|
|
const handelGrantRole = async (id: number) => {
|
|
|
const selectedIds = await UserApi.getRoleIds(id);
|
|
const selectedIds = await UserApi.getRoleIds(id);
|
|
|
- selectCardApi.setData({
|
|
|
|
|
- baseData: {
|
|
|
|
|
- key: id,
|
|
|
|
|
- selectedIds,
|
|
|
|
|
- fieldNames: [
|
|
|
|
|
- { label: '编号', value: 'code', maxLength: 12 },
|
|
|
|
|
- { label: '名称', value: 'name', maxLength: 8 },
|
|
|
|
|
- ],
|
|
|
|
|
- config: {
|
|
|
|
|
- type: 'role',
|
|
|
|
|
- },
|
|
|
|
|
- api: {
|
|
|
|
|
- url: RoleApi.getPage,
|
|
|
|
|
|
|
+ selectCardApi
|
|
|
|
|
+ .setData({
|
|
|
|
|
+ baseData: {
|
|
|
|
|
+ key: id,
|
|
|
|
|
+ selectedIds,
|
|
|
|
|
+ fieldNames: [
|
|
|
|
|
+ { label: '编号', value: 'code', maxLength: 12 },
|
|
|
|
|
+ { label: '名称', value: 'name', maxLength: 8 },
|
|
|
|
|
+ ],
|
|
|
|
|
+ config: {
|
|
|
|
|
+ type: 'role',
|
|
|
|
|
+ },
|
|
|
|
|
+ api: {
|
|
|
|
|
+ url: RoleApi.getPage,
|
|
|
|
|
+ },
|
|
|
|
|
+ searchName: 'name',
|
|
|
},
|
|
},
|
|
|
- searchName: 'name',
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- selectCardApi.open();
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ .open();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handelSuccess = () => {
|
|
const handelSuccess = () => {
|
|
@@ -113,6 +90,56 @@ const handelRoleSuccess = async (data: any) => {
|
|
|
await UserApi.updateGrantRole({ id: data.key, relationIds: data.ids });
|
|
await UserApi.updateGrantRole({ id: data.key, relationIds: data.ids });
|
|
|
message.success('授权成功');
|
|
message.success('授权成功');
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+const handleActionClick = async ({
|
|
|
|
|
+ code,
|
|
|
|
|
+ row,
|
|
|
|
|
+}: OnActionClickParams<UserApi.RecordItem>) => {
|
|
|
|
|
+ switch (code) {
|
|
|
|
|
+ case 'delete': {
|
|
|
|
|
+ await handleDelete(row.id);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case 'edit': {
|
|
|
|
|
+ handleEdit(row, true);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case 'grantRole': {
|
|
|
|
|
+ handelGrantRole(row.id);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case 'resetPwd': {
|
|
|
|
|
+ handelResetPassword(row.id);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case 'setStatus': {
|
|
|
|
|
+ await handleUpdateStatus(row);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const [Grid, { reload }] = useVbenVxeGrid(
|
|
|
|
|
+ useTableGridOptions({
|
|
|
|
|
+ formOptions: {
|
|
|
|
|
+ schema: useSearchSchema(),
|
|
|
|
|
+ },
|
|
|
|
|
+ gridOptions: {
|
|
|
|
|
+ columns: useColumns(handleActionClick),
|
|
|
|
|
+ proxyConfig: {
|
|
|
|
|
+ ajax: {
|
|
|
|
|
+ query: async ({ page }, formValues) => {
|
|
|
|
|
+ return await UserApi.getPage({
|
|
|
|
|
+ pageIndex: page.currentPage,
|
|
|
|
|
+ pageSize: page.pageSize,
|
|
|
|
|
+ ...formValues,
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ } as VxeTableGridOptions,
|
|
|
|
|
+ }),
|
|
|
|
|
+);
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|
|
@@ -134,45 +161,6 @@ const handelRoleSuccess = async (data: any) => {
|
|
|
新增用户
|
|
新增用户
|
|
|
</Button>
|
|
</Button>
|
|
|
</template>
|
|
</template>
|
|
|
- <template #action="{ row }">
|
|
|
|
|
- <TableAction
|
|
|
|
|
- :actions="[
|
|
|
|
|
- {
|
|
|
|
|
- label: '编辑',
|
|
|
|
|
- type: 'text',
|
|
|
|
|
- danger: true,
|
|
|
|
|
- disabled: !hasAccessByCodes(['user:edit']),
|
|
|
|
|
- onClick: handleEdit.bind(null, row, true),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- label: '重置密码',
|
|
|
|
|
- type: 'text',
|
|
|
|
|
- disabled: !hasAccessByCodes(['user:resetPwd']),
|
|
|
|
|
- onClick: handelResetPassword.bind(null, row.id),
|
|
|
|
|
- },
|
|
|
|
|
- ]"
|
|
|
|
|
- :drop-down-actions="[
|
|
|
|
|
- {
|
|
|
|
|
- label: row.status === 1 ? '禁用' : '启用',
|
|
|
|
|
- type: 'link',
|
|
|
|
|
- disabled: !hasAccessByCodes(['user:setStatus']),
|
|
|
|
|
- onClick: handleUpdateStatus.bind(null, row),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- label: '角色管理',
|
|
|
|
|
- type: 'link',
|
|
|
|
|
- disabled: !hasAccessByCodes(['user:grantRole']),
|
|
|
|
|
- onClick: handelGrantRole.bind(null, row.id),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- label: '删除',
|
|
|
|
|
- type: 'link',
|
|
|
|
|
- disabled: !hasAccessByCodes(['user:delete']),
|
|
|
|
|
- onClick: handleDelete.bind(null, row.id),
|
|
|
|
|
- },
|
|
|
|
|
- ]"
|
|
|
|
|
- />
|
|
|
|
|
- </template>
|
|
|
|
|
</Grid>
|
|
</Grid>
|
|
|
</Page>
|
|
</Page>
|
|
|
</template>
|
|
</template>
|