refactor: type/注释优化 去除大量any

This commit is contained in:
dap
2025-01-10 14:02:21 +08:00
parent 6e3b468303
commit 9f6bee86f0
81 changed files with 710 additions and 367 deletions

View File

@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { VbenFormProps } from '@vben/common-ui';
import type { Recordable } from '@vben/types';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { Client } from '#/api/system/client/model';
import { useAccess } from '@vben/access';
import { Page, useVbenDrawer } from '@vben/common-ui';
@@ -42,7 +42,7 @@ const gridOptions: VxeGridProps = {
reserve: true,
// 点击行选中
// trigger: 'row',
checkMethod: (row: any) => row?.id !== 1,
checkMethod: ({ row }) => (row as Client)?.id !== 1,
},
columns,
height: 'auto',
@@ -80,19 +80,19 @@ function handleAdd() {
drawerApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: Client) {
drawerApi.setData({ id: record.id });
drawerApi.open();
}
async function handleDelete(row: Recordable<any>) {
await clientRemove(row.id);
async function handleDelete(row: Client) {
await clientRemove([row.id]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.id);
const ids = rows.map((row: Client) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,9 +1,9 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';
import { type FormSchemaGetter } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

View File

@@ -1,16 +1,15 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { SysConfig } from '#/api/system/config/model';
import { Page, useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
configExport,
configList,
@@ -83,19 +82,19 @@ function handleAdd() {
modalApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: SysConfig) {
modalApi.setData({ id: record.configId });
modalApi.open();
}
async function handleDelete(row: Recordable<any>) {
await configRemove(row.configId);
async function handleDelete(row: SysConfig) {
await configRemove([row.configId]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.configId);
const ids = rows.map((row: SysConfig) => row.configId);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,9 +1,10 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';
import { type FormSchemaGetter, z } from '#/adapter/form';
import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

View File

@@ -1,4 +1,6 @@
<script setup lang="ts">
import type { Dept } from '#/api/system/dept/model';
import { computed, ref } from 'vue';
import { useVbenDrawer } from '@vben/common-ui';
@@ -43,7 +45,7 @@ const [BasicForm, formApi] = useVbenForm({
});
async function getDeptTree(deptId?: number | string, exclude = false) {
let ret: any[] = [];
let ret: Dept[] = [];
ret = await (!deptId || exclude ? deptList({}) : deptNodeList(deptId));
const treeData = listToTree(ret, { id: 'deptId', pid: 'parentId' });
// 添加部门名称 如 xx-xx-xx

View File

@@ -1,14 +1,17 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { Dept } from '#/api/system/dept/model';
import { nextTick } from 'vue';
import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { Page, useVbenDrawer } from '@vben/common-ui';
import { eachTree, getVxePopupContainer } from '@vben/utils';
import { Popconfirm, Space } from 'ant-design-vue';
import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { deptList, deptRemove } from '#/api/system/dept';
import { columns, querySchema } from './data';
@@ -74,7 +77,7 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
gridEvents: {
cellDblclick: (e: any) => {
cellDblclick: (e) => {
const { row = {} } = e;
if (!row?.children) {
return;
@@ -84,7 +87,7 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
row.expand = !isExpanded;
},
// 需要监听使用箭头展开的情况 否则展开/折叠的数据不一致
toggleTreeExpand: (e: any) => {
toggleTreeExpand: (e) => {
const { row = {}, expanded } = e;
row.expand = expanded;
},
@@ -99,18 +102,18 @@ function handleAdd() {
drawerApi.open();
}
function handleSubAdd(row: Recordable<any>) {
function handleSubAdd(row: Dept) {
const { deptId } = row;
drawerApi.setData({ id: deptId, update: false });
drawerApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: Dept) {
drawerApi.setData({ id: record.deptId, update: true });
drawerApi.open();
}
async function handleDelete(row: Recordable<any>) {
async function handleDelete(row: Dept) {
await deptRemove(row.deptId);
await tableApi.query();
}

View File

@@ -1,5 +1,6 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { DictData } from '#/api/system/dict/dict-data-model';
import { renderDictTag } from '#/utils/render';
@@ -18,8 +19,8 @@ export const columns: VxeGridProps['columns'] = [
field: 'cssClass',
slots: {
default: ({ row }) => {
const { dictValue } = row;
return renderDictTag(dictValue, [row as any]);
const { dictValue } = row as DictData;
return renderDictTag(dictValue, row);
},
},
},

View File

@@ -1,18 +1,18 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { PageQuery } from '#/api/common';
import type { DictData } from '#/api/system/dict/dict-data-model';
import { ref } from 'vue';
import { useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { useVbenDrawer } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
dictDataExport,
dictDataList,
@@ -53,7 +53,7 @@ const gridOptions: VxeGridProps = {
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
const params: any = {
const params: PageQuery = {
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
@@ -87,7 +87,7 @@ function handleAdd() {
drawerApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: DictData) {
drawerApi.setData({
dictType: dictType.value,
dictCode: record.dictCode,
@@ -95,14 +95,14 @@ async function handleEdit(record: Recordable<any>) {
drawerApi.open();
}
async function handleDelete(row: Recordable<any>) {
await dictDataRemove(row.dictCode);
async function handleDelete(row: DictData) {
await dictDataRemove([row.dictCode]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.dictCode);
const ids = rows.map((row: DictData) => row.dictCode);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,12 +1,11 @@
<script setup lang="ts">
import { computed, type PropType } from 'vue';
import type { RadioChangeEvent } from 'ant-design-vue';
import {
Input,
type RadioChangeEvent,
RadioGroup,
Select,
} from 'ant-design-vue';
import type { PropType } from 'vue';
import { computed } from 'vue';
import { Input, RadioGroup, Select } from 'ant-design-vue';
import { tagSelectOptions } from '#/components/dict';

View File

@@ -1,6 +1,7 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { type FormSchemaGetter, z } from '#/adapter/form';
import { z } from '#/adapter/form';
export const querySchema: FormSchemaGetter = () => [
{

View File

@@ -1,18 +1,17 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { DictType } from '#/api/system/dict/dict-type-model';
import { ref } from 'vue';
import { useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
dictTypeExport,
dictTypeList,
@@ -73,7 +72,7 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
gridEvents: {
cellClick: (e: any) => {
cellClick: (e) => {
const { row } = e;
if (lastDictType.value === row.dictType) {
return;
@@ -92,19 +91,19 @@ function handleAdd() {
modalApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: DictType) {
modalApi.setData({ id: record.dictId });
modalApi.open();
}
async function handleDelete(row: Recordable<any>) {
await dictTypeRemove(row.dictId);
async function handleDelete(row: DictType) {
await dictTypeRemove([row.dictId]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.dictId);
const ids = rows.map((row: DictType) => row.dictId);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,3 +1,4 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { h } from 'vue';
@@ -7,7 +8,7 @@ import { FolderIcon, MenuIcon, OkButtonIcon, VbenIcon } from '@vben/icons';
import { $t } from '@vben/locales';
import { getPopupContainer } from '@vben/utils';
import { type FormSchemaGetter, z } from '#/adapter/form';
import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

View File

@@ -1,16 +1,18 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { Menu } from '#/api/system/menu/model';
import { computed } from 'vue';
import { useAccess } from '@vben/access';
import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { Fallback } from '@vben/common-ui';
import { Fallback, Page, useVbenDrawer } from '@vben/common-ui';
import { eachTree, getVxePopupContainer } from '@vben/utils';
import { Popconfirm, Space } from 'ant-design-vue';
import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { menuList, menuRemove } from '#/api/system/menu';
import { columns, querySchema } from './data';
@@ -74,7 +76,7 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
gridEvents: {
cellDblclick: (e: any) => {
cellDblclick: (e) => {
const { row = {} } = e;
if (!row?.children) {
return;
@@ -84,7 +86,7 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
row.expand = !isExpanded;
},
// 需要监听使用箭头展开的情况 否则展开/折叠的数据不一致
toggleTreeExpand: (e: any) => {
toggleTreeExpand: (e) => {
const { row = {}, expanded } = e;
row.expand = expanded;
},
@@ -99,19 +101,19 @@ function handleAdd() {
drawerApi.open();
}
function handleSubAdd(row: Recordable<any>) {
function handleSubAdd(row: Menu) {
const { menuId } = row;
drawerApi.setData({ id: menuId, update: false });
drawerApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: Menu) {
drawerApi.setData({ id: record.menuId, update: true });
drawerApi.open();
}
async function handleDelete(row: Recordable<any>) {
await menuRemove(row.menuId);
async function handleDelete(row: Menu) {
await menuRemove([row.menuId]);
await tableApi.query();
}

View File

@@ -1,9 +1,9 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';
import { type FormSchemaGetter } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

View File

@@ -1,16 +1,15 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { Notice } from '#/api/system/notice/model';
import { Page, useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import { noticeList, noticeRemove } from '#/api/system/notice';
import { columns, querySchema } from './data';
@@ -72,19 +71,19 @@ function handleAdd() {
modalApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: Notice) {
modalApi.setData({ id: record.noticeId });
modalApi.open();
}
async function handleDelete(row: Recordable<any>) {
await noticeRemove(row.noticeId);
async function handleDelete(row: Notice) {
await noticeRemove([row.noticeId]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.noticeId);
const ids = rows.map((row: Notice) => row.noticeId);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,10 +1,11 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { Tag } from 'ant-design-vue';
import { type FormSchemaGetter, z } from '#/adapter/form';
import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
const accessPolicyOptions = [

View File

@@ -1,17 +1,16 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { OssConfig } from '#/api/system/oss-config/model';
import { useAccess } from '@vben/access';
import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { Page, useVbenDrawer } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
ossConfigChangeStatus,
ossConfigList,
@@ -78,19 +77,19 @@ function handleAdd() {
drawerApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: OssConfig) {
drawerApi.setData({ id: record.ossConfigId });
drawerApi.open();
}
async function handleDelete(row: Recordable<any>) {
await ossConfigRemove(row.ossConfigId);
async function handleDelete(row: OssConfig) {
await ossConfigRemove([row.ossConfigId]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.ossConfigId);
const ids = rows.map((row: OssConfig) => row.ossConfigId);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,7 +1,6 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { type FormSchemaGetter } from '#/adapter/form';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',

View File

@@ -1,10 +1,14 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { PageQuery } from '#/api/common';
import type { OssFile } from '#/api/system/oss/model';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { Page, useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { getVxePopupContainer } from '@vben/utils';
@@ -22,7 +26,6 @@ import {
addSortParams,
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { configInfoByKey } from '#/api/system/config';
import { ossDownload, ossList, ossRemove } from '#/api/system/oss';
@@ -67,7 +70,7 @@ const gridOptions: VxeGridProps = {
proxyConfig: {
ajax: {
query: async ({ page, sorts }, formValues = {}) => {
const params: any = {
const params: PageQuery = {
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
@@ -101,7 +104,7 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
},
});
async function handleDownload(row: Recordable<any>) {
async function handleDownload(row: OssFile) {
const hideLoading = message.loading($t('pages.common.downloadLoading'), 0);
try {
const data = await ossDownload(row.ossId);
@@ -111,14 +114,14 @@ async function handleDownload(row: Recordable<any>) {
}
}
async function handleDelete(row: Recordable<any>) {
await ossRemove(row.ossId);
async function handleDelete(row: OssFile) {
await ossRemove([row.ossId]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.ossId);
const ids = rows.map((row: OssFile) => row.ossId);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,9 +1,9 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';
import { type FormSchemaGetter } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

View File

@@ -1,18 +1,17 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { Post } from '#/api/system/post/model';
import { ref } from 'vue';
import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { Page, useVbenDrawer } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import { postExport, postList, postRemove } from '#/api/system/post';
import { commonDownloadExcel } from '#/utils/file/download';
import DeptTree from '#/views/system/user/dept-tree.vue';
@@ -93,19 +92,19 @@ function handleAdd() {
drawerApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: Post) {
drawerApi.setData({ id: record.postId });
drawerApi.open();
}
async function handleDelete(row: Recordable<any>) {
await postRemove(row.postId);
async function handleDelete(row: Post) {
await postRemove([row.postId]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.postId);
const ids = rows.map((row: Post) => row.postId);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,7 +1,6 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { type FormSchemaGetter } from '#/adapter/form';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',

View File

@@ -1,18 +1,17 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { User } from '#/api/system/user/model';
import { useRoute } from 'vue-router';
import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { Page, useVbenDrawer } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
roleAllocatedList,
roleAuthCancel,
@@ -85,7 +84,7 @@ function handleAdd() {
/**
* 取消授权 一条记录
*/
async function handleAuthCancel(record: Recordable<any>) {
async function handleAuthCancel(record: User) {
await roleAuthCancel({ userId: record.userId, roleId });
await tableApi.query();
}
@@ -95,7 +94,7 @@ async function handleAuthCancel(record: Recordable<any>) {
*/
function handleMultipleAuthCancel() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.userId);
const ids = rows.map((row: User) => row.userId);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,9 +1,13 @@
<script setup lang="ts">
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { useRoute } from 'vue-router';
import { useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { useVbenDrawer } from '@vben/common-ui';
import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { roleSelectAll, roleUnallocatedList } from '#/api/system/role';
import { columns, querySchema } from './data';

View File

@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { VbenFormProps } from '@vben/common-ui';
import type { Recordable } from '@vben/types';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { Role } from '#/api/system/role/model';
import { computed } from 'vue';
import { useRouter } from 'vue-router';
@@ -98,19 +98,19 @@ function handleAdd() {
drawerApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: Role) {
drawerApi.setData({ id: record.roleId });
drawerApi.open();
}
async function handleDelete(row: Recordable<any>) {
await roleRemove(row.roleId);
async function handleDelete(row: Role) {
await roleRemove([row.roleId]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.roleId);
const ids = rows.map((row: Role) => row.roleId);
Modal.confirm({
title: '提示',
okType: 'danger',
@@ -136,13 +136,13 @@ const [RoleAuthModal, authModalApi] = useVbenModal({
connectedComponent: roleAuthModal,
});
function handleAuthEdit(record: Recordable<any>) {
function handleAuthEdit(record: Role) {
authModalApi.setData({ id: record.roleId });
authModalApi.open();
}
const router = useRouter();
function handleAssignRole(record: Recordable<any>) {
function handleAssignRole(record: Role) {
router.push(`/system/role-assign/${record.roleId}`);
}
</script>

View File

@@ -1,4 +1,6 @@
<script setup lang="ts">
import type { DeptOption } from '#/api/system/role/model';
import { ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
@@ -23,7 +25,7 @@ const [BasicForm, formApi] = useVbenForm({
showDefaultActions: false,
});
const deptTree = ref<any[]>([]);
const deptTree = ref<DeptOption[]>([]);
async function setupDeptTree(id: number | string) {
const resp = await roleDeptTree(id);
formApi.setFieldValue('deptIds', resp.checkedKeys);

View File

@@ -1,10 +1,11 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { getPopupContainer } from '@vben/utils';
import dayjs from 'dayjs';
import { type FormSchemaGetter, z } from '#/adapter/form';
import { z } from '#/adapter/form';
export const querySchema: FormSchemaGetter = () => [
{

View File

@@ -1,20 +1,18 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { Tenant } from '#/api/system/tenant/model';
import { computed } from 'vue';
import { useAccess } from '@vben/access';
import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { Fallback } from '@vben/common-ui';
import { Fallback, Page, useVbenDrawer } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
dictSyncTenant,
tenantExport,
@@ -87,20 +85,20 @@ function handleAdd() {
drawerApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: Tenant) {
drawerApi.setData({ id: record.id });
drawerApi.open();
}
async function handleSync(record: Recordable<any>) {
async function handleSync(record: Tenant) {
const { tenantId, packageId } = record;
await tenantSyncPackage(tenantId, packageId);
await tableApi.query();
}
const tenantStore = useTenantStore();
async function handleDelete(row: Recordable<any>) {
await tenantRemove(row.id);
async function handleDelete(row: Tenant) {
await tenantRemove([row.id]);
await tableApi.query();
// 重新加载租户信息
tenantStore.initTenant();
@@ -108,7 +106,7 @@ async function handleDelete(row: Recordable<any>) {
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.id);
const ids = rows.map((row: Tenant) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,7 +1,6 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { type FormSchemaGetter } from '#/adapter/form';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',

View File

@@ -1,20 +1,18 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { TenantPackage } from '#/api/system/tenant-package/model';
import { computed } from 'vue';
import { useAccess } from '@vben/access';
import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { Fallback } from '@vben/common-ui';
import { Fallback, Page, useVbenDrawer } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
packageChangeStatus,
packageExport,
@@ -83,19 +81,19 @@ function handleAdd() {
drawerApi.open();
}
async function handleEdit(record: Recordable<any>) {
async function handleEdit(record: TenantPackage) {
drawerApi.setData({ id: record.packageId });
drawerApi.open();
}
async function handleDelete(row: Recordable<any>) {
await packageRemove(row.packageId);
async function handleDelete(row: TenantPackage) {
await packageRemove([row.packageId]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.packageId);
const ids = rows.map((row: TenantPackage) => row.packageId);
Modal.confirm({
title: '提示',
okType: 'danger',

View File

@@ -1,6 +1,8 @@
import type { PropType } from 'vue';
import type { Menu } from '#/api/system/menu/model';
import { computed, defineComponent, type PropType } from 'vue';
import { computed, defineComponent } from 'vue';
import { Tag } from 'ant-design-vue';

View File

@@ -1,9 +1,10 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';
import { type FormSchemaGetter, z } from '#/adapter/form';
import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
export const querySchema: FormSchemaGetter = () => [

View File

@@ -1,7 +1,9 @@
<script setup lang="ts">
import type { PropType } from 'vue';
import type { DeptTree } from '#/api/system/user/model';
import { onMounted, type PropType, ref } from 'vue';
import { onMounted, ref } from 'vue';
import { SyncOutlined } from '@ant-design/icons-vue';
import { Empty, InputSearch, Skeleton, Tree } from 'ant-design-vue';

View File

@@ -1,15 +1,13 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { User } from '#/api/system/user/model';
import { ref } from 'vue';
import { useAccess } from '@vben/access';
import {
Page,
useVbenDrawer,
useVbenModal,
type VbenFormProps,
} from '@vben/common-ui';
import { Page, useVbenDrawer, useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { preferences } from '@vben/preferences';
import { getVxePopupContainer } from '@vben/utils';
@@ -24,8 +22,7 @@ import {
Space,
} from 'ant-design-vue';
import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table';
import { vxeCheckboxChecked } from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
userExport,
userList,
@@ -137,19 +134,19 @@ function handleAdd() {
userDrawerApi.open();
}
function handleEdit(row: Recordable<any>) {
function handleEdit(row: User) {
userDrawerApi.setData({ id: row.userId });
userDrawerApi.open();
}
async function handleDelete(row: Recordable<any>) {
await userRemove(row.userId);
async function handleDelete(row: User) {
await userRemove([row.userId]);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.userId);
const ids = rows.map((row: User) => row.userId);
Modal.confirm({
title: '提示',
okType: 'danger',
@@ -170,7 +167,7 @@ function handleDownloadExcel() {
const [UserInfoModal, userInfoModalApi] = useVbenModal({
connectedComponent: userInfoModal,
});
function handleUserInfo(row: Recordable<any>) {
function handleUserInfo(row: User) {
userInfoModalApi.setData({ userId: row.userId });
userInfoModalApi.open();
}
@@ -179,7 +176,7 @@ const [UserResetPwdModal, userResetPwdModalApi] = useVbenModal({
connectedComponent: userResetPwdModal,
});
function handleResetPwd(record: Recordable<any>) {
function handleResetPwd(record: User) {
userResetPwdModalApi.setData({ record });
userResetPwdModalApi.open();
}

View File

@@ -1,6 +1,14 @@
<script setup lang="ts">
import type { Role } from '#/api/system/user/model';
import { computed, h, onMounted, ref } from 'vue';
import { useVbenDrawer } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { addFullName, cloneDeep, getPopupContainer } from '@vben/utils';
import { Tag } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import { configInfoByKey } from '#/api/system/config';
import { postOptionSelect } from '#/api/system/post';
@@ -11,11 +19,6 @@ import {
userUpdate,
} from '#/api/system/user';
import { authScopeOptions } from '#/views/system/role/data';
import { useVbenDrawer } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { addFullName, cloneDeep, getPopupContainer } from '@vben/utils';
import { Tag } from 'ant-design-vue';
import { computed, h, onMounted, ref } from 'vue';
import { drawerSchema } from './data';

View File

@@ -1,4 +1,6 @@
<script setup lang="ts">
import type { User } from '#/api/system/user/model';
import { useVbenModal } from '@vben/common-ui';
import { findUserInfo } from '#/api/system/user';
@@ -39,8 +41,12 @@ async function handleOpenChange(open: boolean) {
.filter((item) => roleIds.includes(item.roleId))
.map((item) => item.roleName);
(user as any).postNames = postNames;
(user as any).roleNames = roleNames;
interface UserWithNames extends User {
postNames: string[];
roleNames: string[];
}
(user as UserWithNames).postNames = postNames;
(user as UserWithNames).roleNames = roleNames;
// 赋值
setDescProps({ data: user });

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import type { ResetPwdParam, User } from '#/api/system/user/model';
import { useVbenModal, z } from '@vben/common-ui';
@@ -68,7 +68,7 @@ async function handleOpenChange(open: boolean) {
if (!open) {
return null;
}
const { record } = modalApi.getData() as { record: Recordable<any> };
const { record } = modalApi.getData() as { record: User };
setDescProps({ data: record }, true);
await formApi.setValues({ userId: record.userId });
}
@@ -81,7 +81,7 @@ async function handleSubmit() {
return;
}
const data = await formApi.getValues();
await userResetPassword(data as any);
await userResetPassword(data as ResetPwdParam);
emit('reload');
handleCancel();
} catch (error) {