From 20509909989558fa22694638f1b79b2be0d49174 Mon Sep 17 00:00:00 2001
From: JiangQiming <291854119@qq.com>
Date: Fri, 17 Mar 2023 15:01:16 +0800
Subject: [PATCH 01/14] fix: bug#10538
---
src/views/media/Cascade/index.vue | 6 +++++-
src/views/media/Device/Save/index.vue | 3 +--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/views/media/Cascade/index.vue b/src/views/media/Cascade/index.vue
index 64b14661..341f7f3c 100644
--- a/src/views/media/Cascade/index.vue
+++ b/src/views/media/Cascade/index.vue
@@ -51,7 +51,7 @@
{{ slotProps.name }}
- 通道数量:{{ slotProps.count }}
+ 通道数量:{{ slotProps.count || 0 }}
{{ slotProps.sipConfigs[0]?.publicHost }}
+
+ {{ slotProps.count || 0 }}
+
-
From 3794849946374ab1847993c9d11a194b369667d3 Mon Sep 17 00:00:00 2001
From: easy <1358086367@qq.com>
Date: Fri, 17 Mar 2023 15:18:32 +0800
Subject: [PATCH 02/14] =?UTF-8?q?update:=20api=E9=85=8D=E7=BD=AE=E4=BC=98?=
=?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/system/Basis/index.vue | 2 +-
.../Platforms/Api/components/ApiDoes.vue | 140 +++++-------------
.../Platforms/Api/components/ApiTest.vue | 84 +----------
src/views/system/Platforms/Api/typing.d.ts | 9 +-
src/views/system/Platforms/Api/utils.ts | 90 +++++++++++
5 files changed, 137 insertions(+), 188 deletions(-)
create mode 100644 src/views/system/Platforms/Api/utils.ts
diff --git a/src/views/system/Basis/index.vue b/src/views/system/Basis/index.vue
index a680c581..590f7498 100644
--- a/src/views/system/Basis/index.vue
+++ b/src/views/system/Basis/index.vue
@@ -290,7 +290,7 @@ import { message } from 'ant-design-vue';
import { BASE_API_PATH, TOKEN_KEY } from '@/utils/variable';
import { LocalStore } from '@/utils/comm';
-import { save_api, getDetails_api } from '@/api/system/basis';
+import { save_api } from '@/api/system/basis';
import { usePermissionStore } from '@/store/permission';
import { useSystem } from '@/store/system';
diff --git a/src/views/system/Platforms/Api/components/ApiDoes.vue b/src/views/system/Platforms/Api/components/ApiDoes.vue
index ebaeff99..3731ea6b 100644
--- a/src/views/system/Platforms/Api/components/ApiDoes.vue
+++ b/src/views/system/Platforms/Api/components/ApiDoes.vue
@@ -91,6 +91,16 @@ import 'vue3-json-viewer/dist/index.css';
import type { apiDetailsType } from '../typing';
import InputCard from './InputCard.vue';
import { PropType } from 'vue';
+import { findData, getCodeText } from '../utils';
+
+type cardType = {
+ columns: object[];
+ tableData: any[];
+ codeText?: any;
+ activeKey?: string;
+ getData: Function;
+};
+
const props = defineProps({
selectApi: {
@@ -104,14 +114,8 @@ const props = defineProps({
});
const { selectApi } = toRefs(props);
-type tableCardType = {
- columns: object[];
- tableData: any[];
- codeText?: any;
- activeKey?: any;
- getData?: any;
-};
-const requestCard = reactive({
+
+const requestCard = reactive({
columns: [
{
title: '参数名',
@@ -149,16 +153,16 @@ const requestCard = reactive({
const schema =
props.selectApi.requestBody.content['application/json'].schema;
const _ref = schema.$ref || schema?.items?.$ref;
- if(!_ref) return; // schema不是Java中的类的话则不进行解析,直接结束
+ if (!_ref) return; // schema不是Java中的类的话则不进行解析,直接结束
+
const schemaName = _ref?.split('/').pop();
const type = schema.type || '';
- const tableData = findData(schemaName);
- if (type === 'array') {
- requestCard.codeText = [getCodeText(tableData, 3)];
- } else requestCard.codeText = getCodeText(tableData, 3);
- // console.clear();
- // console.log(schemaName, tableData);
+ const tableData = findData(props.schemas, schemaName);
+ requestCard.codeText =
+ type === 'array'
+ ? [getCodeText(props.schemas, tableData, 3)]
+ : getCodeText(props.schemas, tableData, 3);
requestCard.tableData = [
{
name: schemaName[0].toLowerCase() + schemaName.substring(1),
@@ -176,7 +180,7 @@ const requestCard = reactive({
];
},
});
-const responseStatusCard = reactive({
+const responseStatusCard = reactive({
activeKey: '',
columns: [
{
@@ -220,7 +224,7 @@ const tabs = computed(() =>
.map((item: any) => item.code + '')
.filter((code: string) => code !== '400'),
);
-const respParamsCard = reactive({
+const respParamsCard = reactive({
columns: [
{
title: '参数名称',
@@ -242,9 +246,8 @@ const respParamsCard = reactive({
(item: any) => item.code === code,
)?.schema;
- const tableData = findData(schemaName);
- respParamsCard.codeText = getCodeText(tableData, 3);
-
+ const tableData = findData(props.schemas, schemaName);
+ respParamsCard.codeText = getCodeText(props.schemas, tableData, 3);
respParamsCard.tableData = tableData;
},
});
@@ -258,95 +261,18 @@ const getContent = (data: any) => {
onMounted(() => {
requestCard.getData();
responseStatusCard.getData();
-});
-watch(
- () => props.selectApi,
- () => {
- requestCard.getData();
- responseStatusCard.getData();
- },
-);
+ watch(
+ () => props.selectApi,
+ () => {
+ requestCard.getData();
+ responseStatusCard.getData();
+ },
+ );
-watch([() => responseStatusCard.activeKey, () => props.selectApi], (n) => {
- n[0] && respParamsCard.getData(n[0]);
-});
-
-function findData(schemaName: string) {
- const schemas = toRaw(props.schemas);
- const basicType = ['string', 'integer', 'boolean'];
-
- if (!schemaName || !schemas[schemaName]) {
- return [];
- }
- const result: schemaObjType[] = [];
- const schema = schemas[schemaName];
- Object.entries(schema.properties).forEach((item: [string, any]) => {
- const paramsType =
- item[1].type ||
- (item[1].$ref && item[1].$ref.split('/').pop()) ||
- (item[1].items && item[1].items.$ref.split('/').pop()) ||
- '';
- const schemaObj: schemaObjType = {
- paramsName: item[0],
- paramsType,
- desc: item[1].description || '',
- };
- if (!basicType.includes(paramsType))
- schemaObj.children = findData(paramsType);
- result.push(schemaObj);
+ watch([() => responseStatusCard.activeKey, () => props.selectApi], (n) => {
+ n[0] && respParamsCard.getData(n[0]);
});
-
- return result;
-}
-function getCodeText(arr: schemaObjType[], level: number): object {
- const result = {};
- const schemas = toRaw(props.schemas);
- arr.forEach((item) => {
- switch (item.paramsType) {
- case 'string':
- result[item.paramsName] = '';
- break;
- case 'integer':
- result[item.paramsName] = 0;
- break;
- case 'boolean':
- result[item.paramsName] = true;
- break;
- case 'array':
- result[item.paramsName] = [];
- break;
- case 'object':
- result[item.paramsName] = '';
- break;
- default: {
- const properties = schemas[item.paramsType]
- .properties as object;
- const newArr = Object.entries(properties).map(
- (item: [string, any]) => ({
- paramsName: item[0],
- paramsType: level
- ? (item[1].$ref && item[1].$ref.split('/').pop()) ||
- (item[1].items &&
- item[1].items.$ref.split('/').pop()) ||
- item[1].type ||
- ''
- : item[1].type,
- }),
- );
- result[item.paramsName] = getCodeText(newArr, level - 1);
- }
- }
- });
-
- return result;
-}
-
-type schemaObjType = {
- paramsName: string;
- paramsType: string;
- desc?: string;
- children?: schemaObjType[];
-};
+});
\ No newline at end of file
diff --git a/src/views/Northbound/DuerOS/Detail/command/index.vue b/src/views/Northbound/DuerOS/Detail/command/index.vue
index efd19ebc..fc2ec36c 100644
--- a/src/views/Northbound/DuerOS/Detail/command/index.vue
+++ b/src/views/Northbound/DuerOS/Detail/command/index.vue
@@ -1,76 +1,156 @@
-
+
-
-
- 读取属性
- 修改属性
- 调用功能
+
+
+ 读取属性
+ 修改属性
+ 调用功能
-
-
-
- {{i.name}}
+
+
+
+ {{ i.name }}
-
-
+
+
-
-
- {{i.name}}
+
+
+ {{ i.name }}
-
-
-
+
+
+
@@ -78,101 +158,106 @@
\ No newline at end of file
diff --git a/src/views/Northbound/DuerOS/Detail/index.vue b/src/views/Northbound/DuerOS/Detail/index.vue
index 36894c24..46d2d739 100644
--- a/src/views/Northbound/DuerOS/Detail/index.vue
+++ b/src/views/Northbound/DuerOS/Detail/index.vue
@@ -171,7 +171,8 @@
>
保存
@@ -626,12 +631,11 @@ const saveBtn = async () => {
loading.value = true;
const resp = await savePatch(data).finally(() => {
loading.value = false;
- })
+ });
if (resp.status === 200) {
message.success('操作成功!');
formRef.value.resetFields();
menuStory.jumpPage('Northbound/DuerOS');
-
}
}
})
diff --git a/src/views/Northbound/DuerOS/index.vue b/src/views/Northbound/DuerOS/index.vue
index 7d4b4f02..c9e735d9 100644
--- a/src/views/Northbound/DuerOS/index.vue
+++ b/src/views/Northbound/DuerOS/index.vue
@@ -27,11 +27,12 @@
@@ -39,13 +40,12 @@
-
- {{ slotProps.name }}
-
-
+
+
+ {{ slotProps.name }}
+
+
+
产品
@@ -85,9 +85,13 @@
-
@@ -105,7 +109,7 @@
:tooltip="{
...i.tooltip,
}"
- style="padding: 0px"
+ style="padding: 0 5px"
@click="i.onClick"
type="link"
:hasPermission="'Northbound/DuerOS:' + i.key"
@@ -132,15 +136,12 @@ import type { ActionsType } from '@/views/device/Instance/typings';
import { getImage } from '@/utils/comm';
import { message } from 'jetlinks-ui-components';
import { useMenuStore } from 'store/menu';
+import BadgeStatus from '@/components/BadgeStatus/index.vue';
const instanceRef = ref>({});
const params = ref>({});
const menuStory = useMenuStore();
-const statusMap = new Map();
-statusMap.set('enabled', 'success');
-statusMap.set('disabled', 'error');
-
const columns = [
{
title: '名称',
@@ -193,6 +194,7 @@ const columns = [
title: '说明',
dataIndex: 'description',
key: 'description',
+ ellipsis: true,
},
{
title: '状态',
@@ -211,7 +213,7 @@ const columns = [
title: '操作',
key: 'action',
fixed: 'right',
- width: 250,
+ width: 200,
scopedSlots: true,
},
];
diff --git a/src/views/device/Instance/Detail/index.vue b/src/views/device/Instance/Detail/index.vue
index cd613b7e..5ef614f4 100644
--- a/src/views/device/Instance/Detail/index.vue
+++ b/src/views/device/Instance/Detail/index.vue
@@ -8,20 +8,25 @@
-
-
+
返回
+
{{ instanceStore.current.name }}
-
+
+ 状态:
+
+ {{ instanceStore.current.state?.text }}
+
+
{{
instanceStore.current.id
@@ -199,8 +204,8 @@ watch(
);
onMounted(() => {
- instanceStore.tabActiveKey = history.state?.params?.tab || 'Info'
-})
+ instanceStore.tabActiveKey = history.state?.params?.tab || 'Info';
+});
const onBack = () => {
menuStory.jumpPage('device/Instance');
@@ -284,7 +289,10 @@ watchEffect(() => {
tab: 'OPC UA',
});
}
- if (instanceStore.current.deviceType?.value === 'gateway' && !keys.includes('ChildDevice')) {
+ if (
+ instanceStore.current.deviceType?.value === 'gateway' &&
+ !keys.includes('ChildDevice')
+ ) {
// 产品类型为网关的情况下才显示此模块
list.value.push({
key: 'ChildDevice',
diff --git a/src/views/device/Instance/index.vue b/src/views/device/Instance/index.vue
index 54f908da..82b6bd6a 100644
--- a/src/views/device/Instance/index.vue
+++ b/src/views/device/Instance/index.vue
@@ -143,7 +143,7 @@
:status="slotProps.state?.value"
:statusText="slotProps.state?.text"
:statusNames="{
- online: 'success',
+ online: 'processing',
offline: 'error',
notActive: 'warning',
}"
@@ -202,9 +202,14 @@
-
@@ -226,7 +231,7 @@
}"
@click="i.onClick"
type="link"
- style="padding: 0px"
+ style="padding: 0 5px"
:hasPermission="'device/Instance:' + i.key"
>
@@ -289,6 +294,7 @@ import { queryTree } from '@/api/device/category';
import { useMenuStore } from '@/store/menu';
import type { ActionsType } from './typings';
import dayjs from 'dayjs';
+import BadgeStatus from '@/components/BadgeStatus/index.vue';
const instanceRef = ref>({});
const params = ref>({});
@@ -303,11 +309,6 @@ const type = ref('');
const menuStory = useMenuStore();
-const statusMap = new Map();
-statusMap.set('online', 'success');
-statusMap.set('offline', 'error');
-statusMap.set('notActive', 'warning');
-
const columns = [
{
title: 'ID',
@@ -479,6 +480,7 @@ const columns = [
title: '说明',
dataIndex: 'describe',
key: 'describe',
+ ellipsis: true,
search: {
type: 'string',
},
@@ -487,7 +489,7 @@ const columns = [
title: '操作',
key: 'action',
fixed: 'right',
- width: 250,
+ width: 200,
scopedSlots: true,
},
];
@@ -525,10 +527,10 @@ const paramsFormat = (
};
onMounted(() => {
- if(history.state?.params?.type === 'add'){
- handleAdd()
+ if (history.state?.params?.type === 'add') {
+ handleAdd();
}
-})
+});
const handleParams = (config: Record) => {
const _terms: Record = {};
From d29346248eaac5d9f83bc17401f88e96ded95ffd Mon Sep 17 00:00:00 2001
From: easy <1358086367@qq.com>
Date: Fri, 17 Mar 2023 17:43:58 +0800
Subject: [PATCH 06/14] fix: bug#10537
---
.../system/Department/components/LeftTree.vue | 117 ++++++++++--------
src/views/system/User/index.vue | 12 +-
2 files changed, 70 insertions(+), 59 deletions(-)
diff --git a/src/views/system/Department/components/LeftTree.vue b/src/views/system/Department/components/LeftTree.vue
index aa741a5c..7386aaf3 100644
--- a/src/views/system/Department/components/LeftTree.vue
+++ b/src/views/system/Department/components/LeftTree.vue
@@ -21,56 +21,59 @@
-
-
- {{ name }}
- e.stopPropagation()">
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ {{ name }}
+ e.stopPropagation()">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{
if (row.parentId) {
childrens = row.children;
} else childrens = treeData.value;
- const indexs = childrens.length > 0 ? childrens?.map((item) => item.sortIndex) :[0]
- sortIndex =
- Math.max(...indexs) + 1;
+ const indexs =
+ childrens.length > 0
+ ? childrens?.map((item) => item.sortIndex)
+ : [0];
+ sortIndex = Math.max(...indexs) + 1;
}
dialog.selectItem = { ...row, sortIndex };
@@ -248,5 +253,11 @@ function init() {
}
}
}
+
+ .loading {
+ display: flex;
+ justify-content: center;
+ margin-top: 20px;
+ }
}
diff --git a/src/views/system/User/index.vue b/src/views/system/User/index.vue
index cf9c8007..8d6128ba 100644
--- a/src/views/system/User/index.vue
+++ b/src/views/system/User/index.vue
@@ -92,7 +92,7 @@
}"
:popConfirm="{
title: `确认删除`,
- onConfirm: () => table.clickDel(slotProps),
+ onConfirm: () => table.clickDel(slotProps.id),
}"
:disabled="slotProps.status"
>
@@ -223,10 +223,10 @@ const table = {
dialog.type = type;
dialog.visible = true;
},
- changeStatus: (row: any) => {
+ changeStatus: ({ id, status }: any) => {
const params = {
- id: row.id,
- status: row.status === 0 ? 1 : 0,
+ status: status === 0 ? 1 : 0,
+ id,
};
changeUserStatus_api(params).then(() => {
message.success('操作成功');
@@ -234,8 +234,8 @@ const table = {
});
},
// 删除
- clickDel: (row: any) => {
- deleteUser_api(row.id).then(() => {
+ clickDel: (id: string) => {
+ deleteUser_api(id).then(() => {
message.success('操作成功');
table.refresh();
});
From efcfa42adb93ec4497cea4935192be36d85803a0 Mon Sep 17 00:00:00 2001
From: JiangQiming <291854119@qq.com>
Date: Fri, 17 Mar 2023 18:20:22 +0800
Subject: [PATCH 07/14] =?UTF-8?q?fix:=20bug#10540=E3=80=8110542?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/media/Device/Channel/Live/index.vue | 21 +++++++++--
src/views/media/Device/index.vue | 35 ++++++++++++++++---
2 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/src/views/media/Device/Channel/Live/index.vue b/src/views/media/Device/Channel/Live/index.vue
index 53856333..e5440491 100644
--- a/src/views/media/Device/Channel/Live/index.vue
+++ b/src/views/media/Device/Channel/Live/index.vue
@@ -22,10 +22,18 @@
: '停止录像'
}}
-
刷新
+
+ 刷新
+
重置
-
+
emit('update:visible', val),
});
+// 播放器
+const player = ref();
// 视频地址
const url = ref('');
// 视频类型
@@ -126,6 +136,13 @@ const handleRecord = async () => {
}
};
+/**
+ * 刷新
+ */
+const handleRefresh = () => {
+ player.value.play();
+};
+
/**
* 重置
*/
diff --git a/src/views/media/Device/index.vue b/src/views/media/Device/index.vue
index 3dd5dab0..490736b0 100644
--- a/src/views/media/Device/index.vue
+++ b/src/views/media/Device/index.vue
@@ -131,7 +131,10 @@
style="padding: 0px"
:hasPermission="
'media/Device:' +
- (i.key !== 'updateChannel' ? i.key : 'update')
+ (i.key !== 'updateChannel' &&
+ i.key !== 'viewDevice'
+ ? i.key
+ : 'update')
"
>
@@ -325,6 +328,17 @@ const getActions = (
);
},
},
+ {
+ key: 'viewDevice',
+ text: '查看',
+ tooltip: {
+ title: '查看',
+ },
+ icon: 'EyeOutlined',
+ onClick: () => {
+ menuStory.jumpPage('device/Instance/Detail', { id: data.id });
+ },
+ },
{
key: 'updateChannel',
text: '更新通道',
@@ -374,8 +388,21 @@ const getActions = (
icon: 'DeleteOutlined',
},
];
- return data.provider === 'fixed-media'
- ? actions.filter((f: any) => f.key !== 'updateChannel')
- : actions;
+
+ let acts: any = [];
+ if (type === 'card') {
+ // 卡片不展示查看按钮
+ const tempActs = actions.filter((f: any) => f.key !== 'viewDevice');
+ acts =
+ data.provider === 'fixed-media'
+ ? tempActs.filter((f: any) => f.key !== 'updateChannel')
+ : tempActs;
+ } else {
+ acts =
+ data.provider === 'fixed-media'
+ ? actions.filter((f: any) => f.key !== 'updateChannel')
+ : actions;
+ }
+ return acts;
};
From 232c8440802bb740de872bad91072443438f6825 Mon Sep 17 00:00:00 2001
From: xieyonghong <18010623010@163.com>
Date: Fri, 17 Mar 2023 13:54:25 +0800
Subject: [PATCH 08/14] =?UTF-8?q?update:=20=E6=9B=BF=E6=8D=A2=E5=9C=BA?=
=?UTF-8?q?=E6=99=AF=E8=81=94=E5=8A=A8=E4=B8=AD=E7=9A=84=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 2 +-
src/views/404.vue | 4 +-
.../Scene/Save/Device/AddModal.vue | 30 ++++-----
.../Scene/Save/Device/DeviceList.vue | 15 +++--
.../Scene/Save/Device/InvokeFunction.vue | 28 ++++-----
.../rule-engine/Scene/Save/Device/OrgList.vue | 2 +-
.../rule-engine/Scene/Save/Device/Product.vue | 10 +--
.../Scene/Save/Device/ReadProperties.vue | 20 +++---
.../rule-engine/Scene/Save/Device/Type.vue | 14 ++---
.../Scene/Save/Device/WriteProperty.vue | 26 ++++----
.../rule-engine/Scene/Save/Device/index.vue | 5 +-
.../components/FunctionCall/FunctionCall.vue | 4 +-
.../Scene/Save/components/Timer/index.vue | 62 +++++++++----------
.../Scene/Save/components/TopCard.vue | 4 +-
src/views/rule-engine/Scene/Save/index.vue | 4 +-
src/views/rule-engine/Scene/Save/save.vue | 18 +++---
yarn.lock | 12 ++++
17 files changed, 135 insertions(+), 125 deletions(-)
diff --git a/package.json b/package.json
index e01c7da6..8e4954cc 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,7 @@
"event-source-polyfill": "^1.0.31",
"global": "^4.4.0",
"jetlinks-store": "^0.0.3",
- "jetlinks-ui-components": "^1.0.4",
+ "jetlinks-ui-components": "^1.0.5",
"js-cookie": "^3.0.1",
"less": "^4.1.3",
"less-loader": "^11.1.0",
diff --git a/src/views/404.vue b/src/views/404.vue
index 7794d959..705f1db8 100644
--- a/src/views/404.vue
+++ b/src/views/404.vue
@@ -1,6 +1,6 @@
-
-
+
+
-
-
\ No newline at end of file
diff --git a/src/views/demo/index.vue b/src/views/demo/index.vue
deleted file mode 100644
index 3d4d8f98..00000000
--- a/src/views/demo/index.vue
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
- 父级: {{ testValue }}
-
-
-
卡片组件:
-
-
-
-
-
-
-
- 设备名称
-
-
-
- 设备类型
-
- 直连设备
-
-
-
- 产品名称
-
- 测试固定地址
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/views/demo/table/index.vue b/src/views/demo/table/index.vue
deleted file mode 100644
index f0a3ec2f..00000000
--- a/src/views/demo/table/index.vue
+++ /dev/null
@@ -1,187 +0,0 @@
-
-
-
-
- 新增
-
-
-
-
-
-
-
-
-
- {{slotProps.name}}
-
-
-
- 设备类型
-
- 直连设备
-
-
-
-
-
-
-
-
-
- {{ item.text }}
-
-
-
-
-
-
-
-
- {{ item.text }}
-
-
-
-
-
-
-
- {{slotProps.id}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/views/demo/test.tsx b/src/views/demo/test.tsx
deleted file mode 100644
index b2204213..00000000
--- a/src/views/demo/test.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Button } from 'ant-design-vue'
-
-export default defineComponent({
- setup(){
- return () =>
-
-
- }
-})
\ No newline at end of file
diff --git a/src/views/rule-engine/Scene/Save/Timer/index.vue b/src/views/rule-engine/Scene/Save/Timer/index.vue
index f4e3e9b1..ee5c1f24 100644
--- a/src/views/rule-engine/Scene/Save/Timer/index.vue
+++ b/src/views/rule-engine/Scene/Save/Timer/index.vue
@@ -1,5 +1,6 @@
-
+
+
+
+
+
Date: Fri, 17 Mar 2023 20:33:24 +0800
Subject: [PATCH 10/14] =?UTF-8?q?update:=20=E4=BC=98=E5=8C=96=E4=BA=A7?=
=?UTF-8?q?=E5=93=81-=E8=AE=BE=E5=A4=87=E6=8E=A5=E5=85=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/device/product.ts | 2 +-
src/store/product.ts | 13 +-
.../Product/Detail/DeviceAccess/index.vue | 179 +++++++-----------
.../Product/Detail/DeviceAccess/util.ts | 69 +++++++
src/views/device/Product/typings.d.ts | 6 +-
5 files changed, 146 insertions(+), 123 deletions(-)
create mode 100644 src/views/device/Product/Detail/DeviceAccess/util.ts
diff --git a/src/api/device/product.ts b/src/api/device/product.ts
index fc69bd04..35621b04 100644
--- a/src/api/device/product.ts
+++ b/src/api/device/product.ts
@@ -131,7 +131,7 @@ export const saveProductMetadata = (data: Record) => server.pat
* @param data 查询条件
* @returns
*/
-export const getDeviceNumber = (params:any) => server.get('/device-instance/_count', params)
+export const getDeviceNumber = (params:any) => server.get('/device-instance/_count', params)
/**
* 获取协议详情
diff --git a/src/store/product.ts b/src/store/product.ts
index 7c23a80c..221ddfa5 100644
--- a/src/store/product.ts
+++ b/src/store/product.ts
@@ -15,15 +15,18 @@ export const useProductStore = defineStore({
this.current = current
this.detail = current
},
- async refresh(id: string) {
+ async getDetail(id: string) {
const resp = await detail(id)
- const res = await getDeviceNumber(encodeQuery({ terms: { productId: id } }))
if(resp.status === 200){
this.current = resp.result
this.detail = resp.result
- if(res.status === 200){
- this.current.count = res.result
- }
+ }
+ },
+ async refresh(id: string) {
+ this.getDetail(id)
+ const res = await getDeviceNumber(encodeQuery({ terms: { productId: id } }))
+ if(res.status === 200){
+ this.current.count = res.result
}
},
setTabActiveKey(key: string) {
diff --git a/src/views/device/Product/Detail/DeviceAccess/index.vue b/src/views/device/Product/Detail/DeviceAccess/index.vue
index 5925057d..2c63f138 100644
--- a/src/views/device/Product/Detail/DeviceAccess/index.vue
+++ b/src/views/device/Product/Detail/DeviceAccess/index.vue
@@ -374,6 +374,7 @@ import { Empty, FormItem, message } from 'ant-design-vue';
import { getImage } from '@/utils/comm';
import Title from '../Title/index.vue';
import { usePermissionStore } from '@/store/permission';
+import { steps, steps1 } from './util'
import './index.less';
import {
getProviders,
@@ -412,7 +413,7 @@ const visible = ref(false);
const listData = ref([]);
const access = ref({});
const config = ref({});
-const metadata = ref([]);
+const metadata = ref({ properties: [] });
const dataSource = ref([]);
const storageList = ref([]);
const markdownToHtml = shallowRef('');
@@ -590,74 +591,7 @@ const search = (e: any) => {
};
const stepsRef = reactive({current:0})
-//引导页数据
-const steps = [
- {
- element: '#rc-tabs-0-tab-Metadata',
- popover: {
- id: 'driver',
- title: `配置物模型
1/3
`,
- description: `配置产品物模型,实现设备在云端的功能描述。`,
- position: 'bottom',
- },
- },
- {
- element: '.ant-switch',
- popover: {
- className: 'driver',
- title: `启用产品
2/3
`,
- description: '启用产品后,可在产品下新增设备。',
- position: 'bottom',
- },
- },
- {
- element: '.ant-descriptions-item-label',
- popover: {
- className: 'driver',
- title: `添加设备
3/3
`,
- description: '添加设备,并连接到平台。',
- position: 'bottom',
- },
- },
-];
-const steps1 = [
- {
- element: '.config',
- popover: {
- className: 'driver',
- title: `填写配置
1/4
`,
- description: `填写设备接入所需的配置参数。`,
- position: 'right',
- },
- },
- {
- element: '#rc-tabs-0-tab-Metadata',
- popover: {
- className: 'driver',
- title: `配置物模型
2/4
`,
- description: `配置产品物模型,实现设备在云端的功能描述。`,
- position: 'bottom',
- },
- },
- {
- element: '.ant-switch',
- popover: {
- className: 'driver',
- title: `启用产品
3/4
`,
- description: '启用产品后,可在产品下新增设备。',
- position: 'bottom',
- },
- },
- {
- element: '.ant-descriptions-item-label',
- popover: {
- className: 'driver',
- title: `添加设备
4/4
`,
- description: '添加设备,并连接到平台。',
- position: 'bottom',
- },
- },
-];
+
/**
* 保存引导页数据
*/
@@ -870,11 +804,11 @@ const queryAccessDetail = async (id: string) => {
/**
* 查询协议信息
*/
-const getConfigDetail = async (
+const getConfigDetail = (
messageProtocol: string,
transportProtocol: string,
) => {
- const res = await getConfigView(messageProtocol, transportProtocol).then(
+ getConfigView(messageProtocol, transportProtocol).then(
(resp) => {
if (resp.status === 200) {
config.value = resp.result;
@@ -965,21 +899,23 @@ const submitData = async () => {
obj.metadata = JSON.stringify(mdata);
}
}
+ // 保存或者更新设备接入
const resp: any = obj.id
? await updateDevice(obj)
: await saveDevice(obj);
if (resp.status === 200) {
+
detail(productStore.current?.id || '').then((res) => {
if (res.status === 200) {
productStore.current = { ...res.result };
access.value = res.result;
message.success('操作成功!');
- getData();
}
visible.value = false;
queryParams.value = {};
});
+ getData(obj.accessId);
}
} else {
message.error('请选择接入方式');
@@ -995,48 +931,59 @@ const modifyArray = (oldData: any[], newData: any[]) => {
return { ...item, sortsIndex: index };
});
};
+/**
+ *
+ */
+const getGuide = async (isDriver1: boolean = false) => {
+ const res: any = await productGuide();
+ if (res.result && res.result?.content === 'skip') {
+ return;
+ } else {
+ if (isDriver1) {
+ driver1.defineSteps(steps1);
+ driver1.start();
+ } else {
+ driver.defineSteps(steps);
+ driver.start();
+ }
+ }
+}
/**
* 查询保存数据信息
*/
-const getData = async () => {
- if (productStore.current?.accessId) {
- if (productStore.current?.id) {
- getConfigMetadata(productStore.current?.id).then(
- async (resp: any) => {
- metadata.value =
- (resp?.result[0] as ConfigMetadata[]) || [];
- const res: any = await productGuide();
- if (res.result && res.result?.content === 'skip') {
- return;
- } else {
- if (resp.result && resp.result.length > 0) {
- driver1.defineSteps(steps1);
- driver1.start();
- } else {
- driver.defineSteps(steps);
- driver.start();
- }
- }
- },
- );
- }
- queryAccessDetail(productStore.current?.accessId);
- getConfigDetail(
- productStore.current?.messageProtocol || '',
- productStore.current?.transportProtocol || '',
- );
- getProviders().then((resp) => {
- if (resp.status === 200) {
- dataSource.value = resp.result;
- }
- });
- } else {
- if (productStore.current?.id) {
- getConfigMetadata(productStore.current?.id).then((resp: any) => {
- metadata.value = resp?.result[0] as ConfigMetadata[];
- });
+const getData = async (accessId?: string) => {
+ const _accessId = accessId || productStore.current?.accessId
+ if (productStore.current?.id) {
+ getConfigMetadata(productStore.current?.id).then((resp: any) => {
+ metadata.value = resp?.result[0] as ConfigMetadata || { properties: [] };
+ if (accessId) { // 切换接入方式之后获取是否显示引导
+ getGuide(!resp?.result.length) //
}
+ });
}
+ if (_accessId) { // 有设备接入
+ // const metadataResp = await getConfigMetadata(productStore.current!.id)
+ // if (metadataResp.success) {
+ // metadata.value = (metadataResp.result?.[0] as ConfigMetadata[]) || [];
+ // }
+ queryAccessDetail(_accessId);
+ getConfigDetail(
+ productStore.current?.messageProtocol || '',
+ productStore.current?.transportProtocol || '',
+ );
+ getProviders().then((resp) => {
+ if (resp.status === 200) {
+ dataSource.value = resp.result;
+ }
+ });
+ }
+ // else {
+ // if (productStore.current?.id) {
+ // getConfigMetadata(productStore.current?.id).then((resp: any) => {
+ // metadata.value = resp?.result[0] as ConfigMetadata[];
+ // });
+ // }
+ // }
getStoragList().then((resp: any) => {
if (resp.status === 200) {
storageList.value = resp.result;
@@ -1092,11 +1039,15 @@ const add = () => {
/**
* 初始化
*/
-// watchEffect(() => {
-// if (productStore.current?.accessId) {
-// getData();
-// }
-// });
+watchEffect(() => {
+ if (productStore.current?.storePolicy) {
+ form.storePolicy = productStore.current!.storePolicy
+ }
+})
+
+nextTick(() => {
+ getData();
+})
\ No newline at end of file
diff --git a/src/views/rule-engine/Scene/Save/Timer/index.vue b/src/views/rule-engine/Scene/Save/Timer/index.vue
index ee5c1f24..36e893f8 100644
--- a/src/views/rule-engine/Scene/Save/Timer/index.vue
+++ b/src/views/rule-engine/Scene/Save/Timer/index.vue
@@ -1,30 +1,67 @@