Showing
73 changed files
with
3100 additions
and
2571 deletions
@@ -6,7 +6,7 @@ VITE_PUBLIC_PATH = / | @@ -6,7 +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 | -VITE_PROXY = [["/api","http://localhost:8082/api"],["/upload","http://localhost:3300/upload"]] | 9 | +VITE_PROXY = [["/api","http://192.168.10.123:8082/api"],["/upload","http://192.168.10.125:3300/upload"]] |
10 | # VITE_PROXY=[["/api","https://vvbin.cn/test"]] | 10 | # VITE_PROXY=[["/api","https://vvbin.cn/test"]] |
11 | 11 | ||
12 | # Delete console | 12 | # Delete console |
.vscode/settings.json
0 → 100644
configModel.ts
0 → 100644
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; |
src/api/alarm/contact/alarmContact.ts
0 → 100644
1 | +import { defHttp } from '/@/utils/http/axios'; | ||
2 | +import type { BasicPageParams } from '/@/api/model/baseModel'; | ||
3 | +import type { ContactModal, ContactParams } from './modal/alarmContactModel'; | ||
4 | +import { getPageData } from '../../base'; | ||
5 | +enum Api { | ||
6 | + alarmContact = '/alarmContact', | ||
7 | + updateAlarmContact = '/alarmContact/update', | ||
8 | +} | ||
9 | + | ||
10 | +// 获取 | ||
11 | +export const getAlarmContact = (params: BasicPageParams) => { | ||
12 | + return getPageData<ContactModal>(params, Api.alarmContact); | ||
13 | +}; | ||
14 | + | ||
15 | +// 新增 | ||
16 | +export const addAlarmContact = (params: ContactParams) => { | ||
17 | + return defHttp.post({ | ||
18 | + url: Api.alarmContact, | ||
19 | + data: { | ||
20 | + params, | ||
21 | + }, | ||
22 | + }); | ||
23 | +}; | ||
24 | + | ||
25 | +// 更新 | ||
26 | +export const updateAlarmContact = (params: ContactParams) => { | ||
27 | + return defHttp.post({ | ||
28 | + url: Api.updateAlarmContact, | ||
29 | + data: { | ||
30 | + params, | ||
31 | + }, | ||
32 | + }); | ||
33 | +}; | ||
34 | + | ||
35 | +// 删除 | ||
36 | +export const deleteAlarmContact = (ids: string[]) => { | ||
37 | + return defHttp.delete({ | ||
38 | + url: Api.alarmContact, | ||
39 | + data: ids, | ||
40 | + }); | ||
41 | +}; |
1 | +interface ContactItemsModal { | ||
2 | + id: string; | ||
3 | + createTime: string; | ||
4 | + enabled: boolean; | ||
5 | + username: string; | ||
6 | + department: string; | ||
7 | + phone: string; | ||
8 | +} | ||
9 | + | ||
10 | +export interface ContactModal { | ||
11 | + items: ContactItemsModal[]; | ||
12 | + total: number; | ||
13 | +} | ||
14 | + | ||
15 | +export interface ContactParams { | ||
16 | + phone: string; | ||
17 | + username: string; | ||
18 | + department?: string; | ||
19 | + email?: string; | ||
20 | + enabled?: boolean; | ||
21 | + wechat?: string; | ||
22 | + addPeople?: string; | ||
23 | + remark?: string; | ||
24 | +} |
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 | /** |
@@ -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'; | 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 {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 DeptListItem { | 39 | export interface DeptListItem { |
@@ -70,16 +70,16 @@ export interface RoleReqDTO { | @@ -70,16 +70,16 @@ export interface RoleReqDTO { | ||
70 | } | 70 | } |
71 | 71 | ||
72 | export interface ChangeAccountParams { | 72 | export interface ChangeAccountParams { |
73 | - userId?:string; | ||
74 | - password?:string; | ||
75 | - resetPassword?:string; | 73 | + userId?: string; |
74 | + password?: string; | ||
75 | + resetPassword?: string; | ||
76 | } | 76 | } |
77 | 77 | ||
78 | -export class RoleOrGroupParam{ | ||
79 | - userId:string; | ||
80 | - queryRole:boolean; | ||
81 | - queryGroup:boolean; | ||
82 | - constructor(userId:string,queryRole:boolean,queryGroup:boolean){ | 78 | +export class RoleOrGroupParam { |
79 | + userId: string; | ||
80 | + queryRole: boolean; | ||
81 | + queryGroup: boolean; | ||
82 | + constructor(userId: string, queryRole: boolean, queryGroup: boolean) { | ||
83 | this.queryRole = queryRole; | 83 | this.queryRole = queryRole; |
84 | this.queryGroup = queryGroup; | 84 | this.queryGroup = queryGroup; |
85 | this.userId = userId; | 85 | this.userId = userId; |
@@ -100,4 +100,3 @@ export type RolePageListGetResultModel = BasicFetchResult<RoleListItem>; | @@ -100,4 +100,3 @@ export type RolePageListGetResultModel = BasicFetchResult<RoleListItem>; | ||
100 | export type RoleListGetResultModel = RoleListItem[]; | 100 | export type RoleListGetResultModel = RoleListItem[]; |
101 | 101 | ||
102 | export type AccountListModel = AccountListItem; | 102 | export type AccountListModel = AccountListItem; |
103 | - |
@@ -15,7 +15,7 @@ import { | @@ -15,7 +15,7 @@ import { | ||
15 | RoleOrGroupParam, | 15 | RoleOrGroupParam, |
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', |
@@ -27,41 +27,41 @@ enum Api { | @@ -27,41 +27,41 @@ enum Api { | ||
27 | SaveOrUpdateRoleInfoWithMenu = '/role/saveOrUpdateRoleInfoWithMenu', | 27 | SaveOrUpdateRoleInfoWithMenu = '/role/saveOrUpdateRoleInfoWithMenu', |
28 | DeleteRole = '/role', | 28 | DeleteRole = '/role', |
29 | GetAllRoleList = '/role/find/list', | 29 | GetAllRoleList = '/role/find/list', |
30 | - BaseUserUrl = '/user' | 30 | + BaseUserUrl = '/user', |
31 | } | 31 | } |
32 | 32 | ||
33 | -export const getAccountInfo=(userId:string)=> | ||
34 | - defHttp.get<AccountListModel>({url: Api.BaseUserUrl+"/"+userId}) | 33 | +export const getAccountInfo = (userId: string) => |
34 | + defHttp.get<AccountListModel>({ url: Api.BaseUserUrl + '/' + userId }); | ||
35 | 35 | ||
36 | export const getAccountList = (params: AccountParams) => | 36 | export const getAccountList = (params: AccountParams) => |
37 | - defHttp.get<AccountListGetResultModel>({url: Api.AccountList, params}); | 37 | + defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params }); |
38 | 38 | ||
39 | export const getDeptList = (params?: DeptListItem) => | 39 | export const getDeptList = (params?: DeptListItem) => |
40 | - defHttp.get<DeptListGetResultModel>({url: Api.DeptList, params}); | 40 | + defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params }); |
41 | 41 | ||
42 | export const getMenuList = (params?: MenuParams) => | 42 | export const getMenuList = (params?: MenuParams) => |
43 | - defHttp.get<MenuListGetResultModel>({url: Api.MenuList, params}); | 43 | + defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params }); |
44 | 44 | ||
45 | export const getRoleListByPage = (params?: RolePageParams) => | 45 | export const getRoleListByPage = (params?: RolePageParams) => |
46 | - defHttp.get<RolePageListGetResultModel>({url: Api.RolePageList, params}); | ||
47 | -export const getTenantRoleListByPage= (params?: RolePageParams) => | ||
48 | - defHttp.get<RolePageListGetResultModel>({url: Api.RolePageList, params}); | 46 | + defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params }); |
47 | +export const getTenantRoleListByPage = (params?: RolePageParams) => | ||
48 | + defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params }); | ||
49 | 49 | ||
50 | export const getAllRoleList = (params?: RoleParams) => | 50 | export const getAllRoleList = (params?: RoleParams) => |
51 | - defHttp.post<RoleListGetResultModel>({url: Api.GetAllRoleList, params}); | 51 | + defHttp.post<RoleListGetResultModel>({ url: Api.GetAllRoleList, params }); |
52 | 52 | ||
53 | export const setRoleStatus = (id: number, status: number) => | 53 | export const setRoleStatus = (id: number, status: number) => |
54 | - defHttp.put({url: Api.setRoleStatus + id + "/" + status}); | 54 | + defHttp.put({ url: Api.setRoleStatus + id + '/' + status }); |
55 | export const saveOrUpdateRoleInfoWithMenu = async (roleRequestDto: RoleReqDTO) => { | 55 | export const saveOrUpdateRoleInfoWithMenu = async (roleRequestDto: RoleReqDTO) => { |
56 | - await defHttp.post({url: Api.SaveOrUpdateRoleInfoWithMenu, params: roleRequestDto}); | ||
57 | -} | 56 | + await defHttp.post({ url: Api.SaveOrUpdateRoleInfoWithMenu, params: roleRequestDto }); |
57 | +}; | ||
58 | 58 | ||
59 | export const isAccountExist = (account: string) => | 59 | export const isAccountExist = (account: string) => |
60 | - defHttp.get({url: Api.IsAccountExist + account}, {errorMessageMode: 'none'}); | 60 | + defHttp.get({ url: Api.IsAccountExist + account }, { errorMessageMode: 'none' }); |
61 | 61 | ||
62 | export const delRole = async (roleIds: string[]) => { | 62 | export const delRole = async (roleIds: string[]) => { |
63 | - await defHttp.delete({url: Api.DeleteRole, params: roleIds}); | ||
64 | -} | 63 | + await defHttp.delete({ url: Api.DeleteRole, params: roleIds }); |
64 | +}; | ||
65 | 65 | ||
66 | /** | 66 | /** |
67 | * 更新或添加用户信息 | 67 | * 更新或添加用户信息 |
@@ -69,19 +69,19 @@ export const delRole = async (roleIds: string[]) => { | @@ -69,19 +69,19 @@ export const delRole = async (roleIds: string[]) => { | ||
69 | * @param isUpdate | 69 | * @param isUpdate |
70 | * @constructor | 70 | * @constructor |
71 | */ | 71 | */ |
72 | -export const SaveOrUpdateUserInfo = (params: AccountListItem, isUpdate: boolean)=>{ | 72 | +export const SaveOrUpdateUserInfo = (params: AccountListItem, isUpdate: boolean) => { |
73 | if (isUpdate) { | 73 | if (isUpdate) { |
74 | return defHttp.put<AccountListModel>({ | 74 | return defHttp.put<AccountListModel>({ |
75 | url: Api.BaseUserUrl, | 75 | url: Api.BaseUserUrl, |
76 | params, | 76 | params, |
77 | - }) | 77 | + }); |
78 | } else { | 78 | } else { |
79 | return defHttp.post<AccountListModel>({ | 79 | return defHttp.post<AccountListModel>({ |
80 | url: Api.BaseUserUrl, | 80 | url: Api.BaseUserUrl, |
81 | params, | 81 | params, |
82 | - }) | 82 | + }); |
83 | } | 83 | } |
84 | -} | 84 | +}; |
85 | /** | 85 | /** |
86 | * 删除User | 86 | * 删除User |
87 | * @param ids 删除id数组 | 87 | * @param ids 删除id数组 |
@@ -90,26 +90,26 @@ export const deleteUser = (ids: string[]) => | @@ -90,26 +90,26 @@ export const deleteUser = (ids: string[]) => | ||
90 | defHttp.delete({ | 90 | defHttp.delete({ |
91 | url: Api.BaseUserUrl, | 91 | url: Api.BaseUserUrl, |
92 | data: { | 92 | data: { |
93 | - ids: ids | 93 | + ids: ids, |
94 | }, | 94 | }, |
95 | - }) | 95 | + }); |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * 查询当前用户的关系 | 98 | * 查询当前用户的关系 |
99 | * @param params | 99 | * @param params |
100 | */ | 100 | */ |
101 | -export const findCurrentUserRelation=(params:RoleOrGroupParam)=> | 101 | +export const findCurrentUserRelation = (params: RoleOrGroupParam) => |
102 | defHttp.post<Array<string>>({ | 102 | defHttp.post<Array<string>>({ |
103 | - url: Api.BaseUserUrl+"/relation", | ||
104 | - params:params | 103 | + url: Api.BaseUserUrl + '/relation', |
104 | + params: params, | ||
105 | }); | 105 | }); |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * 修改密码 | 108 | * 修改密码 |
109 | * @param params | 109 | * @param params |
110 | */ | 110 | */ |
111 | -export const resetPassword=(params:ChangeAccountParams)=> | 111 | +export const resetPassword = (params: ChangeAccountParams) => |
112 | defHttp.post({ | 112 | defHttp.post({ |
113 | - url: Api.BaseUserUrl + "/reset", | ||
114 | - params:params | 113 | + url: Api.BaseUserUrl + '/reset', |
114 | + params: params, | ||
115 | }); | 115 | }); |
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" |
@@ -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 default { | 1 | export default { |
2 | - tenant:{ | ||
3 | - tenant:"租户", | ||
4 | - tenantManagement:"租户管理", | ||
5 | - tenantSetting:"租户设置" | ||
6 | - }, | ||
7 | - dept:{ | ||
8 | - queryDeptName:"部门名称", | ||
9 | - queryDeptStatus:"状态", | ||
10 | - toolDeptList:"部门列表", | ||
11 | - toolCreateDept:"新增部门", | ||
12 | - toolEditDept:"编辑部门", | ||
13 | - tableTitleDeptSort:"排序", | ||
14 | - tableTitleDeptCreateTime:"创建时间", | ||
15 | - tableTitleDeptOperation:"操作", | ||
16 | - drawerTitleDeptEnable:"启用", | ||
17 | - drawerTitleDeptDisable:"停用", | ||
18 | - drawerTitleDeptParentDept:"上级部门", | ||
19 | - tableTitleMemo:"备注" | 2 | + tenant: { |
3 | + tenant: '租户', | ||
4 | + tenantManagement: '租户管理', | ||
5 | + tenantSetting: '租户设置', | ||
20 | }, | 6 | }, |
21 | - system:{ | ||
22 | - system:"系统管理", | ||
23 | - accountManagement:"账号管理", | ||
24 | - roleManagement:"角色管理", | ||
25 | - menuManagement:"菜单管理", | ||
26 | - deptManagement:"部门管理", | ||
27 | - modifyPassword:"修改密码", | ||
28 | - pageSystemTitleCreateMenu:"新增菜单", | ||
29 | - pageSystemTitleCreateTenant:"新增租户", | ||
30 | - pageSystemTitleEditMenu:"编辑菜单", | ||
31 | - pageSystemTitleEditTenant:"编辑租户", | ||
32 | - pageSystemTitleOperation:"操作", | ||
33 | - pageSystemTitleWhetherDelete:"是否确认删除", | ||
34 | - pageSystemTitleMenuList:"菜单列表", | ||
35 | - menuEditPagesMenuType:"菜单类型", | ||
36 | - menuEditPagesDirectory:"目录", | ||
37 | - menuEditPagesMenu:"菜单", | ||
38 | - menuEditPagesButton:"按钮", | ||
39 | - menuEditPagesParentMenu:"上级菜单", | ||
40 | - menuEditPagesRouterAddress:"路由地址", | ||
41 | - menuEditPagesComponentsPath:"组件路径", | ||
42 | - menuEditPagesIsExt:"是否外链", | ||
43 | - menuEditPagesIsKeepAlive:"是否缓存", | ||
44 | - menuEditPagesIsHide:"是否隐藏", | ||
45 | - menuEditPagesYes:"是", | ||
46 | - menuEditPagesNo:"否", | ||
47 | - tableTitleSystemMenuName:"菜单名称", | ||
48 | - tableTitleSystemIcon:"图标", | ||
49 | - tableTitleSystemPermissionTag:"权限标识", | ||
50 | - tableTitleSystemComponents:"组件", | ||
51 | - tableTitleSystemSort:"排序", | ||
52 | - tableTitleSystemStatus:"状态", | ||
53 | - tableTitleSystemCreateTime:"创建时间", | ||
54 | - tableTitleSystemEnable:"启用", | ||
55 | - tableTitleSystemStop:"停用", | ||
56 | - tableSuccessStatus:"成功", | ||
57 | - tableFailedStatus:"失败", | ||
58 | - } | ||
59 | - }; | 7 | + dept: { |
8 | + queryDeptName: '部门名称', | ||
9 | + queryDeptStatus: '状态', | ||
10 | + toolDeptList: '部门列表', | ||
11 | + toolCreateDept: '新增部门', | ||
12 | + toolEditDept: '编辑部门', | ||
13 | + tableTitleDeptSort: '排序', | ||
14 | + tableTitleDeptCreateTime: '创建时间', | ||
15 | + tableTitleDeptOperation: '操作', | ||
16 | + drawerTitleDeptEnable: '启用', | ||
17 | + drawerTitleDeptDisable: '停用', | ||
18 | + drawerTitleDeptParentDept: '上级部门', | ||
19 | + tableTitleMemo: '备注', | ||
20 | + }, | ||
21 | + system: { | ||
22 | + system: '系统管理', | ||
23 | + accountManagement: '账号管理', | ||
24 | + roleManagement: '角色管理', | ||
25 | + menuManagement: '菜单管理', | ||
26 | + deptManagement: '部门管理', | ||
27 | + modifyPassword: '修改密码', | ||
28 | + pageSystemTitleCreateMenu: '新增菜单', | ||
29 | + pageSystemTitleCreateTenant: '新增租户', | ||
30 | + pageSystemTitleEditMenu: '编辑菜单', | ||
31 | + pageSystemTitleEditTenant: '编辑租户', | ||
32 | + pageSystemTitleOperation: '操作', | ||
33 | + pageSystemTitleWhetherDelete: '是否确认删除', | ||
34 | + pageSystemTitleMenuList: '菜单列表', | ||
35 | + menuEditPagesMenuType: '菜单类型', | ||
36 | + menuEditPagesDirectory: '目录', | ||
37 | + menuEditPagesMenu: '菜单', | ||
38 | + menuEditPagesButton: '按钮', | ||
39 | + menuEditPagesParentMenu: '上级菜单', | ||
40 | + menuEditPagesRouterAddress: '路由地址', | ||
41 | + menuEditPagesComponentsPath: '组件路径', | ||
42 | + menuEditPagesIsExt: '是否外链', | ||
43 | + menuEditPagesIsKeepAlive: '是否缓存', | ||
44 | + menuEditPagesIsHide: '是否隐藏', | ||
45 | + menuEditPagesYes: '是', | ||
46 | + menuEditPagesNo: '否', | ||
47 | + tableTitleSystemMenuName: '菜单名称', | ||
48 | + tableTitleSystemIcon: '图标', | ||
49 | + tableTitleSystemPermissionTag: '权限标识', | ||
50 | + tableTitleSystemComponents: '组件', | ||
51 | + tableTitleSystemSort: '排序', | ||
52 | + tableTitleSystemStatus: '状态', | ||
53 | + tableTitleSystemCreateTime: '创建时间', | ||
54 | + tableTitleSystemEnable: '启用', | ||
55 | + tableTitleSystemStop: '停用', | ||
56 | + tableSuccessStatus: '成功', | ||
57 | + tableFailedStatus: '失败', | ||
58 | + }, | ||
59 | +}; |
@@ -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 |
src/views/alarm/template/ContactDrawer.vue
0 → 100644
1 | +<template> | ||
2 | + <BasicDrawer | ||
3 | + v-bind="$attrs" | ||
4 | + @register="registerDrawer" | ||
5 | + showFooter | ||
6 | + :title="getTitle" | ||
7 | + width="500px" | ||
8 | + @ok="handleSubmit" | ||
9 | + > | ||
10 | + <BasicForm @register="registerForm" /> | ||
11 | + </BasicDrawer> | ||
12 | +</template> | ||
13 | +<script lang="ts"> | ||
14 | + import { defineComponent, ref, computed, unref } from 'vue'; | ||
15 | + import { BasicForm, useForm } from '/@/components/Form'; | ||
16 | + import { formSchema } from './config.data'; | ||
17 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
18 | + import { saveOrEditMessageConfig } from '/@/api/message/config'; | ||
19 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
20 | + | ||
21 | + export default defineComponent({ | ||
22 | + name: 'ContactDrawer', | ||
23 | + components: { BasicDrawer, BasicForm }, | ||
24 | + emits: ['success', 'register'], | ||
25 | + setup(_, { emit }) { | ||
26 | + const isUpdate = ref(true); | ||
27 | + | ||
28 | + const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | ||
29 | + labelWidth: 120, | ||
30 | + schemas: formSchema, | ||
31 | + showActionButtonGroup: false, | ||
32 | + }); | ||
33 | + | ||
34 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
35 | + await resetFields(); | ||
36 | + setDrawerProps({ confirmLoading: false }); | ||
37 | + isUpdate.value = !!data?.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({ | ||
44 | + ...data.record, | ||
45 | + }); | ||
46 | + } | ||
47 | + }); | ||
48 | + | ||
49 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增消息配置' : '编辑消息配置')); | ||
50 | + | ||
51 | + async function handleSubmit() { | ||
52 | + try { | ||
53 | + const values = await validate(); | ||
54 | + const { createMessage } = useMessage(); | ||
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 | + }; | ||
69 | + } | ||
70 | + Reflect.set(values, 'config', config); | ||
71 | + let saveMessage = '添加成功'; | ||
72 | + let updateMessage = '修改成功'; | ||
73 | + await saveOrEditMessageConfig(values, unref(isUpdate)); | ||
74 | + closeDrawer(); | ||
75 | + emit('success'); | ||
76 | + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); | ||
77 | + } finally { | ||
78 | + setDrawerProps({ confirmLoading: false }); | ||
79 | + } | ||
80 | + } | ||
81 | + | ||
82 | + return { | ||
83 | + registerDrawer, | ||
84 | + registerForm, | ||
85 | + getTitle, | ||
86 | + handleSubmit, | ||
87 | + }; | ||
88 | + }, | ||
89 | + }); | ||
90 | +</script> |
src/views/alarm/template/config.data.ts
0 → 100644
1 | +import { BasicColumn } from '/@/components/Table'; | ||
2 | +import { FormSchema } from '/@/components/Table'; | ||
3 | +import { findDictItemByCode } from '/@/api/system/dict'; | ||
4 | +import { MessageEnum } from '/@/enums/messageEnum'; | ||
5 | +// 表格列数据 | ||
6 | +export const columns: BasicColumn[] = [ | ||
7 | + { | ||
8 | + title: '姓名', | ||
9 | + dataIndex: 'username', | ||
10 | + width: 100, | ||
11 | + }, | ||
12 | + { | ||
13 | + title: '所属组织', | ||
14 | + dataIndex: 'department', | ||
15 | + width: 200, | ||
16 | + }, | ||
17 | + { | ||
18 | + title: '手机', | ||
19 | + dataIndex: 'phone', | ||
20 | + width: 160, | ||
21 | + }, | ||
22 | + { | ||
23 | + title: '邮箱', | ||
24 | + dataIndex: 'label', | ||
25 | + width: 160, | ||
26 | + }, | ||
27 | + { | ||
28 | + title: '微信', | ||
29 | + dataIndex: 'deviceInfo', | ||
30 | + width: 180, | ||
31 | + }, | ||
32 | + { | ||
33 | + title: '备注', | ||
34 | + dataIndex: 'deviceState', | ||
35 | + width: 120, | ||
36 | + }, | ||
37 | + { | ||
38 | + title: '添加人', | ||
39 | + dataIndex: 'lastConnectTime', | ||
40 | + width: 180, | ||
41 | + }, | ||
42 | + { | ||
43 | + title: '更新时间', | ||
44 | + dataIndex: 'updateTime', | ||
45 | + width: 180, | ||
46 | + }, | ||
47 | + { | ||
48 | + title: '添加时间', | ||
49 | + dataIndex: 'createTime', | ||
50 | + width: 180, | ||
51 | + }, | ||
52 | +]; | ||
53 | + | ||
54 | +// 查询字段 | ||
55 | +export const searchFormSchema: FormSchema[] = [ | ||
56 | + { | ||
57 | + field: 'department', | ||
58 | + label: '所属组织', | ||
59 | + component: 'TreeSelect', | ||
60 | + componentProps: { | ||
61 | + placeholder: '请选择组织', | ||
62 | + }, | ||
63 | + colProps: { span: 6 }, | ||
64 | + }, | ||
65 | + { | ||
66 | + field: 'username', | ||
67 | + label: '用户名', | ||
68 | + component: 'Input', | ||
69 | + colProps: { span: 6 }, | ||
70 | + componentProps: { | ||
71 | + placeholder: '请输入姓名、手机号或邮箱', | ||
72 | + }, | ||
73 | + }, | ||
74 | +]; | ||
75 | + | ||
76 | +// 弹框配置项 | ||
77 | +export const formSchema: FormSchema[] = [ | ||
78 | + { | ||
79 | + field: 'configName', | ||
80 | + label: '联系人姓名', | ||
81 | + required: true, | ||
82 | + component: 'Input', | ||
83 | + }, | ||
84 | + { | ||
85 | + field: 'messageType', | ||
86 | + label: '所属组织', | ||
87 | + required: true, | ||
88 | + component: 'ApiSelect', | ||
89 | + componentProps: { | ||
90 | + api: findDictItemByCode, | ||
91 | + params: { | ||
92 | + dictCode: 'message_type', | ||
93 | + }, | ||
94 | + labelField: 'itemText', | ||
95 | + valueField: 'itemValue', | ||
96 | + }, | ||
97 | + }, | ||
98 | + { | ||
99 | + field: 'platformType', | ||
100 | + label: '手机号码', | ||
101 | + required: true, | ||
102 | + component: 'Input', | ||
103 | + componentProps: { | ||
104 | + api: findDictItemByCode, | ||
105 | + params: { | ||
106 | + dictCode: 'platform_type', | ||
107 | + }, | ||
108 | + labelField: 'itemText', | ||
109 | + valueField: 'itemValue', | ||
110 | + }, | ||
111 | + }, | ||
112 | + { | ||
113 | + field: 'accessKeyId', | ||
114 | + label: 'accessKeyId', | ||
115 | + required: true, | ||
116 | + component: 'Input', | ||
117 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | ||
118 | + }, | ||
119 | + { | ||
120 | + field: 'accessKeySecret', | ||
121 | + label: 'accessKeySecret', | ||
122 | + required: true, | ||
123 | + component: 'Input', | ||
124 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | ||
125 | + }, | ||
126 | + { | ||
127 | + field: 'host', | ||
128 | + label: '服务器地址', | ||
129 | + defaultValue: 'smtp.163.com', | ||
130 | + required: true, | ||
131 | + component: 'Input', | ||
132 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | ||
133 | + }, | ||
134 | + { | ||
135 | + field: 'port', | ||
136 | + label: '端口', | ||
137 | + defaultValue: 25, | ||
138 | + required: true, | ||
139 | + component: 'InputNumber', | ||
140 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | ||
141 | + }, | ||
142 | + { | ||
143 | + field: 'username', | ||
144 | + label: '用户名', | ||
145 | + required: true, | ||
146 | + component: 'Input', | ||
147 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | ||
148 | + }, | ||
149 | + { | ||
150 | + field: 'password', | ||
151 | + label: '密码', | ||
152 | + required: true, | ||
153 | + component: 'InputPassword', | ||
154 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | ||
155 | + }, | ||
156 | + { | ||
157 | + field: 'config', | ||
158 | + label: '消息配置', | ||
159 | + component: 'Input', | ||
160 | + show: false, | ||
161 | + }, | ||
162 | + { | ||
163 | + field: 'id', | ||
164 | + label: '主键', | ||
165 | + component: 'Input', | ||
166 | + show: false, | ||
167 | + }, | ||
168 | + { | ||
169 | + field: 'status', | ||
170 | + label: '状态', | ||
171 | + component: 'RadioButtonGroup', | ||
172 | + defaultValue: 0, | ||
173 | + componentProps: { | ||
174 | + options: [ | ||
175 | + { label: '启用', value: 1 }, | ||
176 | + { label: '停用', value: 0 }, | ||
177 | + ], | ||
178 | + }, | ||
179 | + }, | ||
180 | + { | ||
181 | + label: '备注', | ||
182 | + field: 'remark', | ||
183 | + component: 'InputTextArea', | ||
184 | + }, | ||
185 | +]; | ||
186 | + | ||
187 | +export const isMessage = (type: string) => { | ||
188 | + return type === MessageEnum.IS_SMS; | ||
189 | +}; | ||
190 | +export const isEmail = (type: string) => { | ||
191 | + return type === MessageEnum.IS_EMAIL; | ||
192 | +}; |
src/views/alarm/template/index.vue
0 → 100644
1 | +<template> | ||
2 | + <div> | ||
3 | + <BasicTable @register="registerTable"> | ||
4 | + <template #toolbar> | ||
5 | + <a-button type="primary" @click="handleCreate"> 新增联系人 </a-button> | ||
6 | + <a-button type="primary" color="error" @click="handleDelete"> 批量删除 </a-button> | ||
7 | + </template> | ||
8 | + <template #action="{ record }"> | ||
9 | + <TableAction | ||
10 | + :actions="[ | ||
11 | + { | ||
12 | + label: '编辑', | ||
13 | + icon: 'clarity:note-edit-line', | ||
14 | + onClick: handleEdit.bind(null, record), | ||
15 | + }, | ||
16 | + { | ||
17 | + label: '删除', | ||
18 | + icon: 'ant-design:delete-outlined', | ||
19 | + color: 'error', | ||
20 | + popConfirm: { | ||
21 | + title: '是否确认删除', | ||
22 | + confirm: handleDelete.bind(null, record), | ||
23 | + }, | ||
24 | + }, | ||
25 | + ]" | ||
26 | + /> | ||
27 | + </template> | ||
28 | + </BasicTable> | ||
29 | + <ContactDrawer @register="registerDrawer" @success="handleSuccess" /> | ||
30 | + </div> | ||
31 | +</template> | ||
32 | + | ||
33 | +<script lang="ts"> | ||
34 | + import { defineComponent } from 'vue'; | ||
35 | + import { BasicTable, useTable, TableAction } from '/@/components/Table'; | ||
36 | + // import { useGo } from '/@/hooks/web/usePage'; | ||
37 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
38 | + import { useDrawer } from '/@/components/Drawer'; | ||
39 | + import ContactDrawer from './ContactDrawer.vue'; | ||
40 | + import { getAlarmContact, deleteAlarmContact } from '/@/api/alarm/contact/alarmContact'; | ||
41 | + import { searchFormSchema, columns } from './config.data'; | ||
42 | + import {} from '/@/api/alarm/contact/alarmContact'; | ||
43 | + export default defineComponent({ | ||
44 | + components: { | ||
45 | + BasicTable, | ||
46 | + TableAction, | ||
47 | + ContactDrawer, | ||
48 | + }, | ||
49 | + setup() { | ||
50 | + const [registerTable, { reload }] = useTable({ | ||
51 | + api: getAlarmContact, | ||
52 | + columns, | ||
53 | + formConfig: { | ||
54 | + labelWidth: 120, | ||
55 | + schemas: searchFormSchema, | ||
56 | + }, | ||
57 | + useSearchForm: true, | ||
58 | + showTableSetting: true, | ||
59 | + bordered: true, | ||
60 | + showIndexColumn: false, | ||
61 | + actionColumn: { | ||
62 | + width: 180, | ||
63 | + title: '操作', | ||
64 | + dataIndex: 'action', | ||
65 | + slots: { customRender: 'action' }, | ||
66 | + fixed: 'right', | ||
67 | + }, | ||
68 | + }); | ||
69 | + const [registerDrawer, { openDrawer }] = useDrawer(); | ||
70 | + const { createMessage } = useMessage(); | ||
71 | + const handleCreate = () => { | ||
72 | + openDrawer(true, { | ||
73 | + isUpdate: false, | ||
74 | + }); | ||
75 | + }; | ||
76 | + const handleEdit = (record: Recordable) => { | ||
77 | + openDrawer(true, { | ||
78 | + record, | ||
79 | + isUpdate: true, | ||
80 | + }); | ||
81 | + }; | ||
82 | + const handleDelete = async (record: Recordable) => { | ||
83 | + let ids: string[] = [record.id]; | ||
84 | + console.log(ids); | ||
85 | + try { | ||
86 | + await deleteAlarmContact(ids); | ||
87 | + createMessage.success('删除联系人成功'); | ||
88 | + handleSuccess(); | ||
89 | + } catch (e) { | ||
90 | + createMessage.error('删除失败'); | ||
91 | + } | ||
92 | + }; | ||
93 | + // 刷新 | ||
94 | + const handleSuccess = () => { | ||
95 | + reload(); | ||
96 | + }; | ||
97 | + return { | ||
98 | + handleEdit, | ||
99 | + handleCreate, | ||
100 | + handleDelete, | ||
101 | + registerTable, | ||
102 | + registerDrawer, | ||
103 | + reload, | ||
104 | + }; | ||
105 | + }, | ||
106 | + }); | ||
107 | +</script> |
@@ -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 | } |
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"; | ||
5 | -import {DeviceTypeEnum,DeviceState} from "/@/api/device/model/deviceModel"; | 3 | +import { findDictItemByCode } from '/@/api/system/dict'; |
4 | +import { MessageEnum } from '/@/enums/messageEnum'; | ||
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: '设备名称', |
@@ -13,7 +14,7 @@ export const columns: BasicColumn[] = [ | @@ -13,7 +14,7 @@ export const columns: BasicColumn[] = [ | ||
13 | title: '设备类型', | 14 | title: '设备类型', |
14 | dataIndex: 'deviceType', | 15 | dataIndex: 'deviceType', |
15 | width: 200, | 16 | width: 200, |
16 | - slots:{customRender:'deviceType'}, | 17 | + slots: { customRender: 'deviceType' }, |
17 | }, | 18 | }, |
18 | { | 19 | { |
19 | title: '设备配置', | 20 | title: '设备配置', |
@@ -24,7 +25,7 @@ export const columns: BasicColumn[] = [ | @@ -24,7 +25,7 @@ export const columns: BasicColumn[] = [ | ||
24 | { | 25 | { |
25 | title: '标签', | 26 | title: '标签', |
26 | dataIndex: 'label', | 27 | dataIndex: 'label', |
27 | - width: 180 | 28 | + width: 180, |
28 | }, | 29 | }, |
29 | { | 30 | { |
30 | title: '配置信息', | 31 | title: '配置信息', |
@@ -38,7 +39,6 @@ export const columns: BasicColumn[] = [ | @@ -38,7 +39,6 @@ export const columns: BasicColumn[] = [ | ||
38 | width: 120, | 39 | width: 120, |
39 | slots: { customRender: 'deviceState' }, | 40 | slots: { customRender: 'deviceState' }, |
40 | }, | 41 | }, |
41 | - | ||
42 | { | 42 | { |
43 | title: '最后连接时间', | 43 | title: '最后连接时间', |
44 | dataIndex: 'lastConnectTime', | 44 | dataIndex: 'lastConnectTime', |
@@ -51,6 +51,7 @@ export const columns: BasicColumn[] = [ | @@ -51,6 +51,7 @@ export const columns: BasicColumn[] = [ | ||
51 | }, | 51 | }, |
52 | ]; | 52 | ]; |
53 | 53 | ||
54 | +// 查询字段 | ||
54 | export const searchFormSchema: FormSchema[] = [ | 55 | export const searchFormSchema: FormSchema[] = [ |
55 | { | 56 | { |
56 | field: 'deviceType', | 57 | field: 'deviceType', |
@@ -86,20 +87,13 @@ export const searchFormSchema: FormSchema[] = [ | @@ -86,20 +87,13 @@ export const searchFormSchema: FormSchema[] = [ | ||
86 | }, | 87 | }, |
87 | ]; | 88 | ]; |
88 | 89 | ||
89 | - | ||
90 | -export const isMessage = (type:string)=>{ | ||
91 | - return type===MessageEnum.IS_SMS; | ||
92 | -} | ||
93 | -export const isEmail = (type:string)=>{ | ||
94 | - return type===MessageEnum.IS_EMAIL; | ||
95 | -} | ||
96 | - | 90 | +// 弹框配置项 |
97 | export const formSchema: FormSchema[] = [ | 91 | export const formSchema: FormSchema[] = [ |
98 | { | 92 | { |
99 | field: 'configName', | 93 | field: 'configName', |
100 | label: '配置名称', | 94 | label: '配置名称', |
101 | required: true, | 95 | required: true, |
102 | - component:'Input' | 96 | + component: 'Input', |
103 | }, | 97 | }, |
104 | { | 98 | { |
105 | field: 'messageType', | 99 | field: 'messageType', |
@@ -107,12 +101,12 @@ export const formSchema: FormSchema[] = [ | @@ -107,12 +101,12 @@ export const formSchema: FormSchema[] = [ | ||
107 | required: true, | 101 | required: true, |
108 | component: 'ApiSelect', | 102 | component: 'ApiSelect', |
109 | componentProps: { | 103 | componentProps: { |
110 | - api:findDictItemByCode, | ||
111 | - params:{ | ||
112 | - dictCode:"message_type" | 104 | + api: findDictItemByCode, |
105 | + params: { | ||
106 | + dictCode: 'message_type', | ||
113 | }, | 107 | }, |
114 | - labelField:'itemText', | ||
115 | - valueField:'itemValue', | 108 | + labelField: 'itemText', |
109 | + valueField: 'itemValue', | ||
116 | }, | 110 | }, |
117 | }, | 111 | }, |
118 | { | 112 | { |
@@ -121,70 +115,70 @@ export const formSchema: FormSchema[] = [ | @@ -121,70 +115,70 @@ export const formSchema: FormSchema[] = [ | ||
121 | required: true, | 115 | required: true, |
122 | component: 'ApiSelect', | 116 | component: 'ApiSelect', |
123 | componentProps: { | 117 | componentProps: { |
124 | - api:findDictItemByCode, | ||
125 | - params:{ | ||
126 | - dictCode:"platform_type" | 118 | + api: findDictItemByCode, |
119 | + params: { | ||
120 | + dictCode: 'platform_type', | ||
127 | }, | 121 | }, |
128 | - labelField:'itemText', | ||
129 | - valueField:'itemValue', | 122 | + labelField: 'itemText', |
123 | + valueField: 'itemValue', | ||
130 | }, | 124 | }, |
131 | - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), | 125 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), |
132 | }, | 126 | }, |
133 | { | 127 | { |
134 | field: 'accessKeyId', | 128 | field: 'accessKeyId', |
135 | label: 'accessKeyId', | 129 | label: 'accessKeyId', |
136 | required: true, | 130 | required: true, |
137 | - component:'Input', | ||
138 | - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), | 131 | + component: 'Input', |
132 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | ||
139 | }, | 133 | }, |
140 | { | 134 | { |
141 | field: 'accessKeySecret', | 135 | field: 'accessKeySecret', |
142 | label: 'accessKeySecret', | 136 | label: 'accessKeySecret', |
143 | required: true, | 137 | required: true, |
144 | - component:'Input', | ||
145 | - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), | 138 | + component: 'Input', |
139 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | ||
146 | }, | 140 | }, |
147 | { | 141 | { |
148 | field: 'host', | 142 | field: 'host', |
149 | label: '服务器地址', | 143 | label: '服务器地址', |
150 | - defaultValue:'smtp.163.com', | 144 | + defaultValue: 'smtp.163.com', |
151 | required: true, | 145 | required: true, |
152 | - component:'Input', | ||
153 | - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), | 146 | + component: 'Input', |
147 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | ||
154 | }, | 148 | }, |
155 | { | 149 | { |
156 | field: 'port', | 150 | field: 'port', |
157 | label: '端口', | 151 | label: '端口', |
158 | defaultValue: 25, | 152 | defaultValue: 25, |
159 | required: true, | 153 | required: true, |
160 | - component:'InputNumber', | ||
161 | - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), | 154 | + component: 'InputNumber', |
155 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | ||
162 | }, | 156 | }, |
163 | { | 157 | { |
164 | field: 'username', | 158 | field: 'username', |
165 | label: '用户名', | 159 | label: '用户名', |
166 | required: true, | 160 | required: true, |
167 | - component:'Input', | ||
168 | - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), | 161 | + component: 'Input', |
162 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | ||
169 | }, | 163 | }, |
170 | { | 164 | { |
171 | field: 'password', | 165 | field: 'password', |
172 | label: '密码', | 166 | label: '密码', |
173 | required: true, | 167 | required: true, |
174 | - component:'InputPassword', | ||
175 | - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), | 168 | + component: 'InputPassword', |
169 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | ||
176 | }, | 170 | }, |
177 | { | 171 | { |
178 | field: 'config', | 172 | field: 'config', |
179 | label: '消息配置', | 173 | label: '消息配置', |
180 | - component:'Input', | ||
181 | - show:false, | 174 | + component: 'Input', |
175 | + show: false, | ||
182 | }, | 176 | }, |
183 | { | 177 | { |
184 | field: 'id', | 178 | field: 'id', |
185 | label: '主键', | 179 | label: '主键', |
186 | - component:'Input', | ||
187 | - show:false, | 180 | + component: 'Input', |
181 | + show: false, | ||
188 | }, | 182 | }, |
189 | { | 183 | { |
190 | field: 'status', | 184 | field: 'status', |
@@ -202,5 +196,12 @@ export const formSchema: FormSchema[] = [ | @@ -202,5 +196,12 @@ export const formSchema: FormSchema[] = [ | ||
202 | label: '备注', | 196 | label: '备注', |
203 | field: 'remark', | 197 | field: 'remark', |
204 | component: 'InputTextArea', | 198 | component: 'InputTextArea', |
205 | - } | 199 | + }, |
206 | ]; | 200 | ]; |
201 | + | ||
202 | +export const isMessage = (type: string) => { | ||
203 | + return type === MessageEnum.IS_SMS; | ||
204 | +}; | ||
205 | +export const isEmail = (type: string) => { | ||
206 | + return type === MessageEnum.IS_EMAIL; | ||
207 | +}; |
@@ -4,40 +4,61 @@ | @@ -4,40 +4,61 @@ | ||
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 #deviceProfile="{record}"> | ||
11 | - <a-button type="link" class="ml-2" @click="goDeviceProfile"> {{record.deviceProfile.name}} </a-button> | 10 | + <template #deviceProfile="{ record }"> |
11 | + <a-button type="link" class="ml-2" @click="goDeviceProfile"> | ||
12 | + {{ record.deviceProfile.name }} | ||
13 | + </a-button> | ||
12 | </template> | 14 | </template> |
13 | - <template #deviceType = "{record}"> | 15 | + <template #deviceType="{ record }"> |
14 | <Tag color="success" class="ml-2"> | 16 | <Tag color="success" class="ml-2"> |
15 | - {{record.deviceType==DeviceTypeEnum.GATEWAY ?'网关设备': | ||
16 | - record.deviceType==DeviceTypeEnum.DIRECT_CONNECTION ?'直连设备':'网关子设备'}} | 17 | + {{ |
18 | + record.deviceType == DeviceTypeEnum.GATEWAY | ||
19 | + ? '网关设备' | ||
20 | + : record.deviceType == DeviceTypeEnum.DIRECT_CONNECTION | ||
21 | + ? '直连设备' | ||
22 | + : '网关子设备' | ||
23 | + }} | ||
17 | </Tag> | 24 | </Tag> |
18 | </template> | 25 | </template> |
19 | - <template #deviceState = "{record}"> | ||
20 | - <Tag :color="record.deviceState==DeviceState.INACTIVE?'warning':record.deviceState==DeviceState.ONLINE?'success':'error'" class="ml-2"> | ||
21 | - {{record.deviceState==DeviceState.INACTIVE ?'待激活': | ||
22 | - record.deviceState==DeviceState.ONLINE ?'在线':'离线'}} | 26 | + <template #deviceState="{ record }"> |
27 | + <Tag | ||
28 | + :color=" | ||
29 | + record.deviceState == DeviceState.INACTIVE | ||
30 | + ? 'warning' | ||
31 | + : record.deviceState == DeviceState.ONLINE | ||
32 | + ? 'success' | ||
33 | + : 'error' | ||
34 | + " | ||
35 | + class="ml-2" | ||
36 | + > | ||
37 | + {{ | ||
38 | + record.deviceState == DeviceState.INACTIVE | ||
39 | + ? '待激活' | ||
40 | + : record.deviceState == DeviceState.ONLINE | ||
41 | + ? '在线' | ||
42 | + : '离线' | ||
43 | + }} | ||
23 | </Tag> | 44 | </Tag> |
24 | </template> | 45 | </template> |
25 | <template #action="{ record }"> | 46 | <template #action="{ record }"> |
26 | <TableAction | 47 | <TableAction |
27 | :actions="[ | 48 | :actions="[ |
28 | { | 49 | { |
29 | - label:'编辑', | 50 | + label: '编辑', |
30 | icon: 'clarity:note-edit-line', | 51 | icon: 'clarity:note-edit-line', |
31 | onClick: handleEdit.bind(null, record), | 52 | onClick: handleEdit.bind(null, record), |
32 | }, | 53 | }, |
33 | { | 54 | { |
34 | - label:'删除', | 55 | + label: '删除', |
35 | icon: 'ant-design:delete-outlined', | 56 | icon: 'ant-design:delete-outlined', |
36 | color: 'error', | 57 | color: 'error', |
37 | popConfirm: { | 58 | popConfirm: { |
38 | title: '是否确认删除', | 59 | title: '是否确认删除', |
39 | confirm: handleDelete.bind(null, record), | 60 | confirm: handleDelete.bind(null, record), |
40 | - } | 61 | + }, |
41 | }, | 62 | }, |
42 | ]" | 63 | ]" |
43 | /> | 64 | /> |
@@ -47,93 +68,94 @@ | @@ -47,93 +68,94 @@ | ||
47 | </div> | 68 | </div> |
48 | </template> | 69 | </template> |
49 | <script lang="ts"> | 70 | <script lang="ts"> |
50 | -import { defineComponent,h} from 'vue'; | ||
51 | -import {DeviceState, DeviceTypeEnum} from "/@/api/device/model/deviceModel"; | ||
52 | -import { BasicTable, useTable, TableAction } from '/@/components/Table'; | ||
53 | -import { useDrawer } from '/@/components/Drawer'; | ||
54 | -import ConfigDrawer from './DeviceDrawer.vue'; | ||
55 | -import { columns, searchFormSchema } from './config.data'; | ||
56 | -import {Modal, Tag} from 'ant-design-vue'; | ||
57 | -import { CodeEditor,JsonPreview } from '/@/components/CodeEditor'; | ||
58 | -import {useMessage} from "/@/hooks/web/useMessage"; | ||
59 | -import {deleteDevice, devicePage} from "/@/api/device/deviceManager"; | ||
60 | -import {PageEnum} from "/@/enums/pageEnum"; | ||
61 | -import {useGo} from "/@/hooks/web/usePage"; | 71 | + import { defineComponent, h } from 'vue'; |
72 | + import { DeviceState, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; | ||
73 | + 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 { JsonPreview } from '/@/components/CodeEditor'; | ||
79 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
80 | + import { deleteDevice, devicePage } from '/@/api/device/deviceManager'; | ||
81 | + import { PageEnum } from '/@/enums/pageEnum'; | ||
82 | + import { useGo } from '/@/hooks/web/usePage'; | ||
62 | 83 | ||
63 | -export default defineComponent({ | ||
64 | - name: 'DeviceManagement', | ||
65 | - components: { BasicTable, ConfigDrawer, TableAction ,CodeEditor,Tag}, | ||
66 | - setup() { | ||
67 | - const [registerDrawer, { openDrawer }] = useDrawer(); | ||
68 | - const {createMessage} = useMessage(); | ||
69 | - const go = useGo(); | ||
70 | - const [registerTable, { reload }] = useTable({ | ||
71 | - title: '设备列表', | ||
72 | - api: devicePage, | ||
73 | - columns, | ||
74 | - formConfig: { | ||
75 | - labelWidth: 120, | ||
76 | - schemas: searchFormSchema, | ||
77 | - }, | ||
78 | - useSearchForm: true, | ||
79 | - showTableSetting: true, | ||
80 | - bordered: true, | ||
81 | - showIndexColumn: false, | ||
82 | - actionColumn: { | ||
83 | - width: 180, | ||
84 | - title: '操作', | ||
85 | - dataIndex: 'action', | ||
86 | - slots: { customRender: 'action' }, | ||
87 | - fixed: undefined, | ||
88 | - }, | ||
89 | - }); | ||
90 | - | ||
91 | - function handleCreate() { | ||
92 | - openDrawer(true, { | ||
93 | - isUpdate: false, | ||
94 | - }); | ||
95 | - } | ||
96 | - | ||
97 | - function handleEdit(record: Recordable) { | ||
98 | - openDrawer(true, { | ||
99 | - record, | ||
100 | - isUpdate: true, | ||
101 | - }); | ||
102 | - } | ||
103 | - | ||
104 | - function handleDelete(record: Recordable) { | ||
105 | - let ids = [record.id]; | ||
106 | - deleteDevice(ids).then(()=>{ | ||
107 | - createMessage.success("删除设备成功") | ||
108 | - handleSuccess() | ||
109 | - }); | ||
110 | - } | ||
111 | - | ||
112 | - function handleSuccess() { | ||
113 | - reload(); | ||
114 | - } | ||
115 | - function showData(record: Recordable){ | ||
116 | - Modal.info({ | ||
117 | - title: '当前配置', | ||
118 | - width:480, | ||
119 | - content: h(JsonPreview, { data: JSON.parse(JSON.stringify(record.deviceInfo)) }), | 84 | + export default defineComponent({ |
85 | + name: 'DeviceManagement', | ||
86 | + components: { BasicTable, ConfigDrawer, TableAction, Tag }, | ||
87 | + setup() { | ||
88 | + const go = useGo(); | ||
89 | + const { createMessage } = useMessage(); | ||
90 | + const [registerDrawer, { openDrawer }] = useDrawer(); | ||
91 | + const [registerTable, { reload }] = useTable({ | ||
92 | + title: '设备列表', | ||
93 | + api: devicePage, | ||
94 | + columns, | ||
95 | + formConfig: { | ||
96 | + labelWidth: 120, | ||
97 | + schemas: searchFormSchema, | ||
98 | + }, | ||
99 | + useSearchForm: true, | ||
100 | + showTableSetting: true, | ||
101 | + bordered: true, | ||
102 | + showIndexColumn: false, | ||
103 | + actionColumn: { | ||
104 | + width: 180, | ||
105 | + title: '操作', | ||
106 | + dataIndex: 'action', | ||
107 | + slots: { customRender: 'action' }, | ||
108 | + fixed: undefined, | ||
109 | + }, | ||
120 | }); | 110 | }); |
121 | - } | ||
122 | - function goDeviceProfile(){ | ||
123 | - go(PageEnum.DEVICE_PROFILE) | ||
124 | - } | ||
125 | - return { | ||
126 | - registerTable, | ||
127 | - registerDrawer, | ||
128 | - showData, | ||
129 | - handleCreate, | ||
130 | - handleEdit, | ||
131 | - handleDelete, | ||
132 | - handleSuccess, | ||
133 | - goDeviceProfile, | ||
134 | - DeviceTypeEnum, | ||
135 | - DeviceState | ||
136 | - }; | ||
137 | - }, | ||
138 | -}); | 111 | + // 新增 |
112 | + function handleCreate() { | ||
113 | + openDrawer(true, { | ||
114 | + isUpdate: false, | ||
115 | + }); | ||
116 | + } | ||
117 | + // 更新 | ||
118 | + function handleEdit(record: Recordable) { | ||
119 | + openDrawer(true, { | ||
120 | + record, | ||
121 | + isUpdate: true, | ||
122 | + }); | ||
123 | + } | ||
124 | + // 删除 | ||
125 | + function handleDelete(record: Recordable) { | ||
126 | + let ids = [record.id]; | ||
127 | + deleteDevice(ids).then(() => { | ||
128 | + createMessage.success('删除设备成功'); | ||
129 | + handleSuccess(); | ||
130 | + }); | ||
131 | + } | ||
132 | + // 刷新 | ||
133 | + function handleSuccess() { | ||
134 | + reload(); | ||
135 | + } | ||
136 | + // 查看某一个设备具体信息 | ||
137 | + function showData(record: Recordable) { | ||
138 | + Modal.info({ | ||
139 | + title: '当前配置', | ||
140 | + width: 480, | ||
141 | + content: h(JsonPreview, { data: JSON.parse(JSON.stringify(record.deviceInfo)) }), | ||
142 | + }); | ||
143 | + } | ||
144 | + function goDeviceProfile() { | ||
145 | + go(PageEnum.DEVICE_PROFILE); | ||
146 | + } | ||
147 | + return { | ||
148 | + registerTable, | ||
149 | + registerDrawer, | ||
150 | + showData, | ||
151 | + handleCreate, | ||
152 | + handleEdit, | ||
153 | + handleDelete, | ||
154 | + handleSuccess, | ||
155 | + goDeviceProfile, | ||
156 | + DeviceTypeEnum, | ||
157 | + DeviceState, | ||
158 | + }; | ||
159 | + }, | ||
160 | + }); | ||
139 | </script> | 161 | </script> |
@@ -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> |
@@ -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 | } |
@@ -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> |
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | </template> | 13 | </template> |
14 | 14 | ||
15 | <script lang="ts"> | 15 | <script lang="ts"> |
16 | - import { Tabs, } from 'ant-design-vue'; | 16 | + import { Tabs } from 'ant-design-vue'; |
17 | import { defineComponent } from 'vue'; | 17 | import { defineComponent } from 'vue'; |
18 | import SmsLog from './item/SmsLog.vue'; | 18 | import SmsLog from './item/SmsLog.vue'; |
19 | import EmailLog from './item/EmailLog.vue'; | 19 | import EmailLog from './item/EmailLog.vue'; |
1 | <template> | 1 | <template> |
2 | - <BasicModal v-bind="$attrs" @register="register" title="邮件发送参数" | ||
3 | - :okButtonProps="{ disabled: true }" | ||
4 | - @ok="handleOK" | ||
5 | - width="700px"> | 2 | + <BasicModal |
3 | + v-bind="$attrs" | ||
4 | + @register="register" | ||
5 | + title="邮件发送参数" | ||
6 | + :okButtonProps="{ disabled: true }" | ||
7 | + @ok="handleOK" | ||
8 | + width="700px" | ||
9 | + > | ||
6 | <div class="pt-6px pr-6px"> | 10 | <div class="pt-6px pr-6px"> |
7 | - <BasicForm @register="registerForm"/> | 11 | + <BasicForm @register="registerForm" /> |
8 | </div> | 12 | </div> |
9 | </BasicModal> | 13 | </BasicModal> |
10 | </template> | 14 | </template> |
11 | <script lang="ts"> | 15 | <script lang="ts"> |
12 | -import { defineComponent,h } from 'vue'; | ||
13 | -import { BasicModal, useModalInner } from '/@/components/Modal'; | ||
14 | -import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; | ||
15 | -import { Tinymce } from '/@/components/Tinymce'; | ||
16 | -const schemas: FormSchema[] = [ | ||
17 | - { | ||
18 | - field: 'emailBody', | ||
19 | - component: 'Input', | ||
20 | - label: '', | ||
21 | - rules: [{ required: true }], | ||
22 | - render: ({ model, field }) => { | ||
23 | - return h(Tinymce, { | ||
24 | - value: model[field], | ||
25 | - showImageUpload:false, | ||
26 | - onChange: (value: string) => { | ||
27 | - model[field] = value; | 16 | + import { defineComponent, h } from 'vue'; |
17 | + import { BasicModal, useModalInner } from '/@/components/Modal'; | ||
18 | + import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; | ||
19 | + import { Tinymce } from '/@/components/Tinymce'; | ||
20 | + const schemas: FormSchema[] = [ | ||
21 | + { | ||
22 | + field: 'emailBody', | ||
23 | + component: 'Input', | ||
24 | + label: '', | ||
25 | + rules: [{ required: true }], | ||
26 | + render: ({ model, field }) => { | ||
27 | + return h(Tinymce, { | ||
28 | + value: model[field], | ||
29 | + showImageUpload: false, | ||
30 | + onChange: (value: string) => { | ||
31 | + model[field] = value; | ||
32 | + }, | ||
33 | + }); | ||
34 | + }, | ||
35 | + }, | ||
36 | + ]; | ||
37 | + export default defineComponent({ | ||
38 | + components: { BasicModal, BasicForm }, | ||
39 | + setup() { | ||
40 | + const [registerForm, { resetFields, setFieldsValue }] = useForm({ | ||
41 | + labelWidth: 70, | ||
42 | + schemas, | ||
43 | + showActionButtonGroup: false, | ||
44 | + actionColOptions: { | ||
45 | + span: 24, | ||
28 | }, | 46 | }, |
29 | }); | 47 | }); |
30 | - }, | ||
31 | - }, | ||
32 | -]; | ||
33 | -export default defineComponent({ | ||
34 | - components: { BasicModal, BasicForm}, | ||
35 | - setup() { | ||
36 | - const [registerForm,{resetFields,setFieldsValue},] = useForm({ | ||
37 | - labelWidth: 70, | ||
38 | - schemas, | ||
39 | - showActionButtonGroup: false, | ||
40 | - actionColOptions: { | ||
41 | - span: 24, | ||
42 | - }, | ||
43 | - }); | ||
44 | - const [register,{closeModal}] = useModalInner(async(data) => { | ||
45 | - await resetFields(); | ||
46 | - await setFieldsValue({ | ||
47 | - ...data.record, | 48 | + const [register, { closeModal }] = useModalInner(async (data) => { |
49 | + await resetFields(); | ||
50 | + await setFieldsValue({ | ||
51 | + ...data.record, | ||
52 | + }); | ||
48 | }); | 53 | }); |
49 | - }); | ||
50 | 54 | ||
51 | - async function handleOK() { | ||
52 | - closeModal(); | ||
53 | - } | 55 | + async function handleOK() { |
56 | + closeModal(); | ||
57 | + } | ||
54 | 58 | ||
55 | - return { register, schemas, registerForm, handleOK }; | ||
56 | - }, | ||
57 | -}); | 59 | + return { register, schemas, registerForm, handleOK }; |
60 | + }, | ||
61 | + }); | ||
58 | </script> | 62 | </script> |
@@ -8,12 +8,12 @@ | @@ -8,12 +8,12 @@ | ||
8 | <TableAction | 8 | <TableAction |
9 | :actions="[ | 9 | :actions="[ |
10 | { | 10 | { |
11 | - label:'查看', | 11 | + label: '查看', |
12 | icon: 'ant-design:fund-view-outlined', | 12 | icon: 'ant-design:fund-view-outlined', |
13 | onClick: handleModal.bind(null, record), | 13 | onClick: handleModal.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: { |
@@ -25,81 +25,79 @@ | @@ -25,81 +25,79 @@ | ||
25 | /> | 25 | /> |
26 | </template> | 26 | </template> |
27 | </BasicTable> | 27 | </BasicTable> |
28 | - <EmailDetail @register="registerModal"/> | 28 | + <EmailDetail @register="registerModal" /> |
29 | </div> | 29 | </div> |
30 | </template> | 30 | </template> |
31 | <script lang="ts"> | 31 | <script lang="ts"> |
32 | -import { defineComponent } from 'vue'; | 32 | + import { defineComponent } from 'vue'; |
33 | 33 | ||
34 | -import { BasicTable, useTable, TableAction } from '/@/components/Table'; | ||
35 | -import { BasicDrawer,useDrawerInner } from '/@/components/Drawer'; | ||
36 | -import { columns, searchFormSchema } from './email.data'; | ||
37 | -import {Tag} from "ant-design-vue"; | ||
38 | -import {useMessage} from "/@/hooks/web/useMessage"; | ||
39 | -import {deleteSmsLog, mailLogPage} from "/@/api/message/records"; | ||
40 | -import {useModal} from "/@/components/Modal"; | ||
41 | -import EmailDetail from "/@/views/message/records/item/EmailDetail.vue"; | ||
42 | -export default defineComponent({ | ||
43 | - name: 'EmailLog', | ||
44 | - components: {EmailDetail, BasicDrawer, BasicTable, TableAction ,Tag}, | ||
45 | - setup() { | ||
46 | - const [registerModal, { openModal}] = useModal(); | ||
47 | - const { createMessage } = useMessage(); | ||
48 | - const [register] = useDrawerInner(() => { | ||
49 | - }); | ||
50 | - const [registerTable, { reload }] = useTable({ | ||
51 | - title: '邮件发送列表', | ||
52 | - api: mailLogPage, | ||
53 | - columns, | ||
54 | - formConfig: { | ||
55 | - labelWidth: 120, | ||
56 | - schemas: searchFormSchema, | ||
57 | - fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | ||
58 | - }, | ||
59 | - useSearchForm: true, | ||
60 | - showTableSetting: true, | ||
61 | - bordered: true, | ||
62 | - showIndexColumn: false, | ||
63 | - actionColumn: { | ||
64 | - width: 140, | ||
65 | - title: '操作', | ||
66 | - dataIndex: 'action', | ||
67 | - slots: { customRender: 'action' }, | ||
68 | - fixed: undefined, | ||
69 | - }, | ||
70 | - immediate:true | ||
71 | - }); | 34 | + import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
35 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
36 | + import { columns, searchFormSchema } from './email.data'; | ||
37 | + import { Tag } from 'ant-design-vue'; | ||
38 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
39 | + import { deleteSmsLog, mailLogPage } from '/@/api/message/records'; | ||
40 | + import { useModal } from '/@/components/Modal'; | ||
41 | + import EmailDetail from '/@/views/message/records/item/EmailDetail.vue'; | ||
42 | + export default defineComponent({ | ||
43 | + name: 'EmailLog', | ||
44 | + components: { EmailDetail, BasicDrawer, BasicTable, TableAction, Tag }, | ||
45 | + setup() { | ||
46 | + const [registerModal, { openModal }] = useModal(); | ||
47 | + const { createMessage } = useMessage(); | ||
48 | + const [register] = useDrawerInner(() => {}); | ||
49 | + const [registerTable, { reload }] = useTable({ | ||
50 | + title: '邮件发送列表', | ||
51 | + api: mailLogPage, | ||
52 | + columns, | ||
53 | + formConfig: { | ||
54 | + labelWidth: 120, | ||
55 | + schemas: searchFormSchema, | ||
56 | + fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | ||
57 | + }, | ||
58 | + useSearchForm: true, | ||
59 | + showTableSetting: true, | ||
60 | + bordered: true, | ||
61 | + showIndexColumn: false, | ||
62 | + actionColumn: { | ||
63 | + width: 140, | ||
64 | + title: '操作', | ||
65 | + dataIndex: 'action', | ||
66 | + slots: { customRender: 'action' }, | ||
67 | + fixed: undefined, | ||
68 | + }, | ||
69 | + immediate: true, | ||
70 | + }); | ||
72 | 71 | ||
73 | - function handleCreate() { | ||
74 | - } | 72 | + function handleCreate() {} |
75 | 73 | ||
76 | - function handleModal(record: Recordable) { | ||
77 | - openModal(true,{ | ||
78 | - record, | ||
79 | - }) | ||
80 | - } | 74 | + function handleModal(record: Recordable) { |
75 | + openModal(true, { | ||
76 | + record, | ||
77 | + }); | ||
78 | + } | ||
81 | 79 | ||
82 | - function handleDelete(record: Recordable) { | ||
83 | - let ids = [record.id]; | ||
84 | - deleteSmsLog(ids).then((result)=>{ | ||
85 | - createMessage.success(result.message) | ||
86 | - handleSuccess() | ||
87 | - }); | ||
88 | - } | 80 | + function handleDelete(record: Recordable) { |
81 | + let ids = [record.id]; | ||
82 | + deleteSmsLog(ids).then((result) => { | ||
83 | + createMessage.success(result.message); | ||
84 | + handleSuccess(); | ||
85 | + }); | ||
86 | + } | ||
89 | 87 | ||
90 | - function handleSuccess() { | ||
91 | - reload(); | ||
92 | - } | 88 | + function handleSuccess() { |
89 | + reload(); | ||
90 | + } | ||
93 | 91 | ||
94 | - return { | ||
95 | - register, | ||
96 | - registerTable, | ||
97 | - registerModal, | ||
98 | - handleCreate, | ||
99 | - handleDelete, | ||
100 | - handleModal, | ||
101 | - handleSuccess | ||
102 | - }; | ||
103 | - }, | ||
104 | -}); | 92 | + return { |
93 | + register, | ||
94 | + registerTable, | ||
95 | + registerModal, | ||
96 | + handleCreate, | ||
97 | + handleDelete, | ||
98 | + handleModal, | ||
99 | + handleSuccess, | ||
100 | + }; | ||
101 | + }, | ||
102 | + }); | ||
105 | </script> | 103 | </script> |
@@ -8,12 +8,12 @@ | @@ -8,12 +8,12 @@ | ||
8 | <TableAction | 8 | <TableAction |
9 | :actions="[ | 9 | :actions="[ |
10 | { | 10 | { |
11 | - label:'查看', | 11 | + label: '查看', |
12 | icon: 'ant-design:fund-view-outlined', | 12 | icon: 'ant-design:fund-view-outlined', |
13 | onClick: handleQuery.bind(null, record), | 13 | onClick: handleQuery.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: { |
@@ -28,76 +28,74 @@ | @@ -28,76 +28,74 @@ | ||
28 | </div> | 28 | </div> |
29 | </template> | 29 | </template> |
30 | <script lang="ts"> | 30 | <script lang="ts"> |
31 | -import {defineComponent, h} from 'vue'; | 31 | + import { defineComponent, h } from 'vue'; |
32 | 32 | ||
33 | -import { BasicTable, useTable, TableAction } from '/@/components/Table'; | ||
34 | -import { BasicDrawer,useDrawerInner } from '/@/components/Drawer'; | ||
35 | -import { columns, searchFormSchema } from './sms.data'; | ||
36 | -import {Modal, Tag} from "ant-design-vue"; | ||
37 | -import {useMessage} from "/@/hooks/web/useMessage"; | ||
38 | -import {smsLogPage,deleteSmsLog} from "/@/api/message/records"; | ||
39 | -import {JsonPreview} from "/@/components/CodeEditor"; | 33 | + import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
34 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
35 | + import { columns, searchFormSchema } from './sms.data'; | ||
36 | + import { Modal, Tag } from 'ant-design-vue'; | ||
37 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
38 | + import { smsLogPage, deleteSmsLog } from '/@/api/message/records'; | ||
39 | + import { JsonPreview } from '/@/components/CodeEditor'; | ||
40 | 40 | ||
41 | -export default defineComponent({ | ||
42 | - name: 'SmsLog', | ||
43 | - components: {BasicDrawer, BasicTable, TableAction ,Tag}, | ||
44 | - setup() { | ||
45 | - const { createMessage } = useMessage(); | ||
46 | - const [register] = useDrawerInner(() => { | ||
47 | - }); | ||
48 | - const [registerTable, { reload }] = useTable({ | ||
49 | - title: '短信发送列表', | ||
50 | - api: smsLogPage, | ||
51 | - columns, | ||
52 | - formConfig: { | ||
53 | - labelWidth: 120, | ||
54 | - schemas: searchFormSchema, | ||
55 | - fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | ||
56 | - }, | ||
57 | - useSearchForm: true, | ||
58 | - showTableSetting: true, | ||
59 | - bordered: true, | ||
60 | - showIndexColumn: false, | ||
61 | - actionColumn: { | ||
62 | - width: 140, | ||
63 | - title: '操作', | ||
64 | - dataIndex: 'action', | ||
65 | - slots: { customRender: 'action' }, | ||
66 | - fixed: undefined, | ||
67 | - }, | ||
68 | - }); | 41 | + export default defineComponent({ |
42 | + name: 'SmsLog', | ||
43 | + components: { BasicDrawer, BasicTable, TableAction, Tag }, | ||
44 | + setup() { | ||
45 | + const { createMessage } = useMessage(); | ||
46 | + const [register] = useDrawerInner(() => {}); | ||
47 | + const [registerTable, { reload }] = useTable({ | ||
48 | + title: '短信发送列表', | ||
49 | + api: smsLogPage, | ||
50 | + columns, | ||
51 | + formConfig: { | ||
52 | + labelWidth: 120, | ||
53 | + schemas: searchFormSchema, | ||
54 | + fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | ||
55 | + }, | ||
56 | + useSearchForm: true, | ||
57 | + showTableSetting: true, | ||
58 | + bordered: true, | ||
59 | + showIndexColumn: false, | ||
60 | + actionColumn: { | ||
61 | + width: 140, | ||
62 | + title: '操作', | ||
63 | + dataIndex: 'action', | ||
64 | + slots: { customRender: 'action' }, | ||
65 | + fixed: undefined, | ||
66 | + }, | ||
67 | + }); | ||
69 | 68 | ||
70 | - function handleCreate() { | ||
71 | - } | 69 | + function handleCreate() {} |
72 | 70 | ||
73 | - function handleQuery(record: Recordable) { | ||
74 | - Modal.info({ | ||
75 | - title: '当前配置', | ||
76 | - width:480, | ||
77 | - content: h(JsonPreview, { data: JSON.parse(JSON.stringify(record.templateParam)) }), | ||
78 | - }); | ||
79 | - } | 71 | + function handleQuery(record: Recordable) { |
72 | + Modal.info({ | ||
73 | + title: '当前配置', | ||
74 | + width: 480, | ||
75 | + content: h(JsonPreview, { data: JSON.parse(JSON.stringify(record.templateParam)) }), | ||
76 | + }); | ||
77 | + } | ||
80 | 78 | ||
81 | - function handleDelete(record: Recordable) { | ||
82 | - let ids = [record.id]; | ||
83 | - deleteSmsLog(ids).then((result)=>{ | ||
84 | - createMessage.success(result.message) | ||
85 | - handleSuccess() | ||
86 | - }); | ||
87 | - } | 79 | + function handleDelete(record: Recordable) { |
80 | + let ids = [record.id]; | ||
81 | + deleteSmsLog(ids).then((result) => { | ||
82 | + createMessage.success(result.message); | ||
83 | + handleSuccess(); | ||
84 | + }); | ||
85 | + } | ||
88 | 86 | ||
89 | - function handleSuccess() { | ||
90 | - reload(); | ||
91 | - } | 87 | + function handleSuccess() { |
88 | + reload(); | ||
89 | + } | ||
92 | 90 | ||
93 | - return { | ||
94 | - register, | ||
95 | - registerTable, | ||
96 | - handleCreate, | ||
97 | - handleDelete, | ||
98 | - handleSuccess, | ||
99 | - handleQuery | ||
100 | - }; | ||
101 | - }, | ||
102 | -}); | 91 | + return { |
92 | + register, | ||
93 | + registerTable, | ||
94 | + handleCreate, | ||
95 | + handleDelete, | ||
96 | + handleSuccess, | ||
97 | + handleQuery, | ||
98 | + }; | ||
99 | + }, | ||
100 | + }); | ||
103 | </script> | 101 | </script> |
1 | <template> | 1 | <template> |
2 | - <BasicModal v-bind="$attrs" @register="register" title="邮件发送参数" @ok="handleOK" | ||
3 | - width="700px"> | 2 | + <BasicModal |
3 | + v-bind="$attrs" | ||
4 | + @register="register" | ||
5 | + title="邮件发送参数" | ||
6 | + @ok="handleOK" | ||
7 | + width="700px" | ||
8 | + > | ||
4 | <div class="pt-6px pr-6px"> | 9 | <div class="pt-6px pr-6px"> |
5 | - <BasicForm @register="registerForm"/> | 10 | + <BasicForm @register="registerForm" /> |
6 | </div> | 11 | </div> |
7 | </BasicModal> | 12 | </BasicModal> |
8 | </template> | 13 | </template> |
9 | <script lang="ts"> | 14 | <script lang="ts"> |
10 | -import { defineComponent,h } from 'vue'; | ||
11 | -import { BasicModal, useModalInner } from '/@/components/Modal'; | ||
12 | -import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; | ||
13 | -import {useMessage} from "/@/hooks/web/useMessage"; | ||
14 | -import { Tinymce } from '/@/components/Tinymce'; | ||
15 | -import {sendEmail} from "/@/api/message/template"; | ||
16 | -const schemas: FormSchema[] = [ | ||
17 | - { | ||
18 | - field: 'id', | ||
19 | - component: 'Input', | ||
20 | - label: 'id', | ||
21 | - show:false | ||
22 | - }, | ||
23 | - { | ||
24 | - field: 'templatePurpose', | ||
25 | - label: '用途', | ||
26 | - component:'Input', | ||
27 | - show:false, | ||
28 | - }, | ||
29 | - { | ||
30 | - field: 'messageType', | ||
31 | - component: 'Input', | ||
32 | - label: 'messageType', | ||
33 | - show:false | ||
34 | - }, | ||
35 | - { | ||
36 | - field: 'subject', | ||
37 | - component: 'Input', | ||
38 | - label: '邮件主题', | ||
39 | - required: true, | ||
40 | - colProps: { | ||
41 | - span: 12, | 15 | + import { defineComponent, h } from 'vue'; |
16 | + import { BasicModal, useModalInner } from '/@/components/Modal'; | ||
17 | + import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; | ||
18 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
19 | + import { Tinymce } from '/@/components/Tinymce'; | ||
20 | + import { sendEmail } from '/@/api/message/template'; | ||
21 | + const schemas: FormSchema[] = [ | ||
22 | + { | ||
23 | + field: 'id', | ||
24 | + component: 'Input', | ||
25 | + label: 'id', | ||
26 | + show: false, | ||
42 | }, | 27 | }, |
43 | - }, | ||
44 | - { | ||
45 | - field: 'to', | ||
46 | - component: 'Input', | ||
47 | - label: '主送', | ||
48 | - required: true, | ||
49 | - colProps: { | ||
50 | - span: 12, | 28 | + { |
29 | + field: 'templatePurpose', | ||
30 | + label: '用途', | ||
31 | + component: 'Input', | ||
32 | + show: false, | ||
51 | }, | 33 | }, |
52 | - }, | ||
53 | - { | ||
54 | - field: 'cc', | ||
55 | - component: 'Input', | ||
56 | - label: '抄送', | ||
57 | - colProps: { | ||
58 | - span: 12, | 34 | + { |
35 | + field: 'messageType', | ||
36 | + component: 'Input', | ||
37 | + label: 'messageType', | ||
38 | + show: false, | ||
59 | }, | 39 | }, |
60 | - }, | ||
61 | - { | ||
62 | - field: 'bcc', | ||
63 | - component: 'Input', | ||
64 | - label: '密送', | ||
65 | - colProps: { | ||
66 | - span: 12, | 40 | + { |
41 | + field: 'subject', | ||
42 | + component: 'Input', | ||
43 | + label: '邮件主题', | ||
44 | + required: true, | ||
45 | + colProps: { | ||
46 | + span: 12, | ||
47 | + }, | ||
67 | }, | 48 | }, |
68 | - }, | ||
69 | - { | ||
70 | - field: 'body', | ||
71 | - component: 'Input', | ||
72 | - label: '邮件内容', | ||
73 | - rules: [{ required: true }], | ||
74 | - render: ({ model, field }) => { | ||
75 | - return h(Tinymce, { | ||
76 | - value: model[field], | ||
77 | - onChange: (value: string) => { | ||
78 | - model[field] = value; | ||
79 | - }, | ||
80 | - }); | 49 | + { |
50 | + field: 'to', | ||
51 | + component: 'Input', | ||
52 | + label: '主送', | ||
53 | + required: true, | ||
54 | + colProps: { | ||
55 | + span: 12, | ||
56 | + }, | ||
81 | }, | 57 | }, |
82 | - }, | ||
83 | -]; | ||
84 | -export default defineComponent({ | ||
85 | - components: { BasicModal, BasicForm}, | ||
86 | - setup() { | ||
87 | - const {createMessage} = useMessage(); | ||
88 | - const [registerForm,{validate,resetFields,setFieldsValue},] = useForm({ | ||
89 | - labelWidth: 70, | ||
90 | - schemas, | ||
91 | - showActionButtonGroup: false, | ||
92 | - actionColOptions: { | ||
93 | - span: 24, | 58 | + { |
59 | + field: 'cc', | ||
60 | + component: 'Input', | ||
61 | + label: '抄送', | ||
62 | + colProps: { | ||
63 | + span: 12, | ||
94 | }, | 64 | }, |
95 | - }); | ||
96 | - const [register,{closeModal}] = useModalInner(async(data) => { | ||
97 | - await resetFields(); | ||
98 | - await setFieldsValue({ | ||
99 | - ...data.record, | 65 | + }, |
66 | + { | ||
67 | + field: 'bcc', | ||
68 | + component: 'Input', | ||
69 | + label: '密送', | ||
70 | + colProps: { | ||
71 | + span: 12, | ||
72 | + }, | ||
73 | + }, | ||
74 | + { | ||
75 | + field: 'body', | ||
76 | + component: 'Input', | ||
77 | + label: '邮件内容', | ||
78 | + rules: [{ required: true }], | ||
79 | + render: ({ model, field }) => { | ||
80 | + return h(Tinymce, { | ||
81 | + value: model[field], | ||
82 | + onChange: (value: string) => { | ||
83 | + model[field] = value; | ||
84 | + }, | ||
85 | + }); | ||
86 | + }, | ||
87 | + }, | ||
88 | + ]; | ||
89 | + export default defineComponent({ | ||
90 | + components: { BasicModal, BasicForm }, | ||
91 | + setup() { | ||
92 | + const { createMessage } = useMessage(); | ||
93 | + const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({ | ||
94 | + labelWidth: 70, | ||
95 | + schemas, | ||
96 | + showActionButtonGroup: false, | ||
97 | + actionColOptions: { | ||
98 | + span: 24, | ||
99 | + }, | ||
100 | + }); | ||
101 | + const [register, { closeModal }] = useModalInner(async (data) => { | ||
102 | + await resetFields(); | ||
103 | + await setFieldsValue({ | ||
104 | + ...data.record, | ||
105 | + }); | ||
100 | }); | 106 | }); |
101 | - }); | ||
102 | 107 | ||
103 | - async function handleOK() { | ||
104 | - const values = await validate(); | ||
105 | - const to = Reflect.get(values,"to").split(","); | ||
106 | - const cc = Reflect.get(values,"cc"); | ||
107 | - const bcc = Reflect.get(values,"bcc"); | ||
108 | - if(typeof (cc) != "undefined"){ | ||
109 | - cc.split(","); | ||
110 | - Reflect.set(values,"cc",cc) | ||
111 | - } | ||
112 | - if(typeof (bcc) != "undefined"){ | ||
113 | - bcc.split(","); | ||
114 | - Reflect.set(values,"bcc",bcc) | 108 | + async function handleOK() { |
109 | + const values = await validate(); | ||
110 | + const to = Reflect.get(values, 'to').split(','); | ||
111 | + const cc = Reflect.get(values, 'cc'); | ||
112 | + const bcc = Reflect.get(values, 'bcc'); | ||
113 | + if (typeof cc != 'undefined') { | ||
114 | + cc.split(','); | ||
115 | + Reflect.set(values, 'cc', cc); | ||
116 | + } | ||
117 | + if (typeof bcc != 'undefined') { | ||
118 | + bcc.split(','); | ||
119 | + Reflect.set(values, 'bcc', bcc); | ||
120 | + } | ||
121 | + Reflect.set(values, 'to', to); | ||
122 | + Reflect.set(values, 'emailFormatEnum', 'HTML'); | ||
123 | + await sendEmail(values); | ||
124 | + console.log(values, 'values'); | ||
125 | + closeModal(); | ||
126 | + createMessage.success('发送成功'); | ||
115 | } | 127 | } |
116 | - Reflect.set(values,"to",to) | ||
117 | - Reflect.set(values,"emailFormatEnum","HTML") | ||
118 | - await sendEmail(values); | ||
119 | - console.log(values,"values") | ||
120 | - closeModal(); | ||
121 | - createMessage.success("发送成功") | ||
122 | - } | ||
123 | 128 | ||
124 | - return { register, schemas, registerForm, handleOK }; | ||
125 | - }, | ||
126 | -}); | 129 | + return { register, schemas, registerForm, handleOK }; |
130 | + }, | ||
131 | + }); | ||
127 | </script> | 132 | </script> |
1 | <template> | 1 | <template> |
2 | - <BasicModal | ||
3 | - v-bind="$attrs" | ||
4 | - @register="register" | ||
5 | - title="发送参数" | ||
6 | - @ok="handleOK" | ||
7 | - > | 2 | + <BasicModal v-bind="$attrs" @register="register" title="发送参数" @ok="handleOK"> |
8 | <div class="pt-4px pr-4px"> | 3 | <div class="pt-4px pr-4px"> |
9 | - <BasicForm @register="registerForm"/> | 4 | + <BasicForm @register="registerForm" /> |
10 | </div> | 5 | </div> |
11 | </BasicModal> | 6 | </BasicModal> |
12 | </template> | 7 | </template> |
13 | <script lang="ts"> | 8 | <script lang="ts"> |
14 | -import { defineComponent } from 'vue'; | ||
15 | -import { BasicModal, useModalInner } from '/@/components/Modal'; | ||
16 | -import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; | ||
17 | -import {sendSms} from "/@/api/message/template"; | ||
18 | -import {useMessage} from "/@/hooks/web/useMessage"; | ||
19 | -const schemas: FormSchema[] = [ | ||
20 | - { | ||
21 | - field: 'id', | ||
22 | - component: 'Input', | ||
23 | - label: 'id', | ||
24 | - show:false | ||
25 | - }, | ||
26 | - { | ||
27 | - field: 'templatePurpose', | ||
28 | - label: '用途', | ||
29 | - component:'Input', | ||
30 | - show:false, | ||
31 | - }, | ||
32 | - { | ||
33 | - field: 'messageType', | ||
34 | - component: 'Input', | ||
35 | - label: 'messageType', | ||
36 | - show:false | ||
37 | - }, | ||
38 | - { | ||
39 | - field: 'phoneNumbers', | ||
40 | - component: 'Input', | ||
41 | - label: '手机号码', | ||
42 | - required: true, | ||
43 | - }, | ||
44 | - { | ||
45 | - field: 'params', | ||
46 | - component: 'InputTextArea', | ||
47 | - label: '短信参数', | ||
48 | - required: true, | ||
49 | - componentProps:{ | ||
50 | - placeholder: '示例:{"code":"3654"}', | ||
51 | - } | ||
52 | - }, | ||
53 | - { | ||
54 | - field: 'remark', | ||
55 | - component: 'InputTextArea', | ||
56 | - label: '备注', | ||
57 | - }, | ||
58 | -]; | ||
59 | -export default defineComponent({ | ||
60 | - components: { BasicModal, BasicForm}, | ||
61 | - setup() { | ||
62 | - const {createMessage} = useMessage(); | ||
63 | - const [registerForm,{validate,resetFields,setFieldsValue},] = useForm({ | ||
64 | - labelWidth: 70, | ||
65 | - schemas, | ||
66 | - showActionButtonGroup: false, | ||
67 | - actionColOptions: { | ||
68 | - span: 24, | 9 | + import { defineComponent } from 'vue'; |
10 | + import { BasicModal, useModalInner } from '/@/components/Modal'; | ||
11 | + import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; | ||
12 | + import { sendSms } from '/@/api/message/template'; | ||
13 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
14 | + const schemas: FormSchema[] = [ | ||
15 | + { | ||
16 | + field: 'id', | ||
17 | + component: 'Input', | ||
18 | + label: 'id', | ||
19 | + show: false, | ||
20 | + }, | ||
21 | + { | ||
22 | + field: 'templatePurpose', | ||
23 | + label: '用途', | ||
24 | + component: 'Input', | ||
25 | + show: false, | ||
26 | + }, | ||
27 | + { | ||
28 | + field: 'messageType', | ||
29 | + component: 'Input', | ||
30 | + label: 'messageType', | ||
31 | + show: false, | ||
32 | + }, | ||
33 | + { | ||
34 | + field: 'phoneNumbers', | ||
35 | + component: 'Input', | ||
36 | + label: '手机号码', | ||
37 | + required: true, | ||
38 | + }, | ||
39 | + { | ||
40 | + field: 'params', | ||
41 | + component: 'InputTextArea', | ||
42 | + label: '短信参数', | ||
43 | + required: true, | ||
44 | + componentProps: { | ||
45 | + placeholder: '示例:{"code":"3654"}', | ||
69 | }, | 46 | }, |
70 | - }); | ||
71 | - const [register,{closeModal}] = useModalInner(async(data) => { | ||
72 | - await resetFields(); | ||
73 | - await setFieldsValue({ | ||
74 | - ...data.record, | 47 | + }, |
48 | + { | ||
49 | + field: 'remark', | ||
50 | + component: 'InputTextArea', | ||
51 | + label: '备注', | ||
52 | + }, | ||
53 | + ]; | ||
54 | + export default defineComponent({ | ||
55 | + components: { BasicModal, BasicForm }, | ||
56 | + setup() { | ||
57 | + const { createMessage } = useMessage(); | ||
58 | + const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({ | ||
59 | + labelWidth: 70, | ||
60 | + schemas, | ||
61 | + showActionButtonGroup: false, | ||
62 | + actionColOptions: { | ||
63 | + span: 24, | ||
64 | + }, | ||
65 | + }); | ||
66 | + const [register, { closeModal }] = useModalInner(async (data) => { | ||
67 | + await resetFields(); | ||
68 | + await setFieldsValue({ | ||
69 | + ...data.record, | ||
70 | + }); | ||
75 | }); | 71 | }); |
76 | - }); | ||
77 | 72 | ||
78 | - async function handleOK() { | ||
79 | - const values = await validate(); | ||
80 | - //将字符串转为json | ||
81 | - const smsParams = JSON.parse(Reflect.get(values,'params')) | ||
82 | - Reflect.set(values, 'params', smsParams); | ||
83 | - await sendSms(values) | ||
84 | - closeModal(); | ||
85 | - createMessage.success("发送成功") | ||
86 | - } | 73 | + async function handleOK() { |
74 | + const values = await validate(); | ||
75 | + //将字符串转为json | ||
76 | + const smsParams = JSON.parse(Reflect.get(values, 'params')); | ||
77 | + Reflect.set(values, 'params', smsParams); | ||
78 | + await sendSms(values); | ||
79 | + closeModal(); | ||
80 | + createMessage.success('发送成功'); | ||
81 | + } | ||
87 | 82 | ||
88 | - return {register, schemas, registerForm, handleOK }; | ||
89 | - }, | ||
90 | -}); | 83 | + return { register, schemas, registerForm, handleOK }; |
84 | + }, | ||
85 | + }); | ||
91 | </script> | 86 | </script> |
@@ -4,11 +4,11 @@ | @@ -4,11 +4,11 @@ | ||
4 | @register="registerDrawer" | 4 | @register="registerDrawer" |
5 | showFooter | 5 | showFooter |
6 | :title="getTitle" | 6 | :title="getTitle" |
7 | - :helpMessage="['用户登录、忘记密码模板平台只提供{code}参数','初始密码设置平台提供{name}参数']" | 7 | + :helpMessage="['用户登录、忘记密码模板平台只提供{code}参数', '初始密码设置平台提供{name}参数']" |
8 | width="500px" | 8 | width="500px" |
9 | @ok="handleSubmit" | 9 | @ok="handleSubmit" |
10 | > | 10 | > |
11 | - <BasicForm @register="registerForm"/> | 11 | + <BasicForm @register="registerForm" /> |
12 | </BasicDrawer> | 12 | </BasicDrawer> |
13 | </template> | 13 | </template> |
14 | <script lang="ts"> | 14 | <script lang="ts"> |
@@ -16,15 +16,15 @@ | @@ -16,15 +16,15 @@ | ||
16 | import { BasicForm, useForm } from '/@/components/Form'; | 16 | import { BasicForm, useForm } from '/@/components/Form'; |
17 | import { formSchema } from './template.data'; | 17 | import { formSchema } from './template.data'; |
18 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 18 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
19 | - import {saveOrEditMessageTemplate} from "/@/api/message/template"; | ||
20 | - import {useMessage} from "/@/hooks/web/useMessage"; | 19 | + import { saveOrEditMessageTemplate } from '/@/api/message/template'; |
20 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
21 | export default defineComponent({ | 21 | export default defineComponent({ |
22 | name: 'TemplateDrawer', | 22 | name: 'TemplateDrawer', |
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 | - const [registerForm, { validate,setFieldsValue,resetFields }] = useForm({ | 27 | + const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ |
28 | labelWidth: 120, | 28 | labelWidth: 120, |
29 | schemas: formSchema, | 29 | schemas: formSchema, |
30 | showActionButtonGroup: false, | 30 | showActionButtonGroup: false, |
@@ -36,8 +36,8 @@ | @@ -36,8 +36,8 @@ | ||
36 | isUpdate.value = !!data?.isUpdate; | 36 | isUpdate.value = !!data?.isUpdate; |
37 | if (unref(isUpdate)) { | 37 | if (unref(isUpdate)) { |
38 | const config = data.record.config; | 38 | const config = data.record.config; |
39 | - for (const key in config){ | ||
40 | - Reflect.set(data.record, key+'', config[key]); | 39 | + for (const key in config) { |
40 | + Reflect.set(data.record, key + '', config[key]); | ||
41 | } | 41 | } |
42 | await setFieldsValue({ | 42 | await setFieldsValue({ |
43 | ...data.record, | 43 | ...data.record, |
@@ -52,27 +52,27 @@ | @@ -52,27 +52,27 @@ | ||
52 | const values = await validate(); | 52 | const values = await validate(); |
53 | const { createMessage } = useMessage(); | 53 | const { createMessage } = useMessage(); |
54 | setDrawerProps({ confirmLoading: true }); | 54 | setDrawerProps({ confirmLoading: true }); |
55 | - let config={}; | ||
56 | - if(values.messageType === 'PHONE_MESSAGE'){ | ||
57 | - config ={ | ||
58 | - "accessKeyId":values.accessKeyId, | ||
59 | - "accessKeySecret":values.accessKeySecret, | ||
60 | - } | ||
61 | - }else if(values.messageType === 'EMAIL_MESSAGE'){ | ||
62 | - config ={ | ||
63 | - "host":values.host, | ||
64 | - "port":values.port, | ||
65 | - "username":values.username, | ||
66 | - "password":values.password, | ||
67 | - } | 55 | + let config = {}; |
56 | + if (values.messageType === 'PHONE_MESSAGE') { | ||
57 | + config = { | ||
58 | + accessKeyId: values.accessKeyId, | ||
59 | + accessKeySecret: values.accessKeySecret, | ||
60 | + }; | ||
61 | + } else if (values.messageType === 'EMAIL_MESSAGE') { | ||
62 | + config = { | ||
63 | + host: values.host, | ||
64 | + port: values.port, | ||
65 | + username: values.username, | ||
66 | + password: values.password, | ||
67 | + }; | ||
68 | } | 68 | } |
69 | Reflect.set(values, 'config', config); | 69 | Reflect.set(values, 'config', config); |
70 | - let saveMessage = "添加成功"; | ||
71 | - let updateMessage = "修改成功"; | ||
72 | - await saveOrEditMessageTemplate(values,unref(isUpdate)); | 70 | + let saveMessage = '添加成功'; |
71 | + let updateMessage = '修改成功'; | ||
72 | + await saveOrEditMessageTemplate(values, unref(isUpdate)); | ||
73 | closeDrawer(); | 73 | closeDrawer(); |
74 | emit('success'); | 74 | emit('success'); |
75 | - createMessage.success(unref(isUpdate)?updateMessage:saveMessage); | 75 | + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); |
76 | } finally { | 76 | } finally { |
77 | setDrawerProps({ confirmLoading: false }); | 77 | setDrawerProps({ confirmLoading: false }); |
78 | } | 78 | } |
@@ -4,24 +4,26 @@ | @@ -4,24 +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}"> | ||
8 | - <a-button type="link" class="ml-2" @click="goConfig"> {{record.messageConfig.configName}} </a-button> | 7 | + <template #config="{ record }"> |
8 | + <a-button type="link" class="ml-2" @click="goConfig"> | ||
9 | + {{ record.messageConfig.configName }} | ||
10 | + </a-button> | ||
9 | </template> | 11 | </template> |
10 | <template #action="{ record }"> | 12 | <template #action="{ record }"> |
11 | <TableAction | 13 | <TableAction |
12 | :actions="[ | 14 | :actions="[ |
13 | { | 15 | { |
14 | - label:'发送', | 16 | + label: '发送', |
15 | icon: 'ant-design:send-outlined', | 17 | icon: 'ant-design:send-outlined', |
16 | onClick: handleModal.bind(null, record), | 18 | onClick: handleModal.bind(null, record), |
17 | }, | 19 | }, |
18 | { | 20 | { |
19 | - label:'编辑', | 21 | + label: '编辑', |
20 | icon: 'clarity:note-edit-line', | 22 | icon: 'clarity:note-edit-line', |
21 | onClick: handleEdit.bind(null, record), | 23 | onClick: handleEdit.bind(null, record), |
22 | }, | 24 | }, |
23 | { | 25 | { |
24 | - label:'删除', | 26 | + label: '删除', |
25 | icon: 'ant-design:delete-outlined', | 27 | icon: 'ant-design:delete-outlined', |
26 | color: 'error', | 28 | color: 'error', |
27 | popConfirm: { | 29 | popConfirm: { |
@@ -33,119 +35,119 @@ | @@ -33,119 +35,119 @@ | ||
33 | /> | 35 | /> |
34 | </template> | 36 | </template> |
35 | </BasicTable> | 37 | </BasicTable> |
36 | - <SendSms @register="registerModal"/> | ||
37 | - <SendEmail @register="registerMailModal"/> | 38 | + <SendSms @register="registerModal" /> |
39 | + <SendEmail @register="registerMailModal" /> | ||
38 | <TemplateDrawer @register="registerDrawer" @success="handleSuccess" /> | 40 | <TemplateDrawer @register="registerDrawer" @success="handleSuccess" /> |
39 | </div> | 41 | </div> |
40 | </template> | 42 | </template> |
41 | <script lang="ts"> | 43 | <script lang="ts"> |
42 | -import {defineComponent} from 'vue'; | 44 | + import { defineComponent } from 'vue'; |
43 | 45 | ||
44 | -import {BasicTable, TableAction, useTable} from '/@/components/Table'; | ||
45 | -import {useDrawer} from '/@/components/Drawer'; | ||
46 | -import TemplateDrawer from './TemplateDrawer.vue'; | ||
47 | -import {columns, searchFormSchema} from './template.data'; | ||
48 | -import {CodeEditor} from '/@/components/CodeEditor'; | ||
49 | -import {useMessage} from "/@/hooks/web/useMessage"; | ||
50 | -import {deleteMessageTemplate, messageTemplatePage} from "/@/api/message/template"; | ||
51 | -import {Tag} from "ant-design-vue"; | ||
52 | -import {useGo} from '/@/hooks/web/usePage'; | ||
53 | -import {PageEnum} from "/@/enums/pageEnum"; | ||
54 | -import { useModal } from '/@/components/Modal'; | ||
55 | -import SendSms from "/@/views/message/template/SendSms.vue"; | ||
56 | -import {MessageEnum} from "/@/enums/messageEnum"; | ||
57 | -import SendEmail from "/@/views/message/template/SendEmail.vue"; | 46 | + import { BasicTable, TableAction, useTable } from '/@/components/Table'; |
47 | + import { useDrawer } from '/@/components/Drawer'; | ||
48 | + import TemplateDrawer from './TemplateDrawer.vue'; | ||
49 | + import { columns, searchFormSchema } from './template.data'; | ||
50 | + import { CodeEditor } from '/@/components/CodeEditor'; | ||
51 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
52 | + import { deleteMessageTemplate, messageTemplatePage } from '/@/api/message/template'; | ||
53 | + import { Tag } from 'ant-design-vue'; | ||
54 | + import { useGo } from '/@/hooks/web/usePage'; | ||
55 | + import { PageEnum } from '/@/enums/pageEnum'; | ||
56 | + import { useModal } from '/@/components/Modal'; | ||
57 | + import SendSms from '/@/views/message/template/SendSms.vue'; | ||
58 | + import { MessageEnum } from '/@/enums/messageEnum'; | ||
59 | + import SendEmail from '/@/views/message/template/SendEmail.vue'; | ||
58 | 60 | ||
59 | -export default defineComponent({ | ||
60 | - name: 'MessageTemplateManagement', | ||
61 | - components: {SendSms,SendEmail, BasicTable, TemplateDrawer, TableAction ,CodeEditor,Tag}, | ||
62 | - setup() { | ||
63 | - const [registerModal, { openModal:openModal }] = useModal(); | ||
64 | - const [registerMailModal, { openModal:openMailModal }] = useModal(); | ||
65 | - const go = useGo(); | ||
66 | - const [registerDrawer, { openDrawer }] = useDrawer(); | ||
67 | - const {createMessage} = useMessage(); | ||
68 | - const [registerTable, { reload }] = useTable({ | ||
69 | - title: '消息模板列表', | ||
70 | - api: messageTemplatePage, | ||
71 | - columns, | ||
72 | - formConfig: { | ||
73 | - labelWidth: 120, | ||
74 | - schemas: searchFormSchema, | ||
75 | - }, | ||
76 | - useSearchForm: true, | ||
77 | - showTableSetting: true, | ||
78 | - bordered: true, | ||
79 | - showIndexColumn: false, | ||
80 | - actionColumn: { | ||
81 | - width: 180, | ||
82 | - title: '操作', | ||
83 | - dataIndex: 'action', | ||
84 | - slots: { customRender: 'action' }, | ||
85 | - fixed: undefined, | ||
86 | - }, | ||
87 | - }); | ||
88 | - | ||
89 | - function handleCreate() { | ||
90 | - openDrawer(true, { | ||
91 | - isUpdate: false, | ||
92 | - }); | ||
93 | - } | ||
94 | - | ||
95 | - function handleEdit(record: Recordable) { | ||
96 | - openDrawer(true, { | ||
97 | - record, | ||
98 | - isUpdate: true, | 61 | + export default defineComponent({ |
62 | + name: 'MessageTemplateManagement', | ||
63 | + components: { SendSms, SendEmail, BasicTable, TemplateDrawer, TableAction, CodeEditor, Tag }, | ||
64 | + setup() { | ||
65 | + const [registerModal, { openModal: openModal }] = useModal(); | ||
66 | + const [registerMailModal, { openModal: openMailModal }] = useModal(); | ||
67 | + const go = useGo(); | ||
68 | + const [registerDrawer, { openDrawer }] = useDrawer(); | ||
69 | + const { createMessage } = useMessage(); | ||
70 | + const [registerTable, { reload }] = useTable({ | ||
71 | + title: '消息模板列表', | ||
72 | + api: messageTemplatePage, | ||
73 | + columns, | ||
74 | + formConfig: { | ||
75 | + labelWidth: 120, | ||
76 | + schemas: searchFormSchema, | ||
77 | + }, | ||
78 | + useSearchForm: true, | ||
79 | + showTableSetting: true, | ||
80 | + bordered: true, | ||
81 | + showIndexColumn: false, | ||
82 | + actionColumn: { | ||
83 | + width: 180, | ||
84 | + title: '操作', | ||
85 | + dataIndex: 'action', | ||
86 | + slots: { customRender: 'action' }, | ||
87 | + fixed: undefined, | ||
88 | + }, | ||
99 | }); | 89 | }); |
100 | - } | ||
101 | 90 | ||
102 | - function handleModal(record: Recordable){ | ||
103 | - let openSms = false; | ||
104 | - let openEmail = false; | ||
105 | - const messageType = Reflect.get(record,"messageType"); | ||
106 | - if(messageType===MessageEnum.IS_SMS){ | ||
107 | - openSms = true; | ||
108 | - }else if(messageType===MessageEnum.IS_EMAIL){ | ||
109 | - openEmail = true; | 91 | + function handleCreate() { |
92 | + openDrawer(true, { | ||
93 | + isUpdate: false, | ||
94 | + }); | ||
110 | } | 95 | } |
111 | - if(openSms){ | ||
112 | - openModal(openSms,{ | 96 | + |
97 | + function handleEdit(record: Recordable) { | ||
98 | + openDrawer(true, { | ||
113 | record, | 99 | record, |
114 | - }) | 100 | + isUpdate: true, |
101 | + }); | ||
115 | } | 102 | } |
116 | - if(openEmail){ | ||
117 | - openMailModal(openEmail,{ | ||
118 | - record, | ||
119 | - }) | 103 | + |
104 | + function handleModal(record: Recordable) { | ||
105 | + let openSms = false; | ||
106 | + let openEmail = false; | ||
107 | + const messageType = Reflect.get(record, 'messageType'); | ||
108 | + if (messageType === MessageEnum.IS_SMS) { | ||
109 | + openSms = true; | ||
110 | + } else if (messageType === MessageEnum.IS_EMAIL) { | ||
111 | + openEmail = true; | ||
112 | + } | ||
113 | + if (openSms) { | ||
114 | + openModal(openSms, { | ||
115 | + record, | ||
116 | + }); | ||
117 | + } | ||
118 | + if (openEmail) { | ||
119 | + openMailModal(openEmail, { | ||
120 | + record, | ||
121 | + }); | ||
122 | + } | ||
120 | } | 123 | } |
121 | - } | ||
122 | 124 | ||
123 | - function handleDelete(record: Recordable) { | ||
124 | - let ids = [record.id]; | ||
125 | - deleteMessageTemplate(ids).then((result)=>{ | ||
126 | - createMessage.success(result.message) | ||
127 | - handleSuccess() | ||
128 | - }); | ||
129 | - } | 125 | + function handleDelete(record: Recordable) { |
126 | + let ids = [record.id]; | ||
127 | + deleteMessageTemplate(ids).then((result) => { | ||
128 | + createMessage.success(result.message); | ||
129 | + handleSuccess(); | ||
130 | + }); | ||
131 | + } | ||
130 | 132 | ||
131 | - function handleSuccess() { | ||
132 | - reload(); | ||
133 | - } | ||
134 | - function goConfig(){ | ||
135 | - go(PageEnum.MESSAGE_CONFIG) | ||
136 | - } | ||
137 | - return { | ||
138 | - registerTable, | ||
139 | - registerDrawer, | ||
140 | - registerModal, | ||
141 | - registerMailModal, | ||
142 | - handleCreate, | ||
143 | - handleEdit, | ||
144 | - handleDelete, | ||
145 | - handleSuccess, | ||
146 | - handleModal, | ||
147 | - goConfig, | ||
148 | - }; | ||
149 | - }, | ||
150 | -}); | 133 | + function handleSuccess() { |
134 | + reload(); | ||
135 | + } | ||
136 | + function goConfig() { | ||
137 | + go(PageEnum.MESSAGE_CONFIG); | ||
138 | + } | ||
139 | + return { | ||
140 | + registerTable, | ||
141 | + registerDrawer, | ||
142 | + registerModal, | ||
143 | + registerMailModal, | ||
144 | + handleCreate, | ||
145 | + handleEdit, | ||
146 | + handleDelete, | ||
147 | + handleSuccess, | ||
148 | + handleModal, | ||
149 | + goConfig, | ||
150 | + }; | ||
151 | + }, | ||
152 | + }); | ||
151 | </script> | 153 | </script> |
@@ -16,11 +16,7 @@ | @@ -16,11 +16,7 @@ | ||
16 | <div class="hidden min-h-full pl-4 mr-4 xl:flex xl:flex-col xl:w-6/12"> | 16 | <div class="hidden min-h-full pl-4 mr-4 xl:flex xl:flex-col xl:w-6/12"> |
17 | <AppLogo class="-enter-x" /> | 17 | <AppLogo class="-enter-x" /> |
18 | <div class="my-auto"> | 18 | <div class="my-auto"> |
19 | - <img | ||
20 | - :alt="title" | ||
21 | - src="../../../assets/images/iot.png" | ||
22 | - class="w-4/5 -mt-16 -enter-x" | ||
23 | - /> | 19 | + <img :alt="title" src="../../../assets/images/iot.png" class="w-4/5 -mt-16 -enter-x" /> |
24 | <div class="mt-10 font-medium text-white -enter-x"> | 20 | <div class="mt-10 font-medium text-white -enter-x"> |
25 | <span class="inline-block mt-4 text-3xl"> {{ t('sys.login.signInTitle') }}</span> | 21 | <span class="inline-block mt-4 text-3xl"> {{ t('sys.login.signInTitle') }}</span> |
26 | </div> | 22 | </div> |
@@ -25,8 +25,6 @@ | @@ -25,8 +25,6 @@ | ||
25 | /> | 25 | /> |
26 | </FormItem> | 26 | </FormItem> |
27 | 27 | ||
28 | - | ||
29 | - | ||
30 | <FormItem class="enter-x"> | 28 | <FormItem class="enter-x"> |
31 | <Button type="primary" size="large" block @click="handleLogin" :loading="loading"> | 29 | <Button type="primary" size="large" block @click="handleLogin" :loading="loading"> |
32 | {{ t('sys.login.loginButton') }} | 30 | {{ t('sys.login.loginButton') }} |
@@ -44,10 +42,9 @@ | @@ -44,10 +42,9 @@ | ||
44 | </Button> | 42 | </Button> |
45 | </ACol> | 43 | </ACol> |
46 | </ARow> | 44 | </ARow> |
47 | - <ARow class="enter-x"> | 45 | + <ARow class="enter-x"> |
48 | <ACol :span="12"> | 46 | <ACol :span="12"> |
49 | - <FormItem> | ||
50 | - </FormItem> | 47 | + <FormItem> </FormItem> |
51 | </ACol> | 48 | </ACol> |
52 | <ACol :span="12"> | 49 | <ACol :span="12"> |
53 | <FormItem :style="{ 'text-align': 'right' }"> | 50 | <FormItem :style="{ 'text-align': 'right' }"> |
@@ -123,9 +120,12 @@ | @@ -123,9 +120,12 @@ | ||
123 | } catch (error) { | 120 | } catch (error) { |
124 | createErrorModal({ | 121 | createErrorModal({ |
125 | title: t('sys.api.loginFailed'), | 122 | title: t('sys.api.loginFailed'), |
126 | - content: (error.response && error.response.status == 401)? | ||
127 | - t('sys.api.passwordOrUserNameError') | ||
128 | - :(error.code == 'ECONNABORTED'?t('sys.api.timeoutMessage'):t('sys.api.apiRequestFailed')), | 123 | + content: |
124 | + error.response && error.response.status == 401 | ||
125 | + ? t('sys.api.passwordOrUserNameError') | ||
126 | + : error.code == 'ECONNABORTED' | ||
127 | + ? t('sys.api.timeoutMessage') | ||
128 | + : t('sys.api.apiRequestFailed'), | ||
129 | getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body, | 129 | getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body, |
130 | }); | 130 | }); |
131 | } finally { | 131 | } finally { |
@@ -32,15 +32,15 @@ | @@ -32,15 +32,15 @@ | ||
32 | </template> | 32 | </template> |
33 | </template> | 33 | </template> |
34 | <script lang="ts" setup> | 34 | <script lang="ts" setup> |
35 | -import {reactive, ref, computed, unref, toRaw} from 'vue'; | ||
36 | - import { Form, Input, Button,message } from 'ant-design-vue'; | 35 | + import { reactive, ref, computed, unref, toRaw } from 'vue'; |
36 | + import { Form, Input, Button, message } from 'ant-design-vue'; | ||
37 | import { CountdownInput } from '/@/components/CountDown'; | 37 | import { CountdownInput } from '/@/components/CountDown'; |
38 | import LoginFormTitle from './LoginFormTitle.vue'; | 38 | import LoginFormTitle from './LoginFormTitle.vue'; |
39 | import { useI18n } from '/@/hooks/web/useI18n'; | 39 | import { useI18n } from '/@/hooks/web/useI18n'; |
40 | import { useLoginState, useFormRules, useFormValid, LoginStateEnum } from './useLogin'; | 40 | import { useLoginState, useFormRules, useFormValid, LoginStateEnum } from './useLogin'; |
41 | - import {SendLoginSmsCode, smsCodeLoginApi} from "/@/api/sys/user"; | ||
42 | - import {useUserStore} from "/@/store/modules/user"; | ||
43 | - import {useMessage} from "/@/hooks/web/useMessage"; | 41 | + import { SendLoginSmsCode, smsCodeLoginApi } from '/@/api/sys/user'; |
42 | + import { useUserStore } from '/@/store/modules/user'; | ||
43 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
44 | const { notification, createErrorModal } = useMessage(); | 44 | const { notification, createErrorModal } = useMessage(); |
45 | 45 | ||
46 | const FormItem = Form.Item; | 46 | const FormItem = Form.Item; |
@@ -57,18 +57,18 @@ import {reactive, ref, computed, unref, toRaw} from 'vue'; | @@ -57,18 +57,18 @@ import {reactive, ref, computed, unref, toRaw} from 'vue'; | ||
57 | }); | 57 | }); |
58 | 58 | ||
59 | async function sendLoginSms() { | 59 | async function sendLoginSms() { |
60 | - const reg = /^[1](([3][0-9])|([4][0,1,4-9])|([5][0-3,5-9])|([6][2,5,6,7])|([7][0-8])|([8][0-9])|([9][0-3,5-9]))[0-9]{8}$/; | ||
61 | - if(reg.test(formData.phoneNumber)){ | ||
62 | - const sendRes = await SendLoginSmsCode(formData.phoneNumber); | ||
63 | - if(!sendRes){ | ||
64 | - message.error('发送失败'); | ||
65 | - return false; | ||
66 | - } | 60 | + const reg = |
61 | + /^[1](([3][0-9])|([4][0,1,4-9])|([5][0-3,5-9])|([6][2,5,6,7])|([7][0-8])|([8][0-9])|([9][0-3,5-9]))[0-9]{8}$/; | ||
62 | + if (reg.test(formData.phoneNumber)) { | ||
63 | + const sendRes = await SendLoginSmsCode(formData.phoneNumber); | ||
64 | + if (!sendRes) { | ||
65 | + message.error('发送失败'); | ||
66 | + return false; | ||
67 | + } | ||
67 | return true; | 68 | return true; |
68 | - }else{ | 69 | + } else { |
69 | message.error('请输入正确手机号码'); | 70 | message.error('请输入正确手机号码'); |
70 | } | 71 | } |
71 | - | ||
72 | } | 72 | } |
73 | 73 | ||
74 | const { validForm } = useFormValid(formRef); | 74 | const { validForm } = useFormValid(formRef); |
1 | <template> | 1 | <template> |
2 | - <PageWrapper | ||
3 | - :title="`用户资料`" | ||
4 | - contentBackground | ||
5 | - @back="goBack" | ||
6 | - > | ||
7 | - <Description | ||
8 | - size="middle" | ||
9 | - @register="register" | ||
10 | - /> | 2 | + <PageWrapper :title="`用户资料`" contentBackground @back="goBack"> |
3 | + <Description size="middle" @register="register" /> | ||
11 | </PageWrapper> | 4 | </PageWrapper> |
12 | </template> | 5 | </template> |
13 | 6 | ||
@@ -16,48 +9,52 @@ | @@ -16,48 +9,52 @@ | ||
16 | import { useRoute } from 'vue-router'; | 9 | import { useRoute } from 'vue-router'; |
17 | import { PageWrapper } from '/@/components/Page'; | 10 | import { PageWrapper } from '/@/components/Page'; |
18 | import { useGo } from '/@/hooks/web/usePage'; | 11 | import { useGo } from '/@/hooks/web/usePage'; |
19 | - import {Description} from "../../../components/Description"; | 12 | + import { Description } from '../../../components/Description'; |
20 | import { useTabs } from '/@/hooks/web/useTabs'; | 13 | import { useTabs } from '/@/hooks/web/useTabs'; |
21 | import { Tabs } from 'ant-design-vue'; | 14 | import { Tabs } from 'ant-design-vue'; |
22 | - import {getAccountInfo} from "../../../api/system/system"; | ||
23 | - import {accountSchema} from "./account.detail.data"; | ||
24 | - import {useDescription} from "../../../components/Description"; | 15 | + import { getAccountInfo } from '../../../api/system/system'; |
16 | + import { accountSchema } from './account.detail.data'; | ||
17 | + import { useDescription } from '../../../components/Description'; | ||
25 | const accountData = {}; | 18 | const accountData = {}; |
26 | export default defineComponent({ | 19 | export default defineComponent({ |
27 | name: 'AccountDetail', | 20 | name: 'AccountDetail', |
28 | - components: { PageWrapper, ATabs: Tabs, ATabPane: Tabs.TabPane,Description }, | 21 | + components: { PageWrapper, ATabs: Tabs, ATabPane: Tabs.TabPane, Description }, |
29 | setup() { | 22 | setup() { |
30 | const route = useRoute(); | 23 | const route = useRoute(); |
31 | const go = useGo(); | 24 | const go = useGo(); |
32 | const { setTitle } = useTabs(); | 25 | const { setTitle } = useTabs(); |
33 | - const [register,methods] = useDescription({ | ||
34 | - title:"账号基础信息", | ||
35 | - data:accountData, | ||
36 | - bordered:false, | ||
37 | - schema:accountSchema, | ||
38 | - column:3 | ||
39 | - }) | ||
40 | - getAccountInfo(route.params?.id).then((result)=>{ | ||
41 | - Reflect.set(accountData,"realName",result.realName); | ||
42 | - Reflect.set(accountData,"phoneNumber",result.phoneNumber); | ||
43 | - Reflect.set(accountData,"email",result.email); | ||
44 | - Reflect.set(accountData,"username",result.username); | ||
45 | - Reflect.set(accountData,"enabled",result.enabled?"正常":!result.enabled?"禁用":"已过期"); | ||
46 | - Reflect.set(accountData,"accountExpireTime",result.accountExpireTime); | ||
47 | - Reflect.set(accountData,"createTime",result.createTime); | ||
48 | - Reflect.set(accountData,"updateTime",result.updateTime); | ||
49 | - Reflect.set(accountData,"deptId",result.deptId); | ||
50 | - console.log(accountData,"accountData") | 26 | + const [register, methods] = useDescription({ |
27 | + title: '账号基础信息', | ||
28 | + data: accountData, | ||
29 | + bordered: false, | ||
30 | + schema: accountSchema, | ||
31 | + column: 3, | ||
32 | + }); | ||
33 | + getAccountInfo(route.params?.id).then((result) => { | ||
34 | + Reflect.set(accountData, 'realName', result.realName); | ||
35 | + Reflect.set(accountData, 'phoneNumber', result.phoneNumber); | ||
36 | + Reflect.set(accountData, 'email', result.email); | ||
37 | + Reflect.set(accountData, 'username', result.username); | ||
38 | + Reflect.set( | ||
39 | + accountData, | ||
40 | + 'enabled', | ||
41 | + result.enabled ? '正常' : !result.enabled ? '禁用' : '已过期' | ||
42 | + ); | ||
43 | + Reflect.set(accountData, 'accountExpireTime', result.accountExpireTime); | ||
44 | + Reflect.set(accountData, 'createTime', result.createTime); | ||
45 | + Reflect.set(accountData, 'updateTime', result.updateTime); | ||
46 | + Reflect.set(accountData, 'deptId', result.deptId); | ||
47 | + console.log(accountData, 'accountData'); | ||
51 | // 设置Tab的标题(不会影响页面标题) | 48 | // 设置Tab的标题(不会影响页面标题) |
52 | setTitle('详情:用户' + result.realName); | 49 | setTitle('详情:用户' + result.realName); |
53 | - methods.setDescProps(accountData) | 50 | + methods.setDescProps(accountData); |
54 | }); | 51 | }); |
55 | // 页面左侧点击返回链接时的操作 | 52 | // 页面左侧点击返回链接时的操作 |
56 | function goBack() { | 53 | function goBack() { |
57 | // 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页 | 54 | // 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页 |
58 | go('/system/account'); | 55 | go('/system/account'); |
59 | } | 56 | } |
60 | - return {goBack,accountSchema,accountData,register }; | 57 | + return { goBack, accountSchema, accountData, register }; |
61 | }, | 58 | }, |
62 | }); | 59 | }); |
63 | </script> | 60 | </script> |
1 | <template> | 1 | <template> |
2 | - <BasicModal width="650px" v-bind="$attrs" @register="registerModal" :title="getTitle" | ||
3 | - @ok="handleSubmit"> | 2 | + <BasicModal |
3 | + width="650px" | ||
4 | + v-bind="$attrs" | ||
5 | + @register="registerModal" | ||
6 | + :title="getTitle" | ||
7 | + @ok="handleSubmit" | ||
8 | + > | ||
4 | <BasicForm @register="registerForm"> | 9 | <BasicForm @register="registerForm"> |
5 | <template #groupId="{ model, field }"> | 10 | <template #groupId="{ model, field }"> |
6 | <BasicTree | 11 | <BasicTree |
@@ -17,100 +22,101 @@ | @@ -17,100 +22,101 @@ | ||
17 | </BasicModal> | 22 | </BasicModal> |
18 | </template> | 23 | </template> |
19 | <script lang="ts"> | 24 | <script lang="ts"> |
20 | -import {defineComponent, ref, computed, unref} from 'vue'; | ||
21 | -import {BasicModal, useModalInner} from '/@/components/Modal'; | ||
22 | -import {BasicForm, useForm} from '/@/components/Form/index'; | ||
23 | -import {accountFormSchema} from './account.data'; | ||
24 | -import {findCurrentUserRelation, getDeptList, SaveOrUpdateUserInfo} from '/@/api/system/system'; | ||
25 | -import {BasicTree, TreeItem} from "/@/components/Tree"; | ||
26 | -import {findCurrentUserGroups} from "/@/api/system/group"; | ||
27 | -import {RoleOrGroupParam} from "/@/api/system/model/systemModel"; | ||
28 | -import {useMessage} from "/@/hooks/web/useMessage"; | ||
29 | -export default defineComponent({ | ||
30 | - name: 'AccountModal', | ||
31 | - components: {BasicModal, BasicForm, BasicTree}, | ||
32 | - emits: ['success', 'register'], | ||
33 | - setup(_, {emit}) { | ||
34 | - const isUpdate = ref(true); | ||
35 | - const rowId = ref(''); | ||
36 | - const groupTreeData = ref<TreeItem[]>([]); | ||
37 | - const checkGroup = ref<string[]>([]); | ||
38 | - const [registerForm, {setFieldsValue, updateSchema, resetFields, validate}] = useForm({ | ||
39 | - labelWidth: 100, | ||
40 | - schemas: accountFormSchema, | ||
41 | - showActionButtonGroup: false, | ||
42 | - actionColOptions: { | ||
43 | - span: 18, | ||
44 | - }, | ||
45 | - }); | 25 | + import { defineComponent, ref, computed, unref } from 'vue'; |
26 | + import { BasicModal, useModalInner } from '/@/components/Modal'; | ||
27 | + import { BasicForm, useForm } from '/@/components/Form/index'; | ||
28 | + import { accountFormSchema } from './account.data'; | ||
29 | + import { findCurrentUserRelation, getDeptList, SaveOrUpdateUserInfo } from '/@/api/system/system'; | ||
30 | + import { BasicTree, TreeItem } from '/@/components/Tree'; | ||
31 | + import { findCurrentUserGroups } from '/@/api/system/group'; | ||
32 | + import { RoleOrGroupParam } from '/@/api/system/model/systemModel'; | ||
33 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
34 | + export default defineComponent({ | ||
35 | + name: 'AccountModal', | ||
36 | + components: { BasicModal, BasicForm, BasicTree }, | ||
37 | + emits: ['success', 'register'], | ||
38 | + setup(_, { emit }) { | ||
39 | + const isUpdate = ref(true); | ||
40 | + const rowId = ref(''); | ||
41 | + const groupTreeData = ref<TreeItem[]>([]); | ||
42 | + const checkGroup = ref<string[]>([]); | ||
43 | + const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({ | ||
44 | + labelWidth: 100, | ||
45 | + schemas: accountFormSchema, | ||
46 | + showActionButtonGroup: false, | ||
47 | + actionColOptions: { | ||
48 | + span: 18, | ||
49 | + }, | ||
50 | + }); | ||
46 | 51 | ||
47 | - const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { | ||
48 | - await resetFields(); | ||
49 | - setModalProps({confirmLoading: false}); | ||
50 | - isUpdate.value = !!data?.isUpdate; | ||
51 | - const groupListModel = await findCurrentUserGroups(); | ||
52 | - if (unref(groupTreeData).length === 0) { | ||
53 | - let treeValues = new Array<TreeItem>(); | ||
54 | - groupListModel.map((item) => { | ||
55 | - const groupData = { | ||
56 | - name: item.name, | ||
57 | - key: item.id, | ||
58 | - id: item.id, | ||
59 | - children: item.children as any as TreeItem[], | ||
60 | - } | ||
61 | - treeValues.push(groupData); | ||
62 | - }) | ||
63 | - groupTreeData.value = treeValues; | ||
64 | - } | 52 | + const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { |
53 | + await resetFields(); | ||
54 | + setModalProps({ confirmLoading: false }); | ||
55 | + isUpdate.value = !!data?.isUpdate; | ||
56 | + const groupListModel = await findCurrentUserGroups(); | ||
57 | + if (unref(groupTreeData).length === 0) { | ||
58 | + let treeValues = new Array<TreeItem>(); | ||
59 | + groupListModel.map((item) => { | ||
60 | + const groupData = { | ||
61 | + name: item.name, | ||
62 | + key: item.id, | ||
63 | + id: item.id, | ||
64 | + children: item.children as any as TreeItem[], | ||
65 | + }; | ||
66 | + treeValues.push(groupData); | ||
67 | + }); | ||
68 | + groupTreeData.value = treeValues; | ||
69 | + } | ||
65 | 70 | ||
66 | - if (unref(isUpdate)) { | ||
67 | - rowId.value = data.record.id; | ||
68 | - const roleParams = new RoleOrGroupParam(rowId.value,true,false); | ||
69 | - findCurrentUserRelation(roleParams).then((result)=>{ | ||
70 | - Reflect.set(data.record,"roleIds",result); | ||
71 | - Reflect.set(data.record,"password","******"); | ||
72 | - setFieldsValue({ | ||
73 | - ...data.record, | 71 | + if (unref(isUpdate)) { |
72 | + rowId.value = data.record.id; | ||
73 | + const roleParams = new RoleOrGroupParam(rowId.value, true, false); | ||
74 | + findCurrentUserRelation(roleParams).then((result) => { | ||
75 | + Reflect.set(data.record, 'roleIds', result); | ||
76 | + Reflect.set(data.record, 'password', '******'); | ||
77 | + setFieldsValue({ | ||
78 | + ...data.record, | ||
79 | + }); | ||
74 | }); | 80 | }); |
75 | - }) | ||
76 | - const groupParams = new RoleOrGroupParam(rowId.value,false,true); | ||
77 | - checkGroup.value = await findCurrentUserRelation(groupParams); | ||
78 | - } | ||
79 | - const deptData = await getDeptList(); | ||
80 | - await updateSchema([ | ||
81 | - { | ||
82 | - field: 'username', | ||
83 | - dynamicDisabled: unref(isUpdate), | ||
84 | - }, | ||
85 | - { | ||
86 | - field: 'deptId', | ||
87 | - componentProps: { | ||
88 | - treeData: deptData | 81 | + const groupParams = new RoleOrGroupParam(rowId.value, false, true); |
82 | + checkGroup.value = await findCurrentUserRelation(groupParams); | ||
83 | + } | ||
84 | + const deptData = await getDeptList(); | ||
85 | + await updateSchema([ | ||
86 | + { | ||
87 | + field: 'username', | ||
88 | + dynamicDisabled: unref(isUpdate), | ||
89 | }, | 89 | }, |
90 | - }, | ||
91 | - ]); | ||
92 | - }); | 90 | + { |
91 | + field: 'deptId', | ||
92 | + componentProps: { | ||
93 | + treeData: deptData, | ||
94 | + }, | ||
95 | + }, | ||
96 | + ]); | ||
97 | + }); | ||
93 | 98 | ||
94 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增账号' : '编辑账号')); | 99 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增账号' : '编辑账号')); |
95 | 100 | ||
96 | - async function handleSubmit() { | ||
97 | - try { | ||
98 | - const { createMessage } = useMessage(); | ||
99 | - const values = await validate(); | ||
100 | - values.accountExpireTime = (typeof values.accountExpireTime != 'undefined' && | ||
101 | - values.accountExpireTime != null) ? | ||
102 | - values.accountExpireTime.format('YYYY-MM-DD HH:mm:ss') : null | ||
103 | - setModalProps({confirmLoading: true}); | ||
104 | - await SaveOrUpdateUserInfo(values, unref(isUpdate)); | ||
105 | - closeModal(); | ||
106 | - emit('success', {isUpdate: unref(isUpdate), values: {...values, id: rowId.value}}); | ||
107 | - createMessage.success(unref(isUpdate)?"编辑成功":"新增成功"); | ||
108 | - } finally { | ||
109 | - setModalProps({confirmLoading: false}); | 101 | + async function handleSubmit() { |
102 | + try { | ||
103 | + const { createMessage } = useMessage(); | ||
104 | + const values = await validate(); | ||
105 | + values.accountExpireTime = | ||
106 | + typeof values.accountExpireTime != 'undefined' && values.accountExpireTime != null | ||
107 | + ? values.accountExpireTime.format('YYYY-MM-DD HH:mm:ss') | ||
108 | + : null; | ||
109 | + setModalProps({ confirmLoading: true }); | ||
110 | + await SaveOrUpdateUserInfo(values, unref(isUpdate)); | ||
111 | + closeModal(); | ||
112 | + emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } }); | ||
113 | + createMessage.success(unref(isUpdate) ? '编辑成功' : '新增成功'); | ||
114 | + } finally { | ||
115 | + setModalProps({ confirmLoading: false }); | ||
116 | + } | ||
110 | } | 117 | } |
111 | - } | ||
112 | 118 | ||
113 | - return {registerModal, registerForm, getTitle, handleSubmit, groupTreeData,checkGroup}; | ||
114 | - }, | ||
115 | -}); | 119 | + return { registerModal, registerForm, getTitle, handleSubmit, groupTreeData, checkGroup }; |
120 | + }, | ||
121 | + }); | ||
116 | </script> | 122 | </script> |
@@ -7,32 +7,42 @@ | @@ -7,32 +7,42 @@ | ||
7 | </template> | 7 | </template> |
8 | <template #status="{ record }"> | 8 | <template #status="{ record }"> |
9 | <Tag | 9 | <Tag |
10 | - :color="record.userStatusEnum==='NORMAL'?'green':(record.userStatusEnum==='DISABLED'?'red':'orange')"> | 10 | + :color=" |
11 | + record.userStatusEnum === 'NORMAL' | ||
12 | + ? 'green' | ||
13 | + : record.userStatusEnum === 'DISABLED' | ||
14 | + ? 'red' | ||
15 | + : 'orange' | ||
16 | + " | ||
17 | + > | ||
11 | {{ | 18 | {{ |
12 | - record.userStatusEnum === 'NORMAL' ? '正常' : (record.userStatusEnum === 'DISABLED' ? '已禁用' : '已过期') | 19 | + record.userStatusEnum === 'NORMAL' |
20 | + ? '正常' | ||
21 | + : record.userStatusEnum === 'DISABLED' | ||
22 | + ? '已禁用' | ||
23 | + : '已过期' | ||
13 | }} | 24 | }} |
14 | </Tag> | 25 | </Tag> |
15 | </template> | 26 | </template> |
16 | <template #action="{ record }"> | 27 | <template #action="{ record }"> |
17 | <TableAction | 28 | <TableAction |
18 | - :actions=" | ||
19 | -[ | 29 | + :actions="[ |
20 | { | 30 | { |
21 | - label:'用户详情', | 31 | + label: '用户详情', |
22 | icon: 'clarity:info-standard-line', | 32 | icon: 'clarity:info-standard-line', |
23 | tooltip: '用户详情', | 33 | tooltip: '用户详情', |
24 | onClick: handleView.bind(null, record), | 34 | onClick: handleView.bind(null, record), |
25 | ifShow: record.level != 0, | 35 | ifShow: record.level != 0, |
26 | }, | 36 | }, |
27 | { | 37 | { |
28 | - label:'编辑', | 38 | + label: '编辑', |
29 | icon: 'clarity:note-edit-line', | 39 | icon: 'clarity:note-edit-line', |
30 | tooltip: '编辑', | 40 | tooltip: '编辑', |
31 | onClick: handleEdit.bind(null, record), | 41 | onClick: handleEdit.bind(null, record), |
32 | ifShow: record.level != 0, | 42 | ifShow: record.level != 0, |
33 | }, | 43 | }, |
34 | { | 44 | { |
35 | - label:'删除', | 45 | + label: '删除', |
36 | icon: 'ant-design:delete-outlined', | 46 | icon: 'ant-design:delete-outlined', |
37 | color: 'error', | 47 | color: 'error', |
38 | tooltip: '删除', | 48 | tooltip: '删除', |
@@ -52,26 +62,26 @@ | @@ -52,26 +62,26 @@ | ||
52 | <script lang="ts"> | 62 | <script lang="ts"> |
53 | import { defineComponent, reactive } from 'vue'; | 63 | import { defineComponent, reactive } from 'vue'; |
54 | 64 | ||
55 | - import {TenantCodeEnum} from '/@/enums/codeEnum'; | 65 | + import { TenantCodeEnum } from '/@/enums/codeEnum'; |
56 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 66 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
57 | - import {deleteUser, getAccountList} from '/@/api/system/system'; | 67 | + import { deleteUser, getAccountList } from '/@/api/system/system'; |
58 | import { PageWrapper } from '/@/components/Page'; | 68 | import { PageWrapper } from '/@/components/Page'; |
59 | import DeptTree from './DeptTree.vue'; | 69 | import DeptTree from './DeptTree.vue'; |
60 | - import {Tag} from "ant-design-vue"; | 70 | + import { Tag } from 'ant-design-vue'; |
61 | import { useModal } from '/@/components/Modal'; | 71 | import { useModal } from '/@/components/Modal'; |
62 | import AccountModal from './AccountModal.vue'; | 72 | import AccountModal from './AccountModal.vue'; |
63 | 73 | ||
64 | import { columns, searchFormSchema } from './account.data'; | 74 | import { columns, searchFormSchema } from './account.data'; |
65 | import { useGo } from '/@/hooks/web/usePage'; | 75 | import { useGo } from '/@/hooks/web/usePage'; |
66 | - import {useMessage} from "/@/hooks/web/useMessage"; | 76 | + import { useMessage } from '/@/hooks/web/useMessage'; |
67 | 77 | ||
68 | export default defineComponent({ | 78 | export default defineComponent({ |
69 | name: 'AccountManagement', | 79 | name: 'AccountManagement', |
70 | - components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction,Tag }, | 80 | + components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction, Tag }, |
71 | setup() { | 81 | setup() { |
72 | const go = useGo(); | 82 | const go = useGo(); |
73 | const [registerModal, { openModal }] = useModal(); | 83 | const [registerModal, { openModal }] = useModal(); |
74 | - const {createMessage} = useMessage(); | 84 | + const { createMessage } = useMessage(); |
75 | const searchInfo = reactive<Recordable>({}); | 85 | const searchInfo = reactive<Recordable>({}); |
76 | const [registerTable, { reload, updateTableDataRecord }] = useTable({ | 86 | const [registerTable, { reload, updateTableDataRecord }] = useTable({ |
77 | title: '账号列表', | 87 | title: '账号列表', |
@@ -113,10 +123,10 @@ | @@ -113,10 +123,10 @@ | ||
113 | 123 | ||
114 | function handleDelete(record: Recordable) { | 124 | function handleDelete(record: Recordable) { |
115 | let ids = [record.id]; | 125 | let ids = [record.id]; |
116 | - deleteUser(ids).then(()=>{ | ||
117 | - createMessage.success("删除成功") | 126 | + deleteUser(ids).then(() => { |
127 | + createMessage.success('删除成功'); | ||
118 | reload(); | 128 | reload(); |
119 | - }) | 129 | + }); |
120 | } | 130 | } |
121 | 131 | ||
122 | function handleSuccess({ isUpdate, values }) { | 132 | function handleSuccess({ isUpdate, values }) { |
@@ -148,7 +158,7 @@ | @@ -148,7 +158,7 @@ | ||
148 | handleSelect, | 158 | handleSelect, |
149 | handleView, | 159 | handleView, |
150 | searchInfo, | 160 | searchInfo, |
151 | - TenantCodeEnum | 161 | + TenantCodeEnum, |
152 | }; | 162 | }; |
153 | }, | 163 | }, |
154 | }); | 164 | }); |
@@ -7,96 +7,97 @@ | @@ -7,96 +7,97 @@ | ||
7 | width="50%" | 7 | width="50%" |
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"> |
14 | -import {defineComponent, ref, computed, unref} from 'vue'; | ||
15 | -import {BasicForm, useForm} from '/@/components/Form/index'; | ||
16 | -import {formSchema} from './dept.data'; | ||
17 | -import {BasicDrawer, useDrawerInner} from '/@/components/Drawer'; | 14 | + import { defineComponent, ref, computed, unref } from 'vue'; |
15 | + import { BasicForm, useForm } from '/@/components/Form/index'; | ||
16 | + import { formSchema } from './dept.data'; | ||
17 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
18 | 18 | ||
19 | -// 加载部门 | ||
20 | -import { getDeptList } from '/@/api/system/dept'; | ||
21 | -import {useI18n} from "/@/hooks/web/useI18n"; | ||
22 | -import {saveOrEditDeptApi} from "/@/api/system/dept"; | 19 | + // 加载部门 |
20 | + import { getDeptList } from '/@/api/system/dept'; | ||
21 | + import { useI18n } from '/@/hooks/web/useI18n'; | ||
22 | + import { saveOrEditDeptApi } from '/@/api/system/dept'; | ||
23 | 23 | ||
24 | + export default defineComponent({ | ||
25 | + name: 'DeptDrawer', | ||
26 | + components: { BasicDrawer, BasicForm }, | ||
27 | + emits: ['success', 'register'], | ||
28 | + setup(_, { emit }) { | ||
29 | + const isUpdate = ref(true); | ||
30 | + let deptId, tenantCode, creator, createTime; | ||
24 | 31 | ||
25 | -export default defineComponent({ | ||
26 | - name: 'DeptDrawer', | ||
27 | - components: {BasicDrawer, BasicForm}, | ||
28 | - emits: ['success', 'register'], | ||
29 | - setup(_, {emit}) { | ||
30 | - const isUpdate = ref(true); | ||
31 | - let deptId,tenantCode,creator,createTime; | ||
32 | - | ||
33 | - const [registerForm, {resetFields, setFieldsValue, updateSchema, validate}] = useForm({ | ||
34 | - labelWidth: 100, | ||
35 | - schemas: formSchema, | ||
36 | - showActionButtonGroup: false, | ||
37 | - baseColProps: {lg: 12, md: 24}, | ||
38 | - }); | ||
39 | - const {t} = useI18n(); //加载国际化 | 32 | + const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({ |
33 | + labelWidth: 100, | ||
34 | + schemas: formSchema, | ||
35 | + showActionButtonGroup: false, | ||
36 | + baseColProps: { lg: 12, md: 24 }, | ||
37 | + }); | ||
38 | + const { t } = useI18n(); //加载国际化 | ||
40 | 39 | ||
41 | - //默认传递页面数据 | ||
42 | - const [registerDrawer, {setDrawerProps, closeDrawer}] = useDrawerInner(async (data) => { | ||
43 | - resetFields(); | ||
44 | - setDrawerProps({confirmLoading: false}); | ||
45 | - isUpdate.value = !!data?.isUpdate; | 40 | + //默认传递页面数据 |
41 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
42 | + resetFields(); | ||
43 | + setDrawerProps({ confirmLoading: false }); | ||
44 | + isUpdate.value = !!data?.isUpdate; | ||
46 | 45 | ||
47 | - //如果是编辑操作,设置页面数据 | ||
48 | - if (unref(isUpdate)) { | ||
49 | - //为表单赋值 | ||
50 | - setFieldsValue({ | ||
51 | - ...data.record, | 46 | + //如果是编辑操作,设置页面数据 |
47 | + if (unref(isUpdate)) { | ||
48 | + //为表单赋值 | ||
49 | + setFieldsValue({ | ||
50 | + ...data.record, | ||
51 | + }); | ||
52 | + } | ||
53 | + if (isUpdate.value) { | ||
54 | + tenantCode = Reflect.get(data.record, 'tenantCode'); | ||
55 | + creator = Reflect.get(data.record, 'creator'); | ||
56 | + createTime = Reflect.get(data.record, 'createTime'); | ||
57 | + deptId = Reflect.get(data.record, 'id'); | ||
58 | + } | ||
59 | + //加载部门 | ||
60 | + let treeData = await getDeptList(); | ||
61 | + updateSchema({ | ||
62 | + field: 'parentId', | ||
63 | + componentProps: { treeData }, | ||
52 | }); | 64 | }); |
53 | - | ||
54 | - } | ||
55 | - if (isUpdate.value) { | ||
56 | - tenantCode= Reflect.get(data.record, 'tenantCode'); | ||
57 | - creator= Reflect.get(data.record, 'creator'); | ||
58 | - createTime= Reflect.get(data.record, 'createTime'); | ||
59 | - deptId = Reflect.get(data.record, 'id'); | ||
60 | - } | ||
61 | - //加载部门 | ||
62 | - let treeData = await getDeptList(); | ||
63 | - updateSchema({ | ||
64 | - field: 'parentId', | ||
65 | - componentProps: {treeData}, | ||
66 | }); | 65 | }); |
67 | - }); | ||
68 | - | ||
69 | - //得到页面标题 | ||
70 | - const getTitle = computed(() => (!unref(isUpdate) ? t('routes.common.dept.toolCreateDept') : t('routes.common.dept.toolEditDept'))); | ||
71 | 66 | ||
72 | - //提交按钮 | ||
73 | - async function handleSubmit() { | ||
74 | - try { | ||
75 | - const values = await validate(); | ||
76 | - setDrawerProps({confirmLoading: true}); | 67 | + //得到页面标题 |
68 | + const getTitle = computed(() => | ||
69 | + !unref(isUpdate) | ||
70 | + ? t('routes.common.dept.toolCreateDept') | ||
71 | + : t('routes.common.dept.toolEditDept') | ||
72 | + ); | ||
77 | 73 | ||
78 | - if (isUpdate.value) { | ||
79 | - Reflect.set(values, 'id', deptId); | ||
80 | - Reflect.set(values, 'tenantCode', tenantCode); | ||
81 | - Reflect.set(values, 'creator', creator); | ||
82 | - Reflect.set(values, 'createTime', createTime); | ||
83 | - } | 74 | + //提交按钮 |
75 | + async function handleSubmit() { | ||
76 | + try { | ||
77 | + const values = await validate(); | ||
78 | + setDrawerProps({ confirmLoading: true }); | ||
84 | 79 | ||
85 | - // TODO custom api | ||
86 | - // console.log("-------------提交后台的参数-------------------"); | ||
87 | - // console.log(values); | ||
88 | - const data = await saveOrEditDeptApi(values, isUpdate.value); | ||
89 | - console.log("_______保存返回结果____data:",data); | 80 | + if (isUpdate.value) { |
81 | + Reflect.set(values, 'id', deptId); | ||
82 | + Reflect.set(values, 'tenantCode', tenantCode); | ||
83 | + Reflect.set(values, 'creator', creator); | ||
84 | + Reflect.set(values, 'createTime', createTime); | ||
85 | + } | ||
90 | 86 | ||
87 | + // TODO custom api | ||
88 | + // console.log("-------------提交后台的参数-------------------"); | ||
89 | + // console.log(values); | ||
90 | + const data = await saveOrEditDeptApi(values, isUpdate.value); | ||
91 | + console.log('_______保存返回结果____data:', data); | ||
91 | 92 | ||
92 | - closeDrawer();//关闭侧框 | ||
93 | - emit('success'); | ||
94 | - } finally { | ||
95 | - setDrawerProps({confirmLoading: false}); | 93 | + closeDrawer(); //关闭侧框 |
94 | + emit('success'); | ||
95 | + } finally { | ||
96 | + setDrawerProps({ confirmLoading: false }); | ||
97 | + } | ||
96 | } | 98 | } |
97 | - } | ||
98 | 99 | ||
99 | - return {registerDrawer, registerForm, getTitle, handleSubmit}; | ||
100 | - }, | ||
101 | -}); | 100 | + return { registerDrawer, registerForm, getTitle, handleSubmit }; |
101 | + }, | ||
102 | + }); | ||
102 | </script> | 103 | </script> |
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | icon: 'ant-design:delete-outlined', | 18 | icon: 'ant-design:delete-outlined', |
19 | color: 'error', | 19 | color: 'error', |
20 | popConfirm: { | 20 | popConfirm: { |
21 | - title: getDeleteTitle(),//是否确认删除//getDeleteTitle() | 21 | + title: getDeleteTitle(), //是否确认删除//getDeleteTitle() |
22 | confirm: handleDelete.bind(null, record), | 22 | confirm: handleDelete.bind(null, record), |
23 | }, | 23 | }, |
24 | }, | 24 | }, |
@@ -30,30 +30,30 @@ | @@ -30,30 +30,30 @@ | ||
30 | </div> | 30 | </div> |
31 | </template> | 31 | </template> |
32 | <script lang="ts"> | 32 | <script lang="ts"> |
33 | - import {computed, defineComponent, nextTick} from 'vue'; | 33 | + import { computed, defineComponent, nextTick } from 'vue'; |
34 | 34 | ||
35 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 35 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
36 | import { getDeptList } from '/@/api/system/dept'; | 36 | import { getDeptList } from '/@/api/system/dept'; |
37 | 37 | ||
38 | // 加载自定义侧边弹出框 组件 | 38 | // 加载自定义侧边弹出框 组件 |
39 | - import {useDrawer} from '/@/components/Drawer'; | 39 | + import { useDrawer } from '/@/components/Drawer'; |
40 | import DeptDrawer from './DeptDrawer.vue'; | 40 | import DeptDrawer from './DeptDrawer.vue'; |
41 | 41 | ||
42 | import { columns, searchFormSchema } from './dept.data'; | 42 | import { columns, searchFormSchema } from './dept.data'; |
43 | - import {delDept} from "/@/api/system/dept"; | ||
44 | - import {useI18n} from "/@/hooks/web/useI18n"; | ||
45 | - import {notification} from "ant-design-vue"; | 43 | + import { delDept } from '/@/api/system/dept'; |
44 | + import { useI18n } from '/@/hooks/web/useI18n'; | ||
45 | + import { notification } from 'ant-design-vue'; | ||
46 | 46 | ||
47 | export default defineComponent({ | 47 | export default defineComponent({ |
48 | name: 'DeptManagement', | 48 | name: 'DeptManagement', |
49 | components: { BasicTable, DeptDrawer, TableAction }, | 49 | components: { BasicTable, DeptDrawer, TableAction }, |
50 | setup() { | 50 | setup() { |
51 | const [registerModal, { openDrawer }] = useDrawer(); | 51 | const [registerModal, { openDrawer }] = useDrawer(); |
52 | - const {t} = useI18n(); //加载国际化 | 52 | + const { t } = useI18n(); //加载国际化 |
53 | // 新增部门 | 53 | // 新增部门 |
54 | const getI18nCreateDept = computed(() => t('routes.common.dept.toolCreateDept')); | 54 | const getI18nCreateDept = computed(() => t('routes.common.dept.toolCreateDept')); |
55 | 55 | ||
56 | - const [registerTable, { reload,expandAll }] = useTable({ | 56 | + const [registerTable, { reload, expandAll }] = useTable({ |
57 | title: t('routes.common.dept.toolDeptList'), | 57 | title: t('routes.common.dept.toolDeptList'), |
58 | api: getDeptList, | 58 | api: getDeptList, |
59 | columns, | 59 | columns, |
@@ -71,7 +71,7 @@ | @@ -71,7 +71,7 @@ | ||
71 | canResize: false, | 71 | canResize: false, |
72 | actionColumn: { | 72 | actionColumn: { |
73 | width: 80, | 73 | width: 80, |
74 | - title: t('routes.common.dept.tableTitleDeptOperation'),//操作 | 74 | + title: t('routes.common.dept.tableTitleDeptOperation'), //操作 |
75 | dataIndex: 'action', | 75 | dataIndex: 'action', |
76 | slots: { customRender: 'action' }, | 76 | slots: { customRender: 'action' }, |
77 | fixed: undefined, | 77 | fixed: undefined, |
@@ -82,7 +82,7 @@ | @@ -82,7 +82,7 @@ | ||
82 | */ | 82 | */ |
83 | function getDeleteTitle(): string { | 83 | function getDeleteTitle(): string { |
84 | let labelText = t('routes.common.system.pageSystemTitleWhetherDelete'); | 84 | let labelText = t('routes.common.system.pageSystemTitleWhetherDelete'); |
85 | - return labelText | 85 | + return labelText; |
86 | } | 86 | } |
87 | 87 | ||
88 | function handleCreate() { | 88 | function handleCreate() { |
@@ -101,11 +101,11 @@ | @@ -101,11 +101,11 @@ | ||
101 | async function handleDelete(record: Recordable) { | 101 | async function handleDelete(record: Recordable) { |
102 | // console.log(record); | 102 | // console.log(record); |
103 | try { | 103 | try { |
104 | - let ids = [record.id,]; | 104 | + let ids = [record.id]; |
105 | await delDept(ids); | 105 | await delDept(ids); |
106 | notification.success({ | 106 | notification.success({ |
107 | - message: "成功", | ||
108 | - description: "删除部门成功", | 107 | + message: '成功', |
108 | + description: '删除部门成功', | ||
109 | duration: 3, | 109 | duration: 3, |
110 | }); | 110 | }); |
111 | await reload(); | 111 | await reload(); |
@@ -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"> |
@@ -49,18 +49,17 @@ | @@ -49,18 +49,17 @@ | ||
49 | const values = await validate(); | 49 | const values = await validate(); |
50 | const { createMessage } = useMessage(); | 50 | const { createMessage } = useMessage(); |
51 | setDrawerProps({ confirmLoading: true }); | 51 | setDrawerProps({ confirmLoading: true }); |
52 | - let successMessage="添加成功"; | 52 | + let successMessage = '添加成功'; |
53 | //如果是修改需要传入id | 53 | //如果是修改需要传入id |
54 | - if(unref(isUpdate)){ | ||
55 | - successMessage = "修改成功"; | 54 | + if (unref(isUpdate)) { |
55 | + successMessage = '修改成功'; | ||
56 | Reflect.set(values, 'id', id); | 56 | Reflect.set(values, 'id', id); |
57 | } | 57 | } |
58 | - await saveOrEditDict(values,unref(isUpdate)).then(() =>{ | 58 | + await saveOrEditDict(values, unref(isUpdate)).then(() => { |
59 | closeDrawer(); | 59 | closeDrawer(); |
60 | emit('success'); | 60 | emit('success'); |
61 | createMessage.success(successMessage); | 61 | createMessage.success(successMessage); |
62 | - }) | ||
63 | - | 62 | + }); |
64 | } finally { | 63 | } finally { |
65 | setDrawerProps({ confirmLoading: false }); | 64 | setDrawerProps({ confirmLoading: false }); |
66 | } | 65 | } |
@@ -8,17 +8,17 @@ | @@ -8,17 +8,17 @@ | ||
8 | <TableAction | 8 | <TableAction |
9 | :actions="[ | 9 | :actions="[ |
10 | { | 10 | { |
11 | - label:'字典值配置', | 11 | + label: '字典值配置', |
12 | icon: 'ant-design:appstore-add-outlined', | 12 | icon: 'ant-design:appstore-add-outlined', |
13 | onClick: handleItem.bind(null, record), | 13 | onClick: handleItem.bind(null, record), |
14 | }, | 14 | }, |
15 | { | 15 | { |
16 | - label:'编辑', | 16 | + label: '编辑', |
17 | icon: 'clarity:note-edit-line', | 17 | icon: 'clarity:note-edit-line', |
18 | onClick: handleEdit.bind(null, record), | 18 | onClick: handleEdit.bind(null, record), |
19 | }, | 19 | }, |
20 | { | 20 | { |
21 | - label:'删除', | 21 | + label: '删除', |
22 | icon: 'ant-design:delete-outlined', | 22 | icon: 'ant-design:delete-outlined', |
23 | color: 'error', | 23 | color: 'error', |
24 | popConfirm: { | 24 | popConfirm: { |
@@ -36,30 +36,30 @@ | @@ -36,30 +36,30 @@ | ||
36 | </template> | 36 | </template> |
37 | </BasicTable> | 37 | </BasicTable> |
38 | <DictDrawer @register="registerDrawer" @success="handleSuccess" /> | 38 | <DictDrawer @register="registerDrawer" @success="handleSuccess" /> |
39 | - <ItemIndex @register="registerItemDrawer" @success="handleSuccess"/> | 39 | + <ItemIndex @register="registerItemDrawer" @success="handleSuccess" /> |
40 | </div> | 40 | </div> |
41 | </template> | 41 | </template> |
42 | <script lang="ts"> | 42 | <script lang="ts"> |
43 | import { defineComponent } from 'vue'; | 43 | import { defineComponent } from 'vue'; |
44 | 44 | ||
45 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 45 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
46 | - import { sysDictPage,deleteDict } from '/@/api/system/dict'; | 46 | + import { sysDictPage, deleteDict } from '/@/api/system/dict'; |
47 | 47 | ||
48 | import { useDrawer } from '/@/components/Drawer'; | 48 | import { useDrawer } from '/@/components/Drawer'; |
49 | import DictDrawer from './DictDrawer.vue'; | 49 | import DictDrawer from './DictDrawer.vue'; |
50 | import ItemIndex from './item/ItemIndex.vue'; | 50 | import ItemIndex from './item/ItemIndex.vue'; |
51 | 51 | ||
52 | import { columns, searchFormSchema } from './dict.data'; | 52 | import { columns, searchFormSchema } from './dict.data'; |
53 | - import {Tag} from "ant-design-vue"; | ||
54 | - import {useMessage} from "/@/hooks/web/useMessage"; | 53 | + import { Tag } from 'ant-design-vue'; |
54 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
55 | 55 | ||
56 | export default defineComponent({ | 56 | export default defineComponent({ |
57 | name: 'DictManagement', | 57 | name: 'DictManagement', |
58 | - components: { BasicTable, DictDrawer,ItemIndex, TableAction ,Tag}, | 58 | + components: { BasicTable, DictDrawer, ItemIndex, TableAction, Tag }, |
59 | setup() { | 59 | setup() { |
60 | const { createMessage } = useMessage(); | 60 | const { createMessage } = useMessage(); |
61 | - const [registerDrawer, { openDrawer:openDrawer }] = useDrawer(); | ||
62 | - const [registerItemDrawer, { openDrawer: openItemDrawer}] = useDrawer(); | 61 | + const [registerDrawer, { openDrawer: openDrawer }] = useDrawer(); |
62 | + const [registerItemDrawer, { openDrawer: openItemDrawer }] = useDrawer(); | ||
63 | const [registerTable, { reload }] = useTable({ | 63 | const [registerTable, { reload }] = useTable({ |
64 | title: '字典配置列表', | 64 | title: '字典配置列表', |
65 | api: sysDictPage, | 65 | api: sysDictPage, |
@@ -94,17 +94,17 @@ | @@ -94,17 +94,17 @@ | ||
94 | }); | 94 | }); |
95 | } | 95 | } |
96 | 96 | ||
97 | - function handleItem(record: Recordable){ | 97 | + function handleItem(record: Recordable) { |
98 | openItemDrawer(true, { | 98 | openItemDrawer(true, { |
99 | - id:record.id, | 99 | + id: record.id, |
100 | }); | 100 | }); |
101 | } | 101 | } |
102 | 102 | ||
103 | function handleDelete(record: Recordable) { | 103 | function handleDelete(record: Recordable) { |
104 | let ids = [record.id]; | 104 | let ids = [record.id]; |
105 | - deleteDict(ids).then((result)=>{ | ||
106 | - createMessage.success(result.message) | ||
107 | - handleSuccess() | 105 | + deleteDict(ids).then((result) => { |
106 | + createMessage.success(result.message); | ||
107 | + handleSuccess(); | ||
108 | }); | 108 | }); |
109 | } | 109 | } |
110 | 110 |
@@ -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"> |
@@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
29 | schemas: formSchema, | 29 | schemas: formSchema, |
30 | showActionButtonGroup: false, | 30 | showActionButtonGroup: false, |
31 | }); | 31 | }); |
32 | - let dictId,id; | 32 | + let dictId, id; |
33 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | 33 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
34 | await resetFields(); | 34 | await resetFields(); |
35 | setDrawerProps({ confirmLoading: false }); | 35 | setDrawerProps({ confirmLoading: false }); |
@@ -50,16 +50,16 @@ | @@ -50,16 +50,16 @@ | ||
50 | const values = await validate(); | 50 | const values = await validate(); |
51 | const { createMessage } = useMessage(); | 51 | const { createMessage } = useMessage(); |
52 | setDrawerProps({ confirmLoading: true }); | 52 | setDrawerProps({ confirmLoading: true }); |
53 | - let message="添加成功"; | ||
54 | - if(unref(isUpdate)){ | 53 | + let message = '添加成功'; |
54 | + if (unref(isUpdate)) { | ||
55 | //如果是修改需要传入id | 55 | //如果是修改需要传入id |
56 | Reflect.set(values, 'id', id); | 56 | Reflect.set(values, 'id', id); |
57 | - message = "修改成功"; | ||
58 | - }else{ | 57 | + message = '修改成功'; |
58 | + } else { | ||
59 | //添加需要dictId | 59 | //添加需要dictId |
60 | Reflect.set(values, 'dictId', dictId); | 60 | Reflect.set(values, 'dictId', dictId); |
61 | } | 61 | } |
62 | - await saveOrEditDictItem(values,unref(isUpdate)); | 62 | + await saveOrEditDictItem(values, unref(isUpdate)); |
63 | closeDrawer(); | 63 | closeDrawer(); |
64 | emit('success'); | 64 | emit('success'); |
65 | createMessage.success(message); | 65 | createMessage.success(message); |
@@ -8,22 +8,22 @@ | @@ -8,22 +8,22 @@ | ||
8 | <template #action="{ record }"> | 8 | <template #action="{ record }"> |
9 | <TableAction | 9 | <TableAction |
10 | :actions="[ | 10 | :actions="[ |
11 | - { | ||
12 | - label:'编辑', | ||
13 | - icon: 'clarity:note-edit-line', | ||
14 | - onClick: handleEdit.bind(null, record), | ||
15 | - }, | ||
16 | - { | ||
17 | - label:'删除', | ||
18 | - icon: 'ant-design:delete-outlined', | ||
19 | - color: 'error', | ||
20 | - popConfirm: { | ||
21 | - title: '是否确认删除', | ||
22 | - confirm: handleDelete.bind(null, record), | 11 | + { |
12 | + label: '编辑', | ||
13 | + icon: 'clarity:note-edit-line', | ||
14 | + onClick: handleEdit.bind(null, record), | ||
23 | }, | 15 | }, |
24 | - ifShow: record.status ==0 | ||
25 | - }, | ||
26 | - ]" | 16 | + { |
17 | + label: '删除', | ||
18 | + icon: 'ant-design:delete-outlined', | ||
19 | + color: 'error', | ||
20 | + popConfirm: { | ||
21 | + title: '是否确认删除', | ||
22 | + confirm: handleDelete.bind(null, record), | ||
23 | + }, | ||
24 | + ifShow: record.status == 0, | ||
25 | + }, | ||
26 | + ]" | ||
27 | /> | 27 | /> |
28 | </template> | 28 | </template> |
29 | </BasicTable> | 29 | </BasicTable> |
@@ -35,18 +35,18 @@ | @@ -35,18 +35,18 @@ | ||
35 | import { defineComponent } from 'vue'; | 35 | import { defineComponent } from 'vue'; |
36 | 36 | ||
37 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 37 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
38 | - import { sysDictItemPage,deleteDictItem } from '/@/api/system/dict'; | 38 | + import { sysDictItemPage, deleteDictItem } from '/@/api/system/dict'; |
39 | 39 | ||
40 | - import { BasicDrawer,useDrawer,useDrawerInner } from '/@/components/Drawer'; | ||
41 | - import ItemDrawer from "/@/views/system/dict/item/ItemDrawer.vue"; | 40 | + import { BasicDrawer, useDrawer, useDrawerInner } from '/@/components/Drawer'; |
41 | + import ItemDrawer from '/@/views/system/dict/item/ItemDrawer.vue'; | ||
42 | 42 | ||
43 | import { columns, searchFormSchema } from './dict.item.data'; | 43 | import { columns, searchFormSchema } from './dict.item.data'; |
44 | - import {Tag} from "ant-design-vue"; | ||
45 | - import {useMessage} from "/@/hooks/web/useMessage"; | 44 | + import { Tag } from 'ant-design-vue'; |
45 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
46 | 46 | ||
47 | export default defineComponent({ | 47 | export default defineComponent({ |
48 | name: 'ItemIndex', | 48 | name: 'ItemIndex', |
49 | - components: {BasicDrawer, BasicTable, ItemDrawer, TableAction ,Tag}, | 49 | + components: { BasicDrawer, BasicTable, ItemDrawer, TableAction, Tag }, |
50 | setup() { | 50 | setup() { |
51 | let dictId; | 51 | let dictId; |
52 | const { createMessage } = useMessage(); | 52 | const { createMessage } = useMessage(); |
@@ -73,14 +73,14 @@ | @@ -73,14 +73,14 @@ | ||
73 | slots: { customRender: 'action' }, | 73 | slots: { customRender: 'action' }, |
74 | fixed: undefined, | 74 | fixed: undefined, |
75 | }, | 75 | }, |
76 | - beforeFetch:getDictId, | ||
77 | - immediate:true | 76 | + beforeFetch: getDictId, |
77 | + immediate: true, | ||
78 | }); | 78 | }); |
79 | 79 | ||
80 | function handleCreate() { | 80 | function handleCreate() { |
81 | openDrawer(true, { | 81 | openDrawer(true, { |
82 | isUpdate: false, | 82 | isUpdate: false, |
83 | - dictId:dictId, | 83 | + dictId: dictId, |
84 | }); | 84 | }); |
85 | } | 85 | } |
86 | 86 | ||
@@ -88,7 +88,7 @@ | @@ -88,7 +88,7 @@ | ||
88 | * 获取父页面传递的dictId值 | 88 | * 获取父页面传递的dictId值 |
89 | * @param data 请求之前的参数 | 89 | * @param data 请求之前的参数 |
90 | */ | 90 | */ |
91 | - function getDictId(data){ | 91 | + function getDictId(data) { |
92 | Reflect.set(data, 'dictId', dictId); | 92 | Reflect.set(data, 'dictId', dictId); |
93 | } | 93 | } |
94 | 94 | ||
@@ -101,9 +101,9 @@ | @@ -101,9 +101,9 @@ | ||
101 | 101 | ||
102 | function handleDelete(record: Recordable) { | 102 | function handleDelete(record: Recordable) { |
103 | let ids = [record.id]; | 103 | let ids = [record.id]; |
104 | - deleteDictItem(ids).then((result)=>{ | ||
105 | - createMessage.success(result.message) | ||
106 | - handleSuccess() | 104 | + deleteDictItem(ids).then((result) => { |
105 | + createMessage.success(result.message); | ||
106 | + handleSuccess(); | ||
107 | }); | 107 | }); |
108 | } | 108 | } |
109 | 109 | ||
@@ -118,7 +118,7 @@ | @@ -118,7 +118,7 @@ | ||
118 | handleCreate, | 118 | handleCreate, |
119 | handleEdit, | 119 | handleEdit, |
120 | handleDelete, | 120 | handleDelete, |
121 | - handleSuccess | 121 | + handleSuccess, |
122 | }; | 122 | }; |
123 | }, | 123 | }, |
124 | }); | 124 | }); |
@@ -7,138 +7,140 @@ | @@ -7,138 +7,140 @@ | ||
7 | width="50%" | 7 | width="50%" |
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"> |
14 | -import {defineComponent, ref, computed, unref} from 'vue'; | ||
15 | -import {BasicForm, useForm} from '/@/components/Form/index'; | ||
16 | -import {formSchema} from './menu.data'; | ||
17 | -import {BasicDrawer, useDrawerInner} from '/@/components/Drawer'; | ||
18 | - | ||
19 | -// 加载菜单 | ||
20 | -import {getMenuList} from '/@/api/sys/menu'; | ||
21 | - | ||
22 | -import {saveMenuApi} from '/@/api/system/menu'; | ||
23 | -import {listToTree} from '/@/utils/menuUtil'; | ||
24 | - | ||
25 | -import {useI18n} from "/@/hooks/web/useI18n"; | ||
26 | -import {metaModel} from '/@/api/system/model/menuModel'; | ||
27 | - | ||
28 | - | ||
29 | -export default defineComponent({ | ||
30 | - name: 'MenuDrawer', | ||
31 | - components: {BasicDrawer, BasicForm}, | ||
32 | - emits: ['success', 'register'], | ||
33 | - setup(_, {emit}) { | ||
34 | - const isUpdate = ref(true); | ||
35 | - let menuId; | ||
36 | - | ||
37 | - const [registerForm, {resetFields, setFieldsValue, updateSchema, validate}] = useForm({ | ||
38 | - labelWidth: 100, | ||
39 | - schemas: formSchema, | ||
40 | - showActionButtonGroup: false, | ||
41 | - baseColProps: {lg: 12, md: 24}, | ||
42 | - }); | ||
43 | - const {t} = useI18n(); //加载国际化 | ||
44 | - | ||
45 | - //默认传递页面数据 | ||
46 | - const [registerDrawer, {setDrawerProps, closeDrawer}] = useDrawerInner(async (data) => { | ||
47 | - resetFields(); | ||
48 | - setDrawerProps({confirmLoading: false}); | ||
49 | - isUpdate.value = !!data?.isUpdate; | ||
50 | - | ||
51 | - //初始化,菜单名称为可用 | ||
52 | - updateSchema({field: 'title', componentProps: {disabled: false}}); | ||
53 | - //如果是编辑操作,设置页面数据 | ||
54 | - if (unref(isUpdate)) { | ||
55 | - | ||
56 | - console.log("------------编辑时获得的值-----------------------"); | ||
57 | - console.log(data.record); | ||
58 | - | ||
59 | - // // 动态设置 表单值 | ||
60 | - // | ||
61 | - let menuObj: metaModel = Reflect.get(data.record, 'meta'); | ||
62 | - Reflect.set(data.record, 'menuType', menuObj.menuType);//meta.menuType | ||
63 | - Reflect.set(data.record, 'title', menuObj.title);//meta.title | ||
64 | - Reflect.set(data.record, 'icon', menuObj.icon);//meta.icon | ||
65 | - Reflect.set(data.record, 'hideMenu', menuObj.hideMenu);//meta.hideMenu | ||
66 | - Reflect.set(data.record, 'ignoreKeepAlive', menuObj.ignoreKeepAlive);//meta.ignoreKeepAlive | ||
67 | - Reflect.set(data.record, 'isLink', menuObj.isLink);//meta.isLink | ||
68 | - Reflect.set(data.record, 'status', menuObj.status);//meta.status | ||
69 | - //为表单赋值 | ||
70 | - setFieldsValue({ | ||
71 | - ...data.record, | ||
72 | - }); | ||
73 | - | ||
74 | - //编辑模式,菜单名称为不可用 | ||
75 | - updateSchema({field: 'title', componentProps: {disabled: true,}}); | ||
76 | - } | ||
77 | - if (isUpdate.value) { | ||
78 | - menuId = Reflect.get(data.record, 'id'); | ||
79 | - } | ||
80 | - //加载菜单 | ||
81 | - let treeData = await getMenuList(); | ||
82 | - treeData = listToTree(treeData); | ||
83 | - updateSchema({ | ||
84 | - field: 'parentId', | ||
85 | - componentProps: {treeData}, | 14 | + import { defineComponent, ref, computed, unref } from 'vue'; |
15 | + import { BasicForm, useForm } from '/@/components/Form/index'; | ||
16 | + import { formSchema } from './menu.data'; | ||
17 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
18 | + | ||
19 | + // 加载菜单 | ||
20 | + import { getMenuList } from '/@/api/sys/menu'; | ||
21 | + | ||
22 | + import { saveMenuApi } from '/@/api/system/menu'; | ||
23 | + import { listToTree } from '/@/utils/menuUtil'; | ||
24 | + | ||
25 | + import { useI18n } from '/@/hooks/web/useI18n'; | ||
26 | + import { metaModel } from '/@/api/system/model/menuModel'; | ||
27 | + | ||
28 | + export default defineComponent({ | ||
29 | + name: 'MenuDrawer', | ||
30 | + components: { BasicDrawer, BasicForm }, | ||
31 | + emits: ['success', 'register'], | ||
32 | + setup(_, { emit }) { | ||
33 | + const isUpdate = ref(true); | ||
34 | + let menuId; | ||
35 | + | ||
36 | + const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({ | ||
37 | + labelWidth: 100, | ||
38 | + schemas: formSchema, | ||
39 | + showActionButtonGroup: false, | ||
40 | + baseColProps: { lg: 12, md: 24 }, | ||
86 | }); | 41 | }); |
87 | - }); | ||
88 | - | ||
89 | - //得到页面标题 | ||
90 | - const getTitle = computed(() => (!unref(isUpdate) ? t('routes.common.system.pageSystemTitleCreateMenu') : t('routes.common.system.pageSystemTitleEditMenu'))); | ||
91 | - | ||
92 | - //提交按钮 | ||
93 | - async function handleSubmit() { | ||
94 | - try { | ||
95 | - const values = await validate(); | ||
96 | - setDrawerProps({confirmLoading: true}); | ||
97 | - // TODO custom api | ||
98 | - | ||
99 | - // 处理权限标识为null时,后台空指针 | ||
100 | - let permissionStr: string = Reflect.get(values, 'permission'); | ||
101 | - if (permissionStr === undefined || permissionStr === null) { | ||
102 | - Reflect.set(values, 'permission', " "); | ||
103 | - } | ||
104 | - | ||
105 | - // 添加属性; | ||
106 | - //当前作为默认管理员操作; | ||
107 | - Reflect.set(values, 'type', 'SYSADMIN'); | ||
108 | - Reflect.set(values, 'name', Reflect.get(values, 'title')); | ||
109 | - //当前选择为菜单时操作 | ||
110 | - let menuType: string = Reflect.get(values, 'menuType'); | ||
111 | - if (menuType === '0') { | ||
112 | - Reflect.set(values, 'component', 'LAYOUT'); | 42 | + const { t } = useI18n(); //加载国际化 |
43 | + | ||
44 | + //默认传递页面数据 | ||
45 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
46 | + resetFields(); | ||
47 | + setDrawerProps({ confirmLoading: false }); | ||
48 | + isUpdate.value = !!data?.isUpdate; | ||
49 | + | ||
50 | + //初始化,菜单名称为可用 | ||
51 | + updateSchema({ field: 'title', componentProps: { disabled: false } }); | ||
52 | + //如果是编辑操作,设置页面数据 | ||
53 | + if (unref(isUpdate)) { | ||
54 | + console.log('------------编辑时获得的值-----------------------'); | ||
55 | + console.log(data.record); | ||
56 | + | ||
57 | + // // 动态设置 表单值 | ||
58 | + // | ||
59 | + let menuObj: metaModel = Reflect.get(data.record, 'meta'); | ||
60 | + Reflect.set(data.record, 'menuType', menuObj.menuType); //meta.menuType | ||
61 | + Reflect.set(data.record, 'title', menuObj.title); //meta.title | ||
62 | + Reflect.set(data.record, 'icon', menuObj.icon); //meta.icon | ||
63 | + Reflect.set(data.record, 'hideMenu', menuObj.hideMenu); //meta.hideMenu | ||
64 | + Reflect.set(data.record, 'ignoreKeepAlive', menuObj.ignoreKeepAlive); //meta.ignoreKeepAlive | ||
65 | + Reflect.set(data.record, 'isLink', menuObj.isLink); //meta.isLink | ||
66 | + Reflect.set(data.record, 'status', menuObj.status); //meta.status | ||
67 | + //为表单赋值 | ||
68 | + setFieldsValue({ | ||
69 | + ...data.record, | ||
70 | + }); | ||
71 | + | ||
72 | + //编辑模式,菜单名称为不可用 | ||
73 | + updateSchema({ field: 'title', componentProps: { disabled: true } }); | ||
113 | } | 74 | } |
114 | if (isUpdate.value) { | 75 | if (isUpdate.value) { |
115 | - Reflect.set(values, 'id', menuId); | 76 | + menuId = Reflect.get(data.record, 'id'); |
116 | } | 77 | } |
78 | + //加载菜单 | ||
79 | + let treeData = await getMenuList(); | ||
80 | + treeData = listToTree(treeData); | ||
81 | + updateSchema({ | ||
82 | + field: 'parentId', | ||
83 | + componentProps: { treeData }, | ||
84 | + }); | ||
85 | + }); | ||
117 | 86 | ||
118 | - //为meta设置值 | ||
119 | - const metaTemp: metaModel = { | ||
120 | - icon: Reflect.get(values, 'icon'), | ||
121 | - title: Reflect.get(values, 'title'), | ||
122 | - isLink: Reflect.get(values, 'isLink'), | ||
123 | - menuType: Reflect.get(values, 'menuType'), | ||
124 | - ignoreKeepAlive: Reflect.get(values, 'ignoreKeepAlive'), //[创建菜单,才需要] | ||
125 | - hideMenu: Reflect.get(values, 'hideMenu'), | ||
126 | - status: Reflect.get(values, 'status'), | 87 | + //得到页面标题 |
88 | + const getTitle = computed(() => | ||
89 | + !unref(isUpdate) | ||
90 | + ? t('routes.common.system.pageSystemTitleCreateMenu') | ||
91 | + : t('routes.common.system.pageSystemTitleEditMenu') | ||
92 | + ); | ||
93 | + | ||
94 | + //提交按钮 | ||
95 | + async function handleSubmit() { | ||
96 | + try { | ||
97 | + const values = await validate(); | ||
98 | + setDrawerProps({ confirmLoading: true }); | ||
99 | + // TODO custom api | ||
100 | + | ||
101 | + // 处理权限标识为null时,后台空指针 | ||
102 | + let permissionStr: string = Reflect.get(values, 'permission'); | ||
103 | + if (permissionStr === undefined || permissionStr === null) { | ||
104 | + Reflect.set(values, 'permission', ' '); | ||
105 | + } | ||
106 | + | ||
107 | + // 添加属性; | ||
108 | + //当前作为默认管理员操作; | ||
109 | + Reflect.set(values, 'type', 'SYSADMIN'); | ||
110 | + Reflect.set(values, 'name', Reflect.get(values, 'title')); | ||
111 | + //当前选择为菜单时操作 | ||
112 | + let menuType: string = Reflect.get(values, 'menuType'); | ||
113 | + if (menuType === '0') { | ||
114 | + Reflect.set(values, 'component', 'LAYOUT'); | ||
115 | + } | ||
116 | + if (isUpdate.value) { | ||
117 | + Reflect.set(values, 'id', menuId); | ||
118 | + } | ||
119 | + | ||
120 | + //为meta设置值 | ||
121 | + const metaTemp: metaModel = { | ||
122 | + icon: Reflect.get(values, 'icon'), | ||
123 | + title: Reflect.get(values, 'title'), | ||
124 | + isLink: Reflect.get(values, 'isLink'), | ||
125 | + menuType: Reflect.get(values, 'menuType'), | ||
126 | + ignoreKeepAlive: Reflect.get(values, 'ignoreKeepAlive'), //[创建菜单,才需要] | ||
127 | + hideMenu: Reflect.get(values, 'hideMenu'), | ||
128 | + status: Reflect.get(values, 'status'), | ||
129 | + }; | ||
130 | + Reflect.set(values, 'meta', metaTemp); | ||
131 | + | ||
132 | + // saveMenu | ||
133 | + const data = await saveMenuApi(values, isUpdate.value); | ||
134 | + console.log('_______保存返回结果____data:' + data); | ||
135 | + | ||
136 | + closeDrawer(); //关闭侧框 | ||
137 | + emit('success'); | ||
138 | + } finally { | ||
139 | + setDrawerProps({ confirmLoading: false }); | ||
127 | } | 140 | } |
128 | - Reflect.set(values, 'meta', metaTemp); | ||
129 | - | ||
130 | - // saveMenu | ||
131 | - const data = await saveMenuApi(values, isUpdate.value); | ||
132 | - console.log("_______保存返回结果____data:" + data); | ||
133 | - | ||
134 | - closeDrawer();//关闭侧框 | ||
135 | - emit('success'); | ||
136 | - } finally { | ||
137 | - setDrawerProps({confirmLoading: false}); | ||
138 | } | 141 | } |
139 | - } | ||
140 | 142 | ||
141 | - return {registerDrawer, registerForm, getTitle, handleSubmit}; | ||
142 | - }, | ||
143 | -}); | 143 | + return { registerDrawer, registerForm, getTitle, handleSubmit }; |
144 | + }, | ||
145 | + }); | ||
144 | </script> | 146 | </script> |
@@ -3,12 +3,12 @@ | @@ -3,12 +3,12 @@ | ||
3 | <!-- register 用于注册 useTable,如果需要使用useTable提供的 api,必须将 register 传入组件的 onRegister--> | 3 | <!-- register 用于注册 useTable,如果需要使用useTable提供的 api,必须将 register 传入组件的 onRegister--> |
4 | <!-- @fetch-success接口请求成功后触发 --> | 4 | <!-- @fetch-success接口请求成功后触发 --> |
5 | <BasicTable @register="registerTable" @fetch-success="onFetchSuccess"> | 5 | <BasicTable @register="registerTable" @fetch-success="onFetchSuccess"> |
6 | - | ||
7 | <!-- 通过模板,加载工具栏 --> | 6 | <!-- 通过模板,加载工具栏 --> |
8 | <template #toolbar> | 7 | <template #toolbar> |
9 | <a-button type="primary" @click="handleCreate"> | 8 | <a-button type="primary" @click="handleCreate"> |
10 | {{ getI18nCreateMenu }} | 9 | {{ getI18nCreateMenu }} |
11 | - </a-button> <!-- 新增菜单--> | 10 | + </a-button> |
11 | + <!-- 新增菜单--> | ||
12 | </template> | 12 | </template> |
13 | 13 | ||
14 | <!-- 表格单项,操作 --> | 14 | <!-- 表格单项,操作 --> |
@@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
23 | icon: 'ant-design:delete-outlined', | 23 | icon: 'ant-design:delete-outlined', |
24 | color: 'error', | 24 | color: 'error', |
25 | popConfirm: { | 25 | popConfirm: { |
26 | - title: getDeleteTitle(),//是否确认删除//getDeleteTitle() | 26 | + title: getDeleteTitle(), //是否确认删除//getDeleteTitle() |
27 | confirm: handleDelete.bind(null, record), | 27 | confirm: handleDelete.bind(null, record), |
28 | }, | 28 | }, |
29 | }, | 29 | }, |
@@ -33,135 +33,135 @@ | @@ -33,135 +33,135 @@ | ||
33 | </BasicTable> | 33 | </BasicTable> |
34 | 34 | ||
35 | <!-- 弹出框 --> | 35 | <!-- 弹出框 --> |
36 | - <MenuDrawer @register="registerDrawer" @success="handleSuccess"/> | 36 | + <MenuDrawer @register="registerDrawer" @success="handleSuccess" /> |
37 | </div> | 37 | </div> |
38 | </template> | 38 | </template> |
39 | <script lang="ts"> | 39 | <script lang="ts"> |
40 | -//导入所需插件 | ||
41 | -import {computed, defineComponent, nextTick} from 'vue'; | ||
42 | - | ||
43 | -// 导入表格组件,表格事件 | ||
44 | -import {BasicTable, useTable, TableAction} from '/@/components/Table'; | ||
45 | - | ||
46 | -// 加载表格数据 | ||
47 | -import {getMenuList, delMenu} from '/@/api/sys/menu'; | ||
48 | -// 加载自定义侧边弹出框 组件 | ||
49 | -import {useDrawer} from '/@/components/Drawer'; | ||
50 | - | ||
51 | -// 导入子页面【新增、修改】 | ||
52 | -import MenuDrawer from './MenuDrawer.vue'; | ||
53 | - | ||
54 | -// 导入列 属性,和搜索栏内容 | ||
55 | -import {columns, searchFormSchema} from './menu.data'; | ||
56 | -import {useI18n} from "/@/hooks/web/useI18n"; | ||
57 | -import {notification} from "ant-design-vue"; | ||
58 | - | ||
59 | -// 自定义表格组件和属性 | ||
60 | -export default defineComponent({ | ||
61 | - name: 'MenuManagement', | ||
62 | - components: {BasicTable, MenuDrawer, TableAction}, | ||
63 | - setup() { | ||
64 | - const [registerDrawer, {openDrawer}] = useDrawer();//使用右侧弹出框 | ||
65 | - const {t} = useI18n(); //加载国际化 | ||
66 | - // 新增菜单 | ||
67 | - const getI18nCreateMenu = computed(() => t('routes.common.system.pageSystemTitleCreateMenu')); | ||
68 | - | ||
69 | - const [registerTable, {reload, expandAll}] = useTable({ | ||
70 | - title: t('routes.common.system.pageSystemTitleMenuList'),//'菜单列表' | ||
71 | - api: getMenuList, //加载数据 | ||
72 | - columns, //加载列 | ||
73 | - // formConfig: { | ||
74 | - // labelWidth: 120, | ||
75 | - // schemas: searchFormSchema, | ||
76 | - // }, | ||
77 | - isTreeTable: true, | ||
78 | - pagination: false, | ||
79 | - striped: false, | ||
80 | - // useSearchForm: true, | ||
81 | - showTableSetting: true, | ||
82 | - bordered: true, | ||
83 | - showIndexColumn: false, | ||
84 | - canResize: false, | ||
85 | - actionColumn: { | ||
86 | - width: 80, | ||
87 | - title: t('routes.common.system.pageSystemTitleOperation'),//操作 | ||
88 | - dataIndex: 'action', | ||
89 | - slots: {customRender: 'action'}, | ||
90 | - fixed: undefined, | ||
91 | - }, | ||
92 | - }); | ||
93 | - | ||
94 | - /** | ||
95 | - * 获得删除提示框的文字 | ||
96 | - */ | ||
97 | - function getDeleteTitle(): string { | ||
98 | - let labelText = t('routes.common.system.pageSystemTitleWhetherDelete'); | ||
99 | - return labelText | ||
100 | - } | ||
101 | - | ||
102 | - /** | ||
103 | - * 打开新增菜单 | ||
104 | - */ | ||
105 | - function handleCreate() { | ||
106 | - openDrawer(true, { | ||
107 | - isUpdate: false, | 40 | + //导入所需插件 |
41 | + import { computed, defineComponent, nextTick } from 'vue'; | ||
42 | + | ||
43 | + // 导入表格组件,表格事件 | ||
44 | + import { BasicTable, useTable, TableAction } from '/@/components/Table'; | ||
45 | + | ||
46 | + // 加载表格数据 | ||
47 | + import { getMenuList, delMenu } from '/@/api/sys/menu'; | ||
48 | + // 加载自定义侧边弹出框 组件 | ||
49 | + import { useDrawer } from '/@/components/Drawer'; | ||
50 | + | ||
51 | + // 导入子页面【新增、修改】 | ||
52 | + import MenuDrawer from './MenuDrawer.vue'; | ||
53 | + | ||
54 | + // 导入列 属性,和搜索栏内容 | ||
55 | + import { columns, searchFormSchema } from './menu.data'; | ||
56 | + import { useI18n } from '/@/hooks/web/useI18n'; | ||
57 | + import { notification } from 'ant-design-vue'; | ||
58 | + | ||
59 | + // 自定义表格组件和属性 | ||
60 | + export default defineComponent({ | ||
61 | + name: 'MenuManagement', | ||
62 | + components: { BasicTable, MenuDrawer, TableAction }, | ||
63 | + setup() { | ||
64 | + const [registerDrawer, { openDrawer }] = useDrawer(); //使用右侧弹出框 | ||
65 | + const { t } = useI18n(); //加载国际化 | ||
66 | + // 新增菜单 | ||
67 | + const getI18nCreateMenu = computed(() => t('routes.common.system.pageSystemTitleCreateMenu')); | ||
68 | + | ||
69 | + const [registerTable, { reload, expandAll }] = useTable({ | ||
70 | + title: t('routes.common.system.pageSystemTitleMenuList'), //'菜单列表' | ||
71 | + api: getMenuList, //加载数据 | ||
72 | + columns, //加载列 | ||
73 | + // formConfig: { | ||
74 | + // labelWidth: 120, | ||
75 | + // schemas: searchFormSchema, | ||
76 | + // }, | ||
77 | + isTreeTable: true, | ||
78 | + pagination: false, | ||
79 | + striped: false, | ||
80 | + // useSearchForm: true, | ||
81 | + showTableSetting: true, | ||
82 | + bordered: true, | ||
83 | + showIndexColumn: false, | ||
84 | + canResize: false, | ||
85 | + actionColumn: { | ||
86 | + width: 80, | ||
87 | + title: t('routes.common.system.pageSystemTitleOperation'), //操作 | ||
88 | + dataIndex: 'action', | ||
89 | + slots: { customRender: 'action' }, | ||
90 | + fixed: undefined, | ||
91 | + }, | ||
108 | }); | 92 | }); |
109 | - } | ||
110 | 93 | ||
111 | - /** | ||
112 | - * 打开 编辑菜单 | ||
113 | - * @param record | ||
114 | - */ | ||
115 | - function handleEdit(record: Recordable) { | ||
116 | - console.log("----------------------------333-------------"+record.parentId); | ||
117 | - openDrawer(true, { | ||
118 | - record, | ||
119 | - isUpdate: true, | ||
120 | - }); | ||
121 | - } | 94 | + /** |
95 | + * 获得删除提示框的文字 | ||
96 | + */ | ||
97 | + function getDeleteTitle(): string { | ||
98 | + let labelText = t('routes.common.system.pageSystemTitleWhetherDelete'); | ||
99 | + return labelText; | ||
100 | + } | ||
122 | 101 | ||
123 | - /** | ||
124 | - * 执行 删除操作 | ||
125 | - * @param record | ||
126 | - */ | ||
127 | - async function handleDelete(record: Recordable) { | ||
128 | - try { | ||
129 | - let ids = [record.id,]; | ||
130 | - await delMenu(ids); | ||
131 | - notification.success({ | ||
132 | - message: "成功", | ||
133 | - description: "删除菜单成功", | ||
134 | - duration: 3, | 102 | + /** |
103 | + * 打开新增菜单 | ||
104 | + */ | ||
105 | + function handleCreate() { | ||
106 | + openDrawer(true, { | ||
107 | + isUpdate: false, | ||
135 | }); | 108 | }); |
136 | - await reload(); | ||
137 | - } catch (e) { | ||
138 | - return Promise.reject(e); | ||
139 | } | 109 | } |
140 | - } | ||
141 | 110 | ||
142 | - /** | ||
143 | - * 操作成功,重新加载页面 | ||
144 | - */ | ||
145 | - function handleSuccess() { | ||
146 | - reload(); | ||
147 | - } | 111 | + /** |
112 | + * 打开 编辑菜单 | ||
113 | + * @param record | ||
114 | + */ | ||
115 | + function handleEdit(record: Recordable) { | ||
116 | + console.log('----------------------------333-------------' + record.parentId); | ||
117 | + openDrawer(true, { | ||
118 | + record, | ||
119 | + isUpdate: true, | ||
120 | + }); | ||
121 | + } | ||
148 | 122 | ||
149 | - function onFetchSuccess() { | ||
150 | - // 演示默认展开所有表项 | ||
151 | - nextTick(expandAll); | ||
152 | - } | 123 | + /** |
124 | + * 执行 删除操作 | ||
125 | + * @param record | ||
126 | + */ | ||
127 | + async function handleDelete(record: Recordable) { | ||
128 | + try { | ||
129 | + let ids = [record.id]; | ||
130 | + await delMenu(ids); | ||
131 | + notification.success({ | ||
132 | + message: '成功', | ||
133 | + description: '删除菜单成功', | ||
134 | + duration: 3, | ||
135 | + }); | ||
136 | + await reload(); | ||
137 | + } catch (e) { | ||
138 | + return Promise.reject(e); | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
142 | + /** | ||
143 | + * 操作成功,重新加载页面 | ||
144 | + */ | ||
145 | + function handleSuccess() { | ||
146 | + reload(); | ||
147 | + } | ||
148 | + | ||
149 | + function onFetchSuccess() { | ||
150 | + // 演示默认展开所有表项 | ||
151 | + nextTick(expandAll); | ||
152 | + } | ||
153 | 153 | ||
154 | - return { | ||
155 | - getDeleteTitle, | ||
156 | - getI18nCreateMenu, | ||
157 | - registerTable, | ||
158 | - registerDrawer, | ||
159 | - handleCreate, | ||
160 | - handleEdit, | ||
161 | - handleDelete, | ||
162 | - handleSuccess, | ||
163 | - onFetchSuccess, | ||
164 | - }; | ||
165 | - }, | ||
166 | -}); | 154 | + return { |
155 | + getDeleteTitle, | ||
156 | + getI18nCreateMenu, | ||
157 | + registerTable, | ||
158 | + registerDrawer, | ||
159 | + handleCreate, | ||
160 | + handleEdit, | ||
161 | + handleDelete, | ||
162 | + handleSuccess, | ||
163 | + onFetchSuccess, | ||
164 | + }; | ||
165 | + }, | ||
166 | + }); | ||
167 | </script> | 167 | </script> |
@@ -13,15 +13,15 @@ | @@ -13,15 +13,15 @@ | ||
13 | import { defineComponent } from 'vue'; | 13 | import { defineComponent } from 'vue'; |
14 | import { PageWrapper } from '/@/components/Page'; | 14 | import { PageWrapper } from '/@/components/Page'; |
15 | import { BasicForm, useForm } from '/@/components/Form'; | 15 | import { BasicForm, useForm } from '/@/components/Form'; |
16 | - import {USER_INFO_KEY} from "/@/enums/cacheEnum"; | ||
17 | - import {getAuthCache} from "/@/utils/auth"; | 16 | + import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
17 | + import { getAuthCache } from '/@/utils/auth'; | ||
18 | import { formSchema } from './pwd.data'; | 18 | import { formSchema } from './pwd.data'; |
19 | - import {resetPassword} from "/@/api/system/system"; | ||
20 | - import {useMultipleTabStore} from "/@/store/modules/multipleTab"; | ||
21 | - import {useUserStore} from "/@/store/modules/user"; | ||
22 | - import {useAppStore} from "/@/store/modules/app"; | ||
23 | - import {usePermissionStore} from "/@/store/modules/permission"; | ||
24 | - import {useMessage} from "/@/hooks/web/useMessage"; | 19 | + import { resetPassword } from '/@/api/system/system'; |
20 | + import { useMultipleTabStore } from '/@/store/modules/multipleTab'; | ||
21 | + import { useUserStore } from '/@/store/modules/user'; | ||
22 | + import { useAppStore } from '/@/store/modules/app'; | ||
23 | + import { usePermissionStore } from '/@/store/modules/permission'; | ||
24 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
25 | export default defineComponent({ | 25 | export default defineComponent({ |
26 | name: 'ChangePassword', | 26 | name: 'ChangePassword', |
27 | components: { BasicForm, PageWrapper }, | 27 | components: { BasicForm, PageWrapper }, |
@@ -36,31 +36,31 @@ | @@ -36,31 +36,31 @@ | ||
36 | const userStore = useUserStore(); | 36 | const userStore = useUserStore(); |
37 | const appStore = useAppStore(); | 37 | const appStore = useAppStore(); |
38 | const permissionStore = usePermissionStore(); | 38 | const permissionStore = usePermissionStore(); |
39 | - const {createMessage} = useMessage(); | 39 | + const { createMessage } = useMessage(); |
40 | const userInfo = getAuthCache(USER_INFO_KEY); | 40 | const userInfo = getAuthCache(USER_INFO_KEY); |
41 | - console.log(userInfo,"userInfo") | 41 | + console.log(userInfo, 'userInfo'); |
42 | async function handleSubmit() { | 42 | async function handleSubmit() { |
43 | try { | 43 | try { |
44 | const values = await validate(); | 44 | const values = await validate(); |
45 | const { passwordOld, passwordNew } = values; | 45 | const { passwordOld, passwordNew } = values; |
46 | const params = { | 46 | const params = { |
47 | - userId:userInfo.userId, | ||
48 | - password:passwordOld, | ||
49 | - resetPassword:passwordNew | 47 | + userId: userInfo.userId, |
48 | + password: passwordOld, | ||
49 | + resetPassword: passwordNew, | ||
50 | }; | 50 | }; |
51 | 51 | ||
52 | - await resetPassword(params).then((result)=>{ | ||
53 | - if(result.data){ | ||
54 | - createMessage.success("修改成功"); | ||
55 | - setTimeout(function (){ | ||
56 | - localStorage.clear(); | ||
57 | - appStore.resetAllState(); | ||
58 | - permissionStore.resetState(); | ||
59 | - tabStore.resetState(); | ||
60 | - userStore.resetState(); | ||
61 | - location.reload(); | ||
62 | - },500) | ||
63 | - } | 52 | + await resetPassword(params).then((result) => { |
53 | + if (result.data) { | ||
54 | + createMessage.success('修改成功'); | ||
55 | + setTimeout(function () { | ||
56 | + localStorage.clear(); | ||
57 | + appStore.resetAllState(); | ||
58 | + permissionStore.resetState(); | ||
59 | + tabStore.resetState(); | ||
60 | + userStore.resetState(); | ||
61 | + location.reload(); | ||
62 | + }, 500); | ||
63 | + } | ||
64 | }); | 64 | }); |
65 | } catch (error) {} | 65 | } catch (error) {} |
66 | } | 66 | } |
@@ -23,112 +23,112 @@ | @@ -23,112 +23,112 @@ | ||
23 | </BasicDrawer> | 23 | </BasicDrawer> |
24 | </template> | 24 | </template> |
25 | <script lang="ts"> | 25 | <script lang="ts"> |
26 | -import {defineComponent, ref, computed, unref} from 'vue'; | ||
27 | -import {BasicForm, useForm} from '/@/components/Form/index'; | ||
28 | -import {formSchema} from './role.data'; | ||
29 | -import {BasicDrawer, useDrawerInner} from '/@/components/Drawer'; | ||
30 | -import {BasicTree, TreeItem} from '/@/components/Tree'; | 26 | + import { defineComponent, ref, computed, unref } from 'vue'; |
27 | + import { BasicForm, useForm } from '/@/components/Form/index'; | ||
28 | + import { formSchema } from './role.data'; | ||
29 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
30 | + import { BasicTree, TreeItem } from '/@/components/Tree'; | ||
31 | 31 | ||
32 | -const {t} = useI18n(); //加载国际化 | 32 | + const { t } = useI18n(); //加载国际化 |
33 | 33 | ||
34 | -// import { getMenuList } from '/@/api/demo/system'; | 34 | + // import { getMenuList } from '/@/api/demo/system'; |
35 | 35 | ||
36 | -// 加载菜单数据 | ||
37 | -import {getMenuList, getMenusIdsByRoleId} from '/@/api/sys/menu'; | ||
38 | -import {useI18n} from "/@/hooks/web/useI18n"; | ||
39 | -import {RouteItem} from "/@/api/sys/model/menuModel"; | ||
40 | -import {saveOrUpdateRoleInfoWithMenu} from "/@/api/system/system"; | 36 | + // 加载菜单数据 |
37 | + import { getMenuList, getMenusIdsByRoleId } from '/@/api/sys/menu'; | ||
38 | + import { useI18n } from '/@/hooks/web/useI18n'; | ||
39 | + import { RouteItem } from '/@/api/sys/model/menuModel'; | ||
40 | + import { saveOrUpdateRoleInfoWithMenu } from '/@/api/system/system'; | ||
41 | 41 | ||
42 | -export default defineComponent({ | ||
43 | - name: 'RoleDrawer', | ||
44 | - components: {BasicDrawer, BasicForm, BasicTree}, | ||
45 | - emits: ['success', 'register'], | ||
46 | - setup(_, {emit}) { | ||
47 | - const isUpdate = ref(true); | ||
48 | - const treeData = ref<TreeItem[]>([]); | ||
49 | - const roleMenus = ref<string[]>([]); | ||
50 | - const roleId = ref(""); | 42 | + export default defineComponent({ |
43 | + name: 'RoleDrawer', | ||
44 | + components: { BasicDrawer, BasicForm, BasicTree }, | ||
45 | + emits: ['success', 'register'], | ||
46 | + setup(_, { emit }) { | ||
47 | + const isUpdate = ref(true); | ||
48 | + const treeData = ref<TreeItem[]>([]); | ||
49 | + const roleMenus = ref<string[]>([]); | ||
50 | + const roleId = ref(''); | ||
51 | 51 | ||
52 | - const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ | ||
53 | - labelWidth: 90, | ||
54 | - schemas: formSchema, | ||
55 | - showActionButtonGroup: false, | ||
56 | - }); | ||
57 | - | ||
58 | - function processChildren(items: RouteItem[]) { | ||
59 | - items.map((item) => { | ||
60 | - item.menuName = t(item.meta.title); | ||
61 | - item.icon = item.meta.icon; | ||
62 | - item.key=item.id; | ||
63 | - if (item.children) { | ||
64 | - processChildren(item.children); | ||
65 | - } | 52 | + const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
53 | + labelWidth: 90, | ||
54 | + schemas: formSchema, | ||
55 | + showActionButtonGroup: false, | ||
66 | }); | 56 | }); |
67 | - } | ||
68 | 57 | ||
69 | - const [registerDrawer, {setDrawerProps, closeDrawer}] = useDrawerInner(async (data) => { | ||
70 | - resetFields(); | ||
71 | - roleId.value = ""; | ||
72 | - setDrawerProps({confirmLoading: false}); | ||
73 | - // 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告 | ||
74 | - if (unref(treeData).length === 0) { | ||
75 | - const menuListModel = await getMenuList(); | ||
76 | - processChildren(menuListModel); | ||
77 | - let treeValues = new Array<TreeItem>(); | ||
78 | - menuListModel.map((item) => { | ||
79 | - const data = { | ||
80 | - menuName: t(item.meta.title), | ||
81 | - icon: item.meta.icon, | ||
82 | - key: item.id, | ||
83 | - children: item.children as any as TreeItem[], | 58 | + function processChildren(items: RouteItem[]) { |
59 | + items.map((item) => { | ||
60 | + item.menuName = t(item.meta.title); | ||
61 | + item.icon = item.meta.icon; | ||
62 | + item.key = item.id; | ||
63 | + if (item.children) { | ||
64 | + processChildren(item.children); | ||
84 | } | 65 | } |
85 | - treeValues.push(data); | ||
86 | - }) | ||
87 | - treeData.value = treeValues; | ||
88 | - } | ||
89 | - if (data.record) { | ||
90 | - roleMenus.value = await getMenusIdsByRoleId(data.record.id); | ||
91 | - console.log(roleMenus.value,"roleMenus.value") | ||
92 | - roleId.value = data.record.id; | ||
93 | - } | ||
94 | - isUpdate.value = !!data?.isUpdate; | ||
95 | - if (unref(isUpdate)) { | ||
96 | - setFieldsValue({ | ||
97 | - ...data.record, | ||
98 | }); | 66 | }); |
99 | } | 67 | } |
100 | - }); | ||
101 | 68 | ||
102 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); | 69 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
70 | + resetFields(); | ||
71 | + roleId.value = ''; | ||
72 | + setDrawerProps({ confirmLoading: false }); | ||
73 | + // 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告 | ||
74 | + if (unref(treeData).length === 0) { | ||
75 | + const menuListModel = await getMenuList(); | ||
76 | + processChildren(menuListModel); | ||
77 | + let treeValues = new Array<TreeItem>(); | ||
78 | + menuListModel.map((item) => { | ||
79 | + const data = { | ||
80 | + menuName: t(item.meta.title), | ||
81 | + icon: item.meta.icon, | ||
82 | + key: item.id, | ||
83 | + children: item.children as any as TreeItem[], | ||
84 | + }; | ||
85 | + treeValues.push(data); | ||
86 | + }); | ||
87 | + treeData.value = treeValues; | ||
88 | + } | ||
89 | + if (data.record) { | ||
90 | + roleMenus.value = await getMenusIdsByRoleId(data.record.id); | ||
91 | + console.log(roleMenus.value, 'roleMenus.value'); | ||
92 | + roleId.value = data.record.id; | ||
93 | + } | ||
94 | + isUpdate.value = !!data?.isUpdate; | ||
95 | + if (unref(isUpdate)) { | ||
96 | + setFieldsValue({ | ||
97 | + ...data.record, | ||
98 | + }); | ||
99 | + } | ||
100 | + }); | ||
101 | + | ||
102 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); | ||
103 | 103 | ||
104 | - async function handleSubmit() { | ||
105 | - try { | ||
106 | - const values = await validate(); | ||
107 | - setDrawerProps({confirmLoading: true}); | ||
108 | - const req = { | ||
109 | - id: roleId.value, | ||
110 | - name: values.name, | ||
111 | - remark: values.remark, | ||
112 | - status: values.status, | ||
113 | - menu: [...values.menu] | 104 | + async function handleSubmit() { |
105 | + try { | ||
106 | + const values = await validate(); | ||
107 | + setDrawerProps({ confirmLoading: true }); | ||
108 | + const req = { | ||
109 | + id: roleId.value, | ||
110 | + name: values.name, | ||
111 | + remark: values.remark, | ||
112 | + status: values.status, | ||
113 | + menu: [...values.menu], | ||
114 | + }; | ||
115 | + saveOrUpdateRoleInfoWithMenu(req).then(() => { | ||
116 | + closeDrawer(); | ||
117 | + emit('success'); | ||
118 | + }); | ||
119 | + } finally { | ||
120 | + setDrawerProps({ confirmLoading: false }); | ||
114 | } | 121 | } |
115 | - saveOrUpdateRoleInfoWithMenu(req).then(()=>{ | ||
116 | - closeDrawer(); | ||
117 | - emit('success'); | ||
118 | - }) | ||
119 | - } finally { | ||
120 | - setDrawerProps({confirmLoading: false}); | ||
121 | } | 122 | } |
122 | - } | ||
123 | 123 | ||
124 | - return { | ||
125 | - registerDrawer, | ||
126 | - registerForm, | ||
127 | - getTitle, | ||
128 | - handleSubmit, | ||
129 | - treeData, | ||
130 | - roleMenus, | ||
131 | - }; | ||
132 | - }, | ||
133 | -}); | 124 | + return { |
125 | + registerDrawer, | ||
126 | + registerForm, | ||
127 | + getTitle, | ||
128 | + handleSubmit, | ||
129 | + treeData, | ||
130 | + roleMenus, | ||
131 | + }; | ||
132 | + }, | ||
133 | + }); | ||
134 | </script> | 134 | </script> |
@@ -8,15 +8,15 @@ | @@ -8,15 +8,15 @@ | ||
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 | - ifShow:record.roleType!=RoleEnum.ROLE_SYS_ADMIN, | 19 | + ifShow: record.roleType != RoleEnum.ROLE_SYS_ADMIN, |
20 | popConfirm: { | 20 | popConfirm: { |
21 | title: '是否确认删除', | 21 | title: '是否确认删除', |
22 | confirm: handleDelete.bind(null, record), | 22 | confirm: handleDelete.bind(null, record), |
@@ -33,12 +33,12 @@ | @@ -33,12 +33,12 @@ | ||
33 | import { defineComponent } from 'vue'; | 33 | import { defineComponent } from 'vue'; |
34 | 34 | ||
35 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 35 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
36 | - import {delRole, getRoleListByPage} from '/@/api/system/system'; | 36 | + import { delRole, getRoleListByPage } from '/@/api/system/system'; |
37 | 37 | ||
38 | import { useDrawer } from '/@/components/Drawer'; | 38 | import { useDrawer } from '/@/components/Drawer'; |
39 | import RoleDrawer from './RoleDrawer.vue'; | 39 | import RoleDrawer from './RoleDrawer.vue'; |
40 | import { columns, searchFormSchema } from './role.data'; | 40 | import { columns, searchFormSchema } from './role.data'; |
41 | - import {RoleEnum} from "/@/enums/roleEnum"; | 41 | + import { RoleEnum } from '/@/enums/roleEnum'; |
42 | 42 | ||
43 | export default defineComponent({ | 43 | export default defineComponent({ |
44 | name: 'RoleManagement', | 44 | name: 'RoleManagement', |
@@ -49,10 +49,10 @@ | @@ -49,10 +49,10 @@ | ||
49 | title: '角色列表', | 49 | title: '角色列表', |
50 | api: getRoleListByPage, | 50 | api: getRoleListByPage, |
51 | columns, | 51 | columns, |
52 | - tableSetting:{ | ||
53 | - redo:true, | ||
54 | - size:false, | ||
55 | - setting:false | 52 | + tableSetting: { |
53 | + redo: true, | ||
54 | + size: false, | ||
55 | + setting: false, | ||
56 | }, | 56 | }, |
57 | formConfig: { | 57 | formConfig: { |
58 | labelWidth: 120, | 58 | labelWidth: 120, |
@@ -85,11 +85,10 @@ | @@ -85,11 +85,10 @@ | ||
85 | } | 85 | } |
86 | 86 | ||
87 | async function handleDelete(record: Recordable) { | 87 | async function handleDelete(record: Recordable) { |
88 | - const roleIds = [record.id] | ||
89 | - delRole(roleIds).then(()=>{ | 88 | + const roleIds = [record.id]; |
89 | + delRole(roleIds).then(() => { | ||
90 | reload(); | 90 | reload(); |
91 | - }) | ||
92 | - | 91 | + }); |
93 | } | 92 | } |
94 | function handleSuccess() { | 93 | function handleSuccess() { |
95 | reload(); | 94 | reload(); |
@@ -102,7 +101,7 @@ | @@ -102,7 +101,7 @@ | ||
102 | handleEdit, | 101 | handleEdit, |
103 | handleDelete, | 102 | handleDelete, |
104 | handleSuccess, | 103 | handleSuccess, |
105 | - RoleEnum | 104 | + RoleEnum, |
106 | }; | 105 | }; |
107 | }, | 106 | }, |
108 | }); | 107 | }); |
@@ -7,9 +7,7 @@ | @@ -7,9 +7,7 @@ | ||
7 | width="60%" | 7 | width="60%" |
8 | @ok="handleSubmit" | 8 | @ok="handleSubmit" |
9 | > | 9 | > |
10 | - <BasicTable | ||
11 | - @register="tenantAdminTable" | ||
12 | - > | 10 | + <BasicTable @register="tenantAdminTable"> |
13 | <template #toolbar> | 11 | <template #toolbar> |
14 | <a-button type="primary" @click="handleCreateTenantAdmin">新增租户管理员</a-button> | 12 | <a-button type="primary" @click="handleCreateTenantAdmin">新增租户管理员</a-button> |
15 | </template> | 13 | </template> |
@@ -17,31 +15,31 @@ | @@ -17,31 +15,31 @@ | ||
17 | <TableAction | 15 | <TableAction |
18 | :actions="[ | 16 | :actions="[ |
19 | { | 17 | { |
20 | - label:'短信激活', | 18 | + label: '短信激活', |
21 | icon: 'ant-design:send-outlined', | 19 | icon: 'ant-design:send-outlined', |
22 | - tooltip:'发送激活短信', | ||
23 | - ifShow:record.phoneNumber!=null&& !record.hasPassword, | 20 | + tooltip: '发送激活短信', |
21 | + ifShow: record.phoneNumber != null && !record.hasPassword, | ||
24 | onClick: handleSendMsg.bind(null, record), | 22 | onClick: handleSendMsg.bind(null, record), |
25 | }, | 23 | }, |
26 | { | 24 | { |
27 | - label:'清除密码', | 25 | + label: '清除密码', |
28 | icon: 'ant-design:clear-outlined', | 26 | icon: 'ant-design:clear-outlined', |
29 | - tooltip:'清除密码', | 27 | + tooltip: '清除密码', |
30 | ifShow: record.hasPassword, | 28 | ifShow: record.hasPassword, |
31 | onClick: handleResetPassword.bind(null, record), | 29 | onClick: handleResetPassword.bind(null, record), |
32 | }, | 30 | }, |
33 | - { | ||
34 | - label:'编辑', | ||
35 | - icon: 'clarity:note-edit-line', | ||
36 | - tooltip:'编辑', | ||
37 | - onClick: handleEdit.bind(null, record), | 31 | + { |
32 | + label: '编辑', | ||
33 | + icon: 'clarity:note-edit-line', | ||
34 | + tooltip: '编辑', | ||
35 | + onClick: handleEdit.bind(null, record), | ||
38 | }, | 36 | }, |
39 | - { | ||
40 | - label:'删除', | ||
41 | - icon: 'ant-design:delete-outlined', | ||
42 | - tooltip:'删除', | ||
43 | - color: 'error', | ||
44 | - popConfirm: { | 37 | + { |
38 | + label: '删除', | ||
39 | + icon: 'ant-design:delete-outlined', | ||
40 | + tooltip: '删除', | ||
41 | + color: 'error', | ||
42 | + popConfirm: { | ||
45 | title: '是否确认删除', | 43 | title: '是否确认删除', |
46 | confirm: handleDelete.bind(null, record), | 44 | confirm: handleDelete.bind(null, record), |
47 | }, | 45 | }, |
@@ -51,156 +49,169 @@ | @@ -51,156 +49,169 @@ | ||
51 | </template> | 49 | </template> |
52 | <template #status="{ record }"> | 50 | <template #status="{ record }"> |
53 | <Tag | 51 | <Tag |
54 | - :color="record.userStatusEnum==='NORMAL'?'green':(record.userStatusEnum==='DISABLED'?'red':'orange')"> | 52 | + :color=" |
53 | + record.userStatusEnum === 'NORMAL' | ||
54 | + ? 'green' | ||
55 | + : record.userStatusEnum === 'DISABLED' | ||
56 | + ? 'red' | ||
57 | + : 'orange' | ||
58 | + " | ||
59 | + > | ||
55 | {{ | 60 | {{ |
56 | - record.userStatusEnum === 'NORMAL' ? '正常' : (record.userStatusEnum === 'DISABLED' ? '已禁用' : '已过期') | 61 | + record.userStatusEnum === 'NORMAL' |
62 | + ? '正常' | ||
63 | + : record.userStatusEnum === 'DISABLED' | ||
64 | + ? '已禁用' | ||
65 | + : '已过期' | ||
57 | }} | 66 | }} |
58 | </Tag> | 67 | </Tag> |
59 | </template> | 68 | </template> |
60 | </BasicTable> | 69 | </BasicTable> |
61 | - <TenantAdminFormDrawer @register="tenantAdminFormDrawer" @success="handleSuccess"/> | 70 | + <TenantAdminFormDrawer @register="tenantAdminFormDrawer" @success="handleSuccess" /> |
62 | </BasicDrawer> | 71 | </BasicDrawer> |
63 | </template> | 72 | </template> |
64 | <script lang="ts"> | 73 | <script lang="ts"> |
65 | -import {defineComponent, ref} from 'vue'; | ||
66 | -import {BasicDrawer, useDrawer, useDrawerInner} from '/@/components/Drawer'; | ||
67 | -import {BasicColumn, BasicTable, TableAction, useTable} from '/@/components/Table'; | ||
68 | -import { | ||
69 | - deleteTenantAdmin, | ||
70 | - getTenantAdminPage, | ||
71 | - resetPassword, | ||
72 | - sendMessageOrEmail | ||
73 | -} from "/@/api/tenant/tenantApi"; | ||
74 | -import {Tag} from 'ant-design-vue'; | ||
75 | -import TenantAdminFormDrawer from "./TenantAdminFormDrawer.vue" | ||
76 | -import {MessageTypeEnum, SendResetPasswordEmailMsg} from "/@/api/tenant/tenantInfo"; | ||
77 | -import {useMessage} from "/@/hooks/web/useMessage"; | ||
78 | -import {RoleEnum} from "/@/enums/roleEnum"; | ||
79 | -export default defineComponent({ | ||
80 | - name: 'TenantAdminDrawer', | ||
81 | - components: { | ||
82 | - BasicDrawer, BasicTable, TenantAdminFormDrawer, Tag, TableAction | ||
83 | - }, | ||
84 | - setup() { | ||
85 | - const{createMessage} =useMessage(); | ||
86 | - const [tenantAdminFormDrawer, {openDrawer: openTenantAdminFormDrawer}] = useDrawer(); | ||
87 | - | ||
88 | - function handleCreateTenantAdmin() { | ||
89 | - openTenantAdminFormDrawer(true, { | ||
90 | - isUpdate: false, | ||
91 | - tenantCode: tenantCode | ||
92 | - }); | ||
93 | - } | 74 | + import { defineComponent, ref } from 'vue'; |
75 | + import { BasicDrawer, useDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
76 | + import { BasicColumn, BasicTable, TableAction, useTable } from '/@/components/Table'; | ||
77 | + import { | ||
78 | + deleteTenantAdmin, | ||
79 | + getTenantAdminPage, | ||
80 | + resetPassword, | ||
81 | + sendMessageOrEmail, | ||
82 | + } from '/@/api/tenant/tenantApi'; | ||
83 | + import { Tag } from 'ant-design-vue'; | ||
84 | + import TenantAdminFormDrawer from './TenantAdminFormDrawer.vue'; | ||
85 | + import { MessageTypeEnum, SendResetPasswordEmailMsg } from '/@/api/tenant/tenantInfo'; | ||
86 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
87 | + import { RoleEnum } from '/@/enums/roleEnum'; | ||
88 | + export default defineComponent({ | ||
89 | + name: 'TenantAdminDrawer', | ||
90 | + components: { | ||
91 | + BasicDrawer, | ||
92 | + BasicTable, | ||
93 | + TenantAdminFormDrawer, | ||
94 | + Tag, | ||
95 | + TableAction, | ||
96 | + }, | ||
97 | + setup() { | ||
98 | + const { createMessage } = useMessage(); | ||
99 | + const [tenantAdminFormDrawer, { openDrawer: openTenantAdminFormDrawer }] = useDrawer(); | ||
94 | 100 | ||
95 | - function handleEdit(record: Recordable) { | ||
96 | - openTenantAdminFormDrawer(true, { | ||
97 | - isUpdate: true, | ||
98 | - record, | ||
99 | - tenantCode: tenantCode | ||
100 | - }); | ||
101 | - } | 101 | + function handleCreateTenantAdmin() { |
102 | + openTenantAdminFormDrawer(true, { | ||
103 | + isUpdate: false, | ||
104 | + tenantCode: tenantCode, | ||
105 | + }); | ||
106 | + } | ||
102 | 107 | ||
103 | - function handleDelete(record: Recordable) { | ||
104 | - deleteTenantAdmin([record.id]); | ||
105 | - createMessage.success("删除成功"); | ||
106 | - handleSuccess(); | ||
107 | - } | 108 | + function handleEdit(record: Recordable) { |
109 | + openTenantAdminFormDrawer(true, { | ||
110 | + isUpdate: true, | ||
111 | + record, | ||
112 | + tenantCode: tenantCode, | ||
113 | + }); | ||
114 | + } | ||
108 | 115 | ||
109 | - function handleResetPassword(record: Recordable) { | ||
110 | - resetPassword(record.id); | ||
111 | - createMessage.success("清空密码成功"); | ||
112 | - handleSuccess(); | ||
113 | - } | ||
114 | - function handleSendMsg(record: Recordable) { | ||
115 | - const req = new SendResetPasswordEmailMsg(record.id, MessageTypeEnum.PHONE_MESSAGE) | ||
116 | - sendMessageOrEmail(req).then(()=>{ | ||
117 | - createMessage.success("短信发送成功"); | 116 | + function handleDelete(record: Recordable) { |
117 | + deleteTenantAdmin([record.id]); | ||
118 | + createMessage.success('删除成功'); | ||
118 | handleSuccess(); | 119 | handleSuccess(); |
119 | - }); | ||
120 | - } | ||
121 | - | 120 | + } |
122 | 121 | ||
123 | - const tenantAdminColumns = [ | ||
124 | - { | ||
125 | - title: '用户名', | ||
126 | - dataIndex: 'username', | ||
127 | - width: 50, | ||
128 | - }, | ||
129 | - { | ||
130 | - title: '真实名字', | ||
131 | - dataIndex: 'realName', | ||
132 | - width: 50, | ||
133 | - }, | ||
134 | - { | ||
135 | - title: '电话号码', | ||
136 | - dataIndex: 'phoneNumber', | ||
137 | - width: 50, | ||
138 | - }, | ||
139 | - { | ||
140 | - title: '邮箱', | ||
141 | - dataIndex: 'email', | ||
142 | - width: 70, | ||
143 | - }, | ||
144 | - { | ||
145 | - title: '状态', | ||
146 | - dataIndex: 'userStatus', | ||
147 | - width: 30, | ||
148 | - slots: {customRender: 'status'}, | ||
149 | - }, | ||
150 | - ]; | ||
151 | - const tenantCode = ref(""); | ||
152 | - const [tenantAdminTable, {reload}] = useTable({ | ||
153 | - api: getTenantAdminPage, | ||
154 | - columns: tenantAdminColumns as BasicColumn[], | ||
155 | - showTableSetting: true, | ||
156 | - bordered: true, | ||
157 | - showIndexColumn: false, | ||
158 | - searchInfo: { | ||
159 | - tenantCode: tenantCode, | ||
160 | - roleType: RoleEnum.ROLE_TENANT_ADMIN | ||
161 | - }, | ||
162 | - actionColumn: { | ||
163 | - width: 100, | ||
164 | - title: '操作', | ||
165 | - dataIndex: 'action', | ||
166 | - slots: {customRender: 'action'}, | ||
167 | - fixed: undefined, | ||
168 | - }, | ||
169 | - tableSetting: { | ||
170 | - redo: true, | ||
171 | - size: false, | ||
172 | - setting: false | 122 | + function handleResetPassword(record: Recordable) { |
123 | + resetPassword(record.id); | ||
124 | + createMessage.success('清空密码成功'); | ||
125 | + handleSuccess(); | ||
126 | + } | ||
127 | + function handleSendMsg(record: Recordable) { | ||
128 | + const req = new SendResetPasswordEmailMsg(record.id, MessageTypeEnum.PHONE_MESSAGE); | ||
129 | + sendMessageOrEmail(req).then(() => { | ||
130 | + createMessage.success('短信发送成功'); | ||
131 | + handleSuccess(); | ||
132 | + }); | ||
173 | } | 133 | } |
174 | - }); | ||
175 | - //默认传递页面数据 | ||
176 | - const [tenantAdminDrawer, {closeDrawer}] = useDrawerInner(async (data) => { | ||
177 | - tenantCode.value = data.record.tenantCode; | ||
178 | - await reload(); | ||
179 | - }); | ||
180 | 134 | ||
181 | - //提交按钮 | ||
182 | - async function handleSubmit() { | ||
183 | - closeDrawer();//关闭侧框 | ||
184 | - } | 135 | + const tenantAdminColumns = [ |
136 | + { | ||
137 | + title: '用户名', | ||
138 | + dataIndex: 'username', | ||
139 | + width: 50, | ||
140 | + }, | ||
141 | + { | ||
142 | + title: '真实名字', | ||
143 | + dataIndex: 'realName', | ||
144 | + width: 50, | ||
145 | + }, | ||
146 | + { | ||
147 | + title: '电话号码', | ||
148 | + dataIndex: 'phoneNumber', | ||
149 | + width: 50, | ||
150 | + }, | ||
151 | + { | ||
152 | + title: '邮箱', | ||
153 | + dataIndex: 'email', | ||
154 | + width: 70, | ||
155 | + }, | ||
156 | + { | ||
157 | + title: '状态', | ||
158 | + dataIndex: 'userStatus', | ||
159 | + width: 30, | ||
160 | + slots: { customRender: 'status' }, | ||
161 | + }, | ||
162 | + ]; | ||
163 | + const tenantCode = ref(''); | ||
164 | + const [tenantAdminTable, { reload }] = useTable({ | ||
165 | + api: getTenantAdminPage, | ||
166 | + columns: tenantAdminColumns as BasicColumn[], | ||
167 | + showTableSetting: true, | ||
168 | + bordered: true, | ||
169 | + showIndexColumn: false, | ||
170 | + searchInfo: { | ||
171 | + tenantCode: tenantCode, | ||
172 | + roleType: RoleEnum.ROLE_TENANT_ADMIN, | ||
173 | + }, | ||
174 | + actionColumn: { | ||
175 | + width: 100, | ||
176 | + title: '操作', | ||
177 | + dataIndex: 'action', | ||
178 | + slots: { customRender: 'action' }, | ||
179 | + fixed: undefined, | ||
180 | + }, | ||
181 | + tableSetting: { | ||
182 | + redo: true, | ||
183 | + size: false, | ||
184 | + setting: false, | ||
185 | + }, | ||
186 | + }); | ||
187 | + //默认传递页面数据 | ||
188 | + const [tenantAdminDrawer, { closeDrawer }] = useDrawerInner(async (data) => { | ||
189 | + tenantCode.value = data.record.tenantCode; | ||
190 | + await reload(); | ||
191 | + }); | ||
185 | 192 | ||
186 | - function handleSuccess() { | ||
187 | - reload(); | ||
188 | - } | 193 | + //提交按钮 |
194 | + async function handleSubmit() { | ||
195 | + closeDrawer(); //关闭侧框 | ||
196 | + } | ||
189 | 197 | ||
190 | - return { | ||
191 | - tenantAdminDrawer, | ||
192 | - handleCreateTenantAdmin, | ||
193 | - handleSubmit, | ||
194 | - tenantAdminTable, | ||
195 | - tenantCode, | ||
196 | - tenantAdminFormDrawer, | ||
197 | - handleSuccess, | ||
198 | - handleEdit, | ||
199 | - handleDelete, | ||
200 | - handleResetPassword, | ||
201 | - handleSendMsg | 198 | + function handleSuccess() { |
199 | + reload(); | ||
200 | + } | ||
202 | 201 | ||
203 | - }; | ||
204 | - }, | ||
205 | -}); | 202 | + return { |
203 | + tenantAdminDrawer, | ||
204 | + handleCreateTenantAdmin, | ||
205 | + handleSubmit, | ||
206 | + tenantAdminTable, | ||
207 | + tenantCode, | ||
208 | + tenantAdminFormDrawer, | ||
209 | + handleSuccess, | ||
210 | + handleEdit, | ||
211 | + handleDelete, | ||
212 | + handleResetPassword, | ||
213 | + handleSendMsg, | ||
214 | + }; | ||
215 | + }, | ||
216 | + }); | ||
206 | </script> | 217 | </script> |
@@ -7,120 +7,123 @@ | @@ -7,120 +7,123 @@ | ||
7 | width="60%" | 7 | width="60%" |
8 | @ok="handleSubmit" | 8 | @ok="handleSubmit" |
9 | > | 9 | > |
10 | - <BasicForm @register="tenantAdminForm"> | ||
11 | - </BasicForm> | 10 | + <BasicForm @register="tenantAdminForm"> </BasicForm> |
12 | </BasicDrawer> | 11 | </BasicDrawer> |
13 | </template> | 12 | </template> |
14 | <script lang="ts"> | 13 | <script lang="ts"> |
15 | -import {computed, defineComponent, ref, unref} from 'vue'; | ||
16 | -import {BasicDrawer, useDrawerInner} from '/@/components/Drawer'; | ||
17 | -import {BasicForm, FormSchema, useForm} from '/@/components/Form/index'; | ||
18 | -import {saveTenantAdmin} from "/@/api/tenant/tenantApi"; | ||
19 | -import {UserDTO} from "/@/api/tenant/tenantInfo"; | 14 | + import { computed, defineComponent, ref, unref } from 'vue'; |
15 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
16 | + import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; | ||
17 | + import { saveTenantAdmin } from '/@/api/tenant/tenantApi'; | ||
18 | + import { UserDTO } from '/@/api/tenant/tenantInfo'; | ||
20 | 19 | ||
21 | -export default defineComponent({ | ||
22 | - name: 'TenantAdminFormDrawer', | ||
23 | - components: { | ||
24 | - BasicDrawer, BasicForm | ||
25 | - }, | ||
26 | - setup(_, {emit}) { | ||
27 | - const isUpdate = ref(true); | ||
28 | - const tenantCode = ref(""); | ||
29 | - const formSchema: FormSchema[] = [ | ||
30 | - { | ||
31 | - field: 'id', | ||
32 | - label: 'id:', | ||
33 | - show: false, | ||
34 | - component: 'Input', | ||
35 | - }, | ||
36 | - { | ||
37 | - field: 'username', | ||
38 | - label: '账号:', | ||
39 | - required: true, | ||
40 | - component: 'Input', | ||
41 | - }, | ||
42 | - { | ||
43 | - field: 'realName', | ||
44 | - label: '真实名字:', | ||
45 | - required: true, | ||
46 | - component: 'Input', | ||
47 | - }, | ||
48 | - { | ||
49 | - field: 'phoneNumber', | ||
50 | - label: '电话号码:', | ||
51 | - required: true, | ||
52 | - component: 'Input', | ||
53 | - }, | ||
54 | - { | ||
55 | - field: 'email', | ||
56 | - label: '邮件:', | ||
57 | - required: true, | ||
58 | - component: 'Input', | ||
59 | - }, | ||
60 | - { | ||
61 | - field: 'enabled', | ||
62 | - label: '状态', | ||
63 | - required: true, | ||
64 | - component: 'RadioButtonGroup', | ||
65 | - defaultValue: true, | ||
66 | - componentProps: { | ||
67 | - options: [ | ||
68 | - {label: '启用', value: true}, | ||
69 | - {label: '停用', value: false}, | ||
70 | - ], | 20 | + export default defineComponent({ |
21 | + name: 'TenantAdminFormDrawer', | ||
22 | + components: { | ||
23 | + BasicDrawer, | ||
24 | + BasicForm, | ||
25 | + }, | ||
26 | + setup(_, { emit }) { | ||
27 | + const isUpdate = ref(true); | ||
28 | + const tenantCode = ref(''); | ||
29 | + const formSchema: FormSchema[] = [ | ||
30 | + { | ||
31 | + field: 'id', | ||
32 | + label: 'id:', | ||
33 | + show: false, | ||
34 | + component: 'Input', | ||
71 | }, | 35 | }, |
72 | - }, | ||
73 | - ] | ||
74 | - const [tenantAdminForm, {resetFields, setFieldsValue, updateSchema, validate}] = useForm({ | ||
75 | - labelWidth: 100, | ||
76 | - schemas: formSchema, | ||
77 | - showActionButtonGroup: false, | ||
78 | - baseColProps: {lg: 24, md: 24}, | ||
79 | - }); | ||
80 | - const [tenantAdminFormDrawer, {setDrawerProps, closeDrawer}] = useDrawerInner(async (data) => { | ||
81 | - await resetFields(); | ||
82 | - isUpdate.value = !!data?.isUpdate; | ||
83 | - tenantCode.value = data?.tenantCode; | ||
84 | - await updateSchema({field: 'title', componentProps: {disabled: false}}); | ||
85 | - if (unref(isUpdate)) { | ||
86 | - await setFieldsValue({ | ||
87 | - ...data.record, | ||
88 | - }); | ||
89 | - } | ||
90 | - }); | ||
91 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增租户管理员' : '编辑租户管理员')); | ||
92 | - | ||
93 | - async function handleSubmit() { | ||
94 | - try { | ||
95 | - const values = await validate(); | ||
96 | - const requestParams = { | ||
97 | - id: values.id, | ||
98 | - username: values.username, | ||
99 | - realName: values.realName, | ||
100 | - phoneNumber: values.phoneNumber, | ||
101 | - email: values.email, | ||
102 | - enabled: values.enabled, | ||
103 | - tenantExpireTime: (typeof values.tenantExpireTime != 'undefined' && values.tenantExpireTime != null) ? values.tenantExpireTime.format('YYYY-MM-DD HH:mm:ss') : null, | ||
104 | - tenantCode: tenantCode.value | 36 | + { |
37 | + field: 'username', | ||
38 | + label: '账号:', | ||
39 | + required: true, | ||
40 | + component: 'Input', | ||
41 | + }, | ||
42 | + { | ||
43 | + field: 'realName', | ||
44 | + label: '真实名字:', | ||
45 | + required: true, | ||
46 | + component: 'Input', | ||
47 | + }, | ||
48 | + { | ||
49 | + field: 'phoneNumber', | ||
50 | + label: '电话号码:', | ||
51 | + required: true, | ||
52 | + component: 'Input', | ||
53 | + }, | ||
54 | + { | ||
55 | + field: 'email', | ||
56 | + label: '邮件:', | ||
57 | + required: true, | ||
58 | + component: 'Input', | ||
59 | + }, | ||
60 | + { | ||
61 | + field: 'enabled', | ||
62 | + label: '状态', | ||
63 | + required: true, | ||
64 | + component: 'RadioButtonGroup', | ||
65 | + defaultValue: true, | ||
66 | + componentProps: { | ||
67 | + options: [ | ||
68 | + { label: '启用', value: true }, | ||
69 | + { label: '停用', value: false }, | ||
70 | + ], | ||
71 | + }, | ||
72 | + }, | ||
73 | + ]; | ||
74 | + const [tenantAdminForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({ | ||
75 | + labelWidth: 100, | ||
76 | + schemas: formSchema, | ||
77 | + showActionButtonGroup: false, | ||
78 | + baseColProps: { lg: 24, md: 24 }, | ||
79 | + }); | ||
80 | + const [tenantAdminFormDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner( | ||
81 | + async (data) => { | ||
82 | + await resetFields(); | ||
83 | + isUpdate.value = !!data?.isUpdate; | ||
84 | + tenantCode.value = data?.tenantCode; | ||
85 | + await updateSchema({ field: 'title', componentProps: { disabled: false } }); | ||
86 | + if (unref(isUpdate)) { | ||
87 | + await setFieldsValue({ | ||
88 | + ...data.record, | ||
89 | + }); | ||
90 | + } | ||
105 | } | 91 | } |
106 | - setDrawerProps({confirmLoading: true}); | ||
107 | - saveTenantAdmin(requestParams as any as UserDTO).then(() => { | ||
108 | - closeDrawer();//关闭侧框 | ||
109 | - emit('success'); | ||
110 | - }) | 92 | + ); |
93 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增租户管理员' : '编辑租户管理员')); | ||
111 | 94 | ||
112 | - } finally { | ||
113 | - setDrawerProps({confirmLoading: false}); | 95 | + async function handleSubmit() { |
96 | + try { | ||
97 | + const values = await validate(); | ||
98 | + const requestParams = { | ||
99 | + id: values.id, | ||
100 | + username: values.username, | ||
101 | + realName: values.realName, | ||
102 | + phoneNumber: values.phoneNumber, | ||
103 | + email: values.email, | ||
104 | + enabled: values.enabled, | ||
105 | + tenantExpireTime: | ||
106 | + typeof values.tenantExpireTime != 'undefined' && values.tenantExpireTime != null | ||
107 | + ? values.tenantExpireTime.format('YYYY-MM-DD HH:mm:ss') | ||
108 | + : null, | ||
109 | + tenantCode: tenantCode.value, | ||
110 | + }; | ||
111 | + setDrawerProps({ confirmLoading: true }); | ||
112 | + saveTenantAdmin(requestParams as any as UserDTO).then(() => { | ||
113 | + closeDrawer(); //关闭侧框 | ||
114 | + emit('success'); | ||
115 | + }); | ||
116 | + } finally { | ||
117 | + setDrawerProps({ confirmLoading: false }); | ||
118 | + } | ||
114 | } | 119 | } |
115 | 120 | ||
116 | - } | ||
117 | - | ||
118 | - return { | ||
119 | - tenantAdminFormDrawer, | ||
120 | - handleSubmit, | ||
121 | - tenantAdminForm, | ||
122 | - getTitle | ||
123 | - }; | ||
124 | - }, | ||
125 | -}); | 121 | + return { |
122 | + tenantAdminFormDrawer, | ||
123 | + handleSubmit, | ||
124 | + tenantAdminForm, | ||
125 | + getTitle, | ||
126 | + }; | ||
127 | + }, | ||
128 | + }); | ||
126 | </script> | 129 | </script> |
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | :customRequest="customUpload" | 17 | :customRequest="customUpload" |
18 | :before-upload="beforeUpload" | 18 | :before-upload="beforeUpload" |
19 | > | 19 | > |
20 | - <img v-if="tenantLogo" :src="tenantLogo" alt="avatar"/> | 20 | + <img v-if="tenantLogo" :src="tenantLogo" alt="avatar" /> |
21 | <div v-else> | 21 | <div v-else> |
22 | <loading-outlined v-if="loading"></loading-outlined> | 22 | <loading-outlined v-if="loading"></loading-outlined> |
23 | <plus-outlined v-else></plus-outlined> | 23 | <plus-outlined v-else></plus-outlined> |
@@ -29,130 +29,138 @@ | @@ -29,130 +29,138 @@ | ||
29 | </BasicDrawer> | 29 | </BasicDrawer> |
30 | </template> | 30 | </template> |
31 | <script lang="ts"> | 31 | <script lang="ts"> |
32 | -import {defineComponent, ref, computed, unref} from 'vue'; | ||
33 | -import {BasicForm, useForm} from '/@/components/Form/index'; | ||
34 | -import {BasicDrawer, useDrawerInner} from '/@/components/Drawer'; | ||
35 | -import {CollapseContainer} from '/@/components/Container'; | ||
36 | -import {CropperImage, CropperAvatar} from '/@/components/Cropper'; | ||
37 | -import {PlusOutlined, LoadingOutlined} from '@ant-design/icons-vue'; | ||
38 | -import {message, Upload} from 'ant-design-vue'; | 32 | + import { defineComponent, ref, computed, unref } from 'vue'; |
33 | + import { BasicForm, useForm } from '/@/components/Form/index'; | ||
34 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
35 | + import { CollapseContainer } from '/@/components/Container'; | ||
36 | + import { CropperImage, CropperAvatar } from '/@/components/Cropper'; | ||
37 | + import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | ||
38 | + import { message, Upload } from 'ant-design-vue'; | ||
39 | 39 | ||
40 | -import {useI18n} from "/@/hooks/web/useI18n"; | ||
41 | -import {tenantFormSchema} from "/@/views/tenant/management/tenantBaseColumns"; | ||
42 | -import {FileItem} from "/@/components/Upload/src/typing"; | ||
43 | -import {upload} from "/@/api/oss/ossFileUploader"; | ||
44 | -import {getTenantRoles, updateOrCreateTenant} from "/@/api/tenant/tenantApi"; | 40 | + import { useI18n } from '/@/hooks/web/useI18n'; |
41 | + import { tenantFormSchema } from '/@/views/tenant/management/tenantBaseColumns'; | ||
42 | + import { FileItem } from '/@/components/Upload/src/typing'; | ||
43 | + import { upload } from '/@/api/oss/ossFileUploader'; | ||
44 | + import { getTenantRoles, updateOrCreateTenant } from '/@/api/tenant/tenantApi'; | ||
45 | 45 | ||
46 | + export default defineComponent({ | ||
47 | + name: 'TenantDrawer', | ||
48 | + components: { | ||
49 | + BasicDrawer, | ||
50 | + BasicForm, | ||
51 | + CropperImage, | ||
52 | + CollapseContainer, | ||
53 | + CropperAvatar, | ||
54 | + Upload, | ||
55 | + PlusOutlined, | ||
56 | + LoadingOutlined, | ||
57 | + }, | ||
58 | + emits: ['success', 'register'], | ||
59 | + setup(_, { emit }) { | ||
60 | + const isUpdate = ref(true); | ||
61 | + const tenantLogo = ref(''); | ||
46 | 62 | ||
47 | -export default defineComponent({ | ||
48 | - name: 'TenantDrawer', | ||
49 | - components: { | ||
50 | - BasicDrawer, BasicForm, CropperImage, | ||
51 | - CollapseContainer, | ||
52 | - CropperAvatar, | ||
53 | - Upload, | ||
54 | - PlusOutlined, LoadingOutlined | ||
55 | - }, | ||
56 | - emits: ['success', 'register'], | ||
57 | - setup(_, {emit}) { | ||
58 | - const isUpdate = ref(true); | ||
59 | - const tenantLogo = ref(""); | ||
60 | - | ||
61 | - async function customUpload({file}) { | ||
62 | - if (beforeUpload(file)) { | ||
63 | - const formData = new FormData() | ||
64 | - formData.append('file', file) | ||
65 | - const response = await upload(formData); | ||
66 | - if (response.fileStaticUri) { | ||
67 | - tenantLogo.value = response.fileStaticUri; | 63 | + async function customUpload({ file }) { |
64 | + if (beforeUpload(file)) { | ||
65 | + const formData = new FormData(); | ||
66 | + formData.append('file', file); | ||
67 | + const response = await upload(formData); | ||
68 | + if (response.fileStaticUri) { | ||
69 | + tenantLogo.value = response.fileStaticUri; | ||
70 | + } | ||
68 | } | 71 | } |
69 | } | 72 | } |
70 | - } | ||
71 | 73 | ||
72 | - const beforeUpload = (file: FileItem) => { | ||
73 | - const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; | ||
74 | - if (!isJpgOrPng) { | ||
75 | - message.error('只能上传图片文件!'); | ||
76 | - } | ||
77 | - const isLt2M = file.size as number / 1024 / 1024 < 2; | ||
78 | - if (!isLt2M) { | ||
79 | - message.error('图片大小不能超过2MB!'); | ||
80 | - } | ||
81 | - return isJpgOrPng && isLt2M; | ||
82 | - }; | ||
83 | - const [tenantForm, {resetFields, setFieldsValue, updateSchema, validate}] = useForm({ | ||
84 | - labelWidth: 100, | ||
85 | - schemas: tenantFormSchema, | ||
86 | - showActionButtonGroup: false, | ||
87 | - baseColProps: {lg: 24, md: 24}, | ||
88 | - }); | ||
89 | - const {t} = useI18n(); //加载国际化 | 74 | + const beforeUpload = (file: FileItem) => { |
75 | + const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; | ||
76 | + if (!isJpgOrPng) { | ||
77 | + message.error('只能上传图片文件!'); | ||
78 | + } | ||
79 | + const isLt2M = (file.size as number) / 1024 / 1024 < 2; | ||
80 | + if (!isLt2M) { | ||
81 | + message.error('图片大小不能超过2MB!'); | ||
82 | + } | ||
83 | + return isJpgOrPng && isLt2M; | ||
84 | + }; | ||
85 | + const [tenantForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({ | ||
86 | + labelWidth: 100, | ||
87 | + schemas: tenantFormSchema, | ||
88 | + showActionButtonGroup: false, | ||
89 | + baseColProps: { lg: 24, md: 24 }, | ||
90 | + }); | ||
91 | + const { t } = useI18n(); //加载国际化 | ||
90 | 92 | ||
91 | - //默认传递页面数据 | ||
92 | - const [registerDrawer, {setDrawerProps, closeDrawer}] = useDrawerInner(async (data) => { | ||
93 | - await resetFields(); | ||
94 | - tenantLogo.value = ""; | ||
95 | - setDrawerProps({confirmLoading: false}); | ||
96 | - isUpdate.value = !!data?.isUpdate; | 93 | + //默认传递页面数据 |
94 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
95 | + await resetFields(); | ||
96 | + tenantLogo.value = ''; | ||
97 | + setDrawerProps({ confirmLoading: false }); | ||
98 | + isUpdate.value = !!data?.isUpdate; | ||
97 | 99 | ||
98 | - //初始化,菜单名称为可用 | ||
99 | - await updateSchema({field: 'title', componentProps: {disabled: false}}); | ||
100 | - //如果是编辑操作,设置页面数据 | ||
101 | - if (unref(isUpdate)) { | ||
102 | - getTenantRoles(data.record.tenantCode).then((result)=>{ | ||
103 | - Reflect.set(data.record,"roleIds",result); | ||
104 | - //为表单赋值 | ||
105 | - setFieldsValue({ | ||
106 | - ...data.record, | 100 | + //初始化,菜单名称为可用 |
101 | + await updateSchema({ field: 'title', componentProps: { disabled: false } }); | ||
102 | + //如果是编辑操作,设置页面数据 | ||
103 | + if (unref(isUpdate)) { | ||
104 | + getTenantRoles(data.record.tenantCode).then((result) => { | ||
105 | + Reflect.set(data.record, 'roleIds', result); | ||
106 | + //为表单赋值 | ||
107 | + setFieldsValue({ | ||
108 | + ...data.record, | ||
109 | + }); | ||
110 | + tenantLogo.value = data.record.icon; | ||
111 | + //编辑模式,菜单名称为不可用 | ||
112 | + updateSchema({ field: 'title', componentProps: { disabled: true } }); | ||
107 | }); | 113 | }); |
108 | - tenantLogo.value = data.record.icon; | ||
109 | - //编辑模式,菜单名称为不可用 | ||
110 | - updateSchema({field: 'title', componentProps: {disabled: true,}}); | ||
111 | - }); | ||
112 | - } | ||
113 | - }); | ||
114 | - //得到页面标题 | ||
115 | - const getTitle = computed(() => (!unref(isUpdate) ? t('routes.common.system.pageSystemTitleCreateTenant') : t('routes.common.system.pageSystemTitleEditTenant'))); | ||
116 | - | ||
117 | - //提交按钮 | ||
118 | - async function handleSubmit() { | ||
119 | - try { | ||
120 | - const values = await validate(); | ||
121 | - setDrawerProps({confirmLoading: true}); | ||
122 | - const req = { | ||
123 | - id: values.id, | ||
124 | - icon: tenantLogo.value, | ||
125 | - name: values.name, | ||
126 | - enabled: values.enabled, | ||
127 | - description: values.description, | ||
128 | - roleIds:values.roleIds, | ||
129 | - tenantExpireTime: (typeof values.tenantExpireTime != 'undefined' && values.tenantExpireTime != null) ? values.tenantExpireTime.format('YYYY-MM-DD HH:mm:ss') : null | ||
130 | - }; | ||
131 | - updateOrCreateTenant(req).then(() => { | ||
132 | - closeDrawer();//关闭侧框 | ||
133 | - emit('success'); | ||
134 | - }); | 114 | + } |
115 | + }); | ||
116 | + //得到页面标题 | ||
117 | + const getTitle = computed(() => | ||
118 | + !unref(isUpdate) | ||
119 | + ? t('routes.common.system.pageSystemTitleCreateTenant') | ||
120 | + : t('routes.common.system.pageSystemTitleEditTenant') | ||
121 | + ); | ||
135 | 122 | ||
136 | - } finally { | ||
137 | - setDrawerProps({confirmLoading: false}); | 123 | + //提交按钮 |
124 | + async function handleSubmit() { | ||
125 | + try { | ||
126 | + const values = await validate(); | ||
127 | + setDrawerProps({ confirmLoading: true }); | ||
128 | + const req = { | ||
129 | + id: values.id, | ||
130 | + icon: tenantLogo.value, | ||
131 | + name: values.name, | ||
132 | + enabled: values.enabled, | ||
133 | + description: values.description, | ||
134 | + roleIds: values.roleIds, | ||
135 | + tenantExpireTime: | ||
136 | + typeof values.tenantExpireTime != 'undefined' && values.tenantExpireTime != null | ||
137 | + ? values.tenantExpireTime.format('YYYY-MM-DD HH:mm:ss') | ||
138 | + : null, | ||
139 | + }; | ||
140 | + updateOrCreateTenant(req).then(() => { | ||
141 | + closeDrawer(); //关闭侧框 | ||
142 | + emit('success'); | ||
143 | + }); | ||
144 | + } finally { | ||
145 | + setDrawerProps({ confirmLoading: false }); | ||
146 | + } | ||
138 | } | 147 | } |
139 | - } | ||
140 | 148 | ||
141 | - return { | ||
142 | - registerDrawer, | ||
143 | - tenantForm, | ||
144 | - getTitle, | ||
145 | - handleSubmit, | ||
146 | - tenantLogo, | ||
147 | - beforeUpload, | ||
148 | - customUpload, | ||
149 | - }; | ||
150 | - }, | ||
151 | -}); | 149 | + return { |
150 | + registerDrawer, | ||
151 | + tenantForm, | ||
152 | + getTitle, | ||
153 | + handleSubmit, | ||
154 | + tenantLogo, | ||
155 | + beforeUpload, | ||
156 | + customUpload, | ||
157 | + }; | ||
158 | + }, | ||
159 | + }); | ||
152 | </script> | 160 | </script> |
153 | <style> | 161 | <style> |
154 | -.ant-upload-select-picture-card i { | ||
155 | - font-size: 32px; | ||
156 | - color: #999; | ||
157 | -} | 162 | + .ant-upload-select-picture-card i { |
163 | + font-size: 32px; | ||
164 | + color: #999; | ||
165 | + } | ||
158 | </style> | 166 | </style> |
1 | <template> | 1 | <template> |
2 | <div class="p-4"> | 2 | <div class="p-4"> |
3 | - <BasicTable | ||
4 | - @register="tenantTable" | ||
5 | - > | 3 | + <BasicTable @register="tenantTable"> |
6 | <template #toolbar> | 4 | <template #toolbar> |
7 | <a-button type="primary" @click="handleCreate"> 新增租户</a-button> | 5 | <a-button type="primary" @click="handleCreate"> 新增租户</a-button> |
8 | </template> | 6 | </template> |
9 | <template #img="{ record }"> | 7 | <template #img="{ record }"> |
10 | - <TableImg :size="30" :showBadge="false" :simpleShow="true" | ||
11 | - :imgList="(typeof record.icon!=='undefined'&& record.icon!=='' && record.icon!=null)?[record.icon]:null"/> | 8 | + <TableImg |
9 | + :size="30" | ||
10 | + :showBadge="false" | ||
11 | + :simpleShow="true" | ||
12 | + :imgList=" | ||
13 | + typeof record.icon !== 'undefined' && record.icon !== '' && record.icon != null | ||
14 | + ? [record.icon] | ||
15 | + : null | ||
16 | + " | ||
17 | + /> | ||
12 | </template> | 18 | </template> |
13 | <template #status="{ record }"> | 19 | <template #status="{ record }"> |
14 | <Tag | 20 | <Tag |
15 | - :color="record.tenantStatus==='NORMAL'?'green':(record.tenantStatus==='DISABLED'?'red':'orange')"> | 21 | + :color=" |
22 | + record.tenantStatus === 'NORMAL' | ||
23 | + ? 'green' | ||
24 | + : record.tenantStatus === 'DISABLED' | ||
25 | + ? 'red' | ||
26 | + : 'orange' | ||
27 | + " | ||
28 | + > | ||
16 | {{ | 29 | {{ |
17 | - record.tenantStatus === 'NORMAL' ? '正常' : (record.tenantStatus === 'DISABLED' ? '已禁用' : '已过期') | 30 | + record.tenantStatus === 'NORMAL' |
31 | + ? '正常' | ||
32 | + : record.tenantStatus === 'DISABLED' | ||
33 | + ? '已禁用' | ||
34 | + : '已过期' | ||
18 | }} | 35 | }} |
19 | </Tag> | 36 | </Tag> |
20 | </template> | 37 | </template> |
21 | <template #action="{ record }"> | 38 | <template #action="{ record }"> |
22 | <TableAction | 39 | <TableAction |
23 | - :actions=" | ||
24 | -[ | ||
25 | - { | 40 | + :actions="[ |
41 | + { | ||
26 | icon: 'ant-design:usergroup-add-outlined', | 42 | icon: 'ant-design:usergroup-add-outlined', |
27 | - label:'租户管理员', | 43 | + label: '租户管理员', |
28 | onClick: handleTenantAdminDrawer.bind(null, record), | 44 | onClick: handleTenantAdminDrawer.bind(null, record), |
29 | }, | 45 | }, |
30 | { | 46 | { |
31 | icon: 'clarity:note-edit-line', | 47 | icon: 'clarity:note-edit-line', |
32 | - label:'编辑', | 48 | + label: '编辑', |
33 | onClick: handleEdit.bind(null, record), | 49 | onClick: handleEdit.bind(null, record), |
34 | }, | 50 | }, |
35 | { | 51 | { |
36 | icon: 'ant-design:delete-outlined', | 52 | icon: 'ant-design:delete-outlined', |
37 | - label:'删除', | 53 | + label: '删除', |
38 | color: 'error', | 54 | color: 'error', |
39 | popConfirm: { | 55 | popConfirm: { |
40 | title: '是否确认删除', | 56 | title: '是否确认删除', |
@@ -45,99 +61,98 @@ | @@ -45,99 +61,98 @@ | ||
45 | /> | 61 | /> |
46 | </template> | 62 | </template> |
47 | </BasicTable> | 63 | </BasicTable> |
48 | - <TenantDrawer @register="tenantDrawer" @success="handleSuccess"/> | ||
49 | - <TenantAdminDrawer @register="tenantAdminDrawer"/> | 64 | + <TenantDrawer @register="tenantDrawer" @success="handleSuccess" /> |
65 | + <TenantAdminDrawer @register="tenantAdminDrawer" /> | ||
50 | </div> | 66 | </div> |
51 | </template> | 67 | </template> |
52 | <script lang="ts"> | 68 | <script lang="ts"> |
53 | -import {defineComponent} from 'vue'; | ||
54 | -import {BasicTable, TableImg, TableAction, useTable, FormSchema} from '/@/components/Table'; | ||
55 | -import {Avatar, Tag} from 'ant-design-vue'; | ||
56 | -import {getBasicColumns} from './tenantBaseColumns'; | ||
57 | -import {deleteTenant, getTenantPage} from '/@/api/tenant/tenantApi'; | ||
58 | -import {useDrawer} from "/@/components/Drawer"; | ||
59 | -import TenantDrawer from "./TenantDrawer.vue" | ||
60 | -import TenantAdminDrawer from "./TenantAdminDrawer.vue" | ||
61 | -export default defineComponent({ | ||
62 | - components: {BasicTable, Avatar, TableImg, Tag, TableAction, TenantDrawer, TenantAdminDrawer}, | ||
63 | - setup() { | ||
64 | - const [tenantDrawer, {openDrawer: openDrawer}] = useDrawer(); | ||
65 | - const [tenantAdminDrawer, {openDrawer: openTenantAdminDrawer}] = useDrawer(); | ||
66 | - | ||
67 | - function handleDelete(record: Recordable) { | ||
68 | - deleteTenant([record.id]).then(() => { | ||
69 | - reload(); | ||
70 | - }); | ||
71 | - } | 69 | + import { defineComponent } from 'vue'; |
70 | + import { BasicTable, TableImg, TableAction, useTable, FormSchema } from '/@/components/Table'; | ||
71 | + import { Avatar, Tag } from 'ant-design-vue'; | ||
72 | + import { getBasicColumns } from './tenantBaseColumns'; | ||
73 | + import { deleteTenant, getTenantPage } from '/@/api/tenant/tenantApi'; | ||
74 | + import { useDrawer } from '/@/components/Drawer'; | ||
75 | + import TenantDrawer from './TenantDrawer.vue'; | ||
76 | + import TenantAdminDrawer from './TenantAdminDrawer.vue'; | ||
77 | + export default defineComponent({ | ||
78 | + components: { BasicTable, Avatar, TableImg, Tag, TableAction, TenantDrawer, TenantAdminDrawer }, | ||
79 | + setup() { | ||
80 | + const [tenantDrawer, { openDrawer: openDrawer }] = useDrawer(); | ||
81 | + const [tenantAdminDrawer, { openDrawer: openTenantAdminDrawer }] = useDrawer(); | ||
72 | 82 | ||
73 | - function handleCreate() { | ||
74 | - openDrawer(true, { | ||
75 | - isUpdate: false, | ||
76 | - }); | ||
77 | - } | 83 | + function handleDelete(record: Recordable) { |
84 | + deleteTenant([record.id]).then(() => { | ||
85 | + reload(); | ||
86 | + }); | ||
87 | + } | ||
78 | 88 | ||
79 | - function handleEdit(record: Recordable) { | ||
80 | - openDrawer(true, { | ||
81 | - record, | ||
82 | - isUpdate: true, | ||
83 | - }); | ||
84 | - } | 89 | + function handleCreate() { |
90 | + openDrawer(true, { | ||
91 | + isUpdate: false, | ||
92 | + }); | ||
93 | + } | ||
85 | 94 | ||
86 | - function handleTenantAdminDrawer(record: Recordable) { | ||
87 | - openTenantAdminDrawer(true, { | ||
88 | - record | ||
89 | - }); | 95 | + function handleEdit(record: Recordable) { |
96 | + openDrawer(true, { | ||
97 | + record, | ||
98 | + isUpdate: true, | ||
99 | + }); | ||
100 | + } | ||
90 | 101 | ||
91 | - } | 102 | + function handleTenantAdminDrawer(record: Recordable) { |
103 | + openTenantAdminDrawer(true, { | ||
104 | + record, | ||
105 | + }); | ||
106 | + } | ||
92 | 107 | ||
93 | - const searchFiled: FormSchema[] = [ | ||
94 | - { | ||
95 | - field: 'tenantName', | ||
96 | - label: '租户名称', | ||
97 | - component: 'Input', | ||
98 | - colProps: {span: 8}, | ||
99 | - }, | ||
100 | - ]; | 108 | + const searchFiled: FormSchema[] = [ |
109 | + { | ||
110 | + field: 'tenantName', | ||
111 | + label: '租户名称', | ||
112 | + component: 'Input', | ||
113 | + colProps: { span: 8 }, | ||
114 | + }, | ||
115 | + ]; | ||
101 | 116 | ||
102 | - function handleSuccess() { | ||
103 | - reload(); | ||
104 | - } | 117 | + function handleSuccess() { |
118 | + reload(); | ||
119 | + } | ||
105 | 120 | ||
106 | - const [tenantTable, {reload}] = useTable({ | ||
107 | - title: '租户', | ||
108 | - api: getTenantPage, | ||
109 | - columns: getBasicColumns(), | ||
110 | - useSearchForm: true, | ||
111 | - showTableSetting: true, | ||
112 | - bordered: true, | ||
113 | - showIndexColumn: false, | ||
114 | - tableSetting: { | ||
115 | - redo: true, | ||
116 | - size: false, | ||
117 | - setting: false | ||
118 | - }, | ||
119 | - formConfig: { | ||
120 | - labelWidth: 120, | ||
121 | - schemas: searchFiled, | ||
122 | - }, | ||
123 | - actionColumn: { | ||
124 | - width: 150, | ||
125 | - title: '操作', | ||
126 | - dataIndex: 'action', | ||
127 | - slots: {customRender: 'action'}, | ||
128 | - fixed: undefined, | ||
129 | - }, | ||
130 | - }); | ||
131 | - return { | ||
132 | - tenantTable, | ||
133 | - handleEdit, | ||
134 | - handleDelete, | ||
135 | - handleCreate, | ||
136 | - tenantDrawer, | ||
137 | - tenantAdminDrawer, | ||
138 | - handleSuccess, | ||
139 | - handleTenantAdminDrawer, | ||
140 | - }; | ||
141 | - }, | ||
142 | -}); | 121 | + const [tenantTable, { reload }] = useTable({ |
122 | + title: '租户', | ||
123 | + api: getTenantPage, | ||
124 | + columns: getBasicColumns(), | ||
125 | + useSearchForm: true, | ||
126 | + showTableSetting: true, | ||
127 | + bordered: true, | ||
128 | + showIndexColumn: false, | ||
129 | + tableSetting: { | ||
130 | + redo: true, | ||
131 | + size: false, | ||
132 | + setting: false, | ||
133 | + }, | ||
134 | + formConfig: { | ||
135 | + labelWidth: 120, | ||
136 | + schemas: searchFiled, | ||
137 | + }, | ||
138 | + actionColumn: { | ||
139 | + width: 150, | ||
140 | + title: '操作', | ||
141 | + dataIndex: 'action', | ||
142 | + slots: { customRender: 'action' }, | ||
143 | + fixed: undefined, | ||
144 | + }, | ||
145 | + }); | ||
146 | + return { | ||
147 | + tenantTable, | ||
148 | + handleEdit, | ||
149 | + handleDelete, | ||
150 | + handleCreate, | ||
151 | + tenantDrawer, | ||
152 | + tenantAdminDrawer, | ||
153 | + handleSuccess, | ||
154 | + handleTenantAdminDrawer, | ||
155 | + }; | ||
156 | + }, | ||
157 | + }); | ||
143 | </script> | 158 | </script> |
@@ -23,113 +23,113 @@ | @@ -23,113 +23,113 @@ | ||
23 | </BasicDrawer> | 23 | </BasicDrawer> |
24 | </template> | 24 | </template> |
25 | <script lang="ts"> | 25 | <script lang="ts"> |
26 | -import {defineComponent, ref, computed, unref} from 'vue'; | ||
27 | -import {BasicForm, useForm} from '/@/components/Form/index'; | ||
28 | -import {formSchema} from './role.data'; | ||
29 | -import {BasicDrawer, useDrawerInner} from '/@/components/Drawer'; | ||
30 | -import {BasicTree, TreeItem} from '/@/components/Tree'; | 26 | + import { defineComponent, ref, computed, unref } from 'vue'; |
27 | + import { BasicForm, useForm } from '/@/components/Form/index'; | ||
28 | + import { formSchema } from './role.data'; | ||
29 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
30 | + import { BasicTree, TreeItem } from '/@/components/Tree'; | ||
31 | 31 | ||
32 | -const {t} = useI18n(); //加载国际化 | 32 | + const { t } = useI18n(); //加载国际化 |
33 | 33 | ||
34 | -// import { getMenuList } from '/@/api/demo/system'; | 34 | + // import { getMenuList } from '/@/api/demo/system'; |
35 | 35 | ||
36 | -// 加载菜单数据 | ||
37 | -import {getMenuList, getMenusIdsByRoleId} from '/@/api/sys/menu'; | ||
38 | -import {useI18n} from "/@/hooks/web/useI18n"; | ||
39 | -import {RouteItem} from "/@/api/sys/model/menuModel"; | ||
40 | -import {saveOrUpdateRoleInfoWithMenu} from "/@/api/system/system"; | ||
41 | -import {RoleEnum} from "/@/enums/roleEnum"; | ||
42 | -export default defineComponent({ | ||
43 | - name: 'RoleDrawer', | ||
44 | - components: {BasicDrawer, BasicForm, BasicTree}, | ||
45 | - emits: ['success', 'register'], | ||
46 | - setup(_, {emit}) { | ||
47 | - const isUpdate = ref(true); | ||
48 | - const treeData = ref<TreeItem[]>([]); | ||
49 | - const roleMenus = ref<string[]>([]); | ||
50 | - const roleId = ref(""); | 36 | + // 加载菜单数据 |
37 | + import { getMenuList, getMenusIdsByRoleId } from '/@/api/sys/menu'; | ||
38 | + import { useI18n } from '/@/hooks/web/useI18n'; | ||
39 | + import { RouteItem } from '/@/api/sys/model/menuModel'; | ||
40 | + import { saveOrUpdateRoleInfoWithMenu } from '/@/api/system/system'; | ||
41 | + import { RoleEnum } from '/@/enums/roleEnum'; | ||
42 | + export default defineComponent({ | ||
43 | + name: 'RoleDrawer', | ||
44 | + components: { BasicDrawer, BasicForm, BasicTree }, | ||
45 | + emits: ['success', 'register'], | ||
46 | + setup(_, { emit }) { | ||
47 | + const isUpdate = ref(true); | ||
48 | + const treeData = ref<TreeItem[]>([]); | ||
49 | + const roleMenus = ref<string[]>([]); | ||
50 | + const roleId = ref(''); | ||
51 | 51 | ||
52 | - const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ | ||
53 | - labelWidth: 90, | ||
54 | - schemas: formSchema, | ||
55 | - showActionButtonGroup: false, | ||
56 | - }); | ||
57 | - | ||
58 | - function processChildren(items: RouteItem[]) { | ||
59 | - items.map((item) => { | ||
60 | - item.menuName = t(item.meta.title); | ||
61 | - item.icon = item.meta.icon; | ||
62 | - item.key=item.id; | ||
63 | - if (item.children) { | ||
64 | - processChildren(item.children); | ||
65 | - } | 52 | + const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
53 | + labelWidth: 90, | ||
54 | + schemas: formSchema, | ||
55 | + showActionButtonGroup: false, | ||
66 | }); | 56 | }); |
67 | - } | ||
68 | 57 | ||
69 | - const [registerDrawer, {setDrawerProps, closeDrawer}] = useDrawerInner(async (data) => { | ||
70 | - resetFields(); | ||
71 | - roleId.value = ""; | ||
72 | - setDrawerProps({confirmLoading: false}); | ||
73 | - // 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告 | ||
74 | - if (unref(treeData).length === 0) { | ||
75 | - const menuListModel = await getMenuList(); | ||
76 | - processChildren(menuListModel); | ||
77 | - let treeValues = new Array<TreeItem>(); | ||
78 | - menuListModel.map((item) => { | ||
79 | - const data = { | ||
80 | - menuName: t(item.meta.title), | ||
81 | - icon: item.meta.icon, | ||
82 | - key: item.id, | ||
83 | - children: item.children as any as TreeItem[], | 58 | + function processChildren(items: RouteItem[]) { |
59 | + items.map((item) => { | ||
60 | + item.menuName = t(item.meta.title); | ||
61 | + item.icon = item.meta.icon; | ||
62 | + item.key = item.id; | ||
63 | + if (item.children) { | ||
64 | + processChildren(item.children); | ||
84 | } | 65 | } |
85 | - treeValues.push(data); | ||
86 | - }) | ||
87 | - treeData.value = treeValues; | ||
88 | - } | ||
89 | - if (data.record) { | ||
90 | - roleMenus.value = await getMenusIdsByRoleId(data.record.id); | ||
91 | - roleId.value = data.record.id; | ||
92 | - } | ||
93 | - isUpdate.value = !!data?.isUpdate; | ||
94 | - if (unref(isUpdate)) { | ||
95 | - setFieldsValue({ | ||
96 | - ...data.record, | ||
97 | }); | 66 | }); |
98 | } | 67 | } |
99 | - }); | ||
100 | 68 | ||
101 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); | 69 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
70 | + resetFields(); | ||
71 | + roleId.value = ''; | ||
72 | + setDrawerProps({ confirmLoading: false }); | ||
73 | + // 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告 | ||
74 | + if (unref(treeData).length === 0) { | ||
75 | + const menuListModel = await getMenuList(); | ||
76 | + processChildren(menuListModel); | ||
77 | + let treeValues = new Array<TreeItem>(); | ||
78 | + menuListModel.map((item) => { | ||
79 | + const data = { | ||
80 | + menuName: t(item.meta.title), | ||
81 | + icon: item.meta.icon, | ||
82 | + key: item.id, | ||
83 | + children: item.children as any as TreeItem[], | ||
84 | + }; | ||
85 | + treeValues.push(data); | ||
86 | + }); | ||
87 | + treeData.value = treeValues; | ||
88 | + } | ||
89 | + if (data.record) { | ||
90 | + roleMenus.value = await getMenusIdsByRoleId(data.record.id); | ||
91 | + roleId.value = data.record.id; | ||
92 | + } | ||
93 | + isUpdate.value = !!data?.isUpdate; | ||
94 | + if (unref(isUpdate)) { | ||
95 | + setFieldsValue({ | ||
96 | + ...data.record, | ||
97 | + }); | ||
98 | + } | ||
99 | + }); | ||
100 | + | ||
101 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); | ||
102 | 102 | ||
103 | - async function handleSubmit() { | ||
104 | - try { | ||
105 | - const values = await validate(); | ||
106 | - setDrawerProps({confirmLoading: true}); | ||
107 | - const req = { | ||
108 | - id: roleId.value, | ||
109 | - name: values.name, | ||
110 | - remark: values.remark, | ||
111 | - status: values.status, | ||
112 | - roleType: RoleEnum.ROLE_TENANT_ADMIN, | ||
113 | - menu: [...values.menu] | 103 | + async function handleSubmit() { |
104 | + try { | ||
105 | + const values = await validate(); | ||
106 | + setDrawerProps({ confirmLoading: true }); | ||
107 | + const req = { | ||
108 | + id: roleId.value, | ||
109 | + name: values.name, | ||
110 | + remark: values.remark, | ||
111 | + status: values.status, | ||
112 | + roleType: RoleEnum.ROLE_TENANT_ADMIN, | ||
113 | + menu: [...values.menu], | ||
114 | + }; | ||
115 | + console.log(req, '请求参数'); | ||
116 | + saveOrUpdateRoleInfoWithMenu(req).then(() => { | ||
117 | + closeDrawer(); | ||
118 | + emit('success'); | ||
119 | + }); | ||
120 | + } finally { | ||
121 | + setDrawerProps({ confirmLoading: false }); | ||
114 | } | 122 | } |
115 | - console.log(req,"请求参数") | ||
116 | - saveOrUpdateRoleInfoWithMenu(req).then(()=>{ | ||
117 | - closeDrawer(); | ||
118 | - emit('success'); | ||
119 | - }) | ||
120 | - } finally { | ||
121 | - setDrawerProps({confirmLoading: false}); | ||
122 | } | 123 | } |
123 | - } | ||
124 | 124 | ||
125 | - return { | ||
126 | - registerDrawer, | ||
127 | - registerForm, | ||
128 | - getTitle, | ||
129 | - handleSubmit, | ||
130 | - treeData, | ||
131 | - roleMenus, | ||
132 | - }; | ||
133 | - }, | ||
134 | -}); | 125 | + return { |
126 | + registerDrawer, | ||
127 | + registerForm, | ||
128 | + getTitle, | ||
129 | + handleSubmit, | ||
130 | + treeData, | ||
131 | + roleMenus, | ||
132 | + }; | ||
133 | + }, | ||
134 | + }); | ||
135 | </script> | 135 | </script> |
@@ -8,12 +8,12 @@ | @@ -8,12 +8,12 @@ | ||
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: { |
@@ -32,12 +32,12 @@ | @@ -32,12 +32,12 @@ | ||
32 | import { defineComponent } from 'vue'; | 32 | import { defineComponent } from 'vue'; |
33 | 33 | ||
34 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 34 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
35 | - import {delRole, getRoleListByPage} from '/@/api/system/system'; | 35 | + import { delRole, getRoleListByPage } from '/@/api/system/system'; |
36 | 36 | ||
37 | import { useDrawer } from '/@/components/Drawer'; | 37 | import { useDrawer } from '/@/components/Drawer'; |
38 | import RoleDrawer from './RoleDrawer.vue'; | 38 | import RoleDrawer from './RoleDrawer.vue'; |
39 | import { columns, searchFormSchema } from './role.data'; | 39 | import { columns, searchFormSchema } from './role.data'; |
40 | - import {RoleEnum} from "/@/enums/roleEnum"; | 40 | + import { RoleEnum } from '/@/enums/roleEnum'; |
41 | 41 | ||
42 | export default defineComponent({ | 42 | export default defineComponent({ |
43 | name: 'TenantRoleManagement', | 43 | name: 'TenantRoleManagement', |
@@ -48,10 +48,10 @@ | @@ -48,10 +48,10 @@ | ||
48 | title: '租户角色列表', | 48 | title: '租户角色列表', |
49 | api: getRoleListByPage, | 49 | api: getRoleListByPage, |
50 | columns, | 50 | columns, |
51 | - tableSetting:{ | ||
52 | - redo:true, | ||
53 | - size:false, | ||
54 | - setting:false | 51 | + tableSetting: { |
52 | + redo: true, | ||
53 | + size: false, | ||
54 | + setting: false, | ||
55 | }, | 55 | }, |
56 | formConfig: { | 56 | formConfig: { |
57 | labelWidth: 120, | 57 | labelWidth: 120, |
@@ -84,11 +84,10 @@ | @@ -84,11 +84,10 @@ | ||
84 | } | 84 | } |
85 | 85 | ||
86 | async function handleDelete(record: Recordable) { | 86 | async function handleDelete(record: Recordable) { |
87 | - const roleIds = [record.id] | ||
88 | - delRole(roleIds).then(()=>{ | 87 | + const roleIds = [record.id]; |
88 | + delRole(roleIds).then(() => { | ||
89 | reload(); | 89 | reload(); |
90 | - }) | ||
91 | - | 90 | + }); |
92 | } | 91 | } |
93 | function handleSuccess() { | 92 | function handleSuccess() { |
94 | reload(); | 93 | reload(); |
@@ -101,7 +100,7 @@ | @@ -101,7 +100,7 @@ | ||
101 | handleEdit, | 100 | handleEdit, |
102 | handleDelete, | 101 | handleDelete, |
103 | handleSuccess, | 102 | handleSuccess, |
104 | - RoleEnum | 103 | + RoleEnum, |
105 | }; | 104 | }; |
106 | }, | 105 | }, |
107 | }); | 106 | }); |