agilebuilder-ui 1.1.13-tmp5 → 1.1.13-tmp6

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.
@@ -1,197 +1,197 @@
1
- <template>
2
- <el-scrollbar v-bind="mergedAttrs" ref="scrollbarRef">
3
- <slot />
4
- </el-scrollbar>
5
- </template>
6
-
7
- <script setup>
8
- import { ElScrollbar } from 'element-plus';
9
- // import { useStore } from 'vuex';
10
- import store from '../../store';
11
- import { toRefs, reactive, mergeProps, ref, onMounted, watch, useAttrs, computed, defineEmits, useSlots } from 'vue';
12
-
13
- const slots = useSlots();
14
-
15
- // const store = useStore();
16
-
17
- store?.dispatch?.('startListeningToResize');
18
-
19
- const scrollbarRef = ref(null);
20
-
21
- const scrollToEmitValue = ref(undefined)
22
-
23
- const emits = defineEmits(['scrollToTop', 'scrollToBottom']);
24
-
25
- const resizeProps = computed(() => ({
26
- // 宽度
27
- windowWidth: store.getters.windowWidth,
28
- // 高度
29
- windowHeight: store.getters.windowHeight,
30
- // 是否移动端
31
- isMobileResize: store.getters.isMobileResize,
32
- }));
33
-
34
- // 定义初始化参数
35
- const defaultAttrs = reactive({
36
- always: false, // 滚动条是否总是显示
37
- // wrapStyle: 'height: 100%', // 滚动区域的样式
38
- });
39
-
40
- const props = defineProps({
41
- // 是否开启滚动距离阴影
42
- showScrollShadow: {
43
- type: Boolean,
44
- default: true
45
- },
46
- triggerDistance: {
47
- type: Number,
48
- default: 0
49
- },
50
- // 动态计算 max-height
51
- setMaxHeight: {
52
- type: [Function, undefined],
53
- default: () => undefined
54
- },
55
- // 动态计算 height
56
- setHeight: {
57
- type: [Function, undefined],
58
- default: () => undefined
59
- }
60
- });
61
-
62
- const { attrs } = useAttrs();
63
-
64
- // 统一写入
65
- const setHeightFun = (fun) => {
66
- try {
67
- return fun?.(resizeProps.value)
68
- } catch (error) {
69
- console.error(error)
70
- }
71
- return
72
- }
73
-
74
- // 合并初始化参数和传入的属性
75
- const mergedAttrs = computed(() => {
76
- const attrsData = mergeProps(defaultAttrs, attrs)
77
- return {
78
- ...({
79
- // 绑定 setMaxHeight 事件 返回 最大高度
80
- ...(props.setMaxHeight ? { maxHeight: setHeightFun(props.setMaxHeight) } : {}),
81
- // 绑定 setHeight 事件 返回 高度
82
- ...(props.setHeight ? { height: setHeightFun(props.setHeight) } : {}),
83
- }),
84
- ...attrsData
85
- }
86
- });
87
-
88
- // 滚动距离回调事件
89
- const scrollToEmits = (scrollElement) => {
90
- if (!scrollElement) return
91
- const isAtTop = scrollElement.scrollTop <= props.triggerDistance;
92
- const isAtBottom = scrollElement.scrollTop + scrollElement.clientHeight >= (scrollElement.scrollHeight - props.triggerDistance);
93
- if (isAtBottom) {
94
- // scrollToEmitValue 校验确保只执行一次
95
- // 底部事件
96
- !['at-bottom'].includes(scrollToEmitValue.value) && emits('scrollToBottom');
97
- scrollToEmitValue.value = 'at-bottom'
98
- } else if (isAtTop) {
99
- // 顶部事件
100
- !['at-top'].includes(scrollToEmitValue.value) && emits('scrollToTop');
101
- scrollToEmitValue.value = 'at-top'
102
- } else {
103
- scrollToEmitValue.value = undefined
104
- }
105
- }
106
-
107
- // 滚动阴影事件
108
- const handleScroll = () => {
109
- const scrollElement = scrollbarRef.value?.$el.querySelector('.el-scrollbar__wrap');
110
- if (scrollElement) {
111
- const isAtTop = scrollElement.scrollTop === 0;
112
- const isAtBottom = scrollElement.scrollTop + scrollElement.clientHeight === scrollElement.scrollHeight;
113
- if (props.showScrollShadow) {
114
- if (!isAtTop) {
115
- scrollbarRef.value.$el.classList.add('scroll-top-shadow');
116
- } else {
117
- scrollbarRef.value.$el.classList.remove('scroll-top-shadow');
118
- }
119
- if (!isAtBottom) {
120
- scrollbarRef.value.$el.classList.add('scroll-bottom-shadow');
121
- } else {
122
- scrollbarRef.value.$el.classList.remove('scroll-bottom-shadow');
123
- }
124
- } else {
125
- scrollbarRef.value.$el.classList.remove('scroll-top-shadow', 'scroll-bottom-shadow');
126
- }
127
- scrollToEmits(scrollElement);
128
- }
129
- };
130
-
131
- onMounted(() => {
132
- const scrollElement = scrollbarRef.value.$el.querySelector('.el-scrollbar__wrap');
133
- if (scrollElement) {
134
- scrollElement.addEventListener('scroll', handleScroll);
135
- handleScroll();
136
- scrollToEmits(scrollElement);
137
- }
138
- });
139
-
140
- watch(() => props.showScrollShadow, () => {
141
- handleScroll();
142
- });
143
-
144
- watch(() => mergedAttrs?.maxHeight, () => {
145
- setTimeout(handleScroll, 500);
146
- });
147
-
148
- watch(() => mergedAttrs?.height, () => {
149
- setTimeout(handleScroll, 500);
150
- });
151
- watch(
152
- () => slots.default?.(),
153
- (newValue, oldValue) => {
154
- if (newValue !== oldValue) {
155
- setTimeout(handleScroll, 500);
156
- }
157
- },
158
- { deep: true }
159
- );
160
- </script>
161
-
162
- <style lang="scss" scoped>
163
- .el-scrollbar ::v-deep {
164
- position: relative;
165
-
166
- &.scroll-top-shadow {
167
- &::before {
168
- content: ' ';
169
- position: absolute;
170
- top: 0;
171
- left: 0;
172
- right: 0;
173
- height: 8px;
174
- box-shadow: inset 0 8px 8px -8px rgba(0, 0, 0, 0.2);
175
- z-index: 2;
176
- }
177
- }
178
-
179
- &.scroll-bottom-shadow {
180
- &::after {
181
- content: ' ';
182
- position: absolute;
183
- bottom: 0;
184
- left: 0;
185
- right: 0;
186
- height: 8px;
187
- box-shadow: inset 0 -8px 8px -8px rgba(0, 0, 0, 0.2);
188
- z-index: 2;
189
- }
190
- }
191
-
192
- &>.el-scrollbar__wrap {
193
- position: relative;
194
- z-index: 1;
195
- }
196
- }
1
+ <template>
2
+ <el-scrollbar v-bind="mergedAttrs" ref="scrollbarRef">
3
+ <slot />
4
+ </el-scrollbar>
5
+ </template>
6
+
7
+ <script setup>
8
+ import { ElScrollbar } from 'element-plus';
9
+ // import { useStore } from 'vuex';
10
+ import store from '../../store';
11
+ import { toRefs, reactive, mergeProps, ref, onMounted, watch, useAttrs, computed, defineEmits, useSlots } from 'vue';
12
+
13
+ const slots = useSlots();
14
+
15
+ // const store = useStore();
16
+
17
+ store?.dispatch?.('startListeningToResize');
18
+
19
+ const scrollbarRef = ref(null);
20
+
21
+ const scrollToEmitValue = ref(undefined)
22
+
23
+ const emits = defineEmits(['scrollToTop', 'scrollToBottom']);
24
+
25
+ const resizeProps = computed(() => ({
26
+ // 宽度
27
+ windowWidth: store.getters.windowWidth,
28
+ // 高度
29
+ windowHeight: store.getters.windowHeight,
30
+ // 是否移动端
31
+ isMobileResize: store.getters.isMobileResize,
32
+ }));
33
+
34
+ // 定义初始化参数
35
+ const defaultAttrs = reactive({
36
+ always: false, // 滚动条是否总是显示
37
+ // wrapStyle: 'height: 100%', // 滚动区域的样式
38
+ });
39
+
40
+ const props = defineProps({
41
+ // 是否开启滚动距离阴影
42
+ showScrollShadow: {
43
+ type: Boolean,
44
+ default: true
45
+ },
46
+ triggerDistance: {
47
+ type: Number,
48
+ default: 0
49
+ },
50
+ // 动态计算 max-height
51
+ setMaxHeight: {
52
+ type: [Function, undefined],
53
+ default: () => undefined
54
+ },
55
+ // 动态计算 height
56
+ setHeight: {
57
+ type: [Function, undefined],
58
+ default: () => undefined
59
+ }
60
+ });
61
+
62
+ const { attrs } = useAttrs();
63
+
64
+ // 统一写入
65
+ const setHeightFun = (fun) => {
66
+ try {
67
+ return fun?.(resizeProps.value)
68
+ } catch (error) {
69
+ console.error(error)
70
+ }
71
+ return
72
+ }
73
+
74
+ // 合并初始化参数和传入的属性
75
+ const mergedAttrs = computed(() => {
76
+ const attrsData = mergeProps(defaultAttrs, attrs)
77
+ return {
78
+ ...({
79
+ // 绑定 setMaxHeight 事件 返回 最大高度
80
+ ...(props.setMaxHeight ? { maxHeight: setHeightFun(props.setMaxHeight) } : {}),
81
+ // 绑定 setHeight 事件 返回 高度
82
+ ...(props.setHeight ? { height: setHeightFun(props.setHeight) } : {}),
83
+ }),
84
+ ...attrsData
85
+ }
86
+ });
87
+
88
+ // 滚动距离回调事件
89
+ const scrollToEmits = (scrollElement) => {
90
+ if (!scrollElement) return
91
+ const isAtTop = scrollElement.scrollTop <= props.triggerDistance;
92
+ const isAtBottom = scrollElement.scrollTop + scrollElement.clientHeight >= (scrollElement.scrollHeight - props.triggerDistance);
93
+ if (isAtBottom) {
94
+ // scrollToEmitValue 校验确保只执行一次
95
+ // 底部事件
96
+ !['at-bottom'].includes(scrollToEmitValue.value) && emits('scrollToBottom');
97
+ scrollToEmitValue.value = 'at-bottom'
98
+ } else if (isAtTop) {
99
+ // 顶部事件
100
+ !['at-top'].includes(scrollToEmitValue.value) && emits('scrollToTop');
101
+ scrollToEmitValue.value = 'at-top'
102
+ } else {
103
+ scrollToEmitValue.value = undefined
104
+ }
105
+ }
106
+
107
+ // 滚动阴影事件
108
+ const handleScroll = () => {
109
+ const scrollElement = scrollbarRef.value?.$el.querySelector('.el-scrollbar__wrap');
110
+ if (scrollElement) {
111
+ const isAtTop = scrollElement.scrollTop === 0;
112
+ const isAtBottom = scrollElement.scrollTop + scrollElement.clientHeight === scrollElement.scrollHeight;
113
+ if (props.showScrollShadow) {
114
+ if (!isAtTop) {
115
+ scrollbarRef.value.$el.classList.add('scroll-top-shadow');
116
+ } else {
117
+ scrollbarRef.value.$el.classList.remove('scroll-top-shadow');
118
+ }
119
+ if (!isAtBottom) {
120
+ scrollbarRef.value.$el.classList.add('scroll-bottom-shadow');
121
+ } else {
122
+ scrollbarRef.value.$el.classList.remove('scroll-bottom-shadow');
123
+ }
124
+ } else {
125
+ scrollbarRef.value.$el.classList.remove('scroll-top-shadow', 'scroll-bottom-shadow');
126
+ }
127
+ scrollToEmits(scrollElement);
128
+ }
129
+ };
130
+
131
+ onMounted(() => {
132
+ const scrollElement = scrollbarRef.value.$el.querySelector('.el-scrollbar__wrap');
133
+ if (scrollElement) {
134
+ scrollElement.addEventListener('scroll', handleScroll);
135
+ handleScroll();
136
+ scrollToEmits(scrollElement);
137
+ }
138
+ });
139
+
140
+ watch(() => props.showScrollShadow, () => {
141
+ handleScroll();
142
+ });
143
+
144
+ watch(() => mergedAttrs?.maxHeight, () => {
145
+ setTimeout(handleScroll, 500);
146
+ });
147
+
148
+ watch(() => mergedAttrs?.height, () => {
149
+ setTimeout(handleScroll, 500);
150
+ });
151
+ watch(
152
+ () => slots.default?.(),
153
+ (newValue, oldValue) => {
154
+ if (newValue !== oldValue) {
155
+ setTimeout(handleScroll, 500);
156
+ }
157
+ },
158
+ { deep: true }
159
+ );
160
+ </script>
161
+
162
+ <style lang="scss" scoped>
163
+ .el-scrollbar ::v-deep {
164
+ position: relative;
165
+
166
+ &.scroll-top-shadow {
167
+ &::before {
168
+ content: ' ';
169
+ position: absolute;
170
+ top: 0;
171
+ left: 0;
172
+ right: 0;
173
+ height: 8px;
174
+ box-shadow: inset 0 8px 8px -8px rgba(0, 0, 0, 0.2);
175
+ z-index: 2;
176
+ }
177
+ }
178
+
179
+ &.scroll-bottom-shadow {
180
+ &::after {
181
+ content: ' ';
182
+ position: absolute;
183
+ bottom: 0;
184
+ left: 0;
185
+ right: 0;
186
+ height: 8px;
187
+ box-shadow: inset 0 -8px 8px -8px rgba(0, 0, 0, 0.2);
188
+ z-index: 2;
189
+ }
190
+ }
191
+
192
+ &>.el-scrollbar__wrap {
193
+ position: relative;
194
+ z-index: 1;
195
+ }
196
+ }
197
197
  </style>
@@ -1,49 +1,49 @@
1
- export default {
2
- data() {
3
- const element = document.querySelector('.amb-design-board');
4
- let designObserver
5
- if (element) {
6
- this.designObserver = new ResizeObserver(entries => {
7
- for (const entry of entries) {
8
- console.log(entry);
9
- this.handleDesignResize(entry?.['target'])
10
- }
11
- });
12
- designObserver.observe(element);
13
- }
14
- return {
15
- windowWidth: designObserver ? element.clientWidth : window.innerWidth,
16
- windowHeight: designObserver ? element.clientHeight : window.innerHeight,
17
- designObserver
18
- };
19
- },
20
- computed: {
21
- isMobileResize() {
22
- return (this.windowWidth ?? 0) <= 768
23
- }
24
- },
25
- mounted() {
26
- if (!this.designObserver) {
27
- window.addEventListener('resize', this.handleWindowResize);
28
- }
29
- },
30
- beforeDestroy() {
31
- if (this.designObserver) {
32
- this.designObserver.disconnect();
33
- } else {
34
- window.removeEventListener('resize', this.handleWindowResize);
35
- }
36
- },
37
- methods: {
38
- handleWindowResize() {
39
- this.windowWidth = window.innerWidth;
40
- this.windowHeight = window.innerHeight;
41
- },
42
- handleDesignResize(element) {
43
- if (element) {
44
- this.windowWidth = element.clientWidth;
45
- this.windowHeight = element.clientHeight;
46
- }
47
- }
48
- }
1
+ export default {
2
+ data() {
3
+ const element = document.querySelector('.amb-design-board');
4
+ let designObserver
5
+ if (element) {
6
+ this.designObserver = new ResizeObserver(entries => {
7
+ for (const entry of entries) {
8
+ console.log(entry);
9
+ this.handleDesignResize(entry?.['target'])
10
+ }
11
+ });
12
+ designObserver.observe(element);
13
+ }
14
+ return {
15
+ windowWidth: designObserver ? element.clientWidth : window.innerWidth,
16
+ windowHeight: designObserver ? element.clientHeight : window.innerHeight,
17
+ designObserver
18
+ };
19
+ },
20
+ computed: {
21
+ isMobileResize() {
22
+ return (this.windowWidth ?? 0) <= 768
23
+ }
24
+ },
25
+ mounted() {
26
+ if (!this.designObserver) {
27
+ window.addEventListener('resize', this.handleWindowResize);
28
+ }
29
+ },
30
+ beforeDestroy() {
31
+ if (this.designObserver) {
32
+ this.designObserver.disconnect();
33
+ } else {
34
+ window.removeEventListener('resize', this.handleWindowResize);
35
+ }
36
+ },
37
+ methods: {
38
+ handleWindowResize() {
39
+ this.windowWidth = window.innerWidth;
40
+ this.windowHeight = window.innerHeight;
41
+ },
42
+ handleDesignResize(element) {
43
+ if (element) {
44
+ this.windowWidth = element.clientWidth;
45
+ this.windowHeight = element.clientHeight;
46
+ }
47
+ }
48
+ }
49
49
  };
@@ -93,13 +93,22 @@
93
93
  .yx-card-main {
94
94
  &.is-checked {
95
95
  border-color: #409eff;
96
+ background-color: #ecf5ff;
96
97
  }
97
98
  &[header-padding] {
98
99
  & > .el-card__header {
100
+ display: flex;
101
+ flex-direction: column;
102
+ justify-content: center;
103
+ align-items: stretch;
99
104
  padding: 0 !important;
100
105
  overflow: hidden;
101
106
  min-height: 50px;
102
107
 
108
+ @media (max-width: 450px) {
109
+ min-height: 40px;
110
+ }
111
+
103
112
  & > .yx-flex-wrap {
104
113
  gap: 10px;
105
114
  height: 100%;
@@ -113,6 +122,7 @@
113
122
  }
114
123
  }
115
124
  .el-card__header {
125
+
116
126
  & > .yx-flex-wrap {
117
127
  flex: 1 1 auto;
118
128
 
@@ -131,6 +141,7 @@
131
141
  }
132
142
  .yx-card-body {
133
143
  padding: var(--el-card-padding);
144
+ background-color: var(--el-fill-color-blank);
134
145
  }
135
146
  @media (max-width: 450px) {
136
147
  &[header-padding] {
package/src/utils/guid.js CHANGED
@@ -1,13 +1,13 @@
1
- /**
2
- * 获取4位随机数
3
- */
4
- export function getS4(a, b, c, d) {
5
- return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
6
- }
7
-
8
- /**
9
- * 生成GuId
10
- */
11
- export function getGuId(data = `{s}{s}-{s}-{s}-{s}-{s}{s}{s}`) {
12
- return data.replace(/{(y|m|d|h|i|s|a)+}/g, getS4)
13
- }
1
+ /**
2
+ * 获取4位随机数
3
+ */
4
+ export function getS4(a, b, c, d) {
5
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
6
+ }
7
+
8
+ /**
9
+ * 生成GuId
10
+ */
11
+ export function getGuId(data = `{s}{s}-{s}-{s}-{s}-{s}{s}{s}`) {
12
+ return data.replace(/{(y|m|d|h|i|s|a)+}/g, getS4)
13
+ }