|
@@ -55,7 +55,7 @@
|
|
<t-icon
|
|
<t-icon
|
|
name="link"
|
|
name="link"
|
|
class="hover ml-4"
|
|
class="hover ml-4"
|
|
- :class="{ primary: item.binds?.id }"
|
|
|
|
|
|
+ :class="{ primary: item.enableMock || item.bind?.id }"
|
|
@click="onBind(item)"
|
|
@click="onBind(item)"
|
|
/>
|
|
/>
|
|
</t-tooltip>
|
|
</t-tooltip>
|
|
@@ -154,48 +154,97 @@
|
|
v-if="dataBindDialog.show"
|
|
v-if="dataBindDialog.show"
|
|
:visible="true"
|
|
:visible="true"
|
|
class="data-link-dialog"
|
|
class="data-link-dialog"
|
|
- header="动态数据绑定"
|
|
|
|
|
|
+ header="动态数据设置"
|
|
@close="dataBindDialog.show = false"
|
|
@close="dataBindDialog.show = false"
|
|
@confirm="dataBindonConfirm"
|
|
@confirm="dataBindonConfirm"
|
|
|
|
+ :top="70"
|
|
:width="700"
|
|
:width="700"
|
|
>
|
|
>
|
|
- <div class="form-item">
|
|
|
|
- <label>当前绑定:</label>
|
|
|
|
- <div class="label" v-if="dataBindDialog.data.binds?.id">
|
|
|
|
- <t-tooltip :content="dataBindDialog.data.binds?.id">
|
|
|
|
- <t-tag class="mr-8 mb-8" closable @close="onRemoveBind()">
|
|
|
|
- {{ dataBindDialog.data.binds?.label }}
|
|
|
|
- </t-tag>
|
|
|
|
- </t-tooltip>
|
|
|
|
- </div>
|
|
|
|
- <div class="label gray" v-else>无</div>
|
|
|
|
- </div>
|
|
|
|
- <div class="form-item mt-8">
|
|
|
|
- <t-input
|
|
|
|
- placeholder="搜索"
|
|
|
|
- v-model="dataBindDialog.input"
|
|
|
|
- @change="onSearchDataset"
|
|
|
|
- @enter="onSearchDataset"
|
|
|
|
|
|
+ <t-tabs :defaultValue="1">
|
|
|
|
+ <t-tab-panel
|
|
|
|
+ :value="1"
|
|
|
|
+ label="绑定数据点"
|
|
|
|
+ :destroy-on-hide="false"
|
|
|
|
+ style="height: 420px"
|
|
>
|
|
>
|
|
- <template #suffixIcon>
|
|
|
|
- <t-icon name="search" class="hover" @click="onSearchDataset" />
|
|
|
|
- </template>
|
|
|
|
- </t-input>
|
|
|
|
- </div>
|
|
|
|
- <t-table
|
|
|
|
- class="mt-12 data-list"
|
|
|
|
- row-key="id"
|
|
|
|
- :data="dataBindDialog.dataset"
|
|
|
|
- :columns="dataSetColumns"
|
|
|
|
- size="small"
|
|
|
|
- bordered
|
|
|
|
- :loading="dataBindDialog.loading"
|
|
|
|
- :pagination="query"
|
|
|
|
- @page-change="onChangePagination"
|
|
|
|
- :selected-row-keys="dataBindDialog.selectedIds"
|
|
|
|
- @select-change="onSelectBindsChange"
|
|
|
|
- >
|
|
|
|
- </t-table>
|
|
|
|
|
|
+ <div class="form-item mt-12">
|
|
|
|
+ <label>当前绑定:</label>
|
|
|
|
+ <div class="label" v-if="dataBindDialog.data.bind?.id">
|
|
|
|
+ <t-tooltip :content="dataBindDialog.data.bind?.id">
|
|
|
|
+ <t-tag class="mr-8 mb-8" closable @close="onRemoveBind()">
|
|
|
|
+ {{ dataBindDialog.data.bind?.label }}
|
|
|
|
+ </t-tag>
|
|
|
|
+ </t-tooltip>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="label gray" v-else>无</div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="form-item mt-8">
|
|
|
|
+ <t-input
|
|
|
|
+ placeholder="搜索"
|
|
|
|
+ v-model="dataBindDialog.input"
|
|
|
|
+ @change="onSearchDataset"
|
|
|
|
+ @enter="onSearchDataset"
|
|
|
|
+ >
|
|
|
|
+ <template #suffixIcon>
|
|
|
|
+ <t-icon name="search" class="hover" @click="onSearchDataset" />
|
|
|
|
+ </template>
|
|
|
|
+ </t-input>
|
|
|
|
+ </div>
|
|
|
|
+ <t-table
|
|
|
|
+ class="mt-12 data-list"
|
|
|
|
+ row-key="id"
|
|
|
|
+ :data="dataBindDialog.dataset"
|
|
|
|
+ :columns="dataSetColumns"
|
|
|
|
+ size="small"
|
|
|
|
+ bordered
|
|
|
|
+ :loading="dataBindDialog.loading"
|
|
|
|
+ :pagination="query"
|
|
|
|
+ @page-change="onChangePagination"
|
|
|
|
+ :selected-row-keys="dataBindDialog.selectedIds"
|
|
|
|
+ @select-change="onSelectBindsChange"
|
|
|
|
+ :max-height="270"
|
|
|
|
+ >
|
|
|
|
+ </t-table>
|
|
|
|
+ </t-tab-panel>
|
|
|
|
+ <t-tab-panel
|
|
|
|
+ :value="2"
|
|
|
|
+ label="数据模拟"
|
|
|
|
+ :destroy-on-hide="false"
|
|
|
|
+ style="height: 420px"
|
|
|
|
+ >
|
|
|
|
+ <div class="form-item mt-20">
|
|
|
|
+ <label>模拟值:</label>
|
|
|
|
+ <t-input v-model="dataBindDialog.data.mock" />
|
|
|
|
+ </div>
|
|
|
|
+ <div class="form-item mt-12">
|
|
|
|
+ <label>开启:</label>
|
|
|
|
+ <t-switch
|
|
|
|
+ class="mt-8"
|
|
|
|
+ size="small"
|
|
|
|
+ v-model="dataBindDialog.data.enableMock"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ <h6 class="desc mt-20">模拟值说明</h6>
|
|
|
|
+ <ul class="desc mt-4">
|
|
|
|
+ <li class="mt-4">
|
|
|
|
+ <label class="inline" style="width: 80px">固定值:</label>
|
|
|
|
+ 直接填写,例如:10
|
|
|
|
+ </li>
|
|
|
|
+ <li class="mt-4">
|
|
|
|
+ <label class="inline" style="width: 80px">随机值:</label>
|
|
|
|
+ {值1,值2,...}。例如:{1,2,3,4,5}
|
|
|
|
+ </li>
|
|
|
|
+ <li class="mt-4">
|
|
|
|
+ <label class="inline" style="width: 80px">范围数字:</label>
|
|
|
|
+ 最小值-最大值。例如:0-1.0 或 0-100
|
|
|
|
+ </li>
|
|
|
|
+ <li class="mt-4">
|
|
|
|
+ <label class="inline" style="width: 80px">随机字符串:</label>
|
|
|
|
+ [长度]。例如:[8]
|
|
|
|
+ </li>
|
|
|
|
+ </ul>
|
|
|
|
+ </t-tab-panel>
|
|
|
|
+ </t-tabs>
|
|
</t-dialog>
|
|
</t-dialog>
|
|
|
|
|
|
<t-dialog
|
|
<t-dialog
|
|
@@ -371,10 +420,11 @@ import {
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
import { MessagePlugin } from 'tdesign-vue-next';
|
|
import { MessagePlugin } from 'tdesign-vue-next';
|
|
import axios from 'axios';
|
|
import axios from 'axios';
|
|
|
|
+import { getter, setter } from '@meta2d/core/src/utils/object';
|
|
import { debounce } from '@/services/debouce';
|
|
import { debounce } from '@/services/debouce';
|
|
import { getPenTree, typeOptions } from '@/services/common';
|
|
import { getPenTree, typeOptions } from '@/services/common';
|
|
|
|
+import { searchPinyin } from '@/services/pinyin';
|
|
import { updatePen } from './pen';
|
|
import { updatePen } from './pen';
|
|
-import { getter, setter } from '@meta2d/core/src/utils/object';
|
|
|
|
|
|
|
|
import CodeEditor from '@/views/components/common/CodeEditor.vue';
|
|
import CodeEditor from '@/views/components/common/CodeEditor.vue';
|
|
import Actions from './Actions.vue';
|
|
import Actions from './Actions.vue';
|
|
@@ -481,13 +531,13 @@ const dataSetColumns = [
|
|
{
|
|
{
|
|
colKey: 'label',
|
|
colKey: 'label',
|
|
title: '数据点名称',
|
|
title: '数据点名称',
|
|
- width: 180,
|
|
|
|
|
|
+ width: 200,
|
|
ellipsis: { theme: 'light', trigger: 'context-menu' },
|
|
ellipsis: { theme: 'light', trigger: 'context-menu' },
|
|
},
|
|
},
|
|
{
|
|
{
|
|
colKey: 'id',
|
|
colKey: 'id',
|
|
title: '数据点ID',
|
|
title: '数据点ID',
|
|
- width: 180,
|
|
|
|
|
|
+ width: 200,
|
|
ellipsis: { theme: 'light', trigger: 'context-menu' },
|
|
ellipsis: { theme: 'light', trigger: 'context-menu' },
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -495,11 +545,6 @@ const dataSetColumns = [
|
|
title: '类型',
|
|
title: '类型',
|
|
width: 100,
|
|
width: 100,
|
|
},
|
|
},
|
|
- {
|
|
|
|
- colKey: 'value',
|
|
|
|
- title: '值',
|
|
|
|
- ellipsis: true,
|
|
|
|
- },
|
|
|
|
];
|
|
];
|
|
|
|
|
|
const operatorOptions = ref<any>([
|
|
const operatorOptions = ref<any>([
|
|
@@ -610,9 +655,6 @@ const onConfirmData = () => {
|
|
props.pen.realTimes.push(addDataDialog.data);
|
|
props.pen.realTimes.push(addDataDialog.data);
|
|
}
|
|
}
|
|
|
|
|
|
- meta2d.penMock(props.pen);
|
|
|
|
- meta2d.render();
|
|
|
|
-
|
|
|
|
addDataDialog.show = false;
|
|
addDataDialog.show = false;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -633,23 +675,11 @@ const onMenuMore = (e: any, item: any, i: number) => {
|
|
};
|
|
};
|
|
|
|
|
|
const onBind = (item: any) => {
|
|
const onBind = (item: any) => {
|
|
- // if (!item.binds) {
|
|
|
|
- // item.binds = [];
|
|
|
|
- // }
|
|
|
|
- // dataBindDialog.data = item;
|
|
|
|
- // dataBindDialog.input = '';
|
|
|
|
- // dataBindDialog.selectedIds = [];
|
|
|
|
- // for (const i of item.binds) {
|
|
|
|
- // dataBindDialog.selectedIds.push(i.id);
|
|
|
|
- // }
|
|
|
|
- // dataBindDialog.bkBinds = [];
|
|
|
|
- // dataBindDialog.bkBinds.push(...item.binds);
|
|
|
|
- // dataBindDialog.show = true;
|
|
|
|
dataBindDialog.data = item;
|
|
dataBindDialog.data = item;
|
|
dataBindDialog.input = '';
|
|
dataBindDialog.input = '';
|
|
dataBindDialog.selectedIds = [];
|
|
dataBindDialog.selectedIds = [];
|
|
- if (item.binds && item.binds.id) {
|
|
|
|
- dataBindDialog.selectedIds.push(item.binds.id);
|
|
|
|
|
|
+ if (item.bind && item.bind.id) {
|
|
|
|
+ dataBindDialog.selectedIds.push(item.bind.id);
|
|
}
|
|
}
|
|
dataBindDialog.show = true;
|
|
dataBindDialog.show = true;
|
|
getDataset();
|
|
getDataset();
|
|
@@ -669,15 +699,27 @@ const getDataset = async () => {
|
|
|
|
|
|
dataBindDialog.loading = true;
|
|
dataBindDialog.loading = true;
|
|
if (data.dataset.url) {
|
|
if (data.dataset.url) {
|
|
- const ret: any = await axios.get(data.dataset.url);
|
|
|
|
|
|
+ const ret: any = await axios.get(data.dataset.url, {
|
|
|
|
+ params: {
|
|
|
|
+ q: dataBindDialog.input,
|
|
|
|
+ current: query.current,
|
|
|
|
+ pageSize: query.pageSize,
|
|
|
|
+ },
|
|
|
|
+ });
|
|
dataBindDialog.dataset = ret;
|
|
dataBindDialog.dataset = ret;
|
|
query.total = ret.total;
|
|
query.total = ret.total;
|
|
|
|
+ } else if (dataBindDialog.input) {
|
|
|
|
+ dataBindDialog.dataset = data.dataset.data.filter((item: any) => {
|
|
|
|
+ return (
|
|
|
|
+ searchPinyin(item.label, dataBindDialog.input) ||
|
|
|
|
+ item.id.indexOf(dataBindDialog.input) > -1
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ query.total = dataBindDialog.dataset.length;
|
|
} else {
|
|
} else {
|
|
dataBindDialog.dataset = data.dataset.data;
|
|
dataBindDialog.dataset = data.dataset.data;
|
|
|
|
+ query.total = dataBindDialog.dataset.length;
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 应该从data获取url或结果列表
|
|
|
|
-
|
|
|
|
dataBindDialog.loading = false;
|
|
dataBindDialog.loading = false;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -692,55 +734,26 @@ const onChangePagination = (pageInfo: any) => {
|
|
};
|
|
};
|
|
|
|
|
|
const onSelectBindsChange = (value: string[], options: any) => {
|
|
const onSelectBindsChange = (value: string[], options: any) => {
|
|
- // dataBindDialog.selectedIds = value;
|
|
|
|
-
|
|
|
|
if (options.type === 'check') {
|
|
if (options.type === 'check') {
|
|
- // for (const item of options.selectedRowData) {
|
|
|
|
- // const found = dataBindDialog.data.binds.findIndex((elem: any) => {
|
|
|
|
- // return elem.id === item.id;
|
|
|
|
- // });
|
|
|
|
- // if (found < 0) {
|
|
|
|
- // dataBindDialog.data.binds.push(toRaw(item));
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
dataBindDialog.selectedIds = value;
|
|
dataBindDialog.selectedIds = value;
|
|
- dataBindDialog.data.binds = toRaw(options.selectedRowData[0]);
|
|
|
|
|
|
+ dataBindDialog.data.bind = toRaw(options.selectedRowData[0]);
|
|
doBindInit();
|
|
doBindInit();
|
|
- //
|
|
|
|
} else if (options.type === 'uncheck') {
|
|
} else if (options.type === 'uncheck') {
|
|
- // if (options.currentRowKey === 'CHECK_ALL_BOX') {
|
|
|
|
- // for (const data of dataBindDialog.dataSet) {
|
|
|
|
- // const found = dataBindDialog.data.binds.findIndex((elem: any) => {
|
|
|
|
- // return elem.id === data.id;
|
|
|
|
- // });
|
|
|
|
- // if (found > -1) {
|
|
|
|
- // dataBindDialog.data.binds.splice(found, 1);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // const found = dataBindDialog.data.binds.findIndex((elem: any) => {
|
|
|
|
- // return elem.id === options.currentRowKey;
|
|
|
|
- // });
|
|
|
|
- // if (found > -1) {
|
|
|
|
- // dataBindDialog.data.binds.splice(found, 1);
|
|
|
|
- // }
|
|
|
|
dataBindDialog.selectedIds = [];
|
|
dataBindDialog.selectedIds = [];
|
|
- dataBindDialog.data.binds = {};
|
|
|
|
- // }
|
|
|
|
|
|
+ dataBindDialog.data.bind = {};
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
const doBindInit = () => {
|
|
const doBindInit = () => {
|
|
- let { key } = dataBindDialog.data;
|
|
|
|
- if (props.pen.name === 'echarts' && key.includes('echarts.option.series')) {
|
|
|
|
|
|
+ let { id } = dataBindDialog.data;
|
|
|
|
+ if (props.pen.name === 'echarts' && id.includes('echarts.option.series')) {
|
|
const { replaceMode } = props.pen.echarts;
|
|
const { replaceMode } = props.pen.echarts;
|
|
const { xAxis } = props.pen.echarts.option;
|
|
const { xAxis } = props.pen.echarts.option;
|
|
|
|
|
|
- let beforeV = getter(props.pen, key);
|
|
|
|
|
|
+ let beforeV = getter(props.pen, id);
|
|
if (Array.isArray(beforeV) && replaceMode === 0) {
|
|
if (Array.isArray(beforeV) && replaceMode === 0) {
|
|
//追加
|
|
//追加
|
|
- setter(props.pen, key, []);
|
|
|
|
|
|
+ setter(props.pen, id, []);
|
|
let _key = 'echarts.option.xAxis.data';
|
|
let _key = 'echarts.option.xAxis.data';
|
|
if (Array.isArray(xAxis) && xAxis.length) {
|
|
if (Array.isArray(xAxis) && xAxis.length) {
|
|
_key = 'echarts.option.xAxis.0.data';
|
|
_key = 'echarts.option.xAxis.0.data';
|
|
@@ -756,27 +769,20 @@ const dataBindonConfirm = () => {
|
|
};
|
|
};
|
|
|
|
|
|
const onRemoveBind = () => {
|
|
const onRemoveBind = () => {
|
|
- // dataBindDialog.data.binds.splice(index, 1);
|
|
|
|
-
|
|
|
|
dataBindDialog.selectedIds = [];
|
|
dataBindDialog.selectedIds = [];
|
|
- // for (const i of dataBindDialog.data.binds) {
|
|
|
|
- // dataBindDialog.selectedIds.push(i.id);
|
|
|
|
- // }
|
|
|
|
- dataBindDialog.data.binds = undefined;
|
|
|
|
|
|
+ dataBindDialog.data.bind = undefined;
|
|
};
|
|
};
|
|
|
|
|
|
const getBindsDesc = (item: any) => {
|
|
const getBindsDesc = (item: any) => {
|
|
- if (!item.binds || !item.binds.id) {
|
|
|
|
- return '绑定动态数据';
|
|
|
|
|
|
+ if (item.bind?.label) {
|
|
|
|
+ return item.bind.label;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (item.enableMock && item.mock) {
|
|
|
|
+ return item.mock;
|
|
}
|
|
}
|
|
- // let desc = '';
|
|
|
|
- // for (const i of item.binds) {
|
|
|
|
- // desc += i.label + ',';
|
|
|
|
- // }
|
|
|
|
- // if (desc && desc.length > 1) {
|
|
|
|
- // desc = desc.substring(0, desc.length - 1);
|
|
|
|
- // }
|
|
|
|
- return item.binds.label;
|
|
|
|
|
|
+
|
|
|
|
+ return '动态数据';
|
|
};
|
|
};
|
|
|
|
|
|
const changeValue = (prop: string) => {
|
|
const changeValue = (prop: string) => {
|
|
@@ -946,8 +952,13 @@ onUnmounted(() => {
|
|
}
|
|
}
|
|
|
|
|
|
.data-list {
|
|
.data-list {
|
|
- height: 300px;
|
|
|
|
- overflow: auto;
|
|
|
|
|
|
+ :deep(.t-table__header--fixed:not(.t-table__header--multiple) > tr > th) {
|
|
|
|
+ background: none;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ :deep(.t-table__pagination) {
|
|
|
|
+ padding-bottom: 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|