@ctzy-web-client/plugin-component-vue 1.0.0
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/package.json +43 -0
- package/src/advance-select/advance-operation.vue +44 -0
- package/src/advance-select/advance-option.vue +115 -0
- package/src/advance-select/advance-select.vue +343 -0
- package/src/advance-select/events-helpers.js +40 -0
- package/src/advance-select/index.js +13 -0
- package/src/advance-select/use-advance-option.js +58 -0
- package/src/advance-select/use-advance-select.js +142 -0
- package/src/application-slot/application-slot.js +70 -0
- package/src/application-slot/breadcrumb-item.vue +12 -0
- package/src/application-slot/header-tools-item.vue +12 -0
- package/src/application-slot/index.js +17 -0
- package/src/breadcrumb-select/breadcrumb-select.vue +97 -0
- package/src/breadcrumb-select/index.js +6 -0
- package/src/components.js +39 -0
- package/src/contextmenu/contextmenu-item.vue +13 -0
- package/src/contextmenu/contextmenu.vue +56 -0
- package/src/contextmenu/index.js +11 -0
- package/src/contextmenu/use-contextmenu.js +117 -0
- package/src/data-form/data-form-item.vue +49 -0
- package/src/data-form/data-form.vue +212 -0
- package/src/data-form/dynamic-component.js +24 -0
- package/src/data-form/form-components/Blots/AtBlot.js +32 -0
- package/src/data-form/form-components/bwa-date-picker.vue +43 -0
- package/src/data-form/form-components/bwa-date-time-picker.vue +49 -0
- package/src/data-form/form-components/bwa-input-float.vue +41 -0
- package/src/data-form/form-components/bwa-input-integer.vue +58 -0
- package/src/data-form/form-components/bwa-input.vue +32 -0
- package/src/data-form/form-components/bwa-multi-select.vue +27 -0
- package/src/data-form/form-components/bwa-rich-text-tinymce.vue +561 -0
- package/src/data-form/form-components/bwa-rich-text.vue +395 -0
- package/src/data-form/form-components/bwa-select.vue +67 -0
- package/src/data-form/form-components/bwa-textarea.vue +28 -0
- package/src/data-form/form-components/bwa-upload.vue +145 -0
- package/src/data-form/form-components/bwa-user-multi-select.vue +25 -0
- package/src/data-form/form-components/bwa-user-select.vue +81 -0
- package/src/data-form/index.js +35 -0
- package/src/data-table/data-column-view.vue +131 -0
- package/src/data-table/data-table-card.vue +81 -0
- package/src/data-table/data-table-column.vue +52 -0
- package/src/data-table/data-table.vue +426 -0
- package/src/data-table/dynamic-component.js +58 -0
- package/src/data-table/index.js +13 -0
- package/src/data-table/use-datatable-drag.js +156 -0
- package/src/datatable-settings/datatable-settings.vue +323 -0
- package/src/datatable-settings/index.js +6 -0
- package/src/date-range/date-picker.vue +115 -0
- package/src/date-range/date-range.vue +202 -0
- package/src/date-range/index.js +6 -0
- package/src/drag-list/constants.js +1 -0
- package/src/drag-list/drag-item.vue +46 -0
- package/src/drag-list/drag-list.vue +50 -0
- package/src/drag-list/index.js +6 -0
- package/src/drag-list/use-drag-list.js +209 -0
- package/src/dragable/constants.js +3 -0
- package/src/dragable/dragable-item.vue +19 -0
- package/src/dragable/dragable-operation.vue +28 -0
- package/src/dragable/dragable.vue +26 -0
- package/src/dragable/index.js +14 -0
- package/src/dragable/use-dragable.js +227 -0
- package/src/filter-panel/conditions/condition.js +35 -0
- package/src/filter-panel/conditions/date-range-condition.vue +35 -0
- package/src/filter-panel/conditions/department-condition/data.json +29537 -0
- package/src/filter-panel/conditions/department-condition/department-condition.vue +92 -0
- package/src/filter-panel/conditions/department-condition/department-node.vue +52 -0
- package/src/filter-panel/conditions/index.js +22 -0
- package/src/filter-panel/conditions/input-condition.vue +63 -0
- package/src/filter-panel/conditions/multi-user-condition.vue +56 -0
- package/src/filter-panel/conditions/multiple-menu-condition.vue +45 -0
- package/src/filter-panel/conditions/single-menu-condition.vue +58 -0
- package/src/filter-panel/conditions/single-user-condition.vue +56 -0
- package/src/filter-panel/filter-panel-item.vue +46 -0
- package/src/filter-panel/filter-panel.vue +149 -0
- package/src/filter-panel/index.js +17 -0
- package/src/filter-panel/use-filter-panel-item.js +59 -0
- package/src/filter-panel/use-filter-panel.js +203 -0
- package/src/hooks/use-data/index.js +234 -0
- package/src/index.js +48 -0
- package/src/layout/index.js +6 -0
- package/src/layout/layout.vue +74 -0
- package/src/make-installer.js +36 -0
- package/src/math/Rectangle.js +28 -0
- package/src/menu/index.js +6 -0
- package/src/menu/menu-item.vue +41 -0
- package/src/menu/menu.vue +53 -0
- package/src/panel/index.js +6 -0
- package/src/panel/panel.vue +42 -0
- package/src/panel-tabs/index.js +6 -0
- package/src/panel-tabs/panel-tabs.js +92 -0
- package/src/pct-filter-panel/index.js +10 -0
- package/src/pct-filter-panel/pct-compents/index.js +10 -0
- package/src/pct-filter-panel/pct-compents/pct-Input-condition.vue +63 -0
- package/src/pct-filter-panel/pct-compents/pct-date-range-condition.vue +60 -0
- package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition.vue +177 -0
- package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue +142 -0
- package/src/pct-filter-panel/pct-filter-panel-item.vue +46 -0
- package/src/pct-filter-panel/pct-filter-panel.vue +201 -0
- package/src/pct-filter-panel/use-filter-panel-item.js +61 -0
- package/src/pct-filter-panel/use-filter-panel.js +206 -0
- package/src/plugins.js +3 -0
- package/src/progress/index.js +8 -0
- package/src/progress/progress-item.vue +81 -0
- package/src/progress/progress.vue +58 -0
- package/src/progress/use-progress.js +66 -0
- package/src/utils/db.js +8 -0
- package/src/utils.js +263 -0
- package/src/where-filter-panel/index.js +0 -0
- package/src/where-filter-panel/use-where-filter-panel.js +28 -0
- package/src/where-filter-panel/where-filter-panel.vue +9 -0
- package/style/advance-select.scss +316 -0
- package/style/breadcrumb-select.scss +80 -0
- package/style/common/var.scss +240 -0
- package/style/common.scss +48 -0
- package/style/contextmenu.scss +58 -0
- package/style/data-form.scss +35 -0
- package/style/data-table.scss +81 -0
- package/style/datatable-settings.scss +125 -0
- package/style/date-range.scss +136 -0
- package/style/department-condition.scss +39 -0
- package/style/drag-list.scss +68 -0
- package/style/dragable.scss +8 -0
- package/style/filter-panel.scss +199 -0
- package/style/index.scss +22 -0
- package/style/input-condition.scss +30 -0
- package/style/layout.scss +70 -0
- package/style/menu.scss +184 -0
- package/style/mixins/_var.scss +21 -0
- package/style/mixins/config.scss +4 -0
- package/style/mixins/function.scss +62 -0
- package/style/mixins/mixins.scss +88 -0
- package/style/panel-tabs.scss +60 -0
- package/style/panel.scss +110 -0
- package/style/pct-filter-panel.scss +306 -0
- package/style/progress.scss +122 -0
- package/style/rich-text.scss +30 -0
- package/style/theme/theme.scss +161 -0
- package/style/theme/var.scss +34 -0
- package/style/var.scss +21 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="[ns.b(), ns.e('dragging', dragging)]">
|
|
3
|
+
<DragItem
|
|
4
|
+
v-for="(item, i) in data"
|
|
5
|
+
:key="item[idAttr]"
|
|
6
|
+
:data-key="item[idAttr]"
|
|
7
|
+
>
|
|
8
|
+
<slot :item="item"></slot>
|
|
9
|
+
</DragItem>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup>
|
|
14
|
+
import { provide, reactive } from 'vue';
|
|
15
|
+
import { useNamespace } from 'web-base-client-vue';
|
|
16
|
+
import { dragListContextKey } from './constants';
|
|
17
|
+
import DragItem from './drag-item.vue';
|
|
18
|
+
import { useDragList } from './use-drag-list';
|
|
19
|
+
|
|
20
|
+
defineOptions({ name: 'BwaDragList' });
|
|
21
|
+
|
|
22
|
+
const props = defineProps({
|
|
23
|
+
data: {
|
|
24
|
+
type: Array,
|
|
25
|
+
default: () => [],
|
|
26
|
+
},
|
|
27
|
+
idAttr: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'id',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const emit = defineEmits(['sort-change']);
|
|
34
|
+
|
|
35
|
+
const ns = useNamespace('draglist');
|
|
36
|
+
|
|
37
|
+
const { startDrag, nextID, handleItemCreate, handleItemDestroy, dragging } =
|
|
38
|
+
useDragList(props, { emit });
|
|
39
|
+
|
|
40
|
+
provide(
|
|
41
|
+
dragListContextKey,
|
|
42
|
+
reactive({
|
|
43
|
+
dragging,
|
|
44
|
+
startDrag,
|
|
45
|
+
nextID,
|
|
46
|
+
handleItemCreate,
|
|
47
|
+
handleItemDestroy,
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
</script>
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { useElementBounding, useMouse } from '@vueuse/core';
|
|
2
|
+
import { computed, getCurrentInstance, ref, unref } from 'vue';
|
|
3
|
+
|
|
4
|
+
export const useDragList = (props, context) => {
|
|
5
|
+
let uid = 1;
|
|
6
|
+
|
|
7
|
+
const itemMap = new Map();
|
|
8
|
+
|
|
9
|
+
const containerInstance = getCurrentInstance();
|
|
10
|
+
|
|
11
|
+
const mouseInfo = useMouse();
|
|
12
|
+
let bounding = null;
|
|
13
|
+
/** @type {import("vue").Ref<HTMLElement>} */
|
|
14
|
+
let currentInstance = ref(null);
|
|
15
|
+
let startPosition = null;
|
|
16
|
+
let offset = null;
|
|
17
|
+
let timer = null;
|
|
18
|
+
let clonedEl = null;
|
|
19
|
+
const dragging = ref(false);
|
|
20
|
+
|
|
21
|
+
const currentEl = computed(() => {
|
|
22
|
+
const instance = unref(currentInstance);
|
|
23
|
+
|
|
24
|
+
if (!instance) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return instance.$el;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const brotherItemList = computed(() => {
|
|
32
|
+
const children = Array.from(itemMap.values());
|
|
33
|
+
|
|
34
|
+
const _currentInstance = unref(currentInstance);
|
|
35
|
+
return children.filter((item) => item !== _currentInstance);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
let animationFrameKey = -1;
|
|
39
|
+
|
|
40
|
+
const calcTransform = () => {
|
|
41
|
+
const targetX = unref(mouseInfo.x) - startPosition.x - offset.x;
|
|
42
|
+
const targetY = unref(mouseInfo.y) - startPosition.y - offset.y;
|
|
43
|
+
|
|
44
|
+
unref(currentEl).style.transform = `translate(${targetX}px, ${targetY}px)`;
|
|
45
|
+
|
|
46
|
+
const currentBounding = unref(currentEl).getBoundingClientRect();
|
|
47
|
+
|
|
48
|
+
for (const brother of unref(brotherItemList)) {
|
|
49
|
+
const _bounding = brother.$el.getBoundingClientRect();
|
|
50
|
+
|
|
51
|
+
if (
|
|
52
|
+
currentBounding.y + currentBounding.height / 2 <=
|
|
53
|
+
_bounding.y + unref(_bounding.height) / 2
|
|
54
|
+
) {
|
|
55
|
+
brother.$el.style.transform = `translate(0, ${unref(
|
|
56
|
+
bounding.height
|
|
57
|
+
)}px)`;
|
|
58
|
+
} else {
|
|
59
|
+
brother.$el.style.transform = `translate(0, 0px)`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const animationFrameCallback = () => {
|
|
65
|
+
calcTransform();
|
|
66
|
+
|
|
67
|
+
animationFrameKey = requestAnimationFrame(animationFrameCallback);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getSorted = () => {
|
|
71
|
+
const el = unref(currentEl);
|
|
72
|
+
const container = el.parentElement;
|
|
73
|
+
const children = Array.from(container.children);
|
|
74
|
+
|
|
75
|
+
let before = [];
|
|
76
|
+
let after = [];
|
|
77
|
+
|
|
78
|
+
for (const child of children) {
|
|
79
|
+
if (child === el || child === clonedEl) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (
|
|
84
|
+
['translate(0px, 0px)', 'translate(0px)'].includes(
|
|
85
|
+
child.style.transform
|
|
86
|
+
)
|
|
87
|
+
) {
|
|
88
|
+
before.push(child.dataset.key);
|
|
89
|
+
} else {
|
|
90
|
+
after.push(child.dataset.key);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return [...before, el.dataset.key, ...after];
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @param {MouseEvent} event
|
|
99
|
+
*/
|
|
100
|
+
const handleMouseup = (event) => {
|
|
101
|
+
cancelAnimationFrame(animationFrameKey);
|
|
102
|
+
document.removeEventListener('mouseup', handleMouseup);
|
|
103
|
+
|
|
104
|
+
context.emit('sort-change', getSorted());
|
|
105
|
+
|
|
106
|
+
for (const brotherItem of [
|
|
107
|
+
...unref(brotherItemList),
|
|
108
|
+
unref(currentInstance),
|
|
109
|
+
]) {
|
|
110
|
+
brotherItem.$el.setAttribute('draggable-context-id', '');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
|
|
115
|
+
containerInstance.proxy.$el.removeChild(clonedEl);
|
|
116
|
+
|
|
117
|
+
Object.assign(unref(currentEl).style, {
|
|
118
|
+
position: '',
|
|
119
|
+
left: '',
|
|
120
|
+
top: '',
|
|
121
|
+
transform: '',
|
|
122
|
+
width: '',
|
|
123
|
+
height: '',
|
|
124
|
+
cursor: '',
|
|
125
|
+
zIndex: '',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
Object.assign(document.body.style, {
|
|
129
|
+
userSelect: '',
|
|
130
|
+
cursor: '',
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
clonedEl =
|
|
134
|
+
timer =
|
|
135
|
+
startPosition =
|
|
136
|
+
offset =
|
|
137
|
+
currentInstance.value =
|
|
138
|
+
bounding =
|
|
139
|
+
null;
|
|
140
|
+
|
|
141
|
+
for (const brother of unref(brotherItemList)) {
|
|
142
|
+
brother.$el.style.transform = ``;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
dragging.value = false;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const startDrag = (el) => {
|
|
149
|
+
dragging.value = true;
|
|
150
|
+
currentInstance.value = el;
|
|
151
|
+
|
|
152
|
+
bounding = useElementBounding(currentEl);
|
|
153
|
+
startPosition = { x: unref(bounding.x), y: unref(bounding.y) };
|
|
154
|
+
|
|
155
|
+
Object.assign(document.body.style, {
|
|
156
|
+
userSelect: 'none',
|
|
157
|
+
cursor: 'grabbing',
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
offset = {
|
|
161
|
+
x: unref(mouseInfo.x) - unref(bounding.x),
|
|
162
|
+
y: unref(mouseInfo.y) - unref(bounding.y),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
clonedEl = document.createElement('div');
|
|
166
|
+
Object.assign(clonedEl.style, {
|
|
167
|
+
height: `${unref(bounding.height)}px`,
|
|
168
|
+
width: `${unref(bounding.width)}px`,
|
|
169
|
+
});
|
|
170
|
+
containerInstance.proxy.$el.append(clonedEl);
|
|
171
|
+
|
|
172
|
+
Object.assign(unref(currentEl).style, {
|
|
173
|
+
position: 'fixed',
|
|
174
|
+
left: `${unref(startPosition.x)}px`,
|
|
175
|
+
top: `${unref(startPosition.y)}px`,
|
|
176
|
+
width: `${unref(bounding.width)}px`,
|
|
177
|
+
height: `${unref(bounding.height)}px`,
|
|
178
|
+
transform: 'translate(0px, 0px)',
|
|
179
|
+
cursor: 'grabbing',
|
|
180
|
+
zIndex: '5000',
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
calcTransform();
|
|
184
|
+
|
|
185
|
+
timer = setTimeout(() => {
|
|
186
|
+
unref(currentInstance).$el.setAttribute('draggable-context-id', '1');
|
|
187
|
+
for (const brotherItem of unref(brotherItemList)) {
|
|
188
|
+
brotherItem.$el.setAttribute('draggable-context-id', '0');
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
animationFrameKey = requestAnimationFrame(animationFrameCallback);
|
|
193
|
+
document.addEventListener('mouseup', handleMouseup);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const nextID = () => {
|
|
197
|
+
return uid++;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const handleItemCreate = (id, instance) => {
|
|
201
|
+
itemMap.set(id, instance);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const handleItemDestroy = (id, instance) => {
|
|
205
|
+
itemMap.delete(id);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
return { startDrag, nextID, handleItemCreate, handleItemDestroy, dragging };
|
|
209
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="ns.b()">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
import { provide } from 'vue';
|
|
9
|
+
import { useNamespace } from 'web-base-client-vue';
|
|
10
|
+
import { dragableItemContextKey } from './constants';
|
|
11
|
+
|
|
12
|
+
defineOptions({
|
|
13
|
+
name: 'BwaDragableItem',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const ns = useNamespace('dragable-item');
|
|
17
|
+
|
|
18
|
+
provide(dragableItemContextKey, {});
|
|
19
|
+
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span
|
|
3
|
+
:class="ns.b()"
|
|
4
|
+
@mousedown="handleMousedown"
|
|
5
|
+
:dragable-operation="dragableOperation"
|
|
6
|
+
>
|
|
7
|
+
<slot></slot>
|
|
8
|
+
</span>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup>
|
|
12
|
+
import { inject, ref } from 'vue';
|
|
13
|
+
import { useNamespace } from 'web-base-client-vue';
|
|
14
|
+
import { dragableContextKey, dragableItemContextKey } from './constants';
|
|
15
|
+
|
|
16
|
+
defineOptions({
|
|
17
|
+
name: 'BwaDragableOperation',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const ns = useNamespace('dragable-operation');
|
|
21
|
+
|
|
22
|
+
const dragableContext = inject(dragableContextKey);
|
|
23
|
+
const dragableItemContext = inject(dragableItemContextKey);
|
|
24
|
+
|
|
25
|
+
const dragableOperation = ref(
|
|
26
|
+
new Boolean(dragableContext && dragableItemContext).valueOf()
|
|
27
|
+
);
|
|
28
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="ns.b()" ref="el">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
import { provide, ref } from 'vue';
|
|
9
|
+
import { useNamespace } from 'web-base-client-vue';
|
|
10
|
+
import { dragableContextKey } from './constants';
|
|
11
|
+
import { useDragable } from './use-dragable';
|
|
12
|
+
|
|
13
|
+
defineOptions({
|
|
14
|
+
name: 'BwaDragable',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const ns = useNamespace('dragable');
|
|
18
|
+
|
|
19
|
+
const emit = defineEmits(['move']);
|
|
20
|
+
|
|
21
|
+
const el = ref(null);
|
|
22
|
+
|
|
23
|
+
useDragable(el, ns.b('item'), ns.b('operation'), { emit });
|
|
24
|
+
|
|
25
|
+
provide(dragableContextKey, {});
|
|
26
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { withInstall } from 'element-plus/es/utils/vue/install';
|
|
2
|
+
import Dragable from './dragable.vue';
|
|
3
|
+
import DragableItem from './dragable-item.vue';
|
|
4
|
+
import DragableOperation from './dragable-operation.vue';
|
|
5
|
+
|
|
6
|
+
export const BwaDragable = withInstall(Dragable, {
|
|
7
|
+
DragableItem,
|
|
8
|
+
DragableOperation,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const BwaDragableItem = withInstall(DragableItem, { DragableOperation });
|
|
12
|
+
export const BwaDragableOperation = withInstall(DragableOperation);
|
|
13
|
+
|
|
14
|
+
export default BwaDragable;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { filter, fromEvent, map, switchMap, take, takeUntil } from 'rxjs';
|
|
2
|
+
import { onMounted, onUnmounted, unref } from 'vue';
|
|
3
|
+
import { Rectangle } from '../math/Rectangle';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {HTMLElement} dragableEl
|
|
7
|
+
* @param {string} itemClass
|
|
8
|
+
* @param {string} operationClass
|
|
9
|
+
*/
|
|
10
|
+
export const useDragable = (dragableEl, itemClass, operationClass, context) => {
|
|
11
|
+
/** @type {import("rxjs").Subscription} */
|
|
12
|
+
let dragSubscription = null;
|
|
13
|
+
|
|
14
|
+
onMounted(() => {
|
|
15
|
+
/** @type {import("rxjs").Observable<MouseEvent>} */
|
|
16
|
+
const mousedownObservable = fromEvent(unref(dragableEl), 'mousedown').pipe(
|
|
17
|
+
filter((event) => {
|
|
18
|
+
const children = Array.from(unref(dragableEl).children).filter((el) =>
|
|
19
|
+
el.classList.contains(itemClass)
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const operations = children
|
|
23
|
+
.map((el) => el.querySelector(`.${operationClass}`))
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.filter((operation) => operation.classList.contains(operationClass));
|
|
26
|
+
|
|
27
|
+
return !!operations.find((operation) =>
|
|
28
|
+
operation.contains(event.target)
|
|
29
|
+
);
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
/** @type {import("rxjs").Observable<MouseEvent>} */
|
|
33
|
+
const mousemoveObservable = fromEvent(document, 'mousemove');
|
|
34
|
+
/** @type {import("rxjs").Observable<MouseEvent>} */
|
|
35
|
+
const mouseupObservable = fromEvent(document, 'mouseup');
|
|
36
|
+
|
|
37
|
+
/** @type {import("rxjs").Observable<{ startEvent: MouseEvent, moveEvent: MouseEvent }>} */
|
|
38
|
+
const dragObservable = mousedownObservable.pipe(
|
|
39
|
+
switchMap((startEvent) =>
|
|
40
|
+
mousemoveObservable.pipe(
|
|
41
|
+
takeUntil(mouseupObservable),
|
|
42
|
+
map((event) => ({
|
|
43
|
+
startEvent,
|
|
44
|
+
moveEvent: event,
|
|
45
|
+
}))
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
let animationFrameKey = -1;
|
|
51
|
+
/** @type {Array<{ rectangle: Rectangle, el: HTMLElement }>} */
|
|
52
|
+
let otherInfos = [];
|
|
53
|
+
/** @type {HTMLElement} */
|
|
54
|
+
let currentEl = null;
|
|
55
|
+
/** @type {Rectangle} */
|
|
56
|
+
let currentRectangle = null;
|
|
57
|
+
/** @type {HTMLElement} */
|
|
58
|
+
let tempEl = null;
|
|
59
|
+
/** @type {{ x: number, y: number }} */
|
|
60
|
+
let offset = null;
|
|
61
|
+
/** @type {number} */
|
|
62
|
+
let sourceIndex = -1;
|
|
63
|
+
|
|
64
|
+
const animationFrameCallback = () => {
|
|
65
|
+
for (let otherInfo of otherInfos) {
|
|
66
|
+
const translateY =
|
|
67
|
+
otherInfo.rectangle.cy < currentRectangle.cy
|
|
68
|
+
? 0
|
|
69
|
+
: currentRectangle.height;
|
|
70
|
+
|
|
71
|
+
otherInfo.el.style.transform = `translate(0px, ${translateY}px)`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
otherInfos = otherInfos.map((info) => {
|
|
75
|
+
const bound = info.el.getBoundingClientRect();
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
el: info.el,
|
|
79
|
+
rectangle: new Rectangle(bound.x, bound.y, bound.width, bound.height),
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
animationFrameKey = requestAnimationFrame(animationFrameCallback);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
dragSubscription = dragObservable.subscribe(({ moveEvent }) => {
|
|
87
|
+
if (!currentEl) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const bound = currentEl.getBoundingClientRect();
|
|
92
|
+
currentRectangle = new Rectangle(
|
|
93
|
+
bound.x,
|
|
94
|
+
bound.y,
|
|
95
|
+
bound.width,
|
|
96
|
+
bound.height
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
Object.assign(currentEl.style, {
|
|
100
|
+
position: 'fixed',
|
|
101
|
+
transform: `translate(${moveEvent.clientX - offset.x}px, ${
|
|
102
|
+
moveEvent.clientY - offset.y
|
|
103
|
+
}px)`,
|
|
104
|
+
zIndex: '5000',
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
dragSubscription.add(
|
|
109
|
+
mousedownObservable.subscribe((event) => {
|
|
110
|
+
/** @type {HTMLElement[]} */
|
|
111
|
+
let children = Array.from(unref(dragableEl).children).filter((el) =>
|
|
112
|
+
el.classList.contains(itemClass)
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
currentEl = children.find((el) => el.contains(event.target)) ?? null;
|
|
116
|
+
|
|
117
|
+
if (!currentEl) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
sourceIndex = children.findIndex((el) => el.contains(event.target));
|
|
122
|
+
|
|
123
|
+
if (sourceIndex === -1) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const bound = currentEl.getBoundingClientRect();
|
|
128
|
+
currentRectangle = new Rectangle(
|
|
129
|
+
bound.x,
|
|
130
|
+
bound.y,
|
|
131
|
+
bound.width,
|
|
132
|
+
bound.height
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
offset = { x: event.x - bound.x, y: event.y - bound.y };
|
|
136
|
+
|
|
137
|
+
tempEl = document.createElement('div');
|
|
138
|
+
Object.assign(tempEl.style, {
|
|
139
|
+
height: `${currentRectangle.height}px`,
|
|
140
|
+
width: `${currentRectangle.width}px`,
|
|
141
|
+
});
|
|
142
|
+
unref(dragableEl).appendChild(tempEl);
|
|
143
|
+
|
|
144
|
+
Object.assign(currentEl.style, {
|
|
145
|
+
position: 'fixed',
|
|
146
|
+
left: '0',
|
|
147
|
+
top: '0',
|
|
148
|
+
transform: `translate(${event.clientX - offset.x}px, ${
|
|
149
|
+
event.clientY - offset.y
|
|
150
|
+
}px)`,
|
|
151
|
+
zIndex: '5000',
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const otherItems = children.filter(
|
|
155
|
+
(item) => !item.contains(event.target)
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
otherInfos = otherItems.map((el) => {
|
|
159
|
+
const bound = el.getBoundingClientRect();
|
|
160
|
+
|
|
161
|
+
const rectangle = new Rectangle(
|
|
162
|
+
bound.x,
|
|
163
|
+
bound.y,
|
|
164
|
+
bound.width,
|
|
165
|
+
bound.height
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
return { el, rectangle };
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
animationFrameCallback();
|
|
172
|
+
|
|
173
|
+
for (let otherInfo of otherInfos) {
|
|
174
|
+
otherInfo.el.setAttribute('dragable-relative', 'true');
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
dragSubscription.add(
|
|
180
|
+
mousedownObservable
|
|
181
|
+
.pipe(switchMap(() => mouseupObservable.pipe(take(1))))
|
|
182
|
+
.subscribe(() => {
|
|
183
|
+
if (!currentEl) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
tempEl.remove();
|
|
188
|
+
|
|
189
|
+
for (let otherInfo of otherInfos) {
|
|
190
|
+
otherInfo.el.style.transform = '';
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
Object.assign(currentEl.style, {
|
|
194
|
+
position: '',
|
|
195
|
+
left: '',
|
|
196
|
+
top: '',
|
|
197
|
+
transform: '',
|
|
198
|
+
zIndex: '',
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const tartgetIndex = otherInfos.filter(
|
|
202
|
+
(info) => info.rectangle.cy < currentRectangle.cy
|
|
203
|
+
).length;
|
|
204
|
+
|
|
205
|
+
if (sourceIndex !== tartgetIndex) {
|
|
206
|
+
context.emit('move', sourceIndex, tartgetIndex);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
for (let otherInfo of otherInfos) {
|
|
210
|
+
otherInfo.el.removeAttribute('dragable-relative');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
otherInfos = [];
|
|
214
|
+
currentEl = tempEl = offset = currentRectangle = null;
|
|
215
|
+
sourceIndex = -1;
|
|
216
|
+
|
|
217
|
+
if (animationFrameKey !== -1) {
|
|
218
|
+
cancelAnimationFrame(animationFrameKey);
|
|
219
|
+
animationFrameKey = -1;
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
onUnmounted(() => {
|
|
225
|
+
dragSubscription?.unsubscribe();
|
|
226
|
+
});
|
|
227
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { h, useSlots, unref } from 'vue';
|
|
2
|
+
import { useDynamicComponent } from '../../utils.js';
|
|
3
|
+
export default {
|
|
4
|
+
name: 'BwaCondition',
|
|
5
|
+
props: {
|
|
6
|
+
modelValue: null,
|
|
7
|
+
column: Object,
|
|
8
|
+
record: Object,
|
|
9
|
+
},
|
|
10
|
+
emits: ['on-change', 'update:modelValue'],
|
|
11
|
+
setup(props, context) {
|
|
12
|
+
//组件信息
|
|
13
|
+
const { component, params } = useDynamicComponent(
|
|
14
|
+
props,
|
|
15
|
+
context,
|
|
16
|
+
'BwaMultipleMenuCondition',
|
|
17
|
+
'fullAttrName'
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const slots = useSlots();
|
|
21
|
+
|
|
22
|
+
return () =>
|
|
23
|
+
h(
|
|
24
|
+
unref(component),
|
|
25
|
+
{
|
|
26
|
+
...unref(params),
|
|
27
|
+
modelValue: props.modelValue,
|
|
28
|
+
'onUpdate:modelValue': (v) => {
|
|
29
|
+
context.emit('update:modelValue', v);
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{ ...slots }
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<BwaDateRange v-model="value" :multiple="true" :value-format="valueFormat">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</BwaDateRange>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
import { computed } from 'vue';
|
|
9
|
+
import { BwaDateRange } from '../../date-range';
|
|
10
|
+
|
|
11
|
+
defineOptions({
|
|
12
|
+
name: 'BwaDateRangeCondition',
|
|
13
|
+
__conditionTitle__: '日期选择',
|
|
14
|
+
__conditionDefault__: () => ({ start: '', end: '' }),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
modelValue: {
|
|
19
|
+
type: null,
|
|
20
|
+
},
|
|
21
|
+
valueFormat: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: 'YYYY-MM-DD',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits(['update:modelValue']);
|
|
28
|
+
|
|
29
|
+
const value = computed({
|
|
30
|
+
get: () => props.modelValue,
|
|
31
|
+
set: (v) => {
|
|
32
|
+
emit('update:modelValue', v);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
</script>
|