Showing
6 changed files
with
668 additions
and
525 deletions
| 1 | -import { defHttp } from '/@/utils/http/axios'; | |
| 2 | -import { | |
| 3 | - TDeviceConfigParams, | |
| 4 | - IDeviceConfigAddOrEditModel, | |
| 5 | - ProfileRecord, | |
| 6 | - RuleChainRecord, | |
| 7 | -} from '/@/api/device/model/deviceConfigModel'; | |
| 8 | -import { PaginationResult } from '/#/axios'; | |
| 9 | - | |
| 10 | -enum EDeviceConfigApi { | |
| 11 | - /** | |
| 12 | - * 设备配置URL | |
| 13 | - */ | |
| 14 | - DEVICE_CONFIG_GET_PAGE = '/device_profile', | |
| 15 | - DEVICE_CONFIG_POST_ADD_OR_EDIT = '/device_profile', | |
| 16 | - DEVICE_CONFIG_GET_DETAIL = '/device_profile/', | |
| 17 | - DEVICE_CONFIG_DELETE = '/device_profile', | |
| 18 | - DEVICE_CONFIG_GET_RULECHAIN = '/rule_chain/me/list', | |
| 19 | - ALARM_CONTACT_GET_PAGE = '/alarm_contact', | |
| 20 | - DEVICE_CONFIG_EXPORT = '/device_profile/export', | |
| 21 | - DEVICE_CONFIG_IMPORT = '/device_profile/import', | |
| 22 | - SET_DEVICE_ISDEFAULT = '/deviceProfile', | |
| 23 | - FRP_API = '/frp/', | |
| 24 | - GET_TB_DEVICE_ID = '/device/get_subset', | |
| 25 | -} | |
| 26 | - | |
| 27 | -/** | |
| 28 | - * 设备配置详情 | |
| 29 | - */ | |
| 30 | -export const deviceConfigGetDetail = (id: string) => { | |
| 31 | - return defHttp.get({ | |
| 32 | - url: `${EDeviceConfigApi.DEVICE_CONFIG_GET_DETAIL}${id}`, | |
| 33 | - }); | |
| 34 | -}; | |
| 35 | - | |
| 36 | -/** | |
| 37 | - * 获取规则链 | |
| 38 | - */ | |
| 39 | -export const deviceConfigGetRuleChain = () => { | |
| 40 | - return defHttp.get<RuleChainRecord[]>({ | |
| 41 | - url: EDeviceConfigApi.DEVICE_CONFIG_GET_RULECHAIN, | |
| 42 | - }); | |
| 43 | -}; | |
| 44 | - | |
| 45 | -/** | |
| 46 | - * 获取告警联系人 | |
| 47 | - */ | |
| 48 | -export const alarmContactGetPage = () => { | |
| 49 | - return defHttp.get({ | |
| 50 | - url: `${EDeviceConfigApi.ALARM_CONTACT_GET_PAGE}?page=1&pageSize=10`, | |
| 51 | - }); | |
| 52 | -}; | |
| 53 | - | |
| 54 | -/** | |
| 55 | - * 分页查询设备配置页面 | |
| 56 | - */ | |
| 57 | -export const deviceConfigGetQuery = (params?: TDeviceConfigParams) => { | |
| 58 | - return defHttp.get<PaginationResult<ProfileRecord>>({ | |
| 59 | - url: EDeviceConfigApi.DEVICE_CONFIG_GET_PAGE, | |
| 60 | - params, | |
| 61 | - }); | |
| 62 | -}; | |
| 63 | - | |
| 64 | -/** | |
| 65 | - * 新增或者编辑设备配置 | |
| 66 | - | |
| 67 | - */ | |
| 68 | -export const deviceConfigAddOrEdit = (params: IDeviceConfigAddOrEditModel) => { | |
| 69 | - return defHttp.post<IDeviceConfigAddOrEditModel>({ | |
| 70 | - url: EDeviceConfigApi.DEVICE_CONFIG_POST_ADD_OR_EDIT, | |
| 71 | - params, | |
| 72 | - }); | |
| 73 | -}; | |
| 74 | - | |
| 75 | -/** | |
| 76 | - * 删除设备配置 | |
| 77 | - */ | |
| 78 | -export const deviceConfigDelete = (ids: string[]) => { | |
| 79 | - return defHttp.delete({ | |
| 80 | - url: EDeviceConfigApi.DEVICE_CONFIG_DELETE, | |
| 81 | - data: { | |
| 82 | - ids, | |
| 83 | - }, | |
| 84 | - }); | |
| 85 | -}; | |
| 86 | - | |
| 87 | -/** | |
| 88 | - * 导出设备配置 | |
| 89 | - */ | |
| 90 | -export const deviceConfigExport = (params: IDeviceConfigAddOrEditModel) => { | |
| 91 | - return defHttp.post<IDeviceConfigAddOrEditModel>({ | |
| 92 | - url: EDeviceConfigApi.DEVICE_CONFIG_EXPORT, | |
| 93 | - params, | |
| 94 | - }); | |
| 95 | -}; | |
| 96 | - | |
| 97 | -/** | |
| 98 | - * 导入设备配置 | |
| 99 | - */ | |
| 100 | -export const deviceConfigImport = (params: IDeviceConfigAddOrEditModel) => { | |
| 101 | - return defHttp.post<IDeviceConfigAddOrEditModel>({ | |
| 102 | - url: EDeviceConfigApi.DEVICE_CONFIG_IMPORT, | |
| 103 | - params, | |
| 104 | - }); | |
| 105 | -}; | |
| 106 | - | |
| 107 | -/** | |
| 108 | - * | |
| 109 | - * 设置该设备配置为默认 | |
| 110 | - */ | |
| 111 | -export const setDeviceProfileIsDefaultApi = (id: string, v, params?: {}) => { | |
| 112 | - return defHttp.post( | |
| 113 | - { | |
| 114 | - url: EDeviceConfigApi.SET_DEVICE_ISDEFAULT + '/' + id + '/' + v, | |
| 115 | - params, | |
| 116 | - }, | |
| 117 | - { | |
| 118 | - joinPrefix: false, | |
| 119 | - } | |
| 120 | - ); | |
| 121 | -}; | |
| 122 | - | |
| 123 | -/** | |
| 124 | - * Frp内网穿透信息API | |
| 125 | - */ | |
| 126 | -export const frpGetInfoApi = (proxyName: string) => { | |
| 127 | - return defHttp.get({ | |
| 128 | - url: `${EDeviceConfigApi.FRP_API}${proxyName}`, | |
| 129 | - }); | |
| 130 | -}; | |
| 131 | - | |
| 132 | -export const frpPutInfoApi = (proxyName: string, enableRemote: number) => { | |
| 133 | - return defHttp.put({ | |
| 134 | - url: `${EDeviceConfigApi.FRP_API}${proxyName}/${enableRemote}`, | |
| 135 | - }); | |
| 136 | -}; | |
| 137 | - | |
| 138 | -export const getTbDeviceId = (params: string) => { | |
| 139 | - return defHttp.get({ | |
| 140 | - url: `${EDeviceConfigApi.GET_TB_DEVICE_ID}/${params}`, | |
| 141 | - }); | |
| 142 | -}; | |
| 1 | +import { defHttp } from '/@/utils/http/axios'; | |
| 2 | +import { | |
| 3 | + TDeviceConfigParams, | |
| 4 | + IDeviceConfigAddOrEditModel, | |
| 5 | + ProfileRecord, | |
| 6 | + RuleChainRecord, | |
| 7 | +} from '/@/api/device/model/deviceConfigModel'; | |
| 8 | +import { PaginationResult } from '/#/axios'; | |
| 9 | + | |
| 10 | +enum EDeviceConfigApi { | |
| 11 | + /** | |
| 12 | + * 设备配置URL | |
| 13 | + */ | |
| 14 | + DEVICE_CONFIG_GET_PAGE = '/device_profile', | |
| 15 | + DEVICE_CONFIG_POST_ADD_OR_EDIT = '/device_profile', | |
| 16 | + DEVICE_CONFIG_GET_DETAIL = '/device_profile/', | |
| 17 | + DEVICE_CONFIG_DELETE = '/device_profile', | |
| 18 | + DEVICE_CONFIG_GET_RULECHAIN = '/rule_chain/me/list', | |
| 19 | + ALARM_CONTACT_GET_PAGE = '/alarm_contact', | |
| 20 | + DEVICE_CONFIG_EXPORT = '/device_profile/export', | |
| 21 | + DEVICE_CONFIG_IMPORT = '/device_profile/import', | |
| 22 | + SET_DEVICE_ISDEFAULT = '/deviceProfile', | |
| 23 | + FRP_API = '/frp/', | |
| 24 | + GET_TB_DEVICE_ID = '/device/get_subset', | |
| 25 | + COMMODRECORD = '/rpc', | |
| 26 | +} | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * 设备配置详情 | |
| 30 | + */ | |
| 31 | +export const deviceConfigGetDetail = (id: string) => { | |
| 32 | + return defHttp.get({ | |
| 33 | + url: `${EDeviceConfigApi.DEVICE_CONFIG_GET_DETAIL}${id}`, | |
| 34 | + }); | |
| 35 | +}; | |
| 36 | + | |
| 37 | +/** | |
| 38 | + * 获取规则链 | |
| 39 | + */ | |
| 40 | +export const deviceConfigGetRuleChain = () => { | |
| 41 | + return defHttp.get<RuleChainRecord[]>({ | |
| 42 | + url: EDeviceConfigApi.DEVICE_CONFIG_GET_RULECHAIN, | |
| 43 | + }); | |
| 44 | +}; | |
| 45 | + | |
| 46 | +/** | |
| 47 | + * 获取告警联系人 | |
| 48 | + */ | |
| 49 | +export const alarmContactGetPage = () => { | |
| 50 | + return defHttp.get({ | |
| 51 | + url: `${EDeviceConfigApi.ALARM_CONTACT_GET_PAGE}?page=1&pageSize=10`, | |
| 52 | + }); | |
| 53 | +}; | |
| 54 | + | |
| 55 | +/** | |
| 56 | + * 分页查询设备配置页面 | |
| 57 | + */ | |
| 58 | +export const deviceConfigGetQuery = (params?: TDeviceConfigParams) => { | |
| 59 | + return defHttp.get<PaginationResult<ProfileRecord>>({ | |
| 60 | + url: EDeviceConfigApi.DEVICE_CONFIG_GET_PAGE, | |
| 61 | + params, | |
| 62 | + }); | |
| 63 | +}; | |
| 64 | + | |
| 65 | +/** | |
| 66 | + * 新增或者编辑设备配置 | |
| 67 | + | |
| 68 | + */ | |
| 69 | +export const deviceConfigAddOrEdit = (params: IDeviceConfigAddOrEditModel) => { | |
| 70 | + return defHttp.post<IDeviceConfigAddOrEditModel>({ | |
| 71 | + url: EDeviceConfigApi.DEVICE_CONFIG_POST_ADD_OR_EDIT, | |
| 72 | + params, | |
| 73 | + }); | |
| 74 | +}; | |
| 75 | + | |
| 76 | +/** | |
| 77 | + * 删除设备配置 | |
| 78 | + */ | |
| 79 | +export const deviceConfigDelete = (ids: string[]) => { | |
| 80 | + return defHttp.delete({ | |
| 81 | + url: EDeviceConfigApi.DEVICE_CONFIG_DELETE, | |
| 82 | + data: { | |
| 83 | + ids, | |
| 84 | + }, | |
| 85 | + }); | |
| 86 | +}; | |
| 87 | + | |
| 88 | +/** | |
| 89 | + * 导出设备配置 | |
| 90 | + */ | |
| 91 | +export const deviceConfigExport = (params: IDeviceConfigAddOrEditModel) => { | |
| 92 | + return defHttp.post<IDeviceConfigAddOrEditModel>({ | |
| 93 | + url: EDeviceConfigApi.DEVICE_CONFIG_EXPORT, | |
| 94 | + params, | |
| 95 | + }); | |
| 96 | +}; | |
| 97 | + | |
| 98 | +/** | |
| 99 | + * 导入设备配置 | |
| 100 | + */ | |
| 101 | +export const deviceConfigImport = (params: IDeviceConfigAddOrEditModel) => { | |
| 102 | + return defHttp.post<IDeviceConfigAddOrEditModel>({ | |
| 103 | + url: EDeviceConfigApi.DEVICE_CONFIG_IMPORT, | |
| 104 | + params, | |
| 105 | + }); | |
| 106 | +}; | |
| 107 | + | |
| 108 | +/** | |
| 109 | + * | |
| 110 | + * 设置该设备配置为默认 | |
| 111 | + */ | |
| 112 | +export const setDeviceProfileIsDefaultApi = (id: string, v, params?: {}) => { | |
| 113 | + return defHttp.post( | |
| 114 | + { | |
| 115 | + url: EDeviceConfigApi.SET_DEVICE_ISDEFAULT + '/' + id + '/' + v, | |
| 116 | + params, | |
| 117 | + }, | |
| 118 | + { | |
| 119 | + joinPrefix: false, | |
| 120 | + } | |
| 121 | + ); | |
| 122 | +}; | |
| 123 | + | |
| 124 | +/** | |
| 125 | + * Frp内网穿透信息API | |
| 126 | + */ | |
| 127 | +export const frpGetInfoApi = (proxyName: string) => { | |
| 128 | + return defHttp.get({ | |
| 129 | + url: `${EDeviceConfigApi.FRP_API}${proxyName}`, | |
| 130 | + }); | |
| 131 | +}; | |
| 132 | + | |
| 133 | +export const frpPutInfoApi = (proxyName: string, enableRemote: number) => { | |
| 134 | + return defHttp.put({ | |
| 135 | + url: `${EDeviceConfigApi.FRP_API}${proxyName}/${enableRemote}`, | |
| 136 | + }); | |
| 137 | +}; | |
| 138 | + | |
| 139 | +export const getTbDeviceId = (params: string) => { | |
| 140 | + return defHttp.get({ | |
| 141 | + url: `${EDeviceConfigApi.GET_TB_DEVICE_ID}/${params}`, | |
| 142 | + }); | |
| 143 | +}; | |
| 144 | + | |
| 145 | +/** | |
| 146 | + * 命令下发记录 | |
| 147 | + */ | |
| 148 | +export const deviceCommandRecordGetQuery = (params?: TDeviceConfigParams) => { | |
| 149 | + return defHttp.get({ | |
| 150 | + url: EDeviceConfigApi.COMMODRECORD, | |
| 151 | + params, | |
| 152 | + }); | |
| 153 | +}; | ... | ... |
| 1 | -import { BasicPageParams } from '/@/api/model/baseModel'; | |
| 2 | - | |
| 3 | -export type TDeviceConfigPageQueryParam = BasicPageParams & TDeviceConfigParams; | |
| 4 | - | |
| 5 | -export type TDeviceConfigParams = { | |
| 6 | - page?: any; | |
| 7 | - pageSize?: any; | |
| 8 | - name?: string; | |
| 9 | - transportType?: string; | |
| 10 | - orderFiled?: string; | |
| 11 | - orderType?: string; | |
| 12 | -}; | |
| 13 | - | |
| 14 | -export interface IDeviceConfigAddOrEditModel { | |
| 15 | - defaultQueueName?: string; //处理队列 | |
| 16 | - alarmProfile?: { | |
| 17 | - alarmContactId: string; | |
| 18 | - createTime: '2021-12-15T02:17:26.644Z'; | |
| 19 | - creator: string; | |
| 20 | - defaultConfig: string; | |
| 21 | - description: string; | |
| 22 | - deviceProfileId: string; | |
| 23 | - enabled: true; | |
| 24 | - icon: string; | |
| 25 | - id: string; | |
| 26 | - messageMode: string; | |
| 27 | - name: string; | |
| 28 | - roleIds: [string]; | |
| 29 | - tenantExpireTime: '2021-12-15T02:17:26.644Z'; | |
| 30 | - tenantId: string; | |
| 31 | - tenantStatus: 'DISABLED'; | |
| 32 | - updateTime: '2021-12-15T02:17:26.644Z'; | |
| 33 | - updater: string; | |
| 34 | - }; | |
| 35 | - convertJs?: string; | |
| 36 | - createTime?: '2021-12-15T02:17:26.644Z'; | |
| 37 | - creator?: string; | |
| 38 | - defaultConfig?: string; | |
| 39 | - defaultRuleChainId?: string; | |
| 40 | - description?: string; | |
| 41 | - enabled?: true; | |
| 42 | - icon?: string; | |
| 43 | - id?: string; | |
| 44 | - name?: string; | |
| 45 | - profileData?: { | |
| 46 | - configuration: {}; | |
| 47 | - transportConfiguration: {}; | |
| 48 | - provisionConfiguration: { | |
| 49 | - provisionDeviceSecret: string; | |
| 50 | - }; | |
| 51 | - //报警类型字段 | |
| 52 | - alarms: [ | |
| 53 | - { | |
| 54 | - id: 'highTemperatureAlarmID'; | |
| 55 | - alarmType: 'High Temperature Alarm'; | |
| 56 | - createRules: { | |
| 57 | - additionalProp1: { | |
| 58 | - condition: { | |
| 59 | - condition: [ | |
| 60 | - { | |
| 61 | - key: { | |
| 62 | - type: 'TIME_SERIES'; | |
| 63 | - key: 'temp'; | |
| 64 | - }; | |
| 65 | - valueType: 'NUMERIC'; | |
| 66 | - value: {}; | |
| 67 | - predicate: {}; | |
| 68 | - } | |
| 69 | - ]; | |
| 70 | - spec: {}; | |
| 71 | - }; | |
| 72 | - schedule: { | |
| 73 | - type: 'ANY_TIME'; | |
| 74 | - }; | |
| 75 | - alarmDetails: string; | |
| 76 | - dashboardId: { | |
| 77 | - id: '784f394c-42b6-435a-983c-b7beff2784f9'; | |
| 78 | - entityType: 'DASHBOARD'; | |
| 79 | - }; | |
| 80 | - }; | |
| 81 | - additionalProp2: { | |
| 82 | - condition: { | |
| 83 | - condition: [ | |
| 84 | - { | |
| 85 | - key: { | |
| 86 | - type: 'TIME_SERIES'; | |
| 87 | - key: 'temp'; | |
| 88 | - }; | |
| 89 | - valueType: 'NUMERIC'; | |
| 90 | - value: {}; | |
| 91 | - predicate: {}; | |
| 92 | - } | |
| 93 | - ]; | |
| 94 | - spec: {}; | |
| 95 | - }; | |
| 96 | - schedule: { | |
| 97 | - type: 'ANY_TIME'; | |
| 98 | - }; | |
| 99 | - alarmDetails: string; | |
| 100 | - dashboardId: { | |
| 101 | - id: '784f394c-42b6-435a-983c-b7beff2784f9'; | |
| 102 | - entityType: 'DASHBOARD'; | |
| 103 | - }; | |
| 104 | - }; | |
| 105 | - additionalProp3: { | |
| 106 | - condition: { | |
| 107 | - condition: [ | |
| 108 | - { | |
| 109 | - key: { | |
| 110 | - type: 'TIME_SERIES'; | |
| 111 | - key: 'temp'; | |
| 112 | - }; | |
| 113 | - valueType: 'NUMERIC'; | |
| 114 | - value: {}; | |
| 115 | - predicate: {}; | |
| 116 | - } | |
| 117 | - ]; | |
| 118 | - spec: {}; | |
| 119 | - }; | |
| 120 | - schedule: { | |
| 121 | - type: 'ANY_TIME'; | |
| 122 | - }; | |
| 123 | - alarmDetails: string; | |
| 124 | - dashboardId: { | |
| 125 | - id: '784f394c-42b6-435a-983c-b7beff2784f9'; | |
| 126 | - entityType: 'DASHBOARD'; | |
| 127 | - }; | |
| 128 | - }; | |
| 129 | - }; | |
| 130 | - clearRule: { | |
| 131 | - condition: { | |
| 132 | - condition: [ | |
| 133 | - { | |
| 134 | - key: { | |
| 135 | - type: 'TIME_SERIES'; | |
| 136 | - key: 'temp'; | |
| 137 | - }; | |
| 138 | - valueType: 'NUMERIC'; | |
| 139 | - value: {}; | |
| 140 | - predicate: {}; | |
| 141 | - } | |
| 142 | - ]; | |
| 143 | - spec: {}; | |
| 144 | - }; | |
| 145 | - schedule: { | |
| 146 | - type: 'ANY_TIME'; | |
| 147 | - }; | |
| 148 | - alarmDetails: string; | |
| 149 | - dashboardId: { | |
| 150 | - id: '784f394c-42b6-435a-983c-b7beff2784f9'; | |
| 151 | - entityType: 'DASHBOARD'; | |
| 152 | - }; | |
| 153 | - }; | |
| 154 | - propagate: true; | |
| 155 | - propagateRelationTypes: [string]; | |
| 156 | - } | |
| 157 | - ]; | |
| 158 | - }; | |
| 159 | - roleIds?: [string]; | |
| 160 | - tbProfileId?: string; | |
| 161 | - tenantExpireTime?: '2021-12-15T02:17:26.645Z'; | |
| 162 | - tenantId?: string; | |
| 163 | - tenantStatus?: 'DISABLED'; | |
| 164 | - transportType?: string; | |
| 165 | - updateTime?: '2021-12-15T02:17:26.645Z'; | |
| 166 | - updater?: string; | |
| 167 | -} | |
| 168 | - | |
| 169 | -export interface Data { | |
| 170 | - CO: number; | |
| 171 | -} | |
| 172 | - | |
| 173 | -export interface Details { | |
| 174 | - data: Data; | |
| 175 | -} | |
| 176 | - | |
| 177 | -export interface AlarmLogItem { | |
| 178 | - id: string; | |
| 179 | - tenantId: string; | |
| 180 | - creator?: any; | |
| 181 | - updater?: any; | |
| 182 | - createdTime: string; | |
| 183 | - updatedTime: string; | |
| 184 | - customerId: string; | |
| 185 | - tbDeviceId: string; | |
| 186 | - originatorType: number; | |
| 187 | - deviceId: string; | |
| 188 | - deviceName: string; | |
| 189 | - type: string; | |
| 190 | - severity: string; | |
| 191 | - status: string; | |
| 192 | - startTs: string; | |
| 193 | - endTs: string; | |
| 194 | - ackTs: string; | |
| 195 | - clearTs: string; | |
| 196 | - details: Details; | |
| 197 | - propagate: boolean; | |
| 198 | - propagateRelationTypes?: any; | |
| 199 | - organizationId: string; | |
| 200 | - organizationName: string; | |
| 201 | -} | |
| 202 | - | |
| 203 | -export interface Configuration { | |
| 204 | - type: string; | |
| 205 | -} | |
| 206 | - | |
| 207 | -export interface TransportConfiguration { | |
| 208 | - type: string; | |
| 209 | -} | |
| 210 | - | |
| 211 | -export interface ProvisionConfiguration { | |
| 212 | - type: string; | |
| 213 | - provisionDeviceSecret?: any; | |
| 214 | -} | |
| 215 | - | |
| 216 | -export interface ProfileData { | |
| 217 | - configuration: Configuration; | |
| 218 | - transportConfiguration: TransportConfiguration; | |
| 219 | - provisionConfiguration: ProvisionConfiguration; | |
| 220 | - alarms?: any; | |
| 221 | -} | |
| 222 | - | |
| 223 | -export interface ProfileRecord { | |
| 224 | - id: string; | |
| 225 | - creator: string; | |
| 226 | - createTime: string; | |
| 227 | - updater: string; | |
| 228 | - updateTime: string; | |
| 229 | - name: string; | |
| 230 | - tenantId: string; | |
| 231 | - transportType: string; | |
| 232 | - provisionType: string; | |
| 233 | - deviceType: string; | |
| 234 | - tbProfileId: string; | |
| 235 | - profileData: ProfileData; | |
| 236 | - defaultRuleChainId: string; | |
| 237 | - defaultQueueName: string; | |
| 238 | - image: string; | |
| 239 | - type: string; | |
| 240 | - default: boolean; | |
| 241 | - | |
| 242 | - checked?: boolean; | |
| 243 | -} | |
| 244 | - | |
| 245 | -export interface IDRecord { | |
| 246 | - entityType: string; | |
| 247 | - id: string; | |
| 248 | -} | |
| 249 | - | |
| 250 | -export interface RuleChainRecord { | |
| 251 | - id: IDRecord; | |
| 252 | - createdTime: number; | |
| 253 | - additionalInfo?: any; | |
| 254 | - tenantId: IDRecord; | |
| 255 | - name: string; | |
| 256 | - type: string; | |
| 257 | - firstRuleNodeId: IDRecord; | |
| 258 | - root: boolean; | |
| 259 | - debugMode: boolean; | |
| 260 | - configuration?: any; | |
| 261 | -} | |
| 1 | +import { BasicPageParams } from '/@/api/model/baseModel'; | |
| 2 | + | |
| 3 | +export type TDeviceConfigPageQueryParam = BasicPageParams & TDeviceConfigParams; | |
| 4 | + | |
| 5 | +export type TDeviceConfigParams = { | |
| 6 | + page?: any; | |
| 7 | + pageSize?: any; | |
| 8 | + name?: string; | |
| 9 | + transportType?: string; | |
| 10 | + orderFiled?: string; | |
| 11 | + orderType?: string; | |
| 12 | + tbDeviceId?: string; | |
| 13 | +}; | |
| 14 | + | |
| 15 | +export interface IDeviceConfigAddOrEditModel { | |
| 16 | + defaultQueueName?: string; //处理队列 | |
| 17 | + alarmProfile?: { | |
| 18 | + alarmContactId: string; | |
| 19 | + createTime: '2021-12-15T02:17:26.644Z'; | |
| 20 | + creator: string; | |
| 21 | + defaultConfig: string; | |
| 22 | + description: string; | |
| 23 | + deviceProfileId: string; | |
| 24 | + enabled: true; | |
| 25 | + icon: string; | |
| 26 | + id: string; | |
| 27 | + messageMode: string; | |
| 28 | + name: string; | |
| 29 | + roleIds: [string]; | |
| 30 | + tenantExpireTime: '2021-12-15T02:17:26.644Z'; | |
| 31 | + tenantId: string; | |
| 32 | + tenantStatus: 'DISABLED'; | |
| 33 | + updateTime: '2021-12-15T02:17:26.644Z'; | |
| 34 | + updater: string; | |
| 35 | + }; | |
| 36 | + convertJs?: string; | |
| 37 | + createTime?: '2021-12-15T02:17:26.644Z'; | |
| 38 | + creator?: string; | |
| 39 | + defaultConfig?: string; | |
| 40 | + defaultRuleChainId?: string; | |
| 41 | + description?: string; | |
| 42 | + enabled?: true; | |
| 43 | + icon?: string; | |
| 44 | + id?: string; | |
| 45 | + name?: string; | |
| 46 | + profileData?: { | |
| 47 | + configuration: {}; | |
| 48 | + transportConfiguration: {}; | |
| 49 | + provisionConfiguration: { | |
| 50 | + provisionDeviceSecret: string; | |
| 51 | + }; | |
| 52 | + //报警类型字段 | |
| 53 | + alarms: [ | |
| 54 | + { | |
| 55 | + id: 'highTemperatureAlarmID'; | |
| 56 | + alarmType: 'High Temperature Alarm'; | |
| 57 | + createRules: { | |
| 58 | + additionalProp1: { | |
| 59 | + condition: { | |
| 60 | + condition: [ | |
| 61 | + { | |
| 62 | + key: { | |
| 63 | + type: 'TIME_SERIES'; | |
| 64 | + key: 'temp'; | |
| 65 | + }; | |
| 66 | + valueType: 'NUMERIC'; | |
| 67 | + value: {}; | |
| 68 | + predicate: {}; | |
| 69 | + } | |
| 70 | + ]; | |
| 71 | + spec: {}; | |
| 72 | + }; | |
| 73 | + schedule: { | |
| 74 | + type: 'ANY_TIME'; | |
| 75 | + }; | |
| 76 | + alarmDetails: string; | |
| 77 | + dashboardId: { | |
| 78 | + id: '784f394c-42b6-435a-983c-b7beff2784f9'; | |
| 79 | + entityType: 'DASHBOARD'; | |
| 80 | + }; | |
| 81 | + }; | |
| 82 | + additionalProp2: { | |
| 83 | + condition: { | |
| 84 | + condition: [ | |
| 85 | + { | |
| 86 | + key: { | |
| 87 | + type: 'TIME_SERIES'; | |
| 88 | + key: 'temp'; | |
| 89 | + }; | |
| 90 | + valueType: 'NUMERIC'; | |
| 91 | + value: {}; | |
| 92 | + predicate: {}; | |
| 93 | + } | |
| 94 | + ]; | |
| 95 | + spec: {}; | |
| 96 | + }; | |
| 97 | + schedule: { | |
| 98 | + type: 'ANY_TIME'; | |
| 99 | + }; | |
| 100 | + alarmDetails: string; | |
| 101 | + dashboardId: { | |
| 102 | + id: '784f394c-42b6-435a-983c-b7beff2784f9'; | |
| 103 | + entityType: 'DASHBOARD'; | |
| 104 | + }; | |
| 105 | + }; | |
| 106 | + additionalProp3: { | |
| 107 | + condition: { | |
| 108 | + condition: [ | |
| 109 | + { | |
| 110 | + key: { | |
| 111 | + type: 'TIME_SERIES'; | |
| 112 | + key: 'temp'; | |
| 113 | + }; | |
| 114 | + valueType: 'NUMERIC'; | |
| 115 | + value: {}; | |
| 116 | + predicate: {}; | |
| 117 | + } | |
| 118 | + ]; | |
| 119 | + spec: {}; | |
| 120 | + }; | |
| 121 | + schedule: { | |
| 122 | + type: 'ANY_TIME'; | |
| 123 | + }; | |
| 124 | + alarmDetails: string; | |
| 125 | + dashboardId: { | |
| 126 | + id: '784f394c-42b6-435a-983c-b7beff2784f9'; | |
| 127 | + entityType: 'DASHBOARD'; | |
| 128 | + }; | |
| 129 | + }; | |
| 130 | + }; | |
| 131 | + clearRule: { | |
| 132 | + condition: { | |
| 133 | + condition: [ | |
| 134 | + { | |
| 135 | + key: { | |
| 136 | + type: 'TIME_SERIES'; | |
| 137 | + key: 'temp'; | |
| 138 | + }; | |
| 139 | + valueType: 'NUMERIC'; | |
| 140 | + value: {}; | |
| 141 | + predicate: {}; | |
| 142 | + } | |
| 143 | + ]; | |
| 144 | + spec: {}; | |
| 145 | + }; | |
| 146 | + schedule: { | |
| 147 | + type: 'ANY_TIME'; | |
| 148 | + }; | |
| 149 | + alarmDetails: string; | |
| 150 | + dashboardId: { | |
| 151 | + id: '784f394c-42b6-435a-983c-b7beff2784f9'; | |
| 152 | + entityType: 'DASHBOARD'; | |
| 153 | + }; | |
| 154 | + }; | |
| 155 | + propagate: true; | |
| 156 | + propagateRelationTypes: [string]; | |
| 157 | + } | |
| 158 | + ]; | |
| 159 | + }; | |
| 160 | + roleIds?: [string]; | |
| 161 | + tbProfileId?: string; | |
| 162 | + tenantExpireTime?: '2021-12-15T02:17:26.645Z'; | |
| 163 | + tenantId?: string; | |
| 164 | + tenantStatus?: 'DISABLED'; | |
| 165 | + transportType?: string; | |
| 166 | + updateTime?: '2021-12-15T02:17:26.645Z'; | |
| 167 | + updater?: string; | |
| 168 | +} | |
| 169 | + | |
| 170 | +export interface Data { | |
| 171 | + CO: number; | |
| 172 | +} | |
| 173 | + | |
| 174 | +export interface Details { | |
| 175 | + data: Data; | |
| 176 | +} | |
| 177 | + | |
| 178 | +export interface AlarmLogItem { | |
| 179 | + id: string; | |
| 180 | + tenantId: string; | |
| 181 | + creator?: any; | |
| 182 | + updater?: any; | |
| 183 | + createdTime: string; | |
| 184 | + updatedTime: string; | |
| 185 | + customerId: string; | |
| 186 | + tbDeviceId: string; | |
| 187 | + originatorType: number; | |
| 188 | + deviceId: string; | |
| 189 | + deviceName: string; | |
| 190 | + type: string; | |
| 191 | + severity: string; | |
| 192 | + status: string; | |
| 193 | + startTs: string; | |
| 194 | + endTs: string; | |
| 195 | + ackTs: string; | |
| 196 | + clearTs: string; | |
| 197 | + details: Details; | |
| 198 | + propagate: boolean; | |
| 199 | + propagateRelationTypes?: any; | |
| 200 | + organizationId: string; | |
| 201 | + organizationName: string; | |
| 202 | +} | |
| 203 | + | |
| 204 | +export interface Configuration { | |
| 205 | + type: string; | |
| 206 | +} | |
| 207 | + | |
| 208 | +export interface TransportConfiguration { | |
| 209 | + type: string; | |
| 210 | +} | |
| 211 | + | |
| 212 | +export interface ProvisionConfiguration { | |
| 213 | + type: string; | |
| 214 | + provisionDeviceSecret?: any; | |
| 215 | +} | |
| 216 | + | |
| 217 | +export interface ProfileData { | |
| 218 | + configuration: Configuration; | |
| 219 | + transportConfiguration: TransportConfiguration; | |
| 220 | + provisionConfiguration: ProvisionConfiguration; | |
| 221 | + alarms?: any; | |
| 222 | +} | |
| 223 | + | |
| 224 | +export interface ProfileRecord { | |
| 225 | + id: string; | |
| 226 | + creator: string; | |
| 227 | + createTime: string; | |
| 228 | + updater: string; | |
| 229 | + updateTime: string; | |
| 230 | + name: string; | |
| 231 | + tenantId: string; | |
| 232 | + transportType: string; | |
| 233 | + provisionType: string; | |
| 234 | + deviceType: string; | |
| 235 | + tbProfileId: string; | |
| 236 | + profileData: ProfileData; | |
| 237 | + defaultRuleChainId: string; | |
| 238 | + defaultQueueName: string; | |
| 239 | + image: string; | |
| 240 | + type: string; | |
| 241 | + default: boolean; | |
| 242 | + | |
| 243 | + checked?: boolean; | |
| 244 | +} | |
| 245 | + | |
| 246 | +export interface IDRecord { | |
| 247 | + entityType: string; | |
| 248 | + id: string; | |
| 249 | +} | |
| 250 | + | |
| 251 | +export interface RuleChainRecord { | |
| 252 | + id: IDRecord; | |
| 253 | + createdTime: number; | |
| 254 | + additionalInfo?: any; | |
| 255 | + tenantId: IDRecord; | |
| 256 | + name: string; | |
| 257 | + type: string; | |
| 258 | + firstRuleNodeId: IDRecord; | |
| 259 | + root: boolean; | |
| 260 | + debugMode: boolean; | |
| 261 | + configuration?: any; | |
| 262 | +} | ... | ... |
| 1 | -<template> | |
| 2 | - <BasicDrawer | |
| 3 | - v-bind="$attrs" | |
| 4 | - isDetail | |
| 5 | - @register="register" | |
| 6 | - destroyOnClose | |
| 7 | - @close="closeDrawer" | |
| 8 | - :title="deviceDetail.alias || deviceDetail.name" | |
| 9 | - width="80%" | |
| 10 | - > | |
| 11 | - <Tabs v-model:activeKey="activeKey" :size="size"> | |
| 12 | - <TabPane key="1" tab="详情"> | |
| 13 | - <Detail | |
| 14 | - ref="deviceDetailRef" | |
| 15 | - :deviceDetail="deviceDetail" | |
| 16 | - @open-gateway-device="handleOpenGatewayDevice" | |
| 17 | - /> | |
| 18 | - </TabPane> | |
| 19 | - <TabPane key="modelOfMatter" tab="物模型数据"> | |
| 20 | - <ModelOfMatter :deviceDetail="deviceDetail" /> | |
| 21 | - </TabPane> | |
| 22 | - <!-- <TabPane key="2" tab="实时数据" v-if="deviceDetail?.deviceType !== 'GATEWAY'"> | |
| 23 | - <RealTimeData :deviceDetail="deviceDetail" /> | |
| 24 | - </TabPane> | |
| 25 | - <TabPane key="7" tab="历史数据" v-if="deviceDetail?.deviceType !== 'GATEWAY'"> | |
| 26 | - <HistoryData :deviceDetail="deviceDetail" /> | |
| 27 | - </TabPane> --> | |
| 28 | - <TabPane key="5" tab="命令下发" v-if="deviceDetail?.deviceType !== 'SENSOR'"> | |
| 29 | - <CommandIssuance :deviceDetail="deviceDetail" /> | |
| 30 | - </TabPane> | |
| 31 | - <TabPane key="3" tab="告警"><Alarm :id="deviceDetail.id" /></TabPane> | |
| 32 | - <TabPane key="4" tab="子设备" v-if="deviceDetail?.deviceType === 'GATEWAY'"> | |
| 33 | - <ChildDevice | |
| 34 | - :fromId="deviceDetail?.tbDeviceId" | |
| 35 | - @openTbDeviceDetail="handleOpenTbDeviceDetail" | |
| 36 | - /> | |
| 37 | - </TabPane> | |
| 38 | - <!-- 网关设备并且场家是TBox --> | |
| 39 | - <TabPane | |
| 40 | - key="6" | |
| 41 | - tab="TBox" | |
| 42 | - v-if="deviceDetail?.deviceType === 'GATEWAY' && deviceDetail?.brand == 'TBox'" | |
| 43 | - > | |
| 44 | - <TBoxDetail :deviceDetail="deviceDetail" /> | |
| 45 | - </TabPane> | |
| 46 | - <!-- 网关设备并且是TBox --> | |
| 47 | - </Tabs> | |
| 48 | - </BasicDrawer> | |
| 49 | -</template> | |
| 50 | -<script lang="ts"> | |
| 51 | - import { defineComponent, ref } from 'vue'; | |
| 52 | - import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
| 53 | - | |
| 54 | - import { Tabs } from 'ant-design-vue'; | |
| 55 | - import Detail from '../tabs/Detail.vue'; | |
| 56 | - // import RealTimeData from '../tabs/RealTimeData.vue'; | |
| 57 | - import Alarm from '../tabs/Alarm.vue'; | |
| 58 | - import ChildDevice from '../tabs/ChildDevice.vue'; | |
| 59 | - import TBoxDetail from '../tabs/TBoxDetail.vue'; | |
| 60 | - import CommandIssuance from '../tabs/CommandIssuance.vue'; | |
| 61 | - import { getDeviceDetail } from '/@/api/device/deviceManager'; | |
| 62 | - // import HistoryData from '../tabs/HistoryData.vue'; | |
| 63 | - import ModelOfMatter from '../tabs/ModelOfMatter.vue'; | |
| 64 | - export default defineComponent({ | |
| 65 | - name: 'DeviceModal', | |
| 66 | - components: { | |
| 67 | - BasicDrawer, | |
| 68 | - Tabs, | |
| 69 | - TabPane: Tabs.TabPane, | |
| 70 | - Detail, | |
| 71 | - // RealTimeData, | |
| 72 | - Alarm, | |
| 73 | - ChildDevice, | |
| 74 | - CommandIssuance, | |
| 75 | - TBoxDetail, | |
| 76 | - // HistoryData, | |
| 77 | - ModelOfMatter, | |
| 78 | - }, | |
| 79 | - emits: ['reload', 'register', 'openTbDeviceDetail', 'openGatewayDeviceDetail'], | |
| 80 | - setup(_props, { emit }) { | |
| 81 | - const activeKey = ref('1'); | |
| 82 | - const size = ref('small'); | |
| 83 | - const deviceDetailRef = ref(); | |
| 84 | - const deviceDetail = ref<any>({}); | |
| 85 | - const tbDeviceId = ref(''); | |
| 86 | - // 详情回显 | |
| 87 | - const [register] = useDrawerInner(async (data) => { | |
| 88 | - const { id } = data; | |
| 89 | - // 设备详情 | |
| 90 | - const res = await getDeviceDetail(id); | |
| 91 | - deviceDetail.value = res; | |
| 92 | - const { latitude, longitude, address } = res.deviceInfo; | |
| 93 | - if (latitude) { | |
| 94 | - deviceDetailRef.value.initMap(longitude, latitude, address); | |
| 95 | - } | |
| 96 | - }); | |
| 97 | - const closeDrawer = () => { | |
| 98 | - activeKey.value = '1'; | |
| 99 | - }; | |
| 100 | - | |
| 101 | - const handleOpenTbDeviceDetail = (data: { id: string; tbDeviceId: string }) => { | |
| 102 | - emit('openTbDeviceDetail', data); | |
| 103 | - }; | |
| 104 | - | |
| 105 | - const handleOpenGatewayDevice = (data: { gatewayId: string; tbDeviceId: string }) => { | |
| 106 | - emit('openGatewayDeviceDetail', { id: data.gatewayId }); | |
| 107 | - }; | |
| 108 | - | |
| 109 | - return { | |
| 110 | - size, | |
| 111 | - activeKey, | |
| 112 | - register, | |
| 113 | - closeDrawer, | |
| 114 | - deviceDetail, | |
| 115 | - deviceDetailRef, | |
| 116 | - tbDeviceId, | |
| 117 | - handleOpenTbDeviceDetail, | |
| 118 | - handleOpenGatewayDevice, | |
| 119 | - }; | |
| 120 | - }, | |
| 121 | - }); | |
| 122 | -</script> | |
| 1 | +<template> | |
| 2 | + <BasicDrawer | |
| 3 | + v-bind="$attrs" | |
| 4 | + isDetail | |
| 5 | + @register="register" | |
| 6 | + destroyOnClose | |
| 7 | + @close="closeDrawer" | |
| 8 | + :title="deviceDetail.alias || deviceDetail.name" | |
| 9 | + width="80%" | |
| 10 | + > | |
| 11 | + <Tabs v-model:activeKey="activeKey" :size="size"> | |
| 12 | + <TabPane key="1" tab="详情"> | |
| 13 | + <Detail | |
| 14 | + ref="deviceDetailRef" | |
| 15 | + :deviceDetail="deviceDetail" | |
| 16 | + @open-gateway-device="handleOpenGatewayDevice" | |
| 17 | + /> | |
| 18 | + </TabPane> | |
| 19 | + <TabPane key="modelOfMatter" tab="物模型数据"> | |
| 20 | + <ModelOfMatter :deviceDetail="deviceDetail" /> | |
| 21 | + </TabPane> | |
| 22 | + <!-- <TabPane key="2" tab="实时数据" v-if="deviceDetail?.deviceType !== 'GATEWAY'"> | |
| 23 | + <RealTimeData :deviceDetail="deviceDetail" /> | |
| 24 | + </TabPane> | |
| 25 | + <TabPane key="7" tab="历史数据" v-if="deviceDetail?.deviceType !== 'GATEWAY'"> | |
| 26 | + <HistoryData :deviceDetail="deviceDetail" /> | |
| 27 | + </TabPane> --> | |
| 28 | + <TabPane key="5" tab="命令下发" v-if="deviceDetail?.deviceType !== 'SENSOR'"> | |
| 29 | + <CommandIssuance :deviceDetail="deviceDetail" /> | |
| 30 | + </TabPane> | |
| 31 | + <TabPane key="3" tab="告警"><Alarm :id="deviceDetail.id" /></TabPane> | |
| 32 | + <TabPane key="4" tab="子设备" v-if="deviceDetail?.deviceType === 'GATEWAY'"> | |
| 33 | + <ChildDevice | |
| 34 | + :fromId="deviceDetail?.tbDeviceId" | |
| 35 | + @openTbDeviceDetail="handleOpenTbDeviceDetail" | |
| 36 | + /> | |
| 37 | + </TabPane> | |
| 38 | + <TabPane key="7" tab="命令下发记录"> | |
| 39 | + <CommandRecord :fromId="deviceDetail?.tbDeviceId" /> | |
| 40 | + </TabPane> | |
| 41 | + <!-- 网关设备并且场家是TBox --> | |
| 42 | + <TabPane | |
| 43 | + key="6" | |
| 44 | + tab="TBox" | |
| 45 | + v-if="deviceDetail?.deviceType === 'GATEWAY' && deviceDetail?.brand == 'TBox'" | |
| 46 | + > | |
| 47 | + <TBoxDetail :deviceDetail="deviceDetail" /> | |
| 48 | + </TabPane> | |
| 49 | + <!-- 网关设备并且是TBox --> | |
| 50 | + </Tabs> | |
| 51 | + </BasicDrawer> | |
| 52 | +</template> | |
| 53 | +<script lang="ts"> | |
| 54 | + import { defineComponent, ref } from 'vue'; | |
| 55 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
| 56 | + | |
| 57 | + import { Tabs } from 'ant-design-vue'; | |
| 58 | + import Detail from '../tabs/Detail.vue'; | |
| 59 | + // import RealTimeData from '../tabs/RealTimeData.vue'; | |
| 60 | + import Alarm from '../tabs/Alarm.vue'; | |
| 61 | + import ChildDevice from '../tabs/ChildDevice.vue'; | |
| 62 | + import TBoxDetail from '../tabs/TBoxDetail.vue'; | |
| 63 | + import CommandIssuance from '../tabs/CommandIssuance.vue'; | |
| 64 | + import { CommandRecord } from '../tabs/commandRecord/index'; | |
| 65 | + import { getDeviceDetail } from '/@/api/device/deviceManager'; | |
| 66 | + // import HistoryData from '../tabs/HistoryData.vue'; | |
| 67 | + import ModelOfMatter from '../tabs/ModelOfMatter.vue'; | |
| 68 | + export default defineComponent({ | |
| 69 | + name: 'DeviceModal', | |
| 70 | + components: { | |
| 71 | + BasicDrawer, | |
| 72 | + Tabs, | |
| 73 | + TabPane: Tabs.TabPane, | |
| 74 | + Detail, | |
| 75 | + // RealTimeData, | |
| 76 | + Alarm, | |
| 77 | + ChildDevice, | |
| 78 | + CommandIssuance, | |
| 79 | + TBoxDetail, | |
| 80 | + // HistoryData, | |
| 81 | + ModelOfMatter, | |
| 82 | + CommandRecord, | |
| 83 | + }, | |
| 84 | + emits: ['reload', 'register', 'openTbDeviceDetail', 'openGatewayDeviceDetail'], | |
| 85 | + setup(_props, { emit }) { | |
| 86 | + const activeKey = ref('1'); | |
| 87 | + const size = ref('small'); | |
| 88 | + const deviceDetailRef = ref(); | |
| 89 | + const deviceDetail = ref<any>({}); | |
| 90 | + const tbDeviceId = ref(''); | |
| 91 | + // 详情回显 | |
| 92 | + const [register] = useDrawerInner(async (data) => { | |
| 93 | + const { id } = data; | |
| 94 | + // 设备详情 | |
| 95 | + const res = await getDeviceDetail(id); | |
| 96 | + deviceDetail.value = res; | |
| 97 | + const { latitude, longitude, address } = res.deviceInfo; | |
| 98 | + if (latitude) { | |
| 99 | + deviceDetailRef.value.initMap(longitude, latitude, address); | |
| 100 | + } | |
| 101 | + }); | |
| 102 | + const closeDrawer = () => { | |
| 103 | + activeKey.value = '1'; | |
| 104 | + }; | |
| 105 | + | |
| 106 | + const handleOpenTbDeviceDetail = (data: { id: string; tbDeviceId: string }) => { | |
| 107 | + emit('openTbDeviceDetail', data); | |
| 108 | + }; | |
| 109 | + | |
| 110 | + const handleOpenGatewayDevice = (data: { gatewayId: string; tbDeviceId: string }) => { | |
| 111 | + emit('openGatewayDeviceDetail', { id: data.gatewayId }); | |
| 112 | + }; | |
| 113 | + | |
| 114 | + return { | |
| 115 | + size, | |
| 116 | + activeKey, | |
| 117 | + register, | |
| 118 | + closeDrawer, | |
| 119 | + deviceDetail, | |
| 120 | + deviceDetailRef, | |
| 121 | + tbDeviceId, | |
| 122 | + handleOpenTbDeviceDetail, | |
| 123 | + handleOpenGatewayDevice, | |
| 124 | + }; | |
| 125 | + }, | |
| 126 | + }); | |
| 127 | +</script> | ... | ... |
| 1 | +import { BasicColumn } from '/@/components/Table'; | |
| 2 | +import moment from 'moment'; | |
| 3 | +import { Tag } from 'ant-design-vue'; | |
| 4 | +import { h } from 'vue'; | |
| 5 | + | |
| 6 | +export const configColumns: BasicColumn[] = [ | |
| 7 | + { | |
| 8 | + title: '命令下发时间', | |
| 9 | + dataIndex: 'createTime', | |
| 10 | + format: (text) => { | |
| 11 | + return moment(text).format('YYYY-MM-DD HH:mm:ss'); | |
| 12 | + }, | |
| 13 | + }, | |
| 14 | + { | |
| 15 | + title: '命令类型', | |
| 16 | + dataIndex: 'additionalInfo.cmdType', | |
| 17 | + }, | |
| 18 | + { | |
| 19 | + title: '响应类型', | |
| 20 | + dataIndex: 'request.oneway', | |
| 21 | + format: (text) => { | |
| 22 | + return !text ? '双向' : '单向'; | |
| 23 | + }, | |
| 24 | + }, | |
| 25 | + { | |
| 26 | + title: '命令状态', | |
| 27 | + dataIndex: 'status', | |
| 28 | + customRender: ({ text, record }) => { | |
| 29 | + return h( | |
| 30 | + Tag, | |
| 31 | + { | |
| 32 | + color: | |
| 33 | + text == 'EXPIRED' | |
| 34 | + ? 'red' | |
| 35 | + : text == 'DELIVERED' | |
| 36 | + ? 'blue' | |
| 37 | + : text == 'QUEUED' | |
| 38 | + ? '#00C9A7' | |
| 39 | + : text == 'TIMEOUT' | |
| 40 | + ? 'red' | |
| 41 | + : text == 'SENT' | |
| 42 | + ? '#00C9A7' | |
| 43 | + : text == 'FAILED' | |
| 44 | + ? 'red' | |
| 45 | + : 'green', | |
| 46 | + }, | |
| 47 | + () => record?.statusName | |
| 48 | + ); | |
| 49 | + }, | |
| 50 | + }, | |
| 51 | + { | |
| 52 | + title: '响应结果', | |
| 53 | + dataIndex: 'response', | |
| 54 | + customRender: (text) => { | |
| 55 | + return h( | |
| 56 | + Tag, | |
| 57 | + { | |
| 58 | + color: text?.status === 'SUCCESS' ? 'green' : 'red', | |
| 59 | + }, | |
| 60 | + () => (text?.status === 'SUCCESS' ? '成功' : '失败') | |
| 61 | + ); | |
| 62 | + }, | |
| 63 | + }, | |
| 64 | + { | |
| 65 | + title: '响应失败内容', | |
| 66 | + dataIndex: 'response.error', | |
| 67 | + format: (_, record) => { | |
| 68 | + return record?.response === null ? '无' : record?.response?.error; | |
| 69 | + }, | |
| 70 | + }, | |
| 71 | + { | |
| 72 | + title: '命令内容', | |
| 73 | + dataIndex: 'request.body', | |
| 74 | + slots: { customRender: 'recordContent' }, | |
| 75 | + }, | |
| 76 | +]; | ... | ... |
| 1 | +<template> | |
| 2 | + <div style="background-color: #f0f2f5"> | |
| 3 | + <BasicTable @register="registerTable"> | |
| 4 | + <template #recordContent="{ record }"> | |
| 5 | + <a-button type="link" class="ml-2" @click="handleRecordContent(record)"> 查看 </a-button> | |
| 6 | + </template> | |
| 7 | + </BasicTable> | |
| 8 | + </div> | |
| 9 | +</template> | |
| 10 | +<script lang="ts" setup> | |
| 11 | + import { h } from 'vue'; | |
| 12 | + import { configColumns } from './config'; | |
| 13 | + import { deviceCommandRecordGetQuery } from '/@/api/device/deviceConfigApi'; | |
| 14 | + import { BasicTable, useTable } from '/@/components/Table'; | |
| 15 | + import { Modal } from 'ant-design-vue'; | |
| 16 | + import { JsonPreview } from '/@/components/CodeEditor'; | |
| 17 | + | |
| 18 | + const props = defineProps({ | |
| 19 | + fromId: { | |
| 20 | + type: String, | |
| 21 | + default: '', | |
| 22 | + }, | |
| 23 | + }); | |
| 24 | + const [registerTable] = useTable({ | |
| 25 | + api: deviceCommandRecordGetQuery, | |
| 26 | + columns: configColumns, | |
| 27 | + beforeFetch: (params) => { | |
| 28 | + return { | |
| 29 | + ...params, | |
| 30 | + tbDeviceId: props.fromId, | |
| 31 | + }; | |
| 32 | + }, | |
| 33 | + showTableSetting: true, | |
| 34 | + bordered: true, | |
| 35 | + showIndexColumn: false, | |
| 36 | + }); | |
| 37 | + const commonModalInfo = (title, value) => { | |
| 38 | + Modal.info({ | |
| 39 | + title, | |
| 40 | + width: 600, | |
| 41 | + content: h(JsonPreview, { data: value }), | |
| 42 | + }); | |
| 43 | + }; | |
| 44 | + const handleRecordContent = (record) => { | |
| 45 | + commonModalInfo('命令下发内容', JSON.parse(record?.request?.body?.params)); | |
| 46 | + }; | |
| 47 | +</script> | ... | ... |