|
@@ -198,10 +198,10 @@
|
|
|
<a @click="onScaleView"><t-icon name="refresh" /></a>
|
|
|
</t-tooltip>
|
|
|
<t-tooltip content="窗口大小" placement="bottom">
|
|
|
- <a @click="onScaleWindow"><t-icon name="minus-rectangle" /></a>
|
|
|
+ <a @click="onScaleWindow"><t-icon name="fullscreen-exit" /></a>
|
|
|
</t-tooltip>
|
|
|
<t-tooltip content="数据源" placement="bottom">
|
|
|
- <a @click="connectShow"><t-icon name="server" /></a>
|
|
|
+ <a @click="onShowDataDialog"><t-icon name="server" /></a>
|
|
|
</t-tooltip>
|
|
|
|
|
|
<div class="flex-grow"></div>
|
|
@@ -257,248 +257,180 @@
|
|
|
@changeVisible="changeContextMenuVisible"
|
|
|
/>
|
|
|
<t-dialog
|
|
|
+ v-if="dataDialog.show"
|
|
|
width="800px"
|
|
|
header="数据源管理"
|
|
|
- v-model:visible="connectVisible"
|
|
|
- :cancel-btn="null"
|
|
|
- confirm-btn="完成"
|
|
|
+ :visible="true"
|
|
|
+ @close="dataDialog.show = false"
|
|
|
>
|
|
|
- <div class="body" style="height: 420px">
|
|
|
- <t-tabs :default-value="1">
|
|
|
- <t-tab-panel :value="1" label="通信" :destroy-on-hide="false">
|
|
|
- <template #panel>
|
|
|
- <div v-show="comShow">
|
|
|
- <t-row class="mt-8" justify="end">
|
|
|
- <t-space :size="8">
|
|
|
- <t-select-input
|
|
|
- placeholder="搜索我的数据源"
|
|
|
- allow-input
|
|
|
- clearable
|
|
|
- :popup-visible="popupVisible"
|
|
|
- :popup-props="{ overlayInnerStyle: { padding: '6px' } }"
|
|
|
- @input-change="onInputChange"
|
|
|
- @popup-visible-change="onPopupVisibleChange"
|
|
|
- >
|
|
|
- <template #panel>
|
|
|
- <ul>
|
|
|
- <li
|
|
|
- style="line-height: 14px; margin: 8px 4px"
|
|
|
- v-for="item in comOptions"
|
|
|
- :key="item.url"
|
|
|
- @click="() => onOptionClick(item)"
|
|
|
- >
|
|
|
- 名称: {{ item.name }}<br />
|
|
|
- 地址: {{ item.url }}
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- </template>
|
|
|
- <template #suffixIcon>
|
|
|
- <t-icon name="search"></t-icon
|
|
|
- ></template>
|
|
|
- </t-select-input>
|
|
|
- <t-button style="height: 30px" @click="addCom"
|
|
|
- >添加数据源</t-button
|
|
|
- >
|
|
|
- </t-space>
|
|
|
- </t-row>
|
|
|
- <t-table
|
|
|
- class="mt-8"
|
|
|
- row-key="id"
|
|
|
- :data="comData"
|
|
|
- :columns="comColumns"
|
|
|
- >
|
|
|
- <template #operation="{ row, rowIndex }">
|
|
|
- <t-link theme="primary" hover="color" @click="editCom(row)">
|
|
|
- 编辑
|
|
|
- </t-link>
|
|
|
- <t-divider layout="vertical" />
|
|
|
- <t-popconfirm
|
|
|
- content="确认删除吗"
|
|
|
- @confirm="deleteCom(rowIndex)"
|
|
|
- >
|
|
|
- <t-link theme="primary" hover="color"> 删除 </t-link>
|
|
|
- </t-popconfirm>
|
|
|
- </template>
|
|
|
- </t-table>
|
|
|
- </div>
|
|
|
- <div v-show="!comShow">
|
|
|
- <t-row class="mt-8">
|
|
|
- <t-col :span="4">
|
|
|
- <t-button
|
|
|
- theme="primary"
|
|
|
- variant="text"
|
|
|
- ghost
|
|
|
- @click="comBack"
|
|
|
- >
|
|
|
- <template #icon>
|
|
|
- <t-icon name="rollback"></t-icon>
|
|
|
- </template>
|
|
|
- 返回
|
|
|
- </t-button>
|
|
|
- </t-col>
|
|
|
- <t-col :span="4" :offset="4">
|
|
|
- <t-button @click="saveForCurrent" theme="primary"
|
|
|
- >仅当前页面使用</t-button
|
|
|
- >
|
|
|
- <t-button @click="saveToServer" theme="primary" class="ml-4"
|
|
|
- >保存到服务器</t-button
|
|
|
- >
|
|
|
- </t-col>
|
|
|
- </t-row>
|
|
|
- <div class="form-item mt-16">
|
|
|
- <label>名称</label>
|
|
|
- <t-input v-model="com.name" style="width: 200px" />
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="form-item">
|
|
|
- <label>连接类型</label>
|
|
|
- <t-select
|
|
|
- v-model="com.type"
|
|
|
- placeholder="请选择"
|
|
|
- style="width: 200px"
|
|
|
- :popup-props="{ overlayInnerStyle: { width: '200px' } }"
|
|
|
- :disabled="comType === 'edit'"
|
|
|
- @change="comTypeChange"
|
|
|
+ <t-tabs :default-value="1" class="body">
|
|
|
+ <t-tab-panel :value="1" label="数据订阅" :destroy-on-hide="false">
|
|
|
+ <template #panel>
|
|
|
+ <div v-if="!dataDialog.editNetwork">
|
|
|
+ <t-row class="mt-16" justify="end">
|
|
|
+ <t-space :size="12">
|
|
|
+ <t-select-input
|
|
|
+ placeholder="搜索我的数据源"
|
|
|
+ allow-input
|
|
|
+ clearable
|
|
|
+ :popup-visible="dataDialog.popupVisible"
|
|
|
+ @input-change="onInputNetwork"
|
|
|
+ style="width: 240px"
|
|
|
>
|
|
|
- <t-option key="mqtt" value="mqtt" class="overlay-options">
|
|
|
- </t-option>
|
|
|
- <t-option
|
|
|
- key="websocket"
|
|
|
- value="websocket"
|
|
|
- class="overlay-options"
|
|
|
- >
|
|
|
- </t-option>
|
|
|
- <t-option key="http" value="http" class="overlay-options">
|
|
|
- </t-option>
|
|
|
- </t-select>
|
|
|
- </div>
|
|
|
- <template v-if="com.type === 'mqtt'">
|
|
|
- <div class="form-item">
|
|
|
- <label>接口地址</label>
|
|
|
- <t-input v-model="com.url" style="width: 200px" />
|
|
|
- </div>
|
|
|
- <div class="form-item">
|
|
|
- <label>Client Id</label>
|
|
|
- <t-input
|
|
|
- v-model="com.options.clientId"
|
|
|
- style="width: 200px"
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="form-item">
|
|
|
- <label>关闭自动生成</label>
|
|
|
- <t-switch v-model="com.options.customClientId" />
|
|
|
- </div>
|
|
|
- <div class="form-item">
|
|
|
- <label>用户名</label>
|
|
|
- <t-input
|
|
|
- v-model="com.options.username"
|
|
|
- style="width: 200px"
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="form-item">
|
|
|
- <label>密码</label>
|
|
|
- <t-input
|
|
|
- v-model="com.options.password"
|
|
|
- style="width: 200px"
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="form-item">
|
|
|
- <label>Topics</label>
|
|
|
- <t-input v-model="com.topics" style="width: 200px" />
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template v-else-if="com.type === 'http'">
|
|
|
- <div class="form-item">
|
|
|
- <label>请求方式</label>
|
|
|
- <t-select
|
|
|
- v-model="com.method"
|
|
|
- placeholder="请选择"
|
|
|
- style="width: 200px"
|
|
|
- :popup-props="{ overlayInnerStyle: { width: '200px' } }"
|
|
|
- @change="comHttpMethodChange"
|
|
|
- >
|
|
|
- <t-option key="GET" value="GET"> </t-option>
|
|
|
- <t-option key="POST" value="POST"> </t-option>
|
|
|
- </t-select>
|
|
|
- </div>
|
|
|
- <div class="form-item">
|
|
|
- <label>请求头</label>
|
|
|
- <t-textarea
|
|
|
- v-model="com.httpHeaders"
|
|
|
- placeholder="请输入请求头"
|
|
|
- name="description"
|
|
|
- :autosize="{ minRows: 3, maxRows: 5 }"
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div v-if="com.method === 'POST'" class="form-item">
|
|
|
- <label>请求体</label>
|
|
|
-
|
|
|
- <t-textarea
|
|
|
- v-model="com.body"
|
|
|
- placeholder="请输入请求体"
|
|
|
- name="description"
|
|
|
- :autosize="{ minRows: 3, maxRows: 5 }"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <div class="form-item">
|
|
|
- <label>protocol</label>
|
|
|
- <t-input v-model="com.protocols" style="width: 200px" />
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </t-tab-panel>
|
|
|
- <t-tab-panel :value="2" :destroy-on-hide="false">
|
|
|
- <template #label
|
|
|
- >数据集
|
|
|
- <span><label class="vip-label">VIP</label></span></template
|
|
|
- >
|
|
|
- <template #panel>
|
|
|
- <t-row class="mt-8" style="height: 32px; line-height: 32px">
|
|
|
- <t-col flex="60px"> 网络接口 </t-col>
|
|
|
- <t-col flex="auto">
|
|
|
- <t-input class="ml-8" style="width: 200px" />
|
|
|
- </t-col>
|
|
|
- </t-row>
|
|
|
- <t-row class="mt-8">
|
|
|
- <t-col flex="60px">自定义</t-col>
|
|
|
- <t-col flex="auto">
|
|
|
- <t-button
|
|
|
- @click="importDataSet"
|
|
|
- class="ml-8"
|
|
|
- style="height: 30px"
|
|
|
- >从Excel导入</t-button
|
|
|
- >
|
|
|
- <t-button @click="downloadDataSet" variant="text">
|
|
|
- <template #icon
|
|
|
- ><t-icon name="download"></t-icon>
|
|
|
+ <template #panel>
|
|
|
+ <ul style="padding: 4px">
|
|
|
+ <li
|
|
|
+ class="hover-background"
|
|
|
+ style="
|
|
|
+ line-height: 1.5;
|
|
|
+ padding: 8px;
|
|
|
+ border-radius: 2px;
|
|
|
+ "
|
|
|
+ v-for="item in dataDialog.networkList"
|
|
|
+ :key="item.url"
|
|
|
+ @click="() => onSelectNetWork(item)"
|
|
|
+ >
|
|
|
+ 名称: {{ item.name }}
|
|
|
+ <div class="desc">地址: {{ item.url }}</div>
|
|
|
+ </li>
|
|
|
+ <li
|
|
|
+ v-if="!dataDialog.networkList.length"
|
|
|
+ style="
|
|
|
+ line-height: 1.5;
|
|
|
+ padding: 8px;
|
|
|
+ border-radius: 2px;
|
|
|
+ "
|
|
|
+ :key="-1"
|
|
|
+ >
|
|
|
+ <div class="desc">暂无数据</div>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </template>
|
|
|
+ <template #suffixIcon>
|
|
|
+ <t-icon name="search" class="hover" />
|
|
|
</template>
|
|
|
- 下载示例
|
|
|
+ </t-select-input>
|
|
|
+ <t-button style="height: 30px" @click="addNetwork">
|
|
|
+ 添加数据订阅
|
|
|
</t-button>
|
|
|
- </t-col>
|
|
|
+ </t-space>
|
|
|
</t-row>
|
|
|
<t-table
|
|
|
- class="mt-8"
|
|
|
+ class="mt-12"
|
|
|
row-key="id"
|
|
|
- :data="dsData"
|
|
|
- :columns="dsColumns"
|
|
|
+ :data="dataDialog.networks"
|
|
|
+ :columns="networkColumns"
|
|
|
+ :max-height="280"
|
|
|
+ size="small"
|
|
|
>
|
|
|
- <template #label="{ row }">
|
|
|
- {{ `${row.label}(${row.key})` }}
|
|
|
+ <template #actions="{ row, rowIndex }">
|
|
|
+ <a @click="editNetwork(row)"> 编辑 </a>
|
|
|
+ <t-popconfirm
|
|
|
+ content="确认删除吗"
|
|
|
+ @confirm="deleteNetwork(rowIndex)"
|
|
|
+ >
|
|
|
+ <a class="ml-12"> 删除 </a>
|
|
|
+ </t-popconfirm>
|
|
|
+ </template>
|
|
|
+ <template #empty>
|
|
|
+ <div class="center">
|
|
|
+ <div>暂无数据</div>
|
|
|
+ <div class="mt-8">
|
|
|
+ <a @click="addNetwork"> + 添加数据订阅</a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
- <template #operation="{ row }"> </template>
|
|
|
</t-table>
|
|
|
- </template>
|
|
|
- </t-tab-panel>
|
|
|
- </t-tabs>
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <div class="mt-8">
|
|
|
+ <a
|
|
|
+ @click="dataDialog.editNetwork = false"
|
|
|
+ class="flex middle"
|
|
|
+ style="width: 44px"
|
|
|
+ >
|
|
|
+ <t-icon name="rollback" class="mr-4" /> 返回
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div style="height: 300px; overflow-y: auto">
|
|
|
+ <Network v-model="dataDialog.network" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </t-tab-panel>
|
|
|
+ <t-tab-panel :value="2" :destroy-on-hide="false">
|
|
|
+ <template #label>
|
|
|
+ 数据集
|
|
|
+ <span><label class="vip-label ml-4">VIP</label></span>
|
|
|
+ </template>
|
|
|
+ <template #panel>
|
|
|
+ <div class="form-item mt-12">
|
|
|
+ <label>网络地址</label>
|
|
|
+ <div class="w-full">
|
|
|
+ <t-input v-model="dataDialog.datasetUrl" />
|
|
|
+ <div class="desc mt-4">
|
|
|
+ 高优先级。存在网络地址时,用网络数据代替自定义数据
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-item mt-16">
|
|
|
+ <label>自定义</label>
|
|
|
+ <div class="w-full">
|
|
|
+ <t-button @click="importDataset">从Excel导入</t-button>
|
|
|
+ <a href="/data.xlsx" download class="ml-16">下载Excel示例</a>
|
|
|
+ <span class="desc ml-16">
|
|
|
+ “自定义”数据集 - 方便构建项目时了解数据结构
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <t-table
|
|
|
+ class="mt-12"
|
|
|
+ row-key="id"
|
|
|
+ :data="dataDialog.dataset"
|
|
|
+ :columns="datasetColumns"
|
|
|
+ size="small"
|
|
|
+ :max-height="210"
|
|
|
+ >
|
|
|
+ <template #label="{ row }">
|
|
|
+ {{ `${row.label}(${row.key})` }}
|
|
|
+ </template>
|
|
|
+ <template #actions="{ row }"> </template>
|
|
|
+ <template #empty>
|
|
|
+ <div class="center">
|
|
|
+ <div>暂无数据</div>
|
|
|
+ <div class="mt-8">
|
|
|
+ <a @click="importDataset"> 从Excel导入</a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </t-table>
|
|
|
+ </template>
|
|
|
+ </t-tab-panel>
|
|
|
+ </t-tabs>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <div v-if="dataDialog.editNetwork" class="flex middle">
|
|
|
+ <div class="flex-grow"></div>
|
|
|
+ <t-checkbox v-model="dataDialog.save">
|
|
|
+ 同时保存到我的数据源
|
|
|
+ </t-checkbox>
|
|
|
+ <t-button class="ml-16" @click="onOkNetwork">确定</t-button>
|
|
|
+ </div>
|
|
|
+ <div v-else class="flex middle">
|
|
|
+ <div class="flex-grow"></div>
|
|
|
+ <t-button class="ml-16" @click="dataDialog.show = false">
|
|
|
+ 完成
|
|
|
+ </t-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
</t-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
+import { onMounted, onUnmounted, watch, ref, reactive } from 'vue';
|
|
|
+import { useRouter, useRoute } from 'vue-router';
|
|
|
import {
|
|
|
Meta2d,
|
|
|
Options,
|
|
@@ -508,30 +440,34 @@ import {
|
|
|
PenType,
|
|
|
HoverType,
|
|
|
} from '@meta2d/core';
|
|
|
-import { onMounted, onUnmounted, watch, ref, reactive } from 'vue';
|
|
|
+import localforage from 'localforage';
|
|
|
+import dayjs from 'dayjs';
|
|
|
+import axios from 'axios';
|
|
|
+import { MessagePlugin } from 'tdesign-vue-next';
|
|
|
+
|
|
|
import { registerBasicDiagram } from '@/services/register';
|
|
|
-import { useRouter, useRoute } from 'vue-router';
|
|
|
import { useUser } from '@/services/user';
|
|
|
-import { getLe5le2d } from '@/services/api';
|
|
|
-import { useDot } from '@/services/common';
|
|
|
+import { cdn, getLe5le2d } from '@/services/api';
|
|
|
import {
|
|
|
save,
|
|
|
newFile,
|
|
|
SaveType,
|
|
|
onScaleView,
|
|
|
onScaleWindow,
|
|
|
+ useDot,
|
|
|
} from '@/services/common';
|
|
|
import { useSelection, SelectionMode } from '@/services/selections';
|
|
|
import { defaultFormat } from '@/services/defaults';
|
|
|
-import { MessagePlugin } from 'tdesign-vue-next';
|
|
|
-import { localMeta2dDataName } from '@/services/utils';
|
|
|
-import localforage from 'localforage';
|
|
|
-import { checkData, Meta2dBackData } from '@/services/utils';
|
|
|
-import { cdn } from '@/services/api';
|
|
|
-import dayjs from 'dayjs';
|
|
|
+import {
|
|
|
+ checkData,
|
|
|
+ localMeta2dDataName,
|
|
|
+ Meta2dBackData,
|
|
|
+} from '@/services/utils';
|
|
|
+import { debounce } from '@/services/debouce';
|
|
|
+import { importExcel } from '@/services/excel';
|
|
|
+
|
|
|
import ContextMenu from './ContextMenu.vue';
|
|
|
-import { importExcel, saveAsExcel } from '@/services/excel';
|
|
|
-import { it } from 'node:test';
|
|
|
+import Network from './Network.vue';
|
|
|
|
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
@@ -572,13 +508,11 @@ onMounted(() => {
|
|
|
meta2d.on('rotatePens', autoSave);
|
|
|
meta2d.on('translatePens', autoSave);
|
|
|
|
|
|
- //TODO所有编辑栏所做修改
|
|
|
+ // 所有编辑栏所做修改
|
|
|
meta2d.on('components-update-value', autoSave);
|
|
|
// @ts-ignore
|
|
|
meta2d.on('contextmenu', contextmenu);
|
|
|
meta2d.on('click', canvasClick);
|
|
|
-
|
|
|
- meta2d.on('opened', dataSourceManage);
|
|
|
});
|
|
|
|
|
|
const watcher = watch(
|
|
@@ -636,7 +570,6 @@ onUnmounted(() => {
|
|
|
meta2d.off('contextmenu', contextmenu);
|
|
|
meta2d.off('click', canvasClick);
|
|
|
|
|
|
- meta2d.off('opened', dataSourceManage);
|
|
|
meta2d.destroy();
|
|
|
}
|
|
|
});
|
|
@@ -725,10 +658,7 @@ function scaleListener(newScale: number) {
|
|
|
scale.value = Math.round(newScale * 100);
|
|
|
}
|
|
|
|
|
|
-const connectVisible = ref(false);
|
|
|
-const connectShow = () => {
|
|
|
- connectVisible.value = true;
|
|
|
-};
|
|
|
+const dataDialog = reactive<any>({});
|
|
|
|
|
|
const currentLineType = ref('curve');
|
|
|
const lineTypes = reactive([
|
|
@@ -968,128 +898,67 @@ const changeContextMenuVisible = (e: boolean) => {
|
|
|
contextMenuVisible.value = e;
|
|
|
};
|
|
|
|
|
|
-// const comConfirm = () => {
|
|
|
-// connectVisible.value = false;
|
|
|
-// };
|
|
|
-
|
|
|
-interface Com {
|
|
|
- name?: string;
|
|
|
- type: 'mqtt' | 'websocket' | 'http';
|
|
|
- url?: string;
|
|
|
- //websocket
|
|
|
- protocols?: string;
|
|
|
- //mqtt
|
|
|
- topics?: string;
|
|
|
- options?: {
|
|
|
- clientId?: string;
|
|
|
- username?: string;
|
|
|
- password?: string;
|
|
|
- customClientId?: boolean;
|
|
|
- };
|
|
|
- //http
|
|
|
- http?: string; // http 请求 Url
|
|
|
- httpTimeInterval?: number; // http 请求间隔
|
|
|
- httpHeaders?: HeadersInit; //请求头
|
|
|
- method?: string;
|
|
|
- body?: BodyInit | null;
|
|
|
-}
|
|
|
-
|
|
|
-const comData = ref<Com[]>([
|
|
|
- {
|
|
|
- name: '连接1',
|
|
|
- type: 'mqtt',
|
|
|
- url: 'wss://1',
|
|
|
- topics: '',
|
|
|
- options: {
|
|
|
- clientId: '',
|
|
|
- username: '',
|
|
|
- password: '',
|
|
|
- customClientId: false,
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- name: '连接2',
|
|
|
- type: 'websocket',
|
|
|
- url: 'wss://2',
|
|
|
- },
|
|
|
- {
|
|
|
- name: '连接3',
|
|
|
- type: 'http',
|
|
|
- url: 'wss://3',
|
|
|
- },
|
|
|
-]);
|
|
|
-const comColumns = ref([
|
|
|
+const networkColumns = ref([
|
|
|
{
|
|
|
colKey: 'name',
|
|
|
title: '名称',
|
|
|
ellipsis: true,
|
|
|
+ width: 160,
|
|
|
},
|
|
|
{
|
|
|
colKey: 'type',
|
|
|
title: '类型',
|
|
|
- ellipsis: true,
|
|
|
+ width: 120,
|
|
|
},
|
|
|
{
|
|
|
colKey: 'url',
|
|
|
- title: '接口地址',
|
|
|
+ title: 'URL地址',
|
|
|
ellipsis: true,
|
|
|
},
|
|
|
- { colKey: 'operation', title: '操作', width: 120, foot: '-' },
|
|
|
+ { colKey: 'actions', title: '操作', width: 100 },
|
|
|
]);
|
|
|
|
|
|
-const comOptions = ref<Com[]>([
|
|
|
- {
|
|
|
- name: '连接A',
|
|
|
- type: 'mqtt',
|
|
|
- url: 'ws://A',
|
|
|
- },
|
|
|
- {
|
|
|
- name: '连接B',
|
|
|
- type: 'mqtt',
|
|
|
- url: 'ws://B',
|
|
|
- },
|
|
|
- {
|
|
|
- name: '连接C',
|
|
|
- type: 'mqtt',
|
|
|
- url: 'ws://C',
|
|
|
- },
|
|
|
- {
|
|
|
- name: '连接D',
|
|
|
- type: 'mqtt',
|
|
|
- url: 'ws://D',
|
|
|
- },
|
|
|
- {
|
|
|
- name: '连接E',
|
|
|
- type: 'mqtt',
|
|
|
- url: 'ws://E',
|
|
|
- },
|
|
|
-]);
|
|
|
-
|
|
|
-const dataSourceManage = () => {
|
|
|
- comData.value = (meta2d.store.data as any).comData; //确定字段
|
|
|
- dsData.value = (meta2d.store.data as any).dsData;
|
|
|
+const onShowDataDialog = () => {
|
|
|
+ // @ts-ignore
|
|
|
+ dataDialog.networks = meta2d.store.data.networks || [];
|
|
|
+ // @ts-ignore
|
|
|
+ dataDialog.dataset = meta2d.store.data.dataset;
|
|
|
+ dataDialog.networkList = [];
|
|
|
+ dataDialog.editNetwork = false;
|
|
|
+ dataDialog.save = true;
|
|
|
+ dataDialog.show = true;
|
|
|
+ getNetworks();
|
|
|
};
|
|
|
|
|
|
-const onOptionClick = (item: Com) => {
|
|
|
- comData.value.push(item);
|
|
|
- popupVisible.value = false;
|
|
|
+const onOkData = () => {
|
|
|
+ // @ts-ignore
|
|
|
+ meta2d.store.data.networks = dataDialog.networks;
|
|
|
+ // @ts-ignore
|
|
|
+ meta2d.store.data.dataset = dataDialog.dataset;
|
|
|
+ dataDialog.show = false;
|
|
|
};
|
|
|
|
|
|
-const popupVisible = ref(false);
|
|
|
-const onInputChange = (e) => {
|
|
|
- console.log('change', e);
|
|
|
+const onSelectNetWork = (item: any) => {
|
|
|
+ dataDialog.networks.push(item);
|
|
|
+ dataDialog.popupVisible = false;
|
|
|
};
|
|
|
-const onPopupVisibleChange = (val: boolean) => {
|
|
|
- popupVisible.value = val;
|
|
|
+
|
|
|
+const onInputNetwork = (text: string) => {
|
|
|
+ debounce(getNetworks, 300);
|
|
|
};
|
|
|
|
|
|
-const comType = ref('add'); //or edit
|
|
|
+// 请求我的数据源接口
|
|
|
+const getNetworks = async () => {
|
|
|
+ // const ret: any = await axios.get(`/api/xxx`);
|
|
|
+ // if (ret) {
|
|
|
+ // dataDialog.networkList = ret.list
|
|
|
+ // }
|
|
|
+};
|
|
|
|
|
|
-const addCom = () => {
|
|
|
- comType.value = 'add';
|
|
|
- com.value = {
|
|
|
+const addNetwork = () => {
|
|
|
+ dataDialog.network = {
|
|
|
name: '',
|
|
|
- type: 'mqtt', //默认
|
|
|
+ type: '',
|
|
|
url: '',
|
|
|
options: {
|
|
|
clientId: '',
|
|
@@ -1098,132 +967,35 @@ const addCom = () => {
|
|
|
customClientId: false,
|
|
|
},
|
|
|
};
|
|
|
- comShow.value = false;
|
|
|
-};
|
|
|
-const editCom = (row: Com) => {
|
|
|
- comType.value = 'edit';
|
|
|
- com.value = row;
|
|
|
- comShow.value = false;
|
|
|
+ dataDialog.editNetwork = 1;
|
|
|
};
|
|
|
|
|
|
-const deleteCom = (index: number) => {
|
|
|
- comData.value.splice(index, 1);
|
|
|
- dataToCom(comData.value);
|
|
|
+const editNetwork = (data: any) => {
|
|
|
+ dataDialog.network = data;
|
|
|
+ dataDialog.editNetwork = 2;
|
|
|
};
|
|
|
|
|
|
-//将配置的通信列表转成核心库能识别的格式
|
|
|
-const dataToCom = (data: Com[]) => {
|
|
|
- const mqtts: any = [];
|
|
|
- const https: any = [];
|
|
|
- const websockets: any = [];
|
|
|
- data.forEach((item) => {
|
|
|
- if (item.type === 'http') {
|
|
|
- https.push({
|
|
|
- http: item.http,
|
|
|
- httpTimeInterval: item.httpTimeInterval,
|
|
|
- httpHeaders: item.httpHeaders,
|
|
|
- method: item.method,
|
|
|
- body: item.body,
|
|
|
- });
|
|
|
- } else if (item.type === 'mqtt') {
|
|
|
- mqtts.push({
|
|
|
- url: item.url,
|
|
|
- options: {
|
|
|
- clientId: item.options?.clientId,
|
|
|
- username: item.options?.username,
|
|
|
- password: item.options?.password,
|
|
|
- customClientId: item.options?.customClientId,
|
|
|
- },
|
|
|
- topics: item.topics,
|
|
|
- });
|
|
|
- } else if (item.type === 'websocket') {
|
|
|
- websockets.push({
|
|
|
- url: item.url,
|
|
|
- protocols: item.protocols,
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- meta2d.store.data.mqtts = mqtts;
|
|
|
- meta2d.store.data.https = https;
|
|
|
- meta2d.store.data.websockets = websockets;
|
|
|
- //TODO 建立通信连接
|
|
|
+const deleteNetwork = (index: number) => {
|
|
|
+ dataDialog.networks.splice(index, 1);
|
|
|
meta2d.connectSocket();
|
|
|
};
|
|
|
-const comShow = ref(true);
|
|
|
-
|
|
|
-const comBack = () => {
|
|
|
- comShow.value = true;
|
|
|
-};
|
|
|
|
|
|
-const com = ref<Com>({
|
|
|
- name: '连接E',
|
|
|
- type: 'mqtt',
|
|
|
- url: 'ws://E',
|
|
|
- options: {
|
|
|
- clientId: '',
|
|
|
- username: '',
|
|
|
- password: '',
|
|
|
- customClientId: false,
|
|
|
- },
|
|
|
-});
|
|
|
-
|
|
|
-const comTypeChange = (e: string) => {
|
|
|
- console.log(e, com.value.type);
|
|
|
- if (e === 'mqtt') {
|
|
|
- Object.assign(com.value, {
|
|
|
- options: {
|
|
|
- clientId: '',
|
|
|
- username: '',
|
|
|
- password: '',
|
|
|
- customClientId: false,
|
|
|
- },
|
|
|
- });
|
|
|
- } else if (e === 'websocket') {
|
|
|
- Object.assign(com.value, {
|
|
|
- protocols: '',
|
|
|
- });
|
|
|
- } else {
|
|
|
- Object.assign(com.value, {
|
|
|
- http: '',
|
|
|
- httpTimeInterval: 1000,
|
|
|
- httpHeaders: '',
|
|
|
- method: 'GET',
|
|
|
- body: '',
|
|
|
- });
|
|
|
+const onOkNetwork = () => {
|
|
|
+ if (dataDialog.editNetwork === 1) {
|
|
|
+ dataDialog.networks.push(dataDialog.network);
|
|
|
}
|
|
|
-};
|
|
|
+ dataDialog.editNetwork = false;
|
|
|
|
|
|
-const comHttpMethodChange = (e: string) => {
|
|
|
- if (e === 'GET') {
|
|
|
- com.value.body = null;
|
|
|
+ // 保存到我的数据源
|
|
|
+ if (dataDialog.save) {
|
|
|
+ // todo
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const dsData = ref([
|
|
|
- {
|
|
|
- label: '数据点1',
|
|
|
- key: 'a-1',
|
|
|
- value: '12',
|
|
|
- type: 'number/select/bool/color',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '数据点2',
|
|
|
- key: 'a-2',
|
|
|
- value: '12',
|
|
|
- type: 'number/select/bool/color',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '数据点3',
|
|
|
- key: 'a-3',
|
|
|
- value: '12',
|
|
|
- type: 'number/select/bool/color',
|
|
|
- },
|
|
|
-]);
|
|
|
-
|
|
|
-const dsColumns = ref([
|
|
|
+const datasetColumns = ref([
|
|
|
{
|
|
|
colKey: 'label',
|
|
|
- title: '名称(数据点ID)',
|
|
|
+ title: '名称(数据ID)',
|
|
|
ellipsis: true,
|
|
|
},
|
|
|
{
|
|
@@ -1238,20 +1010,7 @@ const dsColumns = ref([
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
-const saveForCurrent = () => {
|
|
|
- comData.value.push(com.value);
|
|
|
- comShow.value = true;
|
|
|
- dataToCom(comData.value);
|
|
|
-};
|
|
|
-
|
|
|
-const saveToServer = () => {
|
|
|
- //TODO 将com保存到服务器
|
|
|
- comData.value.push(com.value);
|
|
|
- comShow.value = true;
|
|
|
- dataToCom(comData.value);
|
|
|
-};
|
|
|
-
|
|
|
-const importDataSet = async () => {
|
|
|
+const importDataset = async () => {
|
|
|
let columns: any = [
|
|
|
{
|
|
|
header: '名称',
|
|
@@ -1270,40 +1029,9 @@ const importDataSet = async () => {
|
|
|
key: 'value',
|
|
|
},
|
|
|
];
|
|
|
- // dsData.value = [];
|
|
|
- let data: any = await importExcel(columns);
|
|
|
+ const data: any = await importExcel(columns);
|
|
|
console.log('data', data);
|
|
|
- // setTimeout(() => {
|
|
|
- dsData.value = data;
|
|
|
- // }, 2000);
|
|
|
-};
|
|
|
-
|
|
|
-const downloadDataSet = () => {
|
|
|
- let name = '数据集示例';
|
|
|
- let columns = [
|
|
|
- {
|
|
|
- header: '名称',
|
|
|
- key: 'label',
|
|
|
- },
|
|
|
- {
|
|
|
- header: '数据ID',
|
|
|
- key: 'id',
|
|
|
- },
|
|
|
- {
|
|
|
- header: '类型',
|
|
|
- key: 'type',
|
|
|
- },
|
|
|
- {
|
|
|
- header: '值',
|
|
|
- key: 'value',
|
|
|
- },
|
|
|
- ];
|
|
|
- let data = [
|
|
|
- ['数据集1', 'dataId-1', 'string', 'zzz'],
|
|
|
- ['数据集2', 'dataId-2', 'boolean', true],
|
|
|
- ['数据集3', 'dataId-3', 'number', 12],
|
|
|
- ];
|
|
|
- saveAsExcel(name, columns, data);
|
|
|
+ dataDialog.dataset = data;
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="postcss" scoped>
|
|
@@ -1352,12 +1080,5 @@ const downloadDataSet = () => {
|
|
|
background: var(--color-background);
|
|
|
}
|
|
|
}
|
|
|
- .form-item {
|
|
|
- display: flex;
|
|
|
- margin-bottom: 8px;
|
|
|
- label {
|
|
|
- width: 100px;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
</style>
|