eoss 0.1.0-alpha.20 → 0.1.0-alpha.21
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/lib/account-login.js +1943 -1890
- package/lib/alert.js +4 -4
- package/lib/aside.js +4 -4
- package/lib/autocomplete.js +4936 -4834
- package/lib/avatar.js +4 -4
- package/lib/backtop.js +4 -4
- package/lib/badge.js +4 -4
- package/lib/breadcrumb-item.js +6 -6
- package/lib/breadcrumb.js +7 -7
- package/lib/button-group.js +11 -14
- package/lib/button.js +6 -6
- package/lib/ca-login.js +2480 -2382
- package/lib/calendar.js +798 -798
- package/lib/card.js +4 -4
- package/lib/carousel-item.js +911 -813
- package/lib/carousel.js +1646 -1548
- package/lib/cascader-panel.js +2556 -2458
- package/lib/cascader.js +4546 -4444
- package/lib/checkbox-button.js +4 -4
- package/lib/checkbox-group.js +2894 -2841
- package/lib/checkbox.js +4 -4
- package/lib/col.js +2 -2
- package/lib/collapse-item.js +35159 -2572
- package/lib/collapse.js +35410 -2762
- package/lib/color-picker.js +494 -490
- package/lib/config/api.js +15 -1
- package/lib/container.js +4 -4
- package/lib/cron.js +4 -4
- package/lib/data-table.js +1895 -1842
- package/lib/date-picker.js +6422 -6320
- package/lib/dialog.js +2912 -2806
- package/lib/divider.js +4 -4
- package/lib/drawer.js +311 -299
- package/lib/dropdown-item.js +6 -6
- package/lib/dropdown-menu.js +539 -535
- package/lib/dropdown.js +2270 -2172
- package/lib/email-login.js +1783 -1730
- package/lib/empty.js +723 -0
- package/lib/eoss.common.js +63680 -56193
- package/lib/flip.js +4 -4
- package/lib/flow-group.js +2985 -2887
- package/lib/flow.js +28067 -28022
- package/lib/footer.js +4 -4
- package/lib/form-item.js +1935 -1837
- package/lib/form.js +9230 -9092
- package/lib/header.js +4 -4
- package/lib/icon.js +1708 -1590
- package/lib/icons.js +4 -4
- package/lib/image-viewer.js +1660 -1562
- package/lib/image.js +162 -162
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +76 -76
- package/lib/input-number.js +172 -172
- package/lib/input.js +1362 -1264
- package/lib/link.js +4 -4
- package/lib/loading.js +321 -317
- package/lib/login.js +3306 -3300
- package/lib/lowcode.js +13320 -0
- package/lib/main.js +14465 -14339
- package/lib/marquee.js +1237 -1139
- package/lib/menu-item-group.js +119 -119
- package/lib/menu-item.js +114 -114
- package/lib/menu.js +6193 -6091
- package/lib/message-box.js +3582 -3480
- package/lib/message.js +2265 -2163
- package/lib/notification.js +2430 -2328
- package/lib/option-group.js +4 -4
- package/lib/option.js +842 -744
- package/lib/page-header.js +4 -4
- package/lib/pagination.js +1916 -1815
- package/lib/phone-login.js +1788 -1735
- package/lib/popconfirm.js +8 -8
- package/lib/popover.js +4559 -4457
- package/lib/progress.js +4 -4
- package/lib/qr-code.js +9 -9
- package/lib/qrcode-login.js +1600 -1543
- package/lib/radio-button.js +6 -6
- package/lib/radio-group.js +2142 -2089
- package/lib/radio.js +6 -6
- package/lib/rate.js +1226 -1128
- package/lib/row.js +2 -2
- package/lib/scrollbar.js +2695 -2597
- package/lib/select.js +5985 -5961
- package/lib/selector-panel.js +5239 -5186
- package/lib/selector.js +1712 -1659
- package/lib/slider.js +16 -16
- package/lib/step.js +35836 -2736
- package/lib/steps.js +1281 -1183
- package/lib/submenu.js +461 -457
- package/lib/switch.js +1010 -912
- package/lib/tab-pane.js +4 -4
- package/lib/table-column.js +2595 -2497
- package/lib/table.js +9225 -9239
- package/lib/tabs.js +2414 -2320
- package/lib/tag.js +4 -4
- package/lib/theme-chalk/account-login.css +1 -1
- package/lib/theme-chalk/autocomplete.css +1 -1
- package/lib/theme-chalk/base.css +1 -1
- package/lib/theme-chalk/cascader.css +1 -1
- package/lib/theme-chalk/date-picker.css +1 -1
- package/lib/theme-chalk/empty.css +1 -0
- package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
- package/lib/theme-chalk/fonts/iconfont.woff +0 -0
- package/lib/theme-chalk/form.css +1 -1
- package/lib/theme-chalk/icon.css +1 -1
- package/lib/theme-chalk/index.css +1 -1
- package/lib/theme-chalk/input-number.css +1 -1
- package/lib/theme-chalk/input.css +1 -1
- package/lib/theme-chalk/login.css +1 -1
- package/lib/theme-chalk/lowcode.css +1 -0
- package/lib/theme-chalk/main.css +1 -1
- package/lib/theme-chalk/message-box.css +1 -1
- package/lib/theme-chalk/pagination.css +1 -1
- package/lib/theme-chalk/qrcode-login.css +1 -1
- package/lib/theme-chalk/select.css +1 -1
- package/lib/theme-chalk/slider.css +1 -1
- package/lib/theme-chalk/tabs.css +1 -1
- package/lib/theme-chalk/time-picker.css +1 -1
- package/lib/theme-chalk/transfer.css +1 -1
- package/lib/time-picker.js +5823 -5819
- package/lib/time-select.js +3578 -3574
- package/lib/timeline-item.js +4 -4
- package/lib/timeline.js +4 -4
- package/lib/tips.js +1633 -1580
- package/lib/toolbar.js +213 -213
- package/lib/tooltip.js +4441 -4339
- package/lib/transfer.js +938 -840
- package/lib/tree-group.js +1875 -1757
- package/lib/tree.js +2626 -2573
- package/lib/upload.js +7209 -7156
- package/lib/utils/ajax.js +185 -243
- package/lib/utils/bus.js +2 -2
- package/lib/utils/popup/index.js +5 -1
- package/lib/utils/util.js +108 -11
- package/package.json +2 -2
- package/packages/button/src/button-group.vue +1 -4
- package/packages/collapse/src/collapse-item.vue +47 -33
- package/packages/dialog/src/dialog.vue +4 -1
- package/packages/drawer/src/drawer.vue +12 -4
- package/packages/empty/index.js +7 -0
- package/packages/empty/src/img-empty.vue +132 -0
- package/packages/empty/src/index.vue +49 -0
- package/packages/form/src/form-item-render.vue +16 -18
- package/packages/form/src/form.vue +27 -5
- package/packages/icons/src/icon.json +1 -1
- package/packages/login/src/login.vue +19 -21
- package/packages/login/src/mixins.js +2 -1
- package/packages/lowcode/index.js +5 -0
- package/packages/lowcode/src/aside.vue +331 -0
- package/packages/lowcode/src/attribute/bind.vue +441 -0
- package/packages/lowcode/src/attribute/dependency.vue +325 -0
- package/packages/lowcode/src/attribute/function.vue +112 -0
- package/packages/lowcode/src/attribute/property.vue +331 -0
- package/packages/lowcode/src/attribute/styles.vue +318 -0
- package/packages/lowcode/src/attribute.vue +135 -0
- package/packages/lowcode/src/canvas.vue +296 -0
- package/packages/lowcode/src/json.vue +32 -0
- package/packages/lowcode/src/lowcode.vue +539 -0
- package/packages/lowcode/src/modules.vue +93 -0
- package/packages/lowcode/src/pages.vue +91 -0
- package/packages/lowcode/src/render.vue +247 -0
- package/packages/lowcode/src/source.vue +32 -0
- package/packages/lowcode/src/toolbar.vue +162 -0
- package/packages/main/src/components/pages.vue +28 -2
- package/packages/main/src/components/set-menus.vue +3 -3
- package/packages/main/src/components/user.vue +6 -1
- package/packages/main/src/early.vue +2 -2
- package/packages/main/src/gzw.vue +55 -61
- package/packages/main/src/minxs.js +113 -36
- package/packages/pagination/src/pager.vue +2 -2
- package/packages/pagination/src/pagination.js +4 -1
- package/packages/qrcode-login/src/qrcode-login.vue +6 -2
- package/packages/select/src/select.vue +28 -6
- package/packages/steps/src/step.vue +7 -5
- package/packages/tabs/src/tab-nav.vue +1 -0
- package/packages/tabs/src/tabs.vue +0 -2
- package/packages/theme-chalk/dist/fonts/iconfont.ttf +0 -0
- package/packages/theme-chalk/dist/fonts/iconfont.woff +0 -0
- package/packages/theme-chalk/gulpfile.js +3 -0
- package/packages/theme-chalk/src/account-login.scss +1 -0
- package/packages/theme-chalk/src/base.scss +1 -1
- package/packages/theme-chalk/src/common/var.scss +16 -0
- package/packages/theme-chalk/src/empty.scss +45 -0
- package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
- package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
- package/packages/theme-chalk/src/form.scss +1 -8
- package/packages/theme-chalk/src/icon.scss +30 -1
- package/packages/theme-chalk/src/index.scss +2 -0
- package/packages/theme-chalk/src/input-number.scss +0 -4
- package/packages/theme-chalk/src/input.scss +9 -0
- package/packages/theme-chalk/src/login.scss +32 -29
- package/packages/theme-chalk/src/lowcode.scss +461 -0
- package/packages/theme-chalk/src/main.scss +28 -65
- package/packages/theme-chalk/src/pagination.scss +4 -55
- package/packages/theme-chalk/src/qrcode-login.scss +3 -1
- package/packages/theme-chalk/src/tabs.scss +81 -50
- package/src/config/api.js +13 -0
- package/src/index.js +17 -4
- package/src/utils/ajax.js +61 -65
- package/src/utils/bus.js +2 -2
- package/src/utils/popup/index.js +5 -1
- package/src/utils/util.js +104 -7
- package/lib/index_/345/211/257/346/234/254.js +0 -583
- package/packages/dialog copy/index.js +0 -8
- package/packages/dialog copy/src/dialog.vue +0 -615
- package/src/index_/345/211/257/346/234/254.js +0 -359
- /package/{packages/form/src → src/components}/field-render.vue +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="es-lowcode__attribute" :style="styles">
|
|
3
|
+
<es-tabs class="es-lowcode__attribute--tabs" v-model="active" type="card">
|
|
4
|
+
<es-tab-pane label="样式" name="1" lazy>
|
|
5
|
+
<styles :model="current" @change="handleModelUpdate"></styles>
|
|
6
|
+
</es-tab-pane>
|
|
7
|
+
<es-tab-pane label="绑定" name="2" lazy>
|
|
8
|
+
<bind :model="current" @change="handleModelUpdate"></bind>
|
|
9
|
+
</es-tab-pane>
|
|
10
|
+
<es-tab-pane label="定义" name="3" lazy>
|
|
11
|
+
<property :model="current" @change="handleModelUpdate"></property>
|
|
12
|
+
</es-tab-pane>
|
|
13
|
+
<es-tab-pane label="函数" name="4" lazy>
|
|
14
|
+
<functions :model="current" @change="handleModelUpdate"></functions>
|
|
15
|
+
</es-tab-pane>
|
|
16
|
+
<es-tab-pane label="依赖" name="5" lazy>
|
|
17
|
+
<dependency :model="current" @change="handleModelUpdate"></dependency>
|
|
18
|
+
</es-tab-pane>
|
|
19
|
+
</es-tabs>
|
|
20
|
+
<div class="es-lowcode__attribute--handle" @click.self="handleClick"></div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import bus from 'eoss/src/utils/bus.js';
|
|
26
|
+
import Property from './attribute/property.vue';
|
|
27
|
+
import Styles from './attribute/styles.vue';
|
|
28
|
+
import Bind from './attribute/bind.vue';
|
|
29
|
+
import Functions from './attribute/function.vue';
|
|
30
|
+
import Dependency from './attribute/dependency.vue';
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
name: 'Attribute',
|
|
34
|
+
components: {
|
|
35
|
+
Property,
|
|
36
|
+
Styles,
|
|
37
|
+
Bind,
|
|
38
|
+
Functions,
|
|
39
|
+
Dependency
|
|
40
|
+
},
|
|
41
|
+
props: {
|
|
42
|
+
page: {
|
|
43
|
+
type: Object,
|
|
44
|
+
default: null
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
data() {
|
|
48
|
+
return {
|
|
49
|
+
styles: { width: 0 },
|
|
50
|
+
show: false,
|
|
51
|
+
active: '1',
|
|
52
|
+
selected: '',
|
|
53
|
+
/** 当前选中组件的深拷贝副本,仅用于子组件展示 */
|
|
54
|
+
current: {}
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
computed: {},
|
|
58
|
+
watch: {
|
|
59
|
+
show(val) {
|
|
60
|
+
this.styles.width = val ? '350px' : '0px';
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
mounted() {
|
|
64
|
+
/**
|
|
65
|
+
* 监听组件点击事件,更新当前选中的组件
|
|
66
|
+
*/
|
|
67
|
+
bus.$on('componentClick', (id) => {
|
|
68
|
+
this.show = true;
|
|
69
|
+
this.selected = id;
|
|
70
|
+
if (this.page) {
|
|
71
|
+
this.current = this.getComponent(this.page);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* 监听页面切换事件,同步刷新当前选中组件
|
|
76
|
+
*/
|
|
77
|
+
bus.$on('updatePage', () => {
|
|
78
|
+
if (this.selected && this.page) {
|
|
79
|
+
this.current = this.getComponent(this.page);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
methods: {
|
|
84
|
+
/**
|
|
85
|
+
* 处理点击事件
|
|
86
|
+
*/
|
|
87
|
+
handleClick() {
|
|
88
|
+
this.show = false;
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* 从 page 树中查找并返回指定组件的深拷贝
|
|
92
|
+
* 支持页面本身和嵌套子组件的查找
|
|
93
|
+
* @param {Object} page - 页面对象或组件对象
|
|
94
|
+
* @returns {Object} 组件深拷贝对象,未找到返回空对象
|
|
95
|
+
*/
|
|
96
|
+
getComponent(page) {
|
|
97
|
+
if (!page || !this.selected) return {};
|
|
98
|
+
// 先匹配页面本身
|
|
99
|
+
if (page.id === this.selected) return JSON.parse(JSON.stringify(page));
|
|
100
|
+
// 再在 children 树中递归查找
|
|
101
|
+
if (page.children && page.children.length) {
|
|
102
|
+
const found = this.findInTree(page.children, this.selected);
|
|
103
|
+
if (found && found.id) return JSON.parse(JSON.stringify(found));
|
|
104
|
+
}
|
|
105
|
+
return {};
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* 在树结构中递归查找指定 ID 的组件
|
|
109
|
+
* @param {Array} children - 子组件数组
|
|
110
|
+
* @param {String} id - 目标组件 ID
|
|
111
|
+
* @returns {Object|null} 找到的组件或空对象
|
|
112
|
+
*/
|
|
113
|
+
findInTree(children, id) {
|
|
114
|
+
for (const child of children) {
|
|
115
|
+
if (child.id === id) return child;
|
|
116
|
+
if (child.children && child.children.length) {
|
|
117
|
+
const found = this.findInTree(child.children, id);
|
|
118
|
+
if (found) return found;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {};
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* 处理模型更新(来自属性子组件)
|
|
125
|
+
* 合并当前组件 ID 后通过 bus 转发给 lowcode 数据中心
|
|
126
|
+
* 注意:此处不更新 current,避免触发子组件 model watcher 覆盖编辑状态
|
|
127
|
+
* current 只在点击组件或切换页面时才重新同步
|
|
128
|
+
* @param {Object} updates - 子组件传递的更新字段(如 { style: {...} }, { attrs: {...} } 等)
|
|
129
|
+
*/
|
|
130
|
+
handleModelUpdate(updates) {
|
|
131
|
+
bus.$emit('updateComponent', { ...updates, id: this.selected });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
</script>
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="es-lowcode__canvas" ref="waterfallContainer">
|
|
3
|
+
<div
|
|
4
|
+
class="es-lowcode__canvas--content"
|
|
5
|
+
:class="{
|
|
6
|
+
'is-empty': isEmpty,
|
|
7
|
+
'is-active': active === (page && page.id)
|
|
8
|
+
}"
|
|
9
|
+
:style="styles"
|
|
10
|
+
@drop="handleDrop"
|
|
11
|
+
@dragover="handleDragOver"
|
|
12
|
+
@click.stop="handleClickPage(page)"
|
|
13
|
+
>
|
|
14
|
+
<es-empty description="请新建或打开文件" v-if="isEmpty" />
|
|
15
|
+
<es-scrollbar v-else>
|
|
16
|
+
<div
|
|
17
|
+
class="es-lowcode__canvas--components"
|
|
18
|
+
ref="container"
|
|
19
|
+
:style="getStyle(page)"
|
|
20
|
+
>
|
|
21
|
+
<Render
|
|
22
|
+
class="es-lowcode__canvas--component"
|
|
23
|
+
:class="{ 'is-active': active === node.id }"
|
|
24
|
+
v-for="(node, index) in components"
|
|
25
|
+
:key="node.id"
|
|
26
|
+
:node="node"
|
|
27
|
+
:active="active"
|
|
28
|
+
:span="page && page.span"
|
|
29
|
+
@click="handleClick(node)"
|
|
30
|
+
@change="
|
|
31
|
+
(newNode, direction) => handleChange(newNode, index, direction)
|
|
32
|
+
"
|
|
33
|
+
@remove="handleRemove(index)"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
</es-scrollbar>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script>
|
|
42
|
+
import Render from './render.vue';
|
|
43
|
+
import {
|
|
44
|
+
uuid,
|
|
45
|
+
layoutWaterfall
|
|
46
|
+
} from 'eoss/src/utils/util.js';
|
|
47
|
+
import bus from 'eoss/src/utils/bus.js';
|
|
48
|
+
import Sortable from 'sortablejs';
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
name: 'Canvas',
|
|
52
|
+
components: {
|
|
53
|
+
Render
|
|
54
|
+
},
|
|
55
|
+
props: {
|
|
56
|
+
page: {
|
|
57
|
+
type: Object,
|
|
58
|
+
default: null
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
data() {
|
|
62
|
+
return {
|
|
63
|
+
styles: {},
|
|
64
|
+
active: '',
|
|
65
|
+
isEmpty: true,
|
|
66
|
+
components: [],
|
|
67
|
+
columns: 1,
|
|
68
|
+
gap: 0,
|
|
69
|
+
widths: {},
|
|
70
|
+
resizeObserver: null
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
watch: {
|
|
74
|
+
/**
|
|
75
|
+
* 深度监听 page prop 变化,同步渲染组件列表
|
|
76
|
+
* 所有数据修改由 lowcode 统一处理,Canvas 只负责读取和展示
|
|
77
|
+
*/
|
|
78
|
+
page: {
|
|
79
|
+
handler(val) {
|
|
80
|
+
this.isEmpty = !val;
|
|
81
|
+
this.components = (val && val.children) || [];
|
|
82
|
+
this.$nextTick(() => {
|
|
83
|
+
this.initSortable();
|
|
84
|
+
if (val && val.style && val.style.display === 'masonry') {
|
|
85
|
+
this.layoutWaterfall();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
deep: true,
|
|
90
|
+
immediate: true
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
mounted() {
|
|
94
|
+
this.$nextTick(() => {
|
|
95
|
+
this.initSortable();
|
|
96
|
+
// 监听容器大小变化
|
|
97
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
98
|
+
this.layoutWaterfall();
|
|
99
|
+
});
|
|
100
|
+
const container = this.$refs.waterfallContainer;
|
|
101
|
+
if (container) {
|
|
102
|
+
this.resizeObserver.observe(container);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* 监听changeSize事件,动态更新Canvas样式
|
|
107
|
+
* @param type 大小类型,'size' 或 'app'
|
|
108
|
+
* @param size 大小值,根据类型不同而不同
|
|
109
|
+
*/
|
|
110
|
+
bus.$on('changeSize', (type, size) => {
|
|
111
|
+
this.styles = {};
|
|
112
|
+
if (type === 'app') {
|
|
113
|
+
this.styles.width = '750px';
|
|
114
|
+
}
|
|
115
|
+
if (type === 'custom') {
|
|
116
|
+
this.styles = size;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
methods: {
|
|
121
|
+
layoutWaterfall() {
|
|
122
|
+
const page = this.page;
|
|
123
|
+
if (!page) return;
|
|
124
|
+
const style = page.style || {};
|
|
125
|
+
this.columns = parseInt(style.columns || 1, 10);
|
|
126
|
+
this.gap = parseInt(style.gap || 0, 10);
|
|
127
|
+
this.widths = layoutWaterfall(
|
|
128
|
+
this,
|
|
129
|
+
this.$refs.container,
|
|
130
|
+
this.components,
|
|
131
|
+
this.columns,
|
|
132
|
+
this.gap
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
getStyle(page) {
|
|
136
|
+
const style = page ? page.style || {} : {};
|
|
137
|
+
|
|
138
|
+
let { columns, span, ...styles } = style;
|
|
139
|
+
if (styles.display && styles.display !== 'masonry') {
|
|
140
|
+
delete styles.display;
|
|
141
|
+
}
|
|
142
|
+
if (styles.display && styles.display === 'grid' && columns) {
|
|
143
|
+
styles['grid-template-columns'] = `repeat(${columns}, 1fr)`;
|
|
144
|
+
}
|
|
145
|
+
return styles;
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* 初始化Sortable拖拽功能
|
|
149
|
+
*/
|
|
150
|
+
initSortable() {
|
|
151
|
+
if (!this.$refs.container) return;
|
|
152
|
+
|
|
153
|
+
const view = this.$refs.container;
|
|
154
|
+
// 先销毁已存在的Sortable实例
|
|
155
|
+
const existingSortable = Sortable.get(view);
|
|
156
|
+
if (existingSortable) {
|
|
157
|
+
existingSortable.destroy();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
new Sortable(view, {
|
|
161
|
+
animation: 150,
|
|
162
|
+
fallbackOnBody: true,
|
|
163
|
+
ghostClass: 'es-lowcode__canvas-ghost',
|
|
164
|
+
chosenClass: 'es-lowcode__canvas-chosen',
|
|
165
|
+
dragClass: 'es-lowcode__canvas-drag',
|
|
166
|
+
group: {
|
|
167
|
+
name: 'shared',
|
|
168
|
+
pull: true,
|
|
169
|
+
put: true
|
|
170
|
+
},
|
|
171
|
+
onEnd: (evt) => {
|
|
172
|
+
const oldIndex = evt.oldIndex;
|
|
173
|
+
const newIndex = evt.newIndex;
|
|
174
|
+
|
|
175
|
+
// 如果位置没有变化则不处理
|
|
176
|
+
if (
|
|
177
|
+
oldIndex === newIndex ||
|
|
178
|
+
oldIndex === undefined ||
|
|
179
|
+
newIndex === undefined
|
|
180
|
+
)
|
|
181
|
+
return;
|
|
182
|
+
|
|
183
|
+
// 移动组件数组中的元素
|
|
184
|
+
const movedItem = this.components[oldIndex];
|
|
185
|
+
this.components.splice(newIndex, 0, movedItem);
|
|
186
|
+
this.components.splice(
|
|
187
|
+
oldIndex > newIndex ? oldIndex + 1 : oldIndex,
|
|
188
|
+
1
|
|
189
|
+
);
|
|
190
|
+
// 通知 lowcode 同步更新 page.children
|
|
191
|
+
this.notifyChildrenChange();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
handleClickPage(page) {
|
|
196
|
+
this.handleClick(page);
|
|
197
|
+
// this.$nextTick(() => {
|
|
198
|
+
// this.layoutWaterfall();
|
|
199
|
+
// });
|
|
200
|
+
},
|
|
201
|
+
/**
|
|
202
|
+
* 处理组件点击事件
|
|
203
|
+
* @param {Object} comp 被点击的组件
|
|
204
|
+
*/
|
|
205
|
+
handleClick(comp) {
|
|
206
|
+
this.active = comp.id;
|
|
207
|
+
bus.$emit('componentClick', comp.id);
|
|
208
|
+
},
|
|
209
|
+
/**
|
|
210
|
+
* 处理 Render 子组件的数据变更(如调整大小等)
|
|
211
|
+
* @param {Object} node 变更后的组件数据
|
|
212
|
+
* @param {Number} index 组件在列表中的索引
|
|
213
|
+
*/
|
|
214
|
+
handleChange(node, index, direction) {
|
|
215
|
+
const old = this.components[index];
|
|
216
|
+
const oldWidth = parseInt(old.style.width, 10);
|
|
217
|
+
const width = parseInt(node.style.width, 10);
|
|
218
|
+
if (direction === 'left' || direction === 'right') {
|
|
219
|
+
if (width > oldWidth) {
|
|
220
|
+
node.style.span = Math.ceil(width / this.widths.columnWidth);
|
|
221
|
+
} else {
|
|
222
|
+
node.style.span = Math.floor(width / this.widths.columnWidth);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
this.components.splice(index, 1, node);
|
|
226
|
+
// 通知 lowcode 更新对应组件
|
|
227
|
+
this.notifyComponentChange(node);
|
|
228
|
+
this.$nextTick(() => {
|
|
229
|
+
this.layoutWaterfall();
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
/**
|
|
233
|
+
* 处理组件删除事件
|
|
234
|
+
* @param {Number} index 被删除的组件索引
|
|
235
|
+
*/
|
|
236
|
+
handleRemove(index) {
|
|
237
|
+
this.components.splice(index, 1);
|
|
238
|
+
// 通知 lowcode 同步更新 page.children
|
|
239
|
+
this.notifyChildrenChange();
|
|
240
|
+
this.$nextTick(() => {
|
|
241
|
+
this.layoutWaterfall();
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* 处理拖动结束事件
|
|
246
|
+
* @param {Event} event 拖动事件对象
|
|
247
|
+
*/
|
|
248
|
+
handleDragOver(event) {
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
if (event.dataTransfer) {
|
|
251
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
/**
|
|
255
|
+
* 处理拖动放置事件
|
|
256
|
+
* @param {Event} event 拖动事件对象
|
|
257
|
+
*/
|
|
258
|
+
handleDrop(event) {
|
|
259
|
+
event.preventDefault();
|
|
260
|
+
if (this.isEmpty) {
|
|
261
|
+
this.$message.warning('请选择页面!');
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (event.dataTransfer) {
|
|
265
|
+
const componentData = event.dataTransfer.getData('component');
|
|
266
|
+
if (componentData) {
|
|
267
|
+
const component = JSON.parse(componentData);
|
|
268
|
+
const id = `${uuid()}`;
|
|
269
|
+
// 生成新组件并添加到列表
|
|
270
|
+
this.components.push({ ...component, id });
|
|
271
|
+
// 通知 lowcode 同步更新 page.children
|
|
272
|
+
this.notifyChildrenChange();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
/**
|
|
277
|
+
* 通知 lowcode 更新整个 children 列表
|
|
278
|
+
*/
|
|
279
|
+
notifyChildrenChange() {
|
|
280
|
+
bus.$emit('updateChildren', [...this.components]);
|
|
281
|
+
},
|
|
282
|
+
/**
|
|
283
|
+
* 通知 lowcode 更新单个组件数据
|
|
284
|
+
* @param {Object} comp 变更后的组件数据
|
|
285
|
+
*/
|
|
286
|
+
notifyComponentChange(comp) {
|
|
287
|
+
bus.$emit('updateComponent', { ...comp });
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
beforeDestroy() {
|
|
291
|
+
if (this.resizeObserver) {
|
|
292
|
+
this.resizeObserver.disconnect();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="es-lowcode__json">
|
|
3
|
+
<pre>{{ page }}</pre>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: 'Json',
|
|
10
|
+
|
|
11
|
+
components: {},
|
|
12
|
+
|
|
13
|
+
props: {},
|
|
14
|
+
|
|
15
|
+
data () {
|
|
16
|
+
return {
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
computed: {},
|
|
21
|
+
|
|
22
|
+
watch: {},
|
|
23
|
+
|
|
24
|
+
created() {},
|
|
25
|
+
|
|
26
|
+
mounted() {},
|
|
27
|
+
|
|
28
|
+
methods: {}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
</script>
|
|
32
|
+
<style lang="scss" scoped></style>
|