Commit 46bfbef2b829f08fc6a0cc0d690e021c4e311d51
Merge branch 'sqy_dev' into 'main'
Sqy dev远程分支与main合并 See merge request huang/yun-teng-iot-front!2
Showing
127 changed files
with
4464 additions
and
3435 deletions
... | ... | @@ -6,7 +6,7 @@ VITE_PUBLIC_PATH = / |
6 | 6 | |
7 | 7 | # Cross-domain proxy, you can configure multiple |
8 | 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.120:8082/api"],["/upload","http://192.168.10.120:3300/upload"]] | |
10 | 10 | # VITE_PROXY=[["/api","https://vvbin.cn/test"]] |
11 | 11 | |
12 | 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; | ... | ... |
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | "clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite", |
22 | 22 | "clean:lib": "rimraf node_modules", |
23 | 23 | "lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix", |
24 | - "lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", | |
24 | + "lint:prettier": "prettier --write \"src/**/*.{js,json,ts,tsx,css,less,scss,vue,html,md}\"", | |
25 | 25 | "lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", |
26 | 26 | "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js", |
27 | 27 | "lint:pretty": "pretty-quick --staged", |
... | ... | @@ -59,6 +59,7 @@ |
59 | 59 | "tinymce": "^5.8.2", |
60 | 60 | "vditor": "^3.8.6", |
61 | 61 | "vue": "3.2.2", |
62 | + "vue-baidu-map": "^0.21.22", | |
62 | 63 | "vue-i18n": "9.1.7", |
63 | 64 | "vue-json-pretty": "^2.0.4", |
64 | 65 | "vue-router": "^4.0.11", | ... | ... |
src/api/alarm/contact/alarmContact.ts
0 → 100644
1 | +import { defHttp } from '/@/utils/http/axios'; | |
2 | +import type { | |
3 | + ContactPageParams, | |
4 | + ContactModal, | |
5 | + ContactParams, | |
6 | + ContactInfo, | |
7 | +} from './model/alarmContactModal'; | |
8 | +import { getPageData } from '../../base'; | |
9 | +enum Api { | |
10 | + alarmContact = '/alarmContact', | |
11 | + updateAlarmContact = '/alarmContact/update', | |
12 | +} | |
13 | + | |
14 | +// 获取 | |
15 | +export const getAlarmContact = (params: ContactPageParams) => { | |
16 | + return getPageData<ContactModal>(params, Api.alarmContact); | |
17 | +}; | |
18 | + | |
19 | +// 新增 | |
20 | +export const addAlarmContact = (params: ContactParams) => { | |
21 | + return defHttp.post({ | |
22 | + url: Api.alarmContact, | |
23 | + data: params, | |
24 | + }); | |
25 | +}; | |
26 | + | |
27 | +// 更新 | |
28 | +export const updateAlarmContact = (params: ContactParams) => { | |
29 | + return defHttp.post({ | |
30 | + url: Api.updateAlarmContact, | |
31 | + data: params, | |
32 | + }); | |
33 | +}; | |
34 | + | |
35 | +// 删除 | |
36 | +export const deleteAlarmContact = (ids: string[]) => { | |
37 | + return defHttp.delete({ | |
38 | + url: Api.alarmContact, | |
39 | + data: ids, | |
40 | + }); | |
41 | +}; | |
42 | + | |
43 | +// 新增或者编辑 | |
44 | +export const saveOrEditAlarmContact = (params: ContactInfo, isUpdate: boolean) => { | |
45 | + if (isUpdate) return updateAlarmContact(params); | |
46 | + addAlarmContact(params); | |
47 | +}; | ... | ... |
1 | +import { BasicPageParams } from '/@/api/model/baseModel'; | |
2 | + | |
3 | +interface ContactItemsModal { | |
4 | + id: string; | |
5 | + createTime: string; | |
6 | + enabled: boolean; | |
7 | + username: string; | |
8 | + department: string; | |
9 | + phone: string; | |
10 | +} | |
11 | +export type ContactPageParams = BasicPageParams & { username: string; organizationId: string }; | |
12 | + | |
13 | +export interface ContactModal { | |
14 | + items: ContactItemsModal[]; | |
15 | + total: number; | |
16 | +} | |
17 | + | |
18 | +export interface ContactParams { | |
19 | + phone: string; | |
20 | + username: string; | |
21 | + department?: string; | |
22 | + email?: string; | |
23 | + wechat?: string; | |
24 | + addPeople?: string; | |
25 | + remark?: string; | |
26 | +} | |
27 | + | |
28 | +export type ContactInfo = ContactParams; | ... | ... |
1 | -import {defHttp} from '/@/utils/http/axios'; | |
1 | +import { defHttp } from '/@/utils/http/axios'; | |
2 | 2 | |
3 | 3 | export interface PageData<T> { |
4 | 4 | total: number; |
... | ... | @@ -14,7 +14,7 @@ export interface BaseQueryParams { |
14 | 14 | pageSize: number; |
15 | 15 | page: number; |
16 | 16 | orderFiled?: string; |
17 | - orderType?: OrderType | |
17 | + orderType?: OrderType; | |
18 | 18 | } |
19 | 19 | |
20 | 20 | export class BaseQueryRequest implements BaseQueryParams { |
... | ... | @@ -23,7 +23,7 @@ export class BaseQueryRequest implements BaseQueryParams { |
23 | 23 | page: number; |
24 | 24 | pageSize: number; |
25 | 25 | |
26 | - constructor(page: number = 1, pageSize: number = 10) { | |
26 | + constructor(page = 1, pageSize = 10) { | |
27 | 27 | this.page = page; |
28 | 28 | this.pageSize = pageSize; |
29 | 29 | } |
... | ... | @@ -41,16 +41,13 @@ export class BaseQueryRequest implements BaseQueryParams { |
41 | 41 | } |
42 | 42 | |
43 | 43 | setPageSize(pageSize: number) { |
44 | - this.pageSize = pageSize | |
44 | + this.pageSize = pageSize; | |
45 | 45 | } |
46 | - | |
47 | 46 | } |
48 | 47 | |
49 | 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 | 2 | import { |
3 | 3 | DeviceModel, |
4 | 4 | DeviceProfileModel, |
5 | 5 | DeviceProfileQueryParam, |
6 | - DeviceQueryParam | |
7 | -} from "/@/api/device/model/deviceModel"; | |
6 | + DeviceQueryParam, | |
7 | +} from '/@/api/device/model/deviceModel'; | |
8 | 8 | |
9 | 9 | enum DeviceManagerApi { |
10 | 10 | /** |
11 | 11 | * 设备URL |
12 | 12 | */ |
13 | - DEVICE_URL = "/device", | |
13 | + DEVICE_URL = '/device', | |
14 | 14 | /** |
15 | 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 | 21 | return defHttp.get<DeviceModel>({ |
22 | 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 | 31 | export const deviceProfilePage = (params: DeviceProfileQueryParam) => { |
32 | 32 | return defHttp.get<DeviceProfileModel>({ |
33 | 33 | url: DeviceManagerApi.DEVICE_PROFILE_URL, |
34 | - params | |
34 | + params, | |
35 | 35 | }); |
36 | -} | |
36 | +}; | |
37 | 37 | /** |
38 | 38 | * 删除设备配置 |
39 | 39 | * @param ids 删除的ids |
... | ... | @@ -41,11 +41,11 @@ export const deviceProfilePage = (params: DeviceProfileQueryParam) => { |
41 | 41 | export const deleteDeviceProfile = (ids: string[]) => { |
42 | 42 | return defHttp.delete({ |
43 | 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 | 54 | export const deleteDevice = (ids: string[]) => { |
55 | 55 | return defHttp.delete({ |
56 | 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 | 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 | 14 | export type DeviceParam = { |
15 | - name?:string, | |
16 | - deviceProfileId?:string | |
17 | -} | |
15 | + name?: string; | |
16 | + deviceProfileId?: string; | |
17 | +}; | |
18 | 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 | 1 | import { defHttp } from '/@/utils/http/axios'; |
2 | 2 | import { |
3 | 3 | MessageConfig, |
4 | - MessageConfigParams, MessageConfigResult, | |
4 | + MessageConfigParams, | |
5 | + MessageConfigResult, | |
5 | 6 | MessageConfigResultModel, |
6 | - MessageParams | |
7 | + MessageParams, | |
7 | 8 | } from './model/configModel'; |
8 | 9 | |
9 | - | |
10 | 10 | enum MessageConfigApi { |
11 | 11 | CONFIG_URL = '/message', |
12 | 12 | } |
... | ... | @@ -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 | 19 | return defHttp.post<MessageConfigResult>({ |
20 | - url: MessageConfigApi.CONFIG_URL + "/find", | |
20 | + url: MessageConfigApi.CONFIG_URL + '/find', | |
21 | 21 | params, |
22 | - }) | |
23 | -} | |
22 | + }); | |
23 | +}; | |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @description: 获取MessageConfig分页数据 |
... | ... | @@ -41,14 +41,14 @@ export const saveOrEditMessageConfig = (params: MessageConfig, isUpdate: boolean |
41 | 41 | return defHttp.put<MessageConfigResultModel>({ |
42 | 42 | url: MessageConfigApi.CONFIG_URL, |
43 | 43 | params, |
44 | - }) | |
44 | + }); | |
45 | 45 | } else { |
46 | 46 | return defHttp.post<MessageConfigResultModel>({ |
47 | 47 | url: MessageConfigApi.CONFIG_URL, |
48 | 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 | 56 | * @param messageType 消息类型 |
57 | 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 | 60 | defHttp.put<MessageConfigResultModel>({ |
61 | 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 | 69 | * 删除MessageConfig |
70 | 70 | * @param ids 删除id数组 |
... | ... | @@ -73,6 +73,6 @@ export const deleteMessageConfig = (ids: string[]) => |
73 | 73 | defHttp.delete({ |
74 | 74 | url: MessageConfigApi.CONFIG_URL, |
75 | 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 | 3 | * @description: Request list interface parameters |
7 | 4 | */ |
8 | 5 | export type MessageConfigParams = BasicPageParams & MessageParams; |
9 | 6 | |
10 | 7 | export type MessageParams = { |
11 | - status?:number; | |
12 | - messageType?:string; | |
13 | -} | |
8 | + status?: number; | |
9 | + messageType?: string; | |
10 | +}; | |
14 | 11 | |
15 | 12 | export interface MessageConfig { |
16 | 13 | id: string; |
17 | - configName:string; | |
14 | + configName: string; | |
18 | 15 | messageType: string; |
19 | 16 | platformType: string; |
20 | 17 | config: ConfigParams; |
... | ... | @@ -22,13 +19,13 @@ export interface MessageConfig { |
22 | 19 | updateTime: string; |
23 | 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 | 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 | 4 | * @description: Request list interface parameters |
... | ... | @@ -15,23 +12,23 @@ export interface MessageTemplate { |
15 | 12 | } |
16 | 13 | |
17 | 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 | 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 | 30 | export interface MessageResult { |
34 | - result:boolean | |
31 | + result: boolean; | |
35 | 32 | } |
36 | 33 | |
37 | 34 | /** | ... | ... |
1 | -import {defHttp} from '/@/utils/http/axios'; | |
1 | +import { defHttp } from '/@/utils/http/axios'; | |
2 | 2 | import { |
3 | 3 | MailLogModelResult, |
4 | 4 | MessageRecordsParams, |
5 | - SmsLogModelResult | |
6 | -} from "/@/api/message/model/recordsModel"; | |
5 | + SmsLogModelResult, | |
6 | +} from '/@/api/message/model/recordsModel'; | |
7 | 7 | |
8 | 8 | enum MessageRecordsApi { |
9 | - SMS_RECORDS = "/smsLog", | |
10 | - EMAIL_RECORDS = "/mailLog" | |
9 | + SMS_RECORDS = '/smsLog', | |
10 | + EMAIL_RECORDS = '/mailLog', | |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
... | ... | @@ -17,30 +17,30 @@ enum MessageRecordsApi { |
17 | 17 | export const smsLogPage = (params: MessageRecordsParams) => { |
18 | 18 | return defHttp.get<SmsLogModelResult>({ |
19 | 19 | url: MessageRecordsApi.SMS_RECORDS, |
20 | - params | |
21 | - }) | |
22 | -} | |
20 | + params, | |
21 | + }); | |
22 | +}; | |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * 获取邮件发送记录【分页】 |
26 | 26 | * @param params 查询参数 |
27 | 27 | */ |
28 | -export const mailLogPage=(params:MessageRecordsParams)=>{ | |
28 | +export const mailLogPage = (params: MessageRecordsParams) => { | |
29 | 29 | return defHttp.get<MailLogModelResult>({ |
30 | 30 | url: MessageRecordsApi.EMAIL_RECORDS, |
31 | - params | |
32 | - }) | |
33 | -} | |
31 | + params, | |
32 | + }); | |
33 | +}; | |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * 删除邮件记录 |
37 | 37 | * @param ids 邮件记录ID |
38 | 38 | */ |
39 | -export const deleteMailLog =(ids: string[]) => | |
39 | +export const deleteMailLog = (ids: string[]) => | |
40 | 40 | defHttp.delete({ |
41 | 41 | url: MessageRecordsApi.EMAIL_RECORDS, |
42 | 42 | data: { |
43 | - ids: ids | |
43 | + ids: ids, | |
44 | 44 | }, |
45 | 45 | }); |
46 | 46 | /** |
... | ... | @@ -51,6 +51,6 @@ export const deleteSmsLog = (ids: string[]) => |
51 | 51 | defHttp.delete({ |
52 | 52 | url: MessageRecordsApi.SMS_RECORDS, |
53 | 53 | data: { |
54 | - ids: ids | |
54 | + ids: ids, | |
55 | 55 | }, |
56 | 56 | }); | ... | ... |
1 | 1 | import { defHttp } from '/@/utils/http/axios'; |
2 | 2 | import { |
3 | - EmailParams, MessageResultModel, | |
3 | + EmailParams, | |
4 | + MessageResultModel, | |
4 | 5 | MessageTemplate, |
5 | 6 | MessageTemplateParams, |
6 | - MessageTemplateResultModel, SmsParams | |
7 | -} from "/@/api/message/model/templateModel"; | |
8 | -import {MessageConfigResultModel} from "/@/api/message/model/configModel"; | |
7 | + MessageTemplateResultModel, | |
8 | + SmsParams, | |
9 | +} from '/@/api/message/model/templateModel'; | |
10 | +import { MessageConfigResultModel } from '/@/api/message/model/configModel'; | |
9 | 11 | |
10 | 12 | enum MessageTemplateApi { |
11 | 13 | TEMPLATE_URL = '/template', |
... | ... | @@ -15,19 +17,19 @@ enum MessageTemplateApi { |
15 | 17 | * 短信发送 |
16 | 18 | * @param params 发送参数 |
17 | 19 | */ |
18 | -export const sendSms=(params: SmsParams)=>{ | |
20 | +export const sendSms = (params: SmsParams) => { | |
19 | 21 | return defHttp.post<MessageResultModel>({ |
20 | - url: MessageTemplateApi.TEMPLATE_URL+"/sendSms", | |
22 | + url: MessageTemplateApi.TEMPLATE_URL + '/sendSms', | |
21 | 23 | params, |
22 | - }) | |
23 | -} | |
24 | + }); | |
25 | +}; | |
24 | 26 | |
25 | -export const sendEmail=(params:EmailParams)=>{ | |
27 | +export const sendEmail = (params: EmailParams) => { | |
26 | 28 | return defHttp.post<MessageResultModel>({ |
27 | - url: MessageTemplateApi.TEMPLATE_URL+"/sendEmail", | |
29 | + url: MessageTemplateApi.TEMPLATE_URL + '/sendEmail', | |
28 | 30 | params, |
29 | - }) | |
30 | -} | |
31 | + }); | |
32 | +}; | |
31 | 33 | |
32 | 34 | export const messageTemplatePage = (params: MessageTemplateParams) => |
33 | 35 | defHttp.get<MessageTemplateResultModel>({ |
... | ... | @@ -35,7 +37,6 @@ export const messageTemplatePage = (params: MessageTemplateParams) => |
35 | 37 | params, |
36 | 38 | }); |
37 | 39 | |
38 | - | |
39 | 40 | /** |
40 | 41 | * 更新或保存MessageTemplate配置 |
41 | 42 | * @param params 参数 |
... | ... | @@ -46,14 +47,14 @@ export const saveOrEditMessageTemplate = (params: MessageTemplate, isUpdate: boo |
46 | 47 | return defHttp.put<MessageTemplateResultModel>({ |
47 | 48 | url: MessageTemplateApi.TEMPLATE_URL, |
48 | 49 | params, |
49 | - }) | |
50 | + }); | |
50 | 51 | } else { |
51 | 52 | return defHttp.post<MessageTemplateResultModel>({ |
52 | 53 | url: MessageTemplateApi.TEMPLATE_URL, |
53 | 54 | params, |
54 | - }) | |
55 | + }); | |
55 | 56 | } |
56 | -} | |
57 | +}; | |
57 | 58 | |
58 | 59 | /** |
59 | 60 | * 删除MessageConfig |
... | ... | @@ -63,21 +64,26 @@ export const deleteMessageTemplate = (ids: string[]) => |
63 | 64 | defHttp.delete({ |
64 | 65 | url: MessageTemplateApi.TEMPLATE_URL, |
65 | 66 | data: { |
66 | - ids: ids | |
67 | + ids: ids, | |
67 | 68 | }, |
68 | - }) | |
69 | + }); | |
69 | 70 | /** |
70 | 71 | * 更新模板状态 |
71 | 72 | * @param id 配置id |
72 | 73 | * @param status 状态 |
73 | 74 | */ |
74 | -export const setMessageTemplateStatus=(id:string,templatePurpose:string,messageType:string,status:number) => | |
75 | +export const setMessageTemplateStatus = ( | |
76 | + id: string, | |
77 | + templatePurpose: string, | |
78 | + messageType: string, | |
79 | + status: number | |
80 | +) => | |
75 | 81 | defHttp.put<MessageConfigResultModel>({ |
76 | 82 | url: MessageTemplateApi.TEMPLATE_URL, |
77 | - data:{ | |
78 | - "id":id, | |
79 | - "status":status, | |
80 | - "templatePurpose":templatePurpose, | |
81 | - "messageType":messageType | |
83 | + data: { | |
84 | + id: id, | |
85 | + status: status, | |
86 | + templatePurpose: templatePurpose, | |
87 | + messageType: messageType, | |
82 | 88 | }, |
83 | - }) | |
89 | + }); | ... | ... |
... | ... | @@ -3,10 +3,10 @@ export interface BasicPageParams { |
3 | 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 | 12 | export interface BasicFetchResult<T extends any> { | ... | ... |
1 | -import {defHttp} from "/@/utils/http/axios"; | |
2 | -import {FileUploadResponse} from "/@/api/oss/FileUploadResponse"; | |
1 | +import { defHttp } from '/@/utils/http/axios'; | |
2 | +import { FileUploadResponse } from '/@/api/oss/FileUploadResponse'; | |
3 | 3 | |
4 | 4 | enum Api { |
5 | 5 | BaseUploadUrl = '/oss/upload', |
6 | 6 | } |
7 | 7 | |
8 | 8 | export const upload = (file) => { |
9 | - return defHttp.post<FileUploadResponse>({url: Api.BaseUploadUrl, params: file}) | |
10 | -} | |
9 | + return defHttp.post<FileUploadResponse>({ url: Api.BaseUploadUrl, params: file }); | |
10 | +}; | ... | ... |
1 | 1 | export interface JwtModel { |
2 | - userId: string; | |
3 | - username: string; | |
4 | - tenantCode: string; | |
5 | - tenantName: string; | |
6 | - exp: number; | |
7 | - role: string[]; | |
8 | - } | |
9 | - | |
\ No newline at end of file | ||
2 | + userId: string; | |
3 | + username: string; | |
4 | + tenantCode: string; | |
5 | + tenantName: string; | |
6 | + exp: number; | |
7 | + role: string[]; | |
8 | +} | ... | ... |
1 | -import {defHttp} from '/@/utils/http/axios'; | |
2 | -import {getMenuListResultModel} from './model/menuModel'; | |
3 | -import {useUserStore} from '/@/store/modules/user'; | |
4 | -import {RoleEnum} from '/@/enums/roleEnum'; | |
1 | +import { defHttp } from '/@/utils/http/axios'; | |
2 | +import { getMenuListResultModel } from './model/menuModel'; | |
3 | +import { useUserStore } from '/@/store/modules/user'; | |
4 | +import { RoleEnum } from '/@/enums/roleEnum'; | |
5 | 5 | |
6 | 6 | enum Api { |
7 | 7 | BaseMenuUrl = '/menu', |
8 | 8 | GetMenuList = '/menu/me/menus', |
9 | 9 | SysAdminMenuList = '/admin/me/menus', |
10 | - GetMenuIdsByRoleId = '/menu/getMenuIdsByRoleId/' | |
10 | + GetMenuIdsByRoleId = '/menu/getMenuIdsByRoleId/', | |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
... | ... | @@ -17,17 +17,17 @@ enum Api { |
17 | 17 | export const getMenuList = () => { |
18 | 18 | const userStore = useUserStore(); |
19 | 19 | let url = Api.GetMenuList; |
20 | - if (userStore.getRoleList.find(v => v == RoleEnum.ROLE_SYS_ADMIN)) { | |
20 | + if (userStore.getRoleList.find((v) => v == RoleEnum.ROLE_SYS_ADMIN)) { | |
21 | 21 | url = Api.SysAdminMenuList; |
22 | 22 | } |
23 | - return defHttp.get<getMenuListResultModel>({url: url}); | |
23 | + return defHttp.get<getMenuListResultModel>({ url: url }); | |
24 | 24 | }; |
25 | 25 | |
26 | 26 | export const delMenu = (menuIds: string[]) => { |
27 | - let url = Api.BaseMenuUrl; | |
28 | - return defHttp.delete({url: url, data: menuIds}) | |
29 | -} | |
27 | + const url = Api.BaseMenuUrl; | |
28 | + return defHttp.delete({ url: url, data: menuIds }); | |
29 | +}; | |
30 | 30 | export const getMenusIdsByRoleId = (roleId: string) => { |
31 | - let url = Api.GetMenuIdsByRoleId + roleId; | |
32 | - return defHttp.get<Array<string>>({url: url}); | |
33 | -} | |
31 | + const url = Api.GetMenuIdsByRoleId + roleId; | |
32 | + return defHttp.get<Array<string>>({ url: url }); | |
33 | +}; | ... | ... |
... | ... | @@ -42,8 +42,7 @@ export interface GetUserInfoModel { |
42 | 42 | // 介绍 |
43 | 43 | desc?: string; |
44 | 44 | } |
45 | - export interface UserInfoModel{ | |
46 | - | |
45 | +export interface UserInfoModel { | |
47 | 46 | userId: string | number; |
48 | 47 | username: string; |
49 | 48 | realName: string; |
... | ... | @@ -52,10 +51,9 @@ export interface GetUserInfoModel { |
52 | 51 | tenantName: string; |
53 | 52 | roles: string[]; |
54 | 53 | plainRoles?: PlainRoleInfo[]; |
55 | - } | |
54 | +} | |
56 | 55 | |
57 | - export interface PlainRoleInfo { | |
56 | +export interface PlainRoleInfo { | |
58 | 57 | roleName: string; |
59 | 58 | roleId: string; |
60 | 59 | } |
61 | - | ... | ... |
... | ... | @@ -5,7 +5,7 @@ import { |
5 | 5 | GetUserInfoModel, |
6 | 6 | UserInfoModel, |
7 | 7 | RefreshTokenParams, |
8 | - SmsLoginParams | |
8 | + SmsLoginParams, | |
9 | 9 | } from './model/userModel'; |
10 | 10 | |
11 | 11 | import { ErrorMessageMode } from '/#/axios'; |
... | ... | @@ -18,7 +18,7 @@ enum Api { |
18 | 18 | GetMyInfo = '/user/me/info', |
19 | 19 | GetPermCode = '/role/me/permissions', |
20 | 20 | RefreshToken = '/auth/token', |
21 | - SendLoginSmsCode = '/noauth/sendLoginSmsCode/' | |
21 | + SendLoginSmsCode = '/noauth/sendLoginSmsCode/', | |
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
... | ... | @@ -35,7 +35,7 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') |
35 | 35 | } |
36 | 36 | ); |
37 | 37 | } |
38 | -export function getMyInfo(){ | |
38 | +export function getMyInfo() { | |
39 | 39 | return defHttp.get<UserInfoModel>({ url: Api.GetMyInfo }); |
40 | 40 | } |
41 | 41 | /** |
... | ... | @@ -48,19 +48,17 @@ export function getUserInfo() { |
48 | 48 | export function getPermCode() { |
49 | 49 | return defHttp.get<string[]>({ url: Api.GetPermCode }); |
50 | 50 | } |
51 | -export async function SendLoginSmsCode(phoneNumber:string){ | |
52 | - return await defHttp.post<boolean>({url:Api.SendLoginSmsCode+phoneNumber}) | |
51 | +export async function SendLoginSmsCode(phoneNumber: string) { | |
52 | + return await defHttp.post<boolean>({ url: Api.SendLoginSmsCode + phoneNumber }); | |
53 | 53 | } |
54 | 54 | export function doLogout() { |
55 | 55 | // return defHttp.get({ url: Api.Logout }); |
56 | 56 | } |
57 | -export function doRefreshToken(params:RefreshTokenParams){ | |
58 | - return defHttp.post<LoginResultModel>( | |
59 | - { | |
60 | - url: Api.RefreshToken, | |
61 | - params, | |
62 | - } | |
63 | - ); | |
57 | +export function doRefreshToken(params: RefreshTokenParams) { | |
58 | + return defHttp.post<LoginResultModel>({ | |
59 | + url: Api.RefreshToken, | |
60 | + params, | |
61 | + }); | |
64 | 62 | } |
65 | 63 | export function smsCodeLoginApi(params: SmsLoginParams, mode: ErrorMessageMode = 'modal') { |
66 | 64 | return defHttp.post<LoginResultModel>( | ... | ... |
1 | -import {defHttp} from '/@/utils/http/axios'; | |
1 | +import { defHttp } from '/@/utils/http/axios'; | |
2 | 2 | |
3 | -import {DeptListGetResultModel, DeptListItem} from "/@/api/system/model/deptModel"; | |
4 | - | |
5 | -import {DeptOperationApiResult, DeptOperationParams} from "/@/api/system/model/deptModel"; | |
6 | -import {ErrorMessageMode} from "/#/axios"; | |
3 | +import { DeptListGetResultModel, DeptListItem } from '/@/api/system/model/deptModel'; | |
7 | 4 | |
5 | +import { DeptOperationApiResult, DeptOperationParams } from '/@/api/system/model/deptModel'; | |
6 | +import { ErrorMessageMode } from '/#/axios'; | |
8 | 7 | |
9 | 8 | enum Api { |
10 | 9 | DeptList = '/dept/all', |
... | ... | @@ -17,7 +16,11 @@ export const getDeptList = (params?: DeptListItem) => |
17 | 16 | /** |
18 | 17 | * @description: save or edit dept api |
19 | 18 | */ |
20 | -export function saveOrEditDeptApi(params: DeptOperationParams, update: boolean = false, mode: ErrorMessageMode = 'modal') { | |
19 | +export function saveOrEditDeptApi( | |
20 | + params: DeptOperationParams, | |
21 | + update = false, | |
22 | + mode: ErrorMessageMode = 'modal' | |
23 | +) { | |
21 | 24 | if (!update) { |
22 | 25 | return defHttp.post<DeptOperationApiResult>( |
23 | 26 | { |
... | ... | @@ -29,11 +32,14 @@ export function saveOrEditDeptApi(params: DeptOperationParams, update: boolean = |
29 | 32 | } |
30 | 33 | ); |
31 | 34 | } else { |
32 | - return defHttp.put<DeptOperationApiResult>({url: Api.basicUrl, params}, {errorMessageMode: mode}); | |
35 | + return defHttp.put<DeptOperationApiResult>( | |
36 | + { url: Api.basicUrl, params }, | |
37 | + { errorMessageMode: mode } | |
38 | + ); | |
33 | 39 | } |
34 | 40 | } |
35 | 41 | |
36 | 42 | export const delDept = (menuIds: string[]) => { |
37 | - let url = Api.basicUrl; | |
38 | - return defHttp.delete({url: url, data: menuIds}) | |
39 | -} | |
43 | + const url = Api.basicUrl; | |
44 | + return defHttp.delete({ url: url, data: menuIds }); | |
45 | +}; | ... | ... |
1 | -import {defHttp} from '/@/utils/http/axios'; | |
1 | +import { defHttp } from '/@/utils/http/axios'; | |
2 | 2 | import { |
3 | 3 | SysDictItem, |
4 | 4 | SysDict, |
5 | 5 | SysDictParams, |
6 | 6 | SysDictItemParams, |
7 | 7 | SysDictResultModel, |
8 | - SysDictItemResultModel, SysDictItemResult, DictCodeParams | |
8 | + SysDictItemResultModel, | |
9 | + SysDictItemResult, | |
10 | + DictCodeParams, | |
9 | 11 | } from './model/dictModel'; |
10 | 12 | |
11 | - | |
12 | 13 | enum SysDictApi { |
13 | 14 | CONFIG_URL = '/dict', |
14 | - CONFIG_ITEM_URL = '/dictItem' | |
15 | + CONFIG_ITEM_URL = '/dictItem', | |
15 | 16 | } |
16 | 17 | |
17 | 18 | /** |
18 | 19 | * 查找字典值 |
19 | 20 | * @param code |
20 | 21 | */ |
21 | -export const findDictItemByCode=(params? : DictCodeParams)=> | |
22 | -{ | |
22 | +export const findDictItemByCode = (params?: DictCodeParams) => { | |
23 | 23 | return defHttp.post<SysDictItemResult>({ |
24 | - url: SysDictApi.CONFIG_ITEM_URL + "/find", | |
24 | + url: SysDictApi.CONFIG_ITEM_URL + '/find', | |
25 | 25 | params, |
26 | - }) | |
26 | + }); | |
27 | 27 | }; |
28 | 28 | |
29 | 29 | /** |
... | ... | @@ -56,14 +56,14 @@ export const saveOrEditDictItem = (params: SysDictItem, isUpdate: boolean) => { |
56 | 56 | return defHttp.put<SysDictItemResultModel>({ |
57 | 57 | url: SysDictApi.CONFIG_ITEM_URL, |
58 | 58 | params, |
59 | - }) | |
59 | + }); | |
60 | 60 | } else { |
61 | 61 | return defHttp.post<SysDictItemResultModel>({ |
62 | 62 | url: SysDictApi.CONFIG_ITEM_URL, |
63 | 63 | params, |
64 | - }) | |
64 | + }); | |
65 | 65 | } |
66 | -} | |
66 | +}; | |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * 修改DictItem的状态 |
... | ... | @@ -74,11 +74,11 @@ export const setDictItemStatus = (id: string, status: number) => { |
74 | 74 | return defHttp.put<SysDictItemResultModel>({ |
75 | 75 | url: SysDictApi.CONFIG_ITEM_URL, |
76 | 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 | 90 | return defHttp.put<SysDictResultModel>({ |
91 | 91 | url: SysDictApi.CONFIG_URL, |
92 | 92 | params, |
93 | - }) | |
93 | + }); | |
94 | 94 | } else { |
95 | 95 | return defHttp.post<SysDictResultModel>({ |
96 | 96 | url: SysDictApi.CONFIG_URL, |
97 | 97 | params, |
98 | - }) | |
98 | + }); | |
99 | 99 | } |
100 | -} | |
100 | +}; | |
101 | 101 | |
102 | 102 | /** |
103 | 103 | * 删除SysDict |
104 | 104 | * @param ids 删除id数组 |
105 | 105 | */ |
106 | 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 | 120 | * 删除SysDictItem |
118 | 121 | * @param ids 删除id数组 |
... | ... | @@ -121,7 +124,6 @@ export const deleteDictItem = (ids: string[]) => |
121 | 124 | defHttp.delete({ |
122 | 125 | url: SysDictApi.CONFIG_ITEM_URL, |
123 | 126 | data: { |
124 | - ids: ids | |
127 | + ids: ids, | |
125 | 128 | }, |
126 | - }) | |
127 | - | |
129 | + }); | ... | ... |
1 | -import {defHttp} from "/@/utils/http/axios"; | |
2 | -import {GroupListResultModel} from "/@/api/system/model/groupModel"; | |
1 | +import { defHttp } from '/@/utils/http/axios'; | |
2 | +import { GroupListResultModel } from '/@/api/system/model/groupModel'; | |
3 | 3 | |
4 | 4 | enum GroupApi { |
5 | - BASE_URL="/organization" | |
5 | + BASE_URL = '/organization', | |
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
9 | 9 | * 查询当前用户的所属组织 |
10 | 10 | */ |
11 | -export const findCurrentUserGroups=()=> | |
11 | +export const findCurrentUserGroups = () => | |
12 | 12 | defHttp.get<GroupListResultModel>({ |
13 | - url: GroupApi.BASE_URL+"/me/organizations", | |
13 | + url: GroupApi.BASE_URL + '/me/organizations', | |
14 | 14 | }); | ... | ... |
1 | -import {MenuOperationParams, MenuOperationApiResult} from "/@/api/system/model/menuModel"; | |
2 | -import {ErrorMessageMode} from "/#/axios"; | |
3 | -import {defHttp} from "/@/utils/http/axios"; | |
4 | - | |
1 | +import { MenuOperationParams, MenuOperationApiResult } from '/@/api/system/model/menuModel'; | |
2 | +import { ErrorMessageMode } from '/#/axios'; | |
3 | +import { defHttp } from '/@/utils/http/axios'; | |
5 | 4 | |
6 | 5 | enum Api { |
7 | 6 | Save = '/menu', |
... | ... | @@ -10,7 +9,11 @@ enum Api { |
10 | 9 | /** |
11 | 10 | * @description: save menu api |
12 | 11 | */ |
13 | -export function saveMenuApi(params: MenuOperationParams, update: boolean = false, mode: ErrorMessageMode = 'modal') { | |
12 | +export function saveMenuApi( | |
13 | + params: MenuOperationParams, | |
14 | + update: boolean = false, | |
15 | + mode: ErrorMessageMode = 'modal' | |
16 | +) { | |
14 | 17 | console.log(params); |
15 | 18 | if (!update) { |
16 | 19 | return defHttp.post<MenuOperationApiResult>( |
... | ... | @@ -23,6 +26,9 @@ export function saveMenuApi(params: MenuOperationParams, update: boolean = false |
23 | 26 | } |
24 | 27 | ); |
25 | 28 | } else { |
26 | - return defHttp.put<MenuOperationApiResult>({url: Api.Save, params}, {errorMessageMode: mode}); | |
29 | + return defHttp.put<MenuOperationApiResult>( | |
30 | + { url: Api.Save, params }, | |
31 | + { errorMessageMode: mode } | |
32 | + ); | |
27 | 33 | } |
28 | 34 | } | ... | ... |
1 | -import {BasicFetchResult} from "/@/api/model/baseModel"; | |
1 | +import { BasicFetchResult } from '/@/api/model/baseModel'; | |
2 | 2 | |
3 | 3 | export interface DeptOperationParams { |
4 | 4 | id: string; |
... | ... | @@ -6,18 +6,16 @@ export interface DeptOperationParams { |
6 | 6 | createTime: string; |
7 | 7 | tenantCode: string; |
8 | 8 | parentId?: string; |
9 | - orderNo:number; | |
10 | - status:number; | |
9 | + orderNo: number; | |
10 | + status: number; | |
11 | 11 | remark: string; |
12 | 12 | } |
13 | 13 | |
14 | - | |
15 | 14 | export interface DeptOperationApiResult { |
16 | 15 | message: string; |
17 | 16 | code: number; |
18 | 17 | } |
19 | 18 | |
20 | - | |
21 | 19 | export interface DeptListItem { |
22 | 20 | id: string; |
23 | 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 | 3 | * @description: Request list interface parameters |
7 | 4 | */ |
8 | 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 | 12 | export type DictParams = { |
16 | - dictName?:string; | |
17 | - dictCode?:string; | |
18 | -} | |
13 | + dictName?: string; | |
14 | + dictCode?: string; | |
15 | +}; | |
19 | 16 | |
20 | 17 | export interface SysDict { |
21 | 18 | id: string; |
... | ... | @@ -28,17 +25,17 @@ export interface SysDict { |
28 | 25 | } |
29 | 26 | |
30 | 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 | 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 | 39 | createTime: string; |
43 | 40 | updateTime: string; |
44 | 41 | } |
... | ... | @@ -51,4 +48,3 @@ export type SysDictResultModel = BasicFetchResult<SysDict>; |
51 | 48 | export type SysDictItemResultModel = BasicFetchResult<SysDictItem>; |
52 | 49 | |
53 | 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 | 9 | export type GroupListResultModel = GroupItem[]; | ... | ... |
1 | - | |
2 | 1 | export interface MenuOperationApiResult { |
3 | 2 | message: string; |
4 | 3 | code: number; |
5 | 4 | } |
6 | 5 | |
7 | - | |
8 | 6 | export interface MenuOperationParams { |
9 | 7 | path: string; |
10 | 8 | component: any; |
11 | - type:string; | |
12 | - parentId:string; | |
9 | + type: string; | |
10 | + parentId: string; | |
13 | 11 | meta: metaModel; |
14 | 12 | name?: string; |
15 | 13 | alias?: string | string[]; |
... | ... | @@ -21,8 +19,8 @@ export interface MenuOperationParams { |
21 | 19 | export interface metaModel { |
22 | 20 | icon: string; |
23 | 21 | title: string; |
24 | - isLink:boolean; | |
25 | - menuType:number; | |
22 | + isLink: boolean; | |
23 | + menuType: number; | |
26 | 24 | ignoreKeepAlive?: boolean; |
27 | 25 | hideMenu: boolean; |
28 | 26 | status: number; | ... | ... |
1 | -import {BasicPageParams, BasicFetchResult} from '/@/api/model/baseModel'; | |
1 | +import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel'; | |
2 | 2 | |
3 | 3 | export type AccountParams = BasicPageParams & { |
4 | 4 | account?: string; |
... | ... | @@ -6,7 +6,7 @@ export type AccountParams = BasicPageParams & { |
6 | 6 | }; |
7 | 7 | |
8 | 8 | export type RoleParams = { |
9 | - roleType?:string; | |
9 | + roleType?: string; | |
10 | 10 | roleName?: string; |
11 | 11 | status?: string; |
12 | 12 | }; |
... | ... | @@ -30,10 +30,10 @@ export interface AccountListItem { |
30 | 30 | email: string; |
31 | 31 | realName: string; |
32 | 32 | roles: any; |
33 | - groupIds:any; | |
33 | + groupIds: any; | |
34 | 34 | createTime: string; |
35 | 35 | deptId: string; |
36 | - accountExpireTime?:string; | |
36 | + accountExpireTime?: string; | |
37 | 37 | } |
38 | 38 | |
39 | 39 | export interface OrganizationListItem { |
... | ... | @@ -69,16 +69,16 @@ export interface RoleReqDTO { |
69 | 69 | } |
70 | 70 | |
71 | 71 | export interface ChangeAccountParams { |
72 | - userId?:string; | |
73 | - password?:string; | |
74 | - resetPassword?:string; | |
72 | + userId?: string; | |
73 | + password?: string; | |
74 | + resetPassword?: string; | |
75 | 75 | } |
76 | 76 | |
77 | 77 | export class RoleOrOrganizationParam { |
78 | - userId:string; | |
79 | - queryRole:boolean; | |
80 | - queryOrganization:boolean; | |
81 | - constructor(userId:string,queryRole:boolean,queryOrganization:boolean){ | |
78 | + userId: string; | |
79 | + queryRole: boolean; | |
80 | + queryOrganization: boolean; | |
81 | + constructor(userId: string, queryRole: boolean, queryOrganization: boolean) { | |
82 | 82 | this.queryRole = queryRole; |
83 | 83 | this.queryOrganization = queryOrganization; |
84 | 84 | this.userId = userId; |
... | ... | @@ -99,4 +99,3 @@ export type RolePageListGetResultModel = BasicFetchResult<RoleListItem>; |
99 | 99 | export type RoleListGetResultModel = RoleListItem[]; |
100 | 100 | |
101 | 101 | export type AccountListModel = AccountListItem; |
102 | - | ... | ... |
... | ... | @@ -15,7 +15,7 @@ import { |
15 | 15 | RoleOrOrganizationParam, |
16 | 16 | ChangeAccountParams, |
17 | 17 | } from './model/systemModel'; |
18 | -import {defHttp} from '/@/utils/http/axios'; | |
18 | +import { defHttp } from '/@/utils/http/axios'; | |
19 | 19 | |
20 | 20 | enum Api { |
21 | 21 | AccountList = '/user/page', |
... | ... | @@ -28,33 +28,34 @@ enum Api { |
28 | 28 | DeleteRole = '/role', |
29 | 29 | GetAllRoleList = '/role/find/list', |
30 | 30 | BaseUserUrl = '/user', |
31 | - BaseOrganization = '/organization' | |
31 | + BaseOrganization = '/organization', | |
32 | 32 | } |
33 | 33 | |
34 | -export const getAccountInfo=(userId:string)=> | |
35 | - defHttp.get<AccountListModel>({url: Api.BaseUserUrl+"/"+userId}) | |
34 | +export const getAccountInfo = (userId: string) => | |
35 | + defHttp.get<AccountListModel>({ url: Api.BaseUserUrl + '/' + userId }); | |
36 | 36 | |
37 | 37 | export const getAccountList = (params: AccountParams) => |
38 | - defHttp.get<AccountListGetResultModel>({url: Api.AccountList, params}); | |
39 | - | |
38 | + defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params }); | |
40 | 39 | /** |
41 | 40 | * 获取组织列表 |
42 | 41 | * @param params 请求参数 |
43 | 42 | */ |
44 | 43 | export const getOrganizationList = (params?: OrganizationListItem) => |
45 | - defHttp.get<OrganizationListGetResultModel>({url: Api.BaseOrganization+'/me/organizations', params}); | |
44 | + defHttp.get<OrganizationListGetResultModel>({ | |
45 | + url: Api.BaseOrganization + '/me/organizations', | |
46 | + params, | |
47 | + }); | |
46 | 48 | |
47 | 49 | /** |
48 | 50 | * 更新或者保存组织 |
49 | 51 | * @param params |
50 | 52 | * @param isUpdate |
51 | 53 | */ |
52 | -export const saveOrUpdateOrganization = (params?:OrganizationListItem,isUpdate?:boolean) => | |
53 | -{ | |
54 | - if(isUpdate){ | |
55 | - return defHttp.put<OrganizationListGetResultModel>({url: Api.BaseOrganization, params}); | |
56 | - }else{ | |
57 | - return defHttp.post<OrganizationListGetResultModel>({url: Api.BaseOrganization, params}); | |
54 | +export const saveOrUpdateOrganization = (params?: OrganizationListItem, isUpdate?: boolean) => { | |
55 | + if (isUpdate) { | |
56 | + return defHttp.put<OrganizationListGetResultModel>({ url: Api.BaseOrganization, params }); | |
57 | + } else { | |
58 | + return defHttp.post<OrganizationListGetResultModel>({ url: Api.BaseOrganization, params }); | |
58 | 59 | } |
59 | 60 | }; |
60 | 61 | |
... | ... | @@ -63,32 +64,31 @@ export const saveOrUpdateOrganization = (params?:OrganizationListItem,isUpdate?: |
63 | 64 | * @param ids 删除的ID |
64 | 65 | */ |
65 | 66 | export const delOrganization = (ids: string[]) => |
66 | - defHttp.delete({url: Api.BaseOrganization, data: ids}) | |
67 | - | |
67 | + defHttp.delete({ url: Api.BaseOrganization, data: ids }); | |
68 | 68 | |
69 | 69 | export const getMenuList = (params?: MenuParams) => |
70 | - defHttp.get<MenuListGetResultModel>({url: Api.MenuList, params}); | |
70 | + defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params }); | |
71 | 71 | |
72 | 72 | export const getRoleListByPage = (params?: RolePageParams) => |
73 | - defHttp.get<RolePageListGetResultModel>({url: Api.RolePageList, params}); | |
74 | -export const getTenantRoleListByPage= (params?: RolePageParams) => | |
75 | - defHttp.get<RolePageListGetResultModel>({url: Api.RolePageList, params}); | |
73 | + defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params }); | |
74 | +export const getTenantRoleListByPage = (params?: RolePageParams) => | |
75 | + defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params }); | |
76 | 76 | |
77 | 77 | export const getAllRoleList = (params?: RoleParams) => |
78 | - defHttp.post<RoleListGetResultModel>({url: Api.GetAllRoleList, params}); | |
78 | + defHttp.post<RoleListGetResultModel>({ url: Api.GetAllRoleList, params }); | |
79 | 79 | |
80 | 80 | export const setRoleStatus = (id: number, status: number) => |
81 | - defHttp.put({url: Api.setRoleStatus + id + "/" + status}); | |
81 | + defHttp.put({ url: Api.setRoleStatus + id + '/' + status }); | |
82 | 82 | export const saveOrUpdateRoleInfoWithMenu = async (roleRequestDto: RoleReqDTO) => { |
83 | - await defHttp.post({url: Api.SaveOrUpdateRoleInfoWithMenu, params: roleRequestDto}); | |
84 | -} | |
83 | + await defHttp.post({ url: Api.SaveOrUpdateRoleInfoWithMenu, params: roleRequestDto }); | |
84 | +}; | |
85 | 85 | |
86 | 86 | export const isAccountExist = (account: string) => |
87 | - defHttp.get({url: Api.IsAccountExist + account}, {errorMessageMode: 'none'}); | |
87 | + defHttp.get({ url: Api.IsAccountExist + account }, { errorMessageMode: 'none' }); | |
88 | 88 | |
89 | 89 | export const delRole = async (roleIds: string[]) => { |
90 | - await defHttp.delete({url: Api.DeleteRole, params: roleIds}); | |
91 | -} | |
90 | + await defHttp.delete({ url: Api.DeleteRole, params: roleIds }); | |
91 | +}; | |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * 更新或添加用户信息 |
... | ... | @@ -96,19 +96,19 @@ export const delRole = async (roleIds: string[]) => { |
96 | 96 | * @param isUpdate |
97 | 97 | * @constructor |
98 | 98 | */ |
99 | -export const SaveOrUpdateUserInfo = (params: AccountListItem, isUpdate: boolean)=>{ | |
99 | +export const SaveOrUpdateUserInfo = (params: AccountListItem, isUpdate: boolean) => { | |
100 | 100 | if (isUpdate) { |
101 | 101 | return defHttp.put<AccountListModel>({ |
102 | 102 | url: Api.BaseUserUrl, |
103 | 103 | params, |
104 | - }) | |
104 | + }); | |
105 | 105 | } else { |
106 | 106 | return defHttp.post<AccountListModel>({ |
107 | 107 | url: Api.BaseUserUrl, |
108 | 108 | params, |
109 | - }) | |
109 | + }); | |
110 | 110 | } |
111 | -} | |
111 | +}; | |
112 | 112 | /** |
113 | 113 | * 删除User |
114 | 114 | * @param ids 删除id数组 |
... | ... | @@ -117,26 +117,27 @@ export const deleteUser = (ids: string[]) => |
117 | 117 | defHttp.delete({ |
118 | 118 | url: Api.BaseUserUrl, |
119 | 119 | data: { |
120 | - ids: ids | |
120 | + ids: ids, | |
121 | 121 | }, |
122 | - }) | |
122 | + }); | |
123 | 123 | |
124 | 124 | /** |
125 | 125 | * 查询当前用户的关系 |
126 | 126 | * @param params |
127 | 127 | */ |
128 | -export const findCurrentUserRelation=(params:RoleOrOrganizationParam)=> | |
128 | + | |
129 | +export const findCurrentUserRelation = (params: RoleOrOrganizationParam) => | |
129 | 130 | defHttp.post<Array<string>>({ |
130 | - url: Api.BaseUserUrl+"/relation", | |
131 | - params:params | |
131 | + url: Api.BaseUserUrl + '/relation', | |
132 | + params: params, | |
132 | 133 | }); |
133 | 134 | |
134 | 135 | /** |
135 | 136 | * 修改密码 |
136 | 137 | * @param params |
137 | 138 | */ |
138 | -export const resetPassword=(params:ChangeAccountParams)=> | |
139 | +export const resetPassword = (params: ChangeAccountParams) => | |
139 | 140 | defHttp.post({ |
140 | - url: Api.BaseUserUrl + "/reset", | |
141 | - params:params | |
141 | + url: Api.BaseUserUrl + '/reset', | |
142 | + params: params, | |
142 | 143 | }); | ... | ... |
1 | -import {getPageData} from '../base'; | |
1 | +import { getPageData } from '../base'; | |
2 | 2 | import { |
3 | 3 | SendResetPasswordEmailMsg, |
4 | 4 | TenantAdminPageRequestParams, |
5 | 5 | TenantDTO, |
6 | 6 | TenantPageRequestParams, |
7 | - TenantRequestDTO, UserDTO | |
7 | + TenantRequestDTO, | |
8 | + UserDTO, | |
8 | 9 | } from './tenantInfo'; |
9 | -import {defHttp} from "/@/utils/http/axios"; | |
10 | +import { defHttp } from '/@/utils/http/axios'; | |
10 | 11 | |
11 | 12 | enum Api { |
12 | 13 | userPage = '/user/page', |
13 | 14 | tenantPage = '/admin/tenant/page', |
14 | 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 | 20 | deleteTenantAdmin = '/admin/user/deleteTenantAdmin', |
20 | - getTenantRoles="/admin/tenant/roles/", | |
21 | + getTenantRoles = '/admin/tenant/roles/', | |
21 | 22 | } |
22 | 23 | |
23 | 24 | export function getTenantPage(params: TenantPageRequestParams) { |
... | ... | @@ -29,63 +30,49 @@ export function getTenantAdminPage(params: TenantAdminPageRequestParams) { |
29 | 30 | } |
30 | 31 | |
31 | 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 | 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 | 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 | 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 | 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 | 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 | 3 | export enum TenantStatusEnum { |
4 | 4 | NORMAL = 'NORMAL', |
... | ... | @@ -54,13 +54,13 @@ export interface UserDTO { |
54 | 54 | accountExpireTime: string; |
55 | 55 | createTime: string; |
56 | 56 | updateTime: string; |
57 | - userStatusEnum: UserStatusEnum | |
57 | + userStatusEnum: UserStatusEnum; | |
58 | 58 | hasPassword?: boolean; |
59 | 59 | } |
60 | 60 | |
61 | 61 | export enum MessageTypeEnum { |
62 | 62 | EMAIL_MESSAGE = 'EMAIL_MESSAGE', |
63 | - PHONE_MESSAGE = 'PHONE_MESSAGE' | |
63 | + PHONE_MESSAGE = 'PHONE_MESSAGE', | |
64 | 64 | } |
65 | 65 | |
66 | 66 | export class SendResetPasswordEmailMsg { |
... | ... | @@ -71,13 +71,12 @@ export class SendResetPasswordEmailMsg { |
71 | 71 | this.userId = userId; |
72 | 72 | this.messageTypeEnum = msgType; |
73 | 73 | } |
74 | - | |
75 | 74 | } |
76 | 75 | |
77 | 76 | export class TenantPageRequest extends BaseQueryRequest { |
78 | 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 | 80 | super(page, pageSize); |
82 | 81 | this.tenantName = tenantName; |
83 | 82 | } | ... | ... |
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <template> |
6 | 6 | <div class="anticon" :class="getAppLogoClass" @click="goHome"> |
7 | 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 | 9 | {{ title }} |
10 | 10 | </div> |
11 | 11 | </div> | ... | ... |
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 | 16 | <template #centerFooter> |
17 | 17 | <a-button |
18 | 18 | @click="handleStartUpload" | ... | ... |
1 | 1 | export enum RoleEnum { |
2 | - ROLE_SYS_ADMIN = "ROLE_SYS_ADMIN", | |
3 | - ROLE_TENANT_ADMIN = "ROLE_TENANT_ADMIN", | |
4 | - ROLE_NORMAL_USER = "ROLE_NORMAL_USER", | |
5 | - ROLE_PLATFORM_ADMIN="ROLE_PLATFORM_ADMIN" | |
2 | + ROLE_SYS_ADMIN = 'ROLE_SYS_ADMIN', | |
3 | + ROLE_TENANT_ADMIN = 'ROLE_TENANT_ADMIN', | |
4 | + ROLE_NORMAL_USER = 'ROLE_NORMAL_USER', | |
5 | + ROLE_PLATFORM_ADMIN = 'ROLE_PLATFORM_ADMIN', | |
6 | 6 | } | ... | ... |
1 | 1 | export default { |
2 | - common:{ | |
3 | - createTime:"create time", | |
4 | - updateTime:"update time", | |
5 | - operation:"operation", | |
6 | - remark:"remark", | |
7 | - enable:"enable", | |
8 | - disable:"disable", | |
9 | - sort:"sort", | |
10 | - status:"status", | |
2 | + common: { | |
3 | + createTime: 'create time', | |
4 | + updateTime: 'update time', | |
5 | + operation: 'operation', | |
6 | + remark: 'remark', | |
7 | + enable: 'enable', | |
8 | + disable: 'disable', | |
9 | + sort: 'sort', | |
10 | + status: 'status', | |
11 | 11 | }, |
12 | - tenant:{ | |
13 | - tenant:"tenant", | |
14 | - tenantManagement:"tenant management", | |
15 | - tenantSetting:"tenant setting" | |
16 | - }, | |
17 | - organization:{ | |
18 | - queryOrganizationName:"organization name", | |
19 | - toolOrganizationList:"organization list", | |
20 | - toolCreateOrganization:"create organization", | |
21 | - toolEditOrganization:"edit organization", | |
22 | - parentOrganization:"parent organization", | |
12 | + tenant: { | |
13 | + tenant: 'tenant', | |
14 | + tenantManagement: 'tenant management', | |
15 | + tenantSetting: 'tenant setting', | |
23 | 16 | }, |
24 | - dept:{ | |
25 | - queryDeptName:"dept name", | |
26 | - queryDeptStatus:"status", | |
27 | - toolDeptList:"dept list", | |
28 | - toolCreateDept:"create dept", | |
29 | - toolEditDept:"edit dept", | |
30 | - tableTitleDeptSort:"sort", | |
31 | - tableTitleDeptCreateTime:"create time", | |
32 | - tableTitleDeptOperation:"operation", | |
33 | - drawerTitleDeptEnable:"enable", | |
34 | - drawerTitleDeptDisable:"disable", | |
35 | - drawerTitleDeptParentDept:"parent dept", | |
36 | - tableTitleMemo:"memo" | |
17 | + organization: { | |
18 | + queryOrganizationName: 'organization name', | |
19 | + toolOrganizationList: 'organization list', | |
20 | + toolCreateOrganization: 'create organization', | |
21 | + toolEditOrganization: 'edit organization', | |
22 | + parentOrganization: 'parent organization', | |
37 | 23 | }, |
38 | - system:{ | |
39 | - system:"system", | |
40 | - accountManagement:"account management", | |
41 | - roleManagement:"role management", | |
42 | - menuManagement:"menu management", | |
43 | - deptManagement:"dept management", | |
44 | - modifyPassword:"modify password", | |
45 | - pageSystemTitleCreateMenu:"create menu", | |
46 | - pageSystemTitleCreateTenant:"new tenant", | |
47 | - pageSystemTitleEditMenu:"edit menu", | |
48 | - pageSystemTitleEditTenant:"edit tenant", | |
49 | - pageSystemTitleOperation:"operation", | |
50 | - pageSystemTitleWhetherDelete:"Are you sure to delete", | |
51 | - pageSystemTitleMenuList:"menu list", | |
52 | - menuEditPagesMenuType:"menu type", | |
53 | - menuEditPagesDirectory:"directory", | |
54 | - menuEditPagesMenu:"menu", | |
55 | - menuEditPagesButton:"button", | |
56 | - menuEditPagesParentMenu:"parent menu", | |
57 | - menuEditPagesRouterAddress:"router address", | |
58 | - menuEditPagesComponentsPath:"components", | |
59 | - menuEditPagesIsExt:"is ext", | |
60 | - menuEditPagesIsKeepAlive:"is keep alive", | |
61 | - menuEditPagesIsHide:"is hide", | |
62 | - menuEditPagesYes:"yes", | |
63 | - menuEditPagesNo:"no", | |
64 | - tableTitleSystemMenuName:"menu name", | |
65 | - tableTitleSystemIcon:"icon", | |
66 | - tableTitleSystemPermissionTag:"permission tag", | |
67 | - tableTitleSystemComponents:"components", | |
68 | - tableTitleSystemSort:"sort", | |
69 | - tableTitleSystemStatus:"status", | |
70 | - tableTitleSystemCreateTime:"create time", | |
71 | - tableTitleSystemEnable:"enable", | |
72 | - tableTitleSystemStop:"disable", | |
73 | - tableSuccessStatus:"success", | |
74 | - tableFailedStatus:"failed", | |
75 | - } | |
76 | - }; | |
24 | + dept: { | |
25 | + queryDeptName: 'dept name', | |
26 | + queryDeptStatus: 'status', | |
27 | + toolDeptList: 'dept list', | |
28 | + toolCreateDept: 'create dept', | |
29 | + toolEditDept: 'edit dept', | |
30 | + tableTitleDeptSort: 'sort', | |
31 | + tableTitleDeptCreateTime: 'create time', | |
32 | + tableTitleDeptOperation: 'operation', | |
33 | + drawerTitleDeptEnable: 'enable', | |
34 | + drawerTitleDeptDisable: 'disable', | |
35 | + drawerTitleDeptParentDept: 'parent dept', | |
36 | + tableTitleMemo: 'memo', | |
37 | + }, | |
38 | + system: { | |
39 | + system: 'system', | |
40 | + accountManagement: 'account management', | |
41 | + roleManagement: 'role management', | |
42 | + menuManagement: 'menu management', | |
43 | + deptManagement: 'dept management', | |
44 | + modifyPassword: 'modify password', | |
45 | + pageSystemTitleCreateMenu: 'create menu', | |
46 | + pageSystemTitleCreateTenant: 'new tenant', | |
47 | + pageSystemTitleEditMenu: 'edit menu', | |
48 | + pageSystemTitleEditTenant: 'edit tenant', | |
49 | + pageSystemTitleOperation: 'operation', | |
50 | + pageSystemTitleWhetherDelete: 'Are you sure to delete', | |
51 | + pageSystemTitleMenuList: 'menu list', | |
52 | + menuEditPagesMenuType: 'menu type', | |
53 | + menuEditPagesDirectory: 'directory', | |
54 | + menuEditPagesMenu: 'menu', | |
55 | + menuEditPagesButton: 'button', | |
56 | + menuEditPagesParentMenu: 'parent menu', | |
57 | + menuEditPagesRouterAddress: 'router address', | |
58 | + menuEditPagesComponentsPath: 'components', | |
59 | + menuEditPagesIsExt: 'is ext', | |
60 | + menuEditPagesIsKeepAlive: 'is keep alive', | |
61 | + menuEditPagesIsHide: 'is hide', | |
62 | + menuEditPagesYes: 'yes', | |
63 | + menuEditPagesNo: 'no', | |
64 | + tableTitleSystemMenuName: 'menu name', | |
65 | + tableTitleSystemIcon: 'icon', | |
66 | + tableTitleSystemPermissionTag: 'permission tag', | |
67 | + tableTitleSystemComponents: 'components', | |
68 | + tableTitleSystemSort: 'sort', | |
69 | + tableTitleSystemStatus: 'status', | |
70 | + tableTitleSystemCreateTime: 'create time', | |
71 | + tableTitleSystemEnable: 'enable', | |
72 | + tableTitleSystemStop: 'disable', | |
73 | + tableSuccessStatus: 'success', | |
74 | + tableFailedStatus: 'failed', | |
75 | + }, | |
76 | +}; | ... | ... |
... | ... | @@ -2,7 +2,7 @@ export default { |
2 | 2 | api: { |
3 | 3 | operationFailed: 'Operation failed', |
4 | 4 | errorTip: 'Error Tip', |
5 | - passwordOrUserNameError:'username or password not correct', | |
5 | + passwordOrUserNameError: 'username or password not correct', | |
6 | 6 | loginFailed: 'Login Failed', |
7 | 7 | errorMessage: 'The operation failed, the system is abnormal!', |
8 | 8 | timeoutMessage: 'Login timed out, please log in again!', | ... | ... |
1 | 1 | export default { |
2 | - common:{ | |
3 | - createTime:"创建时间", | |
4 | - updateTime:"更新时间", | |
5 | - operation:"操作", | |
6 | - remark:"备注", | |
7 | - enable:"启用", | |
8 | - disable:"禁用", | |
9 | - sort:"排序", | |
10 | - status:"状态" | |
11 | - }, | |
12 | - tenant:{ | |
13 | - tenant:"租户", | |
14 | - tenantManagement:"租户管理", | |
15 | - tenantSetting:"租户设置" | |
16 | - }, | |
17 | - organization:{ | |
18 | - queryOrganizationName:"组织名称", | |
19 | - toolOrganizationList:"组织列表", | |
20 | - toolCreateOrganization:"新增组织", | |
21 | - toolEditOrganization:"编辑组织", | |
22 | - parentOrganization:"上级组织", | |
2 | + common: { | |
3 | + createTime: '创建时间', | |
4 | + updateTime: '更新时间', | |
5 | + operation: '操作', | |
6 | + remark: '备注', | |
7 | + enable: '启用', | |
8 | + disable: '禁用', | |
9 | + sort: '排序', | |
10 | + status: '状态', | |
23 | 11 | }, |
24 | - dept:{ | |
25 | - queryDeptName:"部门名称", | |
26 | - queryDeptStatus:"状态", | |
27 | - toolDeptList:"部门列表", | |
28 | - toolCreateDept:"新增部门", | |
29 | - toolEditDept:"编辑部门", | |
30 | - tableTitleDeptSort:"排序", | |
31 | - tableTitleDeptCreateTime:"创建时间", | |
32 | - tableTitleDeptOperation:"操作", | |
33 | - drawerTitleDeptEnable:"启用", | |
34 | - drawerTitleDeptDisable:"停用", | |
35 | - drawerTitleDeptParentDept:"上级部门", | |
36 | - tableTitleMemo:"备注" | |
12 | + tenant: { | |
13 | + tenant: '租户', | |
14 | + tenantManagement: '租户管理', | |
15 | + tenantSetting: '租户设置', | |
37 | 16 | }, |
38 | - system:{ | |
39 | - system:"系统管理", | |
40 | - accountManagement:"账号管理", | |
41 | - roleManagement:"角色管理", | |
42 | - menuManagement:"菜单管理", | |
43 | - deptManagement:"部门管理", | |
44 | - modifyPassword:"修改密码", | |
45 | - pageSystemTitleCreateMenu:"新增菜单", | |
46 | - pageSystemTitleCreateTenant:"新增租户", | |
47 | - pageSystemTitleEditMenu:"编辑菜单", | |
48 | - pageSystemTitleEditTenant:"编辑租户", | |
49 | - pageSystemTitleOperation:"操作", | |
50 | - pageSystemTitleWhetherDelete:"是否确认删除", | |
51 | - pageSystemTitleMenuList:"菜单列表", | |
52 | - menuEditPagesMenuType:"菜单类型", | |
53 | - menuEditPagesDirectory:"目录", | |
54 | - menuEditPagesMenu:"菜单", | |
55 | - menuEditPagesButton:"按钮", | |
56 | - menuEditPagesParentMenu:"上级菜单", | |
57 | - menuEditPagesRouterAddress:"路由地址", | |
58 | - menuEditPagesComponentsPath:"组件路径", | |
59 | - menuEditPagesIsExt:"是否外链", | |
60 | - menuEditPagesIsKeepAlive:"是否缓存", | |
61 | - menuEditPagesIsHide:"是否隐藏", | |
62 | - menuEditPagesYes:"是", | |
63 | - menuEditPagesNo:"否", | |
64 | - tableTitleSystemMenuName:"菜单名称", | |
65 | - tableTitleSystemIcon:"图标", | |
66 | - tableTitleSystemPermissionTag:"权限标识", | |
67 | - tableTitleSystemComponents:"组件", | |
68 | - tableTitleSystemSort:"排序", | |
69 | - tableTitleSystemStatus:"状态", | |
70 | - tableTitleSystemCreateTime:"创建时间", | |
71 | - tableTitleSystemEnable:"启用", | |
72 | - tableTitleSystemStop:"停用", | |
73 | - tableSuccessStatus:"成功", | |
74 | - tableFailedStatus:"失败", | |
75 | - } | |
76 | - }; | |
17 | + organization: { | |
18 | + queryOrganizationName: '组织名称', | |
19 | + toolOrganizationList: '组织列表', | |
20 | + toolCreateOrganization: '新增组织', | |
21 | + toolEditOrganization: '编辑组织', | |
22 | + parentOrganization: '上级组织', | |
23 | + }, | |
24 | + dept: { | |
25 | + queryDeptName: '部门名称', | |
26 | + queryDeptStatus: '状态', | |
27 | + toolDeptList: '部门列表', | |
28 | + toolCreateDept: '新增部门', | |
29 | + toolEditDept: '编辑部门', | |
30 | + tableTitleDeptSort: '排序', | |
31 | + tableTitleDeptCreateTime: '创建时间', | |
32 | + tableTitleDeptOperation: '操作', | |
33 | + drawerTitleDeptEnable: '启用', | |
34 | + drawerTitleDeptDisable: '停用', | |
35 | + drawerTitleDeptParentDept: '上级部门', | |
36 | + tableTitleMemo: '备注', | |
37 | + }, | |
38 | + system: { | |
39 | + system: '系统管理', | |
40 | + accountManagement: '账号管理', | |
41 | + roleManagement: '角色管理', | |
42 | + menuManagement: '菜单管理', | |
43 | + deptManagement: '部门管理', | |
44 | + modifyPassword: '修改密码', | |
45 | + pageSystemTitleCreateMenu: '新增菜单', | |
46 | + pageSystemTitleCreateTenant: '新增租户', | |
47 | + pageSystemTitleEditMenu: '编辑菜单', | |
48 | + pageSystemTitleEditTenant: '编辑租户', | |
49 | + pageSystemTitleOperation: '操作', | |
50 | + pageSystemTitleWhetherDelete: '是否确认删除', | |
51 | + pageSystemTitleMenuList: '菜单列表', | |
52 | + menuEditPagesMenuType: '菜单类型', | |
53 | + menuEditPagesDirectory: '目录', | |
54 | + menuEditPagesMenu: '菜单', | |
55 | + menuEditPagesButton: '按钮', | |
56 | + menuEditPagesParentMenu: '上级菜单', | |
57 | + menuEditPagesRouterAddress: '路由地址', | |
58 | + menuEditPagesComponentsPath: '组件路径', | |
59 | + menuEditPagesIsExt: '是否外链', | |
60 | + menuEditPagesIsKeepAlive: '是否缓存', | |
61 | + menuEditPagesIsHide: '是否隐藏', | |
62 | + menuEditPagesYes: '是', | |
63 | + menuEditPagesNo: '否', | |
64 | + tableTitleSystemMenuName: '菜单名称', | |
65 | + tableTitleSystemIcon: '图标', | |
66 | + tableTitleSystemPermissionTag: '权限标识', | |
67 | + tableTitleSystemComponents: '组件', | |
68 | + tableTitleSystemSort: '排序', | |
69 | + tableTitleSystemStatus: '状态', | |
70 | + tableTitleSystemCreateTime: '创建时间', | |
71 | + tableTitleSystemEnable: '启用', | |
72 | + tableTitleSystemStop: '停用', | |
73 | + tableSuccessStatus: '成功', | |
74 | + tableFailedStatus: '失败', | |
75 | + }, | |
76 | +}; | ... | ... |
... | ... | @@ -63,9 +63,9 @@ export function initAppConfigStore() { |
63 | 63 | // init store |
64 | 64 | localeStore.initLocale(); |
65 | 65 | |
66 | - const userInfo = Persistent.getLocal(USER_INFO_KEY) as UserInfo | |
66 | + const userInfo = Persistent.getLocal(USER_INFO_KEY) as UserInfo; | |
67 | 67 | const userStore = useUserStore(); |
68 | - if(userInfo){ | |
68 | + if (userInfo) { | |
69 | 69 | userStore.setUserInfo(userInfo); |
70 | 70 | userStore.jwtToken = Persistent.getLocal(JWT_TOKEN_KEY) as string; |
71 | 71 | userStore.refreshToken = Persistent.getLocal(REFRESH_TOKEN_KEY) as string; | ... | ... |
... | ... | @@ -188,7 +188,7 @@ export const usePermissionStore = defineStore({ |
188 | 188 | routeList = (await getMenuList()) as AppRouteRecordRaw[]; |
189 | 189 | } catch (error) { |
190 | 190 | console.error(error); |
191 | - } // Dynamically introduce components | |
191 | + } // Dynamically introduce components | |
192 | 192 | routeList = transformObjToRoute(routeList); |
193 | 193 | |
194 | 194 | // Background routing to menu structure | ... | ... |
... | ... | @@ -4,15 +4,21 @@ import { defineStore } from 'pinia'; |
4 | 4 | import { store } from '/@/store'; |
5 | 5 | import { RoleEnum } from '/@/enums/roleEnum'; |
6 | 6 | import { PageEnum } from '/@/enums/pageEnum'; |
7 | -import { JWT_TOKEN_KEY, REFRESH_TOKEN_KEY, ROLES_KEY, TOKEN_KEY, USER_INFO_KEY } from '/@/enums/cacheEnum'; | |
7 | +import { | |
8 | + JWT_TOKEN_KEY, | |
9 | + REFRESH_TOKEN_KEY, | |
10 | + ROLES_KEY, | |
11 | + TOKEN_KEY, | |
12 | + USER_INFO_KEY, | |
13 | +} from '/@/enums/cacheEnum'; | |
8 | 14 | import { getAuthCache, setAuthCache } from '/@/utils/auth'; |
9 | 15 | import { |
10 | 16 | LoginParams, |
11 | 17 | LoginResultModel, |
12 | 18 | RefreshTokenParams, |
13 | - SmsLoginParams | |
19 | + SmsLoginParams, | |
14 | 20 | } from '/@/api/sys/model/userModel'; |
15 | -import {doRefreshToken, getMyInfo, loginApi, smsCodeLoginApi} from '/@/api/sys/user'; | |
21 | +import { doRefreshToken, getMyInfo, loginApi, smsCodeLoginApi } from '/@/api/sys/user'; | |
16 | 22 | import { useI18n } from '/@/hooks/web/useI18n'; |
17 | 23 | import { useMessage } from '/@/hooks/web/useMessage'; |
18 | 24 | import { router } from '/@/router'; |
... | ... | @@ -26,8 +32,8 @@ interface UserState { |
26 | 32 | roleList: RoleEnum[]; |
27 | 33 | sessionTimeout?: boolean; |
28 | 34 | lastUpdateTime: number; |
29 | - jwtToken?:string; | |
30 | - refreshToken?:string; | |
35 | + jwtToken?: string; | |
36 | + refreshToken?: string; | |
31 | 37 | } |
32 | 38 | |
33 | 39 | export const useUserStore = defineStore({ |
... | ... | @@ -38,7 +44,7 @@ export const useUserStore = defineStore({ |
38 | 44 | // token |
39 | 45 | jwtToken: undefined, |
40 | 46 | //refresh Token |
41 | - refreshToken:undefined, | |
47 | + refreshToken: undefined, | |
42 | 48 | // roleList |
43 | 49 | roleList: [], |
44 | 50 | // Whether the login expired |
... | ... | @@ -67,11 +73,11 @@ export const useUserStore = defineStore({ |
67 | 73 | }, |
68 | 74 | }, |
69 | 75 | actions: { |
70 | - storeToken(jwtToken:string,refreshToken:string){ | |
76 | + storeToken(jwtToken: string, refreshToken: string) { | |
71 | 77 | this.jwtToken = jwtToken; |
72 | 78 | this.refreshToken = refreshToken; |
73 | - setAuthCache(JWT_TOKEN_KEY,jwtToken); | |
74 | - setAuthCache(REFRESH_TOKEN_KEY,refreshToken); | |
79 | + setAuthCache(JWT_TOKEN_KEY, jwtToken); | |
80 | + setAuthCache(REFRESH_TOKEN_KEY, refreshToken); | |
75 | 81 | }, |
76 | 82 | setToken(info: string | undefined) { |
77 | 83 | this.token = info; |
... | ... | @@ -107,34 +113,34 @@ export const useUserStore = defineStore({ |
107 | 113 | try { |
108 | 114 | const { goHome = true, mode, ...loginParams } = params; |
109 | 115 | const data = await loginApi(loginParams, mode); |
110 | - return this.process(data,goHome); | |
116 | + return this.process(data, goHome); | |
111 | 117 | } catch (error) { |
112 | 118 | return Promise.reject(error); |
113 | 119 | } |
114 | 120 | }, |
115 | - async process(data: LoginResultModel, goHome?: boolean): Promise<UserInfo | null> { | |
116 | - const {token, refreshToken} = data; | |
117 | - this.storeToken(token, refreshToken); | |
118 | - // get user info | |
119 | - const userInfo = await this.getMyUserInfoAction(); | |
121 | + async process(data: LoginResultModel, goHome?: boolean): Promise<UserInfo | null> { | |
122 | + const { token, refreshToken } = data; | |
123 | + this.storeToken(token, refreshToken); | |
124 | + // get user info | |
125 | + const userInfo = await this.getMyUserInfoAction(); | |
120 | 126 | |
121 | - const sessionTimeout = this.sessionTimeout; | |
122 | - if (sessionTimeout) { | |
123 | - this.setSessionTimeout(false); | |
124 | - } else if (goHome) { | |
125 | - const permissionStore = usePermissionStore(); | |
126 | - if (!permissionStore.isDynamicAddedRoute) { | |
127 | - const routes = await permissionStore.buildRoutesAction(); | |
128 | - routes.forEach((route) => { | |
129 | - router.addRoute(route as unknown as RouteRecordRaw); | |
130 | - }); | |
131 | - router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw); | |
132 | - permissionStore.setDynamicAddedRoute(true); | |
133 | - } | |
134 | - await router.replace(userInfo.homePath || PageEnum.BASE_HOME); | |
135 | - } | |
136 | - return userInfo; | |
137 | - }, | |
127 | + const sessionTimeout = this.sessionTimeout; | |
128 | + if (sessionTimeout) { | |
129 | + this.setSessionTimeout(false); | |
130 | + } else if (goHome) { | |
131 | + const permissionStore = usePermissionStore(); | |
132 | + if (!permissionStore.isDynamicAddedRoute) { | |
133 | + const routes = await permissionStore.buildRoutesAction(); | |
134 | + routes.forEach((route) => { | |
135 | + router.addRoute(route as unknown as RouteRecordRaw); | |
136 | + }); | |
137 | + router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw); | |
138 | + permissionStore.setDynamicAddedRoute(true); | |
139 | + } | |
140 | + await router.replace(userInfo.homePath || PageEnum.BASE_HOME); | |
141 | + } | |
142 | + return userInfo; | |
143 | + }, | |
138 | 144 | async smsCodelogin( |
139 | 145 | params: SmsLoginParams & { |
140 | 146 | goHome?: boolean; |
... | ... | @@ -144,7 +150,7 @@ export const useUserStore = defineStore({ |
144 | 150 | try { |
145 | 151 | const { goHome = true, mode, ...loginParams } = params; |
146 | 152 | const data = await smsCodeLoginApi(loginParams, mode); |
147 | - return this.process(data,goHome); | |
153 | + return this.process(data, goHome); | |
148 | 154 | } catch (error) { |
149 | 155 | return Promise.reject(error); |
150 | 156 | } |
... | ... | @@ -167,21 +173,21 @@ export const useUserStore = defineStore({ |
167 | 173 | // console.log('注销Token失败'); |
168 | 174 | // } |
169 | 175 | this.resetState(); |
170 | - setAuthCache(JWT_TOKEN_KEY,undefined); | |
171 | - setAuthCache(REFRESH_TOKEN_KEY,undefined); | |
176 | + setAuthCache(JWT_TOKEN_KEY, undefined); | |
177 | + setAuthCache(REFRESH_TOKEN_KEY, undefined); | |
172 | 178 | // this.setSessionTimeout(false); |
173 | 179 | // goLogin && router.push(PageEnum.BASE_LOGIN); |
174 | 180 | await router.push(PageEnum.BASE_LOGIN); |
175 | 181 | }, |
176 | 182 | |
177 | - async doRefresh(){ | |
178 | - try{ | |
179 | - const req = {"refreshToken":this.refreshToken} as RefreshTokenParams; | |
183 | + async doRefresh() { | |
184 | + try { | |
185 | + const req = { refreshToken: this.refreshToken } as RefreshTokenParams; | |
180 | 186 | const data = await doRefreshToken(req); |
181 | 187 | const { token, refreshToken } = data; |
182 | - this.storeToken(token,refreshToken); | |
183 | - }catch(error){ | |
184 | - this.logout() | |
188 | + this.storeToken(token, refreshToken); | |
189 | + } catch (error) { | |
190 | + this.logout(); | |
185 | 191 | } |
186 | 192 | }, |
187 | 193 | |
... | ... | @@ -207,4 +213,3 @@ export const useUserStore = defineStore({ |
207 | 213 | export function useUserStoreWithOut() { |
208 | 214 | return useUserStore(store); |
209 | 215 | } |
210 | - | ... | ... |
1 | 1 | import { Persistent, BasicKeys } from '/@/utils/cache/persistent'; |
2 | 2 | import { CacheTypeEnum } from '/@/enums/cacheEnum'; |
3 | 3 | import projectSetting from '/@/settings/projectSetting'; |
4 | -import { JWT_TOKEN_KEY,REFRESH_TOKEN_KEY } from '/@/enums/cacheEnum'; | |
4 | +import { JWT_TOKEN_KEY, REFRESH_TOKEN_KEY } from '/@/enums/cacheEnum'; | |
5 | 5 | |
6 | 6 | const { permissionCacheType } = projectSetting; |
7 | 7 | const isLocal = permissionCacheType === CacheTypeEnum.LOCAL; |
... | ... | @@ -20,9 +20,9 @@ export function clearAuthCache(immediate = true) { |
20 | 20 | const fn = isLocal ? Persistent.clearLocal : Persistent.clearSession; |
21 | 21 | return fn(immediate); |
22 | 22 | } |
23 | -export function getJwtToken(){ | |
24 | - return getAuthCache(JWT_TOKEN_KEY); | |
23 | +export function getJwtToken() { | |
24 | + return getAuthCache(JWT_TOKEN_KEY); | |
25 | 25 | } |
26 | -export function getRefreshToken(){ | |
26 | +export function getRefreshToken() { | |
27 | 27 | return getAuthCache(REFRESH_TOKEN_KEY); |
28 | 28 | } | ... | ... |
... | ... | @@ -105,11 +105,23 @@ window.addEventListener('beforeunload', function () { |
105 | 105 | // LOCK_INFO_KEY 在锁屏和解锁时写入,此处也不应修改 |
106 | 106 | ls.set(APP_LOCAL_CACHE_KEY, { |
107 | 107 | ...omit(localMemory.getCache, LOCK_INFO_KEY), |
108 | - ...pick(ls.get(APP_LOCAL_CACHE_KEY), [TOKEN_KEY,JWT_TOKEN_KEY,REFRESH_TOKEN_KEY, USER_INFO_KEY, LOCK_INFO_KEY]), | |
108 | + ...pick(ls.get(APP_LOCAL_CACHE_KEY), [ | |
109 | + TOKEN_KEY, | |
110 | + JWT_TOKEN_KEY, | |
111 | + REFRESH_TOKEN_KEY, | |
112 | + USER_INFO_KEY, | |
113 | + LOCK_INFO_KEY, | |
114 | + ]), | |
109 | 115 | }); |
110 | 116 | ss.set(APP_SESSION_CACHE_KEY, { |
111 | 117 | ...omit(sessionMemory.getCache, LOCK_INFO_KEY), |
112 | - ...pick(ss.get(APP_SESSION_CACHE_KEY), [TOKEN_KEY,JWT_TOKEN_KEY,REFRESH_TOKEN_KEY, USER_INFO_KEY, LOCK_INFO_KEY]), | |
118 | + ...pick(ss.get(APP_SESSION_CACHE_KEY), [ | |
119 | + TOKEN_KEY, | |
120 | + JWT_TOKEN_KEY, | |
121 | + REFRESH_TOKEN_KEY, | |
122 | + USER_INFO_KEY, | |
123 | + LOCK_INFO_KEY, | |
124 | + ]), | |
113 | 125 | }); |
114 | 126 | }); |
115 | 127 | ... | ... |
src/utils/fnUtils.ts
0 → 100644
1 | +export const copyTransFun = (arr: any[]) => { | |
2 | + arr.forEach((item) => { | |
3 | + if (item.name) { | |
4 | + item.label = item.name; | |
5 | + delete item.name; | |
6 | + } | |
7 | + if (item.id) { | |
8 | + item.value = item.id; | |
9 | + delete item.id; | |
10 | + } | |
11 | + if (item.children) { | |
12 | + if (item.children.length) { | |
13 | + copyTransFun(item.children); | |
14 | + } | |
15 | + } | |
16 | + }); | |
17 | +}; | ... | ... |
... | ... | @@ -10,7 +10,7 @@ import { ContentTypeEnum } from '/@/enums/httpEnum'; |
10 | 10 | import { RequestEnum } from '/@/enums/httpEnum'; |
11 | 11 | import { useUserStore } from '/@/store/modules/user'; |
12 | 12 | import { JwtModel } from '/@/api/sys/jwtModel'; |
13 | -import jwt_decode from "jwt-decode"; | |
13 | +import jwt_decode from 'jwt-decode'; | |
14 | 14 | |
15 | 15 | export * from './axiosTransform'; |
16 | 16 | |
... | ... | @@ -20,14 +20,14 @@ export * from './axiosTransform'; |
20 | 20 | export class VAxios { |
21 | 21 | private axiosInstance: AxiosInstance; |
22 | 22 | private readonly options: CreateAxiosOptions; |
23 | - private waitingQueue:any[]; | |
23 | + private waitingQueue: any[]; | |
24 | 24 | private refreshing = false; |
25 | 25 | |
26 | 26 | constructor(options: CreateAxiosOptions) { |
27 | 27 | this.options = options; |
28 | 28 | this.axiosInstance = axios.create(options); |
29 | 29 | this.setupInterceptors(); |
30 | - this.waitingQueue=[]; | |
30 | + this.waitingQueue = []; | |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
... | ... | @@ -69,15 +69,15 @@ export class VAxios { |
69 | 69 | * JWT 自动刷新 |
70 | 70 | * @description: 自动刷新token |
71 | 71 | */ |
72 | - private isNeedTokenURL(url, arr = ['/auth/login', '/auth/token']) { | |
72 | + private isNeedTokenURL(url, arr = ['/auth/login', '/auth/token']) { | |
73 | 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 | 81 | // 创建一个未完成的promise,把改变状态的resolve方法交给请求token结束后执行 |
82 | 82 | const promise = new Promise((resolve) => { |
83 | 83 | console.log('等待新token'); |
... | ... | @@ -88,7 +88,7 @@ export class VAxios { |
88 | 88 | this.refreshing = true; |
89 | 89 | // 模拟请求刷新Token接口,当接口返回数据时执行then方法 TODO 添加catch捕获异常 |
90 | 90 | doRefreshTokenApi().then(() => { |
91 | - console.log('刷新token成功,放行队列中的请求',this.waitingQueue.length); | |
91 | + console.log('刷新token成功,放行队列中的请求', this.waitingQueue.length); | |
92 | 92 | this.refreshing = false; |
93 | 93 | this.waitingQueue.forEach((cb) => cb()); |
94 | 94 | this.waitingQueue.length = 0; |
... | ... | @@ -116,19 +116,18 @@ export class VAxios { |
116 | 116 | // Request interceptor configuration processing |
117 | 117 | this.axiosInstance.interceptors.request.use(async (config: AxiosRequestConfig) => { |
118 | 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 | 128 | userStore.logout(); |
129 | - } | |
130 | - | |
131 | - } | |
129 | + } | |
130 | + } | |
132 | 131 | const { |
133 | 132 | headers: { ignoreCancelToken }, |
134 | 133 | } = config; | ... | ... |
... | ... | @@ -93,7 +93,7 @@ const transform: AxiosTransform = { |
93 | 93 | const token = getJwtToken(); |
94 | 94 | if (token && (config as Recordable)?.requestOptions?.withToken !== false) { |
95 | 95 | // jwt token |
96 | - config.headers["X-Authorization"] = options.authenticationScheme | |
96 | + config.headers['X-Authorization'] = options.authenticationScheme | |
97 | 97 | ? `${options.authenticationScheme} ${token}` |
98 | 98 | : token; |
99 | 99 | } |
... | ... | @@ -111,10 +111,10 @@ const transform: AxiosTransform = { |
111 | 111 | * @description: 响应错误处理 |
112 | 112 | */ |
113 | 113 | responseInterceptorsCatch: (error: any) => { |
114 | - const {t} = useI18n(); | |
114 | + const { t } = useI18n(); | |
115 | 115 | const errorLogStore = useErrorLogStoreWithOut(); |
116 | 116 | errorLogStore.addAjaxErrorInfo(error); |
117 | - const {response, code, message, config} = error || {}; | |
117 | + const { response, code, message, config } = error || {}; | |
118 | 118 | const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none'; |
119 | 119 | const msg: string = response?.data?.msg ?? ''; |
120 | 120 | const err: string = error?.toString?.() ?? ''; |
... | ... | @@ -130,13 +130,13 @@ const transform: AxiosTransform = { |
130 | 130 | |
131 | 131 | if (errMessage) { |
132 | 132 | if (errorMessageMode === 'modal') { |
133 | - createErrorModal({title: t('sys.api.errorTip'), content: errMessage}); | |
133 | + createErrorModal({ title: t('sys.api.errorTip'), content: errMessage }); | |
134 | 134 | } else if (errorMessageMode === 'message') { |
135 | 135 | createMessage.error(errMessage); |
136 | 136 | } |
137 | 137 | return Promise.reject(error); |
138 | 138 | } |
139 | - } catch (error) { | |
139 | + } catch (error: any) { | |
140 | 140 | throw new Error(error); |
141 | 141 | } |
142 | 142 | ... | ... |
1 | 1 | /* list To Tree */ |
2 | 2 | |
3 | -import {getMenuListResultModel} from "/@/api/sys/model/menuModel"; | |
4 | -import {useI18n} from "/@/hooks/web/useI18n"; | |
5 | - | |
3 | +import { getMenuListResultModel } from '/@/api/sys/model/menuModel'; | |
4 | +import { useI18n } from '/@/hooks/web/useI18n'; | |
6 | 5 | |
7 | 6 | export function listToTree(lists: getMenuListResultModel): getMenuListResultModel { |
8 | 7 | const { t } = useI18n(); //加载国际化 |
9 | - lists.forEach(goods => { | |
8 | + lists.forEach((goods) => { | |
10 | 9 | goods['menuName'] = t(goods.meta.title); // 为goods添加属性menuName |
11 | 10 | |
12 | 11 | // console.log(goods.children?.length); |
13 | - if(goods.children?.length){ | |
14 | - goods.children.forEach(goodChildren => { | |
12 | + if (goods.children?.length) { | |
13 | + goods.children.forEach((goodChildren) => { | |
15 | 14 | goodChildren['menuName'] = t(goodChildren.meta.title); // 为goodChildren添加属性menuName |
16 | - }) | |
15 | + }); | |
17 | 16 | } |
18 | - }) | |
17 | + }); | |
19 | 18 | |
20 | 19 | return lists; |
21 | - | |
22 | 20 | } |
23 | - | |
24 | - | |
25 | - | |
26 | - | |
27 | - | |
28 | - | |
29 | - | ... | ... |
src/views/alarm/position/config.data.ts
0 → 100644
1 | +import { FormSchema } from '/@/components/Table'; | |
2 | +export const formSchema: FormSchema[] = [ | |
3 | + { | |
4 | + field: 'organization', | |
5 | + label: '', | |
6 | + component: 'TreeSelect', | |
7 | + componentProps: {}, | |
8 | + }, | |
9 | + { | |
10 | + field: 'organization', | |
11 | + label: '', | |
12 | + component: 'Select', | |
13 | + componentProps: {}, | |
14 | + }, | |
15 | + { | |
16 | + field: 'device', | |
17 | + label: '', | |
18 | + slot: 'device', | |
19 | + component: 'Input', | |
20 | + }, | |
21 | +]; | ... | ... |
src/views/alarm/position/index.vue
0 → 100644
1 | +<template> | |
2 | + <div class="wrapper"> | |
3 | + <div ref="wrapRef" :style="{ height, width }"> </div> | |
4 | + <div class="right-wrap"> | |
5 | + <BasicForm @register="registerForm"> | |
6 | + <template #device> | |
7 | + <div class="flex justify-between"> | |
8 | + <a-input v-model:value="deviceValue" placeholder="请输入设备名称" style="width: 70%" /> | |
9 | + <a-button color="success" @click="handleReset" class="w-1/4">复位查询</a-button> | |
10 | + </div> | |
11 | + </template> | |
12 | + </BasicForm> | |
13 | + <div> | |
14 | + <RadioGroup v-model:value="deviceStatus"> | |
15 | + <Radio :value="1">全部</Radio> | |
16 | + <Radio :value="2">在线</Radio> | |
17 | + <Radio :value="3">离线</Radio> | |
18 | + <Radio :value="4">报警</Radio> | |
19 | + </RadioGroup> | |
20 | + <div class="scroll-wrap"> | |
21 | + <ScrollContainer ref="scrollRef"> | |
22 | + <template | |
23 | + v-for="(item, index) in 10" | |
24 | + :key="index" | |
25 | + :class="{ active: currentIndex == index }" | |
26 | + @click="bander(index)" | |
27 | + > | |
28 | + <div class="flex" style="border-bottom: 1px solid #ccc"> | |
29 | + <div> | |
30 | + <div class="flex"> | |
31 | + <div class="font-bold ml-5">名称 </div> | |
32 | + <div class="ml-5">发动机{{ item }}</div> | |
33 | + </div> | |
34 | + <div class="flex"> | |
35 | + <div class="font-bold ml-5">位置 </div> | |
36 | + <div class="ml-5 font-bold">四川省成都市高新区{{ item }}</div> | |
37 | + </div> | |
38 | + </div> | |
39 | + <div class="self-center ml-10"><Tag color="default">离线</Tag></div> | |
40 | + </div> | |
41 | + </template> | |
42 | + </ScrollContainer> | |
43 | + </div> | |
44 | + <div class="flex justify-end"> | |
45 | + <Pagination v-model:current="current" :total="50" size="small" show-less-items /> | |
46 | + </div> | |
47 | + </div> | |
48 | + </div> | |
49 | + </div> | |
50 | +</template> | |
51 | +<script lang="ts"> | |
52 | + import { defineComponent, ref, nextTick, unref, onMounted } from 'vue'; | |
53 | + import { useScript } from '/@/hooks/web/useScript'; | |
54 | + import { BasicForm, useForm } from '/@/components/Form/index'; | |
55 | + import { formSchema } from './config.data'; | |
56 | + import { RadioGroup, Radio, Tag, Pagination } from 'ant-design-vue'; | |
57 | + import { ScrollContainer, ScrollActionType } from '/@/components/Container/index'; | |
58 | + export default defineComponent({ | |
59 | + name: 'BaiduMap', | |
60 | + components: { | |
61 | + BasicForm, | |
62 | + RadioGroup, | |
63 | + Radio, | |
64 | + Tag, | |
65 | + ScrollContainer, | |
66 | + Pagination, | |
67 | + }, | |
68 | + props: { | |
69 | + width: { | |
70 | + type: String, | |
71 | + default: '100%', | |
72 | + }, | |
73 | + height: { | |
74 | + type: String, | |
75 | + default: 'calc(100vh - 78px)', | |
76 | + }, | |
77 | + }, | |
78 | + | |
79 | + setup() { | |
80 | + const BAI_DU_MAP_URL = | |
81 | + 'https://api.map.baidu.com/getscript?v=3.0&ak=7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa'; | |
82 | + const wrapRef = ref<HTMLDivElement | null>(null); | |
83 | + const scrollRef = ref<Nullable<ScrollActionType>>(null); | |
84 | + const { toPromise } = useScript({ src: BAI_DU_MAP_URL }); | |
85 | + async function initMap() { | |
86 | + await toPromise(); | |
87 | + await nextTick(); | |
88 | + const wrapEl = unref(wrapRef); | |
89 | + const BMap = (window as any).BMap; | |
90 | + if (!wrapEl) return; | |
91 | + const map = new BMap.Map(wrapEl); | |
92 | + const point = new BMap.Point(116.14282, 35.19515); | |
93 | + map.centerAndZoom(point, 15); | |
94 | + map.enableScrollWheelZoom(true); | |
95 | + } | |
96 | + onMounted(() => { | |
97 | + initMap(); | |
98 | + }); | |
99 | + const deviceValue = ref(''); | |
100 | + const deviceStatus = ref(1); | |
101 | + const current = ref(2); | |
102 | + const currentIndex = ref(1); | |
103 | + const bander = (index: number) => { | |
104 | + currentIndex.value = index; | |
105 | + }; | |
106 | + const [registerForm] = useForm({ | |
107 | + labelWidth: 90, | |
108 | + schemas: formSchema, | |
109 | + showActionButtonGroup: false, | |
110 | + }); | |
111 | + const handleReset = () => { | |
112 | + deviceValue.value = ''; | |
113 | + }; | |
114 | + return { | |
115 | + wrapRef, | |
116 | + registerForm, | |
117 | + deviceValue, | |
118 | + deviceStatus, | |
119 | + handleReset, | |
120 | + scrollRef, | |
121 | + current, | |
122 | + currentIndex, | |
123 | + bander, | |
124 | + }; | |
125 | + }, | |
126 | + }); | |
127 | +</script> | |
128 | + | |
129 | +<style scoped> | |
130 | + .wrapper { | |
131 | + position: relative; | |
132 | + } | |
133 | + .active { | |
134 | + background-color: #fff; | |
135 | + } | |
136 | + .right-wrap { | |
137 | + padding-top: 10px; | |
138 | + width: 20%; | |
139 | + height: 80%; | |
140 | + position: absolute; | |
141 | + right: 5%; | |
142 | + top: 10%; | |
143 | + background-color: #f3f8fe; | |
144 | + } | |
145 | + .scroll-wrap { | |
146 | + height: 450px; | |
147 | + background-color: #f3f8fe; | |
148 | + } | |
149 | +</style> | ... | ... |
src/views/alarm/template/ContactDrawer.vue
0 → 100644
1 | +<template> | |
2 | + <BasicDrawer | |
3 | + v-bind="$attrs" | |
4 | + @register="registerDrawer" | |
5 | + showFooter | |
6 | + :title="getTitle" | |
7 | + width="30%" | |
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 { saveOrEditAlarmContact } from '/@/api/alarm/contact/alarmContact'; | |
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 | + await setFieldsValue({ | |
40 | + ...data.record, | |
41 | + }); | |
42 | + } | |
43 | + }); | |
44 | + | |
45 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增联系人配置' : '编辑联系人配置')); | |
46 | + | |
47 | + async function handleSubmit() { | |
48 | + try { | |
49 | + const values = await validate(); | |
50 | + const { createMessage } = useMessage(); | |
51 | + setDrawerProps({ confirmLoading: true }); | |
52 | + let saveMessage = '添加成功'; | |
53 | + let updateMessage = '修改成功'; | |
54 | + await saveOrEditAlarmContact(values, unref(isUpdate)); | |
55 | + closeDrawer(); | |
56 | + emit('success'); | |
57 | + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); | |
58 | + } finally { | |
59 | + setDrawerProps({ confirmLoading: false }); | |
60 | + } | |
61 | + } | |
62 | + | |
63 | + return { | |
64 | + getTitle, | |
65 | + registerDrawer, | |
66 | + registerForm, | |
67 | + handleSubmit, | |
68 | + }; | |
69 | + }, | |
70 | + }); | |
71 | +</script> | ... | ... |
src/views/alarm/template/config.data.ts
0 → 100644
1 | +import { BasicColumn } from '/@/components/Table'; | |
2 | +import { FormSchema } from '/@/components/Table'; | |
3 | +import { getOrganizationList } from '/@/api/system/system'; | |
4 | +import { copyTransFun } from '/@/utils/fnUtils'; | |
5 | +// 表格列数据 | |
6 | +export const columns: BasicColumn[] = [ | |
7 | + { | |
8 | + title: '姓名', | |
9 | + dataIndex: 'username', | |
10 | + width: 120, | |
11 | + }, | |
12 | + { | |
13 | + title: '所属组织', | |
14 | + dataIndex: 'organizationId', | |
15 | + width: 160, | |
16 | + }, | |
17 | + { | |
18 | + title: '手机', | |
19 | + dataIndex: 'phone', | |
20 | + width: 160, | |
21 | + }, | |
22 | + { | |
23 | + title: '邮箱', | |
24 | + dataIndex: 'email', | |
25 | + width: 160, | |
26 | + }, | |
27 | + { | |
28 | + title: '微信', | |
29 | + dataIndex: 'wechat', | |
30 | + width: 180, | |
31 | + }, | |
32 | + { | |
33 | + title: '备注', | |
34 | + dataIndex: 'remark', | |
35 | + width: 120, | |
36 | + }, | |
37 | + { | |
38 | + title: '添加人', | |
39 | + dataIndex: 'addPeople', | |
40 | + width: 180, | |
41 | + }, | |
42 | + { | |
43 | + title: '添加时间', | |
44 | + dataIndex: 'createTime', | |
45 | + width: 180, | |
46 | + }, | |
47 | + { | |
48 | + title: '更新时间', | |
49 | + dataIndex: 'updateTime', | |
50 | + width: 180, | |
51 | + }, | |
52 | +]; | |
53 | + | |
54 | +// 查询字段 | |
55 | +export const searchFormSchema: FormSchema[] = [ | |
56 | + { | |
57 | + field: 'username', | |
58 | + label: '联系人姓名', | |
59 | + component: 'Input', | |
60 | + colProps: { span: 6 }, | |
61 | + componentProps: { | |
62 | + placeholder: '请输入联系人姓名', | |
63 | + }, | |
64 | + }, | |
65 | +]; | |
66 | + | |
67 | +// 弹框配置项 | |
68 | +export const formSchema: FormSchema[] = [ | |
69 | + { | |
70 | + field: 'username', | |
71 | + label: '联系人姓名', | |
72 | + required: true, | |
73 | + component: 'Input', | |
74 | + componentProps: { | |
75 | + placeholder: '请输入联系人姓名', | |
76 | + }, | |
77 | + }, | |
78 | + { | |
79 | + field: 'organizationId', | |
80 | + label: '所属组织', | |
81 | + component: 'ApiTreeSelect', | |
82 | + componentProps: { | |
83 | + api: async () => { | |
84 | + const data = await getOrganizationList(); | |
85 | + copyTransFun(data as any as any[]); | |
86 | + return data; | |
87 | + }, | |
88 | + }, | |
89 | + }, | |
90 | + { | |
91 | + field: 'phone', | |
92 | + label: '手机号码', | |
93 | + required: true, | |
94 | + component: 'Input', | |
95 | + componentProps: { | |
96 | + placeholder: '请输入手机号码', | |
97 | + }, | |
98 | + }, | |
99 | + { | |
100 | + field: 'email', | |
101 | + label: '邮箱', | |
102 | + component: 'Input', | |
103 | + componentProps: { | |
104 | + placeholder: '请输入邮箱', | |
105 | + }, | |
106 | + }, | |
107 | + { | |
108 | + field: 'wechat', | |
109 | + label: '微信', | |
110 | + component: 'Input', | |
111 | + componentProps: { | |
112 | + placeholder: '请输入微信号', | |
113 | + }, | |
114 | + }, | |
115 | + { | |
116 | + field: 'addPeople', | |
117 | + label: '添加人', | |
118 | + component: 'Input', | |
119 | + componentProps: { | |
120 | + placeholder: '请输入添加人', | |
121 | + }, | |
122 | + }, | |
123 | + { | |
124 | + field: 'remark', | |
125 | + label: '备注', | |
126 | + component: 'InputTextArea', | |
127 | + componentProps: { | |
128 | + placeholder: '', | |
129 | + }, | |
130 | + }, | |
131 | + { | |
132 | + field: 'id', | |
133 | + label: '', | |
134 | + component: 'Input', | |
135 | + componentProps: { | |
136 | + style: { | |
137 | + display: 'none', | |
138 | + }, | |
139 | + }, | |
140 | + }, | |
141 | +]; | ... | ... |
src/views/alarm/template/index.vue
0 → 100644
1 | +<template> | |
2 | + <PageWrapper dense contentFullHeight fixedHeight contentClass="flex"> | |
3 | + <OrganizationIdTree class="w-1/4 xl:w-1/5" @select="handleSelect" /> | |
4 | + <BasicTable @register="registerTable" :searchInfo="searchInfo" class="w-3/4 xl:w-4/5"> | |
5 | + <template #toolbar> | |
6 | + <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增联系人 </a-button> | |
7 | + <a-button | |
8 | + type="primary" | |
9 | + color="error" | |
10 | + @click="handleDeleteOrBatchDelete(null)" | |
11 | + :disabled="hasBatchDelete" | |
12 | + > | |
13 | + 批量删除 | |
14 | + </a-button> | |
15 | + </template> | |
16 | + <template #action="{ record }"> | |
17 | + <TableAction | |
18 | + :actions="[ | |
19 | + { | |
20 | + label: '编辑', | |
21 | + icon: 'clarity:note-edit-line', | |
22 | + onClick: handleCreateOrEdit.bind(null, record), | |
23 | + }, | |
24 | + { | |
25 | + label: '删除', | |
26 | + icon: 'ant-design:delete-outlined', | |
27 | + color: 'error', | |
28 | + popConfirm: { | |
29 | + title: '是否确认删除', | |
30 | + confirm: handleDeleteOrBatchDelete.bind(null, record), | |
31 | + }, | |
32 | + }, | |
33 | + ]" | |
34 | + /> | |
35 | + </template> | |
36 | + </BasicTable> | |
37 | + </PageWrapper> | |
38 | + <ContactDrawer @register="registerDrawer" @success="handleSuccess" /> | |
39 | +</template> | |
40 | + | |
41 | +<script lang="ts"> | |
42 | + import { defineComponent, reactive, ref, computed } from 'vue'; | |
43 | + import { BasicTable, useTable, TableAction } from '/@/components/Table'; | |
44 | + import { PageWrapper } from '/@/components/Page'; | |
45 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
46 | + import { useDrawer } from '/@/components/Drawer'; | |
47 | + import ContactDrawer from './ContactDrawer.vue'; | |
48 | + import OrganizationIdTree from '../../common/OrganizationIdTree.vue'; | |
49 | + import { getAlarmContact, deleteAlarmContact } from '/@/api/alarm/contact/alarmContact'; | |
50 | + import { searchFormSchema, columns } from './config.data'; | |
51 | + export default defineComponent({ | |
52 | + components: { | |
53 | + PageWrapper, | |
54 | + OrganizationIdTree, | |
55 | + BasicTable, | |
56 | + TableAction, | |
57 | + ContactDrawer, | |
58 | + }, | |
59 | + setup() { | |
60 | + let selectedRowIds = ref<string[]>([]); | |
61 | + const hasBatchDelete = computed(() => selectedRowIds.value.length <= 0); | |
62 | + // 复选框事件 | |
63 | + const onSelectRowChange = (selectedRowKeys: string[]) => { | |
64 | + selectedRowIds.value = selectedRowKeys; | |
65 | + }; | |
66 | + // 表格hooks | |
67 | + const [registerTable, { reload }] = useTable({ | |
68 | + api: getAlarmContact, | |
69 | + columns, | |
70 | + formConfig: { | |
71 | + labelWidth: 120, | |
72 | + schemas: searchFormSchema, | |
73 | + }, | |
74 | + useSearchForm: true, | |
75 | + showTableSetting: true, | |
76 | + bordered: true, | |
77 | + rowSelection: { | |
78 | + onChange: onSelectRowChange, | |
79 | + type: 'checkbox', | |
80 | + }, | |
81 | + rowKey: 'id', | |
82 | + actionColumn: { | |
83 | + width: 180, | |
84 | + title: '操作', | |
85 | + dataIndex: 'action', | |
86 | + slots: { customRender: 'action' }, | |
87 | + fixed: 'right', | |
88 | + }, | |
89 | + }); | |
90 | + // 弹框 | |
91 | + const [registerDrawer, { openDrawer }] = useDrawer(); | |
92 | + const { createMessage } = useMessage(); | |
93 | + const searchInfo = reactive<Recordable>({}); | |
94 | + // 刷新 | |
95 | + const handleSuccess = () => { | |
96 | + reload(); | |
97 | + }; | |
98 | + // 新增或编辑 | |
99 | + const handleCreateOrEdit = (record: Recordable) => { | |
100 | + if (record) { | |
101 | + openDrawer(true, { | |
102 | + isUpdate: true, | |
103 | + record, | |
104 | + }); | |
105 | + } else { | |
106 | + openDrawer(true, { | |
107 | + isUpdate: false, | |
108 | + }); | |
109 | + } | |
110 | + }; | |
111 | + // 删除或批量删除 | |
112 | + const handleDeleteOrBatchDelete = async (record?: Recordable) => { | |
113 | + if (record) { | |
114 | + try { | |
115 | + await deleteAlarmContact([record.id]); | |
116 | + createMessage.success('删除联系人成功'); | |
117 | + handleSuccess(); | |
118 | + } catch (e) { | |
119 | + createMessage.error('删除失败'); | |
120 | + } | |
121 | + } else { | |
122 | + try { | |
123 | + await deleteAlarmContact(selectedRowIds.value); | |
124 | + createMessage.success('批量删除联系人成功'); | |
125 | + handleSuccess(); | |
126 | + } catch (e) { | |
127 | + createMessage.info('删除失败'); | |
128 | + } | |
129 | + } | |
130 | + }; | |
131 | + | |
132 | + // 树形选择器 | |
133 | + const handleSelect = (organizationId: string) => { | |
134 | + searchInfo.organizationId = organizationId; | |
135 | + handleSuccess(); | |
136 | + }; | |
137 | + return { | |
138 | + searchInfo, | |
139 | + hasBatchDelete, | |
140 | + handleCreateOrEdit, | |
141 | + handleDeleteOrBatchDelete, | |
142 | + handleSelect, | |
143 | + handleSuccess, | |
144 | + registerTable, | |
145 | + registerDrawer, | |
146 | + }; | |
147 | + }, | |
148 | + }); | |
149 | +</script> | ... | ... |
src/views/device/DeviceDrawer.vue
deleted
100644 → 0
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 | - <template #iconSelect> | |
12 | - <Upload | |
13 | - name="avatar" | |
14 | - list-type="picture-card" | |
15 | - class="avatar-uploader" | |
16 | - :show-upload-list="false" | |
17 | - :customRequest="customUpload" | |
18 | - :before-upload="beforeUpload" | |
19 | - > | |
20 | - <img v-if="devicePic" :src="devicePic" alt="avatar"/> | |
21 | - <div v-else> | |
22 | - <loading-outlined v-if="loading"></loading-outlined> | |
23 | - <plus-outlined v-else></plus-outlined> | |
24 | - <div class="ant-upload-text">图片上传</div> | |
25 | - </div> | |
26 | - </Upload> | |
27 | - </template> | |
28 | - </BasicForm> | |
29 | - </BasicDrawer> | |
30 | -</template> | |
31 | -<script lang="ts"> | |
32 | - import { defineComponent, ref, computed, unref } from 'vue'; | |
33 | - import { BasicForm, useForm } from '/@/components/Form'; | |
34 | - import { formSchema } from './device.data'; | |
35 | - import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
36 | - import {saveOrEditMessageConfig} from "/@/api/message/config"; | |
37 | - import {useMessage} from "/@/hooks/web/useMessage"; | |
38 | - import {upload} from "/@/api/oss/ossFileUploader"; | |
39 | - import {message, Upload} from "ant-design-vue"; | |
40 | - import {FileItem} from "/@/components/Upload/src/typing"; | |
41 | - | |
42 | - export default defineComponent({ | |
43 | - name: 'DeviceDrawer', | |
44 | - components: { BasicDrawer, BasicForm,Upload }, | |
45 | - emits: ['success', 'register'], | |
46 | - setup(_, { emit }) { | |
47 | - const isUpdate = ref(true); | |
48 | - const devicePic = ref(""); | |
49 | - const [registerForm, { validate,setFieldsValue,resetFields }] = useForm({ | |
50 | - labelWidth: 80, | |
51 | - schemas: formSchema, | |
52 | - showActionButtonGroup: false, | |
53 | - }); | |
54 | - | |
55 | - const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | |
56 | - await resetFields(); | |
57 | - setDrawerProps({ confirmLoading: false }); | |
58 | - isUpdate.value = !!data?.isUpdate; | |
59 | - if (unref(isUpdate)) { | |
60 | - const config = data.record.config; | |
61 | - for (const key in config){ | |
62 | - Reflect.set(data.record, key+'', config[key]); | |
63 | - } | |
64 | - await setFieldsValue({ | |
65 | - ...data.record, | |
66 | - }); | |
67 | - } | |
68 | - }); | |
69 | - | |
70 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增设备' : '编辑设备')); | |
71 | - | |
72 | - async function handleSubmit() { | |
73 | - try { | |
74 | - const values = await validate(); | |
75 | - const { createMessage } = useMessage(); | |
76 | - setDrawerProps({ confirmLoading: true }); | |
77 | - let config={}; | |
78 | - if(values.messageType === 'PHONE_MESSAGE'){ | |
79 | - config ={ | |
80 | - "accessKeyId":values.accessKeyId, | |
81 | - "accessKeySecret":values.accessKeySecret, | |
82 | - } | |
83 | - }else if(values.messageType === 'EMAIL_MESSAGE'){ | |
84 | - config ={ | |
85 | - "host":values.host, | |
86 | - "port":values.port, | |
87 | - "username":values.username, | |
88 | - "password":values.password, | |
89 | - } | |
90 | - } | |
91 | - Reflect.set(values, 'config', config); | |
92 | - let saveMessage = "添加成功"; | |
93 | - let updateMessage = "修改成功"; | |
94 | - await saveOrEditMessageConfig(values, unref(isUpdate)); | |
95 | - closeDrawer(); | |
96 | - emit('success'); | |
97 | - createMessage.success(unref(isUpdate)?updateMessage:saveMessage); | |
98 | - } finally { | |
99 | - setDrawerProps({ confirmLoading: false }); | |
100 | - } | |
101 | - } | |
102 | - async function customUpload({file}) { | |
103 | - if (beforeUpload(file)) { | |
104 | - const formData = new FormData() | |
105 | - formData.append('file', file) | |
106 | - const response = await upload(formData); | |
107 | - if (response.fileStaticUri) { | |
108 | - devicePic.value = response.fileStaticUri; | |
109 | - } | |
110 | - } | |
111 | - } | |
112 | - | |
113 | - const beforeUpload = (file: FileItem) => { | |
114 | - const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; | |
115 | - if (!isJpgOrPng) { | |
116 | - message.error('只能上传图片文件!'); | |
117 | - } | |
118 | - const isLt2M = file.size as number / 1024 / 1024 < 2; | |
119 | - if (!isLt2M) { | |
120 | - message.error('图片大小不能超过2MB!'); | |
121 | - } | |
122 | - return isJpgOrPng && isLt2M; | |
123 | - }; | |
124 | - return { | |
125 | - registerDrawer, | |
126 | - registerForm, | |
127 | - getTitle, | |
128 | - handleSubmit, | |
129 | - beforeUpload, | |
130 | - customUpload, | |
131 | - devicePic | |
132 | - }; | |
133 | - }, | |
134 | - }); | |
135 | -</script> | |
136 | -<style> | |
137 | -.ant-upload-select-picture-card i { | |
138 | - font-size: 32px; | |
139 | - color: #999; | |
140 | -} | |
141 | -</style> |
... | ... | @@ -3,14 +3,14 @@ |
3 | 3 | v-bind="$attrs" |
4 | 4 | width="55rem" |
5 | 5 | @register="register" |
6 | - :title=getTitle | |
6 | + :title="getTitle" | |
7 | 7 | @visible-change="handleVisibleChange" |
8 | + @cancel="handleCancel" | |
8 | 9 | > |
9 | 10 | <div class="step-form-form"> |
10 | 11 | <a-steps :current="current"> |
11 | 12 | <a-step title="填写设备信息" /> |
12 | - <a-step title="确认转账信息" /> | |
13 | - <a-step title="完成" /> | |
13 | + <a-step title="添加设备凭证" /> | |
14 | 14 | </a-steps> |
15 | 15 | </div> |
16 | 16 | <div class="mt-5"> |
... | ... | @@ -21,68 +21,35 @@ |
21 | 21 | v-show="current === 1" |
22 | 22 | v-if="initStep2" |
23 | 23 | /> |
24 | - <DeviceStep3 v-show="current === 2" @redo="handleRedo" v-if="initStep3" /> | |
25 | 24 | </div> |
26 | 25 | </BasicModal> |
27 | 26 | </template> |
28 | 27 | <script lang="ts"> |
29 | -import {defineComponent, ref, nextTick, computed, unref, reactive, toRefs} from 'vue'; | |
28 | + import { defineComponent, ref, nextTick, computed, unref, reactive, toRefs } from 'vue'; | |
30 | 29 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
31 | - import { BasicForm, FormSchema, useForm } from '/@/components/Form'; | |
32 | - import DeviceStep1 from "/@/views/device/step/DeviceStep1.vue"; | |
33 | - import DeviceStep2 from "/@/views/device/step/DeviceStep2.vue"; | |
34 | - import DeviceStep3 from "/@/views/device/step/DeviceStep3.vue"; | |
35 | - import { Steps } from "ant-design-vue"; | |
36 | - const schemas: FormSchema[] = [ | |
37 | - { | |
38 | - field: 'field1', | |
39 | - component: 'Input', | |
40 | - label: '字段1', | |
41 | - colProps: { | |
42 | - span: 24, | |
43 | - }, | |
44 | - defaultValue: '111', | |
45 | - }, | |
46 | - { | |
47 | - field: 'field2', | |
48 | - component: 'Input', | |
49 | - label: '字段2', | |
50 | - colProps: { | |
51 | - span: 24, | |
52 | - }, | |
53 | - }, | |
54 | - ]; | |
30 | + import DeviceStep1 from '/@/views/device/step/DeviceStep1.vue'; | |
31 | + import DeviceStep2 from '/@/views/device/step/DeviceStep2.vue'; | |
32 | + import { Steps } from 'ant-design-vue'; | |
55 | 33 | export default defineComponent({ |
56 | - name:'DeviceModal', | |
57 | - components: { BasicModal, BasicForm, DeviceStep1, DeviceStep2, DeviceStep3, | |
34 | + name: 'DeviceModal', | |
35 | + components: { | |
36 | + BasicModal, | |
37 | + DeviceStep1, | |
38 | + DeviceStep2, | |
58 | 39 | [Steps.name]: Steps, |
59 | - [Steps.Step.name]: Steps.Step, }, | |
40 | + [Steps.Step.name]: Steps.Step, | |
41 | + }, | |
60 | 42 | props: { |
61 | 43 | userData: { type: Object }, |
62 | 44 | }, |
63 | 45 | setup(props) { |
64 | 46 | const state = reactive({ |
65 | 47 | initStep2: false, |
66 | - initStep3: false, | |
67 | 48 | }); |
68 | 49 | const current = ref(0); |
69 | 50 | const isUpdate = ref(true); |
70 | 51 | const modelRef = ref({}); |
71 | 52 | const getTitle = computed(() => (!unref(isUpdate) ? '新增设备' : '编辑设备')); |
72 | - const [ | |
73 | - registerForm, | |
74 | - { | |
75 | - // setFieldsValue, | |
76 | - // setProps | |
77 | - }, | |
78 | - ] = useForm({ | |
79 | - labelWidth: 120, | |
80 | - schemas, | |
81 | - showActionButtonGroup: false, | |
82 | - actionColOptions: { | |
83 | - span: 24, | |
84 | - }, | |
85 | - }); | |
86 | 53 | |
87 | 54 | const [register] = useModalInner((data) => { |
88 | 55 | isUpdate.value = !!data?.isUpdate; |
... | ... | @@ -99,15 +66,15 @@ import {defineComponent, ref, nextTick, computed, unref, reactive, toRefs} from |
99 | 66 | } |
100 | 67 | function handleStep2Next(step2Values: any) { |
101 | 68 | current.value++; |
102 | - state.initStep3 = true; | |
103 | 69 | console.log(step2Values); |
104 | 70 | } |
105 | 71 | function handleRedo() { |
106 | 72 | current.value = 0; |
107 | - state.initSetp2 = false; | |
108 | - state.initSetp3 = false; | |
73 | + state.initStep2 = false; | |
74 | + } | |
75 | + function handleCancel() { | |
76 | + console.log('关闭了弹框'); | |
109 | 77 | } |
110 | - | |
111 | 78 | |
112 | 79 | function onDataReceive(data) { |
113 | 80 | console.log('Data Received', data); |
... | ... | @@ -129,8 +96,19 @@ import {defineComponent, ref, nextTick, computed, unref, reactive, toRefs} from |
129 | 96 | v && props.userData && nextTick(() => onDataReceive(props.userData)); |
130 | 97 | } |
131 | 98 | |
132 | - return { register, schemas, registerForm, model: modelRef, getTitle,handleVisibleChange, | |
133 | - current, ...toRefs(state), handleStepPrev, handleStep1Next, handleStep2Next, handleRedo}; | |
99 | + return { | |
100 | + register, | |
101 | + model: modelRef, | |
102 | + getTitle, | |
103 | + handleVisibleChange, | |
104 | + current, | |
105 | + ...toRefs(state), | |
106 | + handleStepPrev, | |
107 | + handleStep1Next, | |
108 | + handleStep2Next, | |
109 | + handleCancel, | |
110 | + handleRedo, | |
111 | + }; | |
134 | 112 | }, |
135 | 113 | }); |
136 | 114 | </script> | ... | ... |
src/views/device/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 | +import { DeviceTypeEnum, DeviceState } from '/@/api/device/model/deviceModel'; | |
6 | +// 表格列数据 | |
7 | +export const columns: BasicColumn[] = [ | |
8 | + { | |
9 | + title: '设备名称', | |
10 | + dataIndex: 'name', | |
11 | + width: 200, | |
12 | + }, | |
13 | + { | |
14 | + title: '设备类型', | |
15 | + dataIndex: 'deviceType', | |
16 | + width: 200, | |
17 | + slots: { customRender: 'deviceType' }, | |
18 | + }, | |
19 | + { | |
20 | + title: '设备配置', | |
21 | + dataIndex: 'deviceProfile.name', | |
22 | + width: 180, | |
23 | + slots: { customRender: 'deviceProfile' }, | |
24 | + }, | |
25 | + { | |
26 | + title: '标签', | |
27 | + dataIndex: 'label', | |
28 | + width: 180, | |
29 | + }, | |
30 | + { | |
31 | + title: '配置信息', | |
32 | + dataIndex: 'deviceInfo', | |
33 | + width: 180, | |
34 | + slots: { customRender: 'config' }, | |
35 | + }, | |
36 | + { | |
37 | + title: '状态', | |
38 | + dataIndex: 'deviceState', | |
39 | + width: 120, | |
40 | + slots: { customRender: 'deviceState' }, | |
41 | + }, | |
42 | + { | |
43 | + title: '最后连接时间', | |
44 | + dataIndex: 'lastConnectTime', | |
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: 'deviceType', | |
58 | + label: '设备类型', | |
59 | + component: 'Select', | |
60 | + componentProps: { | |
61 | + options: [ | |
62 | + { label: '网关设备', value: DeviceTypeEnum.GATEWAY }, | |
63 | + { label: '直连设备', value: DeviceTypeEnum.DIRECT_CONNECTION }, | |
64 | + { label: '网关子设备', value: DeviceTypeEnum.SENSOR }, | |
65 | + ], | |
66 | + }, | |
67 | + colProps: { span: 4 }, | |
68 | + }, | |
69 | + { | |
70 | + field: 'deviceState', | |
71 | + label: '设备状态', | |
72 | + component: 'Select', | |
73 | + componentProps: { | |
74 | + options: [ | |
75 | + { label: '待激活', value: DeviceState.INACTIVE }, | |
76 | + { label: '在线', value: DeviceState.ONLINE }, | |
77 | + { label: '离线', value: DeviceState.OFFLINE }, | |
78 | + ], | |
79 | + }, | |
80 | + colProps: { span: 4 }, | |
81 | + }, | |
82 | + { | |
83 | + field: 'name', | |
84 | + label: '设备名称', | |
85 | + component: 'Input', | |
86 | + colProps: { span: 8 }, | |
87 | + }, | |
88 | +]; | |
89 | + | |
90 | +// 弹框配置项 | |
91 | +export const formSchema: FormSchema[] = [ | |
92 | + { | |
93 | + field: 'configName', | |
94 | + label: '配置名称', | |
95 | + required: true, | |
96 | + component: 'Input', | |
97 | + }, | |
98 | + { | |
99 | + field: 'messageType', | |
100 | + label: '消息类型', | |
101 | + required: true, | |
102 | + component: 'ApiSelect', | |
103 | + componentProps: { | |
104 | + api: findDictItemByCode, | |
105 | + params: { | |
106 | + dictCode: 'message_type', | |
107 | + }, | |
108 | + labelField: 'itemText', | |
109 | + valueField: 'itemValue', | |
110 | + }, | |
111 | + }, | |
112 | + { | |
113 | + field: 'platformType', | |
114 | + label: '平台类型', | |
115 | + required: true, | |
116 | + component: 'ApiSelect', | |
117 | + componentProps: { | |
118 | + api: findDictItemByCode, | |
119 | + params: { | |
120 | + dictCode: 'platform_type', | |
121 | + }, | |
122 | + labelField: 'itemText', | |
123 | + valueField: 'itemValue', | |
124 | + }, | |
125 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
126 | + }, | |
127 | + { | |
128 | + field: 'accessKeyId', | |
129 | + label: 'accessKeyId', | |
130 | + required: true, | |
131 | + component: 'Input', | |
132 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
133 | + }, | |
134 | + { | |
135 | + field: 'accessKeySecret', | |
136 | + label: 'accessKeySecret', | |
137 | + required: true, | |
138 | + component: 'Input', | |
139 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
140 | + }, | |
141 | + { | |
142 | + field: 'host', | |
143 | + label: '服务器地址', | |
144 | + defaultValue: 'smtp.163.com', | |
145 | + required: true, | |
146 | + component: 'Input', | |
147 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | |
148 | + }, | |
149 | + { | |
150 | + field: 'port', | |
151 | + label: '端口', | |
152 | + defaultValue: 25, | |
153 | + required: true, | |
154 | + component: 'InputNumber', | |
155 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | |
156 | + }, | |
157 | + { | |
158 | + field: 'username', | |
159 | + label: '用户名', | |
160 | + required: true, | |
161 | + component: 'Input', | |
162 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | |
163 | + }, | |
164 | + { | |
165 | + field: 'password', | |
166 | + label: '密码', | |
167 | + required: true, | |
168 | + component: 'InputPassword', | |
169 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | |
170 | + }, | |
171 | + { | |
172 | + field: 'config', | |
173 | + label: '消息配置', | |
174 | + component: 'Input', | |
175 | + show: false, | |
176 | + }, | |
177 | + { | |
178 | + field: 'id', | |
179 | + label: '主键', | |
180 | + component: 'Input', | |
181 | + show: false, | |
182 | + }, | |
183 | + { | |
184 | + field: 'status', | |
185 | + label: '状态', | |
186 | + component: 'RadioButtonGroup', | |
187 | + defaultValue: 0, | |
188 | + componentProps: { | |
189 | + options: [ | |
190 | + { label: '启用', value: 1 }, | |
191 | + { label: '停用', value: 0 }, | |
192 | + ], | |
193 | + }, | |
194 | + }, | |
195 | + { | |
196 | + label: '备注', | |
197 | + field: 'remark', | |
198 | + component: 'InputTextArea', | |
199 | + }, | |
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 | +}; | ... | ... |
1 | 1 | import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | -import {findDictItemByCode} from "/@/api/system/dict"; | |
4 | -import {DeviceTypeEnum,DeviceState} from "/@/api/device/model/deviceModel"; | |
3 | +import { findDictItemByCode } from '/@/api/system/dict'; | |
4 | +import { DeviceTypeEnum, DeviceState } from '/@/api/device/model/deviceModel'; | |
5 | 5 | export const columns: BasicColumn[] = [ |
6 | 6 | { |
7 | 7 | title: '设备名称', |
... | ... | @@ -12,7 +12,7 @@ export const columns: BasicColumn[] = [ |
12 | 12 | title: '设备类型', |
13 | 13 | dataIndex: 'deviceType', |
14 | 14 | width: 100, |
15 | - slots:{customRender:'deviceType'}, | |
15 | + slots: { customRender: 'deviceType' }, | |
16 | 16 | }, |
17 | 17 | { |
18 | 18 | title: '设备配置', |
... | ... | @@ -29,7 +29,7 @@ export const columns: BasicColumn[] = [ |
29 | 29 | { |
30 | 30 | title: '标签', |
31 | 31 | dataIndex: 'label', |
32 | - width: 180 | |
32 | + width: 180, | |
33 | 33 | }, |
34 | 34 | { |
35 | 35 | title: '状态', |
... | ... | @@ -80,7 +80,6 @@ export const searchFormSchema: FormSchema[] = [ |
80 | 80 | }, |
81 | 81 | ]; |
82 | 82 | |
83 | - | |
84 | 83 | export const formSchema: FormSchema[] = [ |
85 | 84 | { |
86 | 85 | field: 'icon', |
... | ... | @@ -92,10 +91,10 @@ export const formSchema: FormSchema[] = [ |
92 | 91 | field: 'name', |
93 | 92 | label: '设备名称', |
94 | 93 | required: true, |
95 | - component:'Input', | |
96 | - componentProps:{ | |
97 | - maxLength:30 | |
98 | - } | |
94 | + component: 'Input', | |
95 | + componentProps: { | |
96 | + maxLength: 30, | |
97 | + }, | |
99 | 98 | }, |
100 | 99 | { |
101 | 100 | field: 'deviceType', |
... | ... | @@ -103,25 +102,25 @@ export const formSchema: FormSchema[] = [ |
103 | 102 | required: true, |
104 | 103 | component: 'ApiSelect', |
105 | 104 | componentProps: { |
106 | - api:findDictItemByCode, | |
107 | - params:{ | |
108 | - dictCode:"device_type" | |
105 | + api: findDictItemByCode, | |
106 | + params: { | |
107 | + dictCode: 'device_type', | |
109 | 108 | }, |
110 | - labelField:'itemText', | |
111 | - valueField:'itemValue', | |
109 | + labelField: 'itemText', | |
110 | + valueField: 'itemValue', | |
112 | 111 | }, |
113 | 112 | }, |
114 | 113 | { |
115 | 114 | field: 'label', |
116 | 115 | label: '设备标签', |
117 | - component:'Input', | |
118 | - componentProps:{ | |
119 | - maxLength:255 | |
120 | - } | |
116 | + component: 'Input', | |
117 | + componentProps: { | |
118 | + maxLength: 255, | |
119 | + }, | |
121 | 120 | }, |
122 | 121 | { |
123 | 122 | label: '备注', |
124 | 123 | field: 'remark', |
125 | 124 | component: 'InputTextArea', |
126 | - } | |
125 | + }, | |
127 | 126 | ]; | ... | ... |
... | ... | @@ -5,148 +5,171 @@ |
5 | 5 | <template #toolbar> |
6 | 6 | <a-button type="primary" @click="handleCreate"> 新增设备 </a-button> |
7 | 7 | </template> |
8 | - <template #deviceProfile="{record}"> | |
9 | - <a-button type="link" class="ml-2" @click="goDeviceProfile"> {{record.deviceProfile.name}} </a-button> | |
8 | + <template #deviceProfile="{ record }"> | |
9 | + <a-button type="link" class="ml-2" @click="goDeviceProfile"> | |
10 | + {{ record.deviceProfile.name }} | |
11 | + </a-button> | |
10 | 12 | </template> |
11 | - <template #organizationId = "{record}"> | |
12 | - {{record.organizationDTO.name}} | |
13 | + <template #organizationId="{ record }"> | |
14 | + {{ record.organizationDTO.name }} | |
13 | 15 | </template> |
14 | - <template #deviceType = "{record}"> | |
16 | + <template #deviceType="{ record }"> | |
15 | 17 | <Tag color="success" class="ml-2"> |
16 | - {{record.deviceType==DeviceTypeEnum.GATEWAY ?'网关设备': | |
17 | - record.deviceType==DeviceTypeEnum.DIRECT_CONNECTION ?'直连设备':'网关子设备'}} | |
18 | + {{ | |
19 | + record.deviceType === DeviceTypeEnum.GATEWAY | |
20 | + ? '网关设备' | |
21 | + : record.deviceType === DeviceTypeEnum.DIRECT_CONNECTION | |
22 | + ? '直连设备' | |
23 | + : '网关子设备' | |
24 | + }} | |
18 | 25 | </Tag> |
19 | 26 | </template> |
20 | - <template #deviceState = "{record}"> | |
21 | - <Tag :color="record.deviceState==DeviceState.INACTIVE?'warning':record.deviceState==DeviceState.ONLINE?'success':'error'" class="ml-2"> | |
22 | - {{record.deviceState==DeviceState.INACTIVE ?'待激活': | |
23 | - record.deviceState==DeviceState.ONLINE ?'在线':'离线'}} | |
27 | + <template #deviceState="{ record }"> | |
28 | + <Tag | |
29 | + :color=" | |
30 | + record.deviceState == DeviceState.INACTIVE | |
31 | + ? 'warning' | |
32 | + : record.deviceState == DeviceState.ONLINE | |
33 | + ? 'success' | |
34 | + : 'error' | |
35 | + " | |
36 | + class="ml-2" | |
37 | + > | |
38 | + {{ | |
39 | + record.deviceState == DeviceState.INACTIVE | |
40 | + ? '待激活' | |
41 | + : record.deviceState == DeviceState.ONLINE | |
42 | + ? '在线' | |
43 | + : '离线' | |
44 | + }} | |
24 | 45 | </Tag> |
25 | 46 | </template> |
26 | 47 | <template #action="{ record }"> |
27 | 48 | <TableAction |
28 | 49 | :actions="[ |
29 | 50 | { |
30 | - label:'编辑', | |
51 | + label: '编辑', | |
31 | 52 | icon: 'clarity:note-edit-line', |
32 | 53 | onClick: handleEdit.bind(null, record), |
33 | 54 | }, |
34 | 55 | { |
35 | - label:'删除', | |
56 | + label: '删除', | |
36 | 57 | icon: 'ant-design:delete-outlined', |
37 | 58 | color: 'error', |
38 | 59 | popConfirm: { |
39 | 60 | title: '是否确认删除', |
40 | 61 | confirm: handleDelete.bind(null, record), |
41 | - } | |
62 | + }, | |
42 | 63 | }, |
43 | 64 | ]" |
44 | 65 | /> |
45 | 66 | </template> |
46 | 67 | </BasicTable> |
47 | - <ConfigDrawer @register="registerDrawer" @success="handleSuccess" /> | |
48 | - <DeviceModal @register="registerModal" @success="handleSuccess"></DeviceModal> | |
68 | + <!-- <ConfigDrawer @register="registerDrawer" @success="handleSuccess" /> --> | |
69 | + <DeviceModal @register="registerModal" @success="handleSuccess" /> | |
49 | 70 | </PageWrapper> |
50 | 71 | </template> |
51 | 72 | <script lang="ts"> |
52 | -import {defineComponent, reactive,} from 'vue'; | |
53 | - import { DeviceState, DeviceTypeEnum } from "/@/api/device/model/deviceModel"; | |
73 | + import { defineComponent, reactive } from 'vue'; | |
74 | + import { DeviceState, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; | |
54 | 75 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
55 | - import { useDrawer } from '/@/components/Drawer'; | |
56 | - import ConfigDrawer from './DeviceDrawer.vue'; | |
76 | + // import { useDrawer } from '/@/components/Drawer'; | |
77 | + // import ConfigDrawer from './DeviceDrawer.vue'; | |
57 | 78 | import { columns, searchFormSchema } from './device.data'; |
58 | 79 | import { Tag } from 'ant-design-vue'; |
59 | - import { CodeEditor } from '/@/components/CodeEditor'; | |
60 | - import { useMessage } from "/@/hooks/web/useMessage"; | |
61 | - import { deleteDevice, devicePage } from "/@/api/device/deviceManager"; | |
62 | - import { PageEnum } from "/@/enums/pageEnum"; | |
63 | - import { useGo } from "/@/hooks/web/usePage"; | |
64 | - import { PageWrapper } from "/@/components/Page"; | |
65 | - import OrganizationIdTree from "/@/views/common/OrganizationIdTree.vue"; | |
66 | - import { useModal } from "/@/components/Modal"; | |
67 | - import DeviceModal from "/@/views/device/DeviceModal.vue"; | |
80 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
81 | + import { deleteDevice, devicePage } from '/@/api/device/deviceManager'; | |
82 | + import { PageEnum } from '/@/enums/pageEnum'; | |
83 | + import { useGo } from '/@/hooks/web/usePage'; | |
84 | + import { PageWrapper } from '/@/components/Page'; | |
85 | + import OrganizationIdTree from '/@/views/common/OrganizationIdTree.vue'; | |
86 | + import { useModal } from '/@/components/Modal'; | |
87 | + import DeviceModal from '/@/views/device/DeviceModal.vue'; | |
68 | 88 | |
89 | + export default defineComponent({ | |
90 | + name: 'DeviceManagement', | |
91 | + components: { | |
92 | + BasicTable, | |
93 | + // ConfigDrawer, | |
94 | + PageWrapper, | |
95 | + TableAction, | |
96 | + OrganizationIdTree, | |
97 | + Tag, | |
98 | + DeviceModal, | |
99 | + }, | |
100 | + setup() { | |
101 | + // const [registerDrawer, { openDrawer }] = useDrawer(); | |
102 | + const { createMessage } = useMessage(); | |
103 | + const go = useGo(); | |
104 | + const searchInfo = reactive<Recordable>({}); | |
105 | + const [registerModal, { openModal }] = useModal(); | |
106 | + const [registerTable, { reload }] = useTable({ | |
107 | + title: '设备列表', | |
108 | + api: devicePage, | |
109 | + columns, | |
110 | + formConfig: { | |
111 | + labelWidth: 120, | |
112 | + schemas: searchFormSchema, | |
113 | + }, | |
114 | + useSearchForm: true, | |
115 | + showTableSetting: true, | |
116 | + bordered: true, | |
117 | + showIndexColumn: false, | |
118 | + searchInfo: searchInfo, | |
119 | + actionColumn: { | |
120 | + width: 180, | |
121 | + title: '操作', | |
122 | + dataIndex: 'action', | |
123 | + slots: { customRender: 'action' }, | |
124 | + fixed: undefined, | |
125 | + }, | |
126 | + }); | |
69 | 127 | |
70 | -export default defineComponent({ | |
71 | - name: 'DeviceManagement', | |
72 | - components: { BasicTable, ConfigDrawer,PageWrapper, TableAction ,OrganizationIdTree,CodeEditor,Tag, | |
73 | - DeviceModal}, | |
74 | - setup() { | |
75 | - const [registerDrawer, { openDrawer }] = useDrawer(); | |
76 | - const {createMessage} = useMessage(); | |
77 | - const go = useGo(); | |
78 | - const searchInfo = reactive<Recordable>({}); | |
79 | - const [registerModal, { openModal }] = useModal(); | |
80 | - const [registerTable, { reload }] = useTable({ | |
81 | - title: '设备列表', | |
82 | - api: devicePage, | |
83 | - columns, | |
84 | - formConfig: { | |
85 | - labelWidth: 120, | |
86 | - schemas: searchFormSchema, | |
87 | - }, | |
88 | - useSearchForm: true, | |
89 | - showTableSetting: true, | |
90 | - bordered: true, | |
91 | - showIndexColumn: false, | |
92 | - searchInfo:searchInfo, | |
93 | - actionColumn: { | |
94 | - width: 180, | |
95 | - title: '操作', | |
96 | - dataIndex: 'action', | |
97 | - slots: { customRender: 'action' }, | |
98 | - fixed: undefined, | |
99 | - }, | |
100 | - }); | |
101 | - | |
102 | - function handleCreate() { | |
103 | - // openDrawer(true, { | |
104 | - // isUpdate: false, | |
105 | - // }); | |
106 | - openModal(true,{ | |
107 | - isUpdate: false, | |
108 | - }) | |
109 | - } | |
128 | + function handleCreate() { | |
129 | + openModal(true, { | |
130 | + isUpdate: false, | |
131 | + }); | |
132 | + } | |
110 | 133 | |
111 | - function handleEdit(record: Recordable) { | |
112 | - openDrawer(true, { | |
113 | - record, | |
114 | - isUpdate: true, | |
115 | - }); | |
116 | - } | |
134 | + function handleEdit(record: Recordable) { | |
135 | + openModal(true, { | |
136 | + isUpdate: true, | |
137 | + record, | |
138 | + }); | |
139 | + } | |
117 | 140 | |
118 | - function handleDelete(record: Recordable) { | |
119 | - let ids = [record.id]; | |
120 | - deleteDevice(ids).then(()=>{ | |
121 | - createMessage.success("删除设备成功") | |
122 | - handleSuccess() | |
123 | - }); | |
124 | - } | |
141 | + function handleDelete(record: Recordable) { | |
142 | + let ids = [record.id]; | |
143 | + deleteDevice(ids).then(() => { | |
144 | + createMessage.success('删除设备成功'); | |
145 | + handleSuccess(); | |
146 | + }); | |
147 | + } | |
125 | 148 | |
126 | - function handleSuccess() { | |
127 | - reload(); | |
128 | - } | |
129 | - function handleSelect(organization) { | |
130 | - searchInfo.organizationId = organization; | |
131 | - handleSuccess(); | |
132 | - } | |
133 | - function goDeviceProfile(){ | |
134 | - go(PageEnum.DEVICE_PROFILE) | |
135 | - } | |
136 | - return { | |
137 | - registerTable, | |
138 | - registerDrawer, | |
139 | - handleCreate, | |
140 | - handleEdit, | |
141 | - handleDelete, | |
142 | - handleSuccess, | |
143 | - goDeviceProfile, | |
144 | - DeviceTypeEnum, | |
145 | - DeviceState, | |
146 | - handleSelect, | |
147 | - searchInfo, | |
148 | - registerModal | |
149 | - }; | |
150 | - }, | |
151 | -}); | |
149 | + function handleSuccess() { | |
150 | + reload(); | |
151 | + } | |
152 | + function handleSelect(organization) { | |
153 | + searchInfo.organizationId = organization; | |
154 | + handleSuccess(); | |
155 | + } | |
156 | + function goDeviceProfile() { | |
157 | + go(PageEnum.DEVICE_PROFILE); | |
158 | + } | |
159 | + return { | |
160 | + registerTable, | |
161 | + // registerDrawer, | |
162 | + handleCreate, | |
163 | + handleEdit, | |
164 | + handleDelete, | |
165 | + handleSuccess, | |
166 | + goDeviceProfile, | |
167 | + DeviceTypeEnum, | |
168 | + DeviceState, | |
169 | + handleSelect, | |
170 | + searchInfo, | |
171 | + registerModal, | |
172 | + }; | |
173 | + }, | |
174 | + }); | |
152 | 175 | </script> | ... | ... |
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | width="500px" |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | - <BasicForm @register="registerForm"/> | |
10 | + <BasicForm @register="registerForm" /> | |
11 | 11 | </BasicDrawer> |
12 | 12 | </template> |
13 | 13 | <script lang="ts"> |
... | ... | @@ -15,8 +15,8 @@ |
15 | 15 | import { BasicForm, useForm } from '/@/components/Form'; |
16 | 16 | import { formSchema } from './device.profile.data'; |
17 | 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 | 21 | export default defineComponent({ |
22 | 22 | name: 'DeviceProfileDrawer', |
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | setup(_, { emit }) { |
26 | 26 | const isUpdate = ref(true); |
27 | 27 | |
28 | - const [registerForm, { validate,setFieldsValue,resetFields }] = useForm({ | |
28 | + const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | |
29 | 29 | labelWidth: 120, |
30 | 30 | schemas: formSchema, |
31 | 31 | showActionButtonGroup: false, |
... | ... | @@ -37,8 +37,8 @@ |
37 | 37 | isUpdate.value = !!data?.isUpdate; |
38 | 38 | if (unref(isUpdate)) { |
39 | 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 | 43 | await setFieldsValue({ |
44 | 44 | ...data.record, |
... | ... | @@ -53,27 +53,27 @@ |
53 | 53 | const values = await validate(); |
54 | 54 | const { createMessage } = useMessage(); |
55 | 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 | 70 | Reflect.set(values, 'config', config); |
71 | - let saveMessage = "添加成功"; | |
72 | - let updateMessage = "修改成功"; | |
71 | + let saveMessage = '添加成功'; | |
72 | + let updateMessage = '修改成功'; | |
73 | 73 | await saveOrEditMessageConfig(values, unref(isUpdate)); |
74 | 74 | closeDrawer(); |
75 | 75 | emit('success'); |
76 | - createMessage.success(unref(isUpdate)?updateMessage:saveMessage); | |
76 | + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); | |
77 | 77 | } finally { |
78 | 78 | setDrawerProps({ confirmLoading: false }); |
79 | 79 | } | ... | ... |
1 | 1 | import { BasicColumn } from '/@/components/Table'; |
2 | 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 | 5 | export const columns: BasicColumn[] = [ |
6 | 6 | { |
7 | 7 | title: '配置名称', |
... | ... | @@ -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 | 44 | export const formSchema: FormSchema[] = [ |
46 | 45 | { |
47 | 46 | field: 'configName', |
48 | 47 | label: '配置名称', |
49 | 48 | required: true, |
50 | - component:'Input' | |
49 | + component: 'Input', | |
51 | 50 | }, |
52 | 51 | { |
53 | 52 | field: 'messageType', |
... | ... | @@ -55,12 +54,12 @@ export const formSchema: FormSchema[] = [ |
55 | 54 | required: true, |
56 | 55 | component: 'ApiSelect', |
57 | 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 | 68 | required: true, |
70 | 69 | component: 'ApiSelect', |
71 | 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 | 81 | field: 'accessKeyId', |
83 | 82 | label: 'accessKeyId', |
84 | 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 | 88 | field: 'accessKeySecret', |
90 | 89 | label: 'accessKeySecret', |
91 | 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 | 95 | field: 'host', |
97 | 96 | label: '服务器地址', |
98 | - defaultValue:'smtp.163.com', | |
97 | + defaultValue: 'smtp.163.com', | |
99 | 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 | 103 | field: 'port', |
105 | 104 | label: '端口', |
106 | 105 | defaultValue: 25, |
107 | 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 | 111 | field: 'username', |
113 | 112 | label: '用户名', |
114 | 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 | 118 | field: 'password', |
120 | 119 | label: '密码', |
121 | 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 | 125 | field: 'config', |
127 | 126 | label: '消息配置', |
128 | - component:'Input', | |
129 | - show:false, | |
127 | + component: 'Input', | |
128 | + show: false, | |
130 | 129 | }, |
131 | 130 | { |
132 | 131 | field: 'id', |
133 | 132 | label: '主键', |
134 | - component:'Input', | |
135 | - show:false, | |
133 | + component: 'Input', | |
134 | + show: false, | |
136 | 135 | }, |
137 | 136 | { |
138 | 137 | field: 'status', |
... | ... | @@ -150,5 +149,5 @@ export const formSchema: FormSchema[] = [ |
150 | 149 | label: '备注', |
151 | 150 | field: 'remark', |
152 | 151 | component: 'InputTextArea', |
153 | - } | |
152 | + }, | |
154 | 153 | ]; | ... | ... |
... | ... | @@ -8,18 +8,18 @@ |
8 | 8 | <TableAction |
9 | 9 | :actions="[ |
10 | 10 | { |
11 | - label:'编辑', | |
11 | + label: '编辑', | |
12 | 12 | icon: 'clarity:note-edit-line', |
13 | 13 | onClick: handleEdit.bind(null, record), |
14 | 14 | }, |
15 | 15 | { |
16 | - label:'删除', | |
16 | + label: '删除', | |
17 | 17 | icon: 'ant-design:delete-outlined', |
18 | 18 | color: 'error', |
19 | 19 | popConfirm: { |
20 | 20 | title: '是否确认删除', |
21 | 21 | confirm: handleDelete.bind(null, record), |
22 | - } | |
22 | + }, | |
23 | 23 | }, |
24 | 24 | ]" |
25 | 25 | /> |
... | ... | @@ -29,71 +29,71 @@ |
29 | 29 | </div> |
30 | 30 | </template> |
31 | 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 | 99 | </script> | ... | ... |
... | ... | @@ -11,38 +11,79 @@ |
11 | 11 | :customRequest="customUpload" |
12 | 12 | :before-upload="beforeUpload" |
13 | 13 | > |
14 | - <img v-if="devicePic" :src="devicePic" alt="avatar"/> | |
14 | + <img v-if="devicePic" :src="devicePic" alt="avatar" /> | |
15 | 15 | <div v-else> |
16 | - <loading-outlined v-if="loading"></loading-outlined> | |
17 | - <plus-outlined v-else></plus-outlined> | |
16 | + <!-- <LoadingOutlined v-if="loading" /> --> | |
17 | + <PlusOutlined /> | |
18 | 18 | <div class="ant-upload-text">图片上传</div> |
19 | 19 | </div> |
20 | 20 | </Upload> |
21 | 21 | </template> |
22 | + <template #devicePosition> | |
23 | + <Input disabled v-model:value="positionState.address"> | |
24 | + <template #addonAfter> | |
25 | + <EnvironmentTwoTone @click="selectPosition" /> | |
26 | + </template> | |
27 | + </Input> | |
28 | + </template> | |
22 | 29 | </BasicForm> |
23 | 30 | </div> |
31 | + <Modal v-model:visible="visible" title="设备位置" @ok="handleOk" width="800px"> | |
32 | + <div> | |
33 | + <a-form :label-col="labelCol"> | |
34 | + <a-row :gutter="20"> | |
35 | + <a-col :span="8"> | |
36 | + <a-form-item label="经度"> | |
37 | + <Input type="input" v-model:value="positionState.lng" disabled /> | |
38 | + </a-form-item> | |
39 | + </a-col> | |
40 | + <a-col :span="8"> | |
41 | + <a-form-item label="纬度"> | |
42 | + <Input type="input" v-model:value="positionState.lat" disabled /> | |
43 | + </a-form-item> | |
44 | + </a-col> | |
45 | + </a-row> | |
46 | + </a-form> | |
47 | + <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div> | |
48 | + </div> | |
49 | + </Modal> | |
24 | 50 | </div> |
25 | 51 | </template> |
26 | 52 | <script lang="ts"> |
27 | -import {defineComponent, ref} from 'vue'; | |
53 | + import { defineComponent, ref, nextTick, unref, reactive } from 'vue'; | |
28 | 54 | import { BasicForm, useForm } from '/@/components/Form'; |
29 | 55 | import { step1Schemas } from './data'; |
30 | - import {Select, Input, Divider, Upload, message} from 'ant-design-vue'; | |
31 | - import {upload} from "/@/api/oss/ossFileUploader"; | |
32 | - import {FileItem} from "/@/components/Upload/src/typing"; | |
56 | + import { useScript } from '/@/hooks/web/useScript'; | |
57 | + import { ScrollActionType } from '/@/components/Container/index'; | |
58 | + import { Input, Divider, Upload, message, Modal, Form, Row, Col } from 'ant-design-vue'; | |
59 | + import { EnvironmentTwoTone, LoadingOutlined, PlusOutlined } from '@ant-design/icons-vue'; | |
60 | + import { upload } from '/@/api/oss/ossFileUploader'; | |
61 | + import { FileItem } from '/@/components/Upload/src/typing'; | |
62 | + | |
33 | 63 | export default defineComponent({ |
34 | 64 | components: { |
35 | 65 | BasicForm, |
36 | - [Select.name]: Select, | |
37 | - ASelectOption: Select.Option, | |
38 | - [Input.name]: Input, | |
66 | + Input, | |
39 | 67 | [Input.Group.name]: Input.Group, |
40 | 68 | [Divider.name]: Divider, |
41 | - Upload | |
69 | + Upload, | |
70 | + EnvironmentTwoTone, | |
71 | + // LoadingOutlined, | |
72 | + PlusOutlined, | |
73 | + Modal, | |
74 | + [Form.name]: Form, | |
75 | + [Form.Item.name]: Form.Item, | |
76 | + [Row.name]: Row, | |
77 | + [Col.name]: Col, | |
42 | 78 | }, |
43 | 79 | emits: ['next'], |
44 | 80 | setup(_, { emit }) { |
45 | - const devicePic = ref(""); | |
81 | + const devicePic = ref(''); | |
82 | + const positionState = reactive({ | |
83 | + lng: '', | |
84 | + lat: '', | |
85 | + address: '', | |
86 | + }); | |
46 | 87 | const [register, { validate }] = useForm({ |
47 | 88 | labelWidth: 100, |
48 | 89 | schemas: step1Schemas, |
... | ... | @@ -58,34 +99,91 @@ import {defineComponent, ref} from 'vue'; |
58 | 99 | |
59 | 100 | async function customSubmitFunc() { |
60 | 101 | try { |
61 | - const values = await validate(); | |
102 | + let values = await validate(); | |
103 | + values = { devicePic: devicePic.value, ...positionState, ...values }; | |
104 | + delete values.icon; | |
105 | + delete values.devicePosition; | |
62 | 106 | emit('next', values); |
107 | + // 获取输入的数据 | |
63 | 108 | } catch (error) {} |
64 | 109 | } |
65 | - async function customUpload({file}) { | |
110 | + // 图片上传 | |
111 | + async function customUpload({ file }) { | |
66 | 112 | if (beforeUpload(file)) { |
67 | - const formData = new FormData() | |
68 | - formData.append('file', file) | |
113 | + const formData = new FormData(); | |
114 | + formData.append('file', file); | |
69 | 115 | const response = await upload(formData); |
70 | 116 | if (response.fileStaticUri) { |
71 | 117 | devicePic.value = response.fileStaticUri; |
72 | 118 | } |
73 | 119 | } |
74 | 120 | } |
75 | - | |
76 | 121 | const beforeUpload = (file: FileItem) => { |
77 | 122 | const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; |
78 | 123 | if (!isJpgOrPng) { |
79 | 124 | message.error('只能上传图片文件!'); |
80 | 125 | } |
81 | - const isLt2M = file.size as number / 1024 / 1024 < 2; | |
126 | + const isLt2M = (file.size as number) / 1024 / 1024 < 2; | |
82 | 127 | if (!isLt2M) { |
83 | 128 | message.error('图片大小不能超过2MB!'); |
84 | 129 | } |
85 | 130 | return isJpgOrPng && isLt2M; |
86 | 131 | }; |
87 | 132 | |
88 | - return { register, beforeUpload, customUpload, devicePic }; | |
133 | + // 地图的弹框 | |
134 | + const visible = ref(false); | |
135 | + const selectPosition = () => { | |
136 | + visible.value = true; | |
137 | + initMap(); | |
138 | + }; | |
139 | + | |
140 | + // 地图 | |
141 | + const BAI_DU_MAP_URL = | |
142 | + 'https://api.map.baidu.com/getscript?v=3.0&ak=7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa'; | |
143 | + const wrapRef = ref<HTMLDivElement | null>(null); | |
144 | + const scrollRef = ref<Nullable<ScrollActionType>>(null); | |
145 | + const { toPromise } = useScript({ src: BAI_DU_MAP_URL }); | |
146 | + async function initMap() { | |
147 | + await toPromise(); | |
148 | + await nextTick(); | |
149 | + const wrapEl = unref(wrapRef); | |
150 | + const BMap = (window as any).BMap; | |
151 | + if (!wrapEl) return; | |
152 | + const map = new BMap.Map(wrapEl); | |
153 | + map.addEventListener('click', () => { | |
154 | + const { lat, lng } = map.he; | |
155 | + positionState.lat = lat + ''; | |
156 | + positionState.lng = lng + ''; | |
157 | + let gc = new BMap.Geocoder(); | |
158 | + let newPoint = new BMap.Point(lng, lat); | |
159 | + gc.getLocation(newPoint, (rs) => { | |
160 | + let addComp = rs.addressComponents; | |
161 | + //获取详细的地址,精确到街道的名称 | |
162 | + let addrname = addComp.city + addComp.district + addComp.street + addComp.streetNumber; | |
163 | + positionState.address = addrname; | |
164 | + }); | |
165 | + }); | |
166 | + const point = new BMap.Point(104.04813399999999, 30.54348986021446); | |
167 | + map.centerAndZoom(point, 15); | |
168 | + map.enableScrollWheelZoom(true); | |
169 | + } | |
170 | + // 确定选择的位置 | |
171 | + const handleOk = () => { | |
172 | + visible.value = false; | |
173 | + }; | |
174 | + return { | |
175 | + positionState, | |
176 | + register, | |
177 | + beforeUpload, | |
178 | + customUpload, | |
179 | + selectPosition, | |
180 | + devicePic, | |
181 | + visible, | |
182 | + scrollRef, | |
183 | + handleOk, | |
184 | + wrapRef, | |
185 | + labelCol: { style: { width: '40px' } }, | |
186 | + }; | |
89 | 187 | }, |
90 | 188 | }); |
91 | 189 | </script> | ... | ... |
1 | 1 | <template> |
2 | 2 | <div class="step2"> |
3 | - <a-alert message="确认转账后,资金将直接打入对方账户,无法退回。" show-icon /> | |
4 | - <a-descriptions :column="1" class="mt-5"> | |
5 | - <a-descriptions-item label="付款账户"> ant-design@alipay.com </a-descriptions-item> | |
6 | - <a-descriptions-item label="收款账户"> test@example.com </a-descriptions-item> | |
7 | - <a-descriptions-item label="收款人姓名"> Vben </a-descriptions-item> | |
8 | - <a-descriptions-item label="转账金额"> 500元 </a-descriptions-item> | |
9 | - </a-descriptions> | |
10 | - <a-divider /> | |
11 | - <BasicForm @register="register" /> | |
3 | + <div><input type="checkbox" v-model="isCreaentials" @click="checked" /> 添加凭证 </div> | |
4 | + | |
5 | + <a-form :label-col="labelCol" :wrapper-col="wrapperCol" v-if="isCreaentials"> | |
6 | + <a-form-item label="凭据类型"> | |
7 | + <a-select | |
8 | + v-model:value="creaentialsType" | |
9 | + style="width: 200px" | |
10 | + @change="handleChange" | |
11 | + placeholder="请选择凭据类型" | |
12 | + :options="options" | |
13 | + /> | |
14 | + </a-form-item> | |
15 | + <div v-if="creaentialsType === 'Access token'"> | |
16 | + <a-form-item label="访问令牌"> | |
17 | + <a-input type="input" style="width: 200px" v-model:value="token" /> | |
18 | + </a-form-item> | |
19 | + </div> | |
20 | + <div v-else-if="creaentialsType === 'X.509'"> | |
21 | + <a-form-item label="RSA公钥"> | |
22 | + <a-input type="input" style="width: 200px" v-model:value="publicKey" /> | |
23 | + </a-form-item> | |
24 | + </div> | |
25 | + <div v-else> | |
26 | + <a-form-item label="客户端ID"> | |
27 | + <a-input type="input" style="width: 200px" v-model:value="clientId" /> | |
28 | + </a-form-item> | |
29 | + <a-form-item label="用户名"> | |
30 | + <a-input type="input" style="width: 200px" v-model:value="username" /> | |
31 | + </a-form-item> | |
32 | + <a-form-item label="密码"> | |
33 | + <a-input type="password" style="width: 200px" v-model:value="password" /> | |
34 | + </a-form-item> | |
35 | + </div> | |
36 | + </a-form> | |
37 | + | |
38 | + <div class="flex justify-start"> | |
39 | + <a-button class="mr-5" @click="prevStep">上一步</a-button> | |
40 | + </div> | |
12 | 41 | </div> |
13 | 42 | </template> |
14 | 43 | <script lang="ts"> |
15 | - import { defineComponent } from 'vue'; | |
16 | - import { BasicForm, useForm } from '/@/components/Form'; | |
17 | - import { step2Schemas } from './data'; | |
18 | - import { Alert, Divider, Descriptions } from 'ant-design-vue'; | |
44 | + import { defineComponent, reactive, ref, toRefs } from 'vue'; | |
19 | 45 | |
46 | + import { Input, Form, Select, Button, SelectProps } from 'ant-design-vue'; | |
20 | 47 | export default defineComponent({ |
21 | 48 | components: { |
22 | - BasicForm, | |
23 | - [Alert.name]: Alert, | |
24 | - [Divider.name]: Divider, | |
25 | - [Descriptions.name]: Descriptions, | |
26 | - [Descriptions.Item.name]: Descriptions.Item, | |
49 | + [Form.name]: Form, | |
50 | + [Form.Item.name]: Form.Item, | |
51 | + [Input.name]: Input, | |
52 | + [Select.name]: Select, | |
53 | + [Button.name]: Button, | |
27 | 54 | }, |
28 | - emits: ['next', 'prev'], | |
55 | + emits: ['prev'], | |
29 | 56 | setup(_, { emit }) { |
30 | - const [register, { validate, setProps }] = useForm({ | |
31 | - labelWidth: 80, | |
32 | - schemas: step2Schemas, | |
33 | - actionColOptions: { | |
34 | - span: 14, | |
57 | + const isCreaentials = ref(false); | |
58 | + const creaentialsType = ref('Access token'); | |
59 | + const creaentialsPassword = reactive({ | |
60 | + token: '', | |
61 | + publicKey: '', | |
62 | + clientId: '', | |
63 | + username: '', | |
64 | + password: '', | |
65 | + }); | |
66 | + const options = ref<SelectProps['options']>([ | |
67 | + { | |
68 | + value: 'Access token', | |
69 | + label: 'Access token', | |
35 | 70 | }, |
36 | - resetButtonOptions: { | |
37 | - text: '上一步', | |
71 | + | |
72 | + { | |
73 | + value: 'X.509', | |
74 | + label: 'X.509', | |
38 | 75 | }, |
39 | - submitButtonOptions: { | |
40 | - text: '提交', | |
76 | + { | |
77 | + value: 'MQTT Basic', | |
78 | + label: 'MQTT Basic', | |
41 | 79 | }, |
42 | - resetFunc: customResetFunc, | |
43 | - submitFunc: customSubmitFunc, | |
44 | - }); | |
45 | - | |
46 | - async function customResetFunc() { | |
80 | + ]); | |
81 | + const checked = () => { | |
82 | + isCreaentials.value = !isCreaentials.value; | |
83 | + }; | |
84 | + const prevStep = () => { | |
47 | 85 | emit('prev'); |
48 | - } | |
49 | - | |
50 | - async function customSubmitFunc() { | |
51 | - try { | |
52 | - const values = await validate(); | |
53 | - setProps({ | |
54 | - submitButtonOptions: { | |
55 | - loading: true, | |
56 | - }, | |
57 | - }); | |
58 | - setTimeout(() => { | |
59 | - setProps({ | |
60 | - submitButtonOptions: { | |
61 | - loading: false, | |
62 | - }, | |
63 | - }); | |
64 | - emit('next', values); | |
65 | - }, 1500); | |
66 | - } catch (error) {} | |
67 | - } | |
68 | - | |
69 | - return { register }; | |
86 | + }; | |
87 | + // 切换凭证类型时,重置字段 | |
88 | + const handleChange = (value) => { | |
89 | + if (value === 'Access token') { | |
90 | + creaentialsPassword.token = ''; | |
91 | + } else if (value === 'X.509') { | |
92 | + creaentialsPassword.publicKey = ''; | |
93 | + } else { | |
94 | + creaentialsPassword.clientId = ''; | |
95 | + creaentialsPassword.username = ''; | |
96 | + creaentialsPassword.password = ''; | |
97 | + } | |
98 | + }; | |
99 | + return { | |
100 | + ...toRefs(creaentialsPassword), | |
101 | + creaentialsType, | |
102 | + isCreaentials, | |
103 | + options, | |
104 | + handleChange, | |
105 | + prevStep, | |
106 | + checked, | |
107 | + labelCol: { style: { width: '150px' } }, | |
108 | + wrapperCol: { span: 18 }, | |
109 | + }; | |
70 | 110 | }, |
71 | 111 | }); |
72 | 112 | </script> |
73 | 113 | <style lang="less" scoped> |
74 | 114 | .step2 { |
75 | - width: 450px; | |
115 | + width: 500px; | |
76 | 116 | margin: 0 auto; |
77 | 117 | } |
78 | 118 | </style> | ... | ... |
src/views/device/step/DeviceStep3.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <div class="step3"> | |
3 | - <a-result status="success" title="操作成功" sub-title="预计两小时内到账"> | |
4 | - <template #extra> | |
5 | - <a-button type="primary" @click="redo"> 再转一笔 </a-button> | |
6 | - <a-button> 查看账单 </a-button> | |
7 | - </template> | |
8 | - </a-result> | |
9 | - <div class="desc-wrap"> | |
10 | - <a-descriptions :column="1" class="mt-5"> | |
11 | - <a-descriptions-item label="付款账户"> ant-design@alipay.com </a-descriptions-item> | |
12 | - <a-descriptions-item label="收款账户"> test@example.com </a-descriptions-item> | |
13 | - <a-descriptions-item label="收款人姓名"> Vben </a-descriptions-item> | |
14 | - <a-descriptions-item label="转账金额"> 500元 </a-descriptions-item> | |
15 | - </a-descriptions> | |
16 | - </div> | |
17 | - </div> | |
18 | -</template> | |
19 | -<script lang="ts"> | |
20 | - import { defineComponent } from 'vue'; | |
21 | - import { Result, Descriptions } from 'ant-design-vue'; | |
22 | - export default defineComponent({ | |
23 | - components: { | |
24 | - [Result.name]: Result, | |
25 | - [Descriptions.name]: Descriptions, | |
26 | - [Descriptions.Item.name]: Descriptions.Item, | |
27 | - }, | |
28 | - emits: ['redo'], | |
29 | - setup(_, { emit }) { | |
30 | - return { | |
31 | - redo: () => { | |
32 | - emit('redo'); | |
33 | - }, | |
34 | - }; | |
35 | - }, | |
36 | - }); | |
37 | -</script> | |
38 | -<style lang="less" scoped> | |
39 | - .step3 { | |
40 | - width: 600px; | |
41 | - margin: 0 auto; | |
42 | - } | |
43 | - | |
44 | - .desc-wrap { | |
45 | - padding: 24px 40px; | |
46 | - margin-top: 24px; | |
47 | - background-color: @background-color-light; | |
48 | - } | |
49 | -</style> |
src/views/device/step/StepIndexDemo.vue
renamed from
src/views/device/step/StepIndex.vue
... | ... | @@ -20,7 +20,6 @@ |
20 | 20 | v-show="current === 1" |
21 | 21 | v-if="initSetp2" |
22 | 22 | /> |
23 | - <Step3 v-show="current === 2" @redo="handleRedo" v-if="initSetp3" /> | |
24 | 23 | </div> |
25 | 24 | </PageWrapper> |
26 | 25 | </template> |
... | ... | @@ -28,7 +27,6 @@ |
28 | 27 | import { defineComponent, ref, reactive, toRefs } from 'vue'; |
29 | 28 | import Step1 from './DeviceStep1.vue'; |
30 | 29 | import Step2 from './DeviceStep2.vue'; |
31 | - import Step3 from './DeviceStep3.vue'; | |
32 | 30 | import { PageWrapper } from '/@/components/Page'; |
33 | 31 | import { Steps } from 'ant-design-vue'; |
34 | 32 | |
... | ... | @@ -37,17 +35,16 @@ |
37 | 35 | components: { |
38 | 36 | Step1, |
39 | 37 | Step2, |
40 | - Step3, | |
38 | + | |
41 | 39 | PageWrapper, |
42 | 40 | [Steps.name]: Steps, |
43 | 41 | [Steps.Step.name]: Steps.Step, |
44 | 42 | }, |
45 | 43 | setup() { |
46 | - const current = ref(0); | |
44 | + const current = ref(1); | |
47 | 45 | |
48 | 46 | const state = reactive({ |
49 | 47 | initSetp2: false, |
50 | - initSetp3: false, | |
51 | 48 | }); |
52 | 49 | |
53 | 50 | function handleStep1Next(step1Values: any) { |
... | ... | @@ -62,14 +59,12 @@ |
62 | 59 | |
63 | 60 | function handleStep2Next(step2Values: any) { |
64 | 61 | current.value++; |
65 | - state.initSetp3 = true; | |
66 | 62 | console.log(step2Values); |
67 | 63 | } |
68 | 64 | |
69 | 65 | function handleRedo() { |
70 | 66 | current.value = 0; |
71 | 67 | state.initSetp2 = false; |
72 | - state.initSetp3 = false; | |
73 | 68 | } |
74 | 69 | |
75 | 70 | return { | ... | ... |
src/views/device/step/data.ts
renamed from
src/views/device/step/data.tsx
1 | 1 | import { FormSchema } from '/@/components/Form'; |
2 | -import {findDictItemByCode} from "/@/api/system/dict"; | |
2 | +import { findDictItemByCode } from '/@/api/system/dict'; | |
3 | 3 | |
4 | 4 | export const step1Schemas: FormSchema[] = [ |
5 | 5 | { |
... | ... | @@ -12,10 +12,10 @@ export const step1Schemas: FormSchema[] = [ |
12 | 12 | field: 'name', |
13 | 13 | label: '设备名称', |
14 | 14 | required: true, |
15 | - component:'Input', | |
16 | - componentProps:{ | |
17 | - maxLength:30 | |
18 | - } | |
15 | + component: 'Input', | |
16 | + componentProps: { | |
17 | + maxLength: 30, | |
18 | + }, | |
19 | 19 | }, |
20 | 20 | { |
21 | 21 | field: 'deviceType', |
... | ... | @@ -23,35 +23,31 @@ export const step1Schemas: FormSchema[] = [ |
23 | 23 | required: true, |
24 | 24 | component: 'ApiSelect', |
25 | 25 | componentProps: { |
26 | - api:findDictItemByCode, | |
27 | - params:{ | |
28 | - dictCode:"device_type" | |
26 | + api: findDictItemByCode, | |
27 | + params: { | |
28 | + dictCode: 'device_type', | |
29 | 29 | }, |
30 | - labelField:'itemText', | |
31 | - valueField:'itemValue', | |
30 | + labelField: 'itemText', | |
31 | + valueField: 'itemValue', | |
32 | 32 | }, |
33 | 33 | }, |
34 | 34 | { |
35 | 35 | field: 'label', |
36 | 36 | label: '设备标签', |
37 | - component:'Input', | |
38 | - componentProps:{ | |
39 | - maxLength:255 | |
40 | - } | |
37 | + component: 'Input', | |
38 | + componentProps: { | |
39 | + maxLength: 255, | |
40 | + }, | |
41 | + }, | |
42 | + { | |
43 | + field: 'devicePosition', | |
44 | + label: '设备位置', | |
45 | + component: 'Input', | |
46 | + slot: 'devicePosition', | |
41 | 47 | }, |
42 | 48 | { |
43 | 49 | label: '备注', |
44 | 50 | field: 'remark', |
45 | 51 | component: 'InputTextArea', |
46 | - } | |
47 | -]; | |
48 | - | |
49 | -export const step2Schemas: FormSchema[] = [ | |
50 | - { | |
51 | - field: 'pwd', | |
52 | - component: 'InputPassword', | |
53 | - label: '支付密码', | |
54 | - required: true, | |
55 | - defaultValue: '123456', | |
56 | 52 | }, |
57 | 53 | ]; | ... | ... |
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | width="500px" |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | - <BasicForm @register="registerForm"/> | |
10 | + <BasicForm @register="registerForm" /> | |
11 | 11 | </BasicDrawer> |
12 | 12 | </template> |
13 | 13 | <script lang="ts"> |
... | ... | @@ -15,8 +15,8 @@ |
15 | 15 | import { BasicForm, useForm } from '/@/components/Form'; |
16 | 16 | import { formSchema } from './config.data'; |
17 | 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 | 21 | export default defineComponent({ |
22 | 22 | name: 'ConfigDrawer', |
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | setup(_, { emit }) { |
26 | 26 | const isUpdate = ref(true); |
27 | 27 | |
28 | - const [registerForm, { validate,setFieldsValue,resetFields }] = useForm({ | |
28 | + const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | |
29 | 29 | labelWidth: 120, |
30 | 30 | schemas: formSchema, |
31 | 31 | showActionButtonGroup: false, |
... | ... | @@ -37,8 +37,8 @@ |
37 | 37 | isUpdate.value = !!data?.isUpdate; |
38 | 38 | if (unref(isUpdate)) { |
39 | 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 | 43 | await setFieldsValue({ |
44 | 44 | ...data.record, |
... | ... | @@ -53,27 +53,27 @@ |
53 | 53 | const values = await validate(); |
54 | 54 | const { createMessage } = useMessage(); |
55 | 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 | 70 | Reflect.set(values, 'config', config); |
71 | - let saveMessage = "添加成功"; | |
72 | - let updateMessage = "修改成功"; | |
71 | + let saveMessage = '添加成功'; | |
72 | + let updateMessage = '修改成功'; | |
73 | 73 | await saveOrEditMessageConfig(values, unref(isUpdate)); |
74 | 74 | closeDrawer(); |
75 | 75 | emit('success'); |
76 | - createMessage.success(unref(isUpdate)?updateMessage:saveMessage); | |
76 | + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); | |
77 | 77 | } finally { |
78 | 78 | setDrawerProps({ confirmLoading: false }); |
79 | 79 | } | ... | ... |
... | ... | @@ -2,10 +2,10 @@ import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | 3 | import { h } from 'vue'; |
4 | 4 | import { Switch } from 'ant-design-vue'; |
5 | -import {setMessageConfigStatus} from "/@/api/message/config"; | |
5 | +import { setMessageConfigStatus } from '/@/api/message/config'; | |
6 | 6 | import { useMessage } from '/@/hooks/web/useMessage'; |
7 | -import {findDictItemByCode} from "/@/api/system/dict"; | |
8 | -import {MessageEnum} from "/@/enums/messageEnum"; | |
7 | +import { findDictItemByCode } from '/@/api/system/dict'; | |
8 | +import { MessageEnum } from '/@/enums/messageEnum'; | |
9 | 9 | export const columns: BasicColumn[] = [ |
10 | 10 | { |
11 | 11 | title: '配置名称', |
... | ... | @@ -45,7 +45,7 @@ export const columns: BasicColumn[] = [ |
45 | 45 | record.pendingStatus = true; |
46 | 46 | const newStatus = checked ? 1 : 0; |
47 | 47 | const { createMessage } = useMessage(); |
48 | - setMessageConfigStatus(record.id, record.messageType,newStatus) | |
48 | + setMessageConfigStatus(record.id, record.messageType, newStatus) | |
49 | 49 | .then(() => { |
50 | 50 | record.status = newStatus; |
51 | 51 | createMessage.success(`修改成功`); |
... | ... | @@ -96,20 +96,19 @@ export const searchFormSchema: FormSchema[] = [ |
96 | 96 | }, |
97 | 97 | ]; |
98 | 98 | |
99 | - | |
100 | -export const isMessage = (type:string)=>{ | |
101 | - return type===MessageEnum.IS_SMS; | |
102 | -} | |
103 | -export const isEmail = (type:string)=>{ | |
104 | - return type===MessageEnum.IS_EMAIL; | |
105 | -} | |
99 | +export const isMessage = (type: string) => { | |
100 | + return type === MessageEnum.IS_SMS; | |
101 | +}; | |
102 | +export const isEmail = (type: string) => { | |
103 | + return type === MessageEnum.IS_EMAIL; | |
104 | +}; | |
106 | 105 | |
107 | 106 | export const formSchema: FormSchema[] = [ |
108 | 107 | { |
109 | 108 | field: 'configName', |
110 | 109 | label: '配置名称', |
111 | 110 | required: true, |
112 | - component:'Input' | |
111 | + component: 'Input', | |
113 | 112 | }, |
114 | 113 | { |
115 | 114 | field: 'messageType', |
... | ... | @@ -117,12 +116,12 @@ export const formSchema: FormSchema[] = [ |
117 | 116 | required: true, |
118 | 117 | component: 'ApiSelect', |
119 | 118 | componentProps: { |
120 | - api:findDictItemByCode, | |
121 | - params:{ | |
122 | - dictCode:"message_type" | |
119 | + api: findDictItemByCode, | |
120 | + params: { | |
121 | + dictCode: 'message_type', | |
123 | 122 | }, |
124 | - labelField:'itemText', | |
125 | - valueField:'itemValue', | |
123 | + labelField: 'itemText', | |
124 | + valueField: 'itemValue', | |
126 | 125 | }, |
127 | 126 | }, |
128 | 127 | { |
... | ... | @@ -131,70 +130,70 @@ export const formSchema: FormSchema[] = [ |
131 | 130 | required: true, |
132 | 131 | component: 'ApiSelect', |
133 | 132 | componentProps: { |
134 | - api:findDictItemByCode, | |
135 | - params:{ | |
136 | - dictCode:"platform_type" | |
133 | + api: findDictItemByCode, | |
134 | + params: { | |
135 | + dictCode: 'platform_type', | |
137 | 136 | }, |
138 | - labelField:'itemText', | |
139 | - valueField:'itemValue', | |
137 | + labelField: 'itemText', | |
138 | + valueField: 'itemValue', | |
140 | 139 | }, |
141 | - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), | |
140 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
142 | 141 | }, |
143 | 142 | { |
144 | 143 | field: 'accessKeyId', |
145 | 144 | label: 'accessKeyId', |
146 | 145 | required: true, |
147 | - component:'Input', | |
148 | - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), | |
146 | + component: 'Input', | |
147 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
149 | 148 | }, |
150 | 149 | { |
151 | 150 | field: 'accessKeySecret', |
152 | 151 | label: 'accessKeySecret', |
153 | 152 | required: true, |
154 | - component:'Input', | |
155 | - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), | |
153 | + component: 'Input', | |
154 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
156 | 155 | }, |
157 | 156 | { |
158 | 157 | field: 'host', |
159 | 158 | label: '服务器地址', |
160 | - defaultValue:'smtp.163.com', | |
159 | + defaultValue: 'smtp.163.com', | |
161 | 160 | required: true, |
162 | - component:'Input', | |
163 | - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), | |
161 | + component: 'Input', | |
162 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | |
164 | 163 | }, |
165 | 164 | { |
166 | 165 | field: 'port', |
167 | 166 | label: '端口', |
168 | 167 | defaultValue: 25, |
169 | 168 | required: true, |
170 | - component:'InputNumber', | |
171 | - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), | |
169 | + component: 'InputNumber', | |
170 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | |
172 | 171 | }, |
173 | 172 | { |
174 | 173 | field: 'username', |
175 | 174 | label: '用户名', |
176 | 175 | required: true, |
177 | - component:'Input', | |
178 | - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), | |
176 | + component: 'Input', | |
177 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | |
179 | 178 | }, |
180 | 179 | { |
181 | 180 | field: 'password', |
182 | 181 | label: '密码', |
183 | 182 | required: true, |
184 | - component:'InputPassword', | |
185 | - ifShow:({values}) => isEmail(Reflect.get(values,'messageType')), | |
183 | + component: 'InputPassword', | |
184 | + ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')), | |
186 | 185 | }, |
187 | 186 | { |
188 | 187 | field: 'config', |
189 | 188 | label: '消息配置', |
190 | - component:'Input', | |
191 | - show:false, | |
189 | + component: 'Input', | |
190 | + show: false, | |
192 | 191 | }, |
193 | 192 | { |
194 | 193 | field: 'id', |
195 | 194 | label: '主键', |
196 | - component:'Input', | |
197 | - show:false, | |
195 | + component: 'Input', | |
196 | + show: false, | |
198 | 197 | }, |
199 | 198 | { |
200 | 199 | field: 'status', |
... | ... | @@ -212,5 +211,5 @@ export const formSchema: FormSchema[] = [ |
212 | 211 | label: '备注', |
213 | 212 | field: 'remark', |
214 | 213 | component: 'InputTextArea', |
215 | - } | |
214 | + }, | |
216 | 215 | ]; | ... | ... |
... | ... | @@ -4,26 +4,26 @@ |
4 | 4 | <template #toolbar> |
5 | 5 | <a-button type="primary" @click="handleCreate"> 新增配置 </a-button> |
6 | 6 | </template> |
7 | - <template #config="{record}"> | |
7 | + <template #config="{ record }"> | |
8 | 8 | <a-button type="link" class="ml-2" @click="showData(record)"> 查看配置 </a-button> |
9 | 9 | </template> |
10 | 10 | <template #action="{ record }"> |
11 | 11 | <TableAction |
12 | 12 | :actions="[ |
13 | 13 | { |
14 | - label:'编辑', | |
14 | + label: '编辑', | |
15 | 15 | icon: 'clarity:note-edit-line', |
16 | 16 | onClick: handleEdit.bind(null, record), |
17 | 17 | }, |
18 | 18 | { |
19 | - label:'删除', | |
19 | + label: '删除', | |
20 | 20 | icon: 'ant-design:delete-outlined', |
21 | 21 | color: 'error', |
22 | 22 | popConfirm: { |
23 | 23 | title: '是否确认删除', |
24 | 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 | 33 | </div> |
34 | 34 | </template> |
35 | 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 | 115 | </script> | ... | ... |
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | </template> |
14 | 14 | |
15 | 15 | <script lang="ts"> |
16 | - import { Tabs, } from 'ant-design-vue'; | |
16 | + import { Tabs } from 'ant-design-vue'; | |
17 | 17 | import { defineComponent } from 'vue'; |
18 | 18 | import SmsLog from './item/SmsLog.vue'; |
19 | 19 | import EmailLog from './item/EmailLog.vue'; | ... | ... |
1 | 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 | 10 | <div class="pt-6px pr-6px"> |
7 | - <BasicForm @register="registerForm"/> | |
11 | + <BasicForm @register="registerForm" /> | |
8 | 12 | </div> |
9 | 13 | </BasicModal> |
10 | 14 | </template> |
11 | 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 | 62 | </script> | ... | ... |
... | ... | @@ -8,12 +8,12 @@ |
8 | 8 | <TableAction |
9 | 9 | :actions="[ |
10 | 10 | { |
11 | - label:'查看', | |
11 | + label: '查看', | |
12 | 12 | icon: 'ant-design:fund-view-outlined', |
13 | 13 | onClick: handleModal.bind(null, record), |
14 | 14 | }, |
15 | 15 | { |
16 | - label:'删除', | |
16 | + label: '删除', | |
17 | 17 | icon: 'ant-design:delete-outlined', |
18 | 18 | color: 'error', |
19 | 19 | popConfirm: { |
... | ... | @@ -25,81 +25,79 @@ |
25 | 25 | /> |
26 | 26 | </template> |
27 | 27 | </BasicTable> |
28 | - <EmailDetail @register="registerModal"/> | |
28 | + <EmailDetail @register="registerModal" /> | |
29 | 29 | </div> |
30 | 30 | </template> |
31 | 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 | 103 | </script> | ... | ... |
... | ... | @@ -8,12 +8,12 @@ |
8 | 8 | <TableAction |
9 | 9 | :actions="[ |
10 | 10 | { |
11 | - label:'查看', | |
11 | + label: '查看', | |
12 | 12 | icon: 'ant-design:fund-view-outlined', |
13 | 13 | onClick: handleQuery.bind(null, record), |
14 | 14 | }, |
15 | 15 | { |
16 | - label:'删除', | |
16 | + label: '删除', | |
17 | 17 | icon: 'ant-design:delete-outlined', |
18 | 18 | color: 'error', |
19 | 19 | popConfirm: { |
... | ... | @@ -28,76 +28,74 @@ |
28 | 28 | </div> |
29 | 29 | </template> |
30 | 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 | 101 | </script> | ... | ... |
1 | 1 | import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | -import {h} from "vue"; | |
4 | -import {Tag} from "ant-design-vue"; | |
5 | -import {useI18n} from "/@/hooks/web/useI18n"; | |
3 | +import { h } from 'vue'; | |
4 | +import { Tag } from 'ant-design-vue'; | |
5 | +import { useI18n } from '/@/hooks/web/useI18n'; | |
6 | 6 | const { t } = useI18n(); |
7 | 7 | export const columns: BasicColumn[] = [ |
8 | 8 | { |
... | ... | @@ -13,7 +13,7 @@ export const columns: BasicColumn[] = [ |
13 | 13 | { |
14 | 14 | title: '收件人', |
15 | 15 | dataIndex: 'emailTo', |
16 | - width:160, | |
16 | + width: 160, | |
17 | 17 | }, |
18 | 18 | { |
19 | 19 | title: '状态', |
... | ... | @@ -23,21 +23,21 @@ export const columns: BasicColumn[] = [ |
23 | 23 | const status = record.status; |
24 | 24 | const success = status === 'SUCCESS'; |
25 | 25 | const color = success ? 'green' : 'red'; |
26 | - let successText:string = t('routes.common.system.tableSuccessStatus'); | |
27 | - let failedText:string = t('routes.common.system.tableFailedStatus'); | |
26 | + let successText: string = t('routes.common.system.tableSuccessStatus'); | |
27 | + let failedText: string = t('routes.common.system.tableFailedStatus'); | |
28 | 28 | const text = success ? successText : failedText; |
29 | 29 | return h(Tag, { color: color }, () => text); |
30 | - } | |
30 | + }, | |
31 | 31 | }, |
32 | 32 | { |
33 | 33 | title: '用途', |
34 | 34 | dataIndex: 'templatePurposeDictText', |
35 | - width:160, | |
35 | + width: 160, | |
36 | 36 | }, |
37 | 37 | { |
38 | 38 | title: '备注', |
39 | 39 | dataIndex: 'remark', |
40 | - width:160, | |
40 | + width: 160, | |
41 | 41 | }, |
42 | 42 | { |
43 | 43 | title: '发送时间', | ... | ... |
1 | 1 | import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | -import {h} from "vue"; | |
4 | -import {Tag} from "ant-design-vue"; | |
5 | -import {useI18n} from "/@/hooks/web/useI18n"; | |
3 | +import { h } from 'vue'; | |
4 | +import { Tag } from 'ant-design-vue'; | |
5 | +import { useI18n } from '/@/hooks/web/useI18n'; | |
6 | 6 | const { t } = useI18n(); |
7 | 7 | export const columns: BasicColumn[] = [ |
8 | 8 | { |
... | ... | @@ -13,7 +13,7 @@ export const columns: BasicColumn[] = [ |
13 | 13 | { |
14 | 14 | title: '短信平台', |
15 | 15 | dataIndex: 'typeDictText', |
16 | - width:180, | |
16 | + width: 180, | |
17 | 17 | }, |
18 | 18 | { |
19 | 19 | title: '用途', |
... | ... | @@ -28,11 +28,11 @@ export const columns: BasicColumn[] = [ |
28 | 28 | const status = record.status; |
29 | 29 | const success = status === 'SUCCESS'; |
30 | 30 | const color = success ? 'green' : 'red'; |
31 | - let successText:string = t('routes.common.system.tableSuccessStatus'); | |
32 | - let failedText:string = t('routes.common.system.tableFailedStatus'); | |
31 | + let successText: string = t('routes.common.system.tableSuccessStatus'); | |
32 | + let failedText: string = t('routes.common.system.tableFailedStatus'); | |
33 | 33 | const text = success ? successText : failedText; |
34 | 34 | return h(Tag, { color: color }, () => text); |
35 | - } | |
35 | + }, | |
36 | 36 | }, |
37 | 37 | { |
38 | 38 | title: '备注', | ... | ... |
1 | 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 | 9 | <div class="pt-6px pr-6px"> |
5 | - <BasicForm @register="registerForm"/> | |
10 | + <BasicForm @register="registerForm" /> | |
6 | 11 | </div> |
7 | 12 | </BasicModal> |
8 | 13 | </template> |
9 | 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 | 132 | </script> | ... | ... |
1 | 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 | 3 | <div class="pt-4px pr-4px"> |
9 | - <BasicForm @register="registerForm"/> | |
4 | + <BasicForm @register="registerForm" /> | |
10 | 5 | </div> |
11 | 6 | </BasicModal> |
12 | 7 | </template> |
13 | 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 | 86 | </script> | ... | ... |
... | ... | @@ -4,11 +4,11 @@ |
4 | 4 | @register="registerDrawer" |
5 | 5 | showFooter |
6 | 6 | :title="getTitle" |
7 | - :helpMessage="['用户登录、忘记密码模板平台只提供{code}参数','初始密码设置平台提供{name}参数']" | |
7 | + :helpMessage="['用户登录、忘记密码模板平台只提供{code}参数', '初始密码设置平台提供{name}参数']" | |
8 | 8 | width="500px" |
9 | 9 | @ok="handleSubmit" |
10 | 10 | > |
11 | - <BasicForm @register="registerForm"/> | |
11 | + <BasicForm @register="registerForm" /> | |
12 | 12 | </BasicDrawer> |
13 | 13 | </template> |
14 | 14 | <script lang="ts"> |
... | ... | @@ -16,15 +16,15 @@ |
16 | 16 | import { BasicForm, useForm } from '/@/components/Form'; |
17 | 17 | import { formSchema } from './template.data'; |
18 | 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 | 21 | export default defineComponent({ |
22 | 22 | name: 'TemplateDrawer', |
23 | 23 | components: { BasicDrawer, BasicForm }, |
24 | 24 | emits: ['success', 'register'], |
25 | 25 | setup(_, { emit }) { |
26 | 26 | const isUpdate = ref(true); |
27 | - const [registerForm, { validate,setFieldsValue,resetFields }] = useForm({ | |
27 | + const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | |
28 | 28 | labelWidth: 120, |
29 | 29 | schemas: formSchema, |
30 | 30 | showActionButtonGroup: false, |
... | ... | @@ -36,8 +36,8 @@ |
36 | 36 | isUpdate.value = !!data?.isUpdate; |
37 | 37 | if (unref(isUpdate)) { |
38 | 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 | 42 | await setFieldsValue({ |
43 | 43 | ...data.record, |
... | ... | @@ -52,27 +52,27 @@ |
52 | 52 | const values = await validate(); |
53 | 53 | const { createMessage } = useMessage(); |
54 | 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 | 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 | 73 | closeDrawer(); |
74 | 74 | emit('success'); |
75 | - createMessage.success(unref(isUpdate)?updateMessage:saveMessage); | |
75 | + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); | |
76 | 76 | } finally { |
77 | 77 | setDrawerProps({ confirmLoading: false }); |
78 | 78 | } | ... | ... |
... | ... | @@ -4,24 +4,26 @@ |
4 | 4 | <template #toolbar> |
5 | 5 | <a-button type="primary" @click="handleCreate"> 新增模板 </a-button> |
6 | 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 | 11 | </template> |
10 | 12 | <template #action="{ record }"> |
11 | 13 | <TableAction |
12 | 14 | :actions="[ |
13 | 15 | { |
14 | - label:'发送', | |
16 | + label: '发送', | |
15 | 17 | icon: 'ant-design:send-outlined', |
16 | 18 | onClick: handleModal.bind(null, record), |
17 | 19 | }, |
18 | 20 | { |
19 | - label:'编辑', | |
21 | + label: '编辑', | |
20 | 22 | icon: 'clarity:note-edit-line', |
21 | 23 | onClick: handleEdit.bind(null, record), |
22 | 24 | }, |
23 | 25 | { |
24 | - label:'删除', | |
26 | + label: '删除', | |
25 | 27 | icon: 'ant-design:delete-outlined', |
26 | 28 | color: 'error', |
27 | 29 | popConfirm: { |
... | ... | @@ -33,119 +35,119 @@ |
33 | 35 | /> |
34 | 36 | </template> |
35 | 37 | </BasicTable> |
36 | - <SendSms @register="registerModal"/> | |
37 | - <SendEmail @register="registerMailModal"/> | |
38 | + <SendSms @register="registerModal" /> | |
39 | + <SendEmail @register="registerMailModal" /> | |
38 | 40 | <TemplateDrawer @register="registerDrawer" @success="handleSuccess" /> |
39 | 41 | </div> |
40 | 42 | </template> |
41 | 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 | 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 | 153 | </script> | ... | ... |
1 | 1 | import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | -import {findDictItemByCode} from "/@/api/system/dict"; | |
4 | -import {findMessageConfig} from "/@/api/message/config"; | |
5 | -import {isMessage} from "/@/views/message/config/config.data"; | |
6 | -import {h} from "vue"; | |
7 | -import {Switch} from "ant-design-vue"; | |
8 | -import {useMessage} from "/@/hooks/web/useMessage"; | |
9 | -import {setMessageTemplateStatus} from "/@/api/message/template"; | |
3 | +import { findDictItemByCode } from '/@/api/system/dict'; | |
4 | +import { findMessageConfig } from '/@/api/message/config'; | |
5 | +import { isMessage } from '/@/views/message/config/config.data'; | |
6 | +import { h } from 'vue'; | |
7 | +import { Switch } from 'ant-design-vue'; | |
8 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
9 | +import { setMessageTemplateStatus } from '/@/api/message/template'; | |
10 | 10 | |
11 | 11 | export const columns: BasicColumn[] = [ |
12 | 12 | { |
... | ... | @@ -31,8 +31,8 @@ export const columns: BasicColumn[] = [ |
31 | 31 | width: 180, |
32 | 32 | }, |
33 | 33 | { |
34 | - title:'模板用途', | |
35 | - dataIndex:'templatePurposeDictText', | |
34 | + title: '模板用途', | |
35 | + dataIndex: 'templatePurposeDictText', | |
36 | 36 | width: 180, |
37 | 37 | }, |
38 | 38 | { |
... | ... | @@ -52,7 +52,7 @@ export const columns: BasicColumn[] = [ |
52 | 52 | record.pendingStatus = true; |
53 | 53 | const newStatus = checked ? 1 : 0; |
54 | 54 | const { createMessage } = useMessage(); |
55 | - setMessageTemplateStatus(record.id,record.templatePurpose,record.messageType,newStatus) | |
55 | + setMessageTemplateStatus(record.id, record.templatePurpose, record.messageType, newStatus) | |
56 | 56 | .then(() => { |
57 | 57 | record.status = newStatus; |
58 | 58 | createMessage.success(`修改成功`); |
... | ... | @@ -68,7 +68,7 @@ export const columns: BasicColumn[] = [ |
68 | 68 | title: '模板用途', |
69 | 69 | dataIndex: 'templatePurpose', |
70 | 70 | width: 180, |
71 | - ifShow:false | |
71 | + ifShow: false, | |
72 | 72 | }, |
73 | 73 | { |
74 | 74 | title: '创建时间', |
... | ... | @@ -96,8 +96,8 @@ export const formSchema: FormSchema[] = [ |
96 | 96 | { |
97 | 97 | field: 'id', |
98 | 98 | label: '主键', |
99 | - component:'Input', | |
100 | - show:false, | |
99 | + component: 'Input', | |
100 | + show: false, | |
101 | 101 | }, |
102 | 102 | { |
103 | 103 | field: 'messageType', |
... | ... | @@ -105,12 +105,12 @@ export const formSchema: FormSchema[] = [ |
105 | 105 | required: true, |
106 | 106 | component: 'ApiSelect', |
107 | 107 | componentProps: { |
108 | - api:findDictItemByCode, | |
109 | - params:{ | |
110 | - dictCode:"message_type" | |
108 | + api: findDictItemByCode, | |
109 | + params: { | |
110 | + dictCode: 'message_type', | |
111 | 111 | }, |
112 | - labelField:'itemText', | |
113 | - valueField:'itemValue', | |
112 | + labelField: 'itemText', | |
113 | + valueField: 'itemValue', | |
114 | 114 | }, |
115 | 115 | }, |
116 | 116 | { |
... | ... | @@ -119,13 +119,13 @@ export const formSchema: FormSchema[] = [ |
119 | 119 | required: true, |
120 | 120 | component: 'ApiSelect', |
121 | 121 | componentProps: { |
122 | - api:findMessageConfig, | |
123 | - params:{ | |
124 | - messageType:({values}) => Reflect.get(values,'messageType') | |
122 | + api: findMessageConfig, | |
123 | + params: { | |
124 | + messageType: ({ values }) => Reflect.get(values, 'messageType'), | |
125 | 125 | }, |
126 | - immediate:true, | |
127 | - labelField:'configName', | |
128 | - valueField:'id', | |
126 | + immediate: true, | |
127 | + labelField: 'configName', | |
128 | + valueField: 'id', | |
129 | 129 | }, |
130 | 130 | }, |
131 | 131 | { |
... | ... | @@ -139,14 +139,14 @@ export const formSchema: FormSchema[] = [ |
139 | 139 | label: '模板编号', |
140 | 140 | required: true, |
141 | 141 | component: 'Input', |
142 | - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), | |
142 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
143 | 143 | }, |
144 | 144 | { |
145 | 145 | field: 'signName', |
146 | 146 | label: '签名', |
147 | - required:true, | |
147 | + required: true, | |
148 | 148 | component: 'Input', |
149 | - ifShow:({values}) => isMessage(Reflect.get(values,'messageType')), | |
149 | + ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
150 | 150 | }, |
151 | 151 | { |
152 | 152 | field: 'templatePurpose', |
... | ... | @@ -155,12 +155,12 @@ export const formSchema: FormSchema[] = [ |
155 | 155 | component: 'ApiSelect', |
156 | 156 | helpMessage: ['用户登录、忘记密码模板平台只提供"code"参数', '初始密码设置平台提供"name"参数'], |
157 | 157 | componentProps: { |
158 | - api:findDictItemByCode, | |
159 | - params:{ | |
160 | - dictCode:"template_purpose" | |
158 | + api: findDictItemByCode, | |
159 | + params: { | |
160 | + dictCode: 'template_purpose', | |
161 | 161 | }, |
162 | - labelField:'itemText', | |
163 | - valueField:'itemValue', | |
162 | + labelField: 'itemText', | |
163 | + valueField: 'itemValue', | |
164 | 164 | }, |
165 | 165 | }, |
166 | 166 | ]; | ... | ... |
... | ... | @@ -16,11 +16,7 @@ |
16 | 16 | <div class="hidden min-h-full pl-4 mr-4 xl:flex xl:flex-col xl:w-6/12"> |
17 | 17 | <AppLogo class="-enter-x" /> |
18 | 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 | 20 | <div class="mt-10 font-medium text-white -enter-x"> |
25 | 21 | <span class="inline-block mt-4 text-3xl"> {{ t('sys.login.signInTitle') }}</span> |
26 | 22 | </div> | ... | ... |
... | ... | @@ -25,8 +25,6 @@ |
25 | 25 | /> |
26 | 26 | </FormItem> |
27 | 27 | |
28 | - | |
29 | - | |
30 | 28 | <FormItem class="enter-x"> |
31 | 29 | <Button type="primary" size="large" block @click="handleLogin" :loading="loading"> |
32 | 30 | {{ t('sys.login.loginButton') }} |
... | ... | @@ -44,10 +42,9 @@ |
44 | 42 | </Button> |
45 | 43 | </ACol> |
46 | 44 | </ARow> |
47 | - <ARow class="enter-x"> | |
45 | + <ARow class="enter-x"> | |
48 | 46 | <ACol :span="12"> |
49 | - <FormItem> | |
50 | - </FormItem> | |
47 | + <FormItem> </FormItem> | |
51 | 48 | </ACol> |
52 | 49 | <ACol :span="12"> |
53 | 50 | <FormItem :style="{ 'text-align': 'right' }"> |
... | ... | @@ -123,9 +120,12 @@ |
123 | 120 | } catch (error) { |
124 | 121 | createErrorModal({ |
125 | 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 | 129 | getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body, |
130 | 130 | }); |
131 | 131 | } finally { | ... | ... |
... | ... | @@ -32,15 +32,15 @@ |
32 | 32 | </template> |
33 | 33 | </template> |
34 | 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 | 37 | import { CountdownInput } from '/@/components/CountDown'; |
38 | 38 | import LoginFormTitle from './LoginFormTitle.vue'; |
39 | 39 | import { useI18n } from '/@/hooks/web/useI18n'; |
40 | 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 | 44 | const { notification, createErrorModal } = useMessage(); |
45 | 45 | |
46 | 46 | const FormItem = Form.Item; |
... | ... | @@ -57,18 +57,18 @@ import {reactive, ref, computed, unref, toRaw} from 'vue'; |
57 | 57 | }); |
58 | 58 | |
59 | 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 | 68 | return true; |
68 | - }else{ | |
69 | + } else { | |
69 | 70 | message.error('请输入正确手机号码'); |
70 | 71 | } |
71 | - | |
72 | 72 | } |
73 | 73 | |
74 | 74 | const { validForm } = useFormValid(formRef); | ... | ... |
1 | 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 | 4 | </PageWrapper> |
12 | 5 | </template> |
13 | 6 | |
... | ... | @@ -16,48 +9,52 @@ |
16 | 9 | import { useRoute } from 'vue-router'; |
17 | 10 | import { PageWrapper } from '/@/components/Page'; |
18 | 11 | import { useGo } from '/@/hooks/web/usePage'; |
19 | - import {Description} from "../../../components/Description"; | |
12 | + import { Description } from '../../../components/Description'; | |
20 | 13 | import { useTabs } from '/@/hooks/web/useTabs'; |
21 | 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 | 18 | const accountData = {}; |
26 | 19 | export default defineComponent({ |
27 | 20 | name: 'AccountDetail', |
28 | - components: { PageWrapper, ATabs: Tabs, ATabPane: Tabs.TabPane,Description }, | |
21 | + components: { PageWrapper, ATabs: Tabs, ATabPane: Tabs.TabPane, Description }, | |
29 | 22 | setup() { |
30 | 23 | const route = useRoute(); |
31 | 24 | const go = useGo(); |
32 | 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 | 48 | // 设置Tab的标题(不会影响页面标题) |
52 | 49 | setTitle('详情:用户' + result.realName); |
53 | - methods.setDescProps(accountData) | |
50 | + methods.setDescProps(accountData); | |
54 | 51 | }); |
55 | 52 | // 页面左侧点击返回链接时的操作 |
56 | 53 | function goBack() { |
57 | 54 | // 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页 |
58 | 55 | go('/system/account'); |
59 | 56 | } |
60 | - return {goBack,accountSchema,accountData,register }; | |
57 | + return { goBack, accountSchema, accountData, register }; | |
61 | 58 | }, |
62 | 59 | }); |
63 | 60 | </script> | ... | ... |
1 | 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 | 9 | <BasicForm @register="registerForm"> |
5 | 10 | <template #organizationId="{ model, field }"> |
6 | 11 | <BasicTree |
... | ... | @@ -17,100 +22,111 @@ |
17 | 22 | </BasicModal> |
18 | 23 | </template> |
19 | 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, getOrganizationList, SaveOrUpdateUserInfo} from '/@/api/system/system'; | |
25 | -import {BasicTree, TreeItem} from "/@/components/Tree"; | |
26 | -import {findCurrentUserGroups} from "/@/api/system/group"; | |
27 | -import {RoleOrOrganizationParam} 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 organizationTreeData = 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 { | |
30 | + findCurrentUserRelation, | |
31 | + getOrganizationList, | |
32 | + SaveOrUpdateUserInfo, | |
33 | + } from '/@/api/system/system'; | |
34 | + import { BasicTree, TreeItem } from '/@/components/Tree'; | |
35 | + import { findCurrentUserGroups } from '/@/api/system/group'; | |
36 | + import { RoleOrOrganizationParam } from '/@/api/system/model/systemModel'; | |
37 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
38 | + export default defineComponent({ | |
39 | + name: 'AccountModal', | |
40 | + components: { BasicModal, BasicForm, BasicTree }, | |
41 | + emits: ['success', 'register'], | |
42 | + setup(_, { emit }) { | |
43 | + const isUpdate = ref(true); | |
44 | + const rowId = ref(''); | |
45 | + const organizationTreeData = ref<TreeItem[]>([]); | |
46 | + const checkGroup = ref<string[]>([]); | |
47 | + const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({ | |
48 | + labelWidth: 100, | |
49 | + schemas: accountFormSchema, | |
50 | + showActionButtonGroup: false, | |
51 | + actionColOptions: { | |
52 | + span: 18, | |
53 | + }, | |
54 | + }); | |
46 | 55 | |
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(organizationTreeData).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 | - organizationTreeData.value = treeValues; | |
64 | - } | |
56 | + const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { | |
57 | + await resetFields(); | |
58 | + setModalProps({ confirmLoading: false }); | |
59 | + isUpdate.value = !!data?.isUpdate; | |
60 | + const groupListModel = await findCurrentUserGroups(); | |
61 | + if (unref(organizationTreeData).length === 0) { | |
62 | + let treeValues = new Array<TreeItem>(); | |
63 | + groupListModel.map((item) => { | |
64 | + const groupData = { | |
65 | + name: item.name, | |
66 | + key: item.id, | |
67 | + id: item.id, | |
68 | + children: item.children as any as TreeItem[], | |
69 | + }; | |
70 | + treeValues.push(groupData); | |
71 | + }); | |
72 | + organizationTreeData.value = treeValues; | |
73 | + } | |
65 | 74 | |
66 | - if (unref(isUpdate)) { | |
67 | - rowId.value = data.record.id; | |
68 | - const roleParams = new RoleOrOrganizationParam(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, | |
75 | + if (unref(isUpdate)) { | |
76 | + rowId.value = data.record.id; | |
77 | + const roleParams = new RoleOrOrganizationParam(rowId.value, true, false); | |
78 | + findCurrentUserRelation(roleParams).then((result) => { | |
79 | + Reflect.set(data.record, 'roleIds', result); | |
80 | + Reflect.set(data.record, 'password', '******'); | |
81 | + setFieldsValue({ | |
82 | + ...data.record, | |
83 | + }); | |
74 | 84 | }); |
75 | - }) | |
76 | - const organizationParams = new RoleOrOrganizationParam(rowId.value,false,true); | |
77 | - checkGroup.value = await findCurrentUserRelation(organizationParams); | |
78 | - } | |
79 | - const deptData = await getOrganizationList(); | |
80 | - await updateSchema([ | |
81 | - { | |
82 | - field: 'username', | |
83 | - dynamicDisabled: unref(isUpdate), | |
84 | - }, | |
85 | - { | |
86 | - field: 'deptId', | |
87 | - componentProps: { | |
88 | - treeData: deptData | |
85 | + const organizationParams = new RoleOrOrganizationParam(rowId.value, false, true); | |
86 | + checkGroup.value = await findCurrentUserRelation(organizationParams); | |
87 | + } | |
88 | + const deptData = await getOrganizationList(); | |
89 | + await updateSchema([ | |
90 | + { | |
91 | + field: 'username', | |
92 | + dynamicDisabled: unref(isUpdate), | |
89 | 93 | }, |
90 | - }, | |
91 | - ]); | |
92 | - }); | |
94 | + { | |
95 | + field: 'deptId', | |
96 | + componentProps: { | |
97 | + treeData: deptData, | |
98 | + }, | |
99 | + }, | |
100 | + ]); | |
101 | + }); | |
93 | 102 | |
94 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增账号' : '编辑账号')); | |
103 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增账号' : '编辑账号')); | |
95 | 104 | |
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}); | |
105 | + async function handleSubmit() { | |
106 | + try { | |
107 | + const { createMessage } = useMessage(); | |
108 | + const values = await validate(); | |
109 | + values.accountExpireTime = | |
110 | + typeof values.accountExpireTime != 'undefined' && values.accountExpireTime != null | |
111 | + ? values.accountExpireTime.format('YYYY-MM-DD HH:mm:ss') | |
112 | + : null; | |
113 | + setModalProps({ confirmLoading: true }); | |
114 | + await SaveOrUpdateUserInfo(values, unref(isUpdate)); | |
115 | + closeModal(); | |
116 | + emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } }); | |
117 | + createMessage.success(unref(isUpdate) ? '编辑成功' : '新增成功'); | |
118 | + } finally { | |
119 | + setModalProps({ confirmLoading: false }); | |
120 | + } | |
110 | 121 | } |
111 | - } | |
112 | - | |
113 | - return {registerModal, registerForm, getTitle, handleSubmit, organizationTreeData,checkGroup}; | |
114 | - }, | |
115 | -}); | |
122 | + return { | |
123 | + registerModal, | |
124 | + registerForm, | |
125 | + getTitle, | |
126 | + handleSubmit, | |
127 | + organizationTreeData, | |
128 | + checkGroup, | |
129 | + }; | |
130 | + }, | |
131 | + }); | |
116 | 132 | </script> | ... | ... |
... | ... | @@ -32,7 +32,7 @@ export const columns: BasicColumn[] = [ |
32 | 32 | title: '状态', |
33 | 33 | dataIndex: 'userStatusEnum', |
34 | 34 | width: 120, |
35 | - slots: {customRender: 'status'} | |
35 | + slots: { customRender: 'status' }, | |
36 | 36 | }, |
37 | 37 | ]; |
38 | 38 | |
... | ... | @@ -56,15 +56,15 @@ export const accountFormSchema: FormSchema[] = [ |
56 | 56 | field: 'id', |
57 | 57 | label: 'id', |
58 | 58 | component: 'Input', |
59 | - show:false | |
59 | + show: false, | |
60 | 60 | }, |
61 | 61 | { |
62 | 62 | field: 'username', |
63 | 63 | label: '用户名', |
64 | 64 | component: 'Input', |
65 | 65 | colProps: { span: 12 }, |
66 | - dynamicDisabled:false, | |
67 | - dynamicRules:({values}) =>{ | |
66 | + dynamicDisabled: false, | |
67 | + dynamicRules: ({ values }) => { | |
68 | 68 | return [ |
69 | 69 | { |
70 | 70 | message: '请输入用户名', |
... | ... | @@ -73,28 +73,26 @@ export const accountFormSchema: FormSchema[] = [ |
73 | 73 | { |
74 | 74 | validator(_, value) { |
75 | 75 | return new Promise((resolve, reject) => { |
76 | - if(value == '') | |
77 | - { | |
76 | + if (value == '') { | |
78 | 77 | reject('请输入用户名'); |
79 | - }else { | |
80 | - if(values.username !=undefined && values.id == undefined){ | |
81 | - isAccountExist(value) | |
82 | - .then((data) => { | |
83 | - if(data.data !=null){ | |
84 | - reject('用户已存在'); | |
85 | - }else{ | |
86 | - resolve() | |
87 | - } | |
88 | - }); | |
89 | - }else{ | |
90 | - resolve() | |
78 | + } else { | |
79 | + if (values.username != undefined && values.id == undefined) { | |
80 | + isAccountExist(value).then((data) => { | |
81 | + if (data.data != null) { | |
82 | + reject('用户已存在'); | |
83 | + } else { | |
84 | + resolve(); | |
85 | + } | |
86 | + }); | |
87 | + } else { | |
88 | + resolve(); | |
91 | 89 | } |
92 | 90 | } |
93 | 91 | }); |
94 | 92 | }, |
95 | 93 | }, |
96 | 94 | ]; |
97 | - } | |
95 | + }, | |
98 | 96 | }, |
99 | 97 | { |
100 | 98 | field: 'password', |
... | ... | @@ -149,10 +147,10 @@ export const accountFormSchema: FormSchema[] = [ |
149 | 147 | label: '有效期: ', |
150 | 148 | component: 'DatePicker', |
151 | 149 | colProps: { span: 12 }, |
152 | - componentProps:{ | |
153 | - showTime:true, | |
154 | - format:'YYYY-MM-DD HH:mm:ss' | |
155 | - } | |
150 | + componentProps: { | |
151 | + showTime: true, | |
152 | + format: 'YYYY-MM-DD HH:mm:ss', | |
153 | + }, | |
156 | 154 | }, |
157 | 155 | { |
158 | 156 | field: 'enabled', |
... | ... | @@ -162,8 +160,8 @@ export const accountFormSchema: FormSchema[] = [ |
162 | 160 | defaultValue: true, |
163 | 161 | componentProps: { |
164 | 162 | options: [ |
165 | - {label: '启用', value: true}, | |
166 | - {label: '禁用', value: false}, | |
163 | + { label: '启用', value: true }, | |
164 | + { label: '禁用', value: false }, | |
167 | 165 | ], |
168 | 166 | }, |
169 | 167 | }, |
... | ... | @@ -171,6 +169,6 @@ export const accountFormSchema: FormSchema[] = [ |
171 | 169 | field: 'organizationIds', |
172 | 170 | label: ' ', |
173 | 171 | component: 'Input', |
174 | - slot:'organizationId', | |
172 | + slot: 'organizationId', | |
175 | 173 | }, |
176 | 174 | ]; | ... | ... |
... | ... | @@ -7,32 +7,42 @@ |
7 | 7 | </template> |
8 | 8 | <template #status="{ record }"> |
9 | 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 | 25 | </Tag> |
15 | 26 | </template> |
16 | 27 | <template #action="{ record }"> |
17 | 28 | <TableAction |
18 | - :actions=" | |
19 | -[ | |
29 | + :actions="[ | |
20 | 30 | { |
21 | - label:'用户详情', | |
31 | + label: '用户详情', | |
22 | 32 | icon: 'clarity:info-standard-line', |
23 | 33 | tooltip: '用户详情', |
24 | 34 | onClick: handleView.bind(null, record), |
25 | 35 | ifShow: record.level != 0, |
26 | 36 | }, |
27 | 37 | { |
28 | - label:'编辑', | |
38 | + label: '编辑', | |
29 | 39 | icon: 'clarity:note-edit-line', |
30 | 40 | tooltip: '编辑', |
31 | 41 | onClick: handleEdit.bind(null, record), |
32 | 42 | ifShow: record.level != 0, |
33 | 43 | }, |
34 | 44 | { |
35 | - label:'删除', | |
45 | + label: '删除', | |
36 | 46 | icon: 'ant-design:delete-outlined', |
37 | 47 | color: 'error', |
38 | 48 | tooltip: '删除', |
... | ... | @@ -52,26 +62,27 @@ |
52 | 62 | <script lang="ts"> |
53 | 63 | import { defineComponent, reactive } from 'vue'; |
54 | 64 | |
55 | - import {TenantCodeEnum} from '/@/enums/codeEnum'; | |
65 | + import { TenantCodeEnum } from '/@/enums/codeEnum'; | |
56 | 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 | 68 | import { PageWrapper } from '/@/components/Page'; |
69 | + | |
59 | 70 | import OrganizationIdTree from '../../common/OrganizationIdTree.vue'; |
60 | - import {Tag} from "ant-design-vue"; | |
71 | + import { Tag } from 'ant-design-vue'; | |
61 | 72 | import { useModal } from '/@/components/Modal'; |
62 | 73 | import AccountModal from './AccountModal.vue'; |
63 | 74 | |
64 | 75 | import { columns, searchFormSchema } from './account.data'; |
65 | 76 | import { useGo } from '/@/hooks/web/usePage'; |
66 | - import {useMessage} from "/@/hooks/web/useMessage"; | |
77 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
67 | 78 | |
68 | 79 | export default defineComponent({ |
69 | 80 | name: 'AccountManagement', |
70 | - components: { BasicTable, PageWrapper, OrganizationIdTree, AccountModal, TableAction,Tag }, | |
81 | + components: { BasicTable, PageWrapper, OrganizationIdTree, AccountModal, TableAction, Tag }, | |
71 | 82 | setup() { |
72 | 83 | const go = useGo(); |
73 | 84 | const [registerModal, { openModal }] = useModal(); |
74 | - const {createMessage} = useMessage(); | |
85 | + const { createMessage } = useMessage(); | |
75 | 86 | const searchInfo = reactive<Recordable>({}); |
76 | 87 | const [registerTable, { reload, updateTableDataRecord }] = useTable({ |
77 | 88 | title: '账号列表', |
... | ... | @@ -113,10 +124,10 @@ |
113 | 124 | |
114 | 125 | function handleDelete(record: Recordable) { |
115 | 126 | let ids = [record.id]; |
116 | - deleteUser(ids).then(()=>{ | |
117 | - createMessage.success("删除成功") | |
127 | + deleteUser(ids).then(() => { | |
128 | + createMessage.success('删除成功'); | |
118 | 129 | reload(); |
119 | - }) | |
130 | + }); | |
120 | 131 | } |
121 | 132 | |
122 | 133 | function handleSuccess({ isUpdate, values }) { |
... | ... | @@ -148,7 +159,7 @@ |
148 | 159 | handleSelect, |
149 | 160 | handleView, |
150 | 161 | searchInfo, |
151 | - TenantCodeEnum | |
162 | + TenantCodeEnum, | |
152 | 163 | }; |
153 | 164 | }, |
154 | 165 | }); | ... | ... |
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | width="500px" |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | - <BasicForm @register="registerForm"/> | |
10 | + <BasicForm @register="registerForm" /> | |
11 | 11 | </BasicDrawer> |
12 | 12 | </template> |
13 | 13 | <script lang="ts"> |
... | ... | @@ -49,18 +49,17 @@ |
49 | 49 | const values = await validate(); |
50 | 50 | const { createMessage } = useMessage(); |
51 | 51 | setDrawerProps({ confirmLoading: true }); |
52 | - let successMessage="添加成功"; | |
52 | + let successMessage = '添加成功'; | |
53 | 53 | //如果是修改需要传入id |
54 | - if(unref(isUpdate)){ | |
55 | - successMessage = "修改成功"; | |
54 | + if (unref(isUpdate)) { | |
55 | + successMessage = '修改成功'; | |
56 | 56 | Reflect.set(values, 'id', id); |
57 | 57 | } |
58 | - await saveOrEditDict(values,unref(isUpdate)).then(() =>{ | |
58 | + await saveOrEditDict(values, unref(isUpdate)).then(() => { | |
59 | 59 | closeDrawer(); |
60 | 60 | emit('success'); |
61 | 61 | createMessage.success(successMessage); |
62 | - }) | |
63 | - | |
62 | + }); | |
64 | 63 | } finally { |
65 | 64 | setDrawerProps({ confirmLoading: false }); |
66 | 65 | } | ... | ... |
... | ... | @@ -25,7 +25,7 @@ export const columns: BasicColumn[] = [ |
25 | 25 | { |
26 | 26 | title: '更新时间', |
27 | 27 | dataIndex: 'updateTime', |
28 | - width: 180 | |
28 | + width: 180, | |
29 | 29 | }, |
30 | 30 | ]; |
31 | 31 | |
... | ... | @@ -49,7 +49,7 @@ export const formSchema: FormSchema[] = [ |
49 | 49 | field: 'dictName', |
50 | 50 | label: '字典名称', |
51 | 51 | required: true, |
52 | - component: 'Input' | |
52 | + component: 'Input', | |
53 | 53 | }, |
54 | 54 | { |
55 | 55 | field: 'dictCode', | ... | ... |
... | ... | @@ -8,17 +8,17 @@ |
8 | 8 | <TableAction |
9 | 9 | :actions="[ |
10 | 10 | { |
11 | - label:'字典值配置', | |
11 | + label: '字典值配置', | |
12 | 12 | icon: 'ant-design:appstore-add-outlined', |
13 | 13 | onClick: handleItem.bind(null, record), |
14 | 14 | }, |
15 | 15 | { |
16 | - label:'编辑', | |
16 | + label: '编辑', | |
17 | 17 | icon: 'clarity:note-edit-line', |
18 | 18 | onClick: handleEdit.bind(null, record), |
19 | 19 | }, |
20 | 20 | { |
21 | - label:'删除', | |
21 | + label: '删除', | |
22 | 22 | icon: 'ant-design:delete-outlined', |
23 | 23 | color: 'error', |
24 | 24 | popConfirm: { |
... | ... | @@ -36,30 +36,30 @@ |
36 | 36 | </template> |
37 | 37 | </BasicTable> |
38 | 38 | <DictDrawer @register="registerDrawer" @success="handleSuccess" /> |
39 | - <ItemIndex @register="registerItemDrawer" @success="handleSuccess"/> | |
39 | + <ItemIndex @register="registerItemDrawer" @success="handleSuccess" /> | |
40 | 40 | </div> |
41 | 41 | </template> |
42 | 42 | <script lang="ts"> |
43 | 43 | import { defineComponent } from 'vue'; |
44 | 44 | |
45 | 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 | 48 | import { useDrawer } from '/@/components/Drawer'; |
49 | 49 | import DictDrawer from './DictDrawer.vue'; |
50 | 50 | import ItemIndex from './item/ItemIndex.vue'; |
51 | 51 | |
52 | 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 | 56 | export default defineComponent({ |
57 | 57 | name: 'DictManagement', |
58 | - components: { BasicTable, DictDrawer,ItemIndex, TableAction ,Tag}, | |
58 | + components: { BasicTable, DictDrawer, ItemIndex, TableAction, Tag }, | |
59 | 59 | setup() { |
60 | 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 | 63 | const [registerTable, { reload }] = useTable({ |
64 | 64 | title: '字典配置列表', |
65 | 65 | api: sysDictPage, |
... | ... | @@ -94,17 +94,17 @@ |
94 | 94 | }); |
95 | 95 | } |
96 | 96 | |
97 | - function handleItem(record: Recordable){ | |
97 | + function handleItem(record: Recordable) { | |
98 | 98 | openItemDrawer(true, { |
99 | - id:record.id, | |
99 | + id: record.id, | |
100 | 100 | }); |
101 | 101 | } |
102 | 102 | |
103 | 103 | function handleDelete(record: Recordable) { |
104 | 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 | width="500px" |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | - <BasicForm @register="registerForm"/> | |
10 | + <BasicForm @register="registerForm" /> | |
11 | 11 | </BasicDrawer> |
12 | 12 | </template> |
13 | 13 | <script lang="ts"> |
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | schemas: formSchema, |
30 | 30 | showActionButtonGroup: false, |
31 | 31 | }); |
32 | - let dictId,id; | |
32 | + let dictId, id; | |
33 | 33 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
34 | 34 | await resetFields(); |
35 | 35 | setDrawerProps({ confirmLoading: false }); |
... | ... | @@ -50,16 +50,16 @@ |
50 | 50 | const values = await validate(); |
51 | 51 | const { createMessage } = useMessage(); |
52 | 52 | setDrawerProps({ confirmLoading: true }); |
53 | - let message="添加成功"; | |
54 | - if(unref(isUpdate)){ | |
53 | + let message = '添加成功'; | |
54 | + if (unref(isUpdate)) { | |
55 | 55 | //如果是修改需要传入id |
56 | 56 | Reflect.set(values, 'id', id); |
57 | - message = "修改成功"; | |
58 | - }else{ | |
57 | + message = '修改成功'; | |
58 | + } else { | |
59 | 59 | //添加需要dictId |
60 | 60 | Reflect.set(values, 'dictId', dictId); |
61 | 61 | } |
62 | - await saveOrEditDictItem(values,unref(isUpdate)); | |
62 | + await saveOrEditDictItem(values, unref(isUpdate)); | |
63 | 63 | closeDrawer(); |
64 | 64 | emit('success'); |
65 | 65 | createMessage.success(message); | ... | ... |
... | ... | @@ -8,22 +8,22 @@ |
8 | 8 | <template #action="{ record }"> |
9 | 9 | <TableAction |
10 | 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 | 28 | </template> |
29 | 29 | </BasicTable> |
... | ... | @@ -35,18 +35,18 @@ |
35 | 35 | import { defineComponent } from 'vue'; |
36 | 36 | |
37 | 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 | 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 | 47 | export default defineComponent({ |
48 | 48 | name: 'ItemIndex', |
49 | - components: {BasicDrawer, BasicTable, ItemDrawer, TableAction ,Tag}, | |
49 | + components: { BasicDrawer, BasicTable, ItemDrawer, TableAction, Tag }, | |
50 | 50 | setup() { |
51 | 51 | let dictId; |
52 | 52 | const { createMessage } = useMessage(); |
... | ... | @@ -73,14 +73,14 @@ |
73 | 73 | slots: { customRender: 'action' }, |
74 | 74 | fixed: undefined, |
75 | 75 | }, |
76 | - beforeFetch:getDictId, | |
77 | - immediate:true | |
76 | + beforeFetch: getDictId, | |
77 | + immediate: true, | |
78 | 78 | }); |
79 | 79 | |
80 | 80 | function handleCreate() { |
81 | 81 | openDrawer(true, { |
82 | 82 | isUpdate: false, |
83 | - dictId:dictId, | |
83 | + dictId: dictId, | |
84 | 84 | }); |
85 | 85 | } |
86 | 86 | |
... | ... | @@ -88,7 +88,7 @@ |
88 | 88 | * 获取父页面传递的dictId值 |
89 | 89 | * @param data 请求之前的参数 |
90 | 90 | */ |
91 | - function getDictId(data){ | |
91 | + function getDictId(data) { | |
92 | 92 | Reflect.set(data, 'dictId', dictId); |
93 | 93 | } |
94 | 94 | |
... | ... | @@ -101,9 +101,9 @@ |
101 | 101 | |
102 | 102 | function handleDelete(record: Recordable) { |
103 | 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 | 118 | handleCreate, |
119 | 119 | handleEdit, |
120 | 120 | handleDelete, |
121 | - handleSuccess | |
121 | + handleSuccess, | |
122 | 122 | }; |
123 | 123 | }, |
124 | 124 | }); | ... | ... |
1 | 1 | import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | -import {h} from "vue"; | |
4 | -import {Switch} from "ant-design-vue"; | |
5 | -import {setDictItemStatus} from "/@/api/system/dict"; | |
6 | -import {useMessage} from "/@/hooks/web/useMessage"; | |
3 | +import { h } from 'vue'; | |
4 | +import { Switch } from 'ant-design-vue'; | |
5 | +import { setDictItemStatus } from '/@/api/system/dict'; | |
6 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
7 | 7 | export const columns: BasicColumn[] = [ |
8 | 8 | { |
9 | 9 | title: '文本值', |
... | ... | @@ -13,7 +13,7 @@ export const columns: BasicColumn[] = [ |
13 | 13 | { |
14 | 14 | title: '字典值', |
15 | 15 | dataIndex: 'itemValue', |
16 | - width:180, | |
16 | + width: 180, | |
17 | 17 | }, |
18 | 18 | { |
19 | 19 | title: '描述', |
... | ... | @@ -37,7 +37,7 @@ export const columns: BasicColumn[] = [ |
37 | 37 | record.pendingStatus = true; |
38 | 38 | const newStatus = checked ? 1 : 0; |
39 | 39 | const { createMessage } = useMessage(); |
40 | - setDictItemStatus(record.id,newStatus) | |
40 | + setDictItemStatus(record.id, newStatus) | |
41 | 41 | .then(() => { |
42 | 42 | record.status = newStatus; |
43 | 43 | createMessage.success(`修改成功`); |
... | ... | @@ -52,7 +52,7 @@ export const columns: BasicColumn[] = [ |
52 | 52 | { |
53 | 53 | title: '排序', |
54 | 54 | dataIndex: 'sort', |
55 | - width: 80 | |
55 | + width: 80, | |
56 | 56 | }, |
57 | 57 | { |
58 | 58 | title: '创建时间', |
... | ... | @@ -72,7 +72,7 @@ export const searchFormSchema: FormSchema[] = [ |
72 | 72 | field: 'dictId', |
73 | 73 | label: '文本值', |
74 | 74 | component: 'Input', |
75 | - show:false, | |
75 | + show: false, | |
76 | 76 | }, |
77 | 77 | ]; |
78 | 78 | |
... | ... | @@ -81,7 +81,7 @@ export const formSchema: FormSchema[] = [ |
81 | 81 | field: 'itemText', |
82 | 82 | label: '文本值', |
83 | 83 | required: true, |
84 | - component: 'Input' | |
84 | + component: 'Input', | |
85 | 85 | }, |
86 | 86 | { |
87 | 87 | field: 'itemValue', |
... | ... | @@ -93,7 +93,7 @@ export const formSchema: FormSchema[] = [ |
93 | 93 | field: 'sort', |
94 | 94 | label: '排序', |
95 | 95 | component: 'InputNumber', |
96 | - defaultValue:1, | |
96 | + defaultValue: 1, | |
97 | 97 | }, |
98 | 98 | { |
99 | 99 | field: 'status', | ... | ... |
... | ... | @@ -7,138 +7,140 @@ |
7 | 7 | width="50%" |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | - <BasicForm @register="registerForm"/> | |
10 | + <BasicForm @register="registerForm" /> | |
11 | 11 | </BasicDrawer> |
12 | 12 | </template> |
13 | 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 | 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 | 146 | </script> | ... | ... |
... | ... | @@ -3,12 +3,12 @@ |
3 | 3 | <!-- register 用于注册 useTable,如果需要使用useTable提供的 api,必须将 register 传入组件的 onRegister--> |
4 | 4 | <!-- @fetch-success接口请求成功后触发 --> |
5 | 5 | <BasicTable @register="registerTable" @fetch-success="onFetchSuccess"> |
6 | - | |
7 | 6 | <!-- 通过模板,加载工具栏 --> |
8 | 7 | <template #toolbar> |
9 | 8 | <a-button type="primary" @click="handleCreate"> |
10 | 9 | {{ getI18nCreateMenu }} |
11 | - </a-button> <!-- 新增菜单--> | |
10 | + </a-button> | |
11 | + <!-- 新增菜单--> | |
12 | 12 | </template> |
13 | 13 | |
14 | 14 | <!-- 表格单项,操作 --> |
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 | icon: 'ant-design:delete-outlined', |
24 | 24 | color: 'error', |
25 | 25 | popConfirm: { |
26 | - title: getDeleteTitle(),//是否确认删除//getDeleteTitle() | |
26 | + title: getDeleteTitle(), //是否确认删除//getDeleteTitle() | |
27 | 27 | confirm: handleDelete.bind(null, record), |
28 | 28 | }, |
29 | 29 | }, |
... | ... | @@ -33,135 +33,135 @@ |
33 | 33 | </BasicTable> |
34 | 34 | |
35 | 35 | <!-- 弹出框 --> |
36 | - <MenuDrawer @register="registerDrawer" @success="handleSuccess"/> | |
36 | + <MenuDrawer @register="registerDrawer" @success="handleSuccess" /> | |
37 | 37 | </div> |
38 | 38 | </template> |
39 | 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 | 167 | </script> | ... | ... |
... | ... | @@ -3,24 +3,24 @@ import { FormSchema } from '/@/components/Table'; |
3 | 3 | import { h } from 'vue'; |
4 | 4 | import { Tag } from 'ant-design-vue'; |
5 | 5 | import { Icon } from '/@/components/Icon'; |
6 | -import {useI18n} from "/@/hooks/web/useI18n"; | |
6 | +import { useI18n } from '/@/hooks/web/useI18n'; | |
7 | 7 | const { t } = useI18n(); |
8 | 8 | |
9 | 9 | //菜单管理页,所需的列 配置 |
10 | 10 | export const columns: BasicColumn[] = [ |
11 | 11 | { |
12 | - title: t('routes.common.system.tableTitleSystemMenuName'),//菜单名称 | |
12 | + title: t('routes.common.system.tableTitleSystemMenuName'), //菜单名称 | |
13 | 13 | // title:'菜单名称', |
14 | 14 | dataIndex: 'meta.title', |
15 | 15 | width: 200, |
16 | 16 | align: 'left', |
17 | 17 | customRender: ({ record }) => { |
18 | - record = t(record.meta.title);//国际化处理 | |
18 | + record = t(record.meta.title); //国际化处理 | |
19 | 19 | return record; |
20 | 20 | }, |
21 | 21 | }, |
22 | 22 | { |
23 | - title: t('routes.common.system.tableTitleSystemIcon'),//图标 | |
23 | + title: t('routes.common.system.tableTitleSystemIcon'), //图标 | |
24 | 24 | // title:'图标', |
25 | 25 | dataIndex: 'meta.icon', |
26 | 26 | width: 50, |
... | ... | @@ -29,24 +29,24 @@ export const columns: BasicColumn[] = [ |
29 | 29 | }, |
30 | 30 | }, |
31 | 31 | { |
32 | - title: t('routes.common.system.tableTitleSystemPermissionTag'),//权限标识 | |
32 | + title: t('routes.common.system.tableTitleSystemPermissionTag'), //权限标识 | |
33 | 33 | // title:'权限标识', |
34 | 34 | dataIndex: 'permission', |
35 | 35 | width: 180, |
36 | 36 | }, |
37 | 37 | { |
38 | - title: t('routes.common.system.tableTitleSystemComponents'),//'组件' | |
38 | + title: t('routes.common.system.tableTitleSystemComponents'), //'组件' | |
39 | 39 | // title:'组件', |
40 | 40 | dataIndex: 'component', |
41 | 41 | }, |
42 | 42 | { |
43 | - title: t('routes.common.system.tableTitleSystemSort'),//'排序' | |
43 | + title: t('routes.common.system.tableTitleSystemSort'), //'排序' | |
44 | 44 | // title:'排序', |
45 | 45 | dataIndex: 'sort', |
46 | 46 | width: 50, |
47 | 47 | }, |
48 | 48 | { |
49 | - title: t('routes.common.system.tableTitleSystemStatus'),//'状态' | |
49 | + title: t('routes.common.system.tableTitleSystemStatus'), //'状态' | |
50 | 50 | // title:'状态', |
51 | 51 | dataIndex: 'status', |
52 | 52 | width: 80, |
... | ... | @@ -54,14 +54,14 @@ export const columns: BasicColumn[] = [ |
54 | 54 | const status = record.meta.status; |
55 | 55 | const enable = ~~status === 0; |
56 | 56 | const color = enable ? 'green' : 'red'; |
57 | - let enableText:string = t('routes.common.system.tableTitleSystemEnable');//国际化处理--启用 | |
58 | - let stopText:string = t('routes.common.system.tableTitleSystemStop');//国际化处理--停用 | |
57 | + let enableText: string = t('routes.common.system.tableTitleSystemEnable'); //国际化处理--启用 | |
58 | + let stopText: string = t('routes.common.system.tableTitleSystemStop'); //国际化处理--停用 | |
59 | 59 | const text = enable ? enableText : stopText; |
60 | 60 | return h(Tag, { color: color }, () => text); |
61 | 61 | }, |
62 | 62 | }, |
63 | 63 | { |
64 | - title: t('routes.common.system.tableTitleSystemCreateTime'),//'创建时间' | |
64 | + title: t('routes.common.system.tableTitleSystemCreateTime'), //'创建时间' | |
65 | 65 | // title:'创建时间', |
66 | 66 | dataIndex: 'createTime', |
67 | 67 | width: 180, |
... | ... | @@ -76,14 +76,14 @@ const isButton = (type: string) => type === '2'; |
76 | 76 | export const searchFormSchema: FormSchema[] = [ |
77 | 77 | { |
78 | 78 | field: 'menuName', |
79 | - label: t('routes.common.system.tableTitleSystemMenuName'),//菜单名称 | |
79 | + label: t('routes.common.system.tableTitleSystemMenuName'), //菜单名称 | |
80 | 80 | // label: '菜单名称', |
81 | 81 | component: 'Input', |
82 | 82 | colProps: { span: 8 }, |
83 | 83 | }, |
84 | 84 | { |
85 | 85 | field: 'status', |
86 | - label: t('routes.common.system.tableTitleSystemStatus'),//状态 | |
86 | + label: t('routes.common.system.tableTitleSystemStatus'), //状态 | |
87 | 87 | // label: '状态', |
88 | 88 | component: 'Select', |
89 | 89 | componentProps: { |
... | ... | @@ -99,38 +99,35 @@ export const searchFormSchema: FormSchema[] = [ |
99 | 99 | }, |
100 | 100 | ]; |
101 | 101 | |
102 | - | |
103 | - | |
104 | - | |
105 | 102 | //----------------------------------新增、编辑---------------------------------------------------------- |
106 | 103 | export const formSchema: FormSchema[] = [ |
107 | 104 | { |
108 | 105 | field: 'menuType', |
109 | - label: t('routes.common.system.menuEditPagesMenuType'),//菜单类型 | |
106 | + label: t('routes.common.system.menuEditPagesMenuType'), //菜单类型 | |
110 | 107 | component: 'RadioButtonGroup', |
111 | 108 | defaultValue: '0', |
112 | 109 | componentProps: { |
113 | 110 | options: [ |
114 | - { label: t('routes.common.system.menuEditPagesDirectory'), value: '0' },//目录 | |
115 | - { label: t('routes.common.system.menuEditPagesMenu'), value: '1' },//菜单 | |
116 | - { label: t('routes.common.system.menuEditPagesButton'), value: '2' },//按钮 | |
111 | + { label: t('routes.common.system.menuEditPagesDirectory'), value: '0' }, //目录 | |
112 | + { label: t('routes.common.system.menuEditPagesMenu'), value: '1' }, //菜单 | |
113 | + { label: t('routes.common.system.menuEditPagesButton'), value: '2' }, //按钮 | |
117 | 114 | ], |
118 | 115 | onChange: (e) => { |
119 | - console.log("--------11111---------------",e); | |
116 | + console.log('--------11111---------------', e); | |
120 | 117 | }, |
121 | 118 | }, |
122 | 119 | colProps: { lg: 24, md: 24 }, |
123 | 120 | }, |
124 | 121 | { |
125 | 122 | field: 'title', |
126 | - label: t('routes.common.system.tableTitleSystemMenuName'),//菜单名称 | |
123 | + label: t('routes.common.system.tableTitleSystemMenuName'), //菜单名称 | |
127 | 124 | component: 'Input', |
128 | 125 | required: true, |
129 | 126 | }, |
130 | 127 | |
131 | 128 | { |
132 | 129 | field: 'parentId', |
133 | - label: t('routes.common.system.menuEditPagesParentMenu'),//上级菜单 | |
130 | + label: t('routes.common.system.menuEditPagesParentMenu'), //上级菜单 | |
134 | 131 | component: 'TreeSelect', |
135 | 132 | componentProps: { |
136 | 133 | replaceFields: { |
... | ... | @@ -144,88 +141,88 @@ export const formSchema: FormSchema[] = [ |
144 | 141 | |
145 | 142 | { |
146 | 143 | field: 'sort', |
147 | - label: t('routes.common.system.tableTitleSystemSort'),//排序 | |
144 | + label: t('routes.common.system.tableTitleSystemSort'), //排序 | |
148 | 145 | component: 'InputNumber', |
149 | 146 | required: true, |
150 | 147 | }, |
151 | 148 | { |
152 | 149 | field: 'icon', |
153 | - label: t('routes.common.system.tableTitleSystemIcon'),//图标 | |
150 | + label: t('routes.common.system.tableTitleSystemIcon'), //图标 | |
154 | 151 | component: 'IconPicker', |
155 | 152 | required: true, |
156 | - ifShow: ({ values }) => !isButton(Reflect.get(values,'menuType')), | |
153 | + ifShow: ({ values }) => !isButton(Reflect.get(values, 'menuType')), | |
157 | 154 | }, |
158 | 155 | |
159 | 156 | { |
160 | 157 | field: 'path', |
161 | - label: t('routes.common.system.menuEditPagesRouterAddress'),//路由地址 | |
158 | + label: t('routes.common.system.menuEditPagesRouterAddress'), //路由地址 | |
162 | 159 | component: 'Input', |
163 | 160 | required: true, |
164 | - ifShow: ({ values }) => !isButton(Reflect.get(values,'menuType')), | |
161 | + ifShow: ({ values }) => !isButton(Reflect.get(values, 'menuType')), | |
165 | 162 | }, |
166 | 163 | { |
167 | 164 | field: 'component', |
168 | - label: t('routes.common.system.menuEditPagesComponentsPath'),//组件路径 | |
165 | + label: t('routes.common.system.menuEditPagesComponentsPath'), //组件路径 | |
169 | 166 | component: 'Input', |
170 | - ifShow: ({ values }) => isMenu(Reflect.get(values,'menuType')), | |
167 | + ifShow: ({ values }) => isMenu(Reflect.get(values, 'menuType')), | |
171 | 168 | }, |
172 | 169 | { |
173 | 170 | field: 'permission', |
174 | - label: t('routes.common.system.tableTitleSystemPermissionTag'),//权限标识 | |
171 | + label: t('routes.common.system.tableTitleSystemPermissionTag'), //权限标识 | |
175 | 172 | component: 'Input', |
176 | - ifShow: ({ values }) => !isDir(Reflect.get(values,'menuType')), | |
173 | + ifShow: ({ values }) => !isDir(Reflect.get(values, 'menuType')), | |
177 | 174 | }, |
178 | 175 | { |
179 | 176 | field: 'status', |
180 | - label: t('routes.common.system.tableTitleSystemStatus'),//状态 | |
177 | + label: t('routes.common.system.tableTitleSystemStatus'), //状态 | |
181 | 178 | component: 'RadioButtonGroup', |
182 | 179 | defaultValue: '0', |
183 | 180 | componentProps: { |
184 | 181 | options: [ |
185 | - { label: t('routes.common.system.tableTitleSystemEnable'), value: '0' },//启用 | |
186 | - { label: t('routes.common.system.tableTitleSystemStop'), value: '1' },//禁用 | |
182 | + { label: t('routes.common.system.tableTitleSystemEnable'), value: '0' }, //启用 | |
183 | + { label: t('routes.common.system.tableTitleSystemStop'), value: '1' }, //禁用 | |
187 | 184 | ], |
188 | 185 | }, |
189 | 186 | }, |
190 | 187 | { |
191 | 188 | field: 'isLink', |
192 | - label: t('routes.common.system.menuEditPagesIsExt'),//是否外链 | |
189 | + label: t('routes.common.system.menuEditPagesIsExt'), //是否外链 | |
193 | 190 | component: 'RadioButtonGroup', |
194 | 191 | defaultValue: false, |
195 | 192 | componentProps: { |
196 | 193 | options: [ |
197 | - { label: t('routes.common.system.menuEditPagesYes'), value: true },//是 | |
198 | - { label: t('routes.common.system.menuEditPagesNo'), value: false },//否 | |
194 | + { label: t('routes.common.system.menuEditPagesYes'), value: true }, //是 | |
195 | + { label: t('routes.common.system.menuEditPagesNo'), value: false }, //否 | |
199 | 196 | ], |
200 | 197 | }, |
201 | - ifShow: ({ values }) => !isButton(Reflect.get(values,'menuType')), | |
198 | + ifShow: ({ values }) => !isButton(Reflect.get(values, 'menuType')), | |
202 | 199 | }, |
203 | 200 | |
204 | 201 | { |
205 | 202 | field: 'ignoreKeepAlive', |
206 | - label: t('routes.common.system.menuEditPagesIsKeepAlive'),//是否缓存 | |
203 | + label: t('routes.common.system.menuEditPagesIsKeepAlive'), //是否缓存 | |
207 | 204 | component: 'RadioButtonGroup', |
208 | 205 | defaultValue: false, |
209 | 206 | componentProps: { |
210 | 207 | options: [ |
211 | - { label: t('routes.common.system.menuEditPagesYes'), value: true },//是 | |
212 | - { label: t('routes.common.system.menuEditPagesNo'), value: false },//否 | |
208 | + { label: t('routes.common.system.menuEditPagesYes'), value: true }, //是 | |
209 | + { label: t('routes.common.system.menuEditPagesNo'), value: false }, //否 | |
213 | 210 | ], |
214 | 211 | }, |
215 | - ifShow: ({ values }) => isMenu(Reflect.get(values,'menuType')), | |
212 | + ifShow: ({ values }) => isMenu(Reflect.get(values, 'menuType')), | |
216 | 213 | }, |
217 | 214 | |
218 | 215 | { |
219 | 216 | field: 'hideMenu', |
220 | - label: t('routes.common.system.menuEditPagesIsHide'),//是否隐藏 | |
217 | + label: t('routes.common.system.menuEditPagesIsHide'), //是否隐藏 | |
221 | 218 | component: 'RadioButtonGroup', |
222 | 219 | defaultValue: false, |
223 | 220 | componentProps: { |
224 | 221 | options: [ |
225 | - { label: t('routes.common.system.menuEditPagesYes'), value: true },//是 | |
226 | - { label: t('routes.common.system.menuEditPagesNo'), value: false },//否 | |
222 | + { label: t('routes.common.system.menuEditPagesYes'), value: true }, //是 | |
223 | + { label: t('routes.common.system.menuEditPagesNo'), value: false }, //否 | |
227 | 224 | ], |
228 | 225 | }, |
229 | - ifShow: ({ values }) => !isButton(Reflect.get(values,'menuType')), | |
226 | + ifShow: ({ values }) => !isButton(Reflect.get(values, 'menuType')), | |
230 | 227 | }, |
231 | 228 | ]; | ... | ... |
... | ... | @@ -7,76 +7,78 @@ |
7 | 7 | width="30%" |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | - <BasicForm @register="registerForm"/> | |
10 | + <BasicForm @register="registerForm" /> | |
11 | 11 | </BasicDrawer> |
12 | 12 | </template> |
13 | 13 | <script lang="ts"> |
14 | -import {defineComponent, ref, computed, unref} from 'vue'; | |
15 | -import {BasicForm, useForm} from '/@/components/Form'; | |
16 | -import {formSchema} from './organization.data'; | |
17 | -import {BasicDrawer, useDrawerInner} from '/@/components/Drawer'; | |
18 | -import {useI18n} from "/@/hooks/web/useI18n"; | |
19 | -import {getOrganizationList, saveOrUpdateOrganization} from "/@/api/system/system"; | |
20 | -export default defineComponent({ | |
21 | - name: 'OrganizationDrawer', | |
22 | - components: {BasicDrawer, BasicForm}, | |
23 | - emits: ['success', 'register'], | |
24 | - setup(_, {emit}) { | |
25 | - const isUpdate = ref(true); | |
26 | - let organizationId; | |
14 | + import { defineComponent, ref, computed, unref } from 'vue'; | |
15 | + import { BasicForm, useForm } from '/@/components/Form'; | |
16 | + import { formSchema } from './organization.data'; | |
17 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
18 | + import { useI18n } from '/@/hooks/web/useI18n'; | |
19 | + import { getOrganizationList, saveOrUpdateOrganization } from '/@/api/system/system'; | |
20 | + export default defineComponent({ | |
21 | + name: 'OrganizationDrawer', | |
22 | + components: { BasicDrawer, BasicForm }, | |
23 | + emits: ['success', 'register'], | |
24 | + setup(_, { emit }) { | |
25 | + const isUpdate = ref(true); | |
26 | + let organizationId; | |
27 | 27 | |
28 | - const [registerForm, {resetFields, setFieldsValue, updateSchema, validate}] = useForm({ | |
29 | - labelWidth: 100, | |
30 | - schemas: formSchema, | |
31 | - showActionButtonGroup: false | |
32 | - }); | |
33 | - const {t} = useI18n(); //加载国际化 | |
28 | + const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({ | |
29 | + labelWidth: 100, | |
30 | + schemas: formSchema, | |
31 | + showActionButtonGroup: false, | |
32 | + }); | |
33 | + const { t } = useI18n(); //加载国际化 | |
34 | 34 | |
35 | - //默认传递页面数据 | |
36 | - const [registerDrawer, {setDrawerProps, closeDrawer}] = useDrawerInner(async (data) => { | |
37 | - await resetFields(); | |
38 | - setDrawerProps({confirmLoading: false}); | |
39 | - isUpdate.value = !!data?.isUpdate; | |
35 | + //默认传递页面数据 | |
36 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | |
37 | + await resetFields(); | |
38 | + setDrawerProps({ confirmLoading: false }); | |
39 | + isUpdate.value = !!data?.isUpdate; | |
40 | 40 | |
41 | - //如果是编辑操作,设置页面数据 | |
42 | - if (unref(isUpdate)) { | |
43 | - //为表单赋值 | |
44 | - await setFieldsValue({ | |
45 | - ...data.record, | |
41 | + //如果是编辑操作,设置页面数据 | |
42 | + if (unref(isUpdate)) { | |
43 | + //为表单赋值 | |
44 | + await setFieldsValue({ | |
45 | + ...data.record, | |
46 | + }); | |
47 | + } | |
48 | + if (isUpdate.value) { | |
49 | + organizationId = Reflect.get(data.record, 'id'); | |
50 | + } | |
51 | + let treeData = await getOrganizationList(); | |
52 | + await updateSchema({ | |
53 | + field: 'parentId', | |
54 | + componentProps: { treeData }, | |
46 | 55 | }); |
47 | - | |
48 | - } | |
49 | - if (isUpdate.value) { | |
50 | - organizationId = Reflect.get(data.record, 'id'); | |
51 | - } | |
52 | - let treeData = await getOrganizationList(); | |
53 | - await updateSchema({ | |
54 | - field: 'parentId', | |
55 | - componentProps: {treeData}, | |
56 | 56 | }); |
57 | - }); | |
58 | 57 | |
59 | - //得到页面标题 | |
60 | - const getTitle = computed(() => (!unref(isUpdate) ? t('routes.common.organization.toolCreateOrganization') : t('routes.common.organization.toolEditOrganization'))); | |
58 | + //得到页面标题 | |
59 | + const getTitle = computed(() => | |
60 | + !unref(isUpdate) | |
61 | + ? t('routes.common.organization.toolCreateOrganization') | |
62 | + : t('routes.common.organization.toolEditOrganization') | |
63 | + ); | |
61 | 64 | |
62 | - //提交按钮 | |
63 | - async function handleSubmit() { | |
64 | - try { | |
65 | - const values = await validate(); | |
66 | - setDrawerProps({confirmLoading: true}); | |
67 | - | |
68 | - if (isUpdate.value) { | |
69 | - Reflect.set(values, 'id', organizationId); | |
65 | + //提交按钮 | |
66 | + async function handleSubmit() { | |
67 | + try { | |
68 | + const values = await validate(); | |
69 | + setDrawerProps({ confirmLoading: true }); | |
70 | + if (isUpdate.value) { | |
71 | + Reflect.set(values, 'id', organizationId); | |
72 | + } | |
73 | + await saveOrUpdateOrganization(values, isUpdate.value); | |
74 | + closeDrawer(); //关闭侧框 | |
75 | + emit('success'); | |
76 | + } finally { | |
77 | + setDrawerProps({ confirmLoading: false }); | |
70 | 78 | } |
71 | - await saveOrUpdateOrganization(values, isUpdate.value); | |
72 | - closeDrawer();//关闭侧框 | |
73 | - emit('success'); | |
74 | - } finally { | |
75 | - setDrawerProps({confirmLoading: false}); | |
76 | 79 | } |
77 | - } | |
78 | 80 | |
79 | - return {registerDrawer, registerForm, getTitle, handleSubmit}; | |
80 | - }, | |
81 | -}); | |
81 | + return { registerDrawer, registerForm, getTitle, handleSubmit }; | |
82 | + }, | |
83 | + }); | |
82 | 84 | </script> | ... | ... |
... | ... | @@ -10,16 +10,16 @@ |
10 | 10 | <TableAction |
11 | 11 | :actions="[ |
12 | 12 | { |
13 | - label:'编辑', | |
13 | + label: '编辑', | |
14 | 14 | icon: 'clarity:note-edit-line', |
15 | 15 | onClick: handleEdit.bind(null, record), |
16 | 16 | }, |
17 | 17 | { |
18 | - label:'删除', | |
18 | + label: '删除', | |
19 | 19 | icon: 'ant-design:delete-outlined', |
20 | 20 | color: 'error', |
21 | 21 | popConfirm: { |
22 | - title: getDeleteTitle(),//是否确认删除//getDeleteTitle() | |
22 | + title: getDeleteTitle(), //是否确认删除//getDeleteTitle() | |
23 | 23 | confirm: handleDelete.bind(null, record), |
24 | 24 | }, |
25 | 25 | }, |
... | ... | @@ -31,27 +31,28 @@ |
31 | 31 | </div> |
32 | 32 | </template> |
33 | 33 | <script lang="ts"> |
34 | - import {computed, defineComponent, nextTick} from 'vue'; | |
34 | + import { computed, defineComponent, nextTick } from 'vue'; | |
35 | 35 | |
36 | 36 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
37 | 37 | |
38 | 38 | // 加载自定义侧边弹出框 组件 |
39 | - import {useDrawer} from '/@/components/Drawer'; | |
39 | + | |
40 | + import { useDrawer } from '/@/components/Drawer'; | |
40 | 41 | import DeptDrawer from './OrganizationDrawer.vue'; |
41 | 42 | import { columns } from './organization.data'; |
42 | - import {useI18n} from "/@/hooks/web/useI18n"; | |
43 | - import {delOrganization, getOrganizationList} from "/@/api/system/system"; | |
44 | - import {useMessage} from "/@/hooks/web/useMessage"; | |
43 | + import { useI18n } from '/@/hooks/web/useI18n'; | |
44 | + import { delOrganization, getOrganizationList } from '/@/api/system/system'; | |
45 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
45 | 46 | |
46 | 47 | export default defineComponent({ |
47 | 48 | name: 'DeptManagement', |
48 | 49 | components: { BasicTable, DeptDrawer, TableAction }, |
49 | 50 | setup() { |
50 | 51 | const [registerModal, { openDrawer }] = useDrawer(); |
51 | - const {t} = useI18n(); //加载国际化 | |
52 | + const { t } = useI18n(); //加载国际化 | |
52 | 53 | const getI18n = computed(() => t('routes.common.organization.toolCreateOrganization')); |
53 | - const {createMessage} = useMessage(); | |
54 | - const [registerTable, { reload,expandAll }] = useTable({ | |
54 | + const { createMessage } = useMessage(); | |
55 | + const [registerTable, { reload, expandAll }] = useTable({ | |
55 | 56 | title: t('routes.common.organization.toolOrganizationList'), |
56 | 57 | api: getOrganizationList, |
57 | 58 | columns, |
... | ... | @@ -65,7 +66,7 @@ |
65 | 66 | canResize: false, |
66 | 67 | actionColumn: { |
67 | 68 | width: 80, |
68 | - title: t('routes.common.common.operation'),//操作 | |
69 | + title: t('routes.common.common.operation'), //操作 | |
69 | 70 | dataIndex: 'action', |
70 | 71 | slots: { customRender: 'action' }, |
71 | 72 | fixed: undefined, |
... | ... | @@ -76,7 +77,7 @@ |
76 | 77 | */ |
77 | 78 | function getDeleteTitle(): string { |
78 | 79 | let labelText = t('routes.common.system.pageSystemTitleWhetherDelete'); |
79 | - return labelText | |
80 | + return labelText; | |
80 | 81 | } |
81 | 82 | |
82 | 83 | function handleCreate() { |
... | ... | @@ -95,9 +96,9 @@ |
95 | 96 | async function handleDelete(record: Recordable) { |
96 | 97 | // console.log(record); |
97 | 98 | try { |
98 | - let ids = [record.id,]; | |
99 | - await delOrganization(ids).then(()=>{ | |
100 | - createMessage.success("删除组织成功"); | |
99 | + let ids = [record.id]; | |
100 | + await delOrganization(ids).then(() => { | |
101 | + createMessage.success('删除组织成功'); | |
101 | 102 | handleSuccess(); |
102 | 103 | }); |
103 | 104 | } catch (e) { |
... | ... | @@ -115,9 +116,9 @@ |
115 | 116 | } |
116 | 117 | |
117 | 118 | return { |
119 | + getI18n, | |
118 | 120 | registerTable, |
119 | 121 | registerModal, |
120 | - getI18n, | |
121 | 122 | getDeleteTitle, |
122 | 123 | handleCreate, |
123 | 124 | handleEdit, | ... | ... |
1 | 1 | import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | -import {useI18n} from "/@/hooks/web/useI18n"; | |
3 | +import { useI18n } from '/@/hooks/web/useI18n'; | |
4 | 4 | const { t } = useI18n(); |
5 | 5 | |
6 | 6 | export const columns: BasicColumn[] = [ |
... | ... | @@ -11,17 +11,17 @@ export const columns: BasicColumn[] = [ |
11 | 11 | align: 'left', |
12 | 12 | }, |
13 | 13 | { |
14 | - title: t('routes.common.common.sort'),//排序 | |
14 | + title: t('routes.common.common.sort'), //排序 | |
15 | 15 | dataIndex: 'sort', |
16 | 16 | width: 50, |
17 | 17 | }, |
18 | 18 | { |
19 | - title: t('routes.common.common.createTime'),//创建时间 | |
19 | + title: t('routes.common.common.createTime'), //创建时间 | |
20 | 20 | dataIndex: 'createTime', |
21 | 21 | width: 180, |
22 | 22 | }, |
23 | 23 | { |
24 | - title: t('routes.common.common.remark'),//备注 | |
24 | + title: t('routes.common.common.remark'), //备注 | |
25 | 25 | dataIndex: 'remark', |
26 | 26 | width: 300, |
27 | 27 | }, |
... | ... | @@ -49,12 +49,12 @@ export const formSchema: FormSchema[] = [ |
49 | 49 | }, |
50 | 50 | { |
51 | 51 | field: 'sort', |
52 | - label: t('routes.common.common.sort'),//排序 | |
52 | + label: t('routes.common.common.sort'), //排序 | |
53 | 53 | component: 'InputNumber', |
54 | 54 | required: true, |
55 | 55 | }, |
56 | 56 | { |
57 | - label: t('routes.common.common.remark'),//备注 | |
57 | + label: t('routes.common.common.remark'), //备注 | |
58 | 58 | field: 'remark', |
59 | 59 | component: 'InputTextArea', |
60 | 60 | }, | ... | ... |
... | ... | @@ -13,15 +13,15 @@ |
13 | 13 | import { defineComponent } from 'vue'; |
14 | 14 | import { PageWrapper } from '/@/components/Page'; |
15 | 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 | 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 | 25 | export default defineComponent({ |
26 | 26 | name: 'ChangePassword', |
27 | 27 | components: { BasicForm, PageWrapper }, |
... | ... | @@ -36,31 +36,31 @@ |
36 | 36 | const userStore = useUserStore(); |
37 | 37 | const appStore = useAppStore(); |
38 | 38 | const permissionStore = usePermissionStore(); |
39 | - const {createMessage} = useMessage(); | |
39 | + const { createMessage } = useMessage(); | |
40 | 40 | const userInfo = getAuthCache(USER_INFO_KEY); |
41 | - console.log(userInfo,"userInfo") | |
41 | + console.log(userInfo, 'userInfo'); | |
42 | 42 | async function handleSubmit() { |
43 | 43 | try { |
44 | 44 | const values = await validate(); |
45 | 45 | const { passwordOld, passwordNew } = values; |
46 | 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 | 65 | } catch (error) {} |
66 | 66 | } | ... | ... |
1 | 1 | import { FormSchema } from '/@/components/Form'; |
2 | -import {InputRegExp} from "/@/enums/regexpEnum"; | |
2 | +import { InputRegExp } from '/@/enums/regexpEnum'; | |
3 | 3 | export const formSchema: FormSchema[] = [ |
4 | 4 | { |
5 | 5 | field: 'passwordOld', |
... | ... | @@ -39,8 +39,10 @@ export const formSchema: FormSchema[] = [ |
39 | 39 | } |
40 | 40 | |
41 | 41 | const pwdRegex = new RegExp(InputRegExp.PASSWORD_INPUT); |
42 | - if(!pwdRegex.test(value)){ | |
43 | - return Promise.reject('密码中必须包含大小写 字母、数字、特称字符,至少8个字符,最多30个字符'); | |
42 | + if (!pwdRegex.test(value)) { | |
43 | + return Promise.reject( | |
44 | + '密码中必须包含大小写 字母、数字、特称字符,至少8个字符,最多30个字符' | |
45 | + ); | |
44 | 46 | } |
45 | 47 | return Promise.resolve(); |
46 | 48 | }, | ... | ... |
... | ... | @@ -10,125 +10,225 @@ |
10 | 10 | <BasicForm @register="registerForm"> |
11 | 11 | <template #menu="{ model, field }"> |
12 | 12 | <BasicTree |
13 | + ref="tree" | |
13 | 14 | v-model:value="model[field]" |
14 | 15 | :treeData="treeData" |
15 | 16 | :replaceFields="{ title: 'menuName' }" |
16 | - :checked-keys="roleMenus" | |
17 | + :checkedKeys="roleMenus" | |
17 | 18 | checkable |
18 | 19 | toolbar |
19 | 20 | title="菜单分配" |
21 | + @check="handleCheckClick" | |
20 | 22 | /> |
21 | 23 | </template> |
22 | 24 | </BasicForm> |
23 | 25 | </BasicDrawer> |
24 | 26 | </template> |
27 | + | |
25 | 28 | <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'; | |
31 | - | |
32 | -const {t} = useI18n(); //加载国际化 | |
33 | - | |
34 | -// import { getMenuList } from '/@/api/demo/system'; | |
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 | - | |
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 | - | |
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 | - } | |
29 | + import { defineComponent, ref, computed, unref, getCurrentInstance } from 'vue'; | |
30 | + | |
31 | + import { BasicForm, useForm } from '/@/components/Form/index'; | |
32 | + | |
33 | + import { formSchema } from './role.data'; | |
34 | + | |
35 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
36 | + | |
37 | + import { BasicTree, TreeItem } from '/@/components/Tree'; | |
38 | + | |
39 | + const { t } = useI18n(); //加载国际化 | |
40 | + | |
41 | + // import { getMenuList } from '/@/api/demo/system'; | |
42 | + | |
43 | + // 加载菜单数据 | |
44 | + | |
45 | + import { getMenuList, getMenusIdsByRoleId } from '/@/api/sys/menu'; | |
46 | + | |
47 | + import { useI18n } from '/@/hooks/web/useI18n'; | |
48 | + | |
49 | + import { RouteItem } from '/@/api/sys/model/menuModel'; | |
50 | + | |
51 | + import { saveOrUpdateRoleInfoWithMenu } from '/@/api/system/system'; | |
52 | + import { useChildrenIdsRemoveParentId } from '/@/hooks/web/useChildrenIdsRemoveParentId'; | |
53 | + export default defineComponent({ | |
54 | + name: 'RoleDrawer', | |
55 | + | |
56 | + components: { BasicDrawer, BasicForm, BasicTree }, | |
57 | + | |
58 | + emits: ['success', 'register'], | |
59 | + | |
60 | + setup(_, { emit }) { | |
61 | + const { proxy } = getCurrentInstance(); | |
62 | + | |
63 | + const isUpdate = ref<boolean>(true); | |
64 | + | |
65 | + const treeData = ref<TreeItem[]>([]); | |
66 | + | |
67 | + const roleMenus = ref<string[]>([]); | |
68 | + | |
69 | + const allCheckedKeys = ref<string[]>(); | |
70 | + | |
71 | + const roleHalfCheckedKeys = ref<string[]>([]); | |
72 | + | |
73 | + const roleId = ref<string>(''); | |
74 | + | |
75 | + const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ | |
76 | + labelWidth: 90, | |
77 | + | |
78 | + schemas: formSchema, | |
79 | + | |
80 | + showActionButtonGroup: false, | |
66 | 81 | }); |
67 | - } | |
68 | - | |
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[], | |
82 | + | |
83 | + function processChildren(items: RouteItem[]) { | |
84 | + items.map((item) => { | |
85 | + item.menuName = t(item.meta.title); | |
86 | + | |
87 | + item.icon = item.meta.icon; | |
88 | + | |
89 | + item.key = item.id; | |
90 | + | |
91 | + if (item.children) { | |
92 | + processChildren(item.children); | |
84 | 93 | } |
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 | 94 | }); |
99 | 95 | } |
100 | - }); | |
101 | - | |
102 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); | |
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] | |
96 | + | |
97 | + /** | |
98 | + | |
99 | + * 根据角色id获取所有的菜单ids----里面包含父级id---会造成回显数据时 | |
100 | + | |
101 | + * 存在父级id则默认勾选所有子级id | |
102 | + | |
103 | + */ | |
104 | + | |
105 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | |
106 | + resetFields(); | |
107 | + | |
108 | + roleId.value = ''; | |
109 | + | |
110 | + setDrawerProps({ confirmLoading: false }); | |
111 | + | |
112 | + // 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告 | |
113 | + | |
114 | + if (unref(treeData).length === 0) { | |
115 | + // 获取全部的菜单 | |
116 | + | |
117 | + const menuListModel = await getMenuList(); | |
118 | + | |
119 | + processChildren(menuListModel); | |
120 | + | |
121 | + let treeValues: TreeItem[] = []; | |
122 | + | |
123 | + menuListModel.map((item) => { | |
124 | + const data = { | |
125 | + menuName: t(item.meta.title), | |
126 | + | |
127 | + icon: item.meta.icon, | |
128 | + | |
129 | + key: item.id, | |
130 | + | |
131 | + children: item.children as any as TreeItem[], | |
132 | + }; | |
133 | + | |
134 | + treeValues.push(data); | |
135 | + }); | |
136 | + | |
137 | + treeData.value = treeValues; | |
138 | + } | |
139 | + | |
140 | + if (unref(isUpdate)) { | |
141 | + if (data.record) { | |
142 | + // // 通过角色id去获取角色对应的菜单的ids | |
143 | + | |
144 | + roleMenus.value = await getMenusIdsByRoleId(data.record.id); | |
145 | + | |
146 | + console.log(roleMenus.value); | |
147 | + | |
148 | + console.log(treeData.value); | |
149 | + | |
150 | + treeData.value.map((m) => { | |
151 | + roleMenus.value.map((m1) => { | |
152 | + if (m.key === m1) { | |
153 | + useChildrenIdsRemoveParentId(m1, roleMenus.value); | |
154 | + } | |
155 | + }); | |
156 | + }); | |
157 | + | |
158 | + console.log(roleMenus.value); | |
159 | + | |
160 | + proxy.$refs.tree.setCheckedKeys(roleMenus.value); | |
161 | + | |
162 | + // console.log(roleMenus.value, 'roleMenus.value'); | |
163 | + | |
164 | + roleId.value = data.record.id; | |
165 | + } | |
166 | + | |
167 | + setFieldsValue({ | |
168 | + ...data.record, | |
169 | + }); | |
170 | + } | |
171 | + }); | |
172 | + | |
173 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); | |
174 | + | |
175 | + async function handleSubmit() { | |
176 | + try { | |
177 | + const values = await validate(); | |
178 | + | |
179 | + setDrawerProps({ confirmLoading: true }); | |
180 | + | |
181 | + const req = { | |
182 | + id: roleId.value, | |
183 | + | |
184 | + name: values.name, | |
185 | + | |
186 | + remark: values.remark, | |
187 | + | |
188 | + status: values.status, | |
189 | + | |
190 | + menu: allCheckedKeys.value as string[], | |
191 | + }; | |
192 | + | |
193 | + saveOrUpdateRoleInfoWithMenu(req).then(() => { | |
194 | + closeDrawer(); | |
195 | + | |
196 | + emit('success'); | |
197 | + }); | |
198 | + } finally { | |
199 | + setDrawerProps({ confirmLoading: false }); | |
114 | 200 | } |
115 | - saveOrUpdateRoleInfoWithMenu(req).then(()=>{ | |
116 | - closeDrawer(); | |
117 | - emit('success'); | |
118 | - }) | |
119 | - } finally { | |
120 | - setDrawerProps({confirmLoading: false}); | |
121 | 201 | } |
122 | - } | |
123 | - | |
124 | - return { | |
125 | - registerDrawer, | |
126 | - registerForm, | |
127 | - getTitle, | |
128 | - handleSubmit, | |
129 | - treeData, | |
130 | - roleMenus, | |
131 | - }; | |
132 | - }, | |
133 | -}); | |
202 | + | |
203 | + // Tree check事件 | |
204 | + | |
205 | + const handleCheckClick = (checkedKeys: string[], { halfCheckedKeys }) => { | |
206 | + allCheckedKeys.value = [...checkedKeys, ...halfCheckedKeys]; | |
207 | + | |
208 | + // 父节点 | |
209 | + | |
210 | + roleHalfCheckedKeys.value = halfCheckedKeys; | |
211 | + }; | |
212 | + | |
213 | + return { | |
214 | + allCheckedKeys, | |
215 | + | |
216 | + registerDrawer, | |
217 | + | |
218 | + registerForm, | |
219 | + | |
220 | + getTitle, | |
221 | + | |
222 | + handleSubmit, | |
223 | + | |
224 | + treeData, | |
225 | + | |
226 | + roleMenus, | |
227 | + | |
228 | + handleCheckClick, | |
229 | + | |
230 | + useChildrenIdsRemoveParentId, | |
231 | + }; | |
232 | + }, | |
233 | + }); | |
134 | 234 | </script> | ... | ... |
... | ... | @@ -8,15 +8,15 @@ |
8 | 8 | <TableAction |
9 | 9 | :actions="[ |
10 | 10 | { |
11 | - label:'编辑', | |
11 | + label: '编辑', | |
12 | 12 | icon: 'clarity:note-edit-line', |
13 | 13 | onClick: handleEdit.bind(null, record), |
14 | 14 | }, |
15 | 15 | { |
16 | - label:'删除', | |
16 | + label: '删除', | |
17 | 17 | icon: 'ant-design:delete-outlined', |
18 | 18 | color: 'error', |
19 | - ifShow:record.roleType!=RoleEnum.ROLE_SYS_ADMIN, | |
19 | + ifShow: record.roleType != RoleEnum.ROLE_SYS_ADMIN, | |
20 | 20 | popConfirm: { |
21 | 21 | title: '是否确认删除', |
22 | 22 | confirm: handleDelete.bind(null, record), |
... | ... | @@ -33,12 +33,12 @@ |
33 | 33 | import { defineComponent } from 'vue'; |
34 | 34 | |
35 | 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 | 38 | import { useDrawer } from '/@/components/Drawer'; |
39 | 39 | import RoleDrawer from './RoleDrawer.vue'; |
40 | 40 | import { columns, searchFormSchema } from './role.data'; |
41 | - import {RoleEnum} from "/@/enums/roleEnum"; | |
41 | + import { RoleEnum } from '/@/enums/roleEnum'; | |
42 | 42 | |
43 | 43 | export default defineComponent({ |
44 | 44 | name: 'RoleManagement', |
... | ... | @@ -49,10 +49,10 @@ |
49 | 49 | title: '角色列表', |
50 | 50 | api: getRoleListByPage, |
51 | 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 | 57 | formConfig: { |
58 | 58 | labelWidth: 120, |
... | ... | @@ -85,11 +85,10 @@ |
85 | 85 | } |
86 | 86 | |
87 | 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 | 90 | reload(); |
91 | - }) | |
92 | - | |
91 | + }); | |
93 | 92 | } |
94 | 93 | function handleSuccess() { |
95 | 94 | reload(); |
... | ... | @@ -102,7 +101,7 @@ |
102 | 101 | handleEdit, |
103 | 102 | handleDelete, |
104 | 103 | handleSuccess, |
105 | - RoleEnum | |
104 | + RoleEnum, | |
106 | 105 | }; |
107 | 106 | }, |
108 | 107 | }); | ... | ... |
1 | -import {BasicColumn} from '/@/components/Table'; | |
2 | -import {FormSchema} from '/@/components/Table'; | |
3 | -import {h} from 'vue'; | |
4 | -import {Switch} from 'ant-design-vue'; | |
5 | -import {setRoleStatus} from '/@/api/system/system'; | |
6 | -import {useMessage} from '/@/hooks/web/useMessage'; | |
1 | +import { BasicColumn } from '/@/components/Table'; | |
2 | +import { FormSchema } from '/@/components/Table'; | |
3 | +import { h } from 'vue'; | |
4 | +import { Switch } from 'ant-design-vue'; | |
5 | +import { setRoleStatus } from '/@/api/system/system'; | |
6 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
7 | 7 | |
8 | 8 | export const columns: BasicColumn[] = [ |
9 | 9 | { |
... | ... | @@ -20,7 +20,7 @@ export const columns: BasicColumn[] = [ |
20 | 20 | title: '状态', |
21 | 21 | dataIndex: 'status', |
22 | 22 | width: 120, |
23 | - customRender: ({record}) => { | |
23 | + customRender: ({ record }) => { | |
24 | 24 | if (!Reflect.has(record, 'pendingStatus')) { |
25 | 25 | record.pendingStatus = false; |
26 | 26 | } |
... | ... | @@ -32,7 +32,7 @@ export const columns: BasicColumn[] = [ |
32 | 32 | onChange(checked: boolean) { |
33 | 33 | record.pendingStatus = true; |
34 | 34 | const newStatus = checked ? 1 : 0; |
35 | - const {createMessage} = useMessage(); | |
35 | + const { createMessage } = useMessage(); | |
36 | 36 | setRoleStatus(record.id, newStatus) |
37 | 37 | .then(() => { |
38 | 38 | record.status = newStatus; |
... | ... | @@ -52,7 +52,7 @@ export const columns: BasicColumn[] = [ |
52 | 52 | { |
53 | 53 | title: '备注', |
54 | 54 | dataIndex: 'remark', |
55 | - width:240, | |
55 | + width: 240, | |
56 | 56 | }, |
57 | 57 | { |
58 | 58 | title: '创建时间', |
... | ... | @@ -66,7 +66,7 @@ export const searchFormSchema: FormSchema[] = [ |
66 | 66 | field: 'roleName', |
67 | 67 | label: '角色名称', |
68 | 68 | component: 'Input', |
69 | - colProps: {span: 8}, | |
69 | + colProps: { span: 8 }, | |
70 | 70 | }, |
71 | 71 | { |
72 | 72 | field: 'status', |
... | ... | @@ -74,11 +74,11 @@ export const searchFormSchema: FormSchema[] = [ |
74 | 74 | component: 'Select', |
75 | 75 | componentProps: { |
76 | 76 | options: [ |
77 | - {label: '启用', value: 1}, | |
78 | - {label: '停用', value: 0}, | |
77 | + { label: '启用', value: 1 }, | |
78 | + { label: '停用', value: 0 }, | |
79 | 79 | ], |
80 | 80 | }, |
81 | - colProps: {span: 8}, | |
81 | + colProps: { span: 8 }, | |
82 | 82 | }, |
83 | 83 | ]; |
84 | 84 | |
... | ... | @@ -96,8 +96,8 @@ export const formSchema: FormSchema[] = [ |
96 | 96 | defaultValue: 0, |
97 | 97 | componentProps: { |
98 | 98 | options: [ |
99 | - {label: '启用', value: 1}, | |
100 | - {label: '停用', value: 0}, | |
99 | + { label: '启用', value: 1 }, | |
100 | + { label: '停用', value: 0 }, | |
101 | 101 | ], |
102 | 102 | }, |
103 | 103 | }, | ... | ... |
... | ... | @@ -7,9 +7,7 @@ |
7 | 7 | width="60%" |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | - <BasicTable | |
11 | - @register="tenantAdminTable" | |
12 | - > | |
10 | + <BasicTable @register="tenantAdminTable"> | |
13 | 11 | <template #toolbar> |
14 | 12 | <a-button type="primary" @click="handleCreateTenantAdmin">新增租户管理员</a-button> |
15 | 13 | </template> |
... | ... | @@ -17,31 +15,31 @@ |
17 | 15 | <TableAction |
18 | 16 | :actions="[ |
19 | 17 | { |
20 | - label:'短信激活', | |
18 | + label: '短信激活', | |
21 | 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 | 22 | onClick: handleSendMsg.bind(null, record), |
25 | 23 | }, |
26 | 24 | { |
27 | - label:'清除密码', | |
25 | + label: '清除密码', | |
28 | 26 | icon: 'ant-design:clear-outlined', |
29 | - tooltip:'清除密码', | |
27 | + tooltip: '清除密码', | |
30 | 28 | ifShow: record.hasPassword, |
31 | 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 | 43 | title: '是否确认删除', |
46 | 44 | confirm: handleDelete.bind(null, record), |
47 | 45 | }, |
... | ... | @@ -51,156 +49,169 @@ |
51 | 49 | </template> |
52 | 50 | <template #status="{ record }"> |
53 | 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 | 67 | </Tag> |
59 | 68 | </template> |
60 | 69 | </BasicTable> |
61 | - <TenantAdminFormDrawer @register="tenantAdminFormDrawer" @success="handleSuccess"/> | |
70 | + <TenantAdminFormDrawer @register="tenantAdminFormDrawer" @success="handleSuccess" /> | |
62 | 71 | </BasicDrawer> |
63 | 72 | </template> |
64 | 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 | 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 | 217 | </script> | ... | ... |
... | ... | @@ -7,120 +7,123 @@ |
7 | 7 | width="60%" |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | - <BasicForm @register="tenantAdminForm"> | |
11 | - </BasicForm> | |
10 | + <BasicForm @register="tenantAdminForm"> </BasicForm> | |
12 | 11 | </BasicDrawer> |
13 | 12 | </template> |
14 | 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 | 129 | </script> | ... | ... |
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | :customRequest="customUpload" |
18 | 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 | 21 | <div v-else> |
22 | 22 | <loading-outlined v-if="loading"></loading-outlined> |
23 | 23 | <plus-outlined v-else></plus-outlined> |
... | ... | @@ -29,130 +29,138 @@ |
29 | 29 | </BasicDrawer> |
30 | 30 | </template> |
31 | 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 | 160 | </script> |
153 | 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 | 166 | </style> | ... | ... |
1 | 1 | <template> |
2 | 2 | <div class="p-4"> |
3 | - <BasicTable | |
4 | - @register="tenantTable" | |
5 | - > | |
3 | + <BasicTable @register="tenantTable"> | |
6 | 4 | <template #toolbar> |
7 | 5 | <a-button type="primary" @click="handleCreate"> 新增租户</a-button> |
8 | 6 | </template> |
9 | 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 | 18 | </template> |
13 | 19 | <template #status="{ record }"> |
14 | 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 | 36 | </Tag> |
20 | 37 | </template> |
21 | 38 | <template #action="{ record }"> |
22 | 39 | <TableAction |
23 | - :actions=" | |
24 | -[ | |
25 | - { | |
40 | + :actions="[ | |
41 | + { | |
26 | 42 | icon: 'ant-design:usergroup-add-outlined', |
27 | - label:'租户管理员', | |
43 | + label: '租户管理员', | |
28 | 44 | onClick: handleTenantAdminDrawer.bind(null, record), |
29 | 45 | }, |
30 | 46 | { |
31 | 47 | icon: 'clarity:note-edit-line', |
32 | - label:'编辑', | |
48 | + label: '编辑', | |
33 | 49 | onClick: handleEdit.bind(null, record), |
34 | 50 | }, |
35 | 51 | { |
36 | 52 | icon: 'ant-design:delete-outlined', |
37 | - label:'删除', | |
53 | + label: '删除', | |
38 | 54 | color: 'error', |
39 | 55 | popConfirm: { |
40 | 56 | title: '是否确认删除', |
... | ... | @@ -45,99 +61,98 @@ |
45 | 61 | /> |
46 | 62 | </template> |
47 | 63 | </BasicTable> |
48 | - <TenantDrawer @register="tenantDrawer" @success="handleSuccess"/> | |
49 | - <TenantAdminDrawer @register="tenantAdminDrawer"/> | |
64 | + <TenantDrawer @register="tenantDrawer" @success="handleSuccess" /> | |
65 | + <TenantAdminDrawer @register="tenantAdminDrawer" /> | |
50 | 66 | </div> |
51 | 67 | </template> |
52 | 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 | 158 | </script> | ... | ... |
1 | -import { BasicColumn } from "/@/components/Table/src/types/table"; | |
2 | -import {FormSchema} from "/@/components/Form"; | |
3 | -import {getAllRoleList} from "/@/api/system/system"; | |
4 | -import {RoleEnum} from "/@/enums/roleEnum"; | |
1 | +import { BasicColumn } from '/@/components/Table/src/types/table'; | |
2 | +import { FormSchema } from '/@/components/Form'; | |
3 | +import { getAllRoleList } from '/@/api/system/system'; | |
4 | +import { RoleEnum } from '/@/enums/roleEnum'; | |
5 | 5 | |
6 | 6 | export function getBasicColumns(): BasicColumn[] { |
7 | - return [ | |
8 | - { | |
9 | - title: '图标', | |
10 | - dataIndex: 'icon', | |
11 | - fixed: 'left', | |
12 | - width: 50, | |
13 | - slots: { customRender: 'img' }, | |
14 | - }, | |
15 | - { | |
16 | - title: '名称', | |
17 | - dataIndex: 'name', | |
18 | - width: 150, | |
19 | - }, | |
20 | - { | |
21 | - title: '描述', | |
22 | - dataIndex: 'description', | |
23 | - width: 150, | |
24 | - }, | |
25 | - { | |
26 | - title: '状态', | |
27 | - dataIndex: 'userStatusEnum', | |
28 | - width: 50, | |
29 | - slots: { customRender: 'status' }, | |
30 | - }, | |
31 | - { | |
32 | - title: '有效期', | |
33 | - dataIndex: 'tenantExpireTime', | |
34 | - width: 150, | |
35 | - }, | |
36 | - { | |
37 | - title: '创建时间', | |
38 | - dataIndex: 'createTime', | |
39 | - width: 150, | |
40 | - }, | |
41 | - ] | |
42 | - } | |
7 | + return [ | |
8 | + { | |
9 | + title: '图标', | |
10 | + dataIndex: 'icon', | |
11 | + fixed: 'left', | |
12 | + width: 50, | |
13 | + slots: { customRender: 'img' }, | |
14 | + }, | |
15 | + { | |
16 | + title: '名称', | |
17 | + dataIndex: 'name', | |
18 | + width: 150, | |
19 | + }, | |
20 | + { | |
21 | + title: '描述', | |
22 | + dataIndex: 'description', | |
23 | + width: 150, | |
24 | + }, | |
25 | + { | |
26 | + title: '状态', | |
27 | + dataIndex: 'userStatusEnum', | |
28 | + width: 50, | |
29 | + slots: { customRender: 'status' }, | |
30 | + }, | |
31 | + { | |
32 | + title: '有效期', | |
33 | + dataIndex: 'tenantExpireTime', | |
34 | + width: 150, | |
35 | + }, | |
36 | + { | |
37 | + title: '创建时间', | |
38 | + dataIndex: 'createTime', | |
39 | + width: 150, | |
40 | + }, | |
41 | + ]; | |
42 | +} | |
43 | 43 | export const tenantFormSchema: FormSchema[] = [ |
44 | 44 | { |
45 | 45 | field: 'id', |
46 | 46 | label: 'id', |
47 | 47 | slot: 'iconSelect', |
48 | 48 | component: 'Input', |
49 | - show:false | |
49 | + show: false, | |
50 | 50 | }, |
51 | 51 | { |
52 | 52 | field: 'icon', |
... | ... | @@ -67,12 +67,12 @@ export const tenantFormSchema: FormSchema[] = [ |
67 | 67 | required: true, |
68 | 68 | componentProps: { |
69 | 69 | mode: 'multiple', |
70 | - api:getAllRoleList, | |
71 | - params:{ | |
72 | - roleType:RoleEnum.ROLE_TENANT_ADMIN | |
70 | + api: getAllRoleList, | |
71 | + params: { | |
72 | + roleType: RoleEnum.ROLE_TENANT_ADMIN, | |
73 | 73 | }, |
74 | - labelField:'name', | |
75 | - valueField:'id', | |
74 | + labelField: 'name', | |
75 | + valueField: 'id', | |
76 | 76 | }, |
77 | 77 | }, |
78 | 78 | { |
... | ... | @@ -82,8 +82,8 @@ export const tenantFormSchema: FormSchema[] = [ |
82 | 82 | defaultValue: true, |
83 | 83 | componentProps: { |
84 | 84 | options: [ |
85 | - {label: '启用', value: true}, | |
86 | - {label: '停用', value: false}, | |
85 | + { label: '启用', value: true }, | |
86 | + { label: '停用', value: false }, | |
87 | 87 | ], |
88 | 88 | }, |
89 | 89 | }, |
... | ... | @@ -91,15 +91,14 @@ export const tenantFormSchema: FormSchema[] = [ |
91 | 91 | field: 'tenantExpireTime', |
92 | 92 | label: '有效期: ', |
93 | 93 | component: 'DatePicker', |
94 | - componentProps:{ | |
95 | - showTime:true, | |
96 | - format:'YYYY-MM-DD HH:mm:ss' | |
97 | - } | |
94 | + componentProps: { | |
95 | + showTime: true, | |
96 | + format: 'YYYY-MM-DD HH:mm:ss', | |
97 | + }, | |
98 | 98 | }, |
99 | 99 | { |
100 | 100 | label: '备注: ', |
101 | 101 | field: 'description', |
102 | 102 | component: 'InputTextArea', |
103 | 103 | }, |
104 | - | |
105 | 104 | ]; | ... | ... |
... | ... | @@ -23,113 +23,113 @@ |
23 | 23 | </BasicDrawer> |
24 | 24 | </template> |
25 | 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 | 135 | </script> | ... | ... |
... | ... | @@ -8,12 +8,12 @@ |
8 | 8 | <TableAction |
9 | 9 | :actions="[ |
10 | 10 | { |
11 | - label:'编辑', | |
11 | + label: '编辑', | |
12 | 12 | icon: 'clarity:note-edit-line', |
13 | 13 | onClick: handleEdit.bind(null, record), |
14 | 14 | }, |
15 | 15 | { |
16 | - label:'删除', | |
16 | + label: '删除', | |
17 | 17 | icon: 'ant-design:delete-outlined', |
18 | 18 | color: 'error', |
19 | 19 | popConfirm: { |
... | ... | @@ -32,12 +32,12 @@ |
32 | 32 | import { defineComponent } from 'vue'; |
33 | 33 | |
34 | 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 | 37 | import { useDrawer } from '/@/components/Drawer'; |
38 | 38 | import RoleDrawer from './RoleDrawer.vue'; |
39 | 39 | import { columns, searchFormSchema } from './role.data'; |
40 | - import {RoleEnum} from "/@/enums/roleEnum"; | |
40 | + import { RoleEnum } from '/@/enums/roleEnum'; | |
41 | 41 | |
42 | 42 | export default defineComponent({ |
43 | 43 | name: 'TenantRoleManagement', |
... | ... | @@ -48,10 +48,10 @@ |
48 | 48 | title: '租户角色列表', |
49 | 49 | api: getRoleListByPage, |
50 | 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 | 56 | formConfig: { |
57 | 57 | labelWidth: 120, |
... | ... | @@ -84,11 +84,10 @@ |
84 | 84 | } |
85 | 85 | |
86 | 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 | 89 | reload(); |
90 | - }) | |
91 | - | |
90 | + }); | |
92 | 91 | } |
93 | 92 | function handleSuccess() { |
94 | 93 | reload(); |
... | ... | @@ -101,7 +100,7 @@ |
101 | 100 | handleEdit, |
102 | 101 | handleDelete, |
103 | 102 | handleSuccess, |
104 | - RoleEnum | |
103 | + RoleEnum, | |
105 | 104 | }; |
106 | 105 | }, |
107 | 106 | }); | ... | ... |
1 | -import {BasicColumn} from '/@/components/Table'; | |
2 | -import {FormSchema} from '/@/components/Table'; | |
3 | -import {h} from 'vue'; | |
4 | -import {Switch} from 'ant-design-vue'; | |
5 | -import {setRoleStatus} from '/@/api/system/system'; | |
6 | -import {useMessage} from '/@/hooks/web/useMessage'; | |
7 | -import {RoleEnum} from "/@/enums/roleEnum"; | |
1 | +import { BasicColumn } from '/@/components/Table'; | |
2 | +import { FormSchema } from '/@/components/Table'; | |
3 | +import { h } from 'vue'; | |
4 | +import { Switch } from 'ant-design-vue'; | |
5 | +import { setRoleStatus } from '/@/api/system/system'; | |
6 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
7 | +import { RoleEnum } from '/@/enums/roleEnum'; | |
8 | 8 | export const columns: BasicColumn[] = [ |
9 | 9 | { |
10 | 10 | title: '角色名称', |
... | ... | @@ -20,7 +20,7 @@ export const columns: BasicColumn[] = [ |
20 | 20 | title: '状态', |
21 | 21 | dataIndex: 'status', |
22 | 22 | width: 120, |
23 | - customRender: ({record}) => { | |
23 | + customRender: ({ record }) => { | |
24 | 24 | if (!Reflect.has(record, 'pendingStatus')) { |
25 | 25 | record.pendingStatus = false; |
26 | 26 | } |
... | ... | @@ -32,7 +32,7 @@ export const columns: BasicColumn[] = [ |
32 | 32 | onChange(checked: boolean) { |
33 | 33 | record.pendingStatus = true; |
34 | 34 | const newStatus = checked ? 1 : 0; |
35 | - const {createMessage} = useMessage(); | |
35 | + const { createMessage } = useMessage(); | |
36 | 36 | setRoleStatus(record.id, newStatus) |
37 | 37 | .then(() => { |
38 | 38 | record.status = newStatus; |
... | ... | @@ -52,7 +52,7 @@ export const columns: BasicColumn[] = [ |
52 | 52 | { |
53 | 53 | title: '备注', |
54 | 54 | dataIndex: 'remark', |
55 | - width:240, | |
55 | + width: 240, | |
56 | 56 | }, |
57 | 57 | { |
58 | 58 | title: '创建时间', |
... | ... | @@ -66,15 +66,15 @@ export const searchFormSchema: FormSchema[] = [ |
66 | 66 | field: 'roleName', |
67 | 67 | label: '角色名称', |
68 | 68 | component: 'Input', |
69 | - colProps: {span: 8}, | |
69 | + colProps: { span: 8 }, | |
70 | 70 | }, |
71 | 71 | { |
72 | 72 | field: 'roleType', |
73 | 73 | label: '', |
74 | 74 | component: 'Input', |
75 | - colProps: {span: 8}, | |
76 | - defaultValue:RoleEnum.ROLE_TENANT_ADMIN, | |
77 | - ifShow:false | |
75 | + colProps: { span: 8 }, | |
76 | + defaultValue: RoleEnum.ROLE_TENANT_ADMIN, | |
77 | + ifShow: false, | |
78 | 78 | }, |
79 | 79 | { |
80 | 80 | field: 'status', |
... | ... | @@ -82,11 +82,11 @@ export const searchFormSchema: FormSchema[] = [ |
82 | 82 | component: 'Select', |
83 | 83 | componentProps: { |
84 | 84 | options: [ |
85 | - {label: '启用', value: 1}, | |
86 | - {label: '停用', value: 0}, | |
85 | + { label: '启用', value: 1 }, | |
86 | + { label: '停用', value: 0 }, | |
87 | 87 | ], |
88 | 88 | }, |
89 | - colProps: {span: 8}, | |
89 | + colProps: { span: 8 }, | |
90 | 90 | }, |
91 | 91 | ]; |
92 | 92 | |
... | ... | @@ -104,8 +104,8 @@ export const formSchema: FormSchema[] = [ |
104 | 104 | defaultValue: 0, |
105 | 105 | componentProps: { |
106 | 106 | options: [ |
107 | - {label: '启用', value: 1}, | |
108 | - {label: '停用', value: 0}, | |
107 | + { label: '启用', value: 1 }, | |
108 | + { label: '停用', value: 0 }, | |
109 | 109 | ], |
110 | 110 | }, |
111 | 111 | }, | ... | ... |
... | ... | @@ -3069,6 +3069,33 @@ bluebird@^3.5.0, bluebird@^3.7.2: |
3069 | 3069 | resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" |
3070 | 3070 | integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== |
3071 | 3071 | |
3072 | +bmaplib.curveline@^1.0.0: | |
3073 | + version "1.0.0" | |
3074 | + resolved "https://registry.npmjs.org/bmaplib.curveline/-/bmaplib.curveline-1.0.0.tgz#826eb0bf1c59fad1b23142be66fc360cf009aea2" | |
3075 | + integrity sha512-9wcFMVhiYxNPqpvsLDAADn3qDhNzXp2mA6VyHSHg2XOAgSooC7ZiujdFhy0sp+0QYjTfJ/MjmLuNoUg2HHxH4Q== | |
3076 | + | |
3077 | +bmaplib.heatmap@^1.0.4: | |
3078 | + version "1.0.4" | |
3079 | + resolved "https://registry.npmjs.org/bmaplib.heatmap/-/bmaplib.heatmap-1.0.4.tgz#30161262771fe78af35705ff92457725de5d9850" | |
3080 | + integrity sha512-rmhqUARBpUSJ9jXzUI2j7dIOqnc38bqubkx/8a349U2qtw/ulLUwyzRD535OrA8G7w5cz4aPKm6/rNvUAarg/Q== | |
3081 | + | |
3082 | +bmaplib.lushu@^1.0.7: | |
3083 | + version "1.0.7" | |
3084 | + resolved "https://registry.npmjs.org/bmaplib.lushu/-/bmaplib.lushu-1.0.7.tgz#77c17dcf7148d30c46e8430c7ff86b20e418b8b8" | |
3085 | + integrity sha512-LVvgpESPii6xGxyjnQjq8u+ic4NjvhdCPV/RiSS/PGTUdZKeTDS7prSpleJLZH3ES0+oc0gYn8bw0LtPYUSz2w== | |
3086 | + | |
3087 | +bmaplib.markerclusterer@^1.0.13: | |
3088 | + version "1.0.13" | |
3089 | + resolved "https://registry.npmjs.org/bmaplib.markerclusterer/-/bmaplib.markerclusterer-1.0.13.tgz#442d71a6c40844ee47d01f6db2166b54530b5bd1" | |
3090 | + integrity sha512-VrLyWSiuDEVNi0yUfwOhFQ6z1oEEHS4w36GNu3iASu6p52QIx9uAXMUkuSCHReNR0bj2Cp9SA1dSx5RpojXajQ== | |
3091 | + dependencies: | |
3092 | + bmaplib.texticonoverlay "^1.0.2" | |
3093 | + | |
3094 | +bmaplib.texticonoverlay@^1.0.2: | |
3095 | + version "1.0.2" | |
3096 | + resolved "https://registry.npmjs.org/bmaplib.texticonoverlay/-/bmaplib.texticonoverlay-1.0.2.tgz#d78546ea0f036d9fe964983796315b6c112a05bf" | |
3097 | + integrity sha512-4ZTWr4ZP3B6qEWput5Tut16CfZgII38YwM3bpyb4gFTQyORlKYryFp9WHWrwZZaHlOyYDAXG9SX0hka43jTADg== | |
3098 | + | |
3072 | 3099 | boolbase@^1.0.0: |
3073 | 3100 | version "1.0.0" |
3074 | 3101 | resolved "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" |
... | ... | @@ -4558,7 +4585,7 @@ enquirer@^2.3.5, enquirer@^2.3.6: |
4558 | 4585 | dependencies: |
4559 | 4586 | ansi-colors "^4.1.1" |
4560 | 4587 | |
4561 | -entities@^1.1.1: | |
4588 | +entities@^1.1.1, entities@~1.1.1: | |
4562 | 4589 | version "1.1.2" |
4563 | 4590 | resolved "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56" |
4564 | 4591 | integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w== |
... | ... | @@ -7442,6 +7469,13 @@ lines-and-columns@^1.1.6: |
7442 | 7469 | resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" |
7443 | 7470 | integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= |
7444 | 7471 | |
7472 | +linkify-it@^2.0.0: | |
7473 | + version "2.2.0" | |
7474 | + resolved "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf" | |
7475 | + integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw== | |
7476 | + dependencies: | |
7477 | + uc.micro "^1.0.1" | |
7478 | + | |
7445 | 7479 | lint-staged@^11.1.2: |
7446 | 7480 | version "11.1.2" |
7447 | 7481 | resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-11.1.2.tgz#4dd78782ae43ee6ebf2969cad9af67a46b33cd90" |
... | ... | @@ -7753,6 +7787,17 @@ map-visit@^1.0.0: |
7753 | 7787 | dependencies: |
7754 | 7788 | object-visit "^1.0.0" |
7755 | 7789 | |
7790 | +markdown-it@^8.4.0: | |
7791 | + version "8.4.2" | |
7792 | + resolved "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54" | |
7793 | + integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ== | |
7794 | + dependencies: | |
7795 | + argparse "^1.0.7" | |
7796 | + entities "~1.1.1" | |
7797 | + linkify-it "^2.0.0" | |
7798 | + mdurl "^1.0.1" | |
7799 | + uc.micro "^1.0.5" | |
7800 | + | |
7756 | 7801 | mathml-tag-names@^2.1.3: |
7757 | 7802 | version "2.1.3" |
7758 | 7803 | resolved "https://registry.npmjs.org/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3" |
... | ... | @@ -7791,6 +7836,11 @@ mdn-data@2.0.14: |
7791 | 7836 | resolved "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50" |
7792 | 7837 | integrity sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow== |
7793 | 7838 | |
7839 | +mdurl@^1.0.1: | |
7840 | + version "1.0.1" | |
7841 | + resolved "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" | |
7842 | + integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4= | |
7843 | + | |
7794 | 7844 | memorystream@^0.3.1: |
7795 | 7845 | version "0.3.1" |
7796 | 7846 | resolved "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" |
... | ... | @@ -10912,6 +10962,11 @@ typescript@4.3.5: |
10912 | 10962 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4" |
10913 | 10963 | integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA== |
10914 | 10964 | |
10965 | +uc.micro@^1.0.1, uc.micro@^1.0.5: | |
10966 | + version "1.0.6" | |
10967 | + resolved "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" | |
10968 | + integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== | |
10969 | + | |
10915 | 10970 | uglify-js@^3.1.4: |
10916 | 10971 | version "3.13.9" |
10917 | 10972 | resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.9.tgz#4d8d21dcd497f29cfd8e9378b9df123ad025999b" |
... | ... | @@ -11442,6 +11497,17 @@ vscode-vue-languageservice@^0.27.0: |
11442 | 11497 | vscode-pug-languageservice "^0.27.1" |
11443 | 11498 | vscode-typescript-languageservice "^0.27.1" |
11444 | 11499 | |
11500 | +vue-baidu-map@^0.21.22: | |
11501 | + version "0.21.22" | |
11502 | + resolved "https://registry.npmjs.org/vue-baidu-map/-/vue-baidu-map-0.21.22.tgz#6b76a91ef34f18a782d732ab0f541a1a3aa069e0" | |
11503 | + integrity sha512-WQMPCih4UTh0AZCKKH/OVOYnyAWjfRNeK6BIeoLmscyY5aF8zzlJhz/NOHLb3mdztIpB0Z6aohn4Jd9mfCSjQw== | |
11504 | + dependencies: | |
11505 | + bmaplib.curveline "^1.0.0" | |
11506 | + bmaplib.heatmap "^1.0.4" | |
11507 | + bmaplib.lushu "^1.0.7" | |
11508 | + bmaplib.markerclusterer "^1.0.13" | |
11509 | + markdown-it "^8.4.0" | |
11510 | + | |
11445 | 11511 | vue-demi@*: |
11446 | 11512 | version "0.9.1" |
11447 | 11513 | resolved "https://registry.npmjs.org/vue-demi/-/vue-demi-0.9.1.tgz#25d6e1ebd4d4010757ff3571e2bf6a1d7bf3de82" | ... | ... |