Merge remote-tracking branch 'origin/master'
commit
cb78c2935d
|
|
@ -13,7 +13,7 @@
|
||||||
<el-button
|
<el-button
|
||||||
@click="openForm('update', product.id)"
|
@click="openForm('update', product.id)"
|
||||||
v-hasPermi="['iot:product:update']"
|
v-hasPermi="['iot:product:update']"
|
||||||
:disabled="product.status === 1"
|
:disabled="product.status === ProductStatusEnum.PUBLISHED"
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="confirmPublish(product.id)"
|
@click="confirmPublish(product.id)"
|
||||||
v-hasPermi="['iot:product:update']"
|
v-hasPermi="['iot:product:update']"
|
||||||
v-if="product.status === 0"
|
v-if="product.status === ProductStatusEnum.UNPUBLISHED"
|
||||||
>
|
>
|
||||||
发布
|
发布
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="confirmUnpublish(product.id)"
|
@click="confirmUnpublish(product.id)"
|
||||||
v-hasPermi="['iot:product:update']"
|
v-hasPermi="['iot:product:update']"
|
||||||
v-if="product.status === 1"
|
v-if="product.status === ProductStatusEnum.PUBLISHED"
|
||||||
>
|
>
|
||||||
撤销发布
|
撤销发布
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -54,6 +54,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import ProductForm from '@/views/iot/product/product/ProductForm.vue'
|
import ProductForm from '@/views/iot/product/product/ProductForm.vue'
|
||||||
import { ProductApi, ProductVO } from '@/api/iot/product/product'
|
import { ProductApi, ProductVO } from '@/api/iot/product/product'
|
||||||
|
import { ProductStatusEnum } from '@/views/iot/utils/constants'
|
||||||
import { useClipboard } from '@vueuse/core'
|
import { useClipboard } from '@vueuse/core'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
@ -90,7 +91,7 @@ const openForm = (type: string, id?: number) => {
|
||||||
/** 发布操作 */
|
/** 发布操作 */
|
||||||
const confirmPublish = async (id: number) => {
|
const confirmPublish = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
await ProductApi.updateProductStatus(id, 1)
|
await ProductApi.updateProductStatus(id, ProductStatusEnum.PUBLISHED)
|
||||||
message.success('发布成功')
|
message.success('发布成功')
|
||||||
formRef.value.close() // 关闭弹框
|
formRef.value.close() // 关闭弹框
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
|
|
@ -102,7 +103,7 @@ const confirmPublish = async (id: number) => {
|
||||||
/** 撤销发布操作 */
|
/** 撤销发布操作 */
|
||||||
const confirmUnpublish = async (id: number) => {
|
const confirmUnpublish = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
await ProductApi.updateProductStatus(id, 0)
|
await ProductApi.updateProductStatus(id, ProductStatusEnum.UNPUBLISHED)
|
||||||
message.success('撤销发布成功')
|
message.success('撤销发布成功')
|
||||||
formRef.value.close() // 关闭弹框
|
formRef.value.close() // 关闭弹框
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
<div class="mx-[10px] h-[20px] w-[1px] bg-[#dcdfe6]"></div>
|
<div class="mx-[10px] h-[20px] w-[1px] bg-[#dcdfe6]"></div>
|
||||||
<el-button
|
<el-button
|
||||||
v-hasPermi="['iot:product:delete']"
|
v-hasPermi="['iot:product:delete']"
|
||||||
:disabled="item.status === 1"
|
:disabled="item.status === ProductStatusEnum.PUBLISHED"
|
||||||
class="!px-2 !h-[32px] text-[13px]"
|
class="!px-2 !h-[32px] text-[13px]"
|
||||||
plain
|
plain
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -216,7 +216,7 @@
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
v-hasPermi="['iot:product:delete']"
|
v-hasPermi="['iot:product:delete']"
|
||||||
:disabled="scope.row.status === 1"
|
:disabled="scope.row.status === ProductStatusEnum.PUBLISHED"
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="handleDelete(scope.row.id)"
|
@click="handleDelete(scope.row.id)"
|
||||||
|
|
@ -248,6 +248,7 @@ import { DICT_TYPE } from '@/utils/dict'
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
import defaultPicUrl from '@/assets/imgs/iot/device.png'
|
import defaultPicUrl from '@/assets/imgs/iot/device.png'
|
||||||
import defaultIconUrl from '@/assets/svgs/iot/cube.svg'
|
import defaultIconUrl from '@/assets/svgs/iot/cube.svg'
|
||||||
|
import { ProductStatusEnum } from '@/views/iot/utils/constants'
|
||||||
|
|
||||||
/** iot 产品列表 */
|
/** iot 产品列表 */
|
||||||
defineOptions({ name: 'IoTProduct' })
|
defineOptions({ name: 'IoTProduct' })
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,7 @@
|
||||||
:key="config.id"
|
:key="config.id"
|
||||||
:label="config.name"
|
:label="config.name"
|
||||||
:value="config.id"
|
:value="config.id"
|
||||||
>
|
/>
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<span>{{ config.name }}</span>
|
|
||||||
<el-tag :type="config.enabled ? 'success' : 'danger'" size="small">
|
|
||||||
{{ config.enabled ? '启用' : '禁用' }}
|
|
||||||
</el-tag>
|
|
||||||
</div>
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -57,18 +50,11 @@ const handleChange = (value?: number) => {
|
||||||
emit('update:modelValue', value)
|
emit('update:modelValue', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 加载告警配置列表 */
|
||||||
* 加载告警配置列表
|
|
||||||
*/
|
|
||||||
const loadAlertConfigs = async () => {
|
const loadAlertConfigs = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const data = await AlertConfigApi.getAlertConfigPage({
|
alertConfigs.value = (await AlertConfigApi.getSimpleAlertConfigList()) || []
|
||||||
pageNo: 1,
|
|
||||||
pageSize: 100,
|
|
||||||
enabled: true // 只加载启用的配置
|
|
||||||
})
|
|
||||||
alertConfigs.value = data.list || []
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -222,8 +222,9 @@ const removeAction = (index: number) => {
|
||||||
* @param type 执行器类型
|
* @param type 执行器类型
|
||||||
*/
|
*/
|
||||||
const updateActionType = (index: number, type: number) => {
|
const updateActionType = (index: number, type: number) => {
|
||||||
actions.value[index].type = type
|
const action = actions.value[index]
|
||||||
onActionTypeChange(actions.value[index], type)
|
onActionTypeChange(action, type) // 须在赋新值前调用 ,内部依赖 action.type 旧值
|
||||||
|
action.type = type
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -258,7 +259,7 @@ const onActionTypeChange = (action: Action, type: number) => {
|
||||||
action.params = ''
|
action.params = ''
|
||||||
}
|
}
|
||||||
// 如果从其他类型切换到设备控制类型,清空identifier(让用户重新选择)
|
// 如果从其他类型切换到设备控制类型,清空identifier(让用户重新选择)
|
||||||
if (action.identifier && type !== action.type) {
|
if (action.identifier) {
|
||||||
action.identifier = undefined
|
action.identifier = undefined
|
||||||
}
|
}
|
||||||
} else if (isAlertAction(type)) {
|
} else if (isAlertAction(type)) {
|
||||||
|
|
|
||||||
|
|
@ -72,13 +72,12 @@ const getDeviceList = async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deviceLoading.value = true
|
deviceLoading.value = true
|
||||||
const res = await DeviceApi.getDeviceListByProductId(props.productId)
|
const data = await DeviceApi.getDeviceListByProductId(props.productId)
|
||||||
deviceList.value = res || []
|
deviceList.value = [DEVICE_SELECTOR_OPTIONS.ALL_DEVICES, ...(data || [])]
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取设备列表失败:', error)
|
console.error('获取设备列表失败:', error)
|
||||||
deviceList.value = []
|
deviceList.value = [DEVICE_SELECTOR_OPTIONS.ALL_DEVICES]
|
||||||
} finally {
|
} finally {
|
||||||
deviceList.value.unshift(DEVICE_SELECTOR_OPTIONS.ALL_DEVICES)
|
|
||||||
deviceLoading.value = false
|
deviceLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,12 @@ export enum DeviceStateEnum {
|
||||||
OFFLINE = 2 // 离线
|
OFFLINE = 2 // 离线
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** IoT 产品状态枚举 */
|
||||||
|
export enum ProductStatusEnum {
|
||||||
|
UNPUBLISHED = 0, // 未发布
|
||||||
|
PUBLISHED = 1 // 已发布
|
||||||
|
}
|
||||||
|
|
||||||
/** IoT 产品物模型类型枚举类 */
|
/** IoT 产品物模型类型枚举类 */
|
||||||
export const IoTThingModelTypeEnum = {
|
export const IoTThingModelTypeEnum = {
|
||||||
PROPERTY: 1, // 属性
|
PROPERTY: 1, // 属性
|
||||||
|
|
@ -432,12 +438,12 @@ export const IoTDeviceStatusEnum = {
|
||||||
// 在线状态
|
// 在线状态
|
||||||
ONLINE: {
|
ONLINE: {
|
||||||
label: '在线',
|
label: '在线',
|
||||||
value: 'online',
|
value: '1',
|
||||||
tagType: 'success'
|
tagType: 'success'
|
||||||
},
|
},
|
||||||
OFFLINE: {
|
OFFLINE: {
|
||||||
label: '离线',
|
label: '离线',
|
||||||
value: 'offline',
|
value: '2',
|
||||||
tagType: 'danger'
|
tagType: 'danger'
|
||||||
},
|
},
|
||||||
// 启用状态
|
// 启用状态
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue