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