修复下面的问题 和其他页面中的类似问题
1.apps/web-antd/src/views/iot/device/device/modules/DeviceForm.vue
type 是和方法分离的
2.apps/web-antd/src/views/iot/device/device/modules/detail/DeviceDetailsMessage.vue
const getMessageList = async () => {
方法使用function 不要用const,保持一致
3.apps/web-antd/src/views/iot/device/device/modules/detail/DeviceDetailsMessage.vue
<script setup lang="ts">
文件结构是
4.apps/web-antd/src/views/iot/rule/data/rule/index.vue
handleRefresh 统一命名
Signed-off-by: Administrator <425053404@qq.com>
This commit is contained in:
@@ -21,7 +21,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ async function handleDelete(row: AlertConfigApi.AlertConfig) {
|
|||||||
message.success({
|
message.success({
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||||
});
|
});
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="告警配置列表">
|
<Grid table-title="告警配置列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const productList = ref<any[]>([]);
|
|||||||
const deviceList = ref<any[]>([]);
|
const deviceList = ref<any[]>([]);
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import {
|
|||||||
createDevice,
|
createDevice,
|
||||||
getDevice,
|
getDevice,
|
||||||
updateDevice,
|
updateDevice,
|
||||||
type IotDeviceApi
|
|
||||||
} from '#/api/iot/device/device';
|
} from '#/api/iot/device/device';
|
||||||
|
import type { IotDeviceApi } from '#/api/iot/device/device';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { useFormSchema } from '../data';
|
import { useFormSchema } from '../data';
|
||||||
|
|||||||
@@ -111,14 +111,14 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 下载模板 */
|
/** 下载模板 */
|
||||||
const handleDownloadTemplate = async () => {
|
async function handleDownloadTemplate() {
|
||||||
try {
|
try {
|
||||||
const res = await importDeviceTemplate();
|
const res = await importDeviceTemplate();
|
||||||
downloadFileFromBlobPart({ fileName: '设备导入模版.xls', source: res });
|
downloadFileFromBlobPart({ fileName: '设备导入模版.xls', source: res });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
message.error(error.message || '下载失败');
|
message.error(error.message || '下载失败');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ const rowSelection = computed(() => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
async function getList() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
if (props.productId) {
|
if (props.productId) {
|
||||||
@@ -151,22 +151,22 @@ const getList = async () => {
|
|||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
const handleQuery = () => {
|
function handleQuery() {
|
||||||
queryParams.pageNo = 1;
|
queryParams.pageNo = 1;
|
||||||
getList();
|
getList();
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
const resetQuery = () => {
|
function resetQuery() {
|
||||||
queryFormRef.value.resetFields();
|
queryFormRef.value.resetFields();
|
||||||
handleQuery();
|
handleQuery();
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async () => {
|
async function open() {
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
// 重置选择状态
|
// 重置选择状态
|
||||||
selectedDevices.value = [];
|
selectedDevices.value = [];
|
||||||
@@ -178,7 +178,7 @@ const open = async () => {
|
|||||||
}
|
}
|
||||||
// 获取设备列表
|
// 获取设备列表
|
||||||
await getList();
|
await getList();
|
||||||
};
|
}
|
||||||
defineExpose({ open });
|
defineExpose({ open });
|
||||||
|
|
||||||
/** 处理行点击事件 */
|
/** 处理行点击事件 */
|
||||||
|
|||||||
@@ -1,4 +1,164 @@
|
|||||||
<!-- 设备消息列表 -->
|
<script setup lang="ts">
|
||||||
|
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import { ContentWrap } from '@vben/common-ui';
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
import { formatDate } from '@vben/utils';
|
||||||
|
|
||||||
|
import { Button, Form, Pagination, Select, Switch, Table, Tag } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getDeviceMessagePage } from '#/api/iot/device/device';
|
||||||
|
import { DictTag } from '#/components/dict-tag';
|
||||||
|
import { IotDeviceMessageMethodEnum } from '#/views/iot/utils/constants';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
deviceId: number;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
// 查询参数
|
||||||
|
const queryParams = reactive({
|
||||||
|
deviceId: props.deviceId,
|
||||||
|
method: undefined,
|
||||||
|
upstream: undefined,
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 列表数据
|
||||||
|
const loading = ref(false);
|
||||||
|
const total = ref(0);
|
||||||
|
const list = ref<any[]>([]);
|
||||||
|
const autoRefresh = ref(false); // 自动刷新开关
|
||||||
|
let autoRefreshTimer: any = null; // 自动刷新定时器
|
||||||
|
|
||||||
|
// 消息方法选项
|
||||||
|
const methodOptions = computed(() => {
|
||||||
|
return Object.values(IotDeviceMessageMethodEnum).map((item) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.method,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格列定义
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: '时间',
|
||||||
|
dataIndex: 'ts',
|
||||||
|
key: 'ts',
|
||||||
|
align: 'center' as const,
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '上行/下行',
|
||||||
|
dataIndex: 'upstream',
|
||||||
|
key: 'upstream',
|
||||||
|
align: 'center' as const,
|
||||||
|
width: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '是否回复',
|
||||||
|
dataIndex: 'reply',
|
||||||
|
key: 'reply',
|
||||||
|
align: 'center' as const,
|
||||||
|
width: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '请求编号',
|
||||||
|
dataIndex: 'requestId',
|
||||||
|
key: 'requestId',
|
||||||
|
align: 'center' as const,
|
||||||
|
width: 300,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '请求方法',
|
||||||
|
dataIndex: 'method',
|
||||||
|
key: 'method',
|
||||||
|
align: 'center' as const,
|
||||||
|
width: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '请求/响应数据',
|
||||||
|
dataIndex: 'params',
|
||||||
|
key: 'params',
|
||||||
|
align: 'center' as const,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
/** 查询消息列表 */
|
||||||
|
async function getMessageList() {
|
||||||
|
if (!props.deviceId) return;
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const data = await getDeviceMessagePage(queryParams);
|
||||||
|
total.value = data.total;
|
||||||
|
list.value = data.list;
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
queryParams.pageNo = 1;
|
||||||
|
getMessageList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 监听自动刷新 */
|
||||||
|
watch(autoRefresh, (newValue) => {
|
||||||
|
if (newValue) {
|
||||||
|
autoRefreshTimer = setInterval(() => {
|
||||||
|
getMessageList();
|
||||||
|
}, 5000);
|
||||||
|
} else {
|
||||||
|
clearInterval(autoRefreshTimer);
|
||||||
|
autoRefreshTimer = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 监听设备标识变化 */
|
||||||
|
watch(
|
||||||
|
() => props.deviceId,
|
||||||
|
(newValue) => {
|
||||||
|
if (newValue) {
|
||||||
|
handleQuery();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 组件卸载时清除定时器 */
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (autoRefreshTimer) {
|
||||||
|
clearInterval(autoRefreshTimer);
|
||||||
|
autoRefreshTimer = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.deviceId) {
|
||||||
|
getMessageList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新消息列表 */
|
||||||
|
function refresh(delay = 0) {
|
||||||
|
if (delay > 0) {
|
||||||
|
setTimeout(() => {
|
||||||
|
handleQuery();
|
||||||
|
}, delay);
|
||||||
|
} else {
|
||||||
|
handleQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 暴露方法给父组件 */
|
||||||
|
defineExpose({
|
||||||
|
refresh,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<!-- 搜索区域 -->
|
<!-- 搜索区域 -->
|
||||||
@@ -94,164 +254,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
|
||||||
|
|
||||||
import { ContentWrap } from '@vben/common-ui';
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
|
||||||
import { IconifyIcon } from '@vben/icons';
|
|
||||||
import { formatDate } from '@vben/utils';
|
|
||||||
|
|
||||||
import { Button, Form, Pagination, Select, Switch, Table, Tag } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { getDeviceMessagePage } from '#/api/iot/device/device';
|
|
||||||
import { DictTag } from '#/components/dict-tag';
|
|
||||||
import { IotDeviceMessageMethodEnum } from '#/views/iot/utils/constants';
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
deviceId: number;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
// 查询参数
|
|
||||||
const queryParams = reactive({
|
|
||||||
deviceId: props.deviceId,
|
|
||||||
method: undefined,
|
|
||||||
upstream: undefined,
|
|
||||||
pageNo: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 列表数据
|
|
||||||
const loading = ref(false);
|
|
||||||
const total = ref(0);
|
|
||||||
const list = ref<any[]>([]);
|
|
||||||
const autoRefresh = ref(false); // 自动刷新开关
|
|
||||||
let autoRefreshTimer: any = null; // 自动刷新定时器
|
|
||||||
|
|
||||||
// 消息方法选项
|
|
||||||
const methodOptions = computed(() => {
|
|
||||||
return Object.values(IotDeviceMessageMethodEnum).map((item) => ({
|
|
||||||
label: item.name,
|
|
||||||
value: item.method,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
// 表格列定义
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
title: '时间',
|
|
||||||
dataIndex: 'ts',
|
|
||||||
key: 'ts',
|
|
||||||
align: 'center' as const,
|
|
||||||
width: 180,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '上行/下行',
|
|
||||||
dataIndex: 'upstream',
|
|
||||||
key: 'upstream',
|
|
||||||
align: 'center' as const,
|
|
||||||
width: 140,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '是否回复',
|
|
||||||
dataIndex: 'reply',
|
|
||||||
key: 'reply',
|
|
||||||
align: 'center' as const,
|
|
||||||
width: 140,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '请求编号',
|
|
||||||
dataIndex: 'requestId',
|
|
||||||
key: 'requestId',
|
|
||||||
align: 'center' as const,
|
|
||||||
width: 300,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '请求方法',
|
|
||||||
dataIndex: 'method',
|
|
||||||
key: 'method',
|
|
||||||
align: 'center' as const,
|
|
||||||
width: 140,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '请求/响应数据',
|
|
||||||
dataIndex: 'params',
|
|
||||||
key: 'params',
|
|
||||||
align: 'center' as const,
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
/** 查询消息列表 */
|
|
||||||
const getMessageList = async () => {
|
|
||||||
if (!props.deviceId) return;
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
const data = await getDeviceMessagePage(queryParams);
|
|
||||||
total.value = data.total;
|
|
||||||
list.value = data.list;
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 搜索操作 */
|
|
||||||
const handleQuery = () => {
|
|
||||||
queryParams.pageNo = 1;
|
|
||||||
getMessageList();
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 监听自动刷新 */
|
|
||||||
watch(autoRefresh, (newValue) => {
|
|
||||||
if (newValue) {
|
|
||||||
autoRefreshTimer = setInterval(() => {
|
|
||||||
getMessageList();
|
|
||||||
}, 5000);
|
|
||||||
} else {
|
|
||||||
clearInterval(autoRefreshTimer);
|
|
||||||
autoRefreshTimer = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 监听设备标识变化 */
|
|
||||||
watch(
|
|
||||||
() => props.deviceId,
|
|
||||||
(newValue) => {
|
|
||||||
if (newValue) {
|
|
||||||
handleQuery();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/** 组件卸载时清除定时器 */
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
if (autoRefreshTimer) {
|
|
||||||
clearInterval(autoRefreshTimer);
|
|
||||||
autoRefreshTimer = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 初始化 */
|
|
||||||
onMounted(() => {
|
|
||||||
if (props.deviceId) {
|
|
||||||
getMessageList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 刷新消息列表 */
|
|
||||||
const refresh = (delay = 0) => {
|
|
||||||
if (delay > 0) {
|
|
||||||
setTimeout(() => {
|
|
||||||
handleQuery();
|
|
||||||
}, delay);
|
|
||||||
} else {
|
|
||||||
handleQuery();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 暴露方法给父组件 */
|
|
||||||
defineExpose({
|
|
||||||
refresh,
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ const serviceThingModels = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
async function getList() {
|
||||||
if (!props.deviceId) return;
|
if (!props.deviceId) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
@@ -62,43 +62,43 @@ const getList = async () => {
|
|||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
const handleQuery = () => {
|
function handleQuery() {
|
||||||
queryParams.pageNo = 1;
|
queryParams.pageNo = 1;
|
||||||
getList();
|
getList();
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
const resetQuery = () => {
|
function resetQuery() {
|
||||||
queryFormRef.value?.resetFields();
|
queryFormRef.value?.resetFields();
|
||||||
queryParams.identifier = '';
|
queryParams.identifier = '';
|
||||||
queryParams.times = [];
|
queryParams.times = [];
|
||||||
handleQuery();
|
handleQuery();
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 获取服务名称 */
|
/** 获取服务名称 */
|
||||||
const getServiceName = (identifier: string | undefined) => {
|
function getServiceName(identifier: string | undefined) {
|
||||||
if (!identifier) return '-';
|
if (!identifier) return '-';
|
||||||
const service = serviceThingModels.value.find(
|
const service = serviceThingModels.value.find(
|
||||||
(item: ThingModelData) => item.identifier === identifier,
|
(item: ThingModelData) => item.identifier === identifier,
|
||||||
);
|
);
|
||||||
return service?.name || identifier;
|
return service?.name || identifier;
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 获取调用方式 */
|
/** 获取调用方式 */
|
||||||
const getCallType = (identifier: string | undefined) => {
|
function getCallType(identifier: string | undefined) {
|
||||||
if (!identifier) return '-';
|
if (!identifier) return '-';
|
||||||
const service = serviceThingModels.value.find(
|
const service = serviceThingModels.value.find(
|
||||||
(item: ThingModelData) => item.identifier === identifier,
|
(item: ThingModelData) => item.identifier === identifier,
|
||||||
);
|
);
|
||||||
if (!service?.service?.callType) return '-';
|
if (!service?.service?.callType) return '-';
|
||||||
return getThingModelServiceCallTypeLabel(service.service.callType) || '-';
|
return getThingModelServiceCallTypeLabel(service.service.callType) || '-';
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 解析参数 */
|
/** 解析参数 */
|
||||||
const parseParams = (params: string) => {
|
function parseParams(params: string) {
|
||||||
if (!params) return '-';
|
if (!params) return '-';
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(params);
|
const parsed = JSON.parse(params);
|
||||||
@@ -109,7 +109,7 @@ const parseParams = (params: string) => {
|
|||||||
} catch {
|
} catch {
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 初始化 */
|
/** 初始化 */
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ async function handleDelete(row: IotDeviceGroupApi.DeviceGroup) {
|
|||||||
message.success({
|
message.success({
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||||
});
|
});
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="设备分组列表">
|
<Grid table-title="设备分组列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ async function handleDelete(row: IoTOtaFirmwareApi.Firmware) {
|
|||||||
message.success({
|
message.success({
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||||
});
|
});
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="固件列表">
|
<Grid table-title="固件列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ async function handleDelete(row: IoTOtaFirmwareApi.Firmware) {
|
|||||||
message.success({
|
message.success({
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||||
});
|
});
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="OTA 固件列表">
|
<Grid table-title="OTA 固件列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ async function handleDelete(row: any) {
|
|||||||
message.success({
|
message.success({
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||||
});
|
});
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="数据规则列表">
|
<Grid table-title="数据规则列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ async function handleDelete(row: any) {
|
|||||||
message.success({
|
message.success({
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||||
});
|
});
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="数据规则列表">
|
<Grid table-title="数据规则列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ async function handleDelete(row: any) {
|
|||||||
message.success({
|
message.success({
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||||
});
|
});
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="数据目的列表">
|
<Grid table-title="数据目的列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const subGroup = useVModel(props, 'modelValue', emit);
|
|||||||
const maxConditions = computed(() => props.maxConditions || 3); // 最大条件数量
|
const maxConditions = computed(() => props.maxConditions || 3); // 最大条件数量
|
||||||
|
|
||||||
/** 添加条件 */
|
/** 添加条件 */
|
||||||
const addCondition = async () => {
|
async function addCondition() {
|
||||||
// 确保 subGroup.value 是一个数组
|
// 确保 subGroup.value 是一个数组
|
||||||
if (!subGroup.value) {
|
if (!subGroup.value) {
|
||||||
subGroup.value = [];
|
subGroup.value = [];
|
||||||
@@ -58,7 +58,7 @@ const addCondition = async () => {
|
|||||||
if (subGroup.value) {
|
if (subGroup.value) {
|
||||||
subGroup.value.push(newCondition);
|
subGroup.value.push(newCondition);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除条件
|
* 移除条件
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ async function handleToggleStatus(row: RuleSceneApi.SceneRule) {
|
|||||||
message.success({
|
message.success({
|
||||||
content: newStatus === 0 ? '启用成功' : '停用成功',
|
content: newStatus === 0 ? '启用成功' : '停用成功',
|
||||||
});
|
});
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ async function handleDelete(row: RuleSceneApi.SceneRule) {
|
|||||||
message.success({
|
message.success({
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||||
});
|
});
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="场景规则列表">
|
<Grid table-title="场景规则列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
|||||||
@@ -63,17 +63,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 新增功能
|
// 新增功能
|
||||||
const handleCreate = () => {
|
function handleCreate() {
|
||||||
thingModelFormRef.value?.open('create');
|
thingModelFormRef.value?.open('create');
|
||||||
};
|
}
|
||||||
|
|
||||||
// 编辑功能
|
// 编辑功能
|
||||||
const handleEdit = (row: any) => {
|
function handleEdit(row: any) {
|
||||||
thingModelFormRef.value?.open('update', row.id);
|
thingModelFormRef.value?.open('update', row.id);
|
||||||
};
|
}
|
||||||
|
|
||||||
// 删除功能
|
// 删除功能
|
||||||
const handleDelete = async (row: any) => {
|
async function handleDelete(row: any) {
|
||||||
try {
|
try {
|
||||||
await deleteThingModel(row.id);
|
await deleteThingModel(row.id);
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
@@ -81,31 +81,31 @@ const handleDelete = async (row: any) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('删除失败:', error);
|
console.error('删除失败:', error);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// 打开 TSL
|
// 打开 TSL
|
||||||
const handleOpenTSL = () => {
|
function handleOpenTSL() {
|
||||||
thingModelTSLRef.value?.open();
|
thingModelTSLRef.value?.open();
|
||||||
};
|
}
|
||||||
|
|
||||||
// 获取数据类型标签
|
// 获取数据类型标签
|
||||||
const getDataTypeLabel = (row: any) => {
|
function getDataTypeLabel(row: any) {
|
||||||
return getDataTypeOptionsLabel(row.property?.dataType) || '-';
|
return getDataTypeOptionsLabel(row.property?.dataType) || '-';
|
||||||
};
|
}
|
||||||
|
|
||||||
// 刷新表格
|
// 刷新表格
|
||||||
const handleRefresh = () => {
|
function handleRefresh() {
|
||||||
gridApi.reload();
|
gridApi.reload();
|
||||||
};
|
}
|
||||||
|
|
||||||
// 获取产品信息
|
// 获取产品信息
|
||||||
const getProductData = async () => {
|
async function getProductData() {
|
||||||
try {
|
try {
|
||||||
product.value = await getProduct(props.productId);
|
product.value = await getProduct(props.productId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取产品信息失败:', error);
|
console.error('获取产品信息失败:', error);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ const formData = ref<any>({
|
|||||||
const formRef = ref(); // 表单 Ref
|
const formRef = ref(); // 表单 Ref
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number) => {
|
async function open(type: string, id?: number) {
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
// 设置标题:create -> 新增,update -> 编辑
|
// 设置标题:create -> 新增,update -> 编辑
|
||||||
dialogTitle.value = type === 'create' ? $t('page.action.add') : $t('page.action.edit');
|
dialogTitle.value = type === 'create' ? $t('page.action.add') : $t('page.action.edit');
|
||||||
@@ -137,7 +137,7 @@ const open = async (type: string, id?: number) => {
|
|||||||
formLoading.value = false;
|
formLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
defineExpose({ open, close: () => (dialogVisible.value = false) });
|
defineExpose({ open, close: () => (dialogVisible.value = false) });
|
||||||
|
|
||||||
async function submitForm() {
|
async function submitForm() {
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ const product = inject<Ref<IotProductApi.Product>>(IOT_PROVIDE_KEY.PRODUCT); //
|
|||||||
const viewMode = ref('view'); // 查看模式:view-代码视图,editor-编辑器视图
|
const viewMode = ref('view'); // 查看模式:view-代码视图,editor-编辑器视图
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async () => {
|
async function open() {
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
await getTsl();
|
await getTsl();
|
||||||
};
|
}
|
||||||
defineExpose({ open });
|
defineExpose({ open });
|
||||||
|
|
||||||
/** 获取 TSL */
|
/** 获取 TSL */
|
||||||
const thingModelTSL = ref<any>({});
|
const thingModelTSL = ref<any>({});
|
||||||
const tslString = ref(''); // 用于编辑器的字符串格式
|
const tslString = ref(''); // 用于编辑器的字符串格式
|
||||||
|
|
||||||
const getTsl = async () => {
|
async function getTsl() {
|
||||||
try {
|
try {
|
||||||
thingModelTSL.value = await getThingModelTSL(product?.value?.id || 0);
|
thingModelTSL.value = await getThingModelTSL(product?.value?.id || 0);
|
||||||
// 将对象转换为格式化的 JSON 字符串
|
// 将对象转换为格式化的 JSON 字符串
|
||||||
@@ -38,7 +38,7 @@ const getTsl = async () => {
|
|||||||
thingModelTSL.value = {};
|
thingModelTSL.value = {};
|
||||||
tslString.value = '{}';
|
tslString.value = '{}';
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 格式化的 TSL 用于只读展示 */
|
/** 格式化的 TSL 用于只读展示 */
|
||||||
const formattedTSL = computed(() => {
|
const formattedTSL = computed(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user