Commit 86368a4a47b0ed93775a6e6ddf020279b2a53d4d

Authored by 黄 x
2 parents 3fd01bf3 46bfbef2

Merge branch 'main' into 'ft-dev'

# Conflicts:
#   .env.development
#   src/views/device/config.data.ts
#   src/views/device/index.vue
#   src/views/system/role/RoleDrawer.vue
Showing 78 changed files with 2331 additions and 1019 deletions

Too many changes to show.

To preserve performance only 78 of 125 files are displayed.

@@ -6,9 +6,7 @@ VITE_PUBLIC_PATH = / @@ -6,9 +6,7 @@ VITE_PUBLIC_PATH = /
6 6
7 # Cross-domain proxy, you can configure multiple 7 # Cross-domain proxy, you can configure multiple
8 # Please note that no line breaks 8 # Please note that no line breaks
9 -# If Use Online Mock,Address Is ["https://www.fastmock.site/mock/87187f474cb8128e88a517a04d77d80c/api"]  
10 -VITE_PROXY = [["/api","http://192.168.10.116:8082/api"],["/upload","http://localhost:3300/upload"]]  
11 -# VITE_PROXY = [["/api","https://www.fastmock.site/mock/87187f474cb8128e88a517a04d77d80c/api]",["/upload","http://localhost:3300/upload"]] 9 +VITE_PROXY = [["/api","http://192.168.10.120:8082/api"],["/upload","http://192.168.10.120:3300/upload"]]
12 # VITE_PROXY=[["/api","https://vvbin.cn/test"]] 10 # VITE_PROXY=[["/api","https://vvbin.cn/test"]]
13 11
14 # Delete console 12 # Delete console
  1 +{
  2 + "i18n-ally.localesPaths": [
  3 + "src/locales",
  4 + "src/locales/lang",
  5 + "public/resource/tinymce/langs"
  6 + ],
  7 + "commentTranslate.targetLanguage": "en"
  8 +}
  1 +import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
  2 +/**
  3 + * @description: Request list interface parameters
  4 + */
  5 +export type MessageConfigParams = BasicPageParams & MessageParams;
  6 +
  7 +export type MessageParams = {
  8 + status?: number;
  9 + messageType?: string;
  10 +};
  11 +
  12 +export interface MessageConfig {
  13 + id: string;
  14 + configName: string;
  15 + messageType: string;
  16 + platformType: string;
  17 + config: ConfigParams;
  18 + createTime: string;
  19 + updateTime: string;
  20 + status: number;
  21 +}
  22 +export interface ConfigParams {
  23 + host: string;
  24 + port: number;
  25 + username: string;
  26 + password: string;
  27 + accessKeyId: string;
  28 + accessKeySecret: string;
  29 +}
  30 +
  31 +/**
  32 + * @description: Request list return value
  33 + */
  34 +export type MessageConfigResultModel = BasicFetchResult<MessageConfig>;
  35 +
  36 +export type MessageConfigResult = MessageConfig;
@@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
8 name="viewport" 8 name="viewport"
9 content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" 9 content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
10 /> 10 />
11 -  
12 <title><%= title %></title> 11 <title><%= title %></title>
13 <link rel="icon" href="/favicon.ico" /> 12 <link rel="icon" href="/favicon.ico" />
14 </head> 13 </head>
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 "clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite", 21 "clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",
22 "clean:lib": "rimraf node_modules", 22 "clean:lib": "rimraf node_modules",
23 "lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix", 23 "lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
24 - "lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", 24 + "lint:prettier": "prettier --write \"src/**/*.{js,json,ts,tsx,css,less,scss,vue,html,md}\"",
25 "lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", 25 "lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
26 "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js", 26 "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
27 "lint:pretty": "pretty-quick --staged", 27 "lint:pretty": "pretty-quick --staged",
@@ -59,6 +59,7 @@ @@ -59,6 +59,7 @@
59 "tinymce": "^5.8.2", 59 "tinymce": "^5.8.2",
60 "vditor": "^3.8.6", 60 "vditor": "^3.8.6",
61 "vue": "3.2.2", 61 "vue": "3.2.2",
  62 + "vue-baidu-map": "^0.21.22",
62 "vue-i18n": "9.1.7", 63 "vue-i18n": "9.1.7",
63 "vue-json-pretty": "^2.0.4", 64 "vue-json-pretty": "^2.0.4",
64 "vue-router": "^4.0.11", 65 "vue-router": "^4.0.11",
  1 +import { defHttp } from '/@/utils/http/axios';
  2 +import type {
  3 + ContactPageParams,
  4 + ContactModal,
  5 + ContactParams,
  6 + ContactInfo,
  7 +} from './model/alarmContactModal';
  8 +import { getPageData } from '../../base';
  9 +enum Api {
  10 + alarmContact = '/alarmContact',
  11 + updateAlarmContact = '/alarmContact/update',
  12 +}
  13 +
  14 +// 获取
  15 +export const getAlarmContact = (params: ContactPageParams) => {
  16 + return getPageData<ContactModal>(params, Api.alarmContact);
  17 +};
  18 +
  19 +// 新增
  20 +export const addAlarmContact = (params: ContactParams) => {
  21 + return defHttp.post({
  22 + url: Api.alarmContact,
  23 + data: params,
  24 + });
  25 +};
  26 +
  27 +// 更新
  28 +export const updateAlarmContact = (params: ContactParams) => {
  29 + return defHttp.post({
  30 + url: Api.updateAlarmContact,
  31 + data: params,
  32 + });
  33 +};
  34 +
  35 +// 删除
  36 +export const deleteAlarmContact = (ids: string[]) => {
  37 + return defHttp.delete({
  38 + url: Api.alarmContact,
  39 + data: ids,
  40 + });
  41 +};
  42 +
  43 +// 新增或者编辑
  44 +export const saveOrEditAlarmContact = (params: ContactInfo, isUpdate: boolean) => {
  45 + if (isUpdate) return updateAlarmContact(params);
  46 + addAlarmContact(params);
  47 +};
  1 +import { BasicPageParams } from '/@/api/model/baseModel';
  2 +
  3 +interface ContactItemsModal {
  4 + id: string;
  5 + createTime: string;
  6 + enabled: boolean;
  7 + username: string;
  8 + department: string;
  9 + phone: string;
  10 +}
  11 +export type ContactPageParams = BasicPageParams & { username: string; organizationId: string };
  12 +
  13 +export interface ContactModal {
  14 + items: ContactItemsModal[];
  15 + total: number;
  16 +}
  17 +
  18 +export interface ContactParams {
  19 + phone: string;
  20 + username: string;
  21 + department?: string;
  22 + email?: string;
  23 + wechat?: string;
  24 + addPeople?: string;
  25 + remark?: string;
  26 +}
  27 +
  28 +export type ContactInfo = ContactParams;
1 -import {defHttp} from '/@/utils/http/axios'; 1 +import { defHttp } from '/@/utils/http/axios';
2 2
3 export interface PageData<T> { 3 export interface PageData<T> {
4 total: number; 4 total: number;
@@ -14,7 +14,7 @@ export interface BaseQueryParams { @@ -14,7 +14,7 @@ export interface BaseQueryParams {
14 pageSize: number; 14 pageSize: number;
15 page: number; 15 page: number;
16 orderFiled?: string; 16 orderFiled?: string;
17 - orderType?: OrderType 17 + orderType?: OrderType;
18 } 18 }
19 19
20 export class BaseQueryRequest implements BaseQueryParams { 20 export class BaseQueryRequest implements BaseQueryParams {
@@ -23,7 +23,7 @@ export class BaseQueryRequest implements BaseQueryParams { @@ -23,7 +23,7 @@ export class BaseQueryRequest implements BaseQueryParams {
23 page: number; 23 page: number;
24 pageSize: number; 24 pageSize: number;
25 25
26 - constructor(page: number = 1, pageSize: number = 10) { 26 + constructor(page = 1, pageSize = 10) {
27 this.page = page; 27 this.page = page;
28 this.pageSize = pageSize; 28 this.pageSize = pageSize;
29 } 29 }
@@ -41,16 +41,13 @@ export class BaseQueryRequest implements BaseQueryParams { @@ -41,16 +41,13 @@ export class BaseQueryRequest implements BaseQueryParams {
41 } 41 }
42 42
43 setPageSize(pageSize: number) { 43 setPageSize(pageSize: number) {
44 - this.pageSize = pageSize 44 + this.pageSize = pageSize;
45 } 45 }
46 -  
47 } 46 }
48 47
49 export function getPageData<T>(params: BaseQueryParams, url: string): Promise<PageData<T>> { 48 export function getPageData<T>(params: BaseQueryParams, url: string): Promise<PageData<T>> {
50 - return defHttp.get<PageData<T>>(  
51 - {  
52 - params: params,  
53 - url: url  
54 - }  
55 - ); 49 + return defHttp.get<PageData<T>>({
  50 + params: params,
  51 + url: url,
  52 + });
56 } 53 }
1 -import {defHttp} from "/@/utils/http/axios"; 1 +import { defHttp } from '/@/utils/http/axios';
2 import { 2 import {
3 DeviceModel, 3 DeviceModel,
4 DeviceProfileModel, 4 DeviceProfileModel,
5 DeviceProfileQueryParam, 5 DeviceProfileQueryParam,
6 - DeviceQueryParam  
7 -} from "/@/api/device/model/deviceModel"; 6 + DeviceQueryParam,
  7 +} from '/@/api/device/model/deviceModel';
8 8
9 enum DeviceManagerApi { 9 enum DeviceManagerApi {
10 /** 10 /**
11 * 设备URL 11 * 设备URL
12 */ 12 */
13 - DEVICE_URL = "/device", 13 + DEVICE_URL = '/device',
14 /** 14 /**
15 * 设备配置URL 15 * 设备配置URL
16 */ 16 */
17 - DEVICE_PROFILE_URL = "/deviceProfile" 17 + DEVICE_PROFILE_URL = '/deviceProfile',
18 } 18 }
19 19
20 -export const devicePage = (params: DeviceQueryParam) =>{ 20 +export const devicePage = (params: DeviceQueryParam) => {
21 return defHttp.get<DeviceModel>({ 21 return defHttp.get<DeviceModel>({
22 url: DeviceManagerApi.DEVICE_URL, 22 url: DeviceManagerApi.DEVICE_URL,
23 - params 23 + params,
24 }); 24 });
25 -} 25 +};
26 26
27 /** 27 /**
28 * 分页查询设备配置页面 28 * 分页查询设备配置页面
@@ -31,9 +31,9 @@ export const devicePage = (params: DeviceQueryParam) =>{ @@ -31,9 +31,9 @@ export const devicePage = (params: DeviceQueryParam) =>{
31 export const deviceProfilePage = (params: DeviceProfileQueryParam) => { 31 export const deviceProfilePage = (params: DeviceProfileQueryParam) => {
32 return defHttp.get<DeviceProfileModel>({ 32 return defHttp.get<DeviceProfileModel>({
33 url: DeviceManagerApi.DEVICE_PROFILE_URL, 33 url: DeviceManagerApi.DEVICE_PROFILE_URL,
34 - params 34 + params,
35 }); 35 });
36 -} 36 +};
37 /** 37 /**
38 * 删除设备配置 38 * 删除设备配置
39 * @param ids 删除的ids 39 * @param ids 删除的ids
@@ -41,11 +41,11 @@ export const deviceProfilePage = (params: DeviceProfileQueryParam) => { @@ -41,11 +41,11 @@ export const deviceProfilePage = (params: DeviceProfileQueryParam) => {
41 export const deleteDeviceProfile = (ids: string[]) => { 41 export const deleteDeviceProfile = (ids: string[]) => {
42 return defHttp.delete({ 42 return defHttp.delete({
43 url: DeviceManagerApi.DEVICE_PROFILE_URL, 43 url: DeviceManagerApi.DEVICE_PROFILE_URL,
44 - data:{  
45 - ids:ids  
46 - }  
47 - })  
48 -} 44 + data: {
  45 + ids: ids,
  46 + },
  47 + });
  48 +};
49 49
50 /** 50 /**
51 * 删除设备 51 * 删除设备
@@ -54,8 +54,8 @@ export const deleteDeviceProfile = (ids: string[]) => { @@ -54,8 +54,8 @@ export const deleteDeviceProfile = (ids: string[]) => {
54 export const deleteDevice = (ids: string[]) => { 54 export const deleteDevice = (ids: string[]) => {
55 return defHttp.delete({ 55 return defHttp.delete({
56 url: DeviceManagerApi.DEVICE_URL, 56 url: DeviceManagerApi.DEVICE_URL,
57 - data:{  
58 - ids:ids  
59 - }  
60 - })  
61 -} 57 + data: {
  58 + ids: ids,
  59 + },
  60 + });
  61 +};
1 -import {BasicPageParams} from "/@/api/model/baseModel"; 1 +import { BasicPageParams } from '/@/api/model/baseModel';
2 export enum DeviceState { 2 export enum DeviceState {
3 - INACTIVE='INACTIVE',  
4 - ONLINE='ONLINE',  
5 - OFFLINE='OFFLINE' 3 + INACTIVE = 'INACTIVE',
  4 + ONLINE = 'ONLINE',
  5 + OFFLINE = 'OFFLINE',
6 } 6 }
7 -export enum DeviceTypeEnum{  
8 - GATEWAY='GATEWAY',  
9 - DIRECT_CONNECTION='DIRECT_CONNECTION',  
10 - SENSOR='SENSOR' 7 +export enum DeviceTypeEnum {
  8 + GATEWAY = 'GATEWAY',
  9 + DIRECT_CONNECTION = 'DIRECT_CONNECTION',
  10 + SENSOR = 'SENSOR',
11 } 11 }
12 -export type DeviceProfileQueryParam = BasicPageParams & DeviceProfileParam  
13 -export type DeviceQueryParam = BasicPageParams & DeviceParam 12 +export type DeviceProfileQueryParam = BasicPageParams & DeviceProfileParam;
  13 +export type DeviceQueryParam = BasicPageParams & DeviceParam;
14 export type DeviceParam = { 14 export type DeviceParam = {
15 - name?:string,  
16 - deviceProfileId?:string  
17 -} 15 + name?: string;
  16 + deviceProfileId?: string;
  17 +};
18 export type DeviceProfileParam = { 18 export type DeviceProfileParam = {
19 - name?: string  
20 -} 19 + name?: string;
  20 +};
21 21
22 -export interface DeviceModel{  
23 - id:string,  
24 - name:string,  
25 - deviceInfo:any,  
26 - activeTime:string,  
27 - deviceState:DeviceState,  
28 - profileId:string,  
29 - label:string,  
30 - lastConnectTime:string,  
31 - deviceType:DeviceTypeEnum 22 +export interface DeviceModel {
  23 + id: string;
  24 + name: string;
  25 + deviceInfo: any;
  26 + activeTime: string;
  27 + deviceState: DeviceState;
  28 + profileId: string;
  29 + label: string;
  30 + lastConnectTime: string;
  31 + deviceType: DeviceTypeEnum;
32 } 32 }
33 33
34 -export interface DeviceProfileModel{  
35 - id:string,  
36 - name:string,  
37 - transportType:string,  
38 - createTime:string,  
39 - description:string 34 +export interface DeviceProfileModel {
  35 + id: string;
  36 + name: string;
  37 + transportType: string;
  38 + createTime: string;
  39 + description: string;
40 } 40 }
1 import { defHttp } from '/@/utils/http/axios'; 1 import { defHttp } from '/@/utils/http/axios';
2 import { 2 import {
3 MessageConfig, 3 MessageConfig,
4 - MessageConfigParams, MessageConfigResult, 4 + MessageConfigParams,
  5 + MessageConfigResult,
5 MessageConfigResultModel, 6 MessageConfigResultModel,
6 - MessageParams 7 + MessageParams,
7 } from './model/configModel'; 8 } from './model/configModel';
8 9
9 -  
10 enum MessageConfigApi { 10 enum MessageConfigApi {
11 CONFIG_URL = '/message', 11 CONFIG_URL = '/message',
12 } 12 }
@@ -14,13 +14,13 @@ enum MessageConfigApi { @@ -14,13 +14,13 @@ enum MessageConfigApi {
14 /** 14 /**
15 * 获取当前租户下的所有配置 15 * 获取当前租户下的所有配置
16 */ 16 */
17 -export const findMessageConfig=(params: MessageParams)=>{  
18 - console.log(params,"params") 17 +export const findMessageConfig = (params: MessageParams) => {
  18 + console.log(params, 'params');
19 return defHttp.post<MessageConfigResult>({ 19 return defHttp.post<MessageConfigResult>({
20 - url: MessageConfigApi.CONFIG_URL + "/find", 20 + url: MessageConfigApi.CONFIG_URL + '/find',
21 params, 21 params,
22 - })  
23 -} 22 + });
  23 +};
24 24
25 /** 25 /**
26 * @description: 获取MessageConfig分页数据 26 * @description: 获取MessageConfig分页数据
@@ -41,14 +41,14 @@ export const saveOrEditMessageConfig = (params: MessageConfig, isUpdate: boolean @@ -41,14 +41,14 @@ export const saveOrEditMessageConfig = (params: MessageConfig, isUpdate: boolean
41 return defHttp.put<MessageConfigResultModel>({ 41 return defHttp.put<MessageConfigResultModel>({
42 url: MessageConfigApi.CONFIG_URL, 42 url: MessageConfigApi.CONFIG_URL,
43 params, 43 params,
44 - }) 44 + });
45 } else { 45 } else {
46 return defHttp.post<MessageConfigResultModel>({ 46 return defHttp.post<MessageConfigResultModel>({
47 url: MessageConfigApi.CONFIG_URL, 47 url: MessageConfigApi.CONFIG_URL,
48 params, 48 params,
49 - }) 49 + });
50 } 50 }
51 -} 51 +};
52 52
53 /** 53 /**
54 * 更新配置状态 54 * 更新配置状态
@@ -56,15 +56,15 @@ export const saveOrEditMessageConfig = (params: MessageConfig, isUpdate: boolean @@ -56,15 +56,15 @@ export const saveOrEditMessageConfig = (params: MessageConfig, isUpdate: boolean
56 * @param messageType 消息类型 56 * @param messageType 消息类型
57 * @param status 状态 57 * @param status 状态
58 */ 58 */
59 -export const setMessageConfigStatus=(id:string,messageType:string,status:number) => 59 +export const setMessageConfigStatus = (id: string, messageType: string, status: number) =>
60 defHttp.put<MessageConfigResultModel>({ 60 defHttp.put<MessageConfigResultModel>({
61 url: MessageConfigApi.CONFIG_URL, 61 url: MessageConfigApi.CONFIG_URL,
62 - data:{  
63 - "id":id,  
64 - "messageType":messageType,  
65 - "status":status, 62 + data: {
  63 + id: id,
  64 + messageType: messageType,
  65 + status: status,
66 }, 66 },
67 - }) 67 + });
68 /** 68 /**
69 * 删除MessageConfig 69 * 删除MessageConfig
70 * @param ids 删除id数组 70 * @param ids 删除id数组
@@ -73,6 +73,6 @@ export const deleteMessageConfig = (ids: string[]) => @@ -73,6 +73,6 @@ export const deleteMessageConfig = (ids: string[]) =>
73 defHttp.delete({ 73 defHttp.delete({
74 url: MessageConfigApi.CONFIG_URL, 74 url: MessageConfigApi.CONFIG_URL,
75 data: { 75 data: {
76 - ids: ids 76 + ids: ids,
77 }, 77 },
78 - }) 78 + });
1 -import {  
2 - BasicPageParams,  
3 - BasicFetchResult  
4 -} from '/@/api/model/baseModel'; 1 +import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
5 /** 2 /**
6 * @description: Request list interface parameters 3 * @description: Request list interface parameters
7 */ 4 */
8 export type MessageConfigParams = BasicPageParams & MessageParams; 5 export type MessageConfigParams = BasicPageParams & MessageParams;
9 6
10 export type MessageParams = { 7 export type MessageParams = {
11 - status?:number;  
12 - messageType?:string;  
13 -} 8 + status?: number;
  9 + messageType?: string;
  10 +};
14 11
15 export interface MessageConfig { 12 export interface MessageConfig {
16 id: string; 13 id: string;
17 - configName:string; 14 + configName: string;
18 messageType: string; 15 messageType: string;
19 platformType: string; 16 platformType: string;
20 config: ConfigParams; 17 config: ConfigParams;
@@ -22,13 +19,13 @@ export interface MessageConfig { @@ -22,13 +19,13 @@ export interface MessageConfig {
22 updateTime: string; 19 updateTime: string;
23 status: number; 20 status: number;
24 } 21 }
25 -export interface ConfigParams{  
26 - host:string;  
27 - port:number;  
28 - username:string;  
29 - password:string;  
30 - accessKeyId:string;  
31 - accessKeySecret:string; 22 +export interface ConfigParams {
  23 + host: string;
  24 + port: number;
  25 + username: string;
  26 + password: string;
  27 + accessKeyId: string;
  28 + accessKeySecret: string;
32 } 29 }
33 30
34 /** 31 /**
1 -import {BasicFetchResult, BasicPageParams} from "/@/api/model/baseModel"; 1 +import { BasicFetchResult, BasicPageParams } from '/@/api/model/baseModel';
2 2
3 export type MessageRecordsParams = BasicPageParams; 3 export type MessageRecordsParams = BasicPageParams;
4 4
5 -export interface SmsLogModel{  
6 - id?:string 5 +export interface SmsLogModel {
  6 + id?: string;
7 } 7 }
8 -export interface MailLogModel{  
9 - id?:string;  
10 - subject?:string;  
11 - to?:string;  
12 - cc?:string;  
13 - bcc?:string;  
14 - status?:number; 8 +export interface MailLogModel {
  9 + id?: string;
  10 + subject?: string;
  11 + to?: string;
  12 + cc?: string;
  13 + bcc?: string;
  14 + status?: number;
15 } 15 }
16 -export type SmsLogModelResult= BasicFetchResult<SmsLogModel>;  
17 -export type MailLogModelResult= BasicFetchResult<MailLogModel>; 16 +export type SmsLogModelResult = BasicFetchResult<SmsLogModel>;
  17 +export type MailLogModelResult = BasicFetchResult<MailLogModel>;
1 -import {  
2 - BasicPageParams,  
3 - BasicFetchResult, BasicParams  
4 -} from '/@/api/model/baseModel'; 1 +import { BasicPageParams, BasicFetchResult, BasicParams } from '/@/api/model/baseModel';
5 2
6 /** 3 /**
7 * @description: Request list interface parameters 4 * @description: Request list interface parameters
@@ -15,23 +12,23 @@ export interface MessageTemplate { @@ -15,23 +12,23 @@ export interface MessageTemplate {
15 } 12 }
16 13
17 export type SmsParams = { 14 export type SmsParams = {
18 - id?:string;  
19 - phoneNumbers?:string;  
20 - params?:string;  
21 - remark?:string;  
22 - templatePurpose?:string;  
23 -} 15 + id?: string;
  16 + phoneNumbers?: string;
  17 + params?: string;
  18 + remark?: string;
  19 + templatePurpose?: string;
  20 +};
24 export type EmailParams = { 21 export type EmailParams = {
25 - id?:string;  
26 - to?:string[];  
27 - cc?:string[];  
28 - bcc?:string[];  
29 - subject?:string;  
30 - emailFormatEnum?:string;  
31 - templatePurpose?:string;  
32 -} 22 + id?: string;
  23 + to?: string[];
  24 + cc?: string[];
  25 + bcc?: string[];
  26 + subject?: string;
  27 + emailFormatEnum?: string;
  28 + templatePurpose?: string;
  29 +};
33 export interface MessageResult { 30 export interface MessageResult {
34 - result:boolean 31 + result: boolean;
35 } 32 }
36 33
37 /** 34 /**
1 -import {defHttp} from '/@/utils/http/axios'; 1 +import { defHttp } from '/@/utils/http/axios';
2 import { 2 import {
3 MailLogModelResult, 3 MailLogModelResult,
4 MessageRecordsParams, 4 MessageRecordsParams,
5 - SmsLogModelResult  
6 -} from "/@/api/message/model/recordsModel"; 5 + SmsLogModelResult,
  6 +} from '/@/api/message/model/recordsModel';
7 7
8 enum MessageRecordsApi { 8 enum MessageRecordsApi {
9 - SMS_RECORDS = "/smsLog",  
10 - EMAIL_RECORDS = "/mailLog" 9 + SMS_RECORDS = '/smsLog',
  10 + EMAIL_RECORDS = '/mailLog',
11 } 11 }
12 12
13 /** 13 /**
@@ -17,30 +17,30 @@ enum MessageRecordsApi { @@ -17,30 +17,30 @@ enum MessageRecordsApi {
17 export const smsLogPage = (params: MessageRecordsParams) => { 17 export const smsLogPage = (params: MessageRecordsParams) => {
18 return defHttp.get<SmsLogModelResult>({ 18 return defHttp.get<SmsLogModelResult>({
19 url: MessageRecordsApi.SMS_RECORDS, 19 url: MessageRecordsApi.SMS_RECORDS,
20 - params  
21 - })  
22 -} 20 + params,
  21 + });
  22 +};
23 23
24 /** 24 /**
25 * 获取邮件发送记录【分页】 25 * 获取邮件发送记录【分页】
26 * @param params 查询参数 26 * @param params 查询参数
27 */ 27 */
28 -export const mailLogPage=(params:MessageRecordsParams)=>{ 28 +export const mailLogPage = (params: MessageRecordsParams) => {
29 return defHttp.get<MailLogModelResult>({ 29 return defHttp.get<MailLogModelResult>({
30 url: MessageRecordsApi.EMAIL_RECORDS, 30 url: MessageRecordsApi.EMAIL_RECORDS,
31 - params  
32 - })  
33 -} 31 + params,
  32 + });
  33 +};
34 34
35 /** 35 /**
36 * 删除邮件记录 36 * 删除邮件记录
37 * @param ids 邮件记录ID 37 * @param ids 邮件记录ID
38 */ 38 */
39 -export const deleteMailLog =(ids: string[]) => 39 +export const deleteMailLog = (ids: string[]) =>
40 defHttp.delete({ 40 defHttp.delete({
41 url: MessageRecordsApi.EMAIL_RECORDS, 41 url: MessageRecordsApi.EMAIL_RECORDS,
42 data: { 42 data: {
43 - ids: ids 43 + ids: ids,
44 }, 44 },
45 }); 45 });
46 /** 46 /**
@@ -51,6 +51,6 @@ export const deleteSmsLog = (ids: string[]) => @@ -51,6 +51,6 @@ export const deleteSmsLog = (ids: string[]) =>
51 defHttp.delete({ 51 defHttp.delete({
52 url: MessageRecordsApi.SMS_RECORDS, 52 url: MessageRecordsApi.SMS_RECORDS,
53 data: { 53 data: {
54 - ids: ids 54 + ids: ids,
55 }, 55 },
56 }); 56 });
1 import { defHttp } from '/@/utils/http/axios'; 1 import { defHttp } from '/@/utils/http/axios';
2 import { 2 import {
3 - EmailParams, MessageResultModel, 3 + EmailParams,
  4 + MessageResultModel,
4 MessageTemplate, 5 MessageTemplate,
5 MessageTemplateParams, 6 MessageTemplateParams,
6 - MessageTemplateResultModel, SmsParams  
7 -} from "/@/api/message/model/templateModel";  
8 -import {MessageConfigResultModel} from "/@/api/message/model/configModel"; 7 + MessageTemplateResultModel,
  8 + SmsParams,
  9 +} from '/@/api/message/model/templateModel';
  10 +import { MessageConfigResultModel } from '/@/api/message/model/configModel';
9 11
10 enum MessageTemplateApi { 12 enum MessageTemplateApi {
11 TEMPLATE_URL = '/template', 13 TEMPLATE_URL = '/template',
@@ -15,19 +17,19 @@ enum MessageTemplateApi { @@ -15,19 +17,19 @@ enum MessageTemplateApi {
15 * 短信发送 17 * 短信发送
16 * @param params 发送参数 18 * @param params 发送参数
17 */ 19 */
18 -export const sendSms=(params: SmsParams)=>{ 20 +export const sendSms = (params: SmsParams) => {
19 return defHttp.post<MessageResultModel>({ 21 return defHttp.post<MessageResultModel>({
20 - url: MessageTemplateApi.TEMPLATE_URL+"/sendSms", 22 + url: MessageTemplateApi.TEMPLATE_URL + '/sendSms',
21 params, 23 params,
22 - })  
23 -} 24 + });
  25 +};
24 26
25 -export const sendEmail=(params:EmailParams)=>{ 27 +export const sendEmail = (params: EmailParams) => {
26 return defHttp.post<MessageResultModel>({ 28 return defHttp.post<MessageResultModel>({
27 - url: MessageTemplateApi.TEMPLATE_URL+"/sendEmail", 29 + url: MessageTemplateApi.TEMPLATE_URL + '/sendEmail',
28 params, 30 params,
29 - })  
30 -} 31 + });
  32 +};
31 33
32 export const messageTemplatePage = (params: MessageTemplateParams) => 34 export const messageTemplatePage = (params: MessageTemplateParams) =>
33 defHttp.get<MessageTemplateResultModel>({ 35 defHttp.get<MessageTemplateResultModel>({
@@ -35,7 +37,6 @@ export const messageTemplatePage = (params: MessageTemplateParams) => @@ -35,7 +37,6 @@ export const messageTemplatePage = (params: MessageTemplateParams) =>
35 params, 37 params,
36 }); 38 });
37 39
38 -  
39 /** 40 /**
40 * 更新或保存MessageTemplate配置 41 * 更新或保存MessageTemplate配置
41 * @param params 参数 42 * @param params 参数
@@ -46,14 +47,14 @@ export const saveOrEditMessageTemplate = (params: MessageTemplate, isUpdate: boo @@ -46,14 +47,14 @@ export const saveOrEditMessageTemplate = (params: MessageTemplate, isUpdate: boo
46 return defHttp.put<MessageTemplateResultModel>({ 47 return defHttp.put<MessageTemplateResultModel>({
47 url: MessageTemplateApi.TEMPLATE_URL, 48 url: MessageTemplateApi.TEMPLATE_URL,
48 params, 49 params,
49 - }) 50 + });
50 } else { 51 } else {
51 return defHttp.post<MessageTemplateResultModel>({ 52 return defHttp.post<MessageTemplateResultModel>({
52 url: MessageTemplateApi.TEMPLATE_URL, 53 url: MessageTemplateApi.TEMPLATE_URL,
53 params, 54 params,
54 - }) 55 + });
55 } 56 }
56 -} 57 +};
57 58
58 /** 59 /**
59 * 删除MessageConfig 60 * 删除MessageConfig
@@ -63,21 +64,26 @@ export const deleteMessageTemplate = (ids: string[]) => @@ -63,21 +64,26 @@ export const deleteMessageTemplate = (ids: string[]) =>
63 defHttp.delete({ 64 defHttp.delete({
64 url: MessageTemplateApi.TEMPLATE_URL, 65 url: MessageTemplateApi.TEMPLATE_URL,
65 data: { 66 data: {
66 - ids: ids 67 + ids: ids,
67 }, 68 },
68 - }) 69 + });
69 /** 70 /**
70 * 更新模板状态 71 * 更新模板状态
71 * @param id 配置id 72 * @param id 配置id
72 * @param status 状态 73 * @param status 状态
73 */ 74 */
74 -export const setMessageTemplateStatus=(id:string,templatePurpose:string,messageType:string,status:number) => 75 +export const setMessageTemplateStatus = (
  76 + id: string,
  77 + templatePurpose: string,
  78 + messageType: string,
  79 + status: number
  80 +) =>
75 defHttp.put<MessageConfigResultModel>({ 81 defHttp.put<MessageConfigResultModel>({
76 url: MessageTemplateApi.TEMPLATE_URL, 82 url: MessageTemplateApi.TEMPLATE_URL,
77 - data:{  
78 - "id":id,  
79 - "status":status,  
80 - "templatePurpose":templatePurpose,  
81 - "messageType":messageType 83 + data: {
  84 + id: id,
  85 + status: status,
  86 + templatePurpose: templatePurpose,
  87 + messageType: messageType,
82 }, 88 },
83 - }) 89 + });
@@ -3,10 +3,10 @@ export interface BasicPageParams { @@ -3,10 +3,10 @@ export interface BasicPageParams {
3 pageSize: number; 3 pageSize: number;
4 } 4 }
5 5
6 -export interface BasicParams<T extends any>{  
7 - code:number;  
8 - message:string;  
9 - data:T; 6 +export interface BasicParams<T extends any> {
  7 + code: number;
  8 + message: string;
  9 + data: T;
10 } 10 }
11 11
12 export interface BasicFetchResult<T extends any> { 12 export interface BasicFetchResult<T extends any> {
1 -import {defHttp} from "/@/utils/http/axios";  
2 -import {FileUploadResponse} from "/@/api/oss/FileUploadResponse"; 1 +import { defHttp } from '/@/utils/http/axios';
  2 +import { FileUploadResponse } from '/@/api/oss/FileUploadResponse';
3 3
4 enum Api { 4 enum Api {
5 BaseUploadUrl = '/oss/upload', 5 BaseUploadUrl = '/oss/upload',
6 } 6 }
7 7
8 export const upload = (file) => { 8 export const upload = (file) => {
9 - return defHttp.post<FileUploadResponse>({url: Api.BaseUploadUrl, params: file})  
10 -} 9 + return defHttp.post<FileUploadResponse>({ url: Api.BaseUploadUrl, params: file });
  10 +};
1 export interface JwtModel { 1 export interface JwtModel {
2 - userId: string;  
3 - username: string;  
4 - tenantCode: string;  
5 - tenantName: string;  
6 - exp: number;  
7 - role: string[];  
8 - }  
9 -  
  2 + userId: string;
  3 + username: string;
  4 + tenantCode: string;
  5 + tenantName: string;
  6 + exp: number;
  7 + role: string[];
  8 +}
1 -import {defHttp} from '/@/utils/http/axios';  
2 -import {getMenuListResultModel} from './model/menuModel';  
3 -import {useUserStore} from '/@/store/modules/user';  
4 -import {RoleEnum} from '/@/enums/roleEnum'; 1 +import { defHttp } from '/@/utils/http/axios';
  2 +import { getMenuListResultModel } from './model/menuModel';
  3 +import { useUserStore } from '/@/store/modules/user';
  4 +import { RoleEnum } from '/@/enums/roleEnum';
5 5
6 enum Api { 6 enum Api {
7 BaseMenuUrl = '/menu', 7 BaseMenuUrl = '/menu',
8 GetMenuList = '/menu/me/menus', 8 GetMenuList = '/menu/me/menus',
9 SysAdminMenuList = '/admin/me/menus', 9 SysAdminMenuList = '/admin/me/menus',
10 - GetMenuIdsByRoleId = '/menu/getMenuIdsByRoleId/' 10 + GetMenuIdsByRoleId = '/menu/getMenuIdsByRoleId/',
11 } 11 }
12 12
13 /** 13 /**
@@ -17,17 +17,17 @@ enum Api { @@ -17,17 +17,17 @@ enum Api {
17 export const getMenuList = () => { 17 export const getMenuList = () => {
18 const userStore = useUserStore(); 18 const userStore = useUserStore();
19 let url = Api.GetMenuList; 19 let url = Api.GetMenuList;
20 - if (userStore.getRoleList.find(v => v == RoleEnum.ROLE_SYS_ADMIN)) { 20 + if (userStore.getRoleList.find((v) => v == RoleEnum.ROLE_SYS_ADMIN)) {
21 url = Api.SysAdminMenuList; 21 url = Api.SysAdminMenuList;
22 } 22 }
23 - return defHttp.get<getMenuListResultModel>({url: url}); 23 + return defHttp.get<getMenuListResultModel>({ url: url });
24 }; 24 };
25 25
26 export const delMenu = (menuIds: string[]) => { 26 export const delMenu = (menuIds: string[]) => {
27 - let url = Api.BaseMenuUrl;  
28 - return defHttp.delete({url: url, data: menuIds})  
29 -} 27 + const url = Api.BaseMenuUrl;
  28 + return defHttp.delete({ url: url, data: menuIds });
  29 +};
30 export const getMenusIdsByRoleId = (roleId: string) => { 30 export const getMenusIdsByRoleId = (roleId: string) => {
31 - let url = Api.GetMenuIdsByRoleId + roleId;  
32 - return defHttp.get<Array<string>>({url: url});  
33 -} 31 + const url = Api.GetMenuIdsByRoleId + roleId;
  32 + return defHttp.get<Array<string>>({ url: url });
  33 +};
@@ -9,9 +9,9 @@ export interface RouteItem { @@ -9,9 +9,9 @@ export interface RouteItem {
9 redirect?: string; 9 redirect?: string;
10 caseSensitive?: boolean; 10 caseSensitive?: boolean;
11 children?: RouteItem[]; 11 children?: RouteItem[];
12 - menuName?:string;  
13 - icon?:string;  
14 - key?:string; 12 + menuName?: string;
  13 + icon?: string;
  14 + key?: string;
15 } 15 }
16 16
17 /** 17 /**
@@ -42,8 +42,7 @@ export interface GetUserInfoModel { @@ -42,8 +42,7 @@ export interface GetUserInfoModel {
42 // 介绍 42 // 介绍
43 desc?: string; 43 desc?: string;
44 } 44 }
45 - export interface UserInfoModel{  
46 - 45 +export interface UserInfoModel {
47 userId: string | number; 46 userId: string | number;
48 username: string; 47 username: string;
49 realName: string; 48 realName: string;
@@ -52,10 +51,9 @@ export interface GetUserInfoModel { @@ -52,10 +51,9 @@ export interface GetUserInfoModel {
52 tenantName: string; 51 tenantName: string;
53 roles: string[]; 52 roles: string[];
54 plainRoles?: PlainRoleInfo[]; 53 plainRoles?: PlainRoleInfo[];
55 - } 54 +}
56 55
57 - export interface PlainRoleInfo { 56 +export interface PlainRoleInfo {
58 roleName: string; 57 roleName: string;
59 roleId: string; 58 roleId: string;
60 } 59 }
61 -  
@@ -5,7 +5,7 @@ import { @@ -5,7 +5,7 @@ import {
5 GetUserInfoModel, 5 GetUserInfoModel,
6 UserInfoModel, 6 UserInfoModel,
7 RefreshTokenParams, 7 RefreshTokenParams,
8 - SmsLoginParams 8 + SmsLoginParams,
9 } from './model/userModel'; 9 } from './model/userModel';
10 10
11 import { ErrorMessageMode } from '/#/axios'; 11 import { ErrorMessageMode } from '/#/axios';
@@ -18,7 +18,7 @@ enum Api { @@ -18,7 +18,7 @@ enum Api {
18 GetMyInfo = '/user/me/info', 18 GetMyInfo = '/user/me/info',
19 GetPermCode = '/role/me/permissions', 19 GetPermCode = '/role/me/permissions',
20 RefreshToken = '/auth/token', 20 RefreshToken = '/auth/token',
21 - SendLoginSmsCode = '/noauth/sendLoginSmsCode/' 21 + SendLoginSmsCode = '/noauth/sendLoginSmsCode/',
22 } 22 }
23 23
24 /** 24 /**
@@ -35,7 +35,7 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') @@ -35,7 +35,7 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
35 } 35 }
36 ); 36 );
37 } 37 }
38 -export function getMyInfo(){ 38 +export function getMyInfo() {
39 return defHttp.get<UserInfoModel>({ url: Api.GetMyInfo }); 39 return defHttp.get<UserInfoModel>({ url: Api.GetMyInfo });
40 } 40 }
41 /** 41 /**
@@ -48,19 +48,17 @@ export function getUserInfo() { @@ -48,19 +48,17 @@ export function getUserInfo() {
48 export function getPermCode() { 48 export function getPermCode() {
49 return defHttp.get<string[]>({ url: Api.GetPermCode }); 49 return defHttp.get<string[]>({ url: Api.GetPermCode });
50 } 50 }
51 -export async function SendLoginSmsCode(phoneNumber:string){  
52 - return await defHttp.post<boolean>({url:Api.SendLoginSmsCode+phoneNumber}) 51 +export async function SendLoginSmsCode(phoneNumber: string) {
  52 + return await defHttp.post<boolean>({ url: Api.SendLoginSmsCode + phoneNumber });
53 } 53 }
54 export function doLogout() { 54 export function doLogout() {
55 // return defHttp.get({ url: Api.Logout }); 55 // return defHttp.get({ url: Api.Logout });
56 } 56 }
57 -export function doRefreshToken(params:RefreshTokenParams){  
58 - return defHttp.post<LoginResultModel>(  
59 - {  
60 - url: Api.RefreshToken,  
61 - params,  
62 - }  
63 - ); 57 +export function doRefreshToken(params: RefreshTokenParams) {
  58 + return defHttp.post<LoginResultModel>({
  59 + url: Api.RefreshToken,
  60 + params,
  61 + });
64 } 62 }
65 export function smsCodeLoginApi(params: SmsLoginParams, mode: ErrorMessageMode = 'modal') { 63 export function smsCodeLoginApi(params: SmsLoginParams, mode: ErrorMessageMode = 'modal') {
66 return defHttp.post<LoginResultModel>( 64 return defHttp.post<LoginResultModel>(
1 -import {defHttp} from '/@/utils/http/axios'; 1 +import { defHttp } from '/@/utils/http/axios';
2 2
3 -import {DeptListGetResultModel, DeptListItem} from "/@/api/system/model/deptModel";  
4 -  
5 -import {DeptOperationApiResult, DeptOperationParams} from "/@/api/system/model/deptModel";  
6 -import {ErrorMessageMode} from "/#/axios"; 3 +import { DeptListGetResultModel, DeptListItem } from '/@/api/system/model/deptModel';
7 4
  5 +import { DeptOperationApiResult, DeptOperationParams } from '/@/api/system/model/deptModel';
  6 +import { ErrorMessageMode } from '/#/axios';
8 7
9 enum Api { 8 enum Api {
10 DeptList = '/dept/all', 9 DeptList = '/dept/all',
@@ -17,7 +16,11 @@ export const getDeptList = (params?: DeptListItem) => @@ -17,7 +16,11 @@ export const getDeptList = (params?: DeptListItem) =>
17 /** 16 /**
18 * @description: save or edit dept api 17 * @description: save or edit dept api
19 */ 18 */
20 -export function saveOrEditDeptApi(params: DeptOperationParams, update: boolean = false, mode: ErrorMessageMode = 'modal') { 19 +export function saveOrEditDeptApi(
  20 + params: DeptOperationParams,
  21 + update = false,
  22 + mode: ErrorMessageMode = 'modal'
  23 +) {
21 if (!update) { 24 if (!update) {
22 return defHttp.post<DeptOperationApiResult>( 25 return defHttp.post<DeptOperationApiResult>(
23 { 26 {
@@ -29,11 +32,14 @@ export function saveOrEditDeptApi(params: DeptOperationParams, update: boolean = @@ -29,11 +32,14 @@ export function saveOrEditDeptApi(params: DeptOperationParams, update: boolean =
29 } 32 }
30 ); 33 );
31 } else { 34 } else {
32 - return defHttp.put<DeptOperationApiResult>({url: Api.basicUrl, params}, {errorMessageMode: mode}); 35 + return defHttp.put<DeptOperationApiResult>(
  36 + { url: Api.basicUrl, params },
  37 + { errorMessageMode: mode }
  38 + );
33 } 39 }
34 } 40 }
35 41
36 export const delDept = (menuIds: string[]) => { 42 export const delDept = (menuIds: string[]) => {
37 - let url = Api.basicUrl;  
38 - return defHttp.delete({url: url, data: menuIds})  
39 -} 43 + const url = Api.basicUrl;
  44 + return defHttp.delete({ url: url, data: menuIds });
  45 +};
1 -import {defHttp} from '/@/utils/http/axios'; 1 +import { defHttp } from '/@/utils/http/axios';
2 import { 2 import {
3 SysDictItem, 3 SysDictItem,
4 SysDict, 4 SysDict,
5 SysDictParams, 5 SysDictParams,
6 SysDictItemParams, 6 SysDictItemParams,
7 SysDictResultModel, 7 SysDictResultModel,
8 - SysDictItemResultModel, SysDictItemResult, DictCodeParams 8 + SysDictItemResultModel,
  9 + SysDictItemResult,
  10 + DictCodeParams,
9 } from './model/dictModel'; 11 } from './model/dictModel';
10 12
11 -  
12 enum SysDictApi { 13 enum SysDictApi {
13 CONFIG_URL = '/dict', 14 CONFIG_URL = '/dict',
14 - CONFIG_ITEM_URL = '/dictItem' 15 + CONFIG_ITEM_URL = '/dictItem',
15 } 16 }
16 17
17 /** 18 /**
18 * 查找字典值 19 * 查找字典值
19 * @param code 20 * @param code
20 */ 21 */
21 -export const findDictItemByCode=(params? : DictCodeParams)=>  
22 -{ 22 +export const findDictItemByCode = (params?: DictCodeParams) => {
23 return defHttp.post<SysDictItemResult>({ 23 return defHttp.post<SysDictItemResult>({
24 - url: SysDictApi.CONFIG_ITEM_URL + "/find", 24 + url: SysDictApi.CONFIG_ITEM_URL + '/find',
25 params, 25 params,
26 - }) 26 + });
27 }; 27 };
28 28
29 /** 29 /**
@@ -56,14 +56,14 @@ export const saveOrEditDictItem = (params: SysDictItem, isUpdate: boolean) => { @@ -56,14 +56,14 @@ export const saveOrEditDictItem = (params: SysDictItem, isUpdate: boolean) => {
56 return defHttp.put<SysDictItemResultModel>({ 56 return defHttp.put<SysDictItemResultModel>({
57 url: SysDictApi.CONFIG_ITEM_URL, 57 url: SysDictApi.CONFIG_ITEM_URL,
58 params, 58 params,
59 - }) 59 + });
60 } else { 60 } else {
61 return defHttp.post<SysDictItemResultModel>({ 61 return defHttp.post<SysDictItemResultModel>({
62 url: SysDictApi.CONFIG_ITEM_URL, 62 url: SysDictApi.CONFIG_ITEM_URL,
63 params, 63 params,
64 - }) 64 + });
65 } 65 }
66 -} 66 +};
67 67
68 /** 68 /**
69 * 修改DictItem的状态 69 * 修改DictItem的状态
@@ -74,11 +74,11 @@ export const setDictItemStatus = (id: string, status: number) => { @@ -74,11 +74,11 @@ export const setDictItemStatus = (id: string, status: number) => {
74 return defHttp.put<SysDictItemResultModel>({ 74 return defHttp.put<SysDictItemResultModel>({
75 url: SysDictApi.CONFIG_ITEM_URL, 75 url: SysDictApi.CONFIG_ITEM_URL,
76 data: { 76 data: {
77 - "id": id,  
78 - "status": status 77 + id: id,
  78 + status: status,
79 }, 79 },
80 - })  
81 -} 80 + });
  81 +};
82 82
83 /** 83 /**
84 * 保存或更新字典表 84 * 保存或更新字典表
@@ -90,29 +90,32 @@ export const saveOrEditDict = (params: SysDict, isUpdate: boolean) => { @@ -90,29 +90,32 @@ export const saveOrEditDict = (params: SysDict, isUpdate: boolean) => {
90 return defHttp.put<SysDictResultModel>({ 90 return defHttp.put<SysDictResultModel>({
91 url: SysDictApi.CONFIG_URL, 91 url: SysDictApi.CONFIG_URL,
92 params, 92 params,
93 - }) 93 + });
94 } else { 94 } else {
95 return defHttp.post<SysDictResultModel>({ 95 return defHttp.post<SysDictResultModel>({
96 url: SysDictApi.CONFIG_URL, 96 url: SysDictApi.CONFIG_URL,
97 params, 97 params,
98 - }) 98 + });
99 } 99 }
100 -} 100 +};
101 101
102 /** 102 /**
103 * 删除SysDict 103 * 删除SysDict
104 * @param ids 删除id数组 104 * @param ids 删除id数组
105 */ 105 */
106 export const deleteDict = (ids: string[]) => 106 export const deleteDict = (ids: string[]) =>
107 - defHttp.delete({  
108 - url: SysDictApi.CONFIG_URL,  
109 - data: {  
110 - ids: ids 107 + defHttp.delete(
  108 + {
  109 + url: SysDictApi.CONFIG_URL,
  110 + data: {
  111 + ids: ids,
  112 + },
111 }, 113 },
112 - }, {  
113 - errorMessageMode: "message",  
114 - // catchFirst:true  
115 - }) 114 + {
  115 + errorMessageMode: 'message',
  116 + // catchFirst:true
  117 + }
  118 + );
116 /** 119 /**
117 * 删除SysDictItem 120 * 删除SysDictItem
118 * @param ids 删除id数组 121 * @param ids 删除id数组
@@ -121,7 +124,6 @@ export const deleteDictItem = (ids: string[]) => @@ -121,7 +124,6 @@ export const deleteDictItem = (ids: string[]) =>
121 defHttp.delete({ 124 defHttp.delete({
122 url: SysDictApi.CONFIG_ITEM_URL, 125 url: SysDictApi.CONFIG_ITEM_URL,
123 data: { 126 data: {
124 - ids: ids 127 + ids: ids,
125 }, 128 },
126 - })  
127 - 129 + });
1 -import {defHttp} from "/@/utils/http/axios";  
2 -import {GroupListResultModel} from "/@/api/system/model/groupModel"; 1 +import { defHttp } from '/@/utils/http/axios';
  2 +import { GroupListResultModel } from '/@/api/system/model/groupModel';
3 3
4 enum GroupApi { 4 enum GroupApi {
5 - BASE_URL="/organization" 5 + BASE_URL = '/organization',
6 } 6 }
7 7
8 /** 8 /**
9 * 查询当前用户的所属组织 9 * 查询当前用户的所属组织
10 */ 10 */
11 -export const findCurrentUserGroups=()=> 11 +export const findCurrentUserGroups = () =>
12 defHttp.get<GroupListResultModel>({ 12 defHttp.get<GroupListResultModel>({
13 - url: GroupApi.BASE_URL+"/me/organizations", 13 + url: GroupApi.BASE_URL + '/me/organizations',
14 }); 14 });
1 -import {MenuOperationParams, MenuOperationApiResult} from "/@/api/system/model/menuModel";  
2 -import {ErrorMessageMode} from "/#/axios";  
3 -import {defHttp} from "/@/utils/http/axios";  
4 - 1 +import { MenuOperationParams, MenuOperationApiResult } from '/@/api/system/model/menuModel';
  2 +import { ErrorMessageMode } from '/#/axios';
  3 +import { defHttp } from '/@/utils/http/axios';
5 4
6 enum Api { 5 enum Api {
7 Save = '/menu', 6 Save = '/menu',
@@ -10,7 +9,11 @@ enum Api { @@ -10,7 +9,11 @@ enum Api {
10 /** 9 /**
11 * @description: save menu api 10 * @description: save menu api
12 */ 11 */
13 -export function saveMenuApi(params: MenuOperationParams, update: boolean = false, mode: ErrorMessageMode = 'modal') { 12 +export function saveMenuApi(
  13 + params: MenuOperationParams,
  14 + update: boolean = false,
  15 + mode: ErrorMessageMode = 'modal'
  16 +) {
14 console.log(params); 17 console.log(params);
15 if (!update) { 18 if (!update) {
16 return defHttp.post<MenuOperationApiResult>( 19 return defHttp.post<MenuOperationApiResult>(
@@ -23,6 +26,9 @@ export function saveMenuApi(params: MenuOperationParams, update: boolean = false @@ -23,6 +26,9 @@ export function saveMenuApi(params: MenuOperationParams, update: boolean = false
23 } 26 }
24 ); 27 );
25 } else { 28 } else {
26 - return defHttp.put<MenuOperationApiResult>({url: Api.Save, params}, {errorMessageMode: mode}); 29 + return defHttp.put<MenuOperationApiResult>(
  30 + { url: Api.Save, params },
  31 + { errorMessageMode: mode }
  32 + );
27 } 33 }
28 } 34 }
1 -import {BasicFetchResult} from "/@/api/model/baseModel"; 1 +import { BasicFetchResult } from '/@/api/model/baseModel';
2 2
3 export interface DeptOperationParams { 3 export interface DeptOperationParams {
4 id: string; 4 id: string;
@@ -6,18 +6,16 @@ export interface DeptOperationParams { @@ -6,18 +6,16 @@ export interface DeptOperationParams {
6 createTime: string; 6 createTime: string;
7 tenantCode: string; 7 tenantCode: string;
8 parentId?: string; 8 parentId?: string;
9 - orderNo:number;  
10 - status:number; 9 + orderNo: number;
  10 + status: number;
11 remark: string; 11 remark: string;
12 } 12 }
13 13
14 -  
15 export interface DeptOperationApiResult { 14 export interface DeptOperationApiResult {
16 message: string; 15 message: string;
17 code: number; 16 code: number;
18 } 17 }
19 18
20 -  
21 export interface DeptListItem { 19 export interface DeptListItem {
22 id: string; 20 id: string;
23 deptName: string; 21 deptName: string;
1 -import {  
2 - BasicPageParams,  
3 - BasicFetchResult  
4 -} from '/@/api/model/baseModel'; 1 +import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
5 /** 2 /**
6 * @description: Request list interface parameters 3 * @description: Request list interface parameters
7 */ 4 */
8 export type SysDictParams = BasicPageParams & DictParams; 5 export type SysDictParams = BasicPageParams & DictParams;
9 -export type SysDictItemParams = BasicPageParams & DictItemParams; 6 +export type SysDictItemParams = BasicPageParams & DictItemParams;
10 7
11 -export type DictCodeParams={  
12 - dictCode?:string;  
13 -} 8 +export type DictCodeParams = {
  9 + dictCode?: string;
  10 +};
14 11
15 export type DictParams = { 12 export type DictParams = {
16 - dictName?:string;  
17 - dictCode?:string;  
18 -} 13 + dictName?: string;
  14 + dictCode?: string;
  15 +};
19 16
20 export interface SysDict { 17 export interface SysDict {
21 id: string; 18 id: string;
@@ -28,17 +25,17 @@ export interface SysDict { @@ -28,17 +25,17 @@ export interface SysDict {
28 } 25 }
29 26
30 export type DictItemParams = { 27 export type DictItemParams = {
31 - itemText?:string;  
32 - dictId?:string;  
33 -} 28 + itemText?: string;
  29 + dictId?: string;
  30 +};
34 31
35 -export interface SysDictItem{ 32 +export interface SysDictItem {
36 id: string; 33 id: string;
37 - itemText:string;  
38 - itemValue:string;  
39 - description:string;  
40 - sort:number;  
41 - status:number; 34 + itemText: string;
  35 + itemValue: string;
  36 + description: string;
  37 + sort: number;
  38 + status: number;
42 createTime: string; 39 createTime: string;
43 updateTime: string; 40 updateTime: string;
44 } 41 }
@@ -51,4 +48,3 @@ export type SysDictResultModel = BasicFetchResult<SysDict>; @@ -51,4 +48,3 @@ export type SysDictResultModel = BasicFetchResult<SysDict>;
51 export type SysDictItemResultModel = BasicFetchResult<SysDictItem>; 48 export type SysDictItemResultModel = BasicFetchResult<SysDictItem>;
52 49
53 export type SysDictItemResult = SysDictItem; 50 export type SysDictItemResult = SysDictItem;
54 -  
1 -  
2 -export interface GroupItem{  
3 - id:string;  
4 - name:string;  
5 - parentId:string;  
6 - sort:number;  
7 - children?:GroupItem[]; 1 +export interface GroupItem {
  2 + id: string;
  3 + name: string;
  4 + parentId: string;
  5 + sort: number;
  6 + children?: GroupItem[];
8 } 7 }
9 8
10 export type GroupListResultModel = GroupItem[]; 9 export type GroupListResultModel = GroupItem[];
1 -  
2 export interface MenuOperationApiResult { 1 export interface MenuOperationApiResult {
3 message: string; 2 message: string;
4 code: number; 3 code: number;
5 } 4 }
6 5
7 -  
8 export interface MenuOperationParams { 6 export interface MenuOperationParams {
9 path: string; 7 path: string;
10 component: any; 8 component: any;
11 - type:string;  
12 - parentId:string; 9 + type: string;
  10 + parentId: string;
13 meta: metaModel; 11 meta: metaModel;
14 name?: string; 12 name?: string;
15 alias?: string | string[]; 13 alias?: string | string[];
@@ -21,8 +19,8 @@ export interface MenuOperationParams { @@ -21,8 +19,8 @@ export interface MenuOperationParams {
21 export interface metaModel { 19 export interface metaModel {
22 icon: string; 20 icon: string;
23 title: string; 21 title: string;
24 - isLink:boolean;  
25 - menuType:number; 22 + isLink: boolean;
  23 + menuType: number;
26 ignoreKeepAlive?: boolean; 24 ignoreKeepAlive?: boolean;
27 hideMenu: boolean; 25 hideMenu: boolean;
28 status: number; 26 status: number;
1 -import {BasicPageParams, BasicFetchResult} from '/@/api/model/baseModel'; 1 +import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
2 2
3 export type AccountParams = BasicPageParams & { 3 export type AccountParams = BasicPageParams & {
4 account?: string; 4 account?: string;
@@ -6,7 +6,7 @@ export type AccountParams = BasicPageParams & { @@ -6,7 +6,7 @@ export type AccountParams = BasicPageParams & {
6 }; 6 };
7 7
8 export type RoleParams = { 8 export type RoleParams = {
9 - roleType?:string; 9 + roleType?: string;
10 roleName?: string; 10 roleName?: string;
11 status?: string; 11 status?: string;
12 }; 12 };
@@ -30,10 +30,10 @@ export interface AccountListItem { @@ -30,10 +30,10 @@ export interface AccountListItem {
30 email: string; 30 email: string;
31 realName: string; 31 realName: string;
32 roles: any; 32 roles: any;
33 - groupIds:any; 33 + groupIds: any;
34 createTime: string; 34 createTime: string;
35 deptId: string; 35 deptId: string;
36 - accountExpireTime?:string; 36 + accountExpireTime?: string;
37 } 37 }
38 38
39 export interface OrganizationListItem { 39 export interface OrganizationListItem {
@@ -69,16 +69,16 @@ export interface RoleReqDTO { @@ -69,16 +69,16 @@ export interface RoleReqDTO {
69 } 69 }
70 70
71 export interface ChangeAccountParams { 71 export interface ChangeAccountParams {
72 - userId?:string;  
73 - password?:string;  
74 - resetPassword?:string; 72 + userId?: string;
  73 + password?: string;
  74 + resetPassword?: string;
75 } 75 }
76 76
77 export class RoleOrOrganizationParam { 77 export class RoleOrOrganizationParam {
78 - userId:string;  
79 - queryRole:boolean;  
80 - queryOrganization:boolean;  
81 - constructor(userId:string,queryRole:boolean,queryOrganization:boolean){ 78 + userId: string;
  79 + queryRole: boolean;
  80 + queryOrganization: boolean;
  81 + constructor(userId: string, queryRole: boolean, queryOrganization: boolean) {
82 this.queryRole = queryRole; 82 this.queryRole = queryRole;
83 this.queryOrganization = queryOrganization; 83 this.queryOrganization = queryOrganization;
84 this.userId = userId; 84 this.userId = userId;
@@ -99,4 +99,3 @@ export type RolePageListGetResultModel = BasicFetchResult<RoleListItem>; @@ -99,4 +99,3 @@ export type RolePageListGetResultModel = BasicFetchResult<RoleListItem>;
99 export type RoleListGetResultModel = RoleListItem[]; 99 export type RoleListGetResultModel = RoleListItem[];
100 100
101 export type AccountListModel = AccountListItem; 101 export type AccountListModel = AccountListItem;
102 -  
@@ -15,7 +15,7 @@ import { @@ -15,7 +15,7 @@ import {
15 RoleOrOrganizationParam, 15 RoleOrOrganizationParam,
16 ChangeAccountParams, 16 ChangeAccountParams,
17 } from './model/systemModel'; 17 } from './model/systemModel';
18 -import {defHttp} from '/@/utils/http/axios'; 18 +import { defHttp } from '/@/utils/http/axios';
19 19
20 enum Api { 20 enum Api {
21 AccountList = '/user/page', 21 AccountList = '/user/page',
@@ -28,33 +28,34 @@ enum Api { @@ -28,33 +28,34 @@ enum Api {
28 DeleteRole = '/role', 28 DeleteRole = '/role',
29 GetAllRoleList = '/role/find/list', 29 GetAllRoleList = '/role/find/list',
30 BaseUserUrl = '/user', 30 BaseUserUrl = '/user',
31 - BaseOrganization = '/organization' 31 + BaseOrganization = '/organization',
32 } 32 }
33 33
34 -export const getAccountInfo=(userId:string)=>  
35 - defHttp.get<AccountListModel>({url: Api.BaseUserUrl+"/"+userId}) 34 +export const getAccountInfo = (userId: string) =>
  35 + defHttp.get<AccountListModel>({ url: Api.BaseUserUrl + '/' + userId });
36 36
37 export const getAccountList = (params: AccountParams) => 37 export const getAccountList = (params: AccountParams) =>
38 - defHttp.get<AccountListGetResultModel>({url: Api.AccountList, params});  
39 - 38 + defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params });
40 /** 39 /**
41 * 获取组织列表 40 * 获取组织列表
42 * @param params 请求参数 41 * @param params 请求参数
43 */ 42 */
44 export const getOrganizationList = (params?: OrganizationListItem) => 43 export const getOrganizationList = (params?: OrganizationListItem) =>
45 - defHttp.get<OrganizationListGetResultModel>({url: Api.BaseOrganization+'/me/organizations', params}); 44 + defHttp.get<OrganizationListGetResultModel>({
  45 + url: Api.BaseOrganization + '/me/organizations',
  46 + params,
  47 + });
46 48
47 /** 49 /**
48 * 更新或者保存组织 50 * 更新或者保存组织
49 * @param params 51 * @param params
50 * @param isUpdate 52 * @param isUpdate
51 */ 53 */
52 -export const saveOrUpdateOrganization = (params?:OrganizationListItem,isUpdate?:boolean) =>  
53 -{  
54 - if(isUpdate){  
55 - return defHttp.put<OrganizationListGetResultModel>({url: Api.BaseOrganization, params});  
56 - }else{  
57 - return defHttp.post<OrganizationListGetResultModel>({url: Api.BaseOrganization, params}); 54 +export const saveOrUpdateOrganization = (params?: OrganizationListItem, isUpdate?: boolean) => {
  55 + if (isUpdate) {
  56 + return defHttp.put<OrganizationListGetResultModel>({ url: Api.BaseOrganization, params });
  57 + } else {
  58 + return defHttp.post<OrganizationListGetResultModel>({ url: Api.BaseOrganization, params });
58 } 59 }
59 }; 60 };
60 61
@@ -63,32 +64,31 @@ export const saveOrUpdateOrganization = (params?:OrganizationListItem,isUpdate?: @@ -63,32 +64,31 @@ export const saveOrUpdateOrganization = (params?:OrganizationListItem,isUpdate?:
63 * @param ids 删除的ID 64 * @param ids 删除的ID
64 */ 65 */
65 export const delOrganization = (ids: string[]) => 66 export const delOrganization = (ids: string[]) =>
66 - defHttp.delete({url: Api.BaseOrganization, data: ids})  
67 - 67 + defHttp.delete({ url: Api.BaseOrganization, data: ids });
68 68
69 export const getMenuList = (params?: MenuParams) => 69 export const getMenuList = (params?: MenuParams) =>
70 - defHttp.get<MenuListGetResultModel>({url: Api.MenuList, params}); 70 + defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params });
71 71
72 export const getRoleListByPage = (params?: RolePageParams) => 72 export const getRoleListByPage = (params?: RolePageParams) =>
73 - defHttp.get<RolePageListGetResultModel>({url: Api.RolePageList, params});  
74 -export const getTenantRoleListByPage= (params?: RolePageParams) =>  
75 - defHttp.get<RolePageListGetResultModel>({url: Api.RolePageList, params}); 73 + defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });
  74 +export const getTenantRoleListByPage = (params?: RolePageParams) =>
  75 + defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });
76 76
77 export const getAllRoleList = (params?: RoleParams) => 77 export const getAllRoleList = (params?: RoleParams) =>
78 - defHttp.post<RoleListGetResultModel>({url: Api.GetAllRoleList, params}); 78 + defHttp.post<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });
79 79
80 export const setRoleStatus = (id: number, status: number) => 80 export const setRoleStatus = (id: number, status: number) =>
81 - defHttp.put({url: Api.setRoleStatus + id + "/" + status}); 81 + defHttp.put({ url: Api.setRoleStatus + id + '/' + status });
82 export const saveOrUpdateRoleInfoWithMenu = async (roleRequestDto: RoleReqDTO) => { 82 export const saveOrUpdateRoleInfoWithMenu = async (roleRequestDto: RoleReqDTO) => {
83 - await defHttp.post({url: Api.SaveOrUpdateRoleInfoWithMenu, params: roleRequestDto});  
84 -} 83 + await defHttp.post({ url: Api.SaveOrUpdateRoleInfoWithMenu, params: roleRequestDto });
  84 +};
85 85
86 export const isAccountExist = (account: string) => 86 export const isAccountExist = (account: string) =>
87 - defHttp.get({url: Api.IsAccountExist + account}, {errorMessageMode: 'none'}); 87 + defHttp.get({ url: Api.IsAccountExist + account }, { errorMessageMode: 'none' });
88 88
89 export const delRole = async (roleIds: string[]) => { 89 export const delRole = async (roleIds: string[]) => {
90 - await defHttp.delete({url: Api.DeleteRole, params: roleIds});  
91 -} 90 + await defHttp.delete({ url: Api.DeleteRole, params: roleIds });
  91 +};
92 92
93 /** 93 /**
94 * 更新或添加用户信息 94 * 更新或添加用户信息
@@ -96,19 +96,19 @@ export const delRole = async (roleIds: string[]) => { @@ -96,19 +96,19 @@ export const delRole = async (roleIds: string[]) => {
96 * @param isUpdate 96 * @param isUpdate
97 * @constructor 97 * @constructor
98 */ 98 */
99 -export const SaveOrUpdateUserInfo = (params: AccountListItem, isUpdate: boolean)=>{ 99 +export const SaveOrUpdateUserInfo = (params: AccountListItem, isUpdate: boolean) => {
100 if (isUpdate) { 100 if (isUpdate) {
101 return defHttp.put<AccountListModel>({ 101 return defHttp.put<AccountListModel>({
102 url: Api.BaseUserUrl, 102 url: Api.BaseUserUrl,
103 params, 103 params,
104 - }) 104 + });
105 } else { 105 } else {
106 return defHttp.post<AccountListModel>({ 106 return defHttp.post<AccountListModel>({
107 url: Api.BaseUserUrl, 107 url: Api.BaseUserUrl,
108 params, 108 params,
109 - }) 109 + });
110 } 110 }
111 -} 111 +};
112 /** 112 /**
113 * 删除User 113 * 删除User
114 * @param ids 删除id数组 114 * @param ids 删除id数组
@@ -117,26 +117,27 @@ export const deleteUser = (ids: string[]) => @@ -117,26 +117,27 @@ export const deleteUser = (ids: string[]) =>
117 defHttp.delete({ 117 defHttp.delete({
118 url: Api.BaseUserUrl, 118 url: Api.BaseUserUrl,
119 data: { 119 data: {
120 - ids: ids 120 + ids: ids,
121 }, 121 },
122 - }) 122 + });
123 123
124 /** 124 /**
125 * 查询当前用户的关系 125 * 查询当前用户的关系
126 * @param params 126 * @param params
127 */ 127 */
128 -export const findCurrentUserRelation=(params:RoleOrOrganizationParam)=> 128 +
  129 +export const findCurrentUserRelation = (params: RoleOrOrganizationParam) =>
129 defHttp.post<Array<string>>({ 130 defHttp.post<Array<string>>({
130 - url: Api.BaseUserUrl+"/relation",  
131 - params:params 131 + url: Api.BaseUserUrl + '/relation',
  132 + params: params,
132 }); 133 });
133 134
134 /** 135 /**
135 * 修改密码 136 * 修改密码
136 * @param params 137 * @param params
137 */ 138 */
138 -export const resetPassword=(params:ChangeAccountParams)=> 139 +export const resetPassword = (params: ChangeAccountParams) =>
139 defHttp.post({ 140 defHttp.post({
140 - url: Api.BaseUserUrl + "/reset",  
141 - params:params 141 + url: Api.BaseUserUrl + '/reset',
  142 + params: params,
142 }); 143 });
1 -import {getPageData} from '../base'; 1 +import { getPageData } from '../base';
2 import { 2 import {
3 SendResetPasswordEmailMsg, 3 SendResetPasswordEmailMsg,
4 TenantAdminPageRequestParams, 4 TenantAdminPageRequestParams,
5 TenantDTO, 5 TenantDTO,
6 TenantPageRequestParams, 6 TenantPageRequestParams,
7 - TenantRequestDTO, UserDTO 7 + TenantRequestDTO,
  8 + UserDTO,
8 } from './tenantInfo'; 9 } from './tenantInfo';
9 -import {defHttp} from "/@/utils/http/axios"; 10 +import { defHttp } from '/@/utils/http/axios';
10 11
11 enum Api { 12 enum Api {
12 userPage = '/user/page', 13 userPage = '/user/page',
13 tenantPage = '/admin/tenant/page', 14 tenantPage = '/admin/tenant/page',
14 saveTenantAdmin = '/user/saveTenantAdmin', 15 saveTenantAdmin = '/user/saveTenantAdmin',
15 - updateOrCreateTenant = "/admin/tenant/updateOrCreateTenant",  
16 - deleteTenant = "/admin/tenant",  
17 - resetTenantAdminPassword = "/tenant/resetPassword/",  
18 - sendMessageOrEmail = "/tenant/sendRestPasswordMsg", 16 + updateOrCreateTenant = '/admin/tenant/updateOrCreateTenant',
  17 + deleteTenant = '/admin/tenant',
  18 + resetTenantAdminPassword = '/tenant/resetPassword/',
  19 + sendMessageOrEmail = '/tenant/sendRestPasswordMsg',
19 deleteTenantAdmin = '/admin/user/deleteTenantAdmin', 20 deleteTenantAdmin = '/admin/user/deleteTenantAdmin',
20 - getTenantRoles="/admin/tenant/roles/", 21 + getTenantRoles = '/admin/tenant/roles/',
21 } 22 }
22 23
23 export function getTenantPage(params: TenantPageRequestParams) { 24 export function getTenantPage(params: TenantPageRequestParams) {
@@ -29,63 +30,49 @@ export function getTenantAdminPage(params: TenantAdminPageRequestParams) { @@ -29,63 +30,49 @@ export function getTenantAdminPage(params: TenantAdminPageRequestParams) {
29 } 30 }
30 31
31 export async function saveTenantAdmin(params: UserDTO) { 32 export async function saveTenantAdmin(params: UserDTO) {
32 - await defHttp.post(  
33 - {  
34 - params: params,  
35 - url: Api.saveTenantAdmin  
36 - }  
37 - ); 33 + await defHttp.post({
  34 + params: params,
  35 + url: Api.saveTenantAdmin,
  36 + });
38 } 37 }
39 38
40 export async function updateOrCreateTenant(params: TenantRequestDTO) { 39 export async function updateOrCreateTenant(params: TenantRequestDTO) {
41 - await defHttp.post(  
42 - {  
43 - params: params,  
44 - url: Api.updateOrCreateTenant  
45 - }  
46 - ); 40 + await defHttp.post({
  41 + params: params,
  42 + url: Api.updateOrCreateTenant,
  43 + });
47 } 44 }
48 45
49 export async function deleteTenant(tenantIds: Array<string>) { 46 export async function deleteTenant(tenantIds: Array<string>) {
50 - await defHttp.delete(  
51 - {  
52 - data: tenantIds,  
53 - url: Api.deleteTenant  
54 - }  
55 - ); 47 + await defHttp.delete({
  48 + data: tenantIds,
  49 + url: Api.deleteTenant,
  50 + });
56 } 51 }
57 52
58 export async function deleteTenantAdmin(adminIds: Array<string>) { 53 export async function deleteTenantAdmin(adminIds: Array<string>) {
59 - await defHttp.delete(  
60 - {  
61 - data: adminIds,  
62 - url: Api.deleteTenantAdmin  
63 - }  
64 - ); 54 + await defHttp.delete({
  55 + data: adminIds,
  56 + url: Api.deleteTenantAdmin,
  57 + });
65 } 58 }
66 59
67 export async function resetPassword(params: string) { 60 export async function resetPassword(params: string) {
68 - await defHttp.post(  
69 - {  
70 - url: Api.resetTenantAdminPassword + params  
71 - }  
72 - ); 61 + await defHttp.post({
  62 + url: Api.resetTenantAdminPassword + params,
  63 + });
73 } 64 }
74 65
75 export async function sendMessageOrEmail(params: SendResetPasswordEmailMsg) { 66 export async function sendMessageOrEmail(params: SendResetPasswordEmailMsg) {
76 - await defHttp.post(  
77 - {  
78 - params: params,  
79 - url: Api.sendMessageOrEmail  
80 - }  
81 - ); 67 + await defHttp.post({
  68 + params: params,
  69 + url: Api.sendMessageOrEmail,
  70 + });
82 } 71 }
83 72
84 -export function getTenantRoles(tenantCode:string){  
85 - return defHttp.get(  
86 - {  
87 - params:tenantCode,  
88 - url:Api.getTenantRoles  
89 - }  
90 - ); 73 +export function getTenantRoles(tenantCode: string) {
  74 + return defHttp.get({
  75 + params: tenantCode,
  76 + url: Api.getTenantRoles,
  77 + });
91 } 78 }
1 -import {BaseQueryParams, BaseQueryRequest} from "../base"; 1 +import { BaseQueryParams, BaseQueryRequest } from '../base';
2 2
3 export enum TenantStatusEnum { 3 export enum TenantStatusEnum {
4 NORMAL = 'NORMAL', 4 NORMAL = 'NORMAL',
@@ -54,13 +54,13 @@ export interface UserDTO { @@ -54,13 +54,13 @@ export interface UserDTO {
54 accountExpireTime: string; 54 accountExpireTime: string;
55 createTime: string; 55 createTime: string;
56 updateTime: string; 56 updateTime: string;
57 - userStatusEnum: UserStatusEnum 57 + userStatusEnum: UserStatusEnum;
58 hasPassword?: boolean; 58 hasPassword?: boolean;
59 } 59 }
60 60
61 export enum MessageTypeEnum { 61 export enum MessageTypeEnum {
62 EMAIL_MESSAGE = 'EMAIL_MESSAGE', 62 EMAIL_MESSAGE = 'EMAIL_MESSAGE',
63 - PHONE_MESSAGE = 'PHONE_MESSAGE' 63 + PHONE_MESSAGE = 'PHONE_MESSAGE',
64 } 64 }
65 65
66 export class SendResetPasswordEmailMsg { 66 export class SendResetPasswordEmailMsg {
@@ -71,13 +71,12 @@ export class SendResetPasswordEmailMsg { @@ -71,13 +71,12 @@ export class SendResetPasswordEmailMsg {
71 this.userId = userId; 71 this.userId = userId;
72 this.messageTypeEnum = msgType; 72 this.messageTypeEnum = msgType;
73 } 73 }
74 -  
75 } 74 }
76 75
77 export class TenantPageRequest extends BaseQueryRequest { 76 export class TenantPageRequest extends BaseQueryRequest {
78 tenantName: string | undefined; 77 tenantName: string | undefined;
79 78
80 - constructor(page: number = 1, pageSize: number = 10, tenantName?: string) { 79 + constructor(page = 1, pageSize = 10, tenantName?: string) {
81 super(page, pageSize); 80 super(page, pageSize);
82 this.tenantName = tenantName; 81 this.tenantName = tenantName;
83 } 82 }
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <template> 5 <template>
6 <div class="anticon" :class="getAppLogoClass" @click="goHome"> 6 <div class="anticon" :class="getAppLogoClass" @click="goHome">
7 <img src="../../../assets/images/logo.png" /> 7 <img src="../../../assets/images/logo.png" />
8 - <div class="ml-2 md:opacity-100" :class="getTitleClass" v-show="showTitle"> 8 + <div class="ml-2 md:opacity-100" :class="getTitleClass" v-show="showTitle">
9 {{ title }} 9 {{ title }}
10 </div> 10 </div>
11 </div> 11 </div>
@@ -75,7 +75,7 @@ export function useDrawer(): UseDrawerReturnType { @@ -75,7 +75,7 @@ export function useDrawer(): UseDrawerReturnType {
75 75
76 openDrawer: <T = any>(visible = true, data?: T, openOnSet = true): void => { 76 openDrawer: <T = any>(visible = true, data?: T, openOnSet = true): void => {
77 getInstance()?.setDrawerProps({ 77 getInstance()?.setDrawerProps({
78 - visible: visible, 78 + visible,
79 }); 79 });
80 if (!data) return; 80 if (!data) return;
81 81
1 -<template><BasicModal  
2 - width="800px"  
3 - :title="t('component.upload.upload')"  
4 - :okText="t('component.upload.save')"  
5 - v-bind="$attrs"  
6 - @register="register"  
7 - @ok="handleOk"  
8 - :closeFunc="handleCloseFunc"  
9 - :maskClosable="false"  
10 - :keyboard="false"  
11 - wrapClassName="upload-modal"  
12 - :okButtonProps="getOkButtonProps"  
13 - :cancelButtonProps="{ disabled: isUploadingRef }"  
14 ->  
15 - 1 +<template
  2 + ><BasicModal
  3 + width="800px"
  4 + :title="t('component.upload.upload')"
  5 + :okText="t('component.upload.save')"
  6 + v-bind="$attrs"
  7 + @register="register"
  8 + @ok="handleOk"
  9 + :closeFunc="handleCloseFunc"
  10 + :maskClosable="false"
  11 + :keyboard="false"
  12 + wrapClassName="upload-modal"
  13 + :okButtonProps="getOkButtonProps"
  14 + :cancelButtonProps="{ disabled: isUploadingRef }"
  15 + >
16 <template #centerFooter> 16 <template #centerFooter>
17 <a-button 17 <a-button
18 @click="handleStartUpload" 18 @click="handleStartUpload"
@@ -27,5 +27,4 @@ const repeatDirective: Directive = { @@ -27,5 +27,4 @@ const repeatDirective: Directive = {
27 }); 27 });
28 }, 28 },
29 }; 29 };
30 -  
31 export default repeatDirective; 30 export default repeatDirective;
1 -export enum TenantCodeEnum{  
2 - SYS_ADMIN_CODE="DEFAULT_SYS_ADMIN_TENANT_CODE" 1 +export enum TenantCodeEnum {
  2 + SYS_ADMIN_CODE = 'DEFAULT_SYS_ADMIN_TENANT_CODE',
3 } 3 }
1 export enum MessageEnum { 1 export enum MessageEnum {
2 - IS_SMS="PHONE_MESSAGE",  
3 - IS_EMAIL="EMAIL_MESSAGE", 2 + IS_SMS = 'PHONE_MESSAGE',
  3 + IS_EMAIL = 'EMAIL_MESSAGE',
4 } 4 }
@@ -10,5 +10,5 @@ export enum PageEnum { @@ -10,5 +10,5 @@ export enum PageEnum {
10 //消息配置 10 //消息配置
11 MESSAGE_CONFIG = '/config/message', 11 MESSAGE_CONFIG = '/config/message',
12 //设备配置 12 //设备配置
13 - DEVICE_PROFILE = '/deviceManager/deviceProfile' 13 + DEVICE_PROFILE = '/deviceManager/deviceProfile',
14 } 14 }
1 -export enum InputRegExp{ 1 +export enum InputRegExp {
2 /** 2 /**
3 * 密码中必须包含大小写 字母、数字、特称字符,至少8个字符,最多30个字符; 3 * 密码中必须包含大小写 字母、数字、特称字符,至少8个字符,最多30个字符;
4 */ 4 */
5 - PASSWORD_INPUT='(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9]).{8,30}' 5 + PASSWORD_INPUT = '(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9]).{8,30}',
6 } 6 }
1 export enum RoleEnum { 1 export enum RoleEnum {
2 - ROLE_SYS_ADMIN = "ROLE_SYS_ADMIN",  
3 - ROLE_TENANT_ADMIN = "ROLE_TENANT_ADMIN",  
4 - ROLE_NORMAL_USER = "ROLE_NORMAL_USER",  
5 - ROLE_PLATFORM_ADMIN="ROLE_PLATFORM_ADMIN" 2 + ROLE_SYS_ADMIN = 'ROLE_SYS_ADMIN',
  3 + ROLE_TENANT_ADMIN = 'ROLE_TENANT_ADMIN',
  4 + ROLE_NORMAL_USER = 'ROLE_NORMAL_USER',
  5 + ROLE_PLATFORM_ADMIN = 'ROLE_PLATFORM_ADMIN',
6 } 6 }
  1 +export function useChildrenIdsRemoveParentId(str, arr) {
  2 + const index = arr.indexOf(str);
  3 + arr.splice(index, 1);
  4 + return arr;
  5 +}
1 export default { 1 export default {
2 - common:{  
3 - createTime:"create time",  
4 - updateTime:"update time",  
5 - operation:"operation",  
6 - remark:"remark",  
7 - enable:"enable",  
8 - disable:"disable",  
9 - sort:"sort",  
10 - status:"status", 2 + common: {
  3 + createTime: 'create time',
  4 + updateTime: 'update time',
  5 + operation: 'operation',
  6 + remark: 'remark',
  7 + enable: 'enable',
  8 + disable: 'disable',
  9 + sort: 'sort',
  10 + status: 'status',
11 }, 11 },
12 - tenant:{  
13 - tenant:"tenant",  
14 - tenantManagement:"tenant management",  
15 - tenantSetting:"tenant setting"  
16 - },  
17 - organization:{  
18 - queryOrganizationName:"organization name",  
19 - toolOrganizationList:"organization list",  
20 - toolCreateOrganization:"create organization",  
21 - toolEditOrganization:"edit organization",  
22 - parentOrganization:"parent organization", 12 + tenant: {
  13 + tenant: 'tenant',
  14 + tenantManagement: 'tenant management',
  15 + tenantSetting: 'tenant setting',
23 }, 16 },
24 - dept:{  
25 - queryDeptName:"dept name",  
26 - queryDeptStatus:"status",  
27 - toolDeptList:"dept list",  
28 - toolCreateDept:"create dept",  
29 - toolEditDept:"edit dept",  
30 - tableTitleDeptSort:"sort",  
31 - tableTitleDeptCreateTime:"create time",  
32 - tableTitleDeptOperation:"operation",  
33 - drawerTitleDeptEnable:"enable",  
34 - drawerTitleDeptDisable:"disable",  
35 - drawerTitleDeptParentDept:"parent dept",  
36 - tableTitleMemo:"memo" 17 + organization: {
  18 + queryOrganizationName: 'organization name',
  19 + toolOrganizationList: 'organization list',
  20 + toolCreateOrganization: 'create organization',
  21 + toolEditOrganization: 'edit organization',
  22 + parentOrganization: 'parent organization',
37 }, 23 },
38 - system:{  
39 - system:"system",  
40 - accountManagement:"account management",  
41 - roleManagement:"role management",  
42 - menuManagement:"menu management",  
43 - deptManagement:"dept management",  
44 - modifyPassword:"modify password",  
45 - pageSystemTitleCreateMenu:"create menu",  
46 - pageSystemTitleCreateTenant:"new tenant",  
47 - pageSystemTitleEditMenu:"edit menu",  
48 - pageSystemTitleEditTenant:"edit tenant",  
49 - pageSystemTitleOperation:"operation",  
50 - pageSystemTitleWhetherDelete:"Are you sure to delete",  
51 - pageSystemTitleMenuList:"menu list",  
52 - menuEditPagesMenuType:"menu type",  
53 - menuEditPagesDirectory:"directory",  
54 - menuEditPagesMenu:"menu",  
55 - menuEditPagesButton:"button",  
56 - menuEditPagesParentMenu:"parent menu",  
57 - menuEditPagesRouterAddress:"router address",  
58 - menuEditPagesComponentsPath:"components",  
59 - menuEditPagesIsExt:"is ext",  
60 - menuEditPagesIsKeepAlive:"is keep alive",  
61 - menuEditPagesIsHide:"is hide",  
62 - menuEditPagesYes:"yes",  
63 - menuEditPagesNo:"no",  
64 - tableTitleSystemMenuName:"menu name",  
65 - tableTitleSystemIcon:"icon",  
66 - tableTitleSystemPermissionTag:"permission tag",  
67 - tableTitleSystemComponents:"components",  
68 - tableTitleSystemSort:"sort",  
69 - tableTitleSystemStatus:"status",  
70 - tableTitleSystemCreateTime:"create time",  
71 - tableTitleSystemEnable:"enable",  
72 - tableTitleSystemStop:"disable",  
73 - tableSuccessStatus:"success",  
74 - tableFailedStatus:"failed",  
75 - }  
76 - }; 24 + dept: {
  25 + queryDeptName: 'dept name',
  26 + queryDeptStatus: 'status',
  27 + toolDeptList: 'dept list',
  28 + toolCreateDept: 'create dept',
  29 + toolEditDept: 'edit dept',
  30 + tableTitleDeptSort: 'sort',
  31 + tableTitleDeptCreateTime: 'create time',
  32 + tableTitleDeptOperation: 'operation',
  33 + drawerTitleDeptEnable: 'enable',
  34 + drawerTitleDeptDisable: 'disable',
  35 + drawerTitleDeptParentDept: 'parent dept',
  36 + tableTitleMemo: 'memo',
  37 + },
  38 + system: {
  39 + system: 'system',
  40 + accountManagement: 'account management',
  41 + roleManagement: 'role management',
  42 + menuManagement: 'menu management',
  43 + deptManagement: 'dept management',
  44 + modifyPassword: 'modify password',
  45 + pageSystemTitleCreateMenu: 'create menu',
  46 + pageSystemTitleCreateTenant: 'new tenant',
  47 + pageSystemTitleEditMenu: 'edit menu',
  48 + pageSystemTitleEditTenant: 'edit tenant',
  49 + pageSystemTitleOperation: 'operation',
  50 + pageSystemTitleWhetherDelete: 'Are you sure to delete',
  51 + pageSystemTitleMenuList: 'menu list',
  52 + menuEditPagesMenuType: 'menu type',
  53 + menuEditPagesDirectory: 'directory',
  54 + menuEditPagesMenu: 'menu',
  55 + menuEditPagesButton: 'button',
  56 + menuEditPagesParentMenu: 'parent menu',
  57 + menuEditPagesRouterAddress: 'router address',
  58 + menuEditPagesComponentsPath: 'components',
  59 + menuEditPagesIsExt: 'is ext',
  60 + menuEditPagesIsKeepAlive: 'is keep alive',
  61 + menuEditPagesIsHide: 'is hide',
  62 + menuEditPagesYes: 'yes',
  63 + menuEditPagesNo: 'no',
  64 + tableTitleSystemMenuName: 'menu name',
  65 + tableTitleSystemIcon: 'icon',
  66 + tableTitleSystemPermissionTag: 'permission tag',
  67 + tableTitleSystemComponents: 'components',
  68 + tableTitleSystemSort: 'sort',
  69 + tableTitleSystemStatus: 'status',
  70 + tableTitleSystemCreateTime: 'create time',
  71 + tableTitleSystemEnable: 'enable',
  72 + tableTitleSystemStop: 'disable',
  73 + tableSuccessStatus: 'success',
  74 + tableFailedStatus: 'failed',
  75 + },
  76 +};
@@ -2,7 +2,7 @@ export default { @@ -2,7 +2,7 @@ export default {
2 api: { 2 api: {
3 operationFailed: 'Operation failed', 3 operationFailed: 'Operation failed',
4 errorTip: 'Error Tip', 4 errorTip: 'Error Tip',
5 - passwordOrUserNameError:'username or password not correct', 5 + passwordOrUserNameError: 'username or password not correct',
6 loginFailed: 'Login Failed', 6 loginFailed: 'Login Failed',
7 errorMessage: 'The operation failed, the system is abnormal!', 7 errorMessage: 'The operation failed, the system is abnormal!',
8 timeoutMessage: 'Login timed out, please log in again!', 8 timeoutMessage: 'Login timed out, please log in again!',
1 export default { 1 export default {
2 - common:{  
3 - createTime:"创建时间",  
4 - updateTime:"更新时间",  
5 - operation:"操作",  
6 - remark:"备注",  
7 - enable:"启用",  
8 - disable:"禁用",  
9 - sort:"排序",  
10 - status:"状态"  
11 - },  
12 - tenant:{  
13 - tenant:"租户",  
14 - tenantManagement:"租户管理",  
15 - tenantSetting:"租户设置"  
16 - },  
17 - organization:{  
18 - queryOrganizationName:"组织名称",  
19 - toolOrganizationList:"组织列表",  
20 - toolCreateOrganization:"新增组织",  
21 - toolEditOrganization:"编辑组织",  
22 - parentOrganization:"上级组织", 2 + common: {
  3 + createTime: '创建时间',
  4 + updateTime: '更新时间',
  5 + operation: '操作',
  6 + remark: '备注',
  7 + enable: '启用',
  8 + disable: '禁用',
  9 + sort: '排序',
  10 + status: '状态',
23 }, 11 },
24 - dept:{  
25 - queryDeptName:"部门名称",  
26 - queryDeptStatus:"状态",  
27 - toolDeptList:"部门列表",  
28 - toolCreateDept:"新增部门",  
29 - toolEditDept:"编辑部门",  
30 - tableTitleDeptSort:"排序",  
31 - tableTitleDeptCreateTime:"创建时间",  
32 - tableTitleDeptOperation:"操作",  
33 - drawerTitleDeptEnable:"启用",  
34 - drawerTitleDeptDisable:"停用",  
35 - drawerTitleDeptParentDept:"上级部门",  
36 - tableTitleMemo:"备注" 12 + tenant: {
  13 + tenant: '租户',
  14 + tenantManagement: '租户管理',
  15 + tenantSetting: '租户设置',
37 }, 16 },
38 - system:{  
39 - system:"系统管理",  
40 - accountManagement:"账号管理",  
41 - roleManagement:"角色管理",  
42 - menuManagement:"菜单管理",  
43 - deptManagement:"部门管理",  
44 - modifyPassword:"修改密码",  
45 - pageSystemTitleCreateMenu:"新增菜单",  
46 - pageSystemTitleCreateTenant:"新增租户",  
47 - pageSystemTitleEditMenu:"编辑菜单",  
48 - pageSystemTitleEditTenant:"编辑租户",  
49 - pageSystemTitleOperation:"操作",  
50 - pageSystemTitleWhetherDelete:"是否确认删除",  
51 - pageSystemTitleMenuList:"菜单列表",  
52 - menuEditPagesMenuType:"菜单类型",  
53 - menuEditPagesDirectory:"目录",  
54 - menuEditPagesMenu:"菜单",  
55 - menuEditPagesButton:"按钮",  
56 - menuEditPagesParentMenu:"上级菜单",  
57 - menuEditPagesRouterAddress:"路由地址",  
58 - menuEditPagesComponentsPath:"组件路径",  
59 - menuEditPagesIsExt:"是否外链",  
60 - menuEditPagesIsKeepAlive:"是否缓存",  
61 - menuEditPagesIsHide:"是否隐藏",  
62 - menuEditPagesYes:"是",  
63 - menuEditPagesNo:"否",  
64 - tableTitleSystemMenuName:"菜单名称",  
65 - tableTitleSystemIcon:"图标",  
66 - tableTitleSystemPermissionTag:"权限标识",  
67 - tableTitleSystemComponents:"组件",  
68 - tableTitleSystemSort:"排序",  
69 - tableTitleSystemStatus:"状态",  
70 - tableTitleSystemCreateTime:"创建时间",  
71 - tableTitleSystemEnable:"启用",  
72 - tableTitleSystemStop:"停用",  
73 - tableSuccessStatus:"成功",  
74 - tableFailedStatus:"失败",  
75 - }  
76 - }; 17 + organization: {
  18 + queryOrganizationName: '组织名称',
  19 + toolOrganizationList: '组织列表',
  20 + toolCreateOrganization: '新增组织',
  21 + toolEditOrganization: '编辑组织',
  22 + parentOrganization: '上级组织',
  23 + },
  24 + dept: {
  25 + queryDeptName: '部门名称',
  26 + queryDeptStatus: '状态',
  27 + toolDeptList: '部门列表',
  28 + toolCreateDept: '新增部门',
  29 + toolEditDept: '编辑部门',
  30 + tableTitleDeptSort: '排序',
  31 + tableTitleDeptCreateTime: '创建时间',
  32 + tableTitleDeptOperation: '操作',
  33 + drawerTitleDeptEnable: '启用',
  34 + drawerTitleDeptDisable: '停用',
  35 + drawerTitleDeptParentDept: '上级部门',
  36 + tableTitleMemo: '备注',
  37 + },
  38 + system: {
  39 + system: '系统管理',
  40 + accountManagement: '账号管理',
  41 + roleManagement: '角色管理',
  42 + menuManagement: '菜单管理',
  43 + deptManagement: '部门管理',
  44 + modifyPassword: '修改密码',
  45 + pageSystemTitleCreateMenu: '新增菜单',
  46 + pageSystemTitleCreateTenant: '新增租户',
  47 + pageSystemTitleEditMenu: '编辑菜单',
  48 + pageSystemTitleEditTenant: '编辑租户',
  49 + pageSystemTitleOperation: '操作',
  50 + pageSystemTitleWhetherDelete: '是否确认删除',
  51 + pageSystemTitleMenuList: '菜单列表',
  52 + menuEditPagesMenuType: '菜单类型',
  53 + menuEditPagesDirectory: '目录',
  54 + menuEditPagesMenu: '菜单',
  55 + menuEditPagesButton: '按钮',
  56 + menuEditPagesParentMenu: '上级菜单',
  57 + menuEditPagesRouterAddress: '路由地址',
  58 + menuEditPagesComponentsPath: '组件路径',
  59 + menuEditPagesIsExt: '是否外链',
  60 + menuEditPagesIsKeepAlive: '是否缓存',
  61 + menuEditPagesIsHide: '是否隐藏',
  62 + menuEditPagesYes: '是',
  63 + menuEditPagesNo: '否',
  64 + tableTitleSystemMenuName: '菜单名称',
  65 + tableTitleSystemIcon: '图标',
  66 + tableTitleSystemPermissionTag: '权限标识',
  67 + tableTitleSystemComponents: '组件',
  68 + tableTitleSystemSort: '排序',
  69 + tableTitleSystemStatus: '状态',
  70 + tableTitleSystemCreateTime: '创建时间',
  71 + tableTitleSystemEnable: '启用',
  72 + tableTitleSystemStop: '停用',
  73 + tableSuccessStatus: '成功',
  74 + tableFailedStatus: '失败',
  75 + },
  76 +};
@@ -2,7 +2,7 @@ export default { @@ -2,7 +2,7 @@ export default {
2 api: { 2 api: {
3 operationFailed: '操作失败', 3 operationFailed: '操作失败',
4 errorTip: '错误提示', 4 errorTip: '错误提示',
5 - passwordOrUserNameError:'用户名或密码不正确', 5 + passwordOrUserNameError: '用户名或密码不正确',
6 loginFailed: '登录失败', 6 loginFailed: '登录失败',
7 errorMessage: '操作失败,系统异常!', 7 errorMessage: '操作失败,系统异常!',
8 timeoutMessage: '登录超时,请重新登录!', 8 timeoutMessage: '登录超时,请重新登录!',
@@ -63,9 +63,9 @@ export function initAppConfigStore() { @@ -63,9 +63,9 @@ export function initAppConfigStore() {
63 // init store 63 // init store
64 localeStore.initLocale(); 64 localeStore.initLocale();
65 65
66 - const userInfo = Persistent.getLocal(USER_INFO_KEY) as UserInfo 66 + const userInfo = Persistent.getLocal(USER_INFO_KEY) as UserInfo;
67 const userStore = useUserStore(); 67 const userStore = useUserStore();
68 - if(userInfo){ 68 + if (userInfo) {
69 userStore.setUserInfo(userInfo); 69 userStore.setUserInfo(userInfo);
70 userStore.jwtToken = Persistent.getLocal(JWT_TOKEN_KEY) as string; 70 userStore.jwtToken = Persistent.getLocal(JWT_TOKEN_KEY) as string;
71 userStore.refreshToken = Persistent.getLocal(REFRESH_TOKEN_KEY) as string; 71 userStore.refreshToken = Persistent.getLocal(REFRESH_TOKEN_KEY) as string;
@@ -26,6 +26,9 @@ if (import.meta.env.DEV) { @@ -26,6 +26,9 @@ if (import.meta.env.DEV) {
26 async function bootstrap() { 26 async function bootstrap() {
27 const app = createApp(App); 27 const app = createApp(App);
28 28
  29 + // app.use(VueBaidu, {
  30 + // ak: '7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa',
  31 + // });
29 // Configure store 32 // Configure store
30 setupStore(app); 33 setupStore(app);
31 34
@@ -188,7 +188,7 @@ export const usePermissionStore = defineStore({ @@ -188,7 +188,7 @@ export const usePermissionStore = defineStore({
188 routeList = (await getMenuList()) as AppRouteRecordRaw[]; 188 routeList = (await getMenuList()) as AppRouteRecordRaw[];
189 } catch (error) { 189 } catch (error) {
190 console.error(error); 190 console.error(error);
191 - } // Dynamically introduce components 191 + } // Dynamically introduce components
192 routeList = transformObjToRoute(routeList); 192 routeList = transformObjToRoute(routeList);
193 193
194 // Background routing to menu structure 194 // Background routing to menu structure
@@ -4,15 +4,21 @@ import { defineStore } from 'pinia'; @@ -4,15 +4,21 @@ import { defineStore } from 'pinia';
4 import { store } from '/@/store'; 4 import { store } from '/@/store';
5 import { RoleEnum } from '/@/enums/roleEnum'; 5 import { RoleEnum } from '/@/enums/roleEnum';
6 import { PageEnum } from '/@/enums/pageEnum'; 6 import { PageEnum } from '/@/enums/pageEnum';
7 -import { JWT_TOKEN_KEY, REFRESH_TOKEN_KEY, ROLES_KEY, TOKEN_KEY, USER_INFO_KEY } from '/@/enums/cacheEnum'; 7 +import {
  8 + JWT_TOKEN_KEY,
  9 + REFRESH_TOKEN_KEY,
  10 + ROLES_KEY,
  11 + TOKEN_KEY,
  12 + USER_INFO_KEY,
  13 +} from '/@/enums/cacheEnum';
8 import { getAuthCache, setAuthCache } from '/@/utils/auth'; 14 import { getAuthCache, setAuthCache } from '/@/utils/auth';
9 import { 15 import {
10 LoginParams, 16 LoginParams,
11 LoginResultModel, 17 LoginResultModel,
12 RefreshTokenParams, 18 RefreshTokenParams,
13 - SmsLoginParams 19 + SmsLoginParams,
14 } from '/@/api/sys/model/userModel'; 20 } from '/@/api/sys/model/userModel';
15 -import {doRefreshToken, getMyInfo, loginApi, smsCodeLoginApi} from '/@/api/sys/user'; 21 +import { doRefreshToken, getMyInfo, loginApi, smsCodeLoginApi } from '/@/api/sys/user';
16 import { useI18n } from '/@/hooks/web/useI18n'; 22 import { useI18n } from '/@/hooks/web/useI18n';
17 import { useMessage } from '/@/hooks/web/useMessage'; 23 import { useMessage } from '/@/hooks/web/useMessage';
18 import { router } from '/@/router'; 24 import { router } from '/@/router';
@@ -26,8 +32,8 @@ interface UserState { @@ -26,8 +32,8 @@ interface UserState {
26 roleList: RoleEnum[]; 32 roleList: RoleEnum[];
27 sessionTimeout?: boolean; 33 sessionTimeout?: boolean;
28 lastUpdateTime: number; 34 lastUpdateTime: number;
29 - jwtToken?:string;  
30 - refreshToken?:string; 35 + jwtToken?: string;
  36 + refreshToken?: string;
31 } 37 }
32 38
33 export const useUserStore = defineStore({ 39 export const useUserStore = defineStore({
@@ -38,7 +44,7 @@ export const useUserStore = defineStore({ @@ -38,7 +44,7 @@ export const useUserStore = defineStore({
38 // token 44 // token
39 jwtToken: undefined, 45 jwtToken: undefined,
40 //refresh Token 46 //refresh Token
41 - refreshToken:undefined, 47 + refreshToken: undefined,
42 // roleList 48 // roleList
43 roleList: [], 49 roleList: [],
44 // Whether the login expired 50 // Whether the login expired
@@ -67,11 +73,11 @@ export const useUserStore = defineStore({ @@ -67,11 +73,11 @@ export const useUserStore = defineStore({
67 }, 73 },
68 }, 74 },
69 actions: { 75 actions: {
70 - storeToken(jwtToken:string,refreshToken:string){ 76 + storeToken(jwtToken: string, refreshToken: string) {
71 this.jwtToken = jwtToken; 77 this.jwtToken = jwtToken;
72 this.refreshToken = refreshToken; 78 this.refreshToken = refreshToken;
73 - setAuthCache(JWT_TOKEN_KEY,jwtToken);  
74 - setAuthCache(REFRESH_TOKEN_KEY,refreshToken); 79 + setAuthCache(JWT_TOKEN_KEY, jwtToken);
  80 + setAuthCache(REFRESH_TOKEN_KEY, refreshToken);
75 }, 81 },
76 setToken(info: string | undefined) { 82 setToken(info: string | undefined) {
77 this.token = info; 83 this.token = info;
@@ -107,34 +113,34 @@ export const useUserStore = defineStore({ @@ -107,34 +113,34 @@ export const useUserStore = defineStore({
107 try { 113 try {
108 const { goHome = true, mode, ...loginParams } = params; 114 const { goHome = true, mode, ...loginParams } = params;
109 const data = await loginApi(loginParams, mode); 115 const data = await loginApi(loginParams, mode);
110 - return this.process(data,goHome); 116 + return this.process(data, goHome);
111 } catch (error) { 117 } catch (error) {
112 return Promise.reject(error); 118 return Promise.reject(error);
113 } 119 }
114 }, 120 },
115 - async process(data: LoginResultModel, goHome?: boolean): Promise<UserInfo | null> {  
116 - const {token, refreshToken} = data;  
117 - this.storeToken(token, refreshToken);  
118 - // get user info  
119 - const userInfo = await this.getMyUserInfoAction(); 121 + async process(data: LoginResultModel, goHome?: boolean): Promise<UserInfo | null> {
  122 + const { token, refreshToken } = data;
  123 + this.storeToken(token, refreshToken);
  124 + // get user info
  125 + const userInfo = await this.getMyUserInfoAction();
120 126
121 - const sessionTimeout = this.sessionTimeout;  
122 - if (sessionTimeout) {  
123 - this.setSessionTimeout(false);  
124 - } else if (goHome) {  
125 - const permissionStore = usePermissionStore();  
126 - if (!permissionStore.isDynamicAddedRoute) {  
127 - const routes = await permissionStore.buildRoutesAction();  
128 - routes.forEach((route) => {  
129 - router.addRoute(route as unknown as RouteRecordRaw);  
130 - });  
131 - router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw);  
132 - permissionStore.setDynamicAddedRoute(true);  
133 - }  
134 - await router.replace(userInfo.homePath || PageEnum.BASE_HOME);  
135 - }  
136 - return userInfo;  
137 - }, 127 + const sessionTimeout = this.sessionTimeout;
  128 + if (sessionTimeout) {
  129 + this.setSessionTimeout(false);
  130 + } else if (goHome) {
  131 + const permissionStore = usePermissionStore();
  132 + if (!permissionStore.isDynamicAddedRoute) {
  133 + const routes = await permissionStore.buildRoutesAction();
  134 + routes.forEach((route) => {
  135 + router.addRoute(route as unknown as RouteRecordRaw);
  136 + });
  137 + router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw);
  138 + permissionStore.setDynamicAddedRoute(true);
  139 + }
  140 + await router.replace(userInfo.homePath || PageEnum.BASE_HOME);
  141 + }
  142 + return userInfo;
  143 + },
138 async smsCodelogin( 144 async smsCodelogin(
139 params: SmsLoginParams & { 145 params: SmsLoginParams & {
140 goHome?: boolean; 146 goHome?: boolean;
@@ -144,7 +150,7 @@ export const useUserStore = defineStore({ @@ -144,7 +150,7 @@ export const useUserStore = defineStore({
144 try { 150 try {
145 const { goHome = true, mode, ...loginParams } = params; 151 const { goHome = true, mode, ...loginParams } = params;
146 const data = await smsCodeLoginApi(loginParams, mode); 152 const data = await smsCodeLoginApi(loginParams, mode);
147 - return this.process(data,goHome); 153 + return this.process(data, goHome);
148 } catch (error) { 154 } catch (error) {
149 return Promise.reject(error); 155 return Promise.reject(error);
150 } 156 }
@@ -167,21 +173,21 @@ export const useUserStore = defineStore({ @@ -167,21 +173,21 @@ export const useUserStore = defineStore({
167 // console.log('注销Token失败'); 173 // console.log('注销Token失败');
168 // } 174 // }
169 this.resetState(); 175 this.resetState();
170 - setAuthCache(JWT_TOKEN_KEY,undefined);  
171 - setAuthCache(REFRESH_TOKEN_KEY,undefined); 176 + setAuthCache(JWT_TOKEN_KEY, undefined);
  177 + setAuthCache(REFRESH_TOKEN_KEY, undefined);
172 // this.setSessionTimeout(false); 178 // this.setSessionTimeout(false);
173 // goLogin && router.push(PageEnum.BASE_LOGIN); 179 // goLogin && router.push(PageEnum.BASE_LOGIN);
174 await router.push(PageEnum.BASE_LOGIN); 180 await router.push(PageEnum.BASE_LOGIN);
175 }, 181 },
176 182
177 - async doRefresh(){  
178 - try{  
179 - const req = {"refreshToken":this.refreshToken} as RefreshTokenParams; 183 + async doRefresh() {
  184 + try {
  185 + const req = { refreshToken: this.refreshToken } as RefreshTokenParams;
180 const data = await doRefreshToken(req); 186 const data = await doRefreshToken(req);
181 const { token, refreshToken } = data; 187 const { token, refreshToken } = data;
182 - this.storeToken(token,refreshToken);  
183 - }catch(error){  
184 - this.logout() 188 + this.storeToken(token, refreshToken);
  189 + } catch (error) {
  190 + this.logout();
185 } 191 }
186 }, 192 },
187 193
@@ -207,4 +213,3 @@ export const useUserStore = defineStore({ @@ -207,4 +213,3 @@ export const useUserStore = defineStore({
207 export function useUserStoreWithOut() { 213 export function useUserStoreWithOut() {
208 return useUserStore(store); 214 return useUserStore(store);
209 } 215 }
210 -  
1 import { Persistent, BasicKeys } from '/@/utils/cache/persistent'; 1 import { Persistent, BasicKeys } from '/@/utils/cache/persistent';
2 import { CacheTypeEnum } from '/@/enums/cacheEnum'; 2 import { CacheTypeEnum } from '/@/enums/cacheEnum';
3 import projectSetting from '/@/settings/projectSetting'; 3 import projectSetting from '/@/settings/projectSetting';
4 -import { JWT_TOKEN_KEY,REFRESH_TOKEN_KEY } from '/@/enums/cacheEnum'; 4 +import { JWT_TOKEN_KEY, REFRESH_TOKEN_KEY } from '/@/enums/cacheEnum';
5 5
6 const { permissionCacheType } = projectSetting; 6 const { permissionCacheType } = projectSetting;
7 const isLocal = permissionCacheType === CacheTypeEnum.LOCAL; 7 const isLocal = permissionCacheType === CacheTypeEnum.LOCAL;
@@ -20,9 +20,9 @@ export function clearAuthCache(immediate = true) { @@ -20,9 +20,9 @@ export function clearAuthCache(immediate = true) {
20 const fn = isLocal ? Persistent.clearLocal : Persistent.clearSession; 20 const fn = isLocal ? Persistent.clearLocal : Persistent.clearSession;
21 return fn(immediate); 21 return fn(immediate);
22 } 22 }
23 -export function getJwtToken(){  
24 - return getAuthCache(JWT_TOKEN_KEY); 23 +export function getJwtToken() {
  24 + return getAuthCache(JWT_TOKEN_KEY);
25 } 25 }
26 -export function getRefreshToken(){ 26 +export function getRefreshToken() {
27 return getAuthCache(REFRESH_TOKEN_KEY); 27 return getAuthCache(REFRESH_TOKEN_KEY);
28 } 28 }
@@ -105,11 +105,23 @@ window.addEventListener('beforeunload', function () { @@ -105,11 +105,23 @@ window.addEventListener('beforeunload', function () {
105 // LOCK_INFO_KEY 在锁屏和解锁时写入,此处也不应修改 105 // LOCK_INFO_KEY 在锁屏和解锁时写入,此处也不应修改
106 ls.set(APP_LOCAL_CACHE_KEY, { 106 ls.set(APP_LOCAL_CACHE_KEY, {
107 ...omit(localMemory.getCache, LOCK_INFO_KEY), 107 ...omit(localMemory.getCache, LOCK_INFO_KEY),
108 - ...pick(ls.get(APP_LOCAL_CACHE_KEY), [TOKEN_KEY,JWT_TOKEN_KEY,REFRESH_TOKEN_KEY, USER_INFO_KEY, LOCK_INFO_KEY]), 108 + ...pick(ls.get(APP_LOCAL_CACHE_KEY), [
  109 + TOKEN_KEY,
  110 + JWT_TOKEN_KEY,
  111 + REFRESH_TOKEN_KEY,
  112 + USER_INFO_KEY,
  113 + LOCK_INFO_KEY,
  114 + ]),
109 }); 115 });
110 ss.set(APP_SESSION_CACHE_KEY, { 116 ss.set(APP_SESSION_CACHE_KEY, {
111 ...omit(sessionMemory.getCache, LOCK_INFO_KEY), 117 ...omit(sessionMemory.getCache, LOCK_INFO_KEY),
112 - ...pick(ss.get(APP_SESSION_CACHE_KEY), [TOKEN_KEY,JWT_TOKEN_KEY,REFRESH_TOKEN_KEY, USER_INFO_KEY, LOCK_INFO_KEY]), 118 + ...pick(ss.get(APP_SESSION_CACHE_KEY), [
  119 + TOKEN_KEY,
  120 + JWT_TOKEN_KEY,
  121 + REFRESH_TOKEN_KEY,
  122 + USER_INFO_KEY,
  123 + LOCK_INFO_KEY,
  124 + ]),
113 }); 125 });
114 }); 126 });
115 127
  1 +export const copyTransFun = (arr: any[]) => {
  2 + arr.forEach((item) => {
  3 + if (item.name) {
  4 + item.label = item.name;
  5 + delete item.name;
  6 + }
  7 + if (item.id) {
  8 + item.value = item.id;
  9 + delete item.id;
  10 + }
  11 + if (item.children) {
  12 + if (item.children.length) {
  13 + copyTransFun(item.children);
  14 + }
  15 + }
  16 + });
  17 +};
@@ -10,7 +10,7 @@ import { ContentTypeEnum } from '/@/enums/httpEnum'; @@ -10,7 +10,7 @@ import { ContentTypeEnum } from '/@/enums/httpEnum';
10 import { RequestEnum } from '/@/enums/httpEnum'; 10 import { RequestEnum } from '/@/enums/httpEnum';
11 import { useUserStore } from '/@/store/modules/user'; 11 import { useUserStore } from '/@/store/modules/user';
12 import { JwtModel } from '/@/api/sys/jwtModel'; 12 import { JwtModel } from '/@/api/sys/jwtModel';
13 -import jwt_decode from "jwt-decode"; 13 +import jwt_decode from 'jwt-decode';
14 14
15 export * from './axiosTransform'; 15 export * from './axiosTransform';
16 16
@@ -20,14 +20,14 @@ export * from './axiosTransform'; @@ -20,14 +20,14 @@ export * from './axiosTransform';
20 export class VAxios { 20 export class VAxios {
21 private axiosInstance: AxiosInstance; 21 private axiosInstance: AxiosInstance;
22 private readonly options: CreateAxiosOptions; 22 private readonly options: CreateAxiosOptions;
23 - private waitingQueue:any[]; 23 + private waitingQueue: any[];
24 private refreshing = false; 24 private refreshing = false;
25 25
26 constructor(options: CreateAxiosOptions) { 26 constructor(options: CreateAxiosOptions) {
27 this.options = options; 27 this.options = options;
28 this.axiosInstance = axios.create(options); 28 this.axiosInstance = axios.create(options);
29 this.setupInterceptors(); 29 this.setupInterceptors();
30 - this.waitingQueue=[]; 30 + this.waitingQueue = [];
31 } 31 }
32 32
33 /** 33 /**
@@ -69,15 +69,15 @@ export class VAxios { @@ -69,15 +69,15 @@ export class VAxios {
69 * JWT 自动刷新 69 * JWT 自动刷新
70 * @description: 自动刷新token 70 * @description: 自动刷新token
71 */ 71 */
72 - private isNeedTokenURL(url, arr = ['/auth/login', '/auth/token']) { 72 + private isNeedTokenURL(url, arr = ['/auth/login', '/auth/token']) {
73 return !arr.some((val) => url.indexOf(val) > -1); 73 return !arr.some((val) => url.indexOf(val) > -1);
74 } 74 }
75 - 75 +
76 /** 76 /**
77 - *  
78 - * @returns 77 + *
  78 + * @returns
79 */ 79 */
80 - private refreshTokenBeforeReq(doRefreshTokenApi: () => Promise<unknown>): Promise<unknown> { 80 + private refreshTokenBeforeReq(doRefreshTokenApi: () => Promise<unknown>): Promise<unknown> {
81 // 创建一个未完成的promise,把改变状态的resolve方法交给请求token结束后执行 81 // 创建一个未完成的promise,把改变状态的resolve方法交给请求token结束后执行
82 const promise = new Promise((resolve) => { 82 const promise = new Promise((resolve) => {
83 console.log('等待新token'); 83 console.log('等待新token');
@@ -88,7 +88,7 @@ export class VAxios { @@ -88,7 +88,7 @@ export class VAxios {
88 this.refreshing = true; 88 this.refreshing = true;
89 // 模拟请求刷新Token接口,当接口返回数据时执行then方法 TODO 添加catch捕获异常 89 // 模拟请求刷新Token接口,当接口返回数据时执行then方法 TODO 添加catch捕获异常
90 doRefreshTokenApi().then(() => { 90 doRefreshTokenApi().then(() => {
91 - console.log('刷新token成功,放行队列中的请求',this.waitingQueue.length); 91 + console.log('刷新token成功,放行队列中的请求', this.waitingQueue.length);
92 this.refreshing = false; 92 this.refreshing = false;
93 this.waitingQueue.forEach((cb) => cb()); 93 this.waitingQueue.forEach((cb) => cb());
94 this.waitingQueue.length = 0; 94 this.waitingQueue.length = 0;
@@ -116,19 +116,18 @@ export class VAxios { @@ -116,19 +116,18 @@ export class VAxios {
116 // Request interceptor configuration processing 116 // Request interceptor configuration processing
117 this.axiosInstance.interceptors.request.use(async (config: AxiosRequestConfig) => { 117 this.axiosInstance.interceptors.request.use(async (config: AxiosRequestConfig) => {
118 // If cancel repeat request is turned on, then cancel repeat request is prohibited 118 // If cancel repeat request is turned on, then cancel repeat request is prohibited
119 - const userStore = useUserStore();  
120 - if(userStore && userStore.jwtToken){  
121 - try{  
122 - const res = jwt_decode(userStore.jwtToken) as JwtModel;  
123 - const currentTime = new Date().getTime()/1000;  
124 - if(currentTime >= res.exp && this.isNeedTokenURL(config.url)){  
125 - await this.refreshTokenBeforeReq(userStore.doRefresh);  
126 - }  
127 - }catch(error){ 119 + const userStore = useUserStore();
  120 + if (userStore && userStore.jwtToken) {
  121 + try {
  122 + const res = jwt_decode(userStore.jwtToken) as JwtModel;
  123 + const currentTime = new Date().getTime() / 1000;
  124 + if (currentTime >= res.exp && this.isNeedTokenURL(config.url)) {
  125 + await this.refreshTokenBeforeReq(userStore.doRefresh);
  126 + }
  127 + } catch (error) {
128 userStore.logout(); 128 userStore.logout();
129 - }  
130 -  
131 - } 129 + }
  130 + }
132 const { 131 const {
133 headers: { ignoreCancelToken }, 132 headers: { ignoreCancelToken },
134 } = config; 133 } = config;
@@ -93,7 +93,7 @@ const transform: AxiosTransform = { @@ -93,7 +93,7 @@ const transform: AxiosTransform = {
93 const token = getJwtToken(); 93 const token = getJwtToken();
94 if (token && (config as Recordable)?.requestOptions?.withToken !== false) { 94 if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
95 // jwt token 95 // jwt token
96 - config.headers["X-Authorization"] = options.authenticationScheme 96 + config.headers['X-Authorization'] = options.authenticationScheme
97 ? `${options.authenticationScheme} ${token}` 97 ? `${options.authenticationScheme} ${token}`
98 : token; 98 : token;
99 } 99 }
@@ -111,10 +111,10 @@ const transform: AxiosTransform = { @@ -111,10 +111,10 @@ const transform: AxiosTransform = {
111 * @description: 响应错误处理 111 * @description: 响应错误处理
112 */ 112 */
113 responseInterceptorsCatch: (error: any) => { 113 responseInterceptorsCatch: (error: any) => {
114 - const {t} = useI18n(); 114 + const { t } = useI18n();
115 const errorLogStore = useErrorLogStoreWithOut(); 115 const errorLogStore = useErrorLogStoreWithOut();
116 errorLogStore.addAjaxErrorInfo(error); 116 errorLogStore.addAjaxErrorInfo(error);
117 - const {response, code, message, config} = error || {}; 117 + const { response, code, message, config } = error || {};
118 const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none'; 118 const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none';
119 const msg: string = response?.data?.msg ?? ''; 119 const msg: string = response?.data?.msg ?? '';
120 const err: string = error?.toString?.() ?? ''; 120 const err: string = error?.toString?.() ?? '';
@@ -130,13 +130,13 @@ const transform: AxiosTransform = { @@ -130,13 +130,13 @@ const transform: AxiosTransform = {
130 130
131 if (errMessage) { 131 if (errMessage) {
132 if (errorMessageMode === 'modal') { 132 if (errorMessageMode === 'modal') {
133 - createErrorModal({title: t('sys.api.errorTip'), content: errMessage}); 133 + createErrorModal({ title: t('sys.api.errorTip'), content: errMessage });
134 } else if (errorMessageMode === 'message') { 134 } else if (errorMessageMode === 'message') {
135 createMessage.error(errMessage); 135 createMessage.error(errMessage);
136 } 136 }
137 return Promise.reject(error); 137 return Promise.reject(error);
138 } 138 }
139 - } catch (error) { 139 + } catch (error: any) {
140 throw new Error(error); 140 throw new Error(error);
141 } 141 }
142 142
1 /* list To Tree */ 1 /* list To Tree */
2 2
3 -import {getMenuListResultModel} from "/@/api/sys/model/menuModel";  
4 -import {useI18n} from "/@/hooks/web/useI18n";  
5 - 3 +import { getMenuListResultModel } from '/@/api/sys/model/menuModel';
  4 +import { useI18n } from '/@/hooks/web/useI18n';
6 5
7 export function listToTree(lists: getMenuListResultModel): getMenuListResultModel { 6 export function listToTree(lists: getMenuListResultModel): getMenuListResultModel {
8 const { t } = useI18n(); //加载国际化 7 const { t } = useI18n(); //加载国际化
9 - lists.forEach(goods => { 8 + lists.forEach((goods) => {
10 goods['menuName'] = t(goods.meta.title); // 为goods添加属性menuName 9 goods['menuName'] = t(goods.meta.title); // 为goods添加属性menuName
11 10
12 // console.log(goods.children?.length); 11 // console.log(goods.children?.length);
13 - if(goods.children?.length){  
14 - goods.children.forEach(goodChildren => { 12 + if (goods.children?.length) {
  13 + goods.children.forEach((goodChildren) => {
15 goodChildren['menuName'] = t(goodChildren.meta.title); // 为goodChildren添加属性menuName 14 goodChildren['menuName'] = t(goodChildren.meta.title); // 为goodChildren添加属性menuName
16 - }) 15 + });
17 } 16 }
18 - }) 17 + });
19 18
20 return lists; 19 return lists;
21 -  
22 } 20 }
23 -  
24 -  
25 -  
26 -  
27 -  
28 -  
29 -  
  1 +import { FormSchema } from '/@/components/Table';
  2 +export const formSchema: FormSchema[] = [
  3 + {
  4 + field: 'organization',
  5 + label: '',
  6 + component: 'TreeSelect',
  7 + componentProps: {},
  8 + },
  9 + {
  10 + field: 'organization',
  11 + label: '',
  12 + component: 'Select',
  13 + componentProps: {},
  14 + },
  15 + {
  16 + field: 'device',
  17 + label: '',
  18 + slot: 'device',
  19 + component: 'Input',
  20 + },
  21 +];
  1 +<template>
  2 + <div class="wrapper">
  3 + <div ref="wrapRef" :style="{ height, width }"> </div>
  4 + <div class="right-wrap">
  5 + <BasicForm @register="registerForm">
  6 + <template #device>
  7 + <div class="flex justify-between">
  8 + <a-input v-model:value="deviceValue" placeholder="请输入设备名称" style="width: 70%" />
  9 + <a-button color="success" @click="handleReset" class="w-1/4">复位查询</a-button>
  10 + </div>
  11 + </template>
  12 + </BasicForm>
  13 + <div>
  14 + <RadioGroup v-model:value="deviceStatus">
  15 + <Radio :value="1">全部</Radio>
  16 + <Radio :value="2">在线</Radio>
  17 + <Radio :value="3">离线</Radio>
  18 + <Radio :value="4">报警</Radio>
  19 + </RadioGroup>
  20 + <div class="scroll-wrap">
  21 + <ScrollContainer ref="scrollRef">
  22 + <template
  23 + v-for="(item, index) in 10"
  24 + :key="index"
  25 + :class="{ active: currentIndex == index }"
  26 + @click="bander(index)"
  27 + >
  28 + <div class="flex" style="border-bottom: 1px solid #ccc">
  29 + <div>
  30 + <div class="flex">
  31 + <div class="font-bold ml-5">名称 </div>
  32 + <div class="ml-5">发动机{{ item }}</div>
  33 + </div>
  34 + <div class="flex">
  35 + <div class="font-bold ml-5">位置 </div>
  36 + <div class="ml-5 font-bold">四川省成都市高新区{{ item }}</div>
  37 + </div>
  38 + </div>
  39 + <div class="self-center ml-10"><Tag color="default">离线</Tag></div>
  40 + </div>
  41 + </template>
  42 + </ScrollContainer>
  43 + </div>
  44 + <div class="flex justify-end">
  45 + <Pagination v-model:current="current" :total="50" size="small" show-less-items />
  46 + </div>
  47 + </div>
  48 + </div>
  49 + </div>
  50 +</template>
  51 +<script lang="ts">
  52 + import { defineComponent, ref, nextTick, unref, onMounted } from 'vue';
  53 + import { useScript } from '/@/hooks/web/useScript';
  54 + import { BasicForm, useForm } from '/@/components/Form/index';
  55 + import { formSchema } from './config.data';
  56 + import { RadioGroup, Radio, Tag, Pagination } from 'ant-design-vue';
  57 + import { ScrollContainer, ScrollActionType } from '/@/components/Container/index';
  58 + export default defineComponent({
  59 + name: 'BaiduMap',
  60 + components: {
  61 + BasicForm,
  62 + RadioGroup,
  63 + Radio,
  64 + Tag,
  65 + ScrollContainer,
  66 + Pagination,
  67 + },
  68 + props: {
  69 + width: {
  70 + type: String,
  71 + default: '100%',
  72 + },
  73 + height: {
  74 + type: String,
  75 + default: 'calc(100vh - 78px)',
  76 + },
  77 + },
  78 +
  79 + setup() {
  80 + const BAI_DU_MAP_URL =
  81 + 'https://api.map.baidu.com/getscript?v=3.0&ak=7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa';
  82 + const wrapRef = ref<HTMLDivElement | null>(null);
  83 + const scrollRef = ref<Nullable<ScrollActionType>>(null);
  84 + const { toPromise } = useScript({ src: BAI_DU_MAP_URL });
  85 + async function initMap() {
  86 + await toPromise();
  87 + await nextTick();
  88 + const wrapEl = unref(wrapRef);
  89 + const BMap = (window as any).BMap;
  90 + if (!wrapEl) return;
  91 + const map = new BMap.Map(wrapEl);
  92 + const point = new BMap.Point(116.14282, 35.19515);
  93 + map.centerAndZoom(point, 15);
  94 + map.enableScrollWheelZoom(true);
  95 + }
  96 + onMounted(() => {
  97 + initMap();
  98 + });
  99 + const deviceValue = ref('');
  100 + const deviceStatus = ref(1);
  101 + const current = ref(2);
  102 + const currentIndex = ref(1);
  103 + const bander = (index: number) => {
  104 + currentIndex.value = index;
  105 + };
  106 + const [registerForm] = useForm({
  107 + labelWidth: 90,
  108 + schemas: formSchema,
  109 + showActionButtonGroup: false,
  110 + });
  111 + const handleReset = () => {
  112 + deviceValue.value = '';
  113 + };
  114 + return {
  115 + wrapRef,
  116 + registerForm,
  117 + deviceValue,
  118 + deviceStatus,
  119 + handleReset,
  120 + scrollRef,
  121 + current,
  122 + currentIndex,
  123 + bander,
  124 + };
  125 + },
  126 + });
  127 +</script>
  128 +
  129 +<style scoped>
  130 + .wrapper {
  131 + position: relative;
  132 + }
  133 + .active {
  134 + background-color: #fff;
  135 + }
  136 + .right-wrap {
  137 + padding-top: 10px;
  138 + width: 20%;
  139 + height: 80%;
  140 + position: absolute;
  141 + right: 5%;
  142 + top: 10%;
  143 + background-color: #f3f8fe;
  144 + }
  145 + .scroll-wrap {
  146 + height: 450px;
  147 + background-color: #f3f8fe;
  148 + }
  149 +</style>
src/views/alarm/template/ContactDrawer.vue renamed from src/views/device/DeviceDrawer.vue
@@ -4,10 +4,10 @@ @@ -4,10 +4,10 @@
4 @register="registerDrawer" 4 @register="registerDrawer"
5 showFooter 5 showFooter
6 :title="getTitle" 6 :title="getTitle"
7 - width="500px" 7 + width="30%"
8 @ok="handleSubmit" 8 @ok="handleSubmit"
9 > 9 >
10 - <BasicForm @register="registerForm"/> 10 + <BasicForm @register="registerForm" />
11 </BasicDrawer> 11 </BasicDrawer>
12 </template> 12 </template>
13 <script lang="ts"> 13 <script lang="ts">
@@ -15,17 +15,17 @@ @@ -15,17 +15,17 @@
15 import { BasicForm, useForm } from '/@/components/Form'; 15 import { BasicForm, useForm } from '/@/components/Form';
16 import { formSchema } from './config.data'; 16 import { formSchema } from './config.data';
17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; 17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
18 - import {saveOrEditMessageConfig} from "/@/api/message/config";  
19 - import {useMessage} from "/@/hooks/web/useMessage"; 18 + import { saveOrEditAlarmContact } from '/@/api/alarm/contact/alarmContact';
  19 + import { useMessage } from '/@/hooks/web/useMessage';
20 20
21 export default defineComponent({ 21 export default defineComponent({
22 - name: 'ConfigDrawer', 22 + name: 'ContactDrawer',
23 components: { BasicDrawer, BasicForm }, 23 components: { BasicDrawer, BasicForm },
24 emits: ['success', 'register'], 24 emits: ['success', 'register'],
25 setup(_, { emit }) { 25 setup(_, { emit }) {
26 const isUpdate = ref(true); 26 const isUpdate = ref(true);
27 27
28 - const [registerForm, { validate,setFieldsValue,resetFields }] = useForm({ 28 + const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({
29 labelWidth: 120, 29 labelWidth: 120,
30 schemas: formSchema, 30 schemas: formSchema,
31 showActionButtonGroup: false, 31 showActionButtonGroup: false,
@@ -36,53 +36,34 @@ @@ -36,53 +36,34 @@
36 setDrawerProps({ confirmLoading: false }); 36 setDrawerProps({ confirmLoading: false });
37 isUpdate.value = !!data?.isUpdate; 37 isUpdate.value = !!data?.isUpdate;
38 if (unref(isUpdate)) { 38 if (unref(isUpdate)) {
39 - const config = data.record.config;  
40 - for (const key in config){  
41 - Reflect.set(data.record, key+'', config[key]);  
42 - }  
43 await setFieldsValue({ 39 await setFieldsValue({
44 ...data.record, 40 ...data.record,
45 }); 41 });
46 } 42 }
47 }); 43 });
48 44
49 - const getTitle = computed(() => (!unref(isUpdate) ? '新增消息配置' : '编辑消息配置')); 45 + const getTitle = computed(() => (!unref(isUpdate) ? '新增联系人配置' : '编辑联系人配置'));
50 46
51 async function handleSubmit() { 47 async function handleSubmit() {
52 try { 48 try {
53 const values = await validate(); 49 const values = await validate();
54 const { createMessage } = useMessage(); 50 const { createMessage } = useMessage();
55 setDrawerProps({ confirmLoading: true }); 51 setDrawerProps({ confirmLoading: true });
56 - let config={};  
57 - if(values.messageType === 'PHONE_MESSAGE'){  
58 - config ={  
59 - "accessKeyId":values.accessKeyId,  
60 - "accessKeySecret":values.accessKeySecret,  
61 - }  
62 - }else if(values.messageType === 'EMAIL_MESSAGE'){  
63 - config ={  
64 - "host":values.host,  
65 - "port":values.port,  
66 - "username":values.username,  
67 - "password":values.password,  
68 - }  
69 - }  
70 - Reflect.set(values, 'config', config);  
71 - let saveMessage = "添加成功";  
72 - let updateMessage = "修改成功";  
73 - await saveOrEditMessageConfig(values, unref(isUpdate)); 52 + let saveMessage = '添加成功';
  53 + let updateMessage = '修改成功';
  54 + await saveOrEditAlarmContact(values, unref(isUpdate));
74 closeDrawer(); 55 closeDrawer();
75 emit('success'); 56 emit('success');
76 - createMessage.success(unref(isUpdate)?updateMessage:saveMessage); 57 + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage);
77 } finally { 58 } finally {
78 setDrawerProps({ confirmLoading: false }); 59 setDrawerProps({ confirmLoading: false });
79 } 60 }
80 } 61 }
81 62
82 return { 63 return {
  64 + getTitle,
83 registerDrawer, 65 registerDrawer,
84 registerForm, 66 registerForm,
85 - getTitle,  
86 handleSubmit, 67 handleSubmit,
87 }; 68 };
88 }, 69 },
  1 +import { BasicColumn } from '/@/components/Table';
  2 +import { FormSchema } from '/@/components/Table';
  3 +import { getOrganizationList } from '/@/api/system/system';
  4 +import { copyTransFun } from '/@/utils/fnUtils';
  5 +// 表格列数据
  6 +export const columns: BasicColumn[] = [
  7 + {
  8 + title: '姓名',
  9 + dataIndex: 'username',
  10 + width: 120,
  11 + },
  12 + {
  13 + title: '所属组织',
  14 + dataIndex: 'organizationId',
  15 + width: 160,
  16 + },
  17 + {
  18 + title: '手机',
  19 + dataIndex: 'phone',
  20 + width: 160,
  21 + },
  22 + {
  23 + title: '邮箱',
  24 + dataIndex: 'email',
  25 + width: 160,
  26 + },
  27 + {
  28 + title: '微信',
  29 + dataIndex: 'wechat',
  30 + width: 180,
  31 + },
  32 + {
  33 + title: '备注',
  34 + dataIndex: 'remark',
  35 + width: 120,
  36 + },
  37 + {
  38 + title: '添加人',
  39 + dataIndex: 'addPeople',
  40 + width: 180,
  41 + },
  42 + {
  43 + title: '添加时间',
  44 + dataIndex: 'createTime',
  45 + width: 180,
  46 + },
  47 + {
  48 + title: '更新时间',
  49 + dataIndex: 'updateTime',
  50 + width: 180,
  51 + },
  52 +];
  53 +
  54 +// 查询字段
  55 +export const searchFormSchema: FormSchema[] = [
  56 + {
  57 + field: 'username',
  58 + label: '联系人姓名',
  59 + component: 'Input',
  60 + colProps: { span: 6 },
  61 + componentProps: {
  62 + placeholder: '请输入联系人姓名',
  63 + },
  64 + },
  65 +];
  66 +
  67 +// 弹框配置项
  68 +export const formSchema: FormSchema[] = [
  69 + {
  70 + field: 'username',
  71 + label: '联系人姓名',
  72 + required: true,
  73 + component: 'Input',
  74 + componentProps: {
  75 + placeholder: '请输入联系人姓名',
  76 + },
  77 + },
  78 + {
  79 + field: 'organizationId',
  80 + label: '所属组织',
  81 + component: 'ApiTreeSelect',
  82 + componentProps: {
  83 + api: async () => {
  84 + const data = await getOrganizationList();
  85 + copyTransFun(data as any as any[]);
  86 + return data;
  87 + },
  88 + },
  89 + },
  90 + {
  91 + field: 'phone',
  92 + label: '手机号码',
  93 + required: true,
  94 + component: 'Input',
  95 + componentProps: {
  96 + placeholder: '请输入手机号码',
  97 + },
  98 + },
  99 + {
  100 + field: 'email',
  101 + label: '邮箱',
  102 + component: 'Input',
  103 + componentProps: {
  104 + placeholder: '请输入邮箱',
  105 + },
  106 + },
  107 + {
  108 + field: 'wechat',
  109 + label: '微信',
  110 + component: 'Input',
  111 + componentProps: {
  112 + placeholder: '请输入微信号',
  113 + },
  114 + },
  115 + {
  116 + field: 'addPeople',
  117 + label: '添加人',
  118 + component: 'Input',
  119 + componentProps: {
  120 + placeholder: '请输入添加人',
  121 + },
  122 + },
  123 + {
  124 + field: 'remark',
  125 + label: '备注',
  126 + component: 'InputTextArea',
  127 + componentProps: {
  128 + placeholder: '',
  129 + },
  130 + },
  131 + {
  132 + field: 'id',
  133 + label: '',
  134 + component: 'Input',
  135 + componentProps: {
  136 + style: {
  137 + display: 'none',
  138 + },
  139 + },
  140 + },
  141 +];
  1 +<template>
  2 + <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
  3 + <OrganizationIdTree class="w-1/4 xl:w-1/5" @select="handleSelect" />
  4 + <BasicTable @register="registerTable" :searchInfo="searchInfo" class="w-3/4 xl:w-4/5">
  5 + <template #toolbar>
  6 + <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增联系人 </a-button>
  7 + <a-button
  8 + type="primary"
  9 + color="error"
  10 + @click="handleDeleteOrBatchDelete(null)"
  11 + :disabled="hasBatchDelete"
  12 + >
  13 + 批量删除
  14 + </a-button>
  15 + </template>
  16 + <template #action="{ record }">
  17 + <TableAction
  18 + :actions="[
  19 + {
  20 + label: '编辑',
  21 + icon: 'clarity:note-edit-line',
  22 + onClick: handleCreateOrEdit.bind(null, record),
  23 + },
  24 + {
  25 + label: '删除',
  26 + icon: 'ant-design:delete-outlined',
  27 + color: 'error',
  28 + popConfirm: {
  29 + title: '是否确认删除',
  30 + confirm: handleDeleteOrBatchDelete.bind(null, record),
  31 + },
  32 + },
  33 + ]"
  34 + />
  35 + </template>
  36 + </BasicTable>
  37 + </PageWrapper>
  38 + <ContactDrawer @register="registerDrawer" @success="handleSuccess" />
  39 +</template>
  40 +
  41 +<script lang="ts">
  42 + import { defineComponent, reactive, ref, computed } from 'vue';
  43 + import { BasicTable, useTable, TableAction } from '/@/components/Table';
  44 + import { PageWrapper } from '/@/components/Page';
  45 + import { useMessage } from '/@/hooks/web/useMessage';
  46 + import { useDrawer } from '/@/components/Drawer';
  47 + import ContactDrawer from './ContactDrawer.vue';
  48 + import OrganizationIdTree from '../../common/OrganizationIdTree.vue';
  49 + import { getAlarmContact, deleteAlarmContact } from '/@/api/alarm/contact/alarmContact';
  50 + import { searchFormSchema, columns } from './config.data';
  51 + export default defineComponent({
  52 + components: {
  53 + PageWrapper,
  54 + OrganizationIdTree,
  55 + BasicTable,
  56 + TableAction,
  57 + ContactDrawer,
  58 + },
  59 + setup() {
  60 + let selectedRowIds = ref<string[]>([]);
  61 + const hasBatchDelete = computed(() => selectedRowIds.value.length <= 0);
  62 + // 复选框事件
  63 + const onSelectRowChange = (selectedRowKeys: string[]) => {
  64 + selectedRowIds.value = selectedRowKeys;
  65 + };
  66 + // 表格hooks
  67 + const [registerTable, { reload }] = useTable({
  68 + api: getAlarmContact,
  69 + columns,
  70 + formConfig: {
  71 + labelWidth: 120,
  72 + schemas: searchFormSchema,
  73 + },
  74 + useSearchForm: true,
  75 + showTableSetting: true,
  76 + bordered: true,
  77 + rowSelection: {
  78 + onChange: onSelectRowChange,
  79 + type: 'checkbox',
  80 + },
  81 + rowKey: 'id',
  82 + actionColumn: {
  83 + width: 180,
  84 + title: '操作',
  85 + dataIndex: 'action',
  86 + slots: { customRender: 'action' },
  87 + fixed: 'right',
  88 + },
  89 + });
  90 + // 弹框
  91 + const [registerDrawer, { openDrawer }] = useDrawer();
  92 + const { createMessage } = useMessage();
  93 + const searchInfo = reactive<Recordable>({});
  94 + // 刷新
  95 + const handleSuccess = () => {
  96 + reload();
  97 + };
  98 + // 新增或编辑
  99 + const handleCreateOrEdit = (record: Recordable) => {
  100 + if (record) {
  101 + openDrawer(true, {
  102 + isUpdate: true,
  103 + record,
  104 + });
  105 + } else {
  106 + openDrawer(true, {
  107 + isUpdate: false,
  108 + });
  109 + }
  110 + };
  111 + // 删除或批量删除
  112 + const handleDeleteOrBatchDelete = async (record?: Recordable) => {
  113 + if (record) {
  114 + try {
  115 + await deleteAlarmContact([record.id]);
  116 + createMessage.success('删除联系人成功');
  117 + handleSuccess();
  118 + } catch (e) {
  119 + createMessage.error('删除失败');
  120 + }
  121 + } else {
  122 + try {
  123 + await deleteAlarmContact(selectedRowIds.value);
  124 + createMessage.success('批量删除联系人成功');
  125 + handleSuccess();
  126 + } catch (e) {
  127 + createMessage.info('删除失败');
  128 + }
  129 + }
  130 + };
  131 +
  132 + // 树形选择器
  133 + const handleSelect = (organizationId: string) => {
  134 + searchInfo.organizationId = organizationId;
  135 + handleSuccess();
  136 + };
  137 + return {
  138 + searchInfo,
  139 + hasBatchDelete,
  140 + handleCreateOrEdit,
  141 + handleDeleteOrBatchDelete,
  142 + handleSelect,
  143 + handleSuccess,
  144 + registerTable,
  145 + registerDrawer,
  146 + };
  147 + },
  148 + });
  149 +</script>
  1 +<template>
  2 + <BasicModal
  3 + v-bind="$attrs"
  4 + width="55rem"
  5 + @register="register"
  6 + :title="getTitle"
  7 + @visible-change="handleVisibleChange"
  8 + @cancel="handleCancel"
  9 + >
  10 + <div class="step-form-form">
  11 + <a-steps :current="current">
  12 + <a-step title="填写设备信息" />
  13 + <a-step title="添加设备凭证" />
  14 + </a-steps>
  15 + </div>
  16 + <div class="mt-5">
  17 + <DeviceStep1 @next="handleStep1Next" v-show="current === 0" />
  18 + <DeviceStep2
  19 + @prev="handleStepPrev"
  20 + @next="handleStep2Next"
  21 + v-show="current === 1"
  22 + v-if="initStep2"
  23 + />
  24 + </div>
  25 + </BasicModal>
  26 +</template>
  27 +<script lang="ts">
  28 + import { defineComponent, ref, nextTick, computed, unref, reactive, toRefs } from 'vue';
  29 + import { BasicModal, useModalInner } from '/@/components/Modal';
  30 + import DeviceStep1 from '/@/views/device/step/DeviceStep1.vue';
  31 + import DeviceStep2 from '/@/views/device/step/DeviceStep2.vue';
  32 + import { Steps } from 'ant-design-vue';
  33 + export default defineComponent({
  34 + name: 'DeviceModal',
  35 + components: {
  36 + BasicModal,
  37 + DeviceStep1,
  38 + DeviceStep2,
  39 + [Steps.name]: Steps,
  40 + [Steps.Step.name]: Steps.Step,
  41 + },
  42 + props: {
  43 + userData: { type: Object },
  44 + },
  45 + setup(props) {
  46 + const state = reactive({
  47 + initStep2: false,
  48 + });
  49 + const current = ref(0);
  50 + const isUpdate = ref(true);
  51 + const modelRef = ref({});
  52 + const getTitle = computed(() => (!unref(isUpdate) ? '新增设备' : '编辑设备'));
  53 +
  54 + const [register] = useModalInner((data) => {
  55 + isUpdate.value = !!data?.isUpdate;
  56 + data && onDataReceive(data);
  57 + });
  58 +
  59 + function handleStepPrev() {
  60 + current.value--;
  61 + }
  62 + function handleStep1Next(step1Values: any) {
  63 + current.value++;
  64 + state.initStep2 = true;
  65 + console.log(step1Values);
  66 + }
  67 + function handleStep2Next(step2Values: any) {
  68 + current.value++;
  69 + console.log(step2Values);
  70 + }
  71 + function handleRedo() {
  72 + current.value = 0;
  73 + state.initStep2 = false;
  74 + }
  75 + function handleCancel() {
  76 + console.log('关闭了弹框');
  77 + }
  78 +
  79 + function onDataReceive(data) {
  80 + console.log('Data Received', data);
  81 + // 方式1;
  82 + // setFieldsValue({
  83 + // field2: data.data,
  84 + // field1: data.info,
  85 + // });
  86 +
  87 + // // 方式2
  88 + modelRef.value = { field2: data.data, field1: data.info };
  89 +
  90 + // setProps({
  91 + // model:{ field2: data.data, field1: data.info }
  92 + // })
  93 + }
  94 +
  95 + function handleVisibleChange(v) {
  96 + v && props.userData && nextTick(() => onDataReceive(props.userData));
  97 + }
  98 +
  99 + return {
  100 + register,
  101 + model: modelRef,
  102 + getTitle,
  103 + handleVisibleChange,
  104 + current,
  105 + ...toRefs(state),
  106 + handleStepPrev,
  107 + handleStep1Next,
  108 + handleStep2Next,
  109 + handleCancel,
  110 + handleRedo,
  111 + };
  112 + },
  113 + });
  114 +</script>
@@ -3,6 +3,7 @@ import { FormSchema } from '/@/components/Table'; @@ -3,6 +3,7 @@ import { FormSchema } from '/@/components/Table';
3 import { findDictItemByCode } from '/@/api/system/dict'; 3 import { findDictItemByCode } from '/@/api/system/dict';
4 import { MessageEnum } from '/@/enums/messageEnum'; 4 import { MessageEnum } from '/@/enums/messageEnum';
5 import { DeviceTypeEnum, DeviceState } from '/@/api/device/model/deviceModel'; 5 import { DeviceTypeEnum, DeviceState } from '/@/api/device/model/deviceModel';
  6 +// 表格列数据
6 export const columns: BasicColumn[] = [ 7 export const columns: BasicColumn[] = [
7 { 8 {
8 title: '默认', 9 title: '默认',
@@ -41,7 +42,6 @@ export const columns: BasicColumn[] = [ @@ -41,7 +42,6 @@ export const columns: BasicColumn[] = [
41 width: 120, 42 width: 120,
42 slots: { customRender: 'deviceState' }, 43 slots: { customRender: 'deviceState' },
43 }, 44 },
44 -  
45 { 45 {
46 title: '最后连接时间', 46 title: '最后连接时间',
47 dataIndex: 'lastConnectTime', 47 dataIndex: 'lastConnectTime',
@@ -54,6 +54,7 @@ export const columns: BasicColumn[] = [ @@ -54,6 +54,7 @@ export const columns: BasicColumn[] = [
54 }, 54 },
55 ]; 55 ];
56 56
  57 +// 查询字段
57 export const searchFormSchema: FormSchema[] = [ 58 export const searchFormSchema: FormSchema[] = [
58 { 59 {
59 field: 'deviceType', 60 field: 'deviceType',
@@ -89,13 +90,7 @@ export const searchFormSchema: FormSchema[] = [ @@ -89,13 +90,7 @@ export const searchFormSchema: FormSchema[] = [
89 }, 90 },
90 ]; 91 ];
91 92
92 -export const isMessage = (type: string) => {  
93 - return type === MessageEnum.IS_SMS;  
94 -};  
95 -export const isEmail = (type: string) => {  
96 - return type === MessageEnum.IS_EMAIL;  
97 -};  
98 - 93 +// 弹框配置项
99 export const formSchema: FormSchema[] = [ 94 export const formSchema: FormSchema[] = [
100 { 95 {
101 field: 'configName', 96 field: 'configName',
@@ -206,3 +201,10 @@ export const formSchema: FormSchema[] = [ @@ -206,3 +201,10 @@ export const formSchema: FormSchema[] = [
206 component: 'InputTextArea', 201 component: 'InputTextArea',
207 }, 202 },
208 ]; 203 ];
  204 +
  205 +export const isMessage = (type: string) => {
  206 + return type === MessageEnum.IS_SMS;
  207 +};
  208 +export const isEmail = (type: string) => {
  209 + return type === MessageEnum.IS_EMAIL;
  210 +};
  1 +import { BasicColumn } from '/@/components/Table';
  2 +import { FormSchema } from '/@/components/Table';
  3 +import { findDictItemByCode } from '/@/api/system/dict';
  4 +import { DeviceTypeEnum, DeviceState } from '/@/api/device/model/deviceModel';
  5 +export const columns: BasicColumn[] = [
  6 + {
  7 + title: '设备名称',
  8 + dataIndex: 'name',
  9 + width: 120,
  10 + },
  11 + {
  12 + title: '设备类型',
  13 + dataIndex: 'deviceType',
  14 + width: 100,
  15 + slots: { customRender: 'deviceType' },
  16 + },
  17 + {
  18 + title: '设备配置',
  19 + dataIndex: 'deviceProfile.name',
  20 + width: 160,
  21 + slots: { customRender: 'deviceProfile' },
  22 + },
  23 +
  24 + {
  25 + title: '所属组织',
  26 + dataIndex: 'organizationId',
  27 + slots: { customRender: 'organizationId' },
  28 + },
  29 + {
  30 + title: '标签',
  31 + dataIndex: 'label',
  32 + width: 180,
  33 + },
  34 + {
  35 + title: '状态',
  36 + dataIndex: 'deviceState',
  37 + width: 120,
  38 + slots: { customRender: 'deviceState' },
  39 + },
  40 +
  41 + {
  42 + title: '最后连接时间',
  43 + dataIndex: 'lastConnectTime',
  44 + width: 180,
  45 + },
  46 +];
  47 +
  48 +export const searchFormSchema: FormSchema[] = [
  49 + {
  50 + field: 'deviceType',
  51 + label: '设备类型',
  52 + component: 'Select',
  53 + componentProps: {
  54 + options: [
  55 + { label: '网关设备', value: DeviceTypeEnum.GATEWAY },
  56 + { label: '直连设备', value: DeviceTypeEnum.DIRECT_CONNECTION },
  57 + { label: '网关子设备', value: DeviceTypeEnum.SENSOR },
  58 + ],
  59 + },
  60 + colProps: { span: 4 },
  61 + },
  62 + {
  63 + field: 'deviceState',
  64 + label: '设备状态',
  65 + component: 'Select',
  66 + componentProps: {
  67 + options: [
  68 + { label: '待激活', value: DeviceState.INACTIVE },
  69 + { label: '在线', value: DeviceState.ONLINE },
  70 + { label: '离线', value: DeviceState.OFFLINE },
  71 + ],
  72 + },
  73 + colProps: { span: 4 },
  74 + },
  75 + {
  76 + field: 'name',
  77 + label: '设备名称',
  78 + component: 'Input',
  79 + colProps: { span: 8 },
  80 + },
  81 +];
  82 +
  83 +export const formSchema: FormSchema[] = [
  84 + {
  85 + field: 'icon',
  86 + label: '设备图片: ',
  87 + slot: 'iconSelect',
  88 + component: 'Input',
  89 + },
  90 + {
  91 + field: 'name',
  92 + label: '设备名称',
  93 + required: true,
  94 + component: 'Input',
  95 + componentProps: {
  96 + maxLength: 30,
  97 + },
  98 + },
  99 + {
  100 + field: 'deviceType',
  101 + label: '设备类型',
  102 + required: true,
  103 + component: 'ApiSelect',
  104 + componentProps: {
  105 + api: findDictItemByCode,
  106 + params: {
  107 + dictCode: 'device_type',
  108 + },
  109 + labelField: 'itemText',
  110 + valueField: 'itemValue',
  111 + },
  112 + },
  113 + {
  114 + field: 'label',
  115 + label: '设备标签',
  116 + component: 'Input',
  117 + componentProps: {
  118 + maxLength: 255,
  119 + },
  120 + },
  121 + {
  122 + label: '备注',
  123 + field: 'remark',
  124 + component: 'InputTextArea',
  125 + },
  126 +];
1 <template> 1 <template>
2 - <div>  
3 - <BasicTable @register="registerTable"> 2 + <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
  3 + <OrganizationIdTree class="w-1/6 xl:w-1/5" @select="handleSelect" />
  4 + <BasicTable @register="registerTable" class="w-5/6 xl:w-4/5">
4 <template #toolbar> 5 <template #toolbar>
5 <a-button type="primary" @click="handleCreate"> 新增设备 </a-button> 6 <a-button type="primary" @click="handleCreate"> 新增设备 </a-button>
6 </template> 7 </template>
7 - <template #config="{ record }">  
8 - <a-button type="link" class="ml-2" @click="showData(record)"> 查看配置 </a-button>  
9 - </template>  
10 <template #deviceProfile="{ record }"> 8 <template #deviceProfile="{ record }">
11 <a-button type="link" class="ml-2" @click="goDeviceProfile"> 9 <a-button type="link" class="ml-2" @click="goDeviceProfile">
12 {{ record.deviceProfile.name }} 10 {{ record.deviceProfile.name }}
13 </a-button> 11 </a-button>
14 </template> 12 </template>
  13 + <template #organizationId="{ record }">
  14 + {{ record.organizationDTO.name }}
  15 + </template>
15 <template #deviceType="{ record }"> 16 <template #deviceType="{ record }">
16 <Tag color="success" class="ml-2"> 17 <Tag color="success" class="ml-2">
17 {{ 18 {{
18 - record.deviceType == DeviceTypeEnum.GATEWAY 19 + record.deviceType === DeviceTypeEnum.GATEWAY
19 ? '网关设备' 20 ? '网关设备'
20 - : record.deviceType == DeviceTypeEnum.DIRECT_CONNECTION 21 + : record.deviceType === DeviceTypeEnum.DIRECT_CONNECTION
21 ? '直连设备' 22 ? '直连设备'
22 : '网关子设备' 23 : '网关子设备'
23 }} 24 }}
@@ -64,30 +65,44 @@ @@ -64,30 +65,44 @@
64 /> 65 />
65 </template> 66 </template>
66 </BasicTable> 67 </BasicTable>
67 - <ConfigDrawer @register="registerDrawer" @success="handleSuccess" />  
68 - </div> 68 + <!-- <ConfigDrawer @register="registerDrawer" @success="handleSuccess" /> -->
  69 + <DeviceModal @register="registerModal" @success="handleSuccess" />
  70 + </PageWrapper>
69 </template> 71 </template>
70 <script lang="ts"> 72 <script lang="ts">
71 - import { defineComponent, h } from 'vue'; 73 + import { defineComponent, reactive } from 'vue';
72 import { DeviceState, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; 74 import { DeviceState, DeviceTypeEnum } from '/@/api/device/model/deviceModel';
73 import { BasicTable, useTable, TableAction } from '/@/components/Table'; 75 import { BasicTable, useTable, TableAction } from '/@/components/Table';
74 - import { useDrawer } from '/@/components/Drawer';  
75 - import ConfigDrawer from './DeviceDrawer.vue';  
76 - import { columns, searchFormSchema } from './config.data';  
77 - import { Modal, Tag } from 'ant-design-vue';  
78 - import { CodeEditor, JsonPreview } from '/@/components/CodeEditor'; 76 + // import { useDrawer } from '/@/components/Drawer';
  77 + // import ConfigDrawer from './DeviceDrawer.vue';
  78 + import { columns, searchFormSchema } from './device.data';
  79 + import { Tag } from 'ant-design-vue';
79 import { useMessage } from '/@/hooks/web/useMessage'; 80 import { useMessage } from '/@/hooks/web/useMessage';
80 import { deleteDevice, devicePage } from '/@/api/device/deviceManager'; 81 import { deleteDevice, devicePage } from '/@/api/device/deviceManager';
81 import { PageEnum } from '/@/enums/pageEnum'; 82 import { PageEnum } from '/@/enums/pageEnum';
82 import { useGo } from '/@/hooks/web/usePage'; 83 import { useGo } from '/@/hooks/web/usePage';
  84 + import { PageWrapper } from '/@/components/Page';
  85 + import OrganizationIdTree from '/@/views/common/OrganizationIdTree.vue';
  86 + import { useModal } from '/@/components/Modal';
  87 + import DeviceModal from '/@/views/device/DeviceModal.vue';
83 88
84 export default defineComponent({ 89 export default defineComponent({
85 name: 'DeviceManagement', 90 name: 'DeviceManagement',
86 - components: { BasicTable, ConfigDrawer, TableAction, CodeEditor, Tag }, 91 + components: {
  92 + BasicTable,
  93 + // ConfigDrawer,
  94 + PageWrapper,
  95 + TableAction,
  96 + OrganizationIdTree,
  97 + Tag,
  98 + DeviceModal,
  99 + },
87 setup() { 100 setup() {
88 - const [registerDrawer, { openDrawer }] = useDrawer(); 101 + // const [registerDrawer, { openDrawer }] = useDrawer();
89 const { createMessage } = useMessage(); 102 const { createMessage } = useMessage();
90 const go = useGo(); 103 const go = useGo();
  104 + const searchInfo = reactive<Recordable>({});
  105 + const [registerModal, { openModal }] = useModal();
91 const [registerTable, { reload }] = useTable({ 106 const [registerTable, { reload }] = useTable({
92 title: '设备列表', 107 title: '设备列表',
93 api: devicePage, 108 api: devicePage,
@@ -100,6 +115,7 @@ @@ -100,6 +115,7 @@
100 showTableSetting: true, 115 showTableSetting: true,
101 bordered: true, 116 bordered: true,
102 showIndexColumn: false, 117 showIndexColumn: false,
  118 + searchInfo: searchInfo,
103 actionColumn: { 119 actionColumn: {
104 width: 180, 120 width: 180,
105 title: '操作', 121 title: '操作',
@@ -110,15 +126,15 @@ @@ -110,15 +126,15 @@
110 }); 126 });
111 127
112 function handleCreate() { 128 function handleCreate() {
113 - openDrawer(true, { 129 + openModal(true, {
114 isUpdate: false, 130 isUpdate: false,
115 }); 131 });
116 } 132 }
117 133
118 function handleEdit(record: Recordable) { 134 function handleEdit(record: Recordable) {
119 - openDrawer(true, {  
120 - record, 135 + openModal(true, {
121 isUpdate: true, 136 isUpdate: true,
  137 + record,
122 }); 138 });
123 } 139 }
124 140
@@ -133,20 +149,16 @@ @@ -133,20 +149,16 @@
133 function handleSuccess() { 149 function handleSuccess() {
134 reload(); 150 reload();
135 } 151 }
136 - function showData(record: Recordable) {  
137 - Modal.info({  
138 - title: '当前配置',  
139 - width: 480,  
140 - content: h(JsonPreview, { data: JSON.parse(JSON.stringify(record.deviceInfo)) }),  
141 - }); 152 + function handleSelect(organization) {
  153 + searchInfo.organizationId = organization;
  154 + handleSuccess();
142 } 155 }
143 function goDeviceProfile() { 156 function goDeviceProfile() {
144 go(PageEnum.DEVICE_PROFILE); 157 go(PageEnum.DEVICE_PROFILE);
145 } 158 }
146 return { 159 return {
147 registerTable, 160 registerTable,
148 - registerDrawer,  
149 - showData, 161 + // registerDrawer,
150 handleCreate, 162 handleCreate,
151 handleEdit, 163 handleEdit,
152 handleDelete, 164 handleDelete,
@@ -154,6 +166,9 @@ @@ -154,6 +166,9 @@
154 goDeviceProfile, 166 goDeviceProfile,
155 DeviceTypeEnum, 167 DeviceTypeEnum,
156 DeviceState, 168 DeviceState,
  169 + handleSelect,
  170 + searchInfo,
  171 + registerModal,
157 }; 172 };
158 }, 173 },
159 }); 174 });
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 width="500px" 7 width="500px"
8 @ok="handleSubmit" 8 @ok="handleSubmit"
9 > 9 >
10 - <BasicForm @register="registerForm"/> 10 + <BasicForm @register="registerForm" />
11 </BasicDrawer> 11 </BasicDrawer>
12 </template> 12 </template>
13 <script lang="ts"> 13 <script lang="ts">
@@ -15,8 +15,8 @@ @@ -15,8 +15,8 @@
15 import { BasicForm, useForm } from '/@/components/Form'; 15 import { BasicForm, useForm } from '/@/components/Form';
16 import { formSchema } from './device.profile.data'; 16 import { formSchema } from './device.profile.data';
17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; 17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
18 - import {saveOrEditMessageConfig} from "/@/api/message/config";  
19 - import {useMessage} from "/@/hooks/web/useMessage"; 18 + import { saveOrEditMessageConfig } from '/@/api/message/config';
  19 + import { useMessage } from '/@/hooks/web/useMessage';
20 20
21 export default defineComponent({ 21 export default defineComponent({
22 name: 'DeviceProfileDrawer', 22 name: 'DeviceProfileDrawer',
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 setup(_, { emit }) { 25 setup(_, { emit }) {
26 const isUpdate = ref(true); 26 const isUpdate = ref(true);
27 27
28 - const [registerForm, { validate,setFieldsValue,resetFields }] = useForm({ 28 + const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({
29 labelWidth: 120, 29 labelWidth: 120,
30 schemas: formSchema, 30 schemas: formSchema,
31 showActionButtonGroup: false, 31 showActionButtonGroup: false,
@@ -37,8 +37,8 @@ @@ -37,8 +37,8 @@
37 isUpdate.value = !!data?.isUpdate; 37 isUpdate.value = !!data?.isUpdate;
38 if (unref(isUpdate)) { 38 if (unref(isUpdate)) {
39 const config = data.record.config; 39 const config = data.record.config;
40 - for (const key in config){  
41 - Reflect.set(data.record, key+'', config[key]); 40 + for (const key in config) {
  41 + Reflect.set(data.record, key + '', config[key]);
42 } 42 }
43 await setFieldsValue({ 43 await setFieldsValue({
44 ...data.record, 44 ...data.record,
@@ -53,27 +53,27 @@ @@ -53,27 +53,27 @@
53 const values = await validate(); 53 const values = await validate();
54 const { createMessage } = useMessage(); 54 const { createMessage } = useMessage();
55 setDrawerProps({ confirmLoading: true }); 55 setDrawerProps({ confirmLoading: true });
56 - let config={};  
57 - if(values.messageType === 'PHONE_MESSAGE'){  
58 - config ={  
59 - "accessKeyId":values.accessKeyId,  
60 - "accessKeySecret":values.accessKeySecret,  
61 - }  
62 - }else if(values.messageType === 'EMAIL_MESSAGE'){  
63 - config ={  
64 - "host":values.host,  
65 - "port":values.port,  
66 - "username":values.username,  
67 - "password":values.password,  
68 - } 56 + let config = {};
  57 + if (values.messageType === 'PHONE_MESSAGE') {
  58 + config = {
  59 + accessKeyId: values.accessKeyId,
  60 + accessKeySecret: values.accessKeySecret,
  61 + };
  62 + } else if (values.messageType === 'EMAIL_MESSAGE') {
  63 + config = {
  64 + host: values.host,
  65 + port: values.port,
  66 + username: values.username,
  67 + password: values.password,
  68 + };
69 } 69 }
70 Reflect.set(values, 'config', config); 70 Reflect.set(values, 'config', config);
71 - let saveMessage = "添加成功";  
72 - let updateMessage = "修改成功"; 71 + let saveMessage = '添加成功';
  72 + let updateMessage = '修改成功';
73 await saveOrEditMessageConfig(values, unref(isUpdate)); 73 await saveOrEditMessageConfig(values, unref(isUpdate));
74 closeDrawer(); 74 closeDrawer();
75 emit('success'); 75 emit('success');
76 - createMessage.success(unref(isUpdate)?updateMessage:saveMessage); 76 + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage);
77 } finally { 77 } finally {
78 setDrawerProps({ confirmLoading: false }); 78 setDrawerProps({ confirmLoading: false });
79 } 79 }
1 import { BasicColumn } from '/@/components/Table'; 1 import { BasicColumn } from '/@/components/Table';
2 import { FormSchema } from '/@/components/Table'; 2 import { FormSchema } from '/@/components/Table';
3 -import {findDictItemByCode} from "/@/api/system/dict";  
4 -import {MessageEnum} from "/@/enums/messageEnum"; 3 +import { findDictItemByCode } from '/@/api/system/dict';
  4 +import { MessageEnum } from '/@/enums/messageEnum';
5 export const columns: BasicColumn[] = [ 5 export const columns: BasicColumn[] = [
6 { 6 {
7 title: '配置名称', 7 title: '配置名称',
@@ -34,20 +34,19 @@ export const searchFormSchema: FormSchema[] = [ @@ -34,20 +34,19 @@ export const searchFormSchema: FormSchema[] = [
34 }, 34 },
35 ]; 35 ];
36 36
37 -  
38 -export const isMessage = (type:string)=>{  
39 - return type===MessageEnum.IS_SMS;  
40 -}  
41 -export const isEmail = (type:string)=>{  
42 - return type===MessageEnum.IS_EMAIL;  
43 -} 37 +export const isMessage = (type: string) => {
  38 + return type === MessageEnum.IS_SMS;
  39 +};
  40 +export const isEmail = (type: string) => {
  41 + return type === MessageEnum.IS_EMAIL;
  42 +};
44 43
45 export const formSchema: FormSchema[] = [ 44 export const formSchema: FormSchema[] = [
46 { 45 {
47 field: 'configName', 46 field: 'configName',
48 label: '配置名称', 47 label: '配置名称',
49 required: true, 48 required: true,
50 - component:'Input' 49 + component: 'Input',
51 }, 50 },
52 { 51 {
53 field: 'messageType', 52 field: 'messageType',
@@ -55,12 +54,12 @@ export const formSchema: FormSchema[] = [ @@ -55,12 +54,12 @@ export const formSchema: FormSchema[] = [
55 required: true, 54 required: true,
56 component: 'ApiSelect', 55 component: 'ApiSelect',
57 componentProps: { 56 componentProps: {
58 - api:findDictItemByCode,  
59 - params:{  
60 - dictCode:"message_type" 57 + api: findDictItemByCode,
  58 + params: {
  59 + dictCode: 'message_type',
61 }, 60 },
62 - labelField:'itemText',  
63 - valueField:'itemValue', 61 + labelField: 'itemText',
  62 + valueField: 'itemValue',
64 }, 63 },
65 }, 64 },
66 { 65 {
@@ -69,70 +68,70 @@ export const formSchema: FormSchema[] = [ @@ -69,70 +68,70 @@ export const formSchema: FormSchema[] = [
69 required: true, 68 required: true,
70 component: 'ApiSelect', 69 component: 'ApiSelect',
71 componentProps: { 70 componentProps: {
72 - api:findDictItemByCode,  
73 - params:{  
74 - dictCode:"platform_type" 71 + api: findDictItemByCode,
  72 + params: {
  73 + dictCode: 'platform_type',
75 }, 74 },
76 - labelField:'itemText',  
77 - valueField:'itemValue', 75 + labelField: 'itemText',
  76 + valueField: 'itemValue',
78 }, 77 },
79 - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), 78 + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
80 }, 79 },
81 { 80 {
82 field: 'accessKeyId', 81 field: 'accessKeyId',
83 label: 'accessKeyId', 82 label: 'accessKeyId',
84 required: true, 83 required: true,
85 - component:'Input',  
86 - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), 84 + component: 'Input',
  85 + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
87 }, 86 },
88 { 87 {
89 field: 'accessKeySecret', 88 field: 'accessKeySecret',
90 label: 'accessKeySecret', 89 label: 'accessKeySecret',
91 required: true, 90 required: true,
92 - component:'Input',  
93 - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), 91 + component: 'Input',
  92 + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
94 }, 93 },
95 { 94 {
96 field: 'host', 95 field: 'host',
97 label: '服务器地址', 96 label: '服务器地址',
98 - defaultValue:'smtp.163.com', 97 + defaultValue: 'smtp.163.com',
99 required: true, 98 required: true,
100 - component:'Input',  
101 - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), 99 + component: 'Input',
  100 + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
102 }, 101 },
103 { 102 {
104 field: 'port', 103 field: 'port',
105 label: '端口', 104 label: '端口',
106 defaultValue: 25, 105 defaultValue: 25,
107 required: true, 106 required: true,
108 - component:'InputNumber',  
109 - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), 107 + component: 'InputNumber',
  108 + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
110 }, 109 },
111 { 110 {
112 field: 'username', 111 field: 'username',
113 label: '用户名', 112 label: '用户名',
114 required: true, 113 required: true,
115 - component:'Input',  
116 - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), 114 + component: 'Input',
  115 + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
117 }, 116 },
118 { 117 {
119 field: 'password', 118 field: 'password',
120 label: '密码', 119 label: '密码',
121 required: true, 120 required: true,
122 - component:'InputPassword',  
123 - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), 121 + component: 'InputPassword',
  122 + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
124 }, 123 },
125 { 124 {
126 field: 'config', 125 field: 'config',
127 label: '消息配置', 126 label: '消息配置',
128 - component:'Input',  
129 - show:false, 127 + component: 'Input',
  128 + show: false,
130 }, 129 },
131 { 130 {
132 field: 'id', 131 field: 'id',
133 label: '主键', 132 label: '主键',
134 - component:'Input',  
135 - show:false, 133 + component: 'Input',
  134 + show: false,
136 }, 135 },
137 { 136 {
138 field: 'status', 137 field: 'status',
@@ -150,5 +149,5 @@ export const formSchema: FormSchema[] = [ @@ -150,5 +149,5 @@ export const formSchema: FormSchema[] = [
150 label: '备注', 149 label: '备注',
151 field: 'remark', 150 field: 'remark',
152 component: 'InputTextArea', 151 component: 'InputTextArea',
153 - } 152 + },
154 ]; 153 ];
@@ -8,18 +8,18 @@ @@ -8,18 +8,18 @@
8 <TableAction 8 <TableAction
9 :actions="[ 9 :actions="[
10 { 10 {
11 - label:'编辑', 11 + label: '编辑',
12 icon: 'clarity:note-edit-line', 12 icon: 'clarity:note-edit-line',
13 onClick: handleEdit.bind(null, record), 13 onClick: handleEdit.bind(null, record),
14 }, 14 },
15 { 15 {
16 - label:'删除', 16 + label: '删除',
17 icon: 'ant-design:delete-outlined', 17 icon: 'ant-design:delete-outlined',
18 color: 'error', 18 color: 'error',
19 popConfirm: { 19 popConfirm: {
20 title: '是否确认删除', 20 title: '是否确认删除',
21 confirm: handleDelete.bind(null, record), 21 confirm: handleDelete.bind(null, record),
22 - } 22 + },
23 }, 23 },
24 ]" 24 ]"
25 /> 25 />
@@ -29,71 +29,71 @@ @@ -29,71 +29,71 @@
29 </div> 29 </div>
30 </template> 30 </template>
31 <script lang="ts"> 31 <script lang="ts">
32 -import { defineComponent} from 'vue';  
33 -import { BasicTable, useTable, TableAction } from '/@/components/Table';  
34 -import { useDrawer } from '/@/components/Drawer';  
35 -import DeviceProfileDrawer from './DeviceProfile.vue';  
36 -import { columns, searchFormSchema } from './device.profile.data';  
37 -import {useMessage} from "/@/hooks/web/useMessage";  
38 -import {deviceProfilePage,deleteDeviceProfile} from "/@/api/device/deviceManager";  
39 -export default defineComponent({  
40 - name: 'DeviceProfileManagement',  
41 - components: { BasicTable, DeviceProfileDrawer, TableAction},  
42 - setup() {  
43 - const [registerDrawer, { openDrawer }] = useDrawer();  
44 - const {createMessage} = useMessage();  
45 - const [registerTable, { reload }] = useTable({  
46 - title: '设备配置列表',  
47 - api: deviceProfilePage,  
48 - columns,  
49 - formConfig: {  
50 - labelWidth: 120,  
51 - schemas: searchFormSchema,  
52 - },  
53 - useSearchForm: true,  
54 - showTableSetting: true,  
55 - bordered: true,  
56 - showIndexColumn: false,  
57 - actionColumn: {  
58 - width: 180,  
59 - title: '操作',  
60 - dataIndex: 'action',  
61 - slots: { customRender: 'action' },  
62 - },  
63 - });  
64 -  
65 - function handleCreate() {  
66 - openDrawer(true, {  
67 - isUpdate: false, 32 + import { defineComponent } from 'vue';
  33 + import { BasicTable, useTable, TableAction } from '/@/components/Table';
  34 + import { useDrawer } from '/@/components/Drawer';
  35 + import DeviceProfileDrawer from './DeviceProfile.vue';
  36 + import { columns, searchFormSchema } from './device.profile.data';
  37 + import { useMessage } from '/@/hooks/web/useMessage';
  38 + import { deviceProfilePage, deleteDeviceProfile } from '/@/api/device/deviceManager';
  39 + export default defineComponent({
  40 + name: 'DeviceProfileManagement',
  41 + components: { BasicTable, DeviceProfileDrawer, TableAction },
  42 + setup() {
  43 + const [registerDrawer, { openDrawer }] = useDrawer();
  44 + const { createMessage } = useMessage();
  45 + const [registerTable, { reload }] = useTable({
  46 + title: '设备配置列表',
  47 + api: deviceProfilePage,
  48 + columns,
  49 + formConfig: {
  50 + labelWidth: 120,
  51 + schemas: searchFormSchema,
  52 + },
  53 + useSearchForm: true,
  54 + showTableSetting: true,
  55 + bordered: true,
  56 + showIndexColumn: false,
  57 + actionColumn: {
  58 + width: 180,
  59 + title: '操作',
  60 + dataIndex: 'action',
  61 + slots: { customRender: 'action' },
  62 + },
68 }); 63 });
69 - }  
70 64
71 - function handleEdit(record: Recordable) {  
72 - openDrawer(true, {  
73 - record,  
74 - isUpdate: true,  
75 - });  
76 - } 65 + function handleCreate() {
  66 + openDrawer(true, {
  67 + isUpdate: false,
  68 + });
  69 + }
77 70
78 - function handleDelete(record: Recordable) {  
79 - let ids = [record.id];  
80 - deleteDeviceProfile(ids).then(()=>{  
81 - createMessage.success("删除设备配置成功")  
82 - handleSuccess()  
83 - });  
84 - } 71 + function handleEdit(record: Recordable) {
  72 + openDrawer(true, {
  73 + record,
  74 + isUpdate: true,
  75 + });
  76 + }
  77 +
  78 + function handleDelete(record: Recordable) {
  79 + let ids = [record.id];
  80 + deleteDeviceProfile(ids).then(() => {
  81 + createMessage.success('删除设备配置成功');
  82 + handleSuccess();
  83 + });
  84 + }
85 85
86 - function handleSuccess() {  
87 - reload();  
88 - }  
89 - return {  
90 - registerTable,  
91 - registerDrawer,  
92 - handleCreate,  
93 - handleEdit,  
94 - handleDelete,  
95 - handleSuccess,  
96 - };  
97 - },  
98 -}); 86 + function handleSuccess() {
  87 + reload();
  88 + }
  89 + return {
  90 + registerTable,
  91 + registerDrawer,
  92 + handleCreate,
  93 + handleEdit,
  94 + handleDelete,
  95 + handleSuccess,
  96 + };
  97 + },
  98 + });
99 </script> 99 </script>
  1 +<template>
  2 + <div class="step1">
  3 + <div class="step1-form">
  4 + <BasicForm @register="register">
  5 + <template #iconSelect>
  6 + <Upload
  7 + name="avatar"
  8 + list-type="picture-card"
  9 + class="avatar-uploader"
  10 + :show-upload-list="false"
  11 + :customRequest="customUpload"
  12 + :before-upload="beforeUpload"
  13 + >
  14 + <img v-if="devicePic" :src="devicePic" alt="avatar" />
  15 + <div v-else>
  16 + <!-- <LoadingOutlined v-if="loading" /> -->
  17 + <PlusOutlined />
  18 + <div class="ant-upload-text">图片上传</div>
  19 + </div>
  20 + </Upload>
  21 + </template>
  22 + <template #devicePosition>
  23 + <Input disabled v-model:value="positionState.address">
  24 + <template #addonAfter>
  25 + <EnvironmentTwoTone @click="selectPosition" />
  26 + </template>
  27 + </Input>
  28 + </template>
  29 + </BasicForm>
  30 + </div>
  31 + <Modal v-model:visible="visible" title="设备位置" @ok="handleOk" width="800px">
  32 + <div>
  33 + <a-form :label-col="labelCol">
  34 + <a-row :gutter="20">
  35 + <a-col :span="8">
  36 + <a-form-item label="经度">
  37 + <Input type="input" v-model:value="positionState.lng" disabled />
  38 + </a-form-item>
  39 + </a-col>
  40 + <a-col :span="8">
  41 + <a-form-item label="纬度">
  42 + <Input type="input" v-model:value="positionState.lat" disabled />
  43 + </a-form-item>
  44 + </a-col>
  45 + </a-row>
  46 + </a-form>
  47 + <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div>
  48 + </div>
  49 + </Modal>
  50 + </div>
  51 +</template>
  52 +<script lang="ts">
  53 + import { defineComponent, ref, nextTick, unref, reactive } from 'vue';
  54 + import { BasicForm, useForm } from '/@/components/Form';
  55 + import { step1Schemas } from './data';
  56 + import { useScript } from '/@/hooks/web/useScript';
  57 + import { ScrollActionType } from '/@/components/Container/index';
  58 + import { Input, Divider, Upload, message, Modal, Form, Row, Col } from 'ant-design-vue';
  59 + import { EnvironmentTwoTone, LoadingOutlined, PlusOutlined } from '@ant-design/icons-vue';
  60 + import { upload } from '/@/api/oss/ossFileUploader';
  61 + import { FileItem } from '/@/components/Upload/src/typing';
  62 +
  63 + export default defineComponent({
  64 + components: {
  65 + BasicForm,
  66 + Input,
  67 + [Input.Group.name]: Input.Group,
  68 + [Divider.name]: Divider,
  69 + Upload,
  70 + EnvironmentTwoTone,
  71 + // LoadingOutlined,
  72 + PlusOutlined,
  73 + Modal,
  74 + [Form.name]: Form,
  75 + [Form.Item.name]: Form.Item,
  76 + [Row.name]: Row,
  77 + [Col.name]: Col,
  78 + },
  79 + emits: ['next'],
  80 + setup(_, { emit }) {
  81 + const devicePic = ref('');
  82 + const positionState = reactive({
  83 + lng: '',
  84 + lat: '',
  85 + address: '',
  86 + });
  87 + const [register, { validate }] = useForm({
  88 + labelWidth: 100,
  89 + schemas: step1Schemas,
  90 + actionColOptions: {
  91 + span: 14,
  92 + },
  93 + showResetButton: false,
  94 + submitButtonOptions: {
  95 + text: '下一步',
  96 + },
  97 + submitFunc: customSubmitFunc,
  98 + });
  99 +
  100 + async function customSubmitFunc() {
  101 + try {
  102 + let values = await validate();
  103 + values = { devicePic: devicePic.value, ...positionState, ...values };
  104 + delete values.icon;
  105 + delete values.devicePosition;
  106 + emit('next', values);
  107 + // 获取输入的数据
  108 + } catch (error) {}
  109 + }
  110 + // 图片上传
  111 + async function customUpload({ file }) {
  112 + if (beforeUpload(file)) {
  113 + const formData = new FormData();
  114 + formData.append('file', file);
  115 + const response = await upload(formData);
  116 + if (response.fileStaticUri) {
  117 + devicePic.value = response.fileStaticUri;
  118 + }
  119 + }
  120 + }
  121 + const beforeUpload = (file: FileItem) => {
  122 + const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
  123 + if (!isJpgOrPng) {
  124 + message.error('只能上传图片文件!');
  125 + }
  126 + const isLt2M = (file.size as number) / 1024 / 1024 < 2;
  127 + if (!isLt2M) {
  128 + message.error('图片大小不能超过2MB!');
  129 + }
  130 + return isJpgOrPng && isLt2M;
  131 + };
  132 +
  133 + // 地图的弹框
  134 + const visible = ref(false);
  135 + const selectPosition = () => {
  136 + visible.value = true;
  137 + initMap();
  138 + };
  139 +
  140 + // 地图
  141 + const BAI_DU_MAP_URL =
  142 + 'https://api.map.baidu.com/getscript?v=3.0&ak=7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa';
  143 + const wrapRef = ref<HTMLDivElement | null>(null);
  144 + const scrollRef = ref<Nullable<ScrollActionType>>(null);
  145 + const { toPromise } = useScript({ src: BAI_DU_MAP_URL });
  146 + async function initMap() {
  147 + await toPromise();
  148 + await nextTick();
  149 + const wrapEl = unref(wrapRef);
  150 + const BMap = (window as any).BMap;
  151 + if (!wrapEl) return;
  152 + const map = new BMap.Map(wrapEl);
  153 + map.addEventListener('click', () => {
  154 + const { lat, lng } = map.he;
  155 + positionState.lat = lat + '';
  156 + positionState.lng = lng + '';
  157 + let gc = new BMap.Geocoder();
  158 + let newPoint = new BMap.Point(lng, lat);
  159 + gc.getLocation(newPoint, (rs) => {
  160 + let addComp = rs.addressComponents;
  161 + //获取详细的地址,精确到街道的名称
  162 + let addrname = addComp.city + addComp.district + addComp.street + addComp.streetNumber;
  163 + positionState.address = addrname;
  164 + });
  165 + });
  166 + const point = new BMap.Point(104.04813399999999, 30.54348986021446);
  167 + map.centerAndZoom(point, 15);
  168 + map.enableScrollWheelZoom(true);
  169 + }
  170 + // 确定选择的位置
  171 + const handleOk = () => {
  172 + visible.value = false;
  173 + };
  174 + return {
  175 + positionState,
  176 + register,
  177 + beforeUpload,
  178 + customUpload,
  179 + selectPosition,
  180 + devicePic,
  181 + visible,
  182 + scrollRef,
  183 + handleOk,
  184 + wrapRef,
  185 + labelCol: { style: { width: '40px' } },
  186 + };
  187 + },
  188 + });
  189 +</script>
  190 +<style lang="less" scoped>
  191 + .step1 {
  192 + &-form {
  193 + width: 450px;
  194 + margin: 0 auto;
  195 + }
  196 +
  197 + h3 {
  198 + margin: 0 0 12px;
  199 + font-size: 16px;
  200 + line-height: 32px;
  201 + color: @text-color;
  202 + }
  203 +
  204 + h4 {
  205 + margin: 0 0 4px;
  206 + font-size: 14px;
  207 + line-height: 22px;
  208 + color: @text-color;
  209 + }
  210 +
  211 + p {
  212 + color: @text-color;
  213 + }
  214 + }
  215 +
  216 + .pay-select {
  217 + width: 20%;
  218 + }
  219 +
  220 + .pay-input {
  221 + width: 70%;
  222 + }
  223 +</style>
  1 +<template>
  2 + <div class="step2">
  3 + <div><input type="checkbox" v-model="isCreaentials" @click="checked" /> 添加凭证 </div>
  4 +
  5 + <a-form :label-col="labelCol" :wrapper-col="wrapperCol" v-if="isCreaentials">
  6 + <a-form-item label="凭据类型">
  7 + <a-select
  8 + v-model:value="creaentialsType"
  9 + style="width: 200px"
  10 + @change="handleChange"
  11 + placeholder="请选择凭据类型"
  12 + :options="options"
  13 + />
  14 + </a-form-item>
  15 + <div v-if="creaentialsType === 'Access token'">
  16 + <a-form-item label="访问令牌">
  17 + <a-input type="input" style="width: 200px" v-model:value="token" />
  18 + </a-form-item>
  19 + </div>
  20 + <div v-else-if="creaentialsType === 'X.509'">
  21 + <a-form-item label="RSA公钥">
  22 + <a-input type="input" style="width: 200px" v-model:value="publicKey" />
  23 + </a-form-item>
  24 + </div>
  25 + <div v-else>
  26 + <a-form-item label="客户端ID">
  27 + <a-input type="input" style="width: 200px" v-model:value="clientId" />
  28 + </a-form-item>
  29 + <a-form-item label="用户名">
  30 + <a-input type="input" style="width: 200px" v-model:value="username" />
  31 + </a-form-item>
  32 + <a-form-item label="密码">
  33 + <a-input type="password" style="width: 200px" v-model:value="password" />
  34 + </a-form-item>
  35 + </div>
  36 + </a-form>
  37 +
  38 + <div class="flex justify-start">
  39 + <a-button class="mr-5" @click="prevStep">上一步</a-button>
  40 + </div>
  41 + </div>
  42 +</template>
  43 +<script lang="ts">
  44 + import { defineComponent, reactive, ref, toRefs } from 'vue';
  45 +
  46 + import { Input, Form, Select, Button, SelectProps } from 'ant-design-vue';
  47 + export default defineComponent({
  48 + components: {
  49 + [Form.name]: Form,
  50 + [Form.Item.name]: Form.Item,
  51 + [Input.name]: Input,
  52 + [Select.name]: Select,
  53 + [Button.name]: Button,
  54 + },
  55 + emits: ['prev'],
  56 + setup(_, { emit }) {
  57 + const isCreaentials = ref(false);
  58 + const creaentialsType = ref('Access token');
  59 + const creaentialsPassword = reactive({
  60 + token: '',
  61 + publicKey: '',
  62 + clientId: '',
  63 + username: '',
  64 + password: '',
  65 + });
  66 + const options = ref<SelectProps['options']>([
  67 + {
  68 + value: 'Access token',
  69 + label: 'Access token',
  70 + },
  71 +
  72 + {
  73 + value: 'X.509',
  74 + label: 'X.509',
  75 + },
  76 + {
  77 + value: 'MQTT Basic',
  78 + label: 'MQTT Basic',
  79 + },
  80 + ]);
  81 + const checked = () => {
  82 + isCreaentials.value = !isCreaentials.value;
  83 + };
  84 + const prevStep = () => {
  85 + emit('prev');
  86 + };
  87 + // 切换凭证类型时,重置字段
  88 + const handleChange = (value) => {
  89 + if (value === 'Access token') {
  90 + creaentialsPassword.token = '';
  91 + } else if (value === 'X.509') {
  92 + creaentialsPassword.publicKey = '';
  93 + } else {
  94 + creaentialsPassword.clientId = '';
  95 + creaentialsPassword.username = '';
  96 + creaentialsPassword.password = '';
  97 + }
  98 + };
  99 + return {
  100 + ...toRefs(creaentialsPassword),
  101 + creaentialsType,
  102 + isCreaentials,
  103 + options,
  104 + handleChange,
  105 + prevStep,
  106 + checked,
  107 + labelCol: { style: { width: '150px' } },
  108 + wrapperCol: { span: 18 },
  109 + };
  110 + },
  111 + });
  112 +</script>
  113 +<style lang="less" scoped>
  114 + .step2 {
  115 + width: 500px;
  116 + margin: 0 auto;
  117 + }
  118 +</style>
  1 +<template>
  2 + <PageWrapper
  3 + title="分步表单"
  4 + contentBackground
  5 + content=" 将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。"
  6 + contentClass="p-4"
  7 + >
  8 + <div class="step-form-form">
  9 + <a-steps :current="current">
  10 + <a-step title="填写转账信息" />
  11 + <a-step title="确认转账信息" />
  12 + <a-step title="完成" />
  13 + </a-steps>
  14 + </div>
  15 + <div class="mt-5">
  16 + <Step1 @next="handleStep1Next" v-show="current === 0" />
  17 + <Step2
  18 + @prev="handleStepPrev"
  19 + @next="handleStep2Next"
  20 + v-show="current === 1"
  21 + v-if="initSetp2"
  22 + />
  23 + </div>
  24 + </PageWrapper>
  25 +</template>
  26 +<script lang="ts">
  27 + import { defineComponent, ref, reactive, toRefs } from 'vue';
  28 + import Step1 from './DeviceStep1.vue';
  29 + import Step2 from './DeviceStep2.vue';
  30 + import { PageWrapper } from '/@/components/Page';
  31 + import { Steps } from 'ant-design-vue';
  32 +
  33 + export default defineComponent({
  34 + name: 'FormStepPage',
  35 + components: {
  36 + Step1,
  37 + Step2,
  38 +
  39 + PageWrapper,
  40 + [Steps.name]: Steps,
  41 + [Steps.Step.name]: Steps.Step,
  42 + },
  43 + setup() {
  44 + const current = ref(1);
  45 +
  46 + const state = reactive({
  47 + initSetp2: false,
  48 + });
  49 +
  50 + function handleStep1Next(step1Values: any) {
  51 + current.value++;
  52 + state.initSetp2 = true;
  53 + console.log(step1Values);
  54 + }
  55 +
  56 + function handleStepPrev() {
  57 + current.value--;
  58 + }
  59 +
  60 + function handleStep2Next(step2Values: any) {
  61 + current.value++;
  62 + console.log(step2Values);
  63 + }
  64 +
  65 + function handleRedo() {
  66 + current.value = 0;
  67 + state.initSetp2 = false;
  68 + }
  69 +
  70 + return {
  71 + current,
  72 + handleStep1Next,
  73 + handleStep2Next,
  74 + handleRedo,
  75 + handleStepPrev,
  76 + ...toRefs(state),
  77 + };
  78 + },
  79 + });
  80 +</script>
  81 +<style lang="less" scoped>
  82 + .step-form-content {
  83 + padding: 24px;
  84 + background-color: @component-background;
  85 + }
  86 +
  87 + .step-form-form {
  88 + width: 750px;
  89 + margin: 0 auto;
  90 + }
  91 +</style>
  1 +import { FormSchema } from '/@/components/Form';
  2 +import { findDictItemByCode } from '/@/api/system/dict';
  3 +
  4 +export const step1Schemas: FormSchema[] = [
  5 + {
  6 + field: 'icon',
  7 + label: '设备图片: ',
  8 + slot: 'iconSelect',
  9 + component: 'Input',
  10 + },
  11 + {
  12 + field: 'name',
  13 + label: '设备名称',
  14 + required: true,
  15 + component: 'Input',
  16 + componentProps: {
  17 + maxLength: 30,
  18 + },
  19 + },
  20 + {
  21 + field: 'deviceType',
  22 + label: '设备类型',
  23 + required: true,
  24 + component: 'ApiSelect',
  25 + componentProps: {
  26 + api: findDictItemByCode,
  27 + params: {
  28 + dictCode: 'device_type',
  29 + },
  30 + labelField: 'itemText',
  31 + valueField: 'itemValue',
  32 + },
  33 + },
  34 + {
  35 + field: 'label',
  36 + label: '设备标签',
  37 + component: 'Input',
  38 + componentProps: {
  39 + maxLength: 255,
  40 + },
  41 + },
  42 + {
  43 + field: 'devicePosition',
  44 + label: '设备位置',
  45 + component: 'Input',
  46 + slot: 'devicePosition',
  47 + },
  48 + {
  49 + label: '备注',
  50 + field: 'remark',
  51 + component: 'InputTextArea',
  52 + },
  53 +];
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 width="500px" 7 width="500px"
8 @ok="handleSubmit" 8 @ok="handleSubmit"
9 > 9 >
10 - <BasicForm @register="registerForm"/> 10 + <BasicForm @register="registerForm" />
11 </BasicDrawer> 11 </BasicDrawer>
12 </template> 12 </template>
13 <script lang="ts"> 13 <script lang="ts">
@@ -15,8 +15,8 @@ @@ -15,8 +15,8 @@
15 import { BasicForm, useForm } from '/@/components/Form'; 15 import { BasicForm, useForm } from '/@/components/Form';
16 import { formSchema } from './config.data'; 16 import { formSchema } from './config.data';
17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; 17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
18 - import {saveOrEditMessageConfig} from "/@/api/message/config";  
19 - import {useMessage} from "/@/hooks/web/useMessage"; 18 + import { saveOrEditMessageConfig } from '/@/api/message/config';
  19 + import { useMessage } from '/@/hooks/web/useMessage';
20 20
21 export default defineComponent({ 21 export default defineComponent({
22 name: 'ConfigDrawer', 22 name: 'ConfigDrawer',
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 setup(_, { emit }) { 25 setup(_, { emit }) {
26 const isUpdate = ref(true); 26 const isUpdate = ref(true);
27 27
28 - const [registerForm, { validate,setFieldsValue,resetFields }] = useForm({ 28 + const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({
29 labelWidth: 120, 29 labelWidth: 120,
30 schemas: formSchema, 30 schemas: formSchema,
31 showActionButtonGroup: false, 31 showActionButtonGroup: false,
@@ -37,8 +37,8 @@ @@ -37,8 +37,8 @@
37 isUpdate.value = !!data?.isUpdate; 37 isUpdate.value = !!data?.isUpdate;
38 if (unref(isUpdate)) { 38 if (unref(isUpdate)) {
39 const config = data.record.config; 39 const config = data.record.config;
40 - for (const key in config){  
41 - Reflect.set(data.record, key+'', config[key]); 40 + for (const key in config) {
  41 + Reflect.set(data.record, key + '', config[key]);
42 } 42 }
43 await setFieldsValue({ 43 await setFieldsValue({
44 ...data.record, 44 ...data.record,
@@ -53,27 +53,27 @@ @@ -53,27 +53,27 @@
53 const values = await validate(); 53 const values = await validate();
54 const { createMessage } = useMessage(); 54 const { createMessage } = useMessage();
55 setDrawerProps({ confirmLoading: true }); 55 setDrawerProps({ confirmLoading: true });
56 - let config={};  
57 - if(values.messageType === 'PHONE_MESSAGE'){  
58 - config ={  
59 - "accessKeyId":values.accessKeyId,  
60 - "accessKeySecret":values.accessKeySecret,  
61 - }  
62 - }else if(values.messageType === 'EMAIL_MESSAGE'){  
63 - config ={  
64 - "host":values.host,  
65 - "port":values.port,  
66 - "username":values.username,  
67 - "password":values.password,  
68 - } 56 + let config = {};
  57 + if (values.messageType === 'PHONE_MESSAGE') {
  58 + config = {
  59 + accessKeyId: values.accessKeyId,
  60 + accessKeySecret: values.accessKeySecret,
  61 + };
  62 + } else if (values.messageType === 'EMAIL_MESSAGE') {
  63 + config = {
  64 + host: values.host,
  65 + port: values.port,
  66 + username: values.username,
  67 + password: values.password,
  68 + };
69 } 69 }
70 Reflect.set(values, 'config', config); 70 Reflect.set(values, 'config', config);
71 - let saveMessage = "添加成功";  
72 - let updateMessage = "修改成功"; 71 + let saveMessage = '添加成功';
  72 + let updateMessage = '修改成功';
73 await saveOrEditMessageConfig(values, unref(isUpdate)); 73 await saveOrEditMessageConfig(values, unref(isUpdate));
74 closeDrawer(); 74 closeDrawer();
75 emit('success'); 75 emit('success');
76 - createMessage.success(unref(isUpdate)?updateMessage:saveMessage); 76 + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage);
77 } finally { 77 } finally {
78 setDrawerProps({ confirmLoading: false }); 78 setDrawerProps({ confirmLoading: false });
79 } 79 }
@@ -2,10 +2,10 @@ import { BasicColumn } from '/@/components/Table'; @@ -2,10 +2,10 @@ import { BasicColumn } from '/@/components/Table';
2 import { FormSchema } from '/@/components/Table'; 2 import { FormSchema } from '/@/components/Table';
3 import { h } from 'vue'; 3 import { h } from 'vue';
4 import { Switch } from 'ant-design-vue'; 4 import { Switch } from 'ant-design-vue';
5 -import {setMessageConfigStatus} from "/@/api/message/config"; 5 +import { setMessageConfigStatus } from '/@/api/message/config';
6 import { useMessage } from '/@/hooks/web/useMessage'; 6 import { useMessage } from '/@/hooks/web/useMessage';
7 -import {findDictItemByCode} from "/@/api/system/dict";  
8 -import {MessageEnum} from "/@/enums/messageEnum"; 7 +import { findDictItemByCode } from '/@/api/system/dict';
  8 +import { MessageEnum } from '/@/enums/messageEnum';
9 export const columns: BasicColumn[] = [ 9 export const columns: BasicColumn[] = [
10 { 10 {
11 title: '配置名称', 11 title: '配置名称',
@@ -45,7 +45,7 @@ export const columns: BasicColumn[] = [ @@ -45,7 +45,7 @@ export const columns: BasicColumn[] = [
45 record.pendingStatus = true; 45 record.pendingStatus = true;
46 const newStatus = checked ? 1 : 0; 46 const newStatus = checked ? 1 : 0;
47 const { createMessage } = useMessage(); 47 const { createMessage } = useMessage();
48 - setMessageConfigStatus(record.id, record.messageType,newStatus) 48 + setMessageConfigStatus(record.id, record.messageType, newStatus)
49 .then(() => { 49 .then(() => {
50 record.status = newStatus; 50 record.status = newStatus;
51 createMessage.success(`修改成功`); 51 createMessage.success(`修改成功`);
@@ -96,20 +96,19 @@ export const searchFormSchema: FormSchema[] = [ @@ -96,20 +96,19 @@ export const searchFormSchema: FormSchema[] = [
96 }, 96 },
97 ]; 97 ];
98 98
99 -  
100 -export const isMessage = (type:string)=>{  
101 - return type===MessageEnum.IS_SMS;  
102 -}  
103 -export const isEmail = (type:string)=>{  
104 - return type===MessageEnum.IS_EMAIL;  
105 -} 99 +export const isMessage = (type: string) => {
  100 + return type === MessageEnum.IS_SMS;
  101 +};
  102 +export const isEmail = (type: string) => {
  103 + return type === MessageEnum.IS_EMAIL;
  104 +};
106 105
107 export const formSchema: FormSchema[] = [ 106 export const formSchema: FormSchema[] = [
108 { 107 {
109 field: 'configName', 108 field: 'configName',
110 label: '配置名称', 109 label: '配置名称',
111 required: true, 110 required: true,
112 - component:'Input' 111 + component: 'Input',
113 }, 112 },
114 { 113 {
115 field: 'messageType', 114 field: 'messageType',
@@ -117,12 +116,12 @@ export const formSchema: FormSchema[] = [ @@ -117,12 +116,12 @@ export const formSchema: FormSchema[] = [
117 required: true, 116 required: true,
118 component: 'ApiSelect', 117 component: 'ApiSelect',
119 componentProps: { 118 componentProps: {
120 - api:findDictItemByCode,  
121 - params:{  
122 - dictCode:"message_type" 119 + api: findDictItemByCode,
  120 + params: {
  121 + dictCode: 'message_type',
123 }, 122 },
124 - labelField:'itemText',  
125 - valueField:'itemValue', 123 + labelField: 'itemText',
  124 + valueField: 'itemValue',
126 }, 125 },
127 }, 126 },
128 { 127 {
@@ -131,70 +130,70 @@ export const formSchema: FormSchema[] = [ @@ -131,70 +130,70 @@ export const formSchema: FormSchema[] = [
131 required: true, 130 required: true,
132 component: 'ApiSelect', 131 component: 'ApiSelect',
133 componentProps: { 132 componentProps: {
134 - api:findDictItemByCode,  
135 - params:{  
136 - dictCode:"platform_type" 133 + api: findDictItemByCode,
  134 + params: {
  135 + dictCode: 'platform_type',
137 }, 136 },
138 - labelField:'itemText',  
139 - valueField:'itemValue', 137 + labelField: 'itemText',
  138 + valueField: 'itemValue',
140 }, 139 },
141 - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), 140 + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
142 }, 141 },
143 { 142 {
144 field: 'accessKeyId', 143 field: 'accessKeyId',
145 label: 'accessKeyId', 144 label: 'accessKeyId',
146 required: true, 145 required: true,
147 - component:'Input',  
148 - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), 146 + component: 'Input',
  147 + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
149 }, 148 },
150 { 149 {
151 field: 'accessKeySecret', 150 field: 'accessKeySecret',
152 label: 'accessKeySecret', 151 label: 'accessKeySecret',
153 required: true, 152 required: true,
154 - component:'Input',  
155 - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), 153 + component: 'Input',
  154 + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
156 }, 155 },
157 { 156 {
158 field: 'host', 157 field: 'host',
159 label: '服务器地址', 158 label: '服务器地址',
160 - defaultValue:'smtp.163.com', 159 + defaultValue: 'smtp.163.com',
161 required: true, 160 required: true,
162 - component:'Input',  
163 - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), 161 + component: 'Input',
  162 + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
164 }, 163 },
165 { 164 {
166 field: 'port', 165 field: 'port',
167 label: '端口', 166 label: '端口',
168 defaultValue: 25, 167 defaultValue: 25,
169 required: true, 168 required: true,
170 - component:'InputNumber',  
171 - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), 169 + component: 'InputNumber',
  170 + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
172 }, 171 },
173 { 172 {
174 field: 'username', 173 field: 'username',
175 label: '用户名', 174 label: '用户名',
176 required: true, 175 required: true,
177 - component:'Input',  
178 - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), 176 + component: 'Input',
  177 + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
179 }, 178 },
180 { 179 {
181 field: 'password', 180 field: 'password',
182 label: '密码', 181 label: '密码',
183 required: true, 182 required: true,
184 - component:'InputPassword',  
185 - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), 183 + component: 'InputPassword',
  184 + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
186 }, 185 },
187 { 186 {
188 field: 'config', 187 field: 'config',
189 label: '消息配置', 188 label: '消息配置',
190 - component:'Input',  
191 - show:false, 189 + component: 'Input',
  190 + show: false,
192 }, 191 },
193 { 192 {
194 field: 'id', 193 field: 'id',
195 label: '主键', 194 label: '主键',
196 - component:'Input',  
197 - show:false, 195 + component: 'Input',
  196 + show: false,
198 }, 197 },
199 { 198 {
200 field: 'status', 199 field: 'status',
@@ -212,5 +211,5 @@ export const formSchema: FormSchema[] = [ @@ -212,5 +211,5 @@ export const formSchema: FormSchema[] = [
212 label: '备注', 211 label: '备注',
213 field: 'remark', 212 field: 'remark',
214 component: 'InputTextArea', 213 component: 'InputTextArea',
215 - } 214 + },
216 ]; 215 ];
@@ -4,26 +4,26 @@ @@ -4,26 +4,26 @@
4 <template #toolbar> 4 <template #toolbar>
5 <a-button type="primary" @click="handleCreate"> 新增配置 </a-button> 5 <a-button type="primary" @click="handleCreate"> 新增配置 </a-button>
6 </template> 6 </template>
7 - <template #config="{record}"> 7 + <template #config="{ record }">
8 <a-button type="link" class="ml-2" @click="showData(record)"> 查看配置 </a-button> 8 <a-button type="link" class="ml-2" @click="showData(record)"> 查看配置 </a-button>
9 </template> 9 </template>
10 <template #action="{ record }"> 10 <template #action="{ record }">
11 <TableAction 11 <TableAction
12 :actions="[ 12 :actions="[
13 { 13 {
14 - label:'编辑', 14 + label: '编辑',
15 icon: 'clarity:note-edit-line', 15 icon: 'clarity:note-edit-line',
16 onClick: handleEdit.bind(null, record), 16 onClick: handleEdit.bind(null, record),
17 }, 17 },
18 { 18 {
19 - label:'删除', 19 + label: '删除',
20 icon: 'ant-design:delete-outlined', 20 icon: 'ant-design:delete-outlined',
21 color: 'error', 21 color: 'error',
22 popConfirm: { 22 popConfirm: {
23 title: '是否确认删除', 23 title: '是否确认删除',
24 confirm: handleDelete.bind(null, record), 24 confirm: handleDelete.bind(null, record),
25 }, 25 },
26 - ifShow: record.status ==0 26 + ifShow: record.status == 0,
27 }, 27 },
28 ]" 28 ]"
29 /> 29 />
@@ -33,83 +33,83 @@ @@ -33,83 +33,83 @@
33 </div> 33 </div>
34 </template> 34 </template>
35 <script lang="ts"> 35 <script lang="ts">
36 -import { defineComponent,h} from 'vue'; 36 + import { defineComponent, h } from 'vue';
37 37
38 -import { BasicTable, useTable, TableAction } from '/@/components/Table';  
39 -import { messageConfigPage,deleteMessageConfig } from '/@/api/message/config';  
40 -import { useDrawer } from '/@/components/Drawer';  
41 -import ConfigDrawer from './ConfigDrawer.vue';  
42 -import { columns, searchFormSchema } from './config.data';  
43 -import { Modal } from 'ant-design-vue';  
44 -import { CodeEditor,JsonPreview } from '/@/components/CodeEditor';  
45 -import {useMessage} from "/@/hooks/web/useMessage";  
46 -export default defineComponent({  
47 - name: 'MessageConfigManagement',  
48 - components: { BasicTable, ConfigDrawer, TableAction ,CodeEditor},  
49 - setup() {  
50 - const [registerDrawer, { openDrawer }] = useDrawer();  
51 - const {createMessage} = useMessage();  
52 - const [registerTable, { reload }] = useTable({  
53 - title: '消息配置列表',  
54 - api: messageConfigPage,  
55 - columns,  
56 - formConfig: {  
57 - labelWidth: 120,  
58 - schemas: searchFormSchema,  
59 - },  
60 - useSearchForm: true,  
61 - showTableSetting: true,  
62 - bordered: true,  
63 - showIndexColumn: false,  
64 - actionColumn: {  
65 - width: 180,  
66 - title: '操作',  
67 - dataIndex: 'action',  
68 - slots: { customRender: 'action' },  
69 - fixed: undefined,  
70 - },  
71 - });  
72 -  
73 - function handleCreate() {  
74 - openDrawer(true, {  
75 - isUpdate: false, 38 + import { BasicTable, useTable, TableAction } from '/@/components/Table';
  39 + import { messageConfigPage, deleteMessageConfig } from '/@/api/message/config';
  40 + import { useDrawer } from '/@/components/Drawer';
  41 + import ConfigDrawer from './ConfigDrawer.vue';
  42 + import { columns, searchFormSchema } from './config.data';
  43 + import { Modal } from 'ant-design-vue';
  44 + import { CodeEditor, JsonPreview } from '/@/components/CodeEditor';
  45 + import { useMessage } from '/@/hooks/web/useMessage';
  46 + export default defineComponent({
  47 + name: 'MessageConfigManagement',
  48 + components: { BasicTable, ConfigDrawer, TableAction, CodeEditor },
  49 + setup() {
  50 + const [registerDrawer, { openDrawer }] = useDrawer();
  51 + const { createMessage } = useMessage();
  52 + const [registerTable, { reload }] = useTable({
  53 + title: '消息配置列表',
  54 + api: messageConfigPage,
  55 + columns,
  56 + formConfig: {
  57 + labelWidth: 120,
  58 + schemas: searchFormSchema,
  59 + },
  60 + useSearchForm: true,
  61 + showTableSetting: true,
  62 + bordered: true,
  63 + showIndexColumn: false,
  64 + actionColumn: {
  65 + width: 180,
  66 + title: '操作',
  67 + dataIndex: 'action',
  68 + slots: { customRender: 'action' },
  69 + fixed: undefined,
  70 + },
76 }); 71 });
77 - }  
78 72
79 - function handleEdit(record: Recordable) {  
80 - openDrawer(true, {  
81 - record,  
82 - isUpdate: true,  
83 - });  
84 - } 73 + function handleCreate() {
  74 + openDrawer(true, {
  75 + isUpdate: false,
  76 + });
  77 + }
85 78
86 - function handleDelete(record: Recordable) {  
87 - let ids = [record.id];  
88 - deleteMessageConfig(ids).then((result)=>{  
89 - createMessage.success(result.message)  
90 - handleSuccess()  
91 - });  
92 - } 79 + function handleEdit(record: Recordable) {
  80 + openDrawer(true, {
  81 + record,
  82 + isUpdate: true,
  83 + });
  84 + }
93 85
94 - function handleSuccess() {  
95 - reload();  
96 - }  
97 - function showData(record: Recordable){  
98 - Modal.info({  
99 - title: '当前配置',  
100 - width:480,  
101 - content: h(JsonPreview, { data: JSON.parse(JSON.stringify(record.config)) }),  
102 - });  
103 - }  
104 - return {  
105 - registerTable,  
106 - registerDrawer,  
107 - showData,  
108 - handleCreate,  
109 - handleEdit,  
110 - handleDelete,  
111 - handleSuccess,  
112 - };  
113 - },  
114 -}); 86 + function handleDelete(record: Recordable) {
  87 + let ids = [record.id];
  88 + deleteMessageConfig(ids).then((result) => {
  89 + createMessage.success(result.message);
  90 + handleSuccess();
  91 + });
  92 + }
  93 +
  94 + function handleSuccess() {
  95 + reload();
  96 + }
  97 + function showData(record: Recordable) {
  98 + Modal.info({
  99 + title: '当前配置',
  100 + width: 480,
  101 + content: h(JsonPreview, { data: JSON.parse(JSON.stringify(record.config)) }),
  102 + });
  103 + }
  104 + return {
  105 + registerTable,
  106 + registerDrawer,
  107 + showData,
  108 + handleCreate,
  109 + handleEdit,
  110 + handleDelete,
  111 + handleSuccess,
  112 + };
  113 + },
  114 + });
115 </script> 115 </script>