8 Commits

Author SHA1 Message Date
67b9a74212 feat: 短信日志
Some checks failed
coverage CI / build (push) Has been cancelled
2025-09-23 15:34:48 +08:00
0da43ca229 feat: test
Some checks failed
coverage CI / build (push) Has been cancelled
2025-09-22 18:15:39 +08:00
7b29154116 feat: 邮箱账号 2025-09-19 17:05:00 +08:00
03009cd64d feat: 短信日志 2025-09-19 15:17:26 +08:00
706d2e2a9f feat: 短信模板 2025-09-19 14:00:03 +08:00
e109590aea feat: 短信渠道 2025-09-18 18:12:57 +08:00
8afdb0d09e feat: 消息中心-站内信管理 2025-09-18 17:47:35 +08:00
73bc5aec6b feat: 操作日志 2025-09-17 18:14:39 +08:00
73 changed files with 3978 additions and 4205 deletions

View File

@@ -4,8 +4,8 @@ NODE_ENV=development
VITE_DEV=true VITE_DEV=true
# 请求路径 # 请求路径
VITE_BASE_URL='http://114.132.60.20:48080' # VITE_BASE_URL='http://114.132.60.20:48080'
# VITE_BASE_URL='http://192.168.1.114:48080' # 理君 VITE_BASE_URL='http://192.168.1.114:48080' # 理君
# 文件上传类型server - 后端上传, client - 前端直连上传,仅支持 S3 服务 # 文件上传类型server - 后端上传, client - 前端直连上传,仅支持 S3 服务

View File

@@ -1,20 +1,20 @@
// https://umijs.org/config/ // https://umijs.org/config/
import { join } from "node:path"; import { join } from 'node:path';
import { defineConfig } from "@umijs/max"; import { defineConfig } from '@umijs/max';
import defaultSettings from "./defaultSettings"; import defaultSettings from './defaultSettings';
import proxy from "./proxy"; import proxy from './proxy';
import routes from "./routes"; import routes from './routes';
const { UMI_ENV = "dev" } = process.env; const { UMI_ENV = 'dev' } = process.env;
/** /**
* @name 使用公共路径 * @name 使用公共路径
* @description 部署时的路径,如果部署在非根目录下,需要配置这个变量 * @description 部署时的路径,如果部署在非根目录下,需要配置这个变量
* @doc https://umijs.org/docs/api/config#publicpath * @doc https://umijs.org/docs/api/config#publicpath
*/ */
const PUBLIC_PATH: string = "/"; const PUBLIC_PATH: string = '/';
export default defineConfig({ export default defineConfig({
/** /**
@@ -83,7 +83,7 @@ export default defineConfig({
* @name layout 插件 * @name layout 插件
* @doc https://umijs.org/docs/max/layout-menu * @doc https://umijs.org/docs/max/layout-menu
*/ */
title: "Ant Design Pro", title: 'Ant Design Pro',
layout: { layout: {
locale: true, locale: true,
...defaultSettings, ...defaultSettings,
@@ -94,8 +94,8 @@ export default defineConfig({
* @doc https://umijs.org/docs/max/moment2dayjs * @doc https://umijs.org/docs/max/moment2dayjs
*/ */
moment2dayjs: { moment2dayjs: {
preset: "antd", preset: 'antd',
plugins: ["duration"], plugins: ['duration'],
}, },
/** /**
* @name 国际化插件 * @name 国际化插件
@@ -103,7 +103,7 @@ export default defineConfig({
*/ */
locale: { locale: {
// default zh-CN // default zh-CN
default: "zh-CN", default: 'zh-CN',
antd: true, antd: true,
// default true, when it is true, will use `navigator.language` overwrite default // default true, when it is true, will use `navigator.language` overwrite default
baseNavigator: true, baseNavigator: true,
@@ -119,7 +119,7 @@ export default defineConfig({
theme: { theme: {
cssVar: true, cssVar: true,
token: { token: {
fontFamily: "AlibabaSans, sans-serif", fontFamily: 'AlibabaSans, sans-serif',
}, },
}, },
}, },
@@ -142,30 +142,33 @@ export default defineConfig({
*/ */
headScripts: [ headScripts: [
// 解决首次加载时白屏的问题 // 解决首次加载时白屏的问题
{ src: join(PUBLIC_PATH, "scripts/loading.js"), async: true }, { src: join(PUBLIC_PATH, 'scripts/loading.js'), async: true },
], ],
//================ pro 插件配置 ================= //================ pro 插件配置 =================
presets: ["umi-presets-pro"], presets: ['umi-presets-pro'],
/** /**
* @name openAPI 插件的配置 * @name openAPI 插件的配置
* @description 基于 openapi 的规范生成serve 和mock能减少很多样板代码 * @description 基于 openapi 的规范生成serve 和mock能减少很多样板代码
* @doc https://pro.ant.design/zh-cn/docs/openapi/ * @doc https://pro.ant.design/zh-cn/docs/openapi/
*/ */
openAPI: [ // openAPI: [
// { // // {
// requestLibPath: "import { request } from '@umijs/max'", // // requestLibPath: "import { request } from '@umijs/max'",
// schemaPath: join(__dirname, "oneapi/prodapi.json"), // // schemaPath: join(__dirname, "oneapi/prodapi.json"),
// mock: false, // // mock: false,
// projectName: "prodApi", // // projectName: "prodApi",
// }, // // },
// {schemaPath: "./docs/apifox-api.json", // // {schemaPath: "./docs/apifox-api.json",
// requestLibPath: "import { request } from '@umijs/max'", // // requestLibPath: "import { request } from '@umijs/max'",
// schemaPath: join(__dirname, "oneapi.json"), // // schemaPath: join(__dirname, "oneapi.json"),
// projectName: "login", // // projectName: "login",
// }, // // },
], // ],
codeSplitting: {
jsStrategy: 'granularChunks',
},
mock: { mock: {
include: ["mock/**/*", "src/pages/**/_mock.ts"], include: ['mock/**/*', 'src/pages/**/_mock.ts'],
}, },
/** /**
* @name 是否开启 mako * @name 是否开启 mako
@@ -177,6 +180,6 @@ export default defineConfig({
requestRecord: {}, requestRecord: {},
exportStatic: {}, exportStatic: {},
define: { define: {
"process.env.CI": process.env.CI, 'process.env.CI': process.env.CI,
}, },
}); });

View File

@@ -1,187 +0,0 @@
import { parse } from 'node:url';
import dayjs from 'dayjs';
import type { Request, Response } from 'express';
// mock tableListDataSource
const genList = (current: number, pageSize: number) => {
const tableListDataSource: API.RuleListItem[] = [];
for (let i = 0; i < pageSize; i += 1) {
const index = (current - 1) * 10 + i;
tableListDataSource.push({
key: index,
disabled: i % 6 === 0,
href: 'https://ant.design',
avatar: [
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
][i % 2],
name: `TradeCode ${index}`,
owner: '曲丽丽',
desc: '这是一段描述',
callNo: Math.floor(Math.random() * 1000),
status: Math.floor(Math.random() * 10) % 4,
updatedAt: dayjs().format('YYYY-MM-DD'),
createdAt: dayjs().format('YYYY-MM-DD'),
progress: Math.ceil(Math.random() * 100),
});
}
tableListDataSource.reverse();
return tableListDataSource;
};
let tableListDataSource = genList(1, 100);
function getRule(req: Request, res: Response, u: string) {
let realUrl = u;
if (
!realUrl ||
Object.prototype.toString.call(realUrl) !== '[object String]'
) {
realUrl = req.url;
}
const { current = 1, pageSize = 10 } = req.query;
const params = parse(realUrl, true).query as unknown as API.PageParams &
API.RuleListItem & {
sorter: any;
filter: any;
};
let dataSource = [...tableListDataSource].slice(
((current as number) - 1) * (pageSize as number),
(current as number) * (pageSize as number),
);
if (params.sorter) {
const sorter = JSON.parse(params.sorter);
dataSource = dataSource.sort((prev, next) => {
let sortNumber = 0;
(Object.keys(sorter) as Array<keyof API.RuleListItem>).forEach((key) => {
const nextSort = next?.[key] as number;
const preSort = prev?.[key] as number;
if (sorter[key] === 'descend') {
if (preSort - nextSort > 0) {
sortNumber += -1;
} else {
sortNumber += 1;
}
return;
}
if (preSort - nextSort > 0) {
sortNumber += 1;
} else {
sortNumber += -1;
}
});
return sortNumber;
});
}
if (params.filter) {
const filter = JSON.parse(params.filter as any) as {
[key: string]: string[];
};
if (Object.keys(filter).length > 0) {
dataSource = dataSource.filter((item) => {
return (Object.keys(filter) as Array<keyof API.RuleListItem>).some(
(key) => {
if (!filter[key]) {
return true;
}
if (filter[key].includes(`${item[key]}`)) {
return true;
}
return false;
},
);
});
}
}
if (params.name) {
dataSource = dataSource.filter((data) =>
data?.name?.includes(params.name || ''),
);
}
const result = {
data: dataSource,
total: tableListDataSource.length,
success: true,
pageSize,
current: parseInt(`${params.current}`, 10) || 1,
};
return res.json(result);
}
function postRule(req: Request, res: Response, u: string, b: Request) {
let realUrl = u;
if (
!realUrl ||
Object.prototype.toString.call(realUrl) !== '[object String]'
) {
realUrl = req.url;
}
const body = b?.body || req.body;
const { method, name, desc, key } = body;
switch (method) {
case 'delete':
tableListDataSource = tableListDataSource.filter(
(item) => key.indexOf(item.key) === -1,
);
break;
case 'post':
(() => {
const i = Math.ceil(Math.random() * 10000);
const newRule: API.RuleListItem = {
key: tableListDataSource.length,
href: 'https://ant.design',
avatar: [
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
][i % 2],
name,
owner: '曲丽丽',
desc,
callNo: Math.floor(Math.random() * 1000),
status: Math.floor(Math.random() * 10) % 2,
updatedAt: dayjs().format('YYYY-MM-DD'),
createdAt: dayjs().format('YYYY-MM-DD'),
progress: Math.ceil(Math.random() * 100),
};
tableListDataSource.unshift(newRule);
return res.json(newRule);
})();
return;
case 'update':
(() => {
let newRule = {};
tableListDataSource = tableListDataSource.map((item) => {
if (item.key === key) {
newRule = { ...item, desc, name };
return { ...item, desc, name };
}
return item;
});
return res.json(newRule);
})();
return;
default:
break;
}
const result = {
list: tableListDataSource,
pagination: {
total: tableListDataSource.length,
},
};
res.json(result);
}
export default {
'GET /api/rule': getRule,
'POST /api/rule': postRule,
};

View File

@@ -1,345 +1,18 @@
module.exports = { module.exports = {
'GET /api/currentUser': { "GET /admin-api/system/tenant/get-id-by-name": {
data: { data: 1,
name: 'Serati Ma',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
userid: '00000001',
email: 'antdesign@alipay.com',
signature: '海纳百川,有容乃大',
title: '交互专家',
group: '蚂蚁金服某某某事业群某某平台部某某技术部UED',
tags: [
{ key: '0', label: '很有想法的' },
{ key: '1', label: '专注设计' },
{ key: '2', label: '辣~' },
{ key: '3', label: '大长腿' },
{ key: '4', label: '川妹子' },
{ key: '5', label: '海纳百川' },
],
notifyCount: 12,
unreadCount: 11,
country: 'China',
geographic: {
province: { label: '浙江省', key: '330000' },
city: { label: '杭州市', key: '330100' },
},
address: '西湖区工专路 77 号',
phone: '0752-268888888',
},
},
'GET /api/rule': {
data: [
{
key: 99,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 99',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 503,
status: '0',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 81,
},
{
key: 98,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 98',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 164,
status: '0',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 12,
},
{
key: 97,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 97',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 174,
status: '1',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 81,
},
{
key: 96,
disabled: true,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 96',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 914,
status: '0',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 7,
},
{
key: 95,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 95',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 698,
status: '2',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 82,
},
{
key: 94,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 94',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 488,
status: '1',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 14,
},
{
key: 93,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 93',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 580,
status: '2',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 77,
},
{
key: 92,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 92',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 244,
status: '3',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 58,
},
{
key: 91,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 91',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 959,
status: '0',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 66,
},
{
key: 90,
disabled: true,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 90',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 958,
status: '0',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 72,
},
{
key: 89,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 89',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 301,
status: '2',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 2,
},
{
key: 88,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 88',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 277,
status: '1',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 12,
},
{
key: 87,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 87',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 810,
status: '1',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 82,
},
{
key: 86,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 86',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 780,
status: '3',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 22,
},
{
key: 85,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 85',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 705,
status: '3',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 12,
},
{
key: 84,
disabled: true,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 84',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 203,
status: '0',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 79,
},
{
key: 83,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 83',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 491,
status: '2',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 59,
},
{
key: 82,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 82',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 73,
status: '0',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 100,
},
{
key: 81,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
name: 'TradeCode 81',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 406,
status: '3',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 61,
},
{
key: 80,
disabled: false,
href: 'https://ant.design',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
name: 'TradeCode 80',
owner: '曲丽丽',
desc: '这是一段描述',
callNo: 112,
status: '2',
updatedAt: '2022-12-06T05:00:57.040Z',
createdAt: '2022-12-06T05:00:57.040Z',
progress: 20,
},
],
total: 100,
success: true, success: true,
pageSize: 20, code: 0,
current: 1,
}, },
'POST /api/login/outLogin': { data: {}, success: true }, "POST /admin-api/system/auth/login": {
'POST /api/login/account': { data: null,
status: 'ok', success: true,
type: 'account', code: 0,
currentAuthority: 'admin', },
"POST /api/login/outLogin": { data: {}, success: true },
"POST /api/login/account": {
status: "ok",
type: "account",
currentAuthority: "admin",
}, },
}; };

View File

@@ -7,15 +7,14 @@
"scripts": { "scripts": {
"analyze": "cross-env ANALYZE=1 max build", "analyze": "cross-env ANALYZE=1 max build",
"build": "max build", "build": "max build",
"deploy": "npm run build && npm run gh-pages", "deploy": "pnpm run build && npm run gh-pages",
"dev": "npm run start:dev", "dev": "pnpm run start:dev",
"gh-pages": "gh-pages -d dist", "gh-pages": "gh-pages -d dist",
"i18n-remove": "pro i18n-remove --locale=zh-CN --write", "i18n-remove": "pro i18n-remove --locale=zh-CN --write",
"postinstall": "max setup", "postinstall": "max setup",
"jest": "jest", "jest": "jest",
"lint": "npm run biome:lint && npm run tsc", "lint": "npm run biome:lint && npm run tsc",
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"lint:fix": "eslint --fix --quiet",
"biome:lint": "npx @biomejs/biome lint", "biome:lint": "npx @biomejs/biome lint",
"openapi": "max openapi", "openapi": "max openapi",
"prepare": "husky", "prepare": "husky",

12
pnpm-lock.yaml generated
View File

@@ -14075,14 +14075,14 @@ snapshots:
'@loadable/component@5.15.2(react@18.3.1)': '@loadable/component@5.15.2(react@18.3.1)':
dependencies: dependencies:
'@babel/runtime': 7.23.6 '@babel/runtime': 7.28.4
hoist-non-react-statics: 3.3.2 hoist-non-react-statics: 3.3.2
react: 18.3.1 react: 18.3.1
react-is: 16.13.1 react-is: 16.13.1
'@loadable/component@5.15.2(react@19.1.1)': '@loadable/component@5.15.2(react@19.1.1)':
dependencies: dependencies:
'@babel/runtime': 7.23.6 '@babel/runtime': 7.28.4
hoist-non-react-statics: 3.3.2 hoist-non-react-statics: 3.3.2
react: 19.1.1 react: 19.1.1
react-is: 16.13.1 react-is: 16.13.1
@@ -15402,7 +15402,7 @@ snapshots:
'@umijs/history@5.3.1': '@umijs/history@5.3.1':
dependencies: dependencies:
'@babel/runtime': 7.23.6 '@babel/runtime': 7.28.4
query-string: 6.14.1 query-string: 6.14.1
'@umijs/lint@4.4.12(eslint@8.35.0)(jest@30.1.3(@types/node@24.3.1)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.3.1)(typescript@5.9.2)))(stylelint@14.8.2)(typescript@5.9.2)': '@umijs/lint@4.4.12(eslint@8.35.0)(jest@30.1.3(@types/node@24.3.1)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.3.1)(typescript@5.9.2)))(stylelint@14.8.2)(typescript@5.9.2)':
@@ -16597,7 +16597,7 @@ snapshots:
babel-plugin-macros@2.6.1: babel-plugin-macros@2.6.1:
dependencies: dependencies:
'@babel/runtime': 7.4.5 '@babel/runtime': 7.28.4
cosmiconfig: 5.2.1 cosmiconfig: 5.2.1
resolve: 1.22.10 resolve: 1.22.10
@@ -23257,7 +23257,7 @@ snapshots:
react-helmet-async@1.3.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1): react-helmet-async@1.3.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
dependencies: dependencies:
'@babel/runtime': 7.23.6 '@babel/runtime': 7.28.4
invariant: 2.2.4 invariant: 2.2.4
prop-types: 15.8.1 prop-types: 15.8.1
react: 18.3.1 react: 18.3.1
@@ -23267,7 +23267,7 @@ snapshots:
react-helmet-async@1.3.0(react-dom@19.1.1(react@19.1.1))(react@19.1.1): react-helmet-async@1.3.0(react-dom@19.1.1(react@19.1.1))(react@19.1.1):
dependencies: dependencies:
'@babel/runtime': 7.23.6 '@babel/runtime': 7.28.4
invariant: 2.2.4 invariant: 2.2.4
prop-types: 15.8.1 prop-types: 15.8.1
react: 19.1.1 react: 19.1.1

View File

@@ -1,38 +1,38 @@
import type { Settings as LayoutSettings } from '@ant-design/pro-components';
import { SettingDrawer } from '@ant-design/pro-components';
import type { RequestConfig, RunTimeLayoutConfig } from '@umijs/max';
import { history, Link, Navigate } from '@umijs/max';
import { Modal, Spin } from 'antd';
import React, { import React, {
Children, Children,
Component, Component,
createContext, createContext,
JSX, JSX,
Suspense, Suspense,
} from "react"; } from 'react';
import { Modal, Spin } from "antd";
import type { Settings as LayoutSettings } from "@ant-design/pro-components";
import { SettingDrawer } from "@ant-design/pro-components";
import type { RequestConfig, RunTimeLayoutConfig } from "@umijs/max";
import { history, Link, Navigate } from "@umijs/max";
import { import {
AvatarDropdown, AvatarDropdown,
AvatarName, AvatarName,
Footer, Footer,
Question, Question,
SelectLang, SelectLang,
} from "@/components"; } from '@/components';
import { getInfo } from "@/services/login"; import { getInfo } from '@/services/login';
import type { UserVO, TokenType, UserInfoVO } from "@/services/login/types"; import type { TokenType, UserInfoVO, UserVO } from '@/services/login/types';
import defaultSettings from "../config/defaultSettings"; import defaultSettings from '../config/defaultSettings';
import { errorConfig } from "./requestErrorConfig"; import { errorConfig } from './requestErrorConfig';
import "@ant-design/v5-patch-for-react-19"; import '@ant-design/v5-patch-for-react-19';
import { getAccessToken, getRefreshToken, getTenantId } from "@/utils/auth"; import { getAccessToken, getRefreshToken, getTenantId } from '@/utils/auth';
import { CACHE_KEY, useCache } from "./hooks/web/useCache";
import { MenuVO } from "./services/system/menu";
import { import {
transformBackendMenuToFlatRoutes, transformBackendMenuToFlatRoutes,
transformMenuToRoutes, transformMenuToRoutes,
} from "@/utils/menuUtils"; } from '@/utils/menuUtils';
const isDev = process.env.NODE_ENV === "development"; import { CACHE_KEY, useCache } from './hooks/web/useCache';
import { MenuVO } from './services/system/menu';
const isDev = process.env.NODE_ENV === 'development';
const isDevOrTest = isDev || process.env.CI; const isDevOrTest = isDev || process.env.CI;
const loginPath = "/user/login"; const loginPath = '/user/login';
// 全局存储菜单数据和路由映射 // 全局存储菜单数据和路由映射
@@ -51,7 +51,7 @@ export async function getInitialState(): Promise<{
try { try {
const token = getAccessToken(); const token = getAccessToken();
if (!token) { if (!token) {
throw new Error("No token found"); throw new Error('No token found');
} }
const data = await getInfo(); const data = await getInfo();
wsCache.set(CACHE_KEY.USER, data); wsCache.set(CACHE_KEY.USER, data);
@@ -69,8 +69,8 @@ export async function getInitialState(): Promise<{
const { location } = history; const { location } = history;
if ( if (
![loginPath, "/user/register", "/user/register-result"].includes( ![loginPath, '/user/register', '/user/register-result'].includes(
location.pathname location.pathname,
) )
) { ) {
const currentUser = wsCache.get(CACHE_KEY.USER); const currentUser = wsCache.get(CACHE_KEY.USER);
@@ -125,22 +125,22 @@ export const layout: RunTimeLayoutConfig = ({
}, },
bgLayoutImgList: [ bgLayoutImgList: [
{ {
src: "https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/D2LWSqNny4sAAAAAAAAAAAAAFl94AQBr", src: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/D2LWSqNny4sAAAAAAAAAAAAAFl94AQBr',
left: 85, left: 85,
bottom: 100, bottom: 100,
height: "303px", height: '303px',
}, },
{ {
src: "https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/C2TWRpJpiC0AAAAAAAAAAAAAFl94AQBr", src: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/C2TWRpJpiC0AAAAAAAAAAAAAFl94AQBr',
bottom: -68, bottom: -68,
right: -45, right: -45,
height: "303px", height: '303px',
}, },
{ {
src: "https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/F6vSTbj8KpYAAAAAAAAAAAAAFl94AQBr", src: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/F6vSTbj8KpYAAAAAAAAAAAAAFl94AQBr',
bottom: 0, bottom: 0,
left: 0, left: 0,
width: "331px", width: '331px',
}, },
], ],
menuHeaderRender: undefined, menuHeaderRender: undefined,
@@ -178,14 +178,14 @@ export const layout: RunTimeLayoutConfig = ({
* @doc https://umijs.org/docs/max/request#配置 * @doc https://umijs.org/docs/max/request#配置
*/ */
export const request: RequestConfig = { export const request: RequestConfig = {
baseURL: isDev ? "" : "https://proapi.azurewebsites.net", baseURL: isDev ? '' : 'https://proapi.azurewebsites.net',
...errorConfig, ...errorConfig,
// 添加请求拦截器 // 添加请求拦截器
requestInterceptors: [ requestInterceptors: [
(url, options) => { (url, options) => {
// 为所有请求添加 API 前缀 // 为所有请求添加 API 前缀
if (url && !url.startsWith(process.env.API_PREFIX || "/admin-api")) { if (url && !url.startsWith(process.env.API_PREFIX || '/admin-api')) {
url = (process.env.API_PREFIX || "/admin-api") + url; url = (process.env.API_PREFIX || '/admin-api') + url;
} }
// 获取存储在本地的 token 和 tenantId // 获取存储在本地的 token 和 tenantId
const token = getAccessToken(); const token = getAccessToken();
@@ -193,12 +193,12 @@ export const request: RequestConfig = {
// 设置统一的请求头 // 设置统一的请求头
const headers: Record<string, string> = { const headers: Record<string, string> = {
...options.headers, ...options.headers,
Accept: "*", Accept: '*',
"tenant-id": tenantId, 'tenant-id': tenantId,
}; };
// 如果有token则添加Authorization头 // 如果有token则添加Authorization头
if (token) { if (token) {
headers["Authorization"] = `Bearer ${getAccessToken()}`; headers['Authorization'] = `Bearer ${getAccessToken()}`;
} }
return { url, options: { ...options, headers } }; return { url, options: { ...options, headers } };
}, },
@@ -210,7 +210,7 @@ export const request: RequestConfig = {
const appendParams = (key: string, value: any) => { const appendParams = (key: string, value: any) => {
if (Array.isArray(value)) { if (Array.isArray(value)) {
// 特殊处理 createTime 数组,转换为 createTime[0] 和 createTime[1] 格式 // 特殊处理 createTime 数组,转换为 createTime[0] 和 createTime[1] 格式
if (key === "createTime") { if (key === 'createTime') {
value.forEach((val, index) => { value.forEach((val, index) => {
searchParams.append(`${key}[${index}]`, val); searchParams.append(`${key}[${index}]`, val);
}); });
@@ -237,23 +237,23 @@ export function patchClientRoutes({ routes }: { routes: any }) {
const { wsCache } = useCache(); const { wsCache } = useCache();
console.log(2222); console.log(2222);
const globalMenus = wsCache.get(CACHE_KEY.ROLE_ROUTERS); const globalMenus = wsCache.get(CACHE_KEY.ROLE_ROUTERS);
const routerIndex = routes.findIndex((item: any) => item.path === "/"); const routerIndex = routes.findIndex((item: any) => item.path === '/');
const parentId = routes[routerIndex].id; const parentId = routes[routerIndex].id;
if (globalMenus) { if (globalMenus) {
routes[routerIndex]["routes"].push(...loopMenuItem(globalMenus, parentId)); routes[routerIndex]['routes'].push(...loopMenuItem(globalMenus, parentId));
} }
} }
const loopMenuItem = (menus: any[], pId: number | string): any[] => { const loopMenuItem = (menus: any[], pId: number | string): any[] => {
return menus.flatMap((item) => { return menus.flatMap((item) => {
let Component: React.ComponentType<any> | null = null; let Component: React.ComponentType<any> | null = null;
console.log(findFirstLeafRoute(item), "item"); console.log(findFirstLeafRoute(item), 'item');
if (item.component && item.component.length > 0) { if (item.component && item.component.length > 0) {
// 防止配置了路由,但本地暂未添加对应的页面,产生的错误 // 防止配置了路由,但本地暂未添加对应的页面,产生的错误
Component = React.lazy(() => { Component = React.lazy(() => {
const importComponent = () => import(`@/pages/${item.component}`); const importComponent = () => import(`@/pages/${item.component}`);
const import404 = () => import("@/pages/404"); const import404 = () => import('@/pages/404');
return importComponent().catch(import404); return importComponent().catch(import404);
}); });
} }
@@ -262,7 +262,7 @@ const loopMenuItem = (menus: any[], pId: number | string): any[] => {
{ {
path: item.path, path: item.path,
name: item.name, name: item.name,
icon: item.icon, // icon: item.icon,
id: item.id, id: item.id,
parentId: pId, parentId: pId,
@@ -281,13 +281,13 @@ const loopMenuItem = (menus: any[], pId: number | string): any[] => {
{ {
path: item.path, path: item.path,
name: item.name, name: item.name,
icon: item.icon, // icon: item.icon,
id: item.menuID, id: item.menuID,
parentId: pId, parentId: pId,
redirect: "/system/tenant/list", redirect: '/system/tenant/list',
element: ( element: (
<React.Suspense <React.Suspense
fallback={<Spin style={{ width: "100%", height: "100%" }} />} fallback={<Spin style={{ width: '100%', height: '100%' }} />}
> >
{Component && <Component />} {Component && <Component />}
</React.Suspense> </React.Suspense>
@@ -299,7 +299,7 @@ const loopMenuItem = (menus: any[], pId: number | string): any[] => {
}); });
}; };
const findFirstLeafRoute = (menuItem: any, parent = "/"): string | null => { const findFirstLeafRoute = (menuItem: any, parent = '/'): string | null => {
// 如果没有子菜单,返回当前路径 // 如果没有子菜单,返回当前路径
if (!menuItem.children || menuItem.children.length === 0) { if (!menuItem.children || menuItem.children.length === 0) {
@@ -308,7 +308,7 @@ const findFirstLeafRoute = (menuItem: any, parent = "/"): string | null => {
// 递归查找第一个叶子节点 // 递归查找第一个叶子节点
for (const child of menuItem.children) { for (const child of menuItem.children) {
const leafRoute = findFirstLeafRoute(child, menuItem.path + "/"); const leafRoute = findFirstLeafRoute(child, menuItem.path + '/');
if (leafRoute) { if (leafRoute) {
return leafRoute; return leafRoute;
} }

View File

@@ -1,9 +1,9 @@
import React, { useImperativeHandle, forwardRef } from "react"; import { CloseOutlined } from '@ant-design/icons';
import { DrawerForm } from "@ant-design/pro-components"; import type { ProFormColumnsType } from '@ant-design/pro-components';
import type { ProFormColumnsType } from "@ant-design/pro-components"; import { BetaSchemaForm, DrawerForm } from '@ant-design/pro-components';
import { BetaSchemaForm } from "@ant-design/pro-components"; import { Button, type ColProps, Drawer, Space, Typography } from 'antd';
import { Button, Drawer, Space, Typography } from "antd"; import React, { forwardRef, useImperativeHandle } from 'react';
import { CloseOutlined } from "@ant-design/icons";
const { Title } = Typography; const { Title } = Typography;
interface ConfigurableDrawerFormProps { interface ConfigurableDrawerFormProps {
title?: string; title?: string;
@@ -11,6 +11,8 @@ interface ConfigurableDrawerFormProps {
onSubmit?: (values: any) => Promise<boolean>; onSubmit?: (values: any) => Promise<boolean>;
initialValues?: Record<string, any>; initialValues?: Record<string, any>;
width?: number; width?: number;
labelCol?: ColProps;
wrapperCol?: ColProps;
} }
export interface ConfigurableDrawerFormRef { export interface ConfigurableDrawerFormRef {
@@ -21,102 +23,115 @@ export interface ConfigurableDrawerFormRef {
const ConfigurableDrawerForm = forwardRef< const ConfigurableDrawerForm = forwardRef<
ConfigurableDrawerFormRef, ConfigurableDrawerFormRef,
ConfigurableDrawerFormProps ConfigurableDrawerFormProps
>(({ title = "表单", columns, onSubmit, initialValues, width = 600 }, ref) => { >(
const [open, setOpen] = React.useState(false); (
const [formData, setFormData] = React.useState(initialValues || {}); {
const [loading, setLoading] = React.useState<boolean>(false); title = '表单',
// 添加表单实例引用 labelCol = { span: 4 },
const formRef = React.useRef<any>(null); wrapperCol = { span: 20 },
useImperativeHandle(ref, () => ({ columns,
open: (data) => { onSubmit,
if (data) { initialValues,
setFormData(data); width = 600,
}
console.log("open");
setOpen(true);
}, },
close: () => setOpen(false), ref,
})); ) => {
const [open, setOpen] = React.useState(false);
const handleSubmit = async () => { const [formData, setFormData] = React.useState(initialValues || {});
try { const [loading, setLoading] = React.useState<boolean>(false);
if (onSubmit) { // 添加表单实例引用
await formRef.current?.validateFields(); const formRef = React.useRef<any>(null);
setLoading(true); useImperativeHandle(ref, () => ({
const values = formRef.current?.getFieldsValue(); open: (data) => {
const success = await onSubmit(values); if (data) {
if (success) { setFormData(data);
setOpen(false);
return true;
} }
return false; console.log('open');
setOpen(true);
},
close: () => setOpen(false),
}));
const handleSubmit = async () => {
try {
if (onSubmit) {
await formRef.current?.validateFields();
setLoading(true);
const values = formRef.current?.getFieldsValue();
const success = await onSubmit(values);
if (success) {
setOpen(false);
return true;
}
return false;
}
return true;
} finally {
setLoading(false);
} }
return true; };
} finally { const customHeader = (
setLoading(false); <div
}
};
const customHeader = (
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
padding: "0 0px 16px 0px",
borderBottom: "1px solid #f0f0f0",
marginBottom: "16px",
}}
>
<Title level={4} style={{ margin: 0 }}>
{title}
</Title>
<Button
type="text"
icon={<CloseOutlined />}
onClick={() => setOpen(false)}
style={{ style={{
border: "none", display: 'flex',
boxShadow: "none", justifyContent: 'space-between',
alignItems: 'center',
padding: '0 0px 16px 0px',
borderBottom: '1px solid #f0f0f0',
marginBottom: '16px',
}} }}
/> >
</div> <Title level={4} style={{ margin: 0 }}>
); {title}
return ( </Title>
<Drawer <Button
title={title} type="text"
styles={{ icon={<CloseOutlined />}
header: { onClick={() => setOpen(false)}
textAlign: "left", style={{
position: "relative", border: 'none',
}, boxShadow: 'none',
}} }}
destroyOnHidden />
closable={true} // 隐藏默认关闭按钮 </div>
open={open} );
onClose={() => setOpen(false)} return (
width={width} <Drawer
footer={ title={title}
<Space style={{ width: "100%", justifyContent: "end" }}> styles={{
<Button onClick={() => setOpen(false)}></Button> header: {
<Button loading={loading} type="primary" onClick={handleSubmit}> textAlign: 'left',
position: 'relative',
</Button> },
</Space> }}
} destroyOnHidden
> closable={true} // 隐藏默认关闭按钮
{/* {customHeader} */} open={open}
<BetaSchemaForm onClose={() => setOpen(false)}
initialValues={formData} width={width}
layoutType="Form" footer={
formRef={formRef} <Space style={{ width: '100%', justifyContent: 'end' }}>
columns={columns} <Button onClick={() => setOpen(false)}></Button>
layout="horizontal" <Button loading={loading} type="primary" onClick={handleSubmit}>
labelCol={{ span: 4 }}
wrapperCol={{ span: 20 }} </Button>
submitter={false} </Space>
/> }
</Drawer> >
); {/* {customHeader} */}
}); <BetaSchemaForm
initialValues={formData}
layoutType="Form"
formRef={formRef}
columns={columns}
layout="horizontal"
labelCol={labelCol}
wrapperCol={wrapperCol}
submitter={false}
/>
</Drawer>
);
},
);
export default ConfigurableDrawerForm; export default ConfigurableDrawerForm;

View File

@@ -1,36 +1,37 @@
// components/EnhancedProTable/EnhancedProTable.tsx // components/EnhancedProTable/EnhancedProTable.tsx
import { PlusOutlined } from '@ant-design/icons';
import {
type ActionType,
type ParamsType,
ProColumns,
ProTable,
TableDropdown,
} from '@ant-design/pro-components';
import { Button, Space } from 'antd';
import React, { import React, {
useRef,
useState,
useCallback,
useMemo,
act, act,
forwardRef, forwardRef,
} from "react"; useCallback,
import { useMemo,
ProTable, useRef,
ProColumns, useState,
ActionType, } from 'react';
TableDropdown,
ParamsType,
} from "@ant-design/pro-components";
import { Button, Space } from "antd";
import {
EnhancedProTableProps,
BaseRecord,
TableAction,
ToolbarAction,
} from "./types";
import { import {
buildTableDropdownMenuItems, buildTableDropdownMenuItems,
handleTableDropdownSelect,
formatPaginationTotal, formatPaginationTotal,
} from "@/utils/antd/tableHelpers"; handleTableDropdownSelect,
import { PlusOutlined } from "@ant-design/icons"; } from '@/utils/antd/tableHelpers';
import {
type BaseRecord,
type EnhancedProTableProps,
TableAction,
ToolbarAction,
} from './types';
function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>( function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
props: EnhancedProTableProps<T, U>, props: EnhancedProTableProps<T, U>,
ref: React.Ref<ActionType | undefined> | undefined ref: React.Ref<ActionType | undefined> | undefined,
) { ) {
const { const {
columns, columns,
@@ -87,7 +88,7 @@ function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
</Space> </Space>
); );
}, },
[showSelection] [showSelection],
); );
const toolBarRender = useCallback( const toolBarRender = useCallback(
@@ -96,7 +97,7 @@ function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
rows: { rows: {
selectedRowKeys?: (string | number)[] | undefined; selectedRowKeys?: (string | number)[] | undefined;
selectedRows?: T[] | undefined; selectedRows?: T[] | undefined;
} },
) => { ) => {
const toolbarElements = const toolbarElements =
toolbarActions?.map((action) => { toolbarActions?.map((action) => {
@@ -125,7 +126,7 @@ function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
// ]; // ];
return toolbarElements; return toolbarElements;
}, },
[toolbarActions] [toolbarActions],
); );
return ( return (
<ProTable<T, U> <ProTable<T, U>
@@ -140,9 +141,9 @@ function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
showSorterTooltip showSorterTooltip
tableAlertRender={tableAlertRender} tableAlertRender={tableAlertRender}
// tableAlertOptionRender={tableAlertOptionRender} // tableAlertOptionRender={tableAlertOptionRender}
scroll={{ x: "max-content" }} scroll={{ x: 'max-content' }}
search={{ search={{
labelWidth: "auto", labelWidth: 'auto',
defaultCollapsed: false, defaultCollapsed: false,
...restProps.search, ...restProps.search,
}} }}
@@ -156,6 +157,7 @@ function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
pagination={{ pagination={{
showSizeChanger: true, showSizeChanger: true,
showQuickJumper: true, showQuickJumper: true,
pageSize: 10,
showTotal: formatPaginationTotal, showTotal: formatPaginationTotal,
...restProps.pagination, ...restProps.pagination,
}} }}
@@ -165,7 +167,7 @@ function EnhancedProTable<T extends BaseRecord, U extends ParamsType = any>(
export default forwardRef(EnhancedProTable) as < export default forwardRef(EnhancedProTable) as <
T extends BaseRecord, T extends BaseRecord,
U extends ParamsType = any U extends ParamsType = any,
>( >(
props: EnhancedProTableProps<T, U> & { ref?: React.Ref<ActionType> } props: EnhancedProTableProps<T, U> & { ref?: React.Ref<ActionType> },
) => React.ReactElement; ) => React.ReactElement;

View File

@@ -0,0 +1,72 @@
import {
ProDescriptions,
type ProDescriptionsItemProps,
} from '@ant-design/pro-components';
import { type DescriptionsProps, Modal } from 'antd';
import React, {
forwardRef,
useCallback,
useImperativeHandle,
useState,
} from 'react';
export interface DescriptionsFormRef {
open: (data?: Record<string, any>) => void;
close: () => void;
}
interface Props {
columns: ProDescriptionsItemProps<Record<string, any>, 'text'>[];
title: string;
}
const ModalDescriptions = forwardRef((props: Props, ref) => {
const { columns, title } = props;
const [visible, setVisible] = useState<boolean>(false);
const [data, setData] = useState<DescriptionsProps['items']>([]);
useImperativeHandle(ref, () => ({
open: (data: DescriptionsProps['items']) => {
console.log(data);
if (data) {
setData(data);
}
setVisible(true);
},
close: () => setVisible(false),
}));
const changeVisible = useCallback(
(flag: boolean) => {
setVisible(flag);
},
[visible],
);
return (
<Modal
open={visible}
width={800}
onCancel={() => changeVisible(false)}
footer={null}
>
<ProDescriptions
labelStyle={{ width: '200px' }}
columns={columns}
dataSource={data}
bordered
column={1}
size="small"
title={title}
// tooltip="操作日志详情"
></ProDescriptions>
{/* <Descriptions
title="操作日志"
column={1}
bordered
size="small"
items={data}
/> */}
</Modal>
);
});
export default React.memo(ModalDescriptions);

View File

@@ -1,32 +1 @@
export const formStatusType = { create: '创建', update: '编辑' }; export const formStatusType = { create: '创建', update: '编辑', test: '测试' };
export const tenantStatus = [
{ label: '开启', value: 0 },
{ label: '关闭', value: 1 },
];
export const modlaTypeText: { [key: string]: string } = {
edit: '编辑',
add: '新增',
menu: '菜单权限',
data: '数据权限',
prod_status: '商品状态控制',
prod_audit: '商品上架审核',
prod_sku: '',
};
export const SystemDataScopeEnum = {
ALL: 1, // 全部数据权限
DEPT_CUSTOM: 2, // 指定部门数据权限
DEPT_ONLY: 3, // 部门数据权限
DEPT_AND_CHILD: 4, // 部门及以下数据权限
DEPT_SELF: 5, // 仅本人数据权限
};
export const systemDataScopetStatus = [
{ label: '全部数据权限', value: 1 },
{ label: '指定部门数据权限', value: 2 },
{ label: '部门数据权限', value: 3 },
{ label: '部门及以下数据权限', value: 4 },
{ label: '仅本人数据权限', value: 5 },
];

View File

@@ -1,170 +0,0 @@
import type {
ProColumns,
ProFormColumnsType,
} from '@ant-design/pro-components';
import { Tag } from 'antd';
import dayjs from 'dayjs';
import { tenantStatus } from '@/constants';
import type { DeptVO } from '@/services/system/dept';
import { getStatusLabel } from '@/utils/constant';
export const baseDeptColumns: ProColumns<DeptVO>[] = [
{
title: '部门名称',
dataIndex: 'name',
ellipsis: true,
hideInSearch: true,
},
// { prop: "leaderUserId", label: "负责人", width: 100 },
{
title: '负责人',
dataIndex: 'leaderUserId',
hideInSearch: true,
},
// { prop: "sort", label: "排序", width: 100 },
{
title: '排序',
dataIndex: 'sort',
hideInSearch: true,
},
// {
// prop: "status",
// label: "状态",
// width: 100,
// render: (record) => (
// <ElTag type={record.status == 1 ? "info" : "primary"}>
// {getStatusLabel(tenantStatus, record.status)}
// </ElTag>
// )
// },
{
title: '状态',
dataIndex: 'status',
hideInSearch: true,
render: (_, record: DeptVO) => [
<Tag
key={record.status}
color={record.status === 1 ? 'default' : 'processing'}
>
{getStatusLabel(tenantStatus, record.status)}
</Tag>,
],
},
// {
// prop: "createTime",
// label: "创建时间",
// width: 160,
// render: (row) => dateFormatter(row.createTime)
// },
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
'createTime[0]': dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
'createTime[1]': dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: DeptVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (_type: string): ProFormColumnsType[] => [
{
title: '上级部门',
dataIndex: 'parentId',
valueType: 'treeSelect',
fieldProps: () => {
return {
multiple: true,
placeholder: '请选择上级部门',
options: [{ label: '11', value: 5016 }],
};
},
},
{
title: '部门名称',
dataIndex: 'name',
valueType: 'text',
formItemProps: {
rules: [
{
required: true,
message: '请输入部门名称',
},
],
},
},
{
title: '显示顺序',
dataIndex: 'sort',
valueType: 'digit',
fieldProps: {
min: 0,
},
formItemProps: {
rules: [
{
required: true,
message: '请输入显示顺序',
},
],
},
},
{
title: '负责人',
dataIndex: 'leaderUserId',
formItemProps: {
rules: [
{
required: true,
message: '请选择负责人',
},
],
},
},
{
title: '邮箱',
dataIndex: 'email',
formItemProps: {
rules: [
{
required: true,
message: '请输入邮箱',
},
],
},
},
{
title: '状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
options: [
{
label: '正常',
value: 1,
},
{
label: '禁用',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
},
],
},
},
];

View File

@@ -1,136 +1,5 @@
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createDept,
type DeptReqVO,
type DeptVO,
deleteDept,
getDeptPage,
updateDept,
} from '@/services/system/dept';
import { handleTree } from '@/utils/tree';
import { baseDeptColumns, formColumns } from './config';
const SyStemDept = () => { const SyStemDept = () => {
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null); return <>SyStemDept</>;
const tableRef = useRef<ActionType>(null);
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
const handleEdit = (record: DeptVO) => {
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const onFetch = async (
params: DeptReqVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getDeptPage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: handleTree(data),
success: true,
total: data.total,
};
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open({});
};
const handleSubmit = useCallback(
async (values: DeptVO) => {
if (type === 'create') {
await createDept(values);
} else {
await updateDept({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<DeptVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (_text: React.ReactNode, record: DeptVO, _: any, action: any) => [
<a key="editable" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteDept(record.id);
action?.reload();
}}
okText="是"
cancelText="否"
>
<a></a>
</Popconfirm>,
],
};
const columns = [...baseDeptColumns, actionColumns];
return (
<>
<EnhancedProTable<DeptVO>
ref={tableRef}
columns={columns}
request={onFetch}
toolbarActions={toolbarActions}
headerTitle="租户列表"
showIndex={false}
showSelection={false}
expandable={{
defaultExpandAllRows: true,
}}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
</>
);
}; };
export default SyStemDept; export default SyStemDept;

View File

@@ -1,120 +0,0 @@
import type {
ProColumns,
ProFormColumnsType,
} from '@ant-design/pro-components';
import { Tag } from 'antd';
import dayjs from 'dayjs';
import { tenantStatus } from '@/constants';
import type { DictTypeVO } from '@/services/system/dict/dict.type';
export const baseDictTypeColumns: ProColumns<DictTypeVO>[] = [
{
title: '字典编号',
dataIndex: 'id',
width: 80,
align: 'left',
hideInSearch: true,
},
{
title: '字典名称',
dataIndex: 'name',
width: 120,
},
{
title: '字典类型',
dataIndex: 'type',
width: 120,
},
{
title: '状态',
dataIndex: 'status',
width: 100,
render: (_, record) => (
<Tag
key={record.status}
color={record.status === 1 ? 'default' : 'processing'}
>
{record.status === 1 ? '正常' : '禁用'}
</Tag>
),
},
{
title: '备注',
dataIndex: 'remark',
width: 120,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
'createTime[0]': dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
'createTime[1]': dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: DictTypeVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (type: string): ProFormColumnsType[] => [
{
title: '字典名称',
dataIndex: 'name',
valueType: 'text',
colProps: {
span: 12,
},
formItemProps: {
rules: [
{
required: true,
message: '请输入字典名称',
},
],
},
},
{
title: '字典类型',
dataIndex: 'type',
valueType: 'text',
fieldProps: {
disabled: type === 'update',
},
colProps: {
span: 12,
},
formItemProps: {
rules: [
{
required: true,
message: '请输入字典类型',
},
],
},
},
{
title: '状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
options: tenantStatus,
},
},
{
title: '备注',
dataIndex: 'remark',
valueType: 'textarea',
colProps: {
span: 24,
},
},
];

View File

@@ -1,189 +0,0 @@
import type {
ProColumns,
ProFormColumnsType,
} from '@ant-design/pro-components';
import { Tag } from 'antd';
import dayjs from 'dayjs';
import { tenantStatus } from '@/constants';
import type { DictDataVO } from '@/services/system/dict/dict.data';
import { getStatusLabel } from '@/utils/constant';
export const baseDictDataColumns: ProColumns<DictDataVO>[] = [
{
title: '字典编码',
dataIndex: 'id',
width: 80,
hideInSearch: true,
},
{
title: '字典标签',
dataIndex: 'label',
width: 120,
},
{
title: '字典键值',
dataIndex: 'value',
width: 120,
},
{
title: '字典排序',
dataIndex: 'sort',
width: 80,
},
{
title: '状态',
dataIndex: 'status',
width: 80,
render: (_, record) => (
<Tag color={record.status === 1 ? 'red' : 'green'}>
{getStatusLabel(tenantStatus, record.status)}
</Tag>
),
},
{
title: '颜色类型',
dataIndex: 'colorType',
width: 80,
},
{
title: 'CSS Class',
dataIndex: 'cssClass',
width: 120,
},
{
title: '备注',
dataIndex: 'remark',
width: 120,
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
'createTime[0]': dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
'createTime[1]': dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: DictDataVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (_type: string): ProFormColumnsType[] => [
{
title: '字典类型',
dataIndex: 'dictType',
fieldProps: {
disabled: true,
},
},
{
title: '字典标签',
dataIndex: 'label',
formItemProps: {
rules: [
{
required: true,
message: '请输入字典标签',
},
],
},
},
{
title: '字典键值',
dataIndex: 'value',
formItemProps: {
rules: [
{
required: true,
message: '请输入字典键值',
},
],
},
},
{
title: '显示排序',
dataIndex: 'sort',
valueType: 'digit',
fieldProps: {
min: 0,
max: 9999,
},
formItemProps: {
rules: [
{
required: true,
message: '请输入排序',
},
],
},
},
{
title: '状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
options: [
{
label: '启用',
value: 1,
},
{
label: '禁用',
value: 0,
},
],
},
formItemProps: {
rules: [
{
required: true,
},
],
},
},
{
title: '颜色类型',
dataIndex: 'colorType',
valueType: 'select',
fieldProps: {
options: [
{
label: '默认(waiting)',
value: 'waiting',
},
{
label: '成功(success)',
value: 'success',
},
{
label: '信息(processing)',
value: 'processing',
},
{
label: '失败(error)',
value: 'error',
},
{
label: '警告(warning)',
value: 'warning',
},
],
},
},
{
title: 'CSS Class',
dataIndex: 'cssClass',
},
{
title: '备注',
dataIndex: 'remark',
},
];

View File

@@ -1,144 +1,5 @@
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { history } from '@umijs/max';
import { Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createDictType,
type DictTypeVO,
deleteDictType,
getDictTypePage,
updateDictType,
} from '@/services/system/dict/dict.type';
import { baseDictTypeColumns, formColumns } from './config';
const SyStemDict = () => { const SyStemDict = () => {
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null); return <>SyStemDict</>;
const tableRef = useRef<ActionType>(null);
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
//获取路由数据
const handleEdit = (record: DictTypeVO) => {
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const onFetch = async (params: { pageSize?: number; current?: number }) => {
const data = await getDictTypePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open({});
};
const handleSubmit = useCallback(
async (values: DictTypeVO) => {
if (type === 'create') {
await createDictType(values);
} else {
await updateDictType({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<DictTypeVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (
_text: React.ReactNode,
record: DictTypeVO,
_: any,
action: any,
) => [
<a key="editable" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteDictType(record.id);
action?.reload();
}}
okText="是"
cancelText="否"
>
<a></a>
</Popconfirm>,
<a
key="data"
onClick={() =>
history.push({
pathname: '/system/dict/data/' + record.type,
})
}
>
</a>,
],
};
const columns = [...baseDictTypeColumns, actionColumns];
return (
<>
<EnhancedProTable<DictTypeVO>
ref={tableRef}
columns={columns}
request={onFetch}
toolbarActions={toolbarActions}
headerTitle="租户列表"
showIndex={false}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
</>
);
}; };
export default SyStemDict; export default SyStemDict;

View File

@@ -0,0 +1,105 @@
import type {
ProColumns,
ProDescriptionsItemProps,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { LoginLogVO } from '@/services/system/log/login';
export const baseTenantColumns: ProColumns<LoginLogVO>[] = [
{
title: '日志编号',
dataIndex: 'id',
tip: '日志编号',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '操作类型',
dataIndex: 'logType',
hideInSearch: true, // 在搜索表单中隐藏
tip: '操作类型', // 提示信息
},
{
title: '操作模块',
dataIndex: 'type',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '用户名称',
dataIndex: 'username',
},
{
title: '登录地址',
dataIndex: 'userIp',
},
{
title: '浏览器',
dataIndex: 'userAgent',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '登录结果',
dataIndex: 'result',
hideInSearch: true,
},
{
title: '登录日期',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: LoginLogVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const descriptionsColumns = (): ProDescriptionsItemProps<
Record<string, any>,
'text'
>[] => [
{
title: '日志编号',
key: 'id',
dataIndex: 'id',
},
{
title: '操作类型',
key: 'logType',
dataIndex: 'logType',
},
{
title: '用户名称',
key: 'username',
dataIndex: 'username',
},
{
title: '登录地址',
key: 'userIp',
dataIndex: 'userIp',
},
{
title: '浏览器',
key: 'userAgent',
dataIndex: 'userAgent',
},
{
title: '登录结果',
key: 'result',
dataIndex: 'result',
},
{
title: '登录日期',
key: 'createTime',
dataIndex: 'createTime',
},
];

View File

@@ -1,5 +1,67 @@
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import React, { useRef } from 'react';
import EnhancedProTable from '@/components/EnhancedProTable';
import ModalDescriptions, {
type DescriptionsFormRef,
} from '@/components/ModalDescriptions';
import { getLoginLogPage, type LoginLogVO } from '@/services/system/log/login';
import { baseTenantColumns, descriptionsColumns } from './config';
const SyStemLogLogin = () => { const SyStemLogLogin = () => {
return <>SyStemLogLogin</>; const tableRef = useRef<ActionType>(null);
const descriptionsRef = useRef<DescriptionsFormRef>(null);
const onFetch = async (
params: LoginLogVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getLoginLogPage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleDetail = (record: LoginLogVO) => {
descriptionsRef.current?.open(record);
};
const actionColumns: ProColumns<LoginLogVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 80,
render: (text: React.ReactNode, record: LoginLogVO) => [
<a key="editable" onClick={() => handleDetail(record)}>
</a>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<LoginLogVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
showSelection={false}
/>
<ModalDescriptions
ref={descriptionsRef}
title="登录日志详情"
columns={descriptionsColumns()}
/>
</>
);
}; };
export default SyStemLogLogin; export default SyStemLogLogin;

View File

@@ -0,0 +1,134 @@
import {
type ProColumns,
type ProDescriptionsItemProps,
ProFormColumnsType,
} from '@ant-design/pro-components';
import { DescriptionsProps } from 'antd';
import dayjs from 'dayjs';
import type { OperateLogVO } from '@/services/system/log/operate';
export const baseTenantColumns: ProColumns<OperateLogVO>[] = [
{
title: '日志编号',
dataIndex: 'id',
tip: '日志编号',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '操作人',
dataIndex: 'userName',
tip: '操作人', // 提示信息
},
{
title: '操作模块',
dataIndex: 'type',
},
{
title: '操作名',
dataIndex: 'subType',
},
{
title: '操作内容',
dataIndex: 'action',
},
{
title: '操作时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: OperateLogVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
{
title: '业务编号',
dataIndex: 'bizId',
},
{
title: '操作 IP',
dataIndex: 'userIp',
hideInSearch: true,
},
];
export const descriptionsColumns = (): ProDescriptionsItemProps<
Record<string, any>,
'text'
>[] => [
{
title: '日志主键',
key: 'id',
dataIndex: 'id',
},
{
title: '链路追踪',
key: 'traceId',
dataIndex: 'traceId',
},
{
title: '操作人编号',
key: 'userId',
dataIndex: 'userId',
},
{
title: '操作人名字',
key: 'userName',
dataIndex: 'userName',
},
{
title: '操作人 IP',
key: 'userIp',
dataIndex: 'userIp',
},
{
title: '操作人 UA',
key: 'userAgent',
dataIndex: 'userAgent',
},
{
title: '操作模块',
key: 'type',
dataIndex: 'type',
},
{
title: '操作名',
key: 'subType',
dataIndex: 'subType',
},
{
title: '操作内容',
key: 'action',
dataIndex: 'action',
},
{
title: '操作拓展参数',
key: 'extra',
dataIndex: 'extra',
},
{
title: '请求 URL',
key: 'requestUrl',
dataIndex: 'requestUrl',
},
{
title: '操作时间',
key: 'createTime',
dataIndex: 'createTime',
},
{
title: '业务编号',
key: 'bizId',
dataIndex: 'bizId',
},
];

View File

@@ -1,5 +1,70 @@
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import React, { useRef } from 'react';
import EnhancedProTable from '@/components/EnhancedProTable';
import ModalDescriptions, {
type DescriptionsFormRef,
} from '@/components/ModalDescriptions';
import {
getOperateLogPage,
type OperateLogVO,
} from '@/services/system/log/operate';
import { baseTenantColumns, descriptionsColumns } from './config';
const SyStemLogOperate = () => { const SyStemLogOperate = () => {
return <>SyStemLogOperate</>; const tableRef = useRef<ActionType>(null);
const descriptionsRef = useRef<DescriptionsFormRef>(null);
const onFetch = async (
params: OperateLogVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getOperateLogPage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleDetail = (record: OperateLogVO) => {
descriptionsRef.current?.open(record);
};
const actionColumns: ProColumns<OperateLogVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 80,
render: (text: React.ReactNode, record: OperateLogVO) => [
<a key="editable" onClick={() => handleDetail(record)}>
</a>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<OperateLogVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="操作日志"
showIndex={false}
showSelection={false}
/>
<ModalDescriptions
ref={descriptionsRef}
title="操作日志详情"
columns={descriptionsColumns()}
/>
</>
);
}; };
export default SyStemLogOperate; export default React.memo(SyStemLogOperate);

View File

@@ -1,125 +0,0 @@
// src/pages/system/menu/config.tsx
import type {
ProColumns,
ProFormColumnsType,
} from '@ant-design/pro-components';
import { Switch } from 'antd';
import type { MenuVO } from '@/services/system/menu';
export const baseMenuColumns: ProColumns<MenuVO>[] = [
{
title: '菜单名称',
dataIndex: 'name',
width: 150,
},
{
title: '图标',
dataIndex: 'icon',
width: 60,
render: (_, record: MenuVO) => (
<span>
{record.icon ? <i className={`anticon ${record.icon}`} /> : '—'}
</span>
),
},
{
title: '排序',
dataIndex: 'sort',
width: 80,
},
{
title: '权限标识',
dataIndex: 'permission',
width: 150,
},
{
title: '组件路径',
dataIndex: 'component',
width: 150,
},
{
title: '组件名称',
dataIndex: 'componentName',
width: 150,
},
{
title: '状态',
dataIndex: 'status',
width: 80,
render: (_, record: MenuVO) => (
<Switch
checked={record.status === 1}
disabled={true} // 可后续改为可编辑
/>
),
},
];
export const formColumns = (_type: string): ProFormColumnsType[] => [
{
title: '菜单名称',
dataIndex: 'name',
formItemProps: {
rules: [
{
required: true,
message: '请输入菜单名称',
},
],
},
},
{
title: '图标',
dataIndex: 'icon',
valueType: 'select',
fieldProps: {
placeholder: '请选择图标',
options: [
{ label: '商品', value: 'icon-product' },
{ label: '系统', value: 'icon-system' },
{ label: '用户', value: 'icon-user' },
{ label: '设置', value: 'icon-setting' },
],
},
},
{
title: '排序',
dataIndex: 'sort',
valueType: 'digit',
fieldProps: {
placeholder: '请输入排序值',
},
},
{
title: '权限标识',
dataIndex: 'permission',
fieldProps: {
placeholder: '请输入权限标识',
},
},
{
title: '组件路径',
dataIndex: 'component',
fieldProps: {
placeholder: '请输入组件路径',
},
},
{
title: '组件名称',
dataIndex: 'componentName',
fieldProps: {
placeholder: '请输入组件名称',
},
},
{
title: '状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
options: [
{ label: '启用', value: 1 },
{ label: '禁用', value: 0 },
],
},
},
];

View File

@@ -1,126 +1,5 @@
// src/pages/system/menu/index.tsx const SyStemMenu = () => {
return <>SyStemMenu</>;
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createMenu,
deleteMenu,
getMenuList,
type MenuReqVO,
type MenuVO,
updateMenu,
} from '@/services/system/menu';
import { handleTree } from '@/utils/tree';
import { baseMenuColumns, formColumns } from './config';
const SystemMenu = () => {
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const tableRef = useRef<ActionType>(null);
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
const handleEdit = (record: MenuVO) => {
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const onFetch = async (params: MenuReqVO) => {
const data = await getMenuList({
...params,
});
return {
data: handleTree(data),
success: true,
total: data.total,
};
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open({});
};
const handleSubmit = useCallback(
async (values: MenuVO) => {
if (type === 'create') {
await createMenu(values);
} else {
await updateMenu({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<MenuVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (_text: React.ReactNode, record: MenuVO, _: any, action: any) => [
<a key="editable" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteMenu(record.id);
action?.reload();
}}
okText="是"
cancelText="否"
>
<a></a>
</Popconfirm>,
],
};
const columns = [...baseMenuColumns, actionColumns];
return (
<>
<EnhancedProTable<MenuVO>
ref={tableRef}
columns={columns}
request={onFetch}
toolbarActions={toolbarActions}
headerTitle="租户列表"
showIndex={false}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
</>
);
}; };
export default SystemMenu; export default SyStemMenu;

View File

@@ -0,0 +1,178 @@
import type {
ProColumns,
ProDescriptionsItemProps,
ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { MailAccountVO } from '@/services/system/message/mail/account';
export const baseTenantColumns: ProColumns<MailAccountVO>[] = [
{
title: '邮箱',
dataIndex: 'mail',
width: 100,
},
{
title: '用户名',
dataIndex: 'username',
},
{
title: 'SMTP 服务器域名',
dataIndex: 'host',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: 'SMTP 服务器端口',
dataIndex: 'port',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '是否开启 SSL',
dataIndex: 'sslEnable',
valueType: 'radio',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '是否开启 STARTTLS',
dataIndex: 'starttlsEnable',
valueType: 'radio',
hideInSearch: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
hideInSearch: true, // 在搜索表单中隐藏
render: (_, record: MailAccountVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (): ProFormColumnsType[] => [
{
title: '邮箱',
dataIndex: 'mail',
},
{
title: '用户名',
dataIndex: 'username',
formItemProps: {
rules: [
{
required: true,
message: '请输入用户名',
},
],
},
},
{
title: '密码',
dataIndex: 'password',
formItemProps: {
rules: [
{
required: true,
message: '请输入密码',
},
],
},
},
{
title: 'SMTP 服务器域名',
dataIndex: 'host',
formItemProps: {
rules: [
{
required: true,
message: '请输入SMTP 服务器域名',
},
],
},
},
{
title: 'SMTP 服务器端口',
dataIndex: 'port',
valueType: 'digit',
fieldProps: {
defaultValue: 465,
},
formItemProps: {
rules: [
{
required: true,
message: 'SMTP 服务器端口',
},
],
},
},
{
title: '是否开启 SSL',
dataIndex: 'sslEnable',
valueType: 'select',
fieldProps: {
placeholder: '请选择是否开启 SSL',
options: [
{
label: '正常',
value: 1,
},
{
label: '禁用',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请选择是否开启 SSL',
},
],
},
},
{
title: '是否开启 STARTTLS',
dataIndex: 'starttlsEnable',
valueType: 'select',
fieldProps: {
placeholder: '请选择是否开启 STARTTLS',
options: [
{
label: '正常',
value: 1,
},
{
label: '禁用',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请选择是否开启 STARTTLS',
},
],
},
},
];
export const formTestColumns = (type: string): ProFormColumnsType[] => [
{
title: '模板内容',
dataIndex: 'content',
valueType: 'textarea',
},
{
title: '手机号',
dataIndex: 'mobile',
},
];
// {
// title: "模板内容",
// dataIndex: "content",
// valueType: "textarea",
// },

View File

@@ -0,0 +1,152 @@
import { PlusOutlined } from '@ant-design/icons';
import type {
ActionType,
ProColumns,
ProCoreActionType,
} from '@ant-design/pro-components';
import { message, Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createMailAccount,
deleteMailAccount,
getMailAccount,
getMailAccountPage,
type MailAccountVO,
updateMailAccount,
} from '@/services/system/message/mail/account';
import { baseTenantColumns, formColumns, formTestColumns } from './config';
const SyStemMessageSmsTemplate = () => {
const tableRef = useRef<ActionType>(null);
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const [type, setType] = useState<'create' | 'update' | 'test'>('create');
const testRef = useRef<ConfigurableDrawerFormRef>(null);
const [currentItem, setCurrentItem] = useState<MailAccountVO>();
const onFetch = async (
params: MailAccountVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getMailAccountPage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleSend = async (record: MailAccountVO) => {
setType('test');
setCurrentItem(record);
testRef.current?.open(record);
};
const handleEdit = (record: MailAccountVO) => {
setType('update');
setCurrentItem(record);
configurableDrawerRef.current?.open(record);
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open();
};
const handleSubmit = useCallback(
async (values: MailAccountVO) => {
if (type === 'create') {
await createMailAccount(values);
message.success('创建成功');
} else {
await updateMailAccount({
...values,
id: currentItem!.id,
});
message.success('编辑成功');
}
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<MailAccountVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (
text: React.ReactNode,
record: MailAccountVO,
_: number,
action: ProCoreActionType | undefined,
) => [
<a key="edit" onClick={() => handleEdit(record)}>
</a>,
// <a key="detail" onClick={() => handleSend(record)}>
// 详情
// </a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteMailAccount(record.id);
message.success('删除成功');
action?.reload?.();
}}
okText="是"
cancelText="否"
>
<a style={{ color: 'var(--ant-red)' }} key="delete">
</a>
</Popconfirm>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<MailAccountVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
toolbarActions={toolbarActions}
showSelection={false}
/>
<ConfigurableDrawerForm
labelCol={{ span: 7 }}
wrapperCol={{ span: 17 }}
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns()}
onSubmit={handleSubmit}
/>
</>
);
};
export default SyStemMessageSmsTemplate;

View File

@@ -0,0 +1,171 @@
import type {
ProColumns,
ProDescriptionsItemProps,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { SmsLogVO } from '@/services/system/message/sms/log';
export const baseTenantColumns: ProColumns<SmsLogVO>[] = [
{
title: '编号',
dataIndex: 'id',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '手机号',
dataIndex: 'mobile',
},
{
title: '短信内容',
dataIndex: 'templateContent',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '发送状态',
dataIndex: 'sendStatus',
},
{
title: '发送人名称',
dataIndex: 'templateNickname',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '接收状态',
dataIndex: 'receiveStatus',
},
{
title: '短信渠道',
dataIndex: 'channelId',
},
{
title: '模板编号',
dataIndex: 'templateId',
},
{
title: '短信类型',
dataIndex: 'templateType',
hideInSearch: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
hideInSearch: true,
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: SmsLogVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
{
title: '接收时间',
dataIndex: 'receiveTime',
valueType: 'dateRange',
hideInTable: true,
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: SmsLogVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const descriptionsColumns = (): ProDescriptionsItemProps<
Record<string, any>,
'text'
>[] => [
{
title: '日志主键',
key: 'id',
dataIndex: 'id',
},
{
title: '短信渠道',
key: 'channelId',
dataIndex: 'channelId',
},
{
title: '短信模板',
key: 'templateCode',
dataIndex: 'templateCode',
},
{
title: 'API 的模板编号',
key: 'apiTemplateId',
dataIndex: 'apiTemplateId',
},
{
title: '用户信息',
key: 'mobile',
dataIndex: 'mobile',
},
{
title: '短信内容',
key: 'templateContent',
dataIndex: 'templateContent',
},
{
title: '短信参数',
key: 'templateParams',
dataIndex: 'templateParams',
},
{
title: '创建时间',
key: 'createTime',
dataIndex: 'createTime',
},
{
title: '发送状态',
key: 'sendStatus',
dataIndex: 'sendStatus',
},
{
title: '发送时间',
key: 'sendTime',
dataIndex: 'sendTime',
},
{
title: 'API 发送结果',
key: 'apiSendMsg',
dataIndex: 'apiSendMsg',
},
{
title: 'API 短信编号',
key: 'apiSerialNo',
dataIndex: 'apiSerialNo',
},
{
title: 'API 请求编号',
key: 'apiRequestId',
dataIndex: 'apiRequestId',
},
{
title: 'API 接收状态',
key: 'receiveStatus',
dataIndex: 'receiveStatus',
},
{
title: 'API 接收结果',
key: 'apiReceiveMsg',
dataIndex: 'apiReceiveMsg',
},
];

View File

@@ -0,0 +1,70 @@
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import React, { useRef } from 'react';
import EnhancedProTable from '@/components/EnhancedProTable';
import ModalDescriptions, {
type DescriptionsFormRef,
} from '@/components/ModalDescriptions';
import {
getSmsLogPage,
type SmsLogVO,
} from '@/services/system/message/sms/log';
import { baseTenantColumns, descriptionsColumns } from './config';
const SyStemMessageNotifyMessage = () => {
const tableRef = useRef<ActionType>(null);
const descriptionsRef = useRef<DescriptionsFormRef>(null);
const onFetch = async (
params: SmsLogVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getSmsLogPage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleDetail = (record: SmsLogVO) => {
descriptionsRef.current?.open(record);
};
const actionColumns: ProColumns<SmsLogVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 80,
render: (text: React.ReactNode, record: SmsLogVO) => [
<a key="editable" onClick={() => handleDetail(record)}>
</a>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<SmsLogVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
showSelection={false}
/>
<ModalDescriptions
ref={descriptionsRef}
title="登录日志详情"
columns={descriptionsColumns()}
/>
</>
);
};
export default SyStemMessageNotifyMessage;

View File

@@ -0,0 +1,165 @@
import type {
ProColumns,
ProDescriptionsItemProps,
ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { SmsTemplateVO } from '@/services/system/message/sms/template';
export const baseTenantColumns: ProColumns<SmsTemplateVO>[] = [
{
title: '模板编码',
dataIndex: 'code',
width: 100,
},
{
title: '模板名称',
dataIndex: 'name',
},
{
title: '模板标题',
dataIndex: 'type',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '模板内容',
dataIndex: 'content',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '发送人名称',
dataIndex: 'type',
},
{
title: '邮箱账号',
dataIndex: 'type',
},
{
title: '开启状态',
dataIndex: 'status',
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
render: (_, record: SmsTemplateVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (type: string): ProFormColumnsType[] => [
{
title: '短信渠道编号',
dataIndex: 'channelId',
valueType: 'select',
formItemProps: {
rules: [
{
required: true,
message: '请选择短信渠道编号',
},
],
},
},
{
title: '短信类型',
dataIndex: 'type',
valueType: 'select',
formItemProps: {
rules: [
{
required: true,
message: '请选择短信类型',
},
],
},
},
{
title: '模板编号',
dataIndex: 'code',
formItemProps: {
rules: [
{
required: true,
message: '请输入模板编号',
},
],
},
},
{
title: '模板名称',
dataIndex: 'name',
formItemProps: {
rules: [
{
required: true,
message: '请输入模板名称',
},
],
},
},
{
title: '模板内容',
dataIndex: 'type',
formItemProps: {
rules: [
{
required: true,
message: '请输入模板内容',
},
],
},
},
{
title: '开启状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
placeholder: '请选择开启状态',
options: [
{
label: '正常',
value: 1,
},
{
label: '禁用',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请选择状态',
},
],
},
},
{
title: '短信 API 模板编号',
dataIndex: 'apiTemplateId',
fieldProps: {
placeholder: '请输入短信 API 的模板编号',
},
},
{
title: '备注',
dataIndex: 'remark',
fieldProps: {
placeholder: '请输入备注',
},
},
];
export const formTestColumns = (type: string): ProFormColumnsType[] => [
{
title: '模板内容',
dataIndex: 'content',
valueType: 'textarea',
},
{
title: '手机号',
dataIndex: 'mobile',
},
];

View File

@@ -0,0 +1,174 @@
import { PlusOutlined } from '@ant-design/icons';
import type {
ActionType,
ProColumns,
ProCoreActionType,
} from '@ant-design/pro-components';
import { message, Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createSmsTemplate,
deleteSmsTemplate,
getSmsTemplatePage,
type SmsTemplateVO,
sendSms,
updateSmsTemplate,
} from '@/services/system/message/sms/template';
import { baseTenantColumns, formColumns, formTestColumns } from './config';
const SyStemMessageSmsTemplate = () => {
const tableRef = useRef<ActionType>(null);
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const [type, setType] = useState<'create' | 'update' | 'test'>('create');
const testRef = useRef<ConfigurableDrawerFormRef>(null);
const [currentItem, setCurrentItem] = useState<SmsTemplateVO>();
const onFetch = async (
params: SmsTemplateVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getSmsTemplatePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleSend = async (record: SmsTemplateVO) => {
setType('test');
setCurrentItem(record);
testRef.current?.open(record);
};
const handleEdit = (record: SmsTemplateVO) => {
setType('update');
setCurrentItem(record);
configurableDrawerRef.current?.open(record);
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open();
};
const handleSubmit = useCallback(
async (values: SmsTemplateVO) => {
if (type === 'create') {
await createSmsTemplate(values);
message.success('创建成功');
} else {
await updateSmsTemplate({
...values,
id: currentItem!.id,
});
message.success('编辑成功');
}
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const handleTestSubmit = useCallback(
async (values: SmsTemplateVO) => {
if (currentItem?.status === 1) {
return message.error('请先开启状态');
}
const res = await sendSms({
...currentItem,
...values,
mobile: '',
templateParams: new Map(),
templateCode: currentItem!.code,
});
message.success('提交发送成功!发送结果,见发送日志编号:' + res);
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<SmsTemplateVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (
text: React.ReactNode,
record: SmsTemplateVO,
_: number,
action: ProCoreActionType | undefined,
) => [
<a key="edit" onClick={() => handleEdit(record)}>
</a>,
<a key="detail" onClick={() => handleSend(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteSmsTemplate(record.id);
message.success('删除成功');
action?.reload?.();
}}
okText="是"
cancelText="否"
>
<a style={{ color: 'var(--ant-red)' }} key="delete">
</a>
</Popconfirm>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<SmsTemplateVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
toolbarActions={toolbarActions}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
<ConfigurableDrawerForm
ref={testRef}
title={formStatusType[type]}
columns={formTestColumns(type)}
onSubmit={handleTestSubmit}
/>
</>
);
};
export default SyStemMessageSmsTemplate;

View File

@@ -0,0 +1,105 @@
import type {
ProColumns,
ProDescriptionsItemProps,
ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { NoticeVO } from '@/services/system/message/notice';
export const baseTenantColumns: ProColumns<NoticeVO>[] = [
{
title: '公告编号',
dataIndex: 'id',
width: 100,
hideInSearch: true,
},
{
title: '公告标题',
dataIndex: 'title',
},
{
title: '公告类型',
dataIndex: 'type',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '状态',
dataIndex: 'status',
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
hideInSearch: true,
render: (_, record: NoticeVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (type: string): ProFormColumnsType[] => [
{
title: '公告标题',
dataIndex: 'title',
tip: '公告标题', // 提示信息
formItemProps: {
rules: [
{
required: true,
message: '请输入用户名',
},
],
},
},
{
title: '公告内容',
dataIndex: 'content',
formItemProps: {
rules: [
{
required: true,
message: '请输入公告内容',
},
],
},
},
{
title: '公告类型',
dataIndex: 'type',
formItemProps: {
rules: [
{
required: true,
message: '请输入公告类型',
},
],
},
},
{
title: '状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
options: [
{
label: '正常',
value: 1,
},
{
label: '禁用',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请选择状态',
},
],
},
},
{
title: '备注',
dataIndex: 'username',
},
];

View File

@@ -0,0 +1,126 @@
import type {
ActionType,
ProColumns,
ProCoreActionType,
} from '@ant-design/pro-components';
import { Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import { formStatusType } from '@/constants';
import {
createNotice,
deleteNotice,
getNoticePage,
type NoticeVO,
pushNotice,
updateNotice,
} from '@/services/system/message/notice';
import { baseTenantColumns, formColumns } from './config';
const SyStemMessageNotice = () => {
const tableRef = useRef<ActionType>(null);
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
const onFetch = async (
params: NoticeVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getNoticePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleSend = async (record: NoticeVO) => {
await pushNotice(record.id);
tableRef.current?.reload();
};
const handleEdit = (record: NoticeVO) => {
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const handleSubmit = useCallback(
async (values: NoticeVO) => {
if (type === 'create') {
await createNotice(values);
} else {
await updateNotice({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const actionColumns: ProColumns<NoticeVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (
text: React.ReactNode,
record: NoticeVO,
_: number,
action: ProCoreActionType | undefined,
) => [
<a key="edit" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteNotice(record.id);
action?.reload?.();
}}
okText="是"
cancelText="否"
>
<a style={{ color: 'var(--ant-red)' }} key="delete">
</a>
</Popconfirm>,
<a key="detail" onClick={() => handleSend(record)}>
</a>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<NoticeVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
</>
);
};
export default SyStemMessageNotice;

View File

@@ -0,0 +1,142 @@
import type {
ProColumns,
ProDescriptionsItemProps,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { NotifyMessageVO } from '@/services/system/message/notify/message';
export const baseTenantColumns: ProColumns<NotifyMessageVO>[] = [
{
title: '编号',
dataIndex: 'id',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '用户类型',
dataIndex: 'userType',
},
{
title: '用户编号',
dataIndex: 'userId',
},
{
title: '模板编码',
dataIndex: 'templateCode',
},
{
title: '发送人名称',
dataIndex: 'templateNickname',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '模版内容',
dataIndex: 'templateContent',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '模版参数',
dataIndex: 'templateParams',
hideInSearch: true,
},
{
title: '模版类型',
dataIndex: 'templateType',
valueType: 'select',
},
{
title: '是否已读',
dataIndex: 'readStatus',
hideInSearch: true,
},
{
title: '阅读时间',
dataIndex: 'readTime',
hideInSearch: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: NotifyMessageVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const descriptionsColumns = (): ProDescriptionsItemProps<
Record<string, any>,
'text'
>[] => [
{
title: '编号',
key: 'id',
dataIndex: 'id',
},
{
title: '用户类型',
key: 'userType',
dataIndex: 'userType',
},
{
title: '用户编号',
key: 'userId',
dataIndex: 'userId',
},
{
title: '模版编号',
key: 'templateId',
dataIndex: 'templateId',
},
{
title: '模板编码',
key: 'templateCode',
dataIndex: 'templateCode',
},
{
title: '发送人名称',
key: 'templateNickname',
dataIndex: 'templateNickname',
},
{
title: '模版内容',
key: 'templateContent',
dataIndex: 'templateContent',
},
{
title: '模版参数',
key: 'createTime',
dataIndex: 'createTime',
},
{
title: '模版类型',
key: 'templateType',
dataIndex: 'templateType',
},
{
title: '是否已读',
key: 'readStatus',
dataIndex: 'readStatus',
},
{
title: '阅读时间',
key: 'readTime',
dataIndex: 'readTime',
},
{
title: '创建时间',
key: 'createTime',
dataIndex: 'createTime',
},
];

View File

@@ -0,0 +1,70 @@
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import React, { useRef } from 'react';
import EnhancedProTable from '@/components/EnhancedProTable';
import ModalDescriptions, {
type DescriptionsFormRef,
} from '@/components/ModalDescriptions';
import {
getNotifyMessagePage,
type NotifyMessageVO,
} from '@/services/system/message/notify/message';
import { baseTenantColumns, descriptionsColumns } from './config';
const SyStemMessageNotifyMessage = () => {
const tableRef = useRef<ActionType>(null);
const descriptionsRef = useRef<DescriptionsFormRef>(null);
const onFetch = async (
params: NotifyMessageVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getNotifyMessagePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleDetail = (record: NotifyMessageVO) => {
descriptionsRef.current?.open(record);
};
const actionColumns: ProColumns<NotifyMessageVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 80,
render: (text: React.ReactNode, record: NotifyMessageVO) => [
<a key="editable" onClick={() => handleDetail(record)}>
</a>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<NotifyMessageVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
showSelection={false}
/>
<ModalDescriptions
ref={descriptionsRef}
title="登录日志详情"
columns={descriptionsColumns()}
/>
</>
);
};
export default SyStemMessageNotifyMessage;

View File

@@ -0,0 +1,193 @@
import type {
ProColumns,
ProDescriptionsItemProps,
ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { NotifyTemplateVO } from '@/services/system/message/notify/template';
export const baseTenantColumns: ProColumns<NotifyTemplateVO>[] = [
{
title: '模板编码',
dataIndex: 'code',
width: 100,
},
{
title: '模板名称',
dataIndex: 'name',
},
{
title: '类型',
dataIndex: 'type',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '发送人名称',
dataIndex: 'nickname',
hideInSearch: true,
},
{
title: '模板内容',
dataIndex: 'content',
hideInSearch: true,
},
{
title: '开启状态',
dataIndex: 'status',
},
{
title: '备注',
dataIndex: 'remark',
hideInSearch: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
hideInSearch: true,
render: (_, record: NotifyTemplateVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (type: string): ProFormColumnsType[] => [
{
title: '模版编码',
dataIndex: 'code',
tip: '模版编码', // 提示信息
formItemProps: {
rules: [
{
required: true,
message: '请输入模版编码',
},
],
},
},
{
title: '模板名称',
dataIndex: 'name',
formItemProps: {
rules: [
{
required: true,
message: '请输入模版名称',
},
],
},
},
{
title: '发件人名称',
dataIndex: 'nickname',
formItemProps: {
rules: [
{
required: true,
message: '请输入发件人名称',
},
],
},
},
{
title: '模板内容',
dataIndex: 'content',
formItemProps: {
rules: [
{
required: true,
message: '请输入模板内容',
},
],
},
},
{
title: '类型',
dataIndex: 'type',
formItemProps: {
rules: [
{
required: true,
message: '请选择类型',
},
],
},
},
{
title: '开启状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
placeholder: '请选择开启状态',
options: [
{
label: '正常',
value: 1,
},
{
label: '禁用',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请选择状态',
},
],
},
},
{
title: '备注',
dataIndex: 'remark',
fieldProps: {
placeholder: '请输入备注',
},
},
];
export const formTestColumns = (type: string): ProFormColumnsType[] => [
{
title: '模板内容',
dataIndex: 'content',
},
{
title: '用户类型',
dataIndex: 'userType',
valueType: 'radio',
fieldProps: {
options: [
{
label: '用户',
value: 1,
},
{
label: '管理员',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请输入模版名称',
},
],
},
},
{
title: '接收人ID',
dataIndex: 'userId',
formItemProps: {
rules: [
{
required: true,
message: '请输入接收人ID',
},
],
},
},
];

View File

@@ -0,0 +1,174 @@
import { PlusOutlined } from '@ant-design/icons';
import type {
ActionType,
ProColumns,
ProCoreActionType,
} from '@ant-design/pro-components';
import { message, Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createNotifyTemplate,
deleteNotifyTemplate,
getNotifyTemplatePage,
type NotifyTemplateVO,
sendNotify,
updateNotifyTemplate,
} from '@/services/system/message/notify/template';
import { baseTenantColumns, formColumns, formTestColumns } from './config';
const SyStemMessageNotifyTemplate = () => {
const tableRef = useRef<ActionType>(null);
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const [type, setType] = useState<'create' | 'update' | 'test'>('create');
const testRef = useRef<ConfigurableDrawerFormRef>(null);
const [currentItem, setCurrentItem] = useState<NotifyTemplateVO>();
const onFetch = async (
params: NotifyTemplateVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getNotifyTemplatePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleSend = async (record: NotifyTemplateVO) => {
setType('test');
setCurrentItem(record);
testRef.current?.open(record);
};
const handleEdit = (record: NotifyTemplateVO) => {
setType('update');
setCurrentItem(record);
configurableDrawerRef.current?.open(record);
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open();
};
const handleSubmit = useCallback(
async (values: NotifyTemplateVO) => {
if (type === 'create') {
await createNotifyTemplate(values);
message.success('创建成功');
} else {
await updateNotifyTemplate({
...values,
id: currentItem!.id,
});
message.success('编辑成功');
}
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const handleTestSubmit = useCallback(
async (values: NotifyTemplateVO) => {
if (currentItem?.status === 1) {
return message.error('请先开启状态');
}
const res = await sendNotify({
...currentItem,
...values,
mobile: '',
templateParams: new Map(),
templateCode: currentItem!.code,
});
message.success('提交发送成功!发送结果,见发送日志编号:' + res);
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<NotifyTemplateVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (
text: React.ReactNode,
record: NotifyTemplateVO,
_: number,
action: ProCoreActionType | undefined,
) => [
<a key="edit" onClick={() => handleEdit(record)}>
</a>,
<a key="detail" onClick={() => handleSend(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteNotifyTemplate(record.id);
message.success('删除成功');
action?.reload?.();
}}
okText="是"
cancelText="否"
>
<a style={{ color: 'var(--ant-red)' }} key="delete">
</a>
</Popconfirm>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<NotifyTemplateVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
toolbarActions={toolbarActions}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
<ConfigurableDrawerForm
ref={testRef}
title={formStatusType[type]}
columns={formTestColumns(type)}
onSubmit={handleTestSubmit}
/>
</>
);
};
export default SyStemMessageNotifyTemplate;

View File

@@ -0,0 +1,127 @@
import type {
ProColumns,
ProDescriptionsItemProps,
ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { SmsChannelVO } from '@/services/system/message/sms/channel';
export const baseTenantColumns: ProColumns<SmsChannelVO>[] = [
{
title: '编号',
dataIndex: 'id',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '短信签名',
dataIndex: 'signature',
},
{
title: '渠道编码',
dataIndex: 'code',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '启用状态',
dataIndex: 'status',
valueType: 'select',
},
{
title: '备注',
dataIndex: 'remark',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '短信 API 的账号',
dataIndex: 'apiKey',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '短信 API 的密钥',
dataIndex: 'apiSecret',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '短信发送回调 URL',
dataIndex: 'callbackUrl',
hideInSearch: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: SmsChannelVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (type: string): ProFormColumnsType[] => [
{
title: '短信签名',
dataIndex: 'signature',
formItemProps: {
rules: [
{
required: true,
message: '请输入用户名',
},
],
},
},
{
title: '渠道编码',
dataIndex: 'code',
valueType: 'select',
formItemProps: {
rules: [
{
required: true,
message: '请输入用户名',
},
],
},
},
{
title: '启用状态',
dataIndex: 'status',
valueType: 'radio',
},
{
title: '备注',
dataIndex: 'remark',
},
{
title: '短信 API 的账号',
dataIndex: 'apiKey',
formItemProps: {
rules: [
{
required: true,
message: '请输入用户名',
},
],
},
},
{
title: '短信 API 的密钥',
dataIndex: 'apiSecret',
},
{
title: '短信发送回调 URL',
dataIndex: 'callbackUrl',
},
];

View File

@@ -1,7 +1,10 @@
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components'; import type {
import { useParams } from '@umijs/max'; ActionType,
import { Popconfirm } from 'antd'; ProColumns,
ProCoreActionType,
} from '@ant-design/pro-components';
import { message, Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react'; import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, { import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef, type ConfigurableDrawerFormRef,
@@ -10,36 +13,27 @@ import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types'; import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants'; import { formStatusType } from '@/constants';
import { import {
createDictData, createSmsChannel,
type DictDataVO, deleteSmsChannel,
deleteDictData, getSmsChannelPage,
getDictDataPage, type SmsChannelVO,
updateDictData, updateSmsChannel,
} from '@/services/system/dict/dict.data'; } from '@/services/system/message/sms/channel';
import { baseDictDataColumns, formColumns } from './config'; import { baseTenantColumns, formColumns } from './config';
const SyStemDictData = () => { const SyStemLogLogin = () => {
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const tableRef = useRef<ActionType>(null); const tableRef = useRef<ActionType>(null);
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const [type, setType] = useState<'create' | 'update'>('create'); const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0); const [currentItem, setCurrentItem] = useState<SmsChannelVO>();
const onFetch = async (
const routerParams = useParams(); params: SmsChannelVO & {
pageSize?: number;
console.log(routerParams); current?: number;
},
const handleEdit = (record: DictDataVO) => { ) => {
setType('update'); const data = await getSmsChannelPage({
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const onFetch = async (params: { pageSize?: number; current?: number }) => {
const data = await getDictDataPage({
...params, ...params,
dictType: routerParams.type,
pageNo: params.current, pageNo: params.current,
pageSize: params.pageSize, pageSize: params.pageSize,
}); });
@@ -50,29 +44,15 @@ const SyStemDictData = () => {
}; };
}; };
const handleEdit = (record: SmsChannelVO) => {
setType('update');
setCurrentItem(record);
configurableDrawerRef.current?.open(record);
};
const handleAdd = () => { const handleAdd = () => {
setType('create'); setType('create');
configurableDrawerRef.current?.open({ configurableDrawerRef.current?.open({});
dictType: routerParams.type,
});
}; };
const handleSubmit = useCallback(
async (values: DictDataVO) => {
if (type === 'create') {
await createDictData(values);
} else {
await updateDictData({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const toolbarActions: ToolbarAction[] = [ const toolbarActions: ToolbarAction[] = [
{ {
key: 'add', key: 'add',
@@ -82,18 +62,17 @@ const SyStemDictData = () => {
onClick: handleAdd, onClick: handleAdd,
}, },
]; ];
const actionColumns: ProColumns<SmsChannelVO> = {
const actionColumns: ProColumns<DictDataVO> = {
title: '操作', title: '操作',
dataIndex: 'option', dataIndex: 'option',
valueType: 'option', valueType: 'option',
fixed: 'right', fixed: 'right',
width: 120, width: 80,
render: ( render: (
_text: React.ReactNode, text: React.ReactNode,
record: DictDataVO, record: SmsChannelVO,
_: any, _: number,
action: any, action: ProCoreActionType | undefined,
) => [ ) => [
<a key="editable" onClick={() => handleEdit(record)}> <a key="editable" onClick={() => handleEdit(record)}>
@@ -102,30 +81,46 @@ const SyStemDictData = () => {
title="是否删除?" title="是否删除?"
key="delete" key="delete"
onConfirm={async () => { onConfirm={async () => {
await deleteDictData(record.id); await deleteSmsChannel(record.id);
action?.reload(); message.success('删除成功');
action?.reload?.();
}} }}
okText="是" okText="是"
cancelText="否" cancelText="否"
> >
<a></a> <a style={{ color: 'var(--ant-red)' }} key="delete">
</a>
</Popconfirm>, </Popconfirm>,
], ],
}; };
const handleSubmit = useCallback(
const columns = [...baseDictDataColumns, actionColumns]; async (values: SmsChannelVO) => {
if (type === 'create') {
await createSmsChannel(values);
} else {
await updateSmsChannel({
...values,
id: currentItem!.id,
});
}
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const columns = [...baseTenantColumns, actionColumns];
return ( return (
<> <>
<EnhancedProTable<DictDataVO> <EnhancedProTable<SmsChannelVO>
ref={tableRef} ref={tableRef}
columns={columns} columns={columns}
request={onFetch} request={onFetch}
toolbarActions={toolbarActions} toolbarActions={toolbarActions}
headerTitle="租户列表" headerTitle="短信渠道"
showIndex={false} showIndex={false}
showSelection={false} showSelection={false}
/> />
<ConfigurableDrawerForm <ConfigurableDrawerForm
ref={configurableDrawerRef} ref={configurableDrawerRef}
title={formStatusType[type]} title={formStatusType[type]}
@@ -136,4 +131,4 @@ const SyStemDictData = () => {
); );
}; };
export default SyStemDictData; export default SyStemLogLogin;

View File

@@ -0,0 +1,197 @@
import type {
ProColumns,
ProDescriptionsItemProps,
} from '@ant-design/pro-components';
import { Space, Tag } from 'antd';
import dayjs from 'dayjs';
import type { SmsLogVO } from '@/services/system/message/sms/log';
export const baseTenantColumns: ProColumns<SmsLogVO>[] = [
{
title: '编号',
dataIndex: 'id',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
hideInSearch: true,
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: SmsLogVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
{
title: '手机号',
dataIndex: 'mobile',
},
{
title: '短信内容',
dataIndex: 'templateContent',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '发送状态',
dataIndex: 'sendStatus',
},
{
title: '接收状态',
dataIndex: 'receiveStatus',
},
{
title: '短信渠道',
dataIndex: 'channelId',
},
{
title: '模板编号',
dataIndex: 'templateId',
},
{
title: '短信类型',
dataIndex: 'templateType',
hideInSearch: true,
},
{
title: '发送时间',
dataIndex: 'sendTime',
valueType: 'dateRange',
hideInTable: true,
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: SmsLogVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
{
title: '接收时间',
dataIndex: 'receiveTime',
valueType: 'dateRange',
hideInTable: true,
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: SmsLogVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const descriptionsColumns = (): ProDescriptionsItemProps<
Record<string, any>,
'text'
>[] => [
{
title: '日志主键',
key: 'id',
dataIndex: 'id',
},
{
title: '短信渠道',
key: 'channelId',
dataIndex: 'channelId',
},
{
title: '短信模板',
key: 'templateCode',
dataIndex: 'templateCode',
},
{
title: 'API 的模板编号',
key: 'apiTemplateId',
dataIndex: 'apiTemplateId',
},
{
title: '用户信息',
key: 'mobile',
dataIndex: 'mobile',
render(dom, record) {
return (
<>
<Space>
<Tag>{record.mobile}</Tag>
{record.userId && <Tag>{record.userId}</Tag>}
</Space>
</>
);
},
},
{
title: '短信内容',
key: 'templateContent',
dataIndex: 'templateContent',
},
{
title: '短信参数',
key: 'templateParams',
dataIndex: 'templateParams',
},
{
title: '创建时间',
key: 'createTime',
dataIndex: 'createTime',
},
{
title: '发送状态',
key: 'sendStatus',
dataIndex: 'sendStatus',
},
{
title: '发送时间',
key: 'sendTime',
dataIndex: 'sendTime',
},
{
title: 'API 发送结果',
key: 'apiSendMsg',
dataIndex: 'apiSendMsg',
},
{
title: 'API 短信编号',
key: 'apiSerialNo',
dataIndex: 'apiSerialNo',
},
{
title: 'API 请求编号',
key: 'apiRequestId',
dataIndex: 'apiRequestId',
},
{
title: 'API 接收状态',
key: 'receiveStatus',
dataIndex: 'receiveStatus',
},
{
title: 'API 接收结果',
key: 'apiReceiveMsg',
dataIndex: 'apiReceiveMsg',
},
];

View File

@@ -0,0 +1,70 @@
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import React, { useRef } from 'react';
import EnhancedProTable from '@/components/EnhancedProTable';
import ModalDescriptions, {
type DescriptionsFormRef,
} from '@/components/ModalDescriptions';
import {
getSmsLogPage,
type SmsLogVO,
} from '@/services/system/message/sms/log';
import { baseTenantColumns, descriptionsColumns } from './config';
const SyStemMessageNotifyMessage = () => {
const tableRef = useRef<ActionType>(null);
const descriptionsRef = useRef<DescriptionsFormRef>(null);
const onFetch = async (
params: SmsLogVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getSmsLogPage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleDetail = (record: SmsLogVO) => {
descriptionsRef.current?.open(record);
};
const actionColumns: ProColumns<SmsLogVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 80,
render: (text: React.ReactNode, record: SmsLogVO) => [
<a key="editable" onClick={() => handleDetail(record)}>
</a>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<SmsLogVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
showSelection={false}
/>
<ModalDescriptions
ref={descriptionsRef}
title="登录日志详情"
columns={descriptionsColumns()}
/>
</>
);
};
export default SyStemMessageNotifyMessage;

View File

@@ -0,0 +1,171 @@
import type {
ProColumns,
ProDescriptionsItemProps,
ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { SmsTemplateVO } from '@/services/system/message/sms/template';
export const baseTenantColumns: ProColumns<SmsTemplateVO>[] = [
{
title: '模板编码',
dataIndex: 'code',
width: 100,
},
{
title: '模板名称',
dataIndex: 'name',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '模板内容',
dataIndex: 'content',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '短信类型',
dataIndex: 'type',
},
{
title: '状态',
dataIndex: 'status',
},
{
title: '备注',
dataIndex: 'remark',
hideInSearch: true,
},
{
title: '短信 API 的模板编号',
dataIndex: 'apiTemplateId',
},
{
title: '短信渠道',
dataIndex: 'channelCode',
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
render: (_, record: SmsTemplateVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (type: string): ProFormColumnsType[] => [
{
title: '短信渠道编号',
dataIndex: 'channelId',
valueType: 'select',
formItemProps: {
rules: [
{
required: true,
message: '请选择短信渠道编号',
},
],
},
},
{
title: '短信类型',
dataIndex: 'type',
valueType: 'select',
formItemProps: {
rules: [
{
required: true,
message: '请选择短信类型',
},
],
},
},
{
title: '模板编号',
dataIndex: 'code',
formItemProps: {
rules: [
{
required: true,
message: '请输入模板编号',
},
],
},
},
{
title: '模板名称',
dataIndex: 'name',
formItemProps: {
rules: [
{
required: true,
message: '请输入模板名称',
},
],
},
},
{
title: '模板内容',
dataIndex: 'type',
formItemProps: {
rules: [
{
required: true,
message: '请输入模板内容',
},
],
},
},
{
title: '开启状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
placeholder: '请选择开启状态',
options: [
{
label: '正常',
value: 1,
},
{
label: '禁用',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请选择状态',
},
],
},
},
{
title: '短信 API 模板编号',
dataIndex: 'apiTemplateId',
fieldProps: {
placeholder: '请输入短信 API 的模板编号',
},
},
{
title: '备注',
dataIndex: 'remark',
fieldProps: {
placeholder: '请输入备注',
},
},
];
export const formTestColumns = (type: string): ProFormColumnsType[] => [
{
title: '模板内容',
dataIndex: 'content',
valueType: 'textarea',
},
{
title: '手机号',
dataIndex: 'mobile',
},
];

View File

@@ -0,0 +1,174 @@
import { PlusOutlined } from '@ant-design/icons';
import type {
ActionType,
ProColumns,
ProCoreActionType,
} from '@ant-design/pro-components';
import { message, Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createSmsTemplate,
deleteSmsTemplate,
getSmsTemplatePage,
type SmsTemplateVO,
sendSms,
updateSmsTemplate,
} from '@/services/system/message/sms/template';
import { baseTenantColumns, formColumns, formTestColumns } from './config';
const SyStemMessageSmsTemplate = () => {
const tableRef = useRef<ActionType>(null);
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const [type, setType] = useState<'create' | 'update' | 'test'>('create');
const testRef = useRef<ConfigurableDrawerFormRef>(null);
const [currentItem, setCurrentItem] = useState<SmsTemplateVO>();
const onFetch = async (
params: SmsTemplateVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getSmsTemplatePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleSend = async (record: SmsTemplateVO) => {
setType('test');
setCurrentItem(record);
testRef.current?.open(record);
};
const handleEdit = (record: SmsTemplateVO) => {
setType('update');
setCurrentItem(record);
configurableDrawerRef.current?.open(record);
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open();
};
const handleSubmit = useCallback(
async (values: SmsTemplateVO) => {
if (type === 'create') {
await createSmsTemplate(values);
message.success('创建成功');
} else {
await updateSmsTemplate({
...values,
id: currentItem!.id,
});
message.success('编辑成功');
}
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const handleTestSubmit = useCallback(
async (values: SmsTemplateVO) => {
if (currentItem?.status === 1) {
return message.error('请先开启状态');
}
const res = await sendSms({
...currentItem,
...values,
mobile: '',
templateParams: new Map(),
templateCode: currentItem!.code,
});
message.success('提交发送成功!发送结果,见发送日志编号:' + res);
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<SmsTemplateVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (
text: React.ReactNode,
record: SmsTemplateVO,
_: number,
action: ProCoreActionType | undefined,
) => [
<a key="edit" onClick={() => handleEdit(record)}>
</a>,
<a key="detail" onClick={() => handleSend(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteSmsTemplate(record.id);
message.success('删除成功');
action?.reload?.();
}}
okText="是"
cancelText="否"
>
<a style={{ color: 'var(--ant-red)' }} key="delete">
</a>
</Popconfirm>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<SmsTemplateVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
toolbarActions={toolbarActions}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
<ConfigurableDrawerForm
ref={testRef}
title={formStatusType[type]}
columns={formTestColumns(type)}
onSubmit={handleTestSubmit}
/>
</>
);
};
export default SyStemMessageSmsTemplate;

View File

@@ -1,121 +0,0 @@
import type {
ProColumns,
ProFormColumnsType,
} from '@ant-design/pro-components';
import { Tag } from 'antd';
import dayjs from 'dayjs';
import { tenantStatus } from '@/constants';
import type { PostVO } from '@/services/system/post';
import { getStatusLabel } from '@/utils/constant';
export const basePostColumns: ProColumns<PostVO>[] = [
{
title: '岗位编号',
dataIndex: 'id',
width: 80,
},
{
title: '岗位名称',
dataIndex: 'name',
width: 120,
},
{
title: '岗位编码',
dataIndex: 'code',
width: 120,
},
{
title: '岗位顺序',
dataIndex: 'sort',
width: 80,
},
{
title: '岗位备注',
dataIndex: 'remark',
width: 120,
},
{
title: '状态',
dataIndex: 'status',
width: 100,
render: (_, record: PostVO) => [
<Tag
key={record.status}
color={record.status === 1 ? 'default' : 'processing'}
>
{getStatusLabel(tenantStatus, record.status)}
</Tag>,
],
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
'createTime[0]': dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
'createTime[1]': dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: PostVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (_type: string): ProFormColumnsType[] => [
{
title: '岗位名称',
dataIndex: 'name',
formItemProps: {
rules: [
{
required: true,
message: '请输入岗位名称',
},
],
},
},
{
title: '岗位编码',
dataIndex: 'code',
formItemProps: {
rules: [
{
required: true,
message: '请输入岗位编码',
},
],
},
},
{
title: '岗位顺序',
dataIndex: 'sort',
valueType: 'digit',
fieldProps: {
placeholder: '请输入排序值',
},
},
{
title: '状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
placeholder: '请选择状态',
options: tenantStatus,
},
},
{
title: '备注',
dataIndex: 'remark',
valueType: 'textarea',
fieldProps: {
placeholder: '请输入备注',
},
},
];

View File

@@ -1,132 +1,5 @@
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createPost,
deletePost,
getPostPage,
type PostReqVO,
type PostVO,
updatePost,
} from '@/services/system/post';
import { basePostColumns, formColumns } from './config';
const SyStemPost = () => { const SyStemPost = () => {
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null); return <>SyStemPost</>;
const tableRef = useRef<ActionType>(null);
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
const handleEdit = (record: PostVO) => {
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const onFetch = async (
params: PostReqVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getPostPage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open({});
};
const handleSubmit = useCallback(
async (values: PostVO) => {
if (type === 'create') {
await createPost(values);
} else {
await updatePost({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<PostVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (_text: React.ReactNode, record: PostVO, _: any, action: any) => [
<a key="editable" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deletePost(record.id);
action?.reload();
}}
okText="是"
cancelText="否"
>
<a></a>
</Popconfirm>,
],
};
const columns = [...basePostColumns, actionColumns];
return (
<>
<EnhancedProTable<PostVO>
ref={tableRef}
columns={columns}
request={onFetch}
toolbarActions={toolbarActions}
headerTitle="租户列表"
showIndex={false}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
</>
);
}; };
export default SyStemPost; export default SyStemPost;

View File

@@ -1,143 +0,0 @@
import type {
ProColumns,
ProFormColumnsType,
} from '@ant-design/pro-components';
import { Tag } from 'antd';
import dayjs from 'dayjs';
import { tenantStatus } from '@/constants';
import type { RoleVO } from '@/services/system/role';
import { getStatusLabel } from '@/utils/constant';
export const baseTenantColumns: ProColumns<RoleVO>[] = [
{
title: '角色编号',
dataIndex: 'id',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '角色名称',
dataIndex: 'name',
width: 100,
},
{
title: '角色类型',
dataIndex: 'type',
width: 100,
render: (_, record: RoleVO) => [
<Tag key={record.type} color={record.type === 1 ? 'error' : 'processing'}>
{record.type === 1 ? '内置' : '自定义'}
</Tag>,
],
hideInSearch: true,
},
{
title: '角色标识',
dataIndex: 'code',
width: 150,
render: (_, record: RoleVO) => [
<Tag key={record.code} color={record.type === 1 ? 'error' : 'processing'}>
{record.code}
</Tag>,
],
hideInSearch: true,
},
{
title: '显示顺序',
dataIndex: 'sort',
width: 100,
hideInSearch: true,
},
{
title: '备注',
dataIndex: 'remark',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '租户状态',
dataIndex: 'status',
width: 100,
render: (_, record: RoleVO) => [
<Tag
key={record.status}
color={record.status === 1 ? 'default' : 'processing'}
>
{getStatusLabel(tenantStatus, record.status)}
</Tag>,
],
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
'createTime[0]': dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
'createTime[1]': dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: RoleVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (_type: string): ProFormColumnsType[] => [
{
title: '角色名称',
dataIndex: 'name',
formItemProps: {
rules: [
{
required: true,
message: '请输入角色名称',
},
],
},
},
{
title: '角色标识',
dataIndex: 'code',
formItemProps: {
rules: [
{
required: true,
message: '请输入角色名称',
},
],
},
},
{
title: '显示顺序',
dataIndex: 'sort',
valueType: 'digit',
fieldProps: {
placeholder: '请输入显示顺序',
},
},
{
title: '租户状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
multiple: true,
placeholder: '请选择租户状态',
options: tenantStatus,
},
},
{
title: '备注',
dataIndex: 'remark',
valueType: 'textarea',
fieldProps: {
placeholder: '请输入备注',
min: 5,
max: 20,
},
},
];

View File

@@ -1,132 +1,5 @@
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createRole,
deleteRole,
getRolePage,
type RolePageReqVO,
type RoleVO,
updateRole,
} from '@/services/system/role';
import { baseTenantColumns, formColumns } from './config';
const SyStemRole = () => { const SyStemRole = () => {
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null); return <>SyStemRole</>;
const tableRef = useRef<ActionType>(null);
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
const handleEdit = (record: RoleVO) => {
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const onFetch = async (
params: RolePageReqVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getRolePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open({});
};
const handleSubmit = useCallback(
async (values: RoleVO) => {
if (type === 'create') {
await createRole(values);
} else {
await updateRole({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<RoleVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (_text: React.ReactNode, record: RoleVO, _: any, action: any) => [
<a key="editable" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteRole(record.id);
action?.reload();
}}
okText="是"
cancelText="否"
>
<a></a>
</Popconfirm>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<RoleVO>
ref={tableRef}
columns={columns}
request={onFetch}
toolbarActions={toolbarActions}
headerTitle="租户列表"
showIndex={false}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
</>
);
}; };
export default SyStemRole; export default SyStemRole;

View File

@@ -2,8 +2,11 @@ import type {
ProColumns, ProColumns,
ProFormColumnsType, ProFormColumnsType,
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import { DatePicker, Modal, Popconfirm } from 'antd';
import { FormInstance } from 'antd/lib';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import type { TenantVO } from '@/services/system/tenant/list'; import { deleteTenant, type TenantVO } from '@/services/system/tenant/list';
import { getTenantPackageList } from '@/services/system/tenant/package';
export const baseTenantColumns: ProColumns<TenantVO>[] = [ export const baseTenantColumns: ProColumns<TenantVO>[] = [
{ {
@@ -22,13 +25,13 @@ export const baseTenantColumns: ProColumns<TenantVO>[] = [
title: '租户套餐', title: '租户套餐',
dataIndex: 'packageId', dataIndex: 'packageId',
valueType: 'select', valueType: 'select',
hideInSearch: true, // 在搜索表单中隐藏
request: async () => { request: async () => {
return [ const packageList: { id: number; name: string }[] =
{ await getTenantPackageList();
label: '默认套餐', console.log(packageList);
value: 1, packageList.map((item) => ({ label: item.name, value: item.id }));
}, return packageList.map((item) => ({ label: item.name, value: item.id }));
];
}, },
// valueEnum: { // valueEnum: {
// all: { text: "全部", status: "Default" }, // all: { text: "全部", status: "Default" },
@@ -56,15 +59,22 @@ export const baseTenantColumns: ProColumns<TenantVO>[] = [
hideInSearch: true, // 在搜索表单中隐藏 hideInSearch: true, // 在搜索表单中隐藏
}, },
{ title: '绑定域名', dataIndex: 'website', width: 100 }, { title: '绑定域名', dataIndex: 'website', width: 100, hideInSearch: true },
{ {
title: '租户状态', title: '租户状态',
dataIndex: 'status', dataIndex: 'status',
valueType: 'select', valueType: 'select',
valueEnum: { fieldProps: {
all: { text: '全部', status: 'Default' }, options: [
open: { text: '未解决', status: 'Error' }, {
closed: { text: '已解决', status: 'Success' }, label: '开启',
value: 0,
},
{
label: '关闭',
value: 1,
},
],
}, },
}, },
{ {
@@ -73,14 +83,7 @@ export const baseTenantColumns: ProColumns<TenantVO>[] = [
valueType: 'dateRange', valueType: 'dateRange',
search: { search: {
transform: (value) => { transform: (value) => {
return { return [`${value[0]} 00:00:00`, `${value[1]} 00:00:00`];
'createTime[0]': dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
'createTime[1]': dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
}, },
}, },
render: (_, record: TenantVO) => render: (_, record: TenantVO) =>

View File

@@ -1,8 +1,9 @@
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components'; import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { Popconfirm } from 'antd'; import { Modal, Popconfirm } from 'antd';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import React, { useCallback, useRef, useState } from 'react'; import { ref } from 'process';
import React, { createContext, useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, { import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef, type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm'; } from '@/components/DrawerForm';
@@ -63,7 +64,7 @@ const TenantList = () => {
tableRef.current?.reload(); tableRef.current?.reload();
return true; return true;
}, },
[type], [type, id],
); );
const handleAdd = () => { const handleAdd = () => {
@@ -92,7 +93,7 @@ const TenantList = () => {
valueType: 'option', valueType: 'option',
fixed: 'right', fixed: 'right',
width: 120, width: 120,
render: (_text: React.ReactNode, record: TenantVO, _: any, action: any) => [ render: (text: React.ReactNode, record: TenantVO, _: any, action: any) => [
<a key="editable" onClick={() => handleEdit(record)}> <a key="editable" onClick={() => handleEdit(record)}>
</a>, </a>,
@@ -121,6 +122,8 @@ const TenantList = () => {
headerTitle="租户列表" headerTitle="租户列表"
showIndex={false} showIndex={false}
showSelection={false} showSelection={false}
showActions
maxActionCount={3}
/> />
<ConfigurableDrawerForm <ConfigurableDrawerForm

View File

@@ -1,109 +0,0 @@
import type {
ProColumns,
ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { TenantPackageVO } from '@/services/system/tenant/package';
export const baseTenantColumns: ProColumns<TenantPackageVO>[] = [
{
title: '套餐编号',
dataIndex: 'id',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '套餐名',
dataIndex: 'name',
},
{
title: '状态',
dataIndex: 'status',
valueType: 'select',
valueEnum: {
all: { text: '全部', status: 'Default' },
open: { text: '未解决', status: 'Error' },
closed: { text: '已解决', status: 'Success' },
},
},
{
title: '备注',
dataIndex: 'remark',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
'createTime[0]': dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
'createTime[1]': dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: TenantPackageVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (_type: string): ProFormColumnsType[] => [
{
title: '套餐名',
dataIndex: 'name',
formItemProps: {
rules: [
{
required: true,
message: '请输入用户名',
},
],
},
},
{
title: '套餐权限',
dataIndex: 'menuIds',
valueType: 'treeSelect',
fieldProps: {
multiple: true,
placeholder: '请选择租户权限',
options: [{ lable: '11', value: 5016 }],
},
},
{
title: '租户状态',
dataIndex: 'status',
valueType: 'radio',
formItemProps: {
rules: [
{
required: true,
message: '请选择租户状态',
},
],
},
fieldProps: {
placeholder: '请选择套餐类型',
options: [
{
label: '开启',
value: 1,
},
{
label: '关闭',
value: 0,
},
],
},
},
{
title: '备注',
dataIndex: 'remark',
valueType: 'textarea',
},
];

View File

@@ -1,137 +1,5 @@
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createTenantPackage,
deleteTenantPackage,
getTenantPackagePage,
type TenantPackagePageReqVO,
type TenantPackageVO,
updateTenantPackage,
} from '@/services/system/tenant/package';
import { baseTenantColumns, formColumns } from './config';
const TenantPackage = () => { const TenantPackage = () => {
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null); return <div>TenantPackage</div>;
const tableRef = useRef<ActionType>(null);
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
const handleEdit = (record: TenantPackageVO) => {
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const onFetch = async (
params: TenantPackagePageReqVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getTenantPackagePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open({});
};
const handleSubmit = useCallback(
async (values: TenantPackageVO) => {
if (type === 'create') {
await createTenantPackage(values);
} else {
await updateTenantPackage({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<TenantPackageVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (
_text: React.ReactNode,
record: TenantPackageVO,
_: any,
action: any,
) => [
<a key="editable" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteTenantPackage(record.id);
action?.reload();
}}
okText="是"
cancelText="否"
>
<a></a>
</Popconfirm>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<TenantPackageVO>
ref={tableRef}
columns={columns}
request={onFetch}
toolbarActions={toolbarActions}
headerTitle="租户列表"
showIndex={false}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
</>
);
}; };
export default TenantPackage; export default TenantPackage;

View File

@@ -1,220 +0,0 @@
import type {
ProColumns,
ProCoreActionType,
ProFormColumnsType,
} from '@ant-design/pro-components';
import { Modal, message, Switch } from 'antd';
import dayjs from 'dayjs';
import { updateUserStatus } from '@/services/system/user';
import type { UserVO } from '@/services/system/user/index';
export const baseTenantColumns: ProColumns<UserVO>[] = [
{
title: '用户编号',
dataIndex: 'id',
width: 80,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '用户名称',
dataIndex: 'username',
width: 100,
},
{
title: '用户昵称',
dataIndex: 'nickname',
width: 100,
hideInSearch: true,
},
{
title: '部门',
dataIndex: 'deptName',
width: 100,
},
{
title: '手机号码',
dataIndex: 'mobile',
width: 100,
},
{
title: '状态',
dataIndex: 'status',
valueType: 'select',
valueEnum: {
all: { text: '全部', status: 'Default' },
open: { text: '未解决', status: 'Error' },
closed: { text: '已解决', status: 'Success' },
},
render: (
_dom: React.ReactNode,
record: UserVO,
_index: number,
action: ProCoreActionType | undefined,
) => [
<Switch
key={record.id}
checked={record.status === 0}
onChange={async (_checked) => {
const text = record.status ? '启用' : '停用';
Modal.confirm({
title: '确认操作',
content: `确认要"${text}""${record.username}"用户吗?`,
onOk: async () => {
const status = record.status === 0 ? 1 : 0;
await updateUserStatus(record.id, status);
message.success('修改成功');
action?.reload();
// 执行状态变更逻辑
},
});
// await message.confirm("修改成功");
}}
></Switch>,
],
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
'createTime[0]': dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
'createTime[1]': dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: UserVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
{
title: '备注',
dataIndex: 'remark',
hideInSearch: true, // 在搜索表单中隐藏
},
];
export const formColumns = (type: string): ProFormColumnsType[] => [
{
title: '用户昵称',
dataIndex: 'nickname',
formItemProps: {
rules: [
{
required: true,
message: '请输入用户名',
},
],
},
},
{
title: '归属部门',
dataIndex: 'deptId',
valueType: 'treeSelect',
fieldProps: {
multiple: true,
placeholder: '请选择归属部门',
options: [{ lable: '11', value: 5016 }],
},
},
{
title: '手机号码',
dataIndex: 'mobile',
formItemProps: {
rules: [
{
required: true,
message: '请输入联系手机',
},
],
},
},
// { prop: "email", label: "邮箱", type: "input", inputType: "email" },
{
title: '邮箱',
dataIndex: 'email',
valueType: 'text',
fieldProps: {
type: 'email',
placeholder: '请输入邮箱',
},
formItemProps: {
rules: [
{
required: true,
message: '请输入邮箱',
},
],
},
},
{
title: '用户名称',
dataIndex: 'username',
hideInForm: type === 'update',
},
{
title: '用户密码',
dataIndex: 'password',
valueType: 'password',
hideInForm: type === 'update',
fieldProps: {
placeholder: '请输入用户密码',
autoComplete: 'new-password',
},
formItemProps: {
rules: [
{
required: true,
message: '请输入用户密码',
},
],
},
},
{
title: '用户性别',
dataIndex: 'sex',
valueType: 'select',
fieldProps: {
placeholder: '请选择性别',
options: [
{
label: '男',
value: 1,
},
{
label: '女',
value: 2,
},
],
},
},
{
title: '岗位',
dataIndex: 'postIds',
valueType: 'select',
fieldProps: {
mode: 'multiple',
placeholder: '请选择岗位',
options: [
{
label: '管理员',
value: 1,
},
{
label: '普通用户',
value: 2,
},
],
},
formItemProps: {},
},
{
title: '备注',
dataIndex: 'remark',
valueType: 'textarea',
},
];

View File

@@ -1,130 +1,5 @@
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createUser,
deleteUser,
getUserPage,
type UserReqVO,
type UserVO,
updateUser,
} from '@/services/system/user';
import { baseTenantColumns, formColumns } from './config';
const SyStemUser = () => { const SyStemUser = () => {
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null); return <>SyStemUser</>;
const tableRef = useRef<ActionType>(null);
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
const handleEdit = (record: UserVO) => {
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const onFetch = async (
params: UserReqVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getUserPage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open({});
};
const handleSubmit = useCallback(
async (values: UserVO) => {
if (type === 'create') {
await createUser(values);
} else {
await updateUser({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<UserVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (_text: React.ReactNode, record: UserVO, _: any, action: any) => [
<a key="editable" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteUser(record.id);
action?.reload();
}}
okText="是"
cancelText="否"
>
<a></a>
</Popconfirm>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<UserVO>
ref={tableRef}
columns={columns}
request={onFetch}
toolbarActions={toolbarActions}
headerTitle="租户列表"
showIndex={false}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
</>
);
}; };
export default SyStemUser; export default SyStemUser;

View File

@@ -1,14 +1,15 @@
import type { RequestOptions } from "@@/plugin-request/request"; import type { RequestOptions } from '@@/plugin-request/request';
import type { RequestConfig } from "@umijs/max"; import type { RequestConfig } from '@umijs/max';
import { message, notification } from "antd"; import { request } from '@umijs/max';
import { deleteUserCache } from "@/hooks/web/useCache"; import { message, notification } from 'antd';
import { deleteUserCache } from '@/hooks/web/useCache';
import { import {
getAccessToken, getAccessToken,
getRefreshToken, getRefreshToken,
getTenantId, getTenantId,
setToken, setToken,
} from "./utils/auth"; } from './utils/auth';
import { request } from "@umijs/max";
const tenantEnable = process.env.VITE_APP_TENANT_ENABLE; const tenantEnable = process.env.VITE_APP_TENANT_ENABLE;
// const { result_code, base_url, request_timeout } = config; // const { result_code, base_url, request_timeout } = config;
// 错误处理方案: 错误类型 // 错误处理方案: 错误类型
@@ -27,22 +28,25 @@ interface ResponseStructure {
msg?: string; msg?: string;
} }
const ignoreMsgs = [ const ignoreMsgs = [
"无效的刷新令牌", // 刷新令牌被删除时,不用提示 '无效的刷新令牌', // 刷新令牌被删除时,不用提示
"刷新令牌已过期", // 使用刷新令牌,刷新获取新的访问令牌时,结果因为过期失败,此时需要忽略。否则,会导致继续 401无法跳转到登出界面 '刷新令牌已过期', // 使用刷新令牌,刷新获取新的访问令牌时,结果因为过期失败,此时需要忽略。否则,会导致继续 401无法跳转到登出界面
]; ];
import { EventEmitter } from 'events';
export const requestEventBus = new EventEmitter();
const errorCode: { [key: string]: string } = { const errorCode: { [key: string]: string } = {
"400": "请求参数不正确", '400': '请求参数不正确',
"401": "账号未登录", '401': '账号未登录',
"403": "当前操作没有权限", '403': '当前操作没有权限',
"404": "访问资源不存在", '404': '访问资源不存在',
"405": "请求方法不正确", '405': '请求方法不正确',
"423": "请求失败,请稍后重试", '423': '请求失败,请稍后重试',
"429": "请求失败,请稍后重试", '429': '请求失败,请稍后重试',
"500": "系统异常", '500': '系统异常',
"501": "功能未实现/未开启", '501': '功能未实现/未开启',
"502": "错误的配置项", '502': '错误的配置项',
"900": "重复请求,请稍后重试", '900': '重复请求,请稍后重试',
default: "系统未知错误,请反馈给管理员", default: '系统未知错误,请反馈给管理员',
}; };
/** /**
@@ -52,8 +56,8 @@ const errorCode: { [key: string]: string } = {
*/ */
const refreshToken = async () => { const refreshToken = async () => {
return await request("/system/auth/refresh-token", { return await request('/system/auth/refresh-token', {
method: "POST", method: 'POST',
params: { refreshToken: getRefreshToken() }, params: { refreshToken: getRefreshToken() },
}); });
}; };
@@ -87,7 +91,7 @@ const handleAuthorized = () => {
// 是否正在刷新中 // 是否正在刷新中
let isRefreshToken = false; let isRefreshToken = false;
// 请求队列 // 请求队列
let requestList: any[] = []; const requestList: any[] = [];
export const errorConfig: RequestConfig = { export const errorConfig: RequestConfig = {
// 错误处理: umi@3 的错误处理方案。 // 错误处理: umi@3 的错误处理方案。
errorConfig: { errorConfig: {
@@ -96,7 +100,7 @@ export const errorConfig: RequestConfig = {
const { success, data, code, msg } = res as unknown as ResponseStructure; const { success, data, code, msg } = res as unknown as ResponseStructure;
if (!success) { if (!success) {
const error: any = new Error(msg); const error: any = new Error(msg);
error.name = "BizError"; error.name = 'BizError';
error.info = { code, msg, data }; error.info = { code, msg, data };
throw error; // 抛出自制的错误 throw error; // 抛出自制的错误
} }
@@ -105,9 +109,9 @@ export const errorConfig: RequestConfig = {
errorHandler: async (error: any, opts: any) => { errorHandler: async (error: any, opts: any) => {
if (opts?.skipErrorHandler) throw error; if (opts?.skipErrorHandler) throw error;
// 我们的 errorThrower 抛出的错误。 // 我们的 errorThrower 抛出的错误。
console.log("errorHandler", error); console.log('errorHandler', error);
const errorInfo: ResponseStructure | undefined = error.info; const errorInfo: ResponseStructure | undefined = error.info;
if (error.name === "BizError") { if (error.name === 'BizError') {
if (errorInfo) { if (errorInfo) {
const { msg, code } = errorInfo; const { msg, code } = errorInfo;
message.error(msg); message.error(msg);
@@ -117,9 +121,9 @@ export const errorConfig: RequestConfig = {
// 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围 // 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围
message.error(`Response status:${error.response.status}`); message.error(`Response status:${error.response.status}`);
} else if (error.request) { } else if (error.request) {
message.error("None response! Please retry."); message.error('None response! Please retry.');
} else { } else {
message.error("发送请求时出了点问题:" + error.msg); message.error('发送请求时出了点问题:' + error.msg);
} }
}, },
}, },
@@ -146,8 +150,8 @@ export const errorConfig: RequestConfig = {
// 未设置状态码则默认成功状态 // 未设置状态码则默认成功状态
// 二进制数据则直接返回,例如说 Excel 导出 // 二进制数据则直接返回,例如说 Excel 导出
if ( if (
response.request.responseType === "blob" || response.request.responseType === 'blob' ||
response.request.responseType === "arraybuffer" response.request.responseType === 'arraybuffer'
) { ) {
// 注意:如果导出的响应为 json说明可能失败了不直接返回进行下载 // 注意:如果导出的响应为 json说明可能失败了不直接返回进行下载
// if (response.data.type !== "application/json") { // if (response.data.type !== "application/json") {
@@ -155,14 +159,14 @@ export const errorConfig: RequestConfig = {
// } // }
data = await new Response(data).json(); data = await new Response(data).json();
} }
// 获取错误信息 // // 获取错误信息
const msg = data.msg || errorCode[code] || errorCode["default"]; // const msg = data.msg || errorCode[code] || errorCode["default"];
if (ignoreMsgs.indexOf(msg) !== -1) { // if (ignoreMsgs.indexOf(msg) !== -1) {
// 如果是忽略的错误码,直接返回 msg 异常 // // 如果是忽略的错误码,直接返回 msg 异常
return Promise.reject(msg); // return Promise.reject(msg);
} // }
// 发送请求时出了点问题 // 发送请求时出了点问题
else if (code === 401) { if (code === 401) {
if (!isRefreshToken) { if (!isRefreshToken) {
isRefreshToken = true; isRefreshToken = true;
// 1. 如果获取不到刷新令牌,则只能执行登出操作 // 1. 如果获取不到刷新令牌,则只能执行登出操作
@@ -172,34 +176,25 @@ export const errorConfig: RequestConfig = {
// 2. 进行刷新访问令牌 // 2. 进行刷新访问令牌
try { try {
const refreshTokenRes = await refreshToken(); const refreshTokenRes = await refreshToken();
console.log("刷新成功", refreshTokenRes); console.log('刷新成功', refreshTokenRes);
// 2.1 刷新成功,则回放队列的请求 + 当前请求 // 2.1 刷新成功,则回放队列的请求 + 当前请求
setToken(refreshTokenRes); setToken(refreshTokenRes);
console.log(getAccessToken()); // 发出 token 刷新事件
config.headers!.Authorization = "Bearer " + getAccessToken(); requestEventBus.emit('token-refreshed');
console.log(requestList);
requestList.forEach((cb: any) => {
cb();
});
} catch (e) { } catch (e) {
// 为什么需要 catch 异常呢?刷新失败时,请求因为 Promise.reject 触发异常。 // 为什么需要 catch 异常呢?刷新失败时,请求因为 Promise.reject 触发异常。
// 2.2 刷新失败,只回放队列的请求
requestList.forEach((cb: any) => {
cb();
});
// 提示是否要登出。即不回放当前请求!不然会形成递归 // 提示是否要登出。即不回放当前请求!不然会形成递归
return handleAuthorized(); return handleAuthorized();
} finally { } finally {
requestList = [];
isRefreshToken = false; isRefreshToken = false;
} }
return request(config.url!, config); return request(config.url!, config);
} else { } else {
console.log("刷新令牌失败"); console.log('刷新令牌失败');
//添加到队列,等待刷新获取到新的令牌 //添加到队列,等待刷新获取到新的令牌
return new Promise((resolve) => { return new Promise((resolve) => {
requestList.push(() => { requestList.push(() => {
config.headers!.Authorization = "Bearer " + getAccessToken(); // 让每个请求携带自定义token 请根据实际情况自行修改 config.headers!.Authorization = 'Bearer ' + getAccessToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
resolve(request(config.url!, config)); resolve(request(config.url!, config));
}); });
}); });
@@ -209,7 +204,7 @@ export const errorConfig: RequestConfig = {
return Promise.reject(data); return Promise.reject(data);
} }
if (data?.success === false) { if (data?.success === false) {
message.error("请求失败!"); message.error('请求失败!');
return Promise.reject(data); return Promise.reject(data);
} }

View File

@@ -1,89 +0,0 @@
import { request } from "@umijs/max";
export interface DeptVO {
id: number;
name: string;
parentId: number;
status: number;
sort: number;
leaderUserId: number;
phone: string;
email: string;
createTime: Date;
}
export interface DeptReqVO extends PageParam {
name?: string;
status?: number;
}
// 查询部门(精简)列表
// export const getSimpleDeptList = async (): Promise<Dept[]> => {
// return await request.get({ url: "/system/dept/simple-list" });
// };
export const getSimpleDeptList = async () => {
return request("/system/dept/simple-list", {
method: "GET",
});
};
// 查询部门列表
// export const getDeptPage = async (params: DeptReq): Promise<Dept[]> => {
// return await request.get({ url: "/system/dept/list", params });
// };
export const getDeptPage = (params: DeptReqVO) => {
return request("/system/dept/list", {
method: "GET",
params,
});
};
// 查询部门详情
// export const getDept = async (id: number) => {
// return await request.get({ url: "/system/dept/get?id=" + id });
// };
export const getDept = (id: number) => {
return request("/system/dept/get", {
method: "GET",
params: { id },
});
};
// 新增部门
// export const createDept = async (data: Dept) => {
// return await request.post({ url: "/system/dept/create", data: data });
// };
export const createDept = (data: DeptVO) => {
return request("/system/dept/create", {
method: "POST",
data,
});
};
// 修改部门
// export const updateDept = async (params: Dept) => {
// return await request.put({ url: "/system/dept/update", data: params });
// };
export const updateDept = (params: DeptVO) => {
return request("/system/dept/update", {
method: "PUT",
data: params,
});
};
// 删除部门
// export const deleteDept = async (id: number) => {
// return await request.delete({ url: "/system/dept/delete?id=" + id });
// };
export const deleteDept = (id: number) => {
return request("/system/dept/delete", {
method: "DELETE",
params: { id },
});
};

View File

@@ -1,101 +0,0 @@
import { request } from "@umijs/max";
export type DictDataVO = {
id: number;
sort: number | undefined;
label: string;
value: string;
dictType: string;
status: number;
colorType: string;
cssClass: string;
remark: string;
createTime: Date;
};
export interface DictDataReqVO extends PageParam {
dictType?: string;
createTime?: Date;
}
// 查询字典数据(精简)列表
// export const getSimpleDictDataList = () => {
// return request.get({ url: "/system/dict-data/simple-list" });
// };
export const getSimpleDictDataList = () => {
return request("/system/dict-data/simple-list", {
method: "GET",
});
};
// 查询字典数据列表
// export const getDictDataPage = (params: PageParam) => {
// return request.get({ url: "/system/dict-data/page", params });
// };
export const getDictDataPage = (params: DictDataReqVO) => {
return request("/system/dict-data/page", {
method: "GET",
params,
});
};
// 查询字典数据详情
// export const getDictData = (id: number) => {
// return request.get({ url: "/system/dict-data/get?id=" + id });
// };
export const getDictData = (id: number) => {
return request("/system/dict-data/get", {
method: "GET",
params: { id },
});
};
// 新增字典数据
// export const createDictData = (data: DictData) => {
// return request.post({ url: "/system/dict-data/create", data });
// };
export const createDictData = (data: DictDataVO) => {
return request("/system/dict-data/create", {
method: "POST",
data,
});
};
// 修改字典数据
// export const updateDictData = (data: DictData) => {
// return request.put({ url: "/system/dict-data/update", data });
// };
export const updateDictData = (data: DictDataVO) => {
return request("/system/dict-data/update", {
method: "PUT",
data,
});
};
// 删除字典数据
// export const deleteDictData = (id: number) => {
// return request.delete({ url: "/system/dict-data/delete?id=" + id });
// };
export const deleteDictData = (id: number) => {
return request("/system/dict-data/delete", {
method: "DELETE",
params: { id },
});
};
// 导出字典类型数据
// export const exportDictData = (params: DictData) => {
// return request.download({ url: "/system/dict-data/export", params });
// };
export const exportDictData = (params: DictDataVO) => {
return request("/system/dict-data/export", {
method: "GET",
params,
});
};

View File

@@ -1,101 +0,0 @@
import { request } from "@umijs/max";
export interface DictTypeVO extends PageParam {
id: number;
name: string;
type: string;
status: number;
remark: string;
createTime: Date;
}
export interface DictReqVO extends PageParam {
name?: string;
status?: number;
type?: string;
createTime?: Date;
}
// 查询字典(精简)列表
// export const getSimpleDictTypeList = () => {
// return request.get({ url: "/system/dict-type/list-all-simple" });
// };
export const getSimpleDictTypeList = () => {
return request("/system/dict-type/list-all-simple", {
method: "GET",
});
};
// 查询字典列表
// export const getDictTypePage = (
// params: DictReq
// ): Promise<PageResult<DictType[]>> => {
// return request.get({ url: "/system/dict-type/page", params });
// };
export const getDictTypePage = (params: PageParam) => {
return request("/system/dict-type/page", {
method: "GET",
params,
});
};
// // 查询字典详情
// export const getDictType = (id?: number) => {
// return request.get({ url: "/system/dict-type/get?id=" + id });
// };
export const getDictType = (id: number) => {
return request("/system/dict-type/get", {
method: "GET",
params: { id },
});
};
// 新增字典
// export const createDictType = (data: DictType) => {
// return request.post({ url: "/system/dict-type/create", data });
// };
export const createDictType = (data: DictTypeVO) => {
return request("/system/dict-type/create", {
method: "POST",
data,
});
};
// 修改字典
// export const updateDictType = (data: DictType) => {
// return request.put({ url: "/system/dict-type/update", data });
// };
export const updateDictType = (data: DictTypeVO) => {
return request("/system/dict-type/update", {
method: "PUT",
data,
});
};
// 删除字典
// export const deleteDictType = (id: number) => {
// return request.delete({ url: "/system/dict-type/delete?id=" + id });
// };
export const deleteDictType = (id: number) => {
return request("/system/dict-type/delete", {
method: "DELETE",
params: { id },
});
};
// 导出字典类型
// export const exportDictType = (params: DictType) => {
// return request.download({ url: "/system/dict-type/export", params });
// };
export const exportDictType = (params: DictTypeVO) => {
return request("/system/dict-type/export", {
method: "POST",
params,
});
};

View File

@@ -0,0 +1,27 @@
import { request } from "@umijs/max";
export interface LoginLogVO {
id: number;
logType: number;
traceId: number;
userId: number;
userType: number;
username: string;
result: number;
status: number;
userIp: string;
userAgent: string;
createTime: Date;
}
// 查询登录日志列表
export async function getLoginLogPage(params: PageParam) {
return request("/system/login-log/page", {
method: "GET",
params,
});
}
// // 导出登录日志
// export const exportLoginLog = (params) => {
// return request.download({ url: '/system/login-log/export', params })
// }

View File

@@ -0,0 +1,32 @@
import { request } from "@umijs/max";
export type OperateLogVO = {
id: number;
traceId: string;
userType: number;
userId: number;
userName: string;
type: string;
subType: string;
bizId: number;
action: string;
extra: string;
requestMethod: string;
requestUrl: string;
userIp: string;
userAgent: string;
creator: string;
creatorName: string;
createTime: Date;
};
export async function getOperateLogPage(params: PageParam) {
return request("/system/operate-log/page", {
method: "GET",
params,
});
}
// // 导出操作日志
// export const exportOperateLog = (params: any) => {
// return request.download({ url: "/system/operate-log/export", params });
// };

View File

@@ -19,81 +19,32 @@ export interface MenuVO {
children?: MenuVO[]; children?: MenuVO[];
} }
export interface MenuReqVO {
name?: string;
status?: 0 | 1;
}
// 查询菜单(精简)列表 // 查询菜单(精简)列表
export const getSimpleMenusList = () => {
return request("/system/menu/simple-list", {
method: "GET",
});
};
// export const getSimpleMenusList = () => { // export const getSimpleMenusList = () => {
// return request.get({ url: '/system/menu/simple-list' }) // return request.get({ url: '/system/menu/simple-list' })
// } // }
// // 查询菜单列表 // // 查询菜单列表
export const getMenuList = (params: MenuReqVO) => {
return request("/system/menu/list", {
method: "GET",
params,
});
};
// export const getMenuList = (params) => { // export const getMenuList = (params) => {
// return request.get({ url: '/system/menu/list', params }) // return request.get({ url: '/system/menu/list', params })
// } // }
// // 获取菜单详情 // // 获取菜单详情
export const getMenu = (id: number) => {
return request("/system/menu/get", {
method: "GET",
params: { id },
});
};
// export const getMenu = (id: number) => { // export const getMenu = (id: number) => {
// return request.get({ url: '/system/menu/get?id=' + id }) // return request.get({ url: '/system/menu/get?id=' + id })
// } // }
// // 新增菜单 // // 新增菜单
export const createMenu = (data: MenuVO) => {
return request("/system/menu/create", {
method: "POST",
data,
});
};
// export const createMenu = (data: MenuVO) => { // export const createMenu = (data: MenuVO) => {
// return request.post({ url: '/system/menu/create', data }) // return request.post({ url: '/system/menu/create', data })
// } // }
// // 修改菜单 // // 修改菜单
export const updateMenu = (data: MenuVO) => {
return request("/system/menu/update", {
method: "PUT",
data,
});
};
// export const updateMenu = (data: MenuVO) => { // export const updateMenu = (data: MenuVO) => {
// return request.put({ url: '/system/menu/update', data }) // return request.put({ url: '/system/menu/update', data })
// } // }
// // 删除菜单 // // 删除菜单
export const deleteMenu = (id: number) => {
return request("/system/menu/delete", {
method: "DELETE",
params: { id },
});
};
// export const deleteMenu = (id: number) => { // export const deleteMenu = (id: number) => {
// return request.delete({ url: '/system/menu/delete?id=' + id }) // return request.delete({ url: '/system/menu/delete?id=' + id })
// } // }

View File

@@ -0,0 +1,73 @@
import { request } from "@umijs/max";
export interface MailAccountVO {
id: number;
mail: string;
username: string;
password: string;
host: string;
createTime: Date;
port: number;
sslEnable: boolean;
starttlsEnable: boolean;
}
// 查询邮箱账号列表
// export const getMailAccountPage = async (params: PageParam) => {
// return await request.get({ url: '/system/mail-account/page', params })
// }
export async function getMailAccountPage(params: PageParam) {
return request("/system/mail-account/page", {
method: "GET",
params,
});
}
// 查询邮箱账号详情
// export const getMailAccount = async (id: number) => {
// return await request.get({ url: '/system/mail-account/get?id=' + id })
// }
export async function getMailAccount(id: number) {
return request("/system/mail-account/get", {
method: "GET",
params: { id },
});
}
// 新增邮箱账号
// export const createMailAccount = async (data: MailAccountVO) => {
// return await request.post({ url: "/system/mail-account/create", data });
// };
export async function createMailAccount(data: MailAccountVO) {
return request("/system/mail-account/create", {
method: "POST",
data,
});
}
// 修改邮箱账号
// export const updateMailAccount = async (data: MailAccountVO) => {
// return await request.put({ url: "/system/mail-account/update", data });
// };
export async function updateMailAccount(data: MailAccountVO) {
return request("/system/mail-account/update", {
method: "PUT",
data,
});
}
// 删除邮箱账号
// export const deleteMailAccount = async (id: number) => {
// return await request.delete({ url: "/system/mail-account/delete?id=" + id });
// };
export async function deleteMailAccount(id: number) {
return request("/system/mail-account/delete", {
method: "DELETE",
params: { id },
});
}
// 获得邮箱账号精简列表
// export const getSimpleMailAccountList = async () => {
// return request.get({ url: '/system/mail-account/simple-list' })
// }
export async function getSimpleMailAccountList() {
return request("/system/mail-account/simple-list", {
method: "GET",
});
}

View File

@@ -0,0 +1,41 @@
import { request } from "@umijs/max";
export interface MailLogVO {
id: number;
userId: number;
userType: number;
toMail: string;
accountId: number;
fromMail: string;
templateId: number;
templateCode: string;
templateNickname: string;
templateTitle: string;
templateContent: string;
templateParams: string;
sendStatus: number;
sendTime: Date;
sendMessageId: string;
sendException: string;
}
// 查询邮件日志列表
// export const getMailLogPage = async (params: PageParam) => {
// return await request.get({ url: '/system/mail-log/page', params })
// }
export async function getMailLogPage(params: PageParam) {
return request("/system/mail-log/page", {
method: "GET",
params,
});
}
// 查询邮件日志详情
// export const getMailLog = async (id: number) => {
// return await request.get({ url: '/system/mail-log/get?id=' + id })
// }
export async function getMailLog(id: number) {
return request("/system/mail-log/get", {
method: "GET",
params: { id },
});
}

View File

@@ -0,0 +1,81 @@
import { request } from "@umijs/max";
export interface MailTemplateVO {
id: number;
name: string;
code: string;
accountId: number;
nickname: string;
title: string;
content: string;
params: string;
status: number;
remark: string;
}
export interface MailSendReqVO {
mail: string;
templateCode: string;
templateParams: Map<String, Object>;
}
// 查询邮件模版列表
// export const getMailTemplatePage = async (params: PageParam) => {
// return await request.get({ url: '/system/mail-template/page', params })
// }
export async function getMailTemplatePage(params: PageParam) {
return request("/system/mail-template/page", {
method: "GET",
params,
});
}
// 查询邮件模版详情
// export const getMailTemplate = async (id: number) => {
// return await request.get({ url: '/system/mail-template/get?id=' + id })
// }
export async function getMailTemplate(id: number) {
return request("/system/mail-template/get", {
method: "GET",
params: { id },
});
}
// 新增邮件模版
// export const createMailTemplate = async (data: MailTemplateVO) => {
// return await request.post({ url: '/system/mail-template/create', data })
// }
export async function createMailTemplate(data: MailTemplateVO) {
return request("/system/mail-template/create", {
method: "POST",
data,
});
}
// 修改邮件模版
// export const updateMailTemplate = async (data: MailTemplateVO) => {
// return await request.put({ url: '/system/mail-template/update', data })
// }
export async function updateMailTemplate(data: MailTemplateVO) {
return request("/system/mail-template/update", {
method: "PUT",
data,
});
}
// 删除邮件模版
// export const deleteMailTemplate = async (id: number) => {
// return await request.delete({ url: '/system/mail-template/delete?id=' + id })
// }
export async function deleteMailTemplate(id: number) {
return request("/system/mail-template/delete", {
method: "PUT",
params: { id },
});
}
// 发送邮件
// export const sendMail = (data: MailSendReqVO) => {
// return request.post({ url: '/system/mail-template/send-mail', data })
// }
export async function sendMail(data: MailTemplateVO) {
return request("/system/mail-template/send-mail", {
method: "PUT",
data,
});
}

View File

@@ -0,0 +1,74 @@
import { request } from "@umijs/max";
export interface NoticeVO {
id: number;
title: string;
type: number;
content: string;
status: number;
remark: string;
creator: string;
createTime: Date;
}
// 查询公告列表
// export const getNoticePage = (params: PageParam) => {
// return request.get({ url: '/system/notice/page', params })
// }
export async function getNoticePage(params: PageParam) {
return request("/system/notice/page", {
method: "GET",
params,
});
}
// 查询公告详情
// export const getNotice = (id: number) => {
// return request.get({ url: '/system/notice/get?id=' + id })
// }
export async function getNotice(id: number) {
return request("/system/notice/get", {
method: "GET",
params: { id },
});
}
// 新增公告
// export const createNotice = (data: NoticeVO) => {
// return request.post({ url: '/system/notice/create', data })
// }
export async function createNotice(data: NoticeVO) {
return request("/system/notice/create", {
method: "POST",
data,
});
}
// 修改公告
// export const updateNotice = (data: NoticeVO) => {
// return request.put({ url: '/system/notice/update', data })
// }
export async function updateNotice(data: NoticeVO) {
return request("/system/notice/update", {
method: "PUT",
data,
});
}
// 删除公告
// export const deleteNotice = (id: number) => {
// return request.delete({ url: '/system/notice/delete?id=' + id })
// }
export async function deleteNotice(id: number) {
return request("/system/notice/update", {
method: "DELETE",
params: { id },
});
}
// 推送公告
// export const pushNotice = (id: number) => {
// return request.post({ url: '/system/notice/push?id=' + id })
// }
export async function pushNotice(id: number) {
return request("/system/notice/push", {
method: "POST",
params: { id },
});
}

View File

@@ -0,0 +1,76 @@
import { request } from "@umijs/max";
export interface NotifyMessageVO {
id: number;
userId: number;
userType: number;
templateId: number;
templateCode: string;
templateNickname: string;
templateContent: string;
templateType: number;
templateParams: string;
readStatus: boolean;
readTime: Date;
createTime: Date;
}
// 查询站内信消息列表
// export const getNotifyMessagePage = async (params: PageParam) => {
// return await request.get({ url: '/system/notify-message/page', params })
// }
export async function getNotifyMessagePage(params: PageParam) {
return request("/system/notify-message/page", {
method: "GET",
params,
});
}
// 获得我的站内信分页
// export const getMyNotifyMessagePage = async (params: PageParam) => {
// return await request.get({ url: '/system/notify-message/my-page', params })
// }
export async function getMyNotifyMessagePage(params: PageParam) {
return request("/system/notify-message/my-page", {
method: "GET",
params,
});
}
// 批量标记已读
// export const updateNotifyMessageRead = async (ids) => {
// return await request.put({
// url: '/system/notify-message/update-read?' + qs.stringify({ ids: ids }, { indices: false })
// })
// }
export async function updateNotifyMessageRead(ids: number[]) {
return request("/system/notice/update", {
method: "PUT",
params: { ids: ids },
});
}
// 标记所有站内信为已读
// export const updateAllNotifyMessageRead = async () => {
// return await request.put({ url: '/system/notify-message/update-all-read' })
// }
export async function updateAllNotifyMessageRead() {
return request("/system/notify-message/update-all-read", {
method: "PUT",
});
}
// 获取当前用户的最新站内信列表
// export const getUnreadNotifyMessageList = async () => {
// return await request.get({ url: '/system/notify-message/get-unread-list' })
// }
export async function getUnreadNotifyMessageList() {
return request("/system/notify-message/get-unread-list", {
method: "GET",
});
}
// 获得当前用户的未读站内信数量
// export const getUnreadNotifyMessageCount = async () => {
// return await request.get({ url: '/system/notify-message/get-unread-count' })
// }
export async function getUnreadNotifyMessageCount() {
return request("/system/notify-message/get-unread-count", {
method: "GET",
});
}

View File

@@ -0,0 +1,80 @@
import { request } from "@umijs/max";
export interface NotifyTemplateVO {
id: number;
name: string;
nickname: string;
code: string;
content: string;
type?: number;
params: string;
status: number;
remark: string;
mobile: string;
createTime: Date;
userType: number;
userId: number | null;
templateCode: string;
templateParams: Map<String, Object>;
}
// 查询站内信模板列表
// export const getNotifyTemplatePage = async (params: PageParam) => {
// return await request.get({ url: 'getNotifyTemplatePage', params })
// }
export async function getNotifyTemplatePage(params: PageParam) {
return request("/system/notify-template/page", {
method: "GET",
params,
});
}
// 查询站内信模板详情
// export const getNotifyTemplate = async (id: number) => {
// return await request.get({ url: '/system/notify-template/get?id=' + id })
// }
export async function getNotifyTemplate(id: number) {
return request("/system/notify-template/get", {
method: "GET",
params: { id },
});
}
// 新增站内信模板
// export const createNotifyTemplate = async (data: NotifyTemplateVO) => {
// return await request.post({ url: '/system/notify-template/create', data })
// }
export async function createNotifyTemplate(data: NotifyTemplateVO) {
return request("/system/notify-template/create", {
method: "POST",
data,
});
}
// 修改站内信模板
// export const updateNotifyTemplate = async (data: NotifyTemplateVO) => {
// return await request.put({ url: '/system/notify-template/update', data })
// }
export async function updateNotifyTemplate(data: NotifyTemplateVO) {
return request("/system/notify-template/update", {
method: "PUT",
data,
});
}
// 删除站内信模板
// export const deleteNotifyTemplate = async (id: number) => {
// return await request.delete({ url: '/system/notify-template/delete?id=' + id })
// }
export async function deleteNotifyTemplate(id: number) {
return request("/system/notify-template/delete", {
method: "DELETE",
params: { id },
});
}
// 发送站内信
// export const sendNotify = (data: NotifySendReqVO) => {
// return request.post({ url: '/system/notify-template/send-notify', data })
// }
export async function sendNotify(data: NotifyTemplateVO) {
return request("/system/notify-template/send-notify", {
method: "POST",
data,
});
}

View File

@@ -0,0 +1,73 @@
import { request } from "@umijs/max";
export interface SmsChannelVO {
id: number;
code: string;
status: number;
signature: string;
remark: string;
apiKey: string;
apiSecret: string;
callbackUrl: string;
createTime: Date;
}
// 查询短信渠道列表
// export const getSmsChannelPage = (params: PageParam) => {
// return request.get({ url: '/system/sms-channel/page', params })
// }
export async function getSmsChannelPage(params: PageParam) {
return request("/system/sms-channel/page", {
method: "GET",
params,
});
}
// 获得短信渠道精简列表
// export function getSimpleSmsChannelList() {
// return request.get({ url: '/system/sms-channel/simple-list' })
// }
export async function getSimpleSmsChannelList() {
return request("/system/sms-channel/simple-list", {
method: "GET",
});
}
// 查询短信渠道详情
// export const getSmsChannel = (id: number) => {
// return request.get({ url: '/system/sms-channel/get?id=' + id })
// }
export async function getSmsChannel(id: number) {
return request("/system/sms-channel/get", {
method: "GET",
params: { id },
});
}
// 新增短信渠道
// export const createSmsChannel = (data: SmsChannelVO) => {
// return request.post({ url: '/system/sms-channel/create', data })
// }
export async function createSmsChannel(data: SmsChannelVO) {
return request("/system/sms-channel/create", {
method: "POST",
data,
});
}
// 修改短信渠道
// export const updateSmsChannel = (data: SmsChannelVO) => {
// return request.put({ url: '/system/sms-channel/update', data })
// }
export async function updateSmsChannel(data: SmsChannelVO) {
return request("/system/sms-channel/update", {
method: "PUT",
data,
});
}
// 删除短信渠道
// export const deleteSmsChannel = (id: number) => {
// return request.delete({ url: '/system/sms-channel/delete?id=' + id })
// }
export async function deleteSmsChannel(id: number) {
return request("/system/sms-channel/delete", {
method: "DELETE",
params: { id },
});
}

View File

@@ -0,0 +1,40 @@
import { request } from "@umijs/max";
export interface SmsLogVO {
id: number;
channelId: number | null;
channelCode: string;
templateId: number | null;
templateCode: string;
templateType: number | null;
templateContent: string;
templateParams: Map<string, object> | null;
apiTemplateId: string;
mobile: string;
userId: number | null;
userType: number | null;
sendStatus: number | null;
sendTime: Date | null;
apiSendCode: string;
apiSendMsg: string;
apiRequestId: string;
apiSerialNo: string;
receiveStatus: number | null;
receiveTime: Date | null;
apiReceiveCode: string;
apiReceiveMsg: string;
createTime: Date | null;
}
// 查询短信日志列表
export async function getSmsLogPage(params: PageParam) {
return request("/system/sms-log/page", {
method: "GET",
params,
});
}
// 导出短信日志
// export const exportSmsLog = (params) => {
// return request.download({ url: '/system/sms-log/export-excel', params })
// }

View File

@@ -0,0 +1,89 @@
import { request } from "@umijs/max";
export interface SmsTemplateVO {
id: number;
type: number;
status: number;
code: string;
name: string;
content: string;
remark: string;
apiTemplateId: string;
channelId?: number;
channelCode?: string;
params?: string[];
createTime?: Date;
mobile: string;
templateCode: string;
templateParams: Map<String, Object>;
}
// 查询短信模板列表
// export const getSmsTemplatePage = (params: PageParam) => {
// return request.get({ url: '/system/sms-template/page', params })
// }
export async function getSmsTemplatePage(params: PageParam) {
return request("/system/sms-template/page", {
method: "GET",
params,
});
}
// 查询短信模板详情
// export const getSmsTemplate = (id: number) => {
// return request.get({ url: '/system/sms-template/get?id=' + id })
// }
export async function getSmsTemplate(id: number) {
return request("/system/sms-template/get", {
method: "GET",
params: { id },
});
}
// 新增短信模板
// export const createSmsTemplate = (data: SmsTemplateVO) => {
// return request.post({ url: '/system/sms-template/create', data })
// }
export async function createSmsTemplate(data: SmsTemplateVO) {
return request("/system/sms-template/create", {
method: "POST",
data,
});
}
// 修改短信模板
// export const updateSmsTemplate = (data: SmsTemplateVO) => {
// return request.put({ url: '/system/sms-template/update', data })
// }
export async function updateSmsTemplate(data: SmsTemplateVO) {
return request("/system/sms-template/update", {
method: "PUT",
data,
});
}
// 删除短信模板
// export const deleteSmsTemplate = (id: number) => {
// return request.delete({ url: '/system/sms-template/delete?id=' + id })
// }
export async function deleteSmsTemplate(id: number) {
return request("/system/sms-template/delete", {
method: "DELETE",
params: { id },
});
}
// 导出短信模板
// export const exportSmsTemplate = (params) => {
// return request.download({
// url: '/system/sms-template/export-excel',
// params
// })
// }
// 发送短信
// export const sendSms = (data: SendSmsReqVO) => {
// return request.post({ url: '/system/sms-template/send-sms', data })
// }
export async function sendSms(data: SmsTemplateVO) {
return request("/system/sms-template/send-sms", {
method: "POST",
data,
});
}

View File

@@ -1,87 +0,0 @@
import { request } from "@umijs/max";
export interface PostVO {
id: number;
name: string;
code: string;
sort: number;
status: number;
remark: string;
createTime?: Date;
}
export interface PostReqVO extends PageParam {
name?: string;
status?: number;
code?: string;
}
// 查询岗位列表
// export const getPostPage = async (params: PostReq) => {
// return await request.get({ url: "/system/post/page", params });
// };
export const getPostPage = (params: PostReqVO) => {
return request("/system/post/page", {
method: "GET",
params,
});
};
// 获取岗位精简信息列表
// export const getSimplePostList = async (): Promise<Post[]> => {
// return await request.get({ url: "/system/post/simple-list" });
// };
export const getSimplePostList = () => {
return request("/system/post/simple-list", {
method: "GET",
});
};
// 查询岗位详情
// export const getPost = async (id: number) => {
// return await request.get({ url: "/system/post/get?id=" + id });
// };
export const getPost = (id: number) => {
return request("/system/post/get", {
method: "GET",
params: { id },
});
};
// 新增岗位
// export const createPost = async (data: Post) => {
// return await request.post({ url: "/system/post/create", data });
// };
export const createPost = async (data: PostVO) => {
return await request("/system/post/create", {
method: "POST",
data,
});
};
// 修改岗位
// export const updatePost = async (data: Post) => {
// return await request.put({ url: "/system/post/update", data });
// };
export const updatePost = async (data: PostVO) => {
return await request("/system/post/update", {
method: "PUT",
data,
});
};
// 删除岗位
// export const deletePost = async (id: number) => {
// return await request.delete({ url: "/system/post/delete?id=" + id });
// };
export const deletePost = async (id: number) => {
return await request("/system/post/delete", {
method: "DELETE",
params: { id },
});
};

View File

@@ -1,106 +0,0 @@
import { request } from "@umijs/max";
export interface RoleVO {
id: number;
name: string;
code: string;
sort: number;
status: number;
type: number;
dataScope: number;
dataScopeDeptIds: number[];
createTime: Date;
menuIds: number[];
}
export interface RolePageReqVO extends PageParam {
name?: string;
code?: string;
status?: string;
createTime?: Date[];
}
export interface UpdateStatusReq {
id: number;
status: number;
}
// 查询角色列表
export const getRolePage = (params: RolePageReqVO) => {
return request("/system/role/page", {
method: "GET",
params,
});
};
// export const getRolePage = async (
// params: RolePageReq
// ): Promise<PageResult<Role[]>> => {
// return await request.get({ url: "/system/role/page", params });
// };
// 查询角色(精简)列表
export const getSimpleRoleList = () => {
return request("/system/role/simple-list", {
method: "GET",
});
};
// export const getSimpleRoleList = async (): Promise<Role[]> => {
// return await request.get({ url: "/system/role/simple-list" });
// };
// 查询角色详情
export const getRole = (id: number) => {
return request("/system/role/get", {
method: "GET",
params: { id },
});
};
// export const getRole = async (id: number) => {
// return await request.get({ url: "/system/role/get?id=" + id });
// };
// 新增角色
export const createRole = (data: RoleVO) => {
return request("/system/role/create", {
method: "POST",
data,
});
};
// export const createRole = async (data: Role) => {
// return await request.post({ url: "/system/role/create", data });
// };
// 修改角色
// export const updateRole = async (data: Role) => {
// return await request.put({ url: "/system/role/update", data });
// };
export const updateRole = (data: RoleVO) => {
return request("/system/role/update", {
method: "PUT",
data,
});
};
// 修改角色状态
export const updateRoleStatus = (data: UpdateStatusReq) => {
return request("/system/role/update-status", {
method: "PUT",
data,
});
};
// export const updateRoleStatus = async (data: UpdateStatusReq) => {
// return await request.put({ url: "/system/role/update-status", data });
// };
// 删除角色
export const deleteRole = (id: number) => {
return request("/system/role/delete", {
method: "DELETE",
params: { id },
});
};
// export const deleteRole = async (id: number) => {
// return await request.delete({ url: "/system/role/delete?id=" + id });
// };

View File

@@ -12,27 +12,11 @@ export interface TenantPackageVO {
createTime: Date; createTime: Date;
} }
export interface TenantPackagePageReqVO extends PageParam {
name?: string;
contactName?: string;
contactMobile?: string;
status?: number;
createTime?: Date[];
}
// 查询租户套餐列表 // 查询租户套餐列表
// export const getTenantPackagePage = (params: PageParam) => { // export const getTenantPackagePage = (params: PageParam) => {
// return request.get({ url: '/system/tenant-package/page', params }) // return request.get({ url: '/system/tenant-package/page', params })
// } // }
export async function getTenantPackagePage(params: TenantPackagePageReqVO) {
return request("/system/tenant-package/page", {
method: "GET",
params,
});
}
// 获得租户 // 获得租户
// export const getTenantPackage = (id: number) => { // export const getTenantPackage = (id: number) => {
// return request.get({ url: '/system/tenant-package/get?id=' + id }) // return request.get({ url: '/system/tenant-package/get?id=' + id })

View File

@@ -1,154 +0,0 @@
// import request from "@/config/axios";
import { request } from "@umijs/max";
export interface UserVO {
id: number;
username: string;
nickname: string;
deptId: number;
postIds: string[];
email: string;
mobile: string;
sex: number;
avatar: string;
loginIp: string;
status: number;
remark: string;
loginDate: Date;
createTime: Date;
}
// export interface User {
// id: number;
// username: string;
// nickname: string;
// deptId: number;
// postIds: string[];
// email: string;
// mobile: string;
// sex: number;
// avatar: string;
// loginIp: string;
// status: number;
// remark: string;
// loginDate: Date;
// createTime: Date;
// }
export interface UserReqVO extends PageParam {
username?: string;
status?: number;
mobile?: string;
createTime?: Date;
deptId?: number;
}
// export interface UserReq extends PageParam {
// username?: string;
// status?: number;
// mobile?: string;
// createTime?: Date;
// deptId?: number;
// }
// 查询用户管理列表
export const getUserPage = (params: UserReqVO) => {
return request("/system/user/page", {
method: "GET",
params,
});
};
// export const getUserPage = (params: UserReq) => {
// return request.get({ url: "/system/user/page", params });
// };
// 查询用户详情
export const getUser = (id: number) => {
return request("/system/user/get", {
method: "GET",
params: { id },
});
};
// export const getUser = (id: number) => {
// return request.get({ url: "/system/user/get?id=" + id });
// };
// 新增用户
export const createUser = (data: UserVO) => {
return request("/system/user/create", {
method: "POST",
data,
});
};
// export const createUser = (data: User) => {
// return request.post({ url: "/system/user/create", data });
// };
// 修改用户
export const updateUser = (data: UserVO) => {
return request("/system/user/update", {
method: "PUT",
data,
});
};
// export const updateUser = (data: User) => {
// return request.put({ url: "/system/user/update", data });
// };
// 删除用户
export const deleteUser = (id: number) => {
return request("/system/user/delete", {
method: "DELETE",
params: { id },
});
};
// export const deleteUser = (id: number) => {
// return request.delete({ url: "/system/user/delete?id=" + id });
// };
// 用户密码重置
export const resetUserPassword = (id: number, password: string) => {
return request("/system/user/reset-password", {
method: "PUT",
params: { id, password },
});
};
// export const resetUserPassword = (id: number, password: string) => {
// const data = {
// id,
// password
// };
// return request.put({ url: "/system/user/update-password", data: data });
// };
// 用户状态修改
export const updateUserStatus = (id: number, status: number) => {
return request("/system/user/update-status", {
method: "PUT",
data: { id, status },
});
};
// export const updateUserStatus = (id: number, status: number) => {
// const data = {
// id,
// status
// };
// return request.put({ url: "/system/user/update-status", data: data });
// };
// 获取用户精简信息列表
export const getSimpleUserList = () => {
return request("/system/user/simple-list", {
method: "GET",
});
};
// export const getSimpleUserList = (): Promise<User[]> => {
// return request.get({ url: "/system/user/simple-list" });
// };

View File

@@ -1,5 +0,0 @@
export type Operations = {
handleSearch?: (evt: MouseEvent) => void;
handleReset?: (evt: MouseEvent) => void;
handleExport?: (evt: MouseEvent) => void;
};

View File

@@ -1,22 +0,0 @@
// 创建 value 到 label 的映射
const statusMap = (status: { label: string; value: number }[]) =>
new Map(status?.map((item) => [item.value, item.label]));
const packageMap = (status: { id: number; name: string }[]) =>
new Map(status?.map((item) => [item.id, item.name]));
// 获取 label 的函数
export const getStatusLabel = (
status: { label: string; value: number }[],
value: number,
): string => {
return statusMap(status).get(value) || '';
};
// 获取 label 的函数
export const getpackageLabel = (
status: { id: number; name: string }[],
id: number,
): string => {
return packageMap(status).get(id) || '';
};

View File

@@ -1,451 +0,0 @@
interface TreeHelperConfig {
id: string;
children: string;
pid: string;
}
const DEFAULT_CONFIG: TreeHelperConfig = {
id: 'id',
children: 'children',
pid: 'pid',
};
export const defaultProps = {
children: 'children',
label: 'name',
value: 'id',
isLeaf: 'leaf',
emitPath: false, // 用于 cascader 组件:在选中节点改变时,是否返回由该节点所在的各级菜单的值所组成的数组,若设置 false则只返回该节点的值
};
const getConfig = (config: Partial<TreeHelperConfig>) =>
Object.assign({}, DEFAULT_CONFIG, config);
// tree from list
export const listToTree = <T = any>(
list: any[],
config: Partial<TreeHelperConfig> = {},
): T[] => {
const conf = getConfig(config) as TreeHelperConfig;
const nodeMap = new Map();
const result: T[] = [];
const { id, children, pid } = conf;
for (const node of list) {
node[children] = node[children] || [];
nodeMap.set(node[id], node);
}
for (const node of list) {
const parent = nodeMap.get(node[pid]);
(parent ? parent.children : result).push(node);
}
return result;
};
export const treeToList = <T = any>(
tree: any,
config: Partial<TreeHelperConfig> = {},
): T => {
config = getConfig(config);
const { children } = config;
const result: any = [...tree];
for (let i = 0; i < result.length; i++) {
if (!children) return result;
if (!result[i][children]) continue;
result.splice(i + 1, 0, ...result[i][children]);
}
return result;
};
export const findNode = <T = any>(
tree: any,
func: Fn,
config: Partial<TreeHelperConfig> = {},
): T | null => {
config = getConfig(config);
const { children } = config;
const list = [...tree];
if (!children) return null;
for (const node of list) {
if (func(node)) return node;
node[children] && list.push(...node[children]);
}
return null;
};
export const findNodeAll = <T = any>(
tree: any,
func: Fn,
config: Partial<TreeHelperConfig> = {},
): T[] => {
config = getConfig(config);
const { children } = config;
const list = [...tree];
const result: T[] = [];
if (!children) return result;
for (const node of list) {
func(node) && result.push(node);
node[children] && list.push(...node[children]);
}
return result;
};
export const findPath = <T = any>(
tree: any,
func: Fn,
config: Partial<TreeHelperConfig> = {},
): T | T[] | null => {
config = getConfig(config);
const path: T[] = [];
const list = [...tree];
const visitedSet = new Set();
const { children } = config;
if (!children) return null;
while (list.length) {
const node = list[0];
if (visitedSet.has(node)) {
path.pop();
list.shift();
} else {
visitedSet.add(node);
node[children] && list.unshift(...node[children]);
path.push(node);
if (func(node)) {
return path;
}
}
}
return null;
};
export const findPathAll = (
tree: any,
func: Fn,
config: Partial<TreeHelperConfig> = {},
) => {
config = getConfig(config);
const path: any[] = [];
const list = [...tree];
const result: any[] = [];
const visitedSet = new Set(),
{ children } = config;
if (!children) return [];
while (list.length) {
const node = list[0];
if (visitedSet.has(node)) {
path.pop();
list.shift();
} else {
visitedSet.add(node);
node[children] && list.unshift(...node[children]);
path.push(node);
func(node) && result.push([...path]);
}
}
return result;
};
export const filter = <T = any>(
tree: T[],
func: (n: T) => boolean,
config: Partial<TreeHelperConfig> = {},
): T[] => {
config = getConfig(config);
const children = config.children as string;
function listFilter(list: T[]) {
return list
.map((node: any) => ({ ...node }))
.filter((node) => {
node[children] = node[children] && listFilter(node[children]);
return func(node) || node[children]?.length;
});
}
return listFilter(tree);
};
export const forEach = <T = any>(
tree: T[],
func: (n: T) => any,
config: Partial<TreeHelperConfig> = {},
): void => {
config = getConfig(config);
const list: any[] = [...tree];
const { children } = config;
for (let i = 0; i < list.length; i++) {
// func 返回true就终止遍历避免大量节点场景下无意义循环引起浏览器卡顿
if (func(list[i])) {
return;
}
children &&
list[i][children] &&
list.splice(i + 1, 0, ...list[i][children]);
}
};
/**
* @description: Extract tree specified structure
*/
export const treeMap = <T = any>(
treeData: T[],
opt: { children?: string; conversion: Fn },
): T[] => {
return treeData.map((item) => treeMapEach(item, opt));
};
/**
* @description: Extract tree specified structure
*/
export const treeMapEach = (
data: any,
{ children = 'children', conversion }: { children?: string; conversion: Fn },
) => {
const haveChildren =
Array.isArray(data[children]) && data[children].length > 0;
const conversionData = conversion(data) || {};
if (haveChildren) {
return {
...conversionData,
[children]: data[children].map((i: number) =>
treeMapEach(i, {
children,
conversion,
}),
),
};
} else {
return {
...conversionData,
};
}
};
/**
* 递归遍历树结构
* @param treeDatas 树
* @param callBack 回调
* @param parentNode 父节点
*/
export const eachTree = (treeDatas: any[], callBack: Fn, parentNode = {}) => {
treeDatas.forEach((element) => {
const newNode = callBack(element, parentNode) || element;
if (element.children) {
eachTree(element.children, callBack, newNode);
}
});
};
/**
* 构造树型结构数据
* @param {*} data 数据源
* @param {*} id id字段 默认 'id'
* @param {*} parentId 父节点字段 默认 'parentId'
* @param {*} children 孩子节点字段 默认 'children'
*/
export const handleTree = (
data: any[],
id?: string,
parentId?: string,
children?: string,
) => {
if (!Array.isArray(data)) {
console.warn('data must be an array');
return [];
}
const config = {
id: id || 'id',
parentId: parentId || 'parentId',
childrenList: children || 'children',
};
const childrenListMap: any = {};
const nodeIds: any = {};
const tree: any[] = [];
for (const d of data) {
const parentId = d[config.parentId];
if (childrenListMap[parentId] == null) {
childrenListMap[parentId] = [];
}
nodeIds[d[config.id]] = d;
childrenListMap[parentId].push(d);
}
for (const d of data) {
const parentId = d[config.parentId];
if (nodeIds[parentId] == null) {
tree.push(d);
}
}
for (const t of tree) {
adaptToChildrenList(t);
}
function adaptToChildrenList(o: { [x: string]: any }) {
if (childrenListMap[o[config.id]] !== null) {
o[config.childrenList] = childrenListMap[o[config.id]];
}
if (o[config.childrenList]) {
for (const c of o[config.childrenList]) {
adaptToChildrenList(c);
}
}
}
return tree;
};
/**
* 构造树型结构数据
* @param {*} data 数据源
* @param {*} id id字段 默认 'id'
* @param {*} parentId 父节点字段 默认 'parentId'
* @param {*} children 孩子节点字段 默认 'children'
* @param {*} rootId 根Id 默认 0
*/
// @ts-expect-error
export const handleTree2 = (data, id, parentId, _children, rootId) => {
id = id || 'id';
parentId = parentId || 'parentId';
// children = children || 'children'
rootId =
rootId ||
Math.min(
...data.map((item: { [x: string]: any }) => {
return item[parentId];
}),
) ||
0;
// 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data));
// 循环所有项
const treeData = cloneData.filter(
(father: { [x: string]: any; children: any }) => {
const branchArr = cloneData.filter((child: { [x: string]: any }) => {
// 返回每一项的子级数组
return father[id] === child[parentId];
});
if (branchArr.length > 0) {
father.children = branchArr;
}
// 返回第一层
return father[parentId] === rootId;
},
);
return treeData !== '' ? treeData : data;
};
/**
* 校验选中的节点,是否为指定 level
*
* @param tree 要操作的树结构数据
* @param nodeId 需要判断在什么层级的数据
* @param level 检查的级别, 默认检查到二级
* @return true 是false 否
*/
export const checkSelectedNode = (
tree: any[],
nodeId: any,
level = 2,
): boolean => {
if (
typeof tree === 'undefined' ||
!Array.isArray(tree) ||
tree.length === 0
) {
console.warn('tree must be an array');
return false;
}
// 校验是否是一级节点
if (tree.some((item) => item.id === nodeId)) {
return false;
}
// 递归计数
let count = 1;
// 深层次校验
function performAThoroughValidation(arr: any[]): boolean {
count += 1;
for (const item of arr) {
if (item.id === nodeId) {
return true;
} else if (
typeof item.children !== 'undefined' &&
item.children.length !== 0
) {
if (performAThoroughValidation(item.children)) {
return true;
}
}
}
return false;
}
for (const item of tree) {
count = 1;
if (performAThoroughValidation(item.children)) {
// 找到后对比是否是期望的层级
if (count >= level) {
return true;
}
}
}
return false;
};
/**
* 获取节点的完整结构
* @param tree 树数据
* @param nodeId 节点 id
*/
export const treeToString = (tree: any[], nodeId: number) => {
if (
typeof tree === 'undefined' ||
!Array.isArray(tree) ||
tree.length === 0
) {
console.warn('tree must be an array');
return '';
}
// 校验是否是一级节点
const node = tree.find((item) => item.id === nodeId);
if (typeof node !== 'undefined') {
return node.name;
}
let str = '';
function performAThoroughValidation(arr: string | any[]) {
if (typeof arr === 'undefined' || !Array.isArray(arr) || arr.length === 0) {
return false;
}
for (const item of arr) {
if (item.id === nodeId) {
str += ` / ${item.name}`;
return true;
} else if (
typeof item.children !== 'undefined' &&
item.children.length !== 0
) {
str += ` / ${item.name}`;
if (performAThoroughValidation(item.children)) {
return true;
}
}
}
return false;
}
for (const item of tree) {
str = `${item.name}`;
if (performAThoroughValidation(item.children)) {
break;
}
}
return str;
};