Skip to content

Commit 59062a1

Browse files
author
puhui999
committed
【代码优化】IoT: 数据桥梁配置切换使用字典值
1 parent 5c0a0e6 commit 59062a1

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/api/iot/rule/databridge/index.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import request from '@/config/axios'
22

3-
// IoT 数据桥梁 VO
3+
//数据桥梁 VO
44
export interface DataBridgeVO {
55
id?: number // 桥梁编号
66
name?: string // 桥梁名称
@@ -81,45 +81,45 @@ export interface RedisStreamMQConfig extends Config {
8181

8282
/** 数据桥梁类型 */
8383
export const IoTDataBridgeConfigType = {
84-
HTTP: 'HTTP',
85-
TCP: 'TCP',
86-
WEBSOCKET: 'WEBSOCKET',
87-
MQTT: 'MQTT',
88-
DATABASE: 'DATABASE',
89-
REDIS_STREAM: 'REDIS_STREAM',
90-
ROCKETMQ: 'ROCKETMQ',
91-
RABBITMQ: 'RABBITMQ',
92-
KAFKA: 'KAFKA'
84+
HTTP: '1',
85+
TCP: '2',
86+
WEBSOCKET: '3',
87+
MQTT: '10',
88+
DATABASE: '20',
89+
REDIS_STREAM: '21',
90+
ROCKETMQ: '30',
91+
RABBITMQ: '31',
92+
KAFKA: '32'
9393
} as const
9494

95-
// IoT 数据桥梁 API
95+
// 数据桥梁 API
9696
export const DataBridgeApi = {
97-
// 查询IoT 数据桥梁分页
97+
// 查询数据桥梁分页
9898
getDataBridgePage: async (params: any) => {
9999
return await request.get({ url: `/iot/data-bridge/page`, params })
100100
},
101101

102-
// 查询IoT 数据桥梁详情
102+
// 查询数据桥梁详情
103103
getDataBridge: async (id: number) => {
104104
return await request.get({ url: `/iot/data-bridge/get?id=` + id })
105105
},
106106

107-
// 新增IoT 数据桥梁
107+
// 新增数据桥梁
108108
createDataBridge: async (data: DataBridgeVO) => {
109109
return await request.post({ url: `/iot/data-bridge/create`, data })
110110
},
111111

112-
// 修改IoT 数据桥梁
112+
// 修改数据桥梁
113113
updateDataBridge: async (data: DataBridgeVO) => {
114114
return await request.put({ url: `/iot/data-bridge/update`, data })
115115
},
116116

117-
// 删除IoT 数据桥梁
117+
// 删除数据桥梁
118118
deleteDataBridge: async (id: number) => {
119119
return await request.delete({ url: `/iot/data-bridge/delete?id=` + id })
120120
},
121121

122-
// 导出IoT 数据桥梁 Excel
122+
// 导出数据桥梁 Excel
123123
exportDataBridge: async (params) => {
124124
return await request.download({ url: `/iot/data-bridge/export-excel`, params })
125125
}

src/views/iot/rule/databridge/IoTDataBridgeForm.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
</Dialog>
7373
</template>
7474
<script lang="ts" setup>
75-
import { DICT_TYPE, getDictLabel, getIntDictOptions } from '@/utils/dict'
75+
import { DICT_TYPE, getDictObj, getIntDictOptions } from '@/utils/dict'
7676
import { DataBridgeApi, DataBridgeVO, IoTDataBridgeConfigType } from '@/api/iot/rule/databridge'
7777
import {
7878
HttpConfigForm,
@@ -140,8 +140,8 @@ const formRules = reactive({
140140
141141
const formRef = ref() // 表单 Ref
142142
const showConfig = computed(() => (val: string) => {
143-
const label = getDictLabel(DICT_TYPE.IOT_DATA_BRIDGE_TYPE_ENUM, formData.value.type)
144-
return label && label === val
143+
const dict = getDictObj(DICT_TYPE.IOT_DATA_BRIDGE_TYPE_ENUM, formData.value.type)
144+
return dict && dict.value + '' === val
145145
}) // 显示对应的 Config 配置项
146146
/** 打开弹窗 */
147147
const open = async (type: string, id?: number) => {

0 commit comments

Comments
 (0)