【代码评审】IoT:场景联动的 review

This commit is contained in:
YunaiV 2025-03-30 10:18:33 +08:00
parent 30c9f0b872
commit 782337952d
12 changed files with 28 additions and 33 deletions

View File

@ -162,12 +162,13 @@ export const DeviceApi = {
return await request.get({ url: `/iot/device/log/page`, params }) return await request.get({ url: `/iot/device/log/page`, params })
}, },
// 获取设备MQTT连接参数 // 获取设备 MQTT 连接参数
getMqttConnectionParams: async (deviceId: number) => { getMqttConnectionParams: async (deviceId: number) => {
return await request.get({ url: `/iot/device/mqtt-connection-params`, params: { deviceId } }) return await request.get({ url: `/iot/device/mqtt-connection-params`, params: { deviceId } })
}, },
// 根据ProductKey和DeviceNames获取设备列表 // 根据 ProductKey 和 DeviceNames 获取设备列表
// TODO @puhui999getDeviceListByProductKeyAndNames 哈。项目的风格统一~
getDevicesByProductKeyAndNames: async (productKey: string, deviceNames: string[]) => { getDevicesByProductKeyAndNames: async (productKey: string, deviceNames: string[]) => {
return await request.get({ return await request.get({
url: `/iot/device/list-by-product-key-and-names`, url: `/iot/device/list-by-product-key-and-names`,

View File

@ -80,7 +80,7 @@ export const ProductApi = {
return request.get({ url: '/iot/product/simple-list' }) return request.get({ url: '/iot/product/simple-list' })
}, },
// 根据ProductKey获取产品信息 // 根据 ProductKey 获取产品信息
getProductByKey: async (productKey: string) => { getProductByKey: async (productKey: string) => {
return await request.get({ url: `/iot/product/get-by-key`, params: { productKey } }) return await request.get({ url: `/iot/product/get-by-key`, params: { productKey } })
} }

View File

@ -125,6 +125,7 @@ export const DataBridgeApi = {
}, },
// 查询数据桥梁(精简)列表 // 查询数据桥梁(精简)列表
// TODO @puhui999getDataBridgeSimpleList 哈。项目的风格统一~ 之前有几个,我写错了。。。
getSimpleDataBridgeList() { getSimpleDataBridgeList() {
return request.get({ url: '/iot/data-bridge/simple-list' }) return request.get({ url: '/iot/data-bridge/simple-list' })
} }

View File

@ -100,7 +100,7 @@ interface ActionAlert {
// 执行器配置 // 执行器配置
interface ActionConfig { interface ActionConfig {
key: any // 解决组件索引重用 key: any // 解决组件索引重用 TODO @puhui999看看有没更好的解决方案呢。
type: number // 执行类型 type: number // 执行类型
deviceControl?: ActionDeviceControl // 设备控制 deviceControl?: ActionDeviceControl // 设备控制
alert?: ActionAlert // 告警执行 alert?: ActionAlert // 告警执行

View File

@ -18,8 +18,8 @@ export const getSimpleDeptList = async (): Promise<DeptVO[]> => {
} }
// 查询部门列表 // 查询部门列表
export const getDeptPage = async (params: PageParam) => { export const getDeptList = async () => {
return await request.get({ url: '/system/dept/list', params }) return await request.get({ url: '/system/dept/list' })
} }
// 查询部门详情 // 查询部门详情

View File

@ -12,11 +12,6 @@ export interface RoleVO {
createTime: Date createTime: Date
} }
export interface UpdateStatusReqVO {
id: number
status: number
}
// 查询角色列表 // 查询角色列表
export const getRolePage = async (params: PageParam) => { export const getRolePage = async (params: PageParam) => {
return await request.get({ url: '/system/role/page', params }) return await request.get({ url: '/system/role/page', params })
@ -42,18 +37,13 @@ export const updateRole = async (data: RoleVO) => {
return await request.put({ url: '/system/role/update', data }) return await request.put({ url: '/system/role/update', data })
} }
// 修改角色状态
export const updateRoleStatus = async (data: UpdateStatusReqVO) => {
return await request.put({ url: '/system/role/update-status', data })
}
// 删除角色 // 删除角色
export const deleteRole = async (id: number) => { export const deleteRole = async (id: number) => {
return await request.delete({ url: '/system/role/delete?id=' + id }) return await request.delete({ url: '/system/role/delete?id=' + id })
} }
// 导出角色 // 导出角色
export const exportRole = (params) => { export const exportRole = (params: any) => {
return request.download({ return request.download({
url: '/system/role/export-excel', url: '/system/role/export-excel',
params params

View File

@ -1,12 +1,12 @@
<template> <template>
<Dialog v-model="dialogVisible" :title="dialogTitle" :appendToBody="true" v-loading="loading"> <Dialog v-model="dialogVisible" :title="dialogTitle" :appendToBody="true" v-loading="loading">
<div class="flex h-600px"> <div class="flex h-600px">
<!-- 左侧物模型属性view模式 --> <!-- 左侧物模型属性view 模式 -->
<div class="w-1/2 border-r border-gray-200 pr-2 overflow-auto"> <div class="w-1/2 border-r border-gray-200 pr-2 overflow-auto">
<JsonEditor :model-value="thingModel" mode="view" height="600px" /> <JsonEditor :model-value="thingModel" mode="view" height="600px" />
</div> </div>
<!-- 右侧JSON编辑器code模式 --> <!-- 右侧 JSON 编辑器code 模式 -->
<div class="w-1/2 pl-2 overflow-auto"> <div class="w-1/2 pl-2 overflow-auto">
<JsonEditor v-model="editableModelTSL" mode="code" height="600px" @error="handleError" /> <JsonEditor v-model="editableModelTSL" mode="code" height="600px" @error="handleError" />
</div> </div>

View File

@ -193,16 +193,13 @@ watch(
{ immediate: true } { immediate: true }
) )
/** /** 初始化产品回显信息 */
* 初始化产品回显信息
*/
const initProductInfo = async () => { const initProductInfo = async () => {
if (!actionConfig.value.deviceControl?.productKey) { if (!actionConfig.value.deviceControl?.productKey) {
return return
} }
try { try {
// 使APIproductKey
const productData = await ProductApi.getProductByKey( const productData = await ProductApi.getProductByKey(
actionConfig.value.deviceControl.productKey actionConfig.value.deviceControl.productKey
) )
@ -226,12 +223,10 @@ const initDeviceInfo = async () => {
} }
try { try {
// 使APIproductKeydeviceNames
const deviceData = await DeviceApi.getDevicesByProductKeyAndNames( const deviceData = await DeviceApi.getDevicesByProductKeyAndNames(
actionConfig.value.deviceControl.productKey, actionConfig.value.deviceControl.productKey,
actionConfig.value.deviceControl.deviceNames actionConfig.value.deviceControl.deviceNames
) )
if (deviceData && deviceData.length > 0) { if (deviceData && deviceData.length > 0) {
deviceList.value = deviceData deviceList.value = deviceData
} }

View File

@ -8,6 +8,8 @@
clearable clearable
placeholder="选择接收方式" placeholder="选择接收方式"
> >
<!-- TODO @芋艿后续搞成字典 -->
<!-- TODO @puhui999这里好像是 1/2/3 -->
<el-option <el-option
v-for="(value, key) in IotAlertConfigReceiveTypeEnum" v-for="(value, key) in IotAlertConfigReceiveTypeEnum"
:key="value" :key="value"
@ -16,7 +18,10 @@
/> />
</el-select> </el-select>
</div> </div>
<div v-if="alertConfig.receiveType === IotAlertConfigReceiveTypeEnum.SMS" class="flex items-center mb-10px"> <div
v-if="alertConfig.receiveType === IotAlertConfigReceiveTypeEnum.SMS"
class="flex items-center mb-10px"
>
<span class="mr-10px w-80px">手机号码</span> <span class="mr-10px w-80px">手机号码</span>
<el-select <el-select
v-model="alertConfig.phoneNumbers" v-model="alertConfig.phoneNumbers"
@ -28,7 +33,10 @@
placeholder="请输入手机号码" placeholder="请输入手机号码"
/> />
</div> </div>
<div v-if="alertConfig.receiveType === IotAlertConfigReceiveTypeEnum.MAIL" class="flex items-center mb-10px"> <div
v-if="alertConfig.receiveType === IotAlertConfigReceiveTypeEnum.MAIL"
class="flex items-center mb-10px"
>
<span class="mr-10px w-80px">邮箱地址</span> <span class="mr-10px w-80px">邮箱地址</span>
<el-select <el-select
v-model="alertConfig.emails" v-model="alertConfig.emails"

View File

@ -25,7 +25,7 @@ const props = defineProps<{ modelValue: any }>()
const emits = defineEmits(['update:modelValue']) const emits = defineEmits(['update:modelValue'])
const dataBridgeId = useVModel(props, 'modelValue', emits) const dataBridgeId = useVModel(props, 'modelValue', emits)
const dataBridgeList = ref<any[]>([]) /** 数据桥接列表 */ const dataBridgeList = ref<any[]>([]) //
/** 获取数据桥接列表 */ /** 获取数据桥接列表 */
const getDataBridgeList = async () => { const getDataBridgeList = async () => {

View File

@ -162,7 +162,7 @@ const initDeviceControlConfig = () => {
})) }))
} }
// data // data
if (!deviceControlConfig.value.data) { if (!deviceControlConfig.value.data) {
deviceControlConfig.value.data = {} deviceControlConfig.value.data = {}
} }

View File

@ -134,7 +134,7 @@ const userList = ref<UserApi.UserVO[]>([]) // 用户列表
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await DeptApi.getDeptPage(queryParams) const data = await DeptApi.getDeptList(queryParams)
list.value = handleTree(data) list.value = handleTree(data)
} finally { } finally {
loading.value = false loading.value = false