lw-cdp-ui 1.1.70 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/lwCronSelect/index.vue +218 -0
- package/dist/components/lwFlow/components/lfControl.vue +126 -0
- package/dist/components/lwFlow/components/lfNodePanel.vue +98 -0
- package/dist/components/lwFlow/config/dagre.js +246 -0
- package/dist/components/lwFlow/config/nodesList.js +243 -0
- package/dist/components/lwFlow/index.vue +766 -0
- package/dist/components/lwFlow/nodeEdit/audienceReceive.vue +262 -0
- package/dist/components/lwFlow/nodeEdit/basicSettings.vue +148 -0
- package/dist/components/lwFlow/nodeEdit/eventReceive.vue +206 -0
- package/dist/components/lwFlow/nodeEdit/index.vue +136 -0
- package/dist/components/lwFlow/nodeEdit/sms.vue +167 -0
- package/dist/components/lwFlow/nodeEdit/styleSettings.vue +236 -0
- package/dist/components/lwFlow/nodes/basisEnd.js +56 -0
- package/dist/components/lwFlow/nodes/basisStart.js +56 -0
- package/dist/components/lwFlow/nodes/custom.js +129 -0
- package/dist/components/lwFlow/nodes/et2lTable.js +132 -0
- package/dist/components/lwFlow/nodesData/datas/audienceReceive.js +137 -0
- package/dist/components/lwFlow/nodesData/datas/collap.js +95 -0
- package/dist/components/lwFlow/nodesData/datas/eventReceive.js +106 -0
- package/dist/components/lwFlow/nodesData/datas/expand.js +85 -0
- package/dist/components/lwFlow/nodesData/datas/filter.js +85 -0
- package/dist/components/lwFlow/nodesData/datas/joiner.js +208 -0
- package/dist/components/lwFlow/nodesData/datas/mapper.js +111 -0
- package/dist/components/lwFlow/nodesData/datas/reduce.js +69 -0
- package/dist/components/lwFlow/nodesData/datas/sms.js +69 -0
- package/dist/components/lwFlow/nodesData/datas/source.js +183 -0
- package/dist/components/lwFlow/nodesData/datas/target.js +74 -0
- package/dist/components/lwFlow/nodesData/datas/timer.js +180 -0
- package/dist/components/lwFlow/nodesData/index.js +39 -0
- package/dist/components/lwForm/index.vue +631 -0
- package/dist/components/lwFormJson/JsonItem.vue +243 -0
- package/dist/components/lwFormJson/StatsConfig.vue +346 -0
- package/dist/components/lwFormJson/index.vue +321 -0
- package/dist/components/lwFormJson/menuList.js +321 -0
- package/dist/components/lwFormMini/FormItem.vue +443 -0
- package/dist/components/lwFormMini/index.vue +376 -0
- package/dist/components/lwFormView/index.vue +391 -0
- package/dist/components/lwFormView/textToPassword.vue +59 -0
- package/dist/components/lwIconSelect/iconSelect.js +289 -0
- package/dist/components/lwIconSelect/index.vue +142 -0
- package/dist/components/lwLayout/components/NavMenu.vue +36 -0
- package/dist/components/lwLayout/components/aside.vue +295 -0
- package/dist/components/lwLayout/components/bu.vue +85 -0
- package/dist/components/lwLayout/components/iframeView.vue +57 -0
- package/dist/components/lwLayout/components/lang.vue +77 -0
- package/dist/components/lwLayout/components/setting.vue +102 -0
- package/dist/components/lwLayout/components/sideM.vue +135 -0
- package/dist/components/lwLayout/components/tags.vue +390 -0
- package/dist/components/lwLayout/components/topbar.vue +69 -0
- package/dist/components/lwLayout/components/userbar.vue +213 -0
- package/dist/components/lwLayout/index.vue +460 -0
- package/dist/components/lwLogin/index.vue +504 -0
- package/dist/components/lwLogin/locale/en-us.js +37 -0
- package/dist/components/lwLogin/locale/zh-cn.js +37 -0
- package/dist/components/lwSearch/date/date.vue +113 -0
- package/dist/components/lwSearch/dateRange/dateRange.vue +118 -0
- package/dist/components/lwSearch/dates/dates.vue +366 -0
- package/dist/components/lwSearch/index.vue +628 -0
- package/dist/components/lwSearch/input/input.vue +54 -0
- package/dist/components/lwSearch/locale/en-us.js +15 -0
- package/dist/components/lwSearch/locale/zh-cn.js +15 -0
- package/dist/components/lwSearch/select/select.vue +57 -0
- package/dist/components/lwSvgIcon/index.vue +29 -0
- package/dist/components/lwTable/index.js +381 -0
- package/dist/components/lwTable/index.scss +233 -0
- package/dist/components/lwTable/index.vue +344 -0
- package/dist/components/lwTable/locale/en-US.js +26 -0
- package/dist/components/lwTable/locale/zh-CN.js +26 -0
- package/dist/components/lwTable/useFullscreen.js +73 -0
- package/dist/components/lwTableForm/index.vue +663 -0
- package/dist/components/lwTableSelect/index.vue +266 -0
- package/dist/components/lwTableSelect/tableSelect.js +23 -0
- package/dist/components/lwUpload/index.vue +513 -0
- package/dist/lw-cdp-ui.esm.js +18913 -0
- package/dist/lw-cdp-ui.umd.js +18 -0
- package/dist/static/images/empty.jpg +0 -0
- package/dist/static/images/login.svg +558 -0
- package/dist/static/images/logo.jpg +0 -0
- package/dist/static/images/logo.svg +78 -0
- package/dist/static/images/logo1.svg +86 -0
- package/dist/static/images/register.svg +351 -0
- package/dist/style.css +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-input v-model="showInput"
|
|
3
|
+
placeholder="CRON">
|
|
4
|
+
|
|
5
|
+
<template #append>
|
|
6
|
+
<el-popover placement="top"
|
|
7
|
+
:width="380"
|
|
8
|
+
:visible="visible"
|
|
9
|
+
trigger="click">
|
|
10
|
+
<template #reference>
|
|
11
|
+
<el-button @click="visible = true">选择</el-button>
|
|
12
|
+
</template>
|
|
13
|
+
<div class="select-model">
|
|
14
|
+
<el-select v-model="setData.curType"
|
|
15
|
+
placeholder="选择类型"
|
|
16
|
+
@change="changeInt"
|
|
17
|
+
style="margin-right: 5px;min-width: 80px;width: 80px">
|
|
18
|
+
<el-option label="每天"
|
|
19
|
+
:value="3" />
|
|
20
|
+
<el-option label="每月"
|
|
21
|
+
:value="4" />
|
|
22
|
+
<el-option label="每周"
|
|
23
|
+
:value="5" />
|
|
24
|
+
</el-select>
|
|
25
|
+
|
|
26
|
+
<el-select v-if="setData.curType === 4"
|
|
27
|
+
v-model="setData.day"
|
|
28
|
+
multiple
|
|
29
|
+
allow-clear
|
|
30
|
+
placeholder="日期"
|
|
31
|
+
@change="changeDay"
|
|
32
|
+
:max-tag-count="1"
|
|
33
|
+
style="margin-right: 5px; min-width: 120px">
|
|
34
|
+
<el-option label="最后一天"
|
|
35
|
+
value="L" />
|
|
36
|
+
<el-option v-for="item in 31"
|
|
37
|
+
:key="item"
|
|
38
|
+
:label="item"
|
|
39
|
+
:value="item"
|
|
40
|
+
:disabled="setData.day.indexOf('L') !== -1" />
|
|
41
|
+
</el-select>
|
|
42
|
+
|
|
43
|
+
<el-select v-if="setData.curType === 5"
|
|
44
|
+
v-model="setData.weeks"
|
|
45
|
+
multiple
|
|
46
|
+
allow-clear
|
|
47
|
+
placeholder="星期"
|
|
48
|
+
@change="changeWeeks"
|
|
49
|
+
:max-tag-count="1"
|
|
50
|
+
style="margin-right: 5px; min-width: 120px">
|
|
51
|
+
<el-option label="周日"
|
|
52
|
+
value="1"
|
|
53
|
+
:disabled="setData.weeks.indexOf('?') !== -1" />
|
|
54
|
+
<el-option label="周一"
|
|
55
|
+
value="2"
|
|
56
|
+
:disabled="setData.weeks.indexOf('?') !== -1" />
|
|
57
|
+
<el-option label="周二"
|
|
58
|
+
value="3"
|
|
59
|
+
:disabled="setData.weeks.indexOf('?') !== -1" />
|
|
60
|
+
<el-option label="周三"
|
|
61
|
+
value="4"
|
|
62
|
+
:disabled="setData.weeks.indexOf('?') !== -1" />
|
|
63
|
+
<el-option label="周四"
|
|
64
|
+
value="5"
|
|
65
|
+
:disabled="setData.weeks.indexOf('?') !== -1" />
|
|
66
|
+
<el-option label="周五"
|
|
67
|
+
value="6"
|
|
68
|
+
:disabled="setData.weeks.indexOf('?') !== -1" />
|
|
69
|
+
<el-option label="周六"
|
|
70
|
+
value="7"
|
|
71
|
+
:disabled="setData.weeks.indexOf('?') !== -1" />
|
|
72
|
+
</el-select>
|
|
73
|
+
|
|
74
|
+
<el-time-picker v-model="setData.timeData"
|
|
75
|
+
placeholder="时分秒"
|
|
76
|
+
value-format="HH:mm:ss"
|
|
77
|
+
style="min-width: 100px" />
|
|
78
|
+
|
|
79
|
+
</div>
|
|
80
|
+
<div style="margin-top: 10px; text-align: right;">
|
|
81
|
+
<el-button @click="visible = false">取消</el-button>
|
|
82
|
+
<el-button type="primary"
|
|
83
|
+
@click="changeOk">确定</el-button>
|
|
84
|
+
</div>
|
|
85
|
+
</el-popover>
|
|
86
|
+
</template>
|
|
87
|
+
</el-input>
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<script>
|
|
91
|
+
import { ref, computed } from 'vue';
|
|
92
|
+
|
|
93
|
+
export default {
|
|
94
|
+
name: 'lwCronSelect',
|
|
95
|
+
props: {
|
|
96
|
+
disabled: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false
|
|
99
|
+
},
|
|
100
|
+
modelValue: {
|
|
101
|
+
type: String,
|
|
102
|
+
default: ''
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
setup(props, { emit }) {
|
|
106
|
+
// 解析传入的modelValue,生成内部使用的dataList
|
|
107
|
+
const dataList = computed(() => {
|
|
108
|
+
return props.modelValue ? props.modelValue.split(' ') : ['*', '*', '*', '*', '*', '?']
|
|
109
|
+
})
|
|
110
|
+
// 初始化显示的输入值
|
|
111
|
+
const showInput = ref(props.modelValue)
|
|
112
|
+
// 控制弹出框的显示与隐藏
|
|
113
|
+
const visible = ref(false)
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 根据选择的类型重置相关数据
|
|
117
|
+
* @param {number} val - 选择的类型值
|
|
118
|
+
*/
|
|
119
|
+
const changeInt = (val) => {
|
|
120
|
+
switch (val) {
|
|
121
|
+
case 3:
|
|
122
|
+
dataList.value[3] = '*'
|
|
123
|
+
dataList.value[4] = '*'
|
|
124
|
+
dataList.value[5] = '*'
|
|
125
|
+
break
|
|
126
|
+
case 4:
|
|
127
|
+
dataList.value[4] = '*'
|
|
128
|
+
dataList.value[5] = '*'
|
|
129
|
+
break
|
|
130
|
+
case 5:
|
|
131
|
+
dataList.value[5] = '?'
|
|
132
|
+
break
|
|
133
|
+
}
|
|
134
|
+
setData.value.day = []
|
|
135
|
+
setData.value.weeks = []
|
|
136
|
+
setData.value.month = []
|
|
137
|
+
setData.value.timeData = ''
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 初始化setData对象,用于内部数据管理
|
|
141
|
+
const setData = ref({
|
|
142
|
+
curType: dataList.value[4] !== '*' ? 4 : dataList.value[5] === '?' ? 3 : 5,
|
|
143
|
+
day: dataList.value[3] === '*' ? [] : dataList.value[3]?.split(','),
|
|
144
|
+
month: dataList.value[4] === '*' ? [] : dataList.value[4]?.split(','),
|
|
145
|
+
weeks: dataList.value[5] === '?' ? [] : dataList.value[5]?.split(','),
|
|
146
|
+
timeData: dataList.value[0] === '*' ? '' : `${dataList.value[2]}:${dataList.value[1]}:${dataList.value[0]}`
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 处理日期选择
|
|
151
|
+
* @param {string} val - 选择的日期值
|
|
152
|
+
*/
|
|
153
|
+
const changeDay = (val) => {
|
|
154
|
+
if (val.indexOf('L') !== -1) {
|
|
155
|
+
setData.value.day = ['L']
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 处理周选择
|
|
161
|
+
* @param {string} val - 选择的周值
|
|
162
|
+
*/
|
|
163
|
+
const changeWeeks = (val) => {
|
|
164
|
+
if (val.indexOf('?') !== -1) {
|
|
165
|
+
setData.value.weeks = ['?']
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 更新cron表达式
|
|
171
|
+
*/
|
|
172
|
+
const changeCron = () => {
|
|
173
|
+
emit('update:modelValue', showInput.value)
|
|
174
|
+
emit('change')
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 确定选择,生成最终的cron表达式
|
|
179
|
+
*/
|
|
180
|
+
const changeOk = () => {
|
|
181
|
+
const time = setData.value.timeData ? setData.value.timeData.split(':') : ['*', '*', '*']
|
|
182
|
+
dataList.value[0] = time[2] === "*" ? time[2] : parseInt(time[2], 10).toString()
|
|
183
|
+
dataList.value[1] = time[1] === "*" ? time[1] : parseInt(time[1], 10).toString()
|
|
184
|
+
dataList.value[2] = time[0] === "*" ? time[0] : parseInt(time[0], 10).toString()
|
|
185
|
+
|
|
186
|
+
dataList.value[3] = setData.value.day.length > 0 ? setData.value.day.toString() : '*'
|
|
187
|
+
dataList.value[4] = setData.value.month.length > 0 ? setData.value.month.toString() : '*'
|
|
188
|
+
dataList.value[5] = setData.value.weeks.length > 0 ? setData.value.weeks.toString() : '?'
|
|
189
|
+
|
|
190
|
+
if (dataList.value[3] === '*' && dataList.value[5] !== '?') {
|
|
191
|
+
dataList.value[3] = '?'
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
showInput.value = `${dataList.value[0]} ${dataList.value[1]} ${dataList.value[2]} ${dataList.value[3]} ${dataList.value[4]} ${dataList.value[5]}`
|
|
195
|
+
|
|
196
|
+
emit('update:modelValue', showInput.value)
|
|
197
|
+
emit('change')
|
|
198
|
+
visible.value = false
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
setData,
|
|
203
|
+
showInput,
|
|
204
|
+
visible,
|
|
205
|
+
changeInt,
|
|
206
|
+
changeOk,
|
|
207
|
+
changeCron,
|
|
208
|
+
changeDay,
|
|
209
|
+
changeWeeks
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
</script>
|
|
214
|
+
<style lang="scss" scoped>
|
|
215
|
+
.select-model{
|
|
216
|
+
display: flex;
|
|
217
|
+
}
|
|
218
|
+
</style>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-button-group>
|
|
4
|
+
<el-tooltip class="box-item"
|
|
5
|
+
effect="dark"
|
|
6
|
+
content="放大"
|
|
7
|
+
placement="bottom-end">
|
|
8
|
+
<el-button plain
|
|
9
|
+
@click="zoomIn"
|
|
10
|
+
icon="el-icon-zoom-in"></el-button>
|
|
11
|
+
</el-tooltip>
|
|
12
|
+
<el-tooltip class="box-item"
|
|
13
|
+
effect="dark"
|
|
14
|
+
content="缩小"
|
|
15
|
+
placement="bottom-end">
|
|
16
|
+
<el-button plain
|
|
17
|
+
@click="zoomOut"
|
|
18
|
+
icon="el-icon-zoom-out"></el-button>
|
|
19
|
+
</el-tooltip>
|
|
20
|
+
|
|
21
|
+
<el-tooltip class="box-item"
|
|
22
|
+
effect="dark"
|
|
23
|
+
content="还原(大小&定位)"
|
|
24
|
+
placement="bottom-end">
|
|
25
|
+
<el-button plain
|
|
26
|
+
@click="reset"
|
|
27
|
+
icon="el-icon-location"></el-button>
|
|
28
|
+
</el-tooltip>
|
|
29
|
+
<el-tooltip class="box-item"
|
|
30
|
+
effect="dark"
|
|
31
|
+
content="上一步(ctrl+z)"
|
|
32
|
+
placement="bottom-end">
|
|
33
|
+
<el-button plain
|
|
34
|
+
@click="undo"
|
|
35
|
+
icon="el-icon-arrow-left"
|
|
36
|
+
:disabled="undoDisable"></el-button>
|
|
37
|
+
</el-tooltip>
|
|
38
|
+
<el-tooltip class="box-item"
|
|
39
|
+
effect="dark"
|
|
40
|
+
content="下一步(ctrl+y)"
|
|
41
|
+
placement="bottom-end">
|
|
42
|
+
<el-button plain
|
|
43
|
+
@click="redo"
|
|
44
|
+
icon="el-icon-arrow-right"
|
|
45
|
+
:disabled="redoDisable"></el-button>
|
|
46
|
+
</el-tooltip>
|
|
47
|
+
|
|
48
|
+
<el-tooltip class="box-item"
|
|
49
|
+
effect="dark"
|
|
50
|
+
content="缩略图(点击展开,再次点击关闭)"
|
|
51
|
+
placement="bottom-end">
|
|
52
|
+
<el-button plain
|
|
53
|
+
@click="showMiniMap"
|
|
54
|
+
icon="el-icon-position"></el-button>
|
|
55
|
+
</el-tooltip>
|
|
56
|
+
|
|
57
|
+
</el-button-group>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
<script>
|
|
61
|
+
/**
|
|
62
|
+
* 工具栏
|
|
63
|
+
*/
|
|
64
|
+
export default {
|
|
65
|
+
name: 'lfControl',
|
|
66
|
+
props: {
|
|
67
|
+
lf: {
|
|
68
|
+
type: Object,
|
|
69
|
+
default: () => { }
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
data() {
|
|
73
|
+
return {
|
|
74
|
+
undoDisable: true,
|
|
75
|
+
redoDisable: true,
|
|
76
|
+
graphData: null,
|
|
77
|
+
dataVisible: false,
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
mounted() {
|
|
81
|
+
this.$props.lf.on('history:change', ({ data: { undoAble, redoAble } }) => {
|
|
82
|
+
this.$data.undoDisable = !undoAble
|
|
83
|
+
this.$data.redoDisable = !redoAble
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
methods: {
|
|
87
|
+
zoomIn() {
|
|
88
|
+
this.$props.lf.zoom(true);
|
|
89
|
+
},
|
|
90
|
+
zoomOut() {
|
|
91
|
+
this.$props.lf.zoom(false);
|
|
92
|
+
},
|
|
93
|
+
zoomReset() {
|
|
94
|
+
this.$props.lf.resetZoom();
|
|
95
|
+
},
|
|
96
|
+
translateRest() {
|
|
97
|
+
this.$props.lf.resetTranslate();
|
|
98
|
+
},
|
|
99
|
+
reset() {
|
|
100
|
+
this.$props.lf.resetZoom();
|
|
101
|
+
this.$props.lf.resetTranslate();
|
|
102
|
+
this.$props.lf.translateCenter()
|
|
103
|
+
},
|
|
104
|
+
undo() {
|
|
105
|
+
this.$props.lf.undo();
|
|
106
|
+
},
|
|
107
|
+
redo() {
|
|
108
|
+
this.$props.lf.redo();
|
|
109
|
+
},
|
|
110
|
+
download() {
|
|
111
|
+
this.$props.lf.getSnapshot();
|
|
112
|
+
},
|
|
113
|
+
catData() {
|
|
114
|
+
this.$emit('catData');
|
|
115
|
+
},
|
|
116
|
+
showMiniMap() {
|
|
117
|
+
const { lf } = this.$props;
|
|
118
|
+
if (lf.extension.miniMap.isShow) {
|
|
119
|
+
lf.extension.miniMap.hide()
|
|
120
|
+
} else {
|
|
121
|
+
lf.extension.miniMap.show(lf.graphModel.width - 178, 50)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
</script>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="node-panel">
|
|
3
|
+
<el-collapse v-model="activeNames"
|
|
4
|
+
accordion>
|
|
5
|
+
<el-collapse-item v-for="item in nodeList"
|
|
6
|
+
:title="item.title"
|
|
7
|
+
:name="item.title">
|
|
8
|
+
<div class="node-list">
|
|
9
|
+
<div class="node-item"
|
|
10
|
+
v-for="item in item.list"
|
|
11
|
+
:class="[item.type]"
|
|
12
|
+
:key="item.name"
|
|
13
|
+
@mousedown="dragNode(item)">
|
|
14
|
+
<i class="iconfont"
|
|
15
|
+
:style="{color: item.themeColor}"
|
|
16
|
+
:class="[item.icon]"></i>
|
|
17
|
+
<span class="node-label">{{item.name}}</span>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</el-collapse-item>
|
|
21
|
+
</el-collapse>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
<script>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 节点面板
|
|
28
|
+
*/
|
|
29
|
+
export default {
|
|
30
|
+
name: 'lfNodePanel',
|
|
31
|
+
props: {
|
|
32
|
+
lf: Object,
|
|
33
|
+
nodeList: Array,
|
|
34
|
+
},
|
|
35
|
+
data() {
|
|
36
|
+
return {
|
|
37
|
+
activeNames: ''
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
mounted(){
|
|
41
|
+
this.activeNames = this.nodeList[0].title;
|
|
42
|
+
},
|
|
43
|
+
methods: {
|
|
44
|
+
dragNode(item) {
|
|
45
|
+
this.$props.lf.dnd.startDrag({
|
|
46
|
+
type: item.type,
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
<style lang="scss" scoped>
|
|
53
|
+
.node-panel {
|
|
54
|
+
position: absolute;
|
|
55
|
+
width: 200px;
|
|
56
|
+
left: 10px;
|
|
57
|
+
top: 10px;
|
|
58
|
+
border-radius: var(--el-popover-border-radius);
|
|
59
|
+
box-shadow: var(--el-box-shadow-light);
|
|
60
|
+
border: 1px solid var(--el-border-color-light);
|
|
61
|
+
padding: var(--el-popover-padding);
|
|
62
|
+
background-color: rgba($color: #ffffff, $alpha: 0.6);
|
|
63
|
+
box-shadow: 0 0 10px 1px rgb(228, 224, 219);
|
|
64
|
+
border-radius: 6px;
|
|
65
|
+
text-align: center;
|
|
66
|
+
z-index: 101;
|
|
67
|
+
:deep(.el-collapse) {
|
|
68
|
+
background-color: rgba($color: #ffffff, $alpha: 0.6);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
:deep(.el-collapse-item__header) {
|
|
72
|
+
padding-left: 10px;
|
|
73
|
+
font-weight: bold;
|
|
74
|
+
}
|
|
75
|
+
.node-list {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
gap: 10px;
|
|
79
|
+
padding: 10px;
|
|
80
|
+
max-height: 400px;
|
|
81
|
+
overflow: auto;
|
|
82
|
+
.node-item {
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
width: 100%;
|
|
85
|
+
padding: 6px 10px;
|
|
86
|
+
border-radius: var(--el-popover-border-radius);
|
|
87
|
+
color: var(--el-text-color-regular);
|
|
88
|
+
line-height: 20px;
|
|
89
|
+
font-size: var(--el-popover-font-size);
|
|
90
|
+
overflow-wrap: break-word;
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
background: var(--el-bg-color-overlay);
|
|
93
|
+
border: 1px solid var(--el-border-color-light);
|
|
94
|
+
display: flex;
|
|
95
|
+
gap: 5px;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import dagre from 'dagre';
|
|
2
|
+
import { graphlib } from 'dagre'
|
|
3
|
+
window.graphlib = graphlib
|
|
4
|
+
export default class Dagre {
|
|
5
|
+
static pluginName = 'dagre';
|
|
6
|
+
lf;
|
|
7
|
+
option;
|
|
8
|
+
|
|
9
|
+
render(lf) {
|
|
10
|
+
this.lf = lf;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getBytesLength(word) {
|
|
14
|
+
if (!word) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
let totalLength = 0;
|
|
18
|
+
for (let i = 0; i < word.length; i++) {
|
|
19
|
+
const c = word.charCodeAt(i);
|
|
20
|
+
if (word.match(/[A-Z]/)) {
|
|
21
|
+
totalLength += 1.5;
|
|
22
|
+
} else if ((c >= 0x0001 && c <= 0x007e) || (c >= 0xff60 && c <= 0xff9f)) {
|
|
23
|
+
totalLength += 1;
|
|
24
|
+
} else {
|
|
25
|
+
totalLength += 2;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return totalLength;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
layout(option = {}) {
|
|
32
|
+
const { nodes, edges, gridSize } = this.lf.graphModel;
|
|
33
|
+
|
|
34
|
+
let nodesep = 40;
|
|
35
|
+
let ranksep = 40;
|
|
36
|
+
if (gridSize > 20) {
|
|
37
|
+
nodesep = gridSize * 2;
|
|
38
|
+
ranksep = gridSize * 2;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.option = {
|
|
42
|
+
type: 'dagre',
|
|
43
|
+
rankdir: 'LR',
|
|
44
|
+
align: 'DR',
|
|
45
|
+
nodesep,
|
|
46
|
+
ranksep,
|
|
47
|
+
begin: [120, 120],
|
|
48
|
+
...option,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const layoutInstance = new DagreLayout(this.option);
|
|
52
|
+
const layoutData = layoutInstance.layout({
|
|
53
|
+
nodes: nodes.map((node) => ({
|
|
54
|
+
id: node.id,
|
|
55
|
+
size: {
|
|
56
|
+
width: node.width,
|
|
57
|
+
height: node.height,
|
|
58
|
+
},
|
|
59
|
+
model: node,
|
|
60
|
+
})),
|
|
61
|
+
edges: edges.map((edge) => ({
|
|
62
|
+
source: edge.sourceNodeId,
|
|
63
|
+
target: edge.targetNodeId,
|
|
64
|
+
model: edge,
|
|
65
|
+
})),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const newGraphData = {
|
|
69
|
+
nodes: [],
|
|
70
|
+
edges: [],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
layoutData?.nodes.forEach(node => {
|
|
74
|
+
const { model } = node;
|
|
75
|
+
const data = model.getData();
|
|
76
|
+
data.x = node.x;
|
|
77
|
+
data.y = node.y;
|
|
78
|
+
newGraphData.nodes.push(data);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
layoutData?.edges.forEach(edge => {
|
|
82
|
+
const { model } = edge;
|
|
83
|
+
const data = model.getData();
|
|
84
|
+
data.pointsList = this.calcPointsList(model, newGraphData.nodes);
|
|
85
|
+
if (data.pointsList) {
|
|
86
|
+
const first = data.pointsList[0];
|
|
87
|
+
const last = data.pointsList[data.pointsList.length - 1];
|
|
88
|
+
data.startPoint = { x: first.x, y: first.y };
|
|
89
|
+
data.endPoint = { x: last.x, y: last.y };
|
|
90
|
+
if (data.text && data.text.value) {
|
|
91
|
+
data.text = {
|
|
92
|
+
x: last.x - this.getBytesLength(data.text.value) * 6 - 10,
|
|
93
|
+
y: last.y,
|
|
94
|
+
value: data.text.value,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
data.startPoint = undefined;
|
|
99
|
+
data.endPoint = undefined;
|
|
100
|
+
if (data.text && data.text.value) {
|
|
101
|
+
data.text = data.text.value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
newGraphData.edges.push(data);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
this.lf.render(newGraphData);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
pointFilter(points) {
|
|
111
|
+
const allPoints = points;
|
|
112
|
+
let i = 1;
|
|
113
|
+
while (i < allPoints.length - 1) {
|
|
114
|
+
const pre = allPoints[i - 1];
|
|
115
|
+
const current = allPoints[i];
|
|
116
|
+
const next = allPoints[i + 1];
|
|
117
|
+
if ((pre.x === current.x && current.x === next.x)
|
|
118
|
+
|| (pre.y === current.y && current.y === next.y)) {
|
|
119
|
+
allPoints.splice(i, 1);
|
|
120
|
+
} else {
|
|
121
|
+
i++;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return allPoints;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
calcPointsList(model, nodes) {
|
|
128
|
+
const pointsList = [];
|
|
129
|
+
if (this.option.rankdir === 'LR' && model.modelType === 'polyline-edge') {
|
|
130
|
+
const sourceNodeModel = this.lf.getNodeModelById(model.sourceNodeId);
|
|
131
|
+
const targetNodeModel = this.lf.getNodeModelById(model.targetNodeId);
|
|
132
|
+
const newSourceNodeData = nodes.find(node => node.id === model.sourceNodeId);
|
|
133
|
+
const newTargetNodeData = nodes.find(node => node.id === model.targetNodeId);
|
|
134
|
+
if (newSourceNodeData.x < newTargetNodeData.x) {
|
|
135
|
+
pointsList.push({
|
|
136
|
+
x: newSourceNodeData.x + sourceNodeModel.width / 2,
|
|
137
|
+
y: newSourceNodeData.y,
|
|
138
|
+
});
|
|
139
|
+
pointsList.push({
|
|
140
|
+
x: newSourceNodeData.x + sourceNodeModel.width / 2 + (model.offset || 50),
|
|
141
|
+
y: newSourceNodeData.y,
|
|
142
|
+
});
|
|
143
|
+
pointsList.push({
|
|
144
|
+
x: newSourceNodeData.x + sourceNodeModel.width / 2 + (model.offset || 50),
|
|
145
|
+
y: newTargetNodeData.y,
|
|
146
|
+
});
|
|
147
|
+
pointsList.push({
|
|
148
|
+
x: newTargetNodeData.x - targetNodeModel.width / 2,
|
|
149
|
+
y: newTargetNodeData.y,
|
|
150
|
+
});
|
|
151
|
+
return this.pointFilter(pointsList);
|
|
152
|
+
}
|
|
153
|
+
if (newSourceNodeData.x > newTargetNodeData.x) {
|
|
154
|
+
if (newSourceNodeData.y >= newTargetNodeData.y) {
|
|
155
|
+
pointsList.push({
|
|
156
|
+
x: newSourceNodeData.x,
|
|
157
|
+
y: newSourceNodeData.y + sourceNodeModel.height / 2,
|
|
158
|
+
});
|
|
159
|
+
pointsList.push({
|
|
160
|
+
x: newSourceNodeData.x,
|
|
161
|
+
y: newSourceNodeData.y + sourceNodeModel.height / 2 + (model.offset || 50),
|
|
162
|
+
});
|
|
163
|
+
pointsList.push({
|
|
164
|
+
x: newTargetNodeData.x,
|
|
165
|
+
y: newSourceNodeData.y + sourceNodeModel.height / 2 + (model.offset || 50),
|
|
166
|
+
});
|
|
167
|
+
pointsList.push({
|
|
168
|
+
x: newTargetNodeData.x,
|
|
169
|
+
y: newTargetNodeData.y + targetNodeModel.height / 2,
|
|
170
|
+
});
|
|
171
|
+
} else {
|
|
172
|
+
pointsList.push({
|
|
173
|
+
x: newSourceNodeData.x,
|
|
174
|
+
y: newSourceNodeData.y - sourceNodeModel.height / 2,
|
|
175
|
+
});
|
|
176
|
+
pointsList.push({
|
|
177
|
+
x: newSourceNodeData.x,
|
|
178
|
+
y: newSourceNodeData.y - sourceNodeModel.height / 2 - (model.offset || 50),
|
|
179
|
+
});
|
|
180
|
+
pointsList.push({
|
|
181
|
+
x: newTargetNodeData.x,
|
|
182
|
+
y: newSourceNodeData.y - sourceNodeModel.height / 2 - (model.offset || 50),
|
|
183
|
+
});
|
|
184
|
+
pointsList.push({
|
|
185
|
+
x: newTargetNodeData.x,
|
|
186
|
+
y: newTargetNodeData.y - targetNodeModel.height / 2,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return this.pointFilter(pointsList);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
class DagreLayout {
|
|
197
|
+
constructor(options) {
|
|
198
|
+
this.options = {
|
|
199
|
+
rankdir: 'TB',
|
|
200
|
+
align: null,
|
|
201
|
+
nodesep: 50,
|
|
202
|
+
ranksep: 50,
|
|
203
|
+
controlPoints: false,
|
|
204
|
+
...options,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
layout(data) {
|
|
209
|
+
const { nodes, edges } = data;
|
|
210
|
+
if (!nodes || nodes.length === 0) return;
|
|
211
|
+
|
|
212
|
+
const g = new dagre.graphlib.Graph({ multigraph: true });
|
|
213
|
+
g.setGraph({});
|
|
214
|
+
g.setDefaultEdgeLabel(() => ({}));
|
|
215
|
+
|
|
216
|
+
g.graph().rankdir = this.options.rankdir;
|
|
217
|
+
g.graph().align = this.options.align;
|
|
218
|
+
g.graph().nodesep = this.options.nodesep;
|
|
219
|
+
g.graph().ranksep = this.options.ranksep;
|
|
220
|
+
|
|
221
|
+
nodes.forEach((node) => {
|
|
222
|
+
g.setNode(node.id, { width: node.width || 50, height: node.height || 50 });
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
edges.forEach((edge) => {
|
|
226
|
+
g.setEdge(edge.source, edge.target);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
dagre.layout(g);
|
|
230
|
+
|
|
231
|
+
nodes.forEach((node) => {
|
|
232
|
+
const coord = g.node(node.id);
|
|
233
|
+
node.x = coord.x;
|
|
234
|
+
node.y = coord.y;
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
if (this.options.controlPoints) {
|
|
238
|
+
edges.forEach((edge) => {
|
|
239
|
+
const edgeData = g.edge(edge.source, edge.target);
|
|
240
|
+
edge.controlPoints = edgeData.points;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return { nodes, edges };
|
|
245
|
+
}
|
|
246
|
+
}
|