@meethive/components 0.0.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/es/AutoComplete/AutoComplete.js +84 -0
- package/es/AutoComplete/index.js +7 -0
- package/es/BadgeStatus/Badge.js +51 -0
- package/es/BadgeStatus/color.js +14 -0
- package/es/BadgeStatus/index.js +8 -0
- package/es/CardSelect/CardSelect.js +141 -0
- package/es/CardSelect/index.js +7 -0
- package/es/CardSelect/style/index.js +29 -0
- package/es/CheckButton/CheckButton.js +122 -0
- package/es/CheckButton/index.js +7 -0
- package/es/CheckButton/style/index.js +44 -0
- package/es/ConfigProvider/ConfigProvider.js +73 -0
- package/es/ConfigProvider/context.js +26 -0
- package/es/ConfigProvider/index.js +9 -0
- package/es/DragModal/DragModal.js +212 -0
- package/es/DragModal/index.js +7 -0
- package/es/DragModal/style/index.js +86 -0
- package/es/EditTable/Body.js +189 -0
- package/es/EditTable/CellRender.js +12 -0
- package/es/EditTable/EditTable.js +434 -0
- package/es/EditTable/FormItem.js +169 -0
- package/es/EditTable/Group.js +204 -0
- package/es/EditTable/Header.js +63 -0
- package/es/EditTable/HeaderRender.js +12 -0
- package/es/EditTable/components/ContextMenu/Menu.js +86 -0
- package/es/EditTable/components/ContextMenu/index.js +96 -0
- package/es/EditTable/components/Search/Search.js +163 -0
- package/es/EditTable/components/Search/Sort.js +119 -0
- package/es/EditTable/components/Search/index.js +2 -0
- package/es/EditTable/consts.js +13 -0
- package/es/EditTable/context.js +88 -0
- package/es/EditTable/hooks/index.js +19 -0
- package/es/EditTable/hooks/useGroup.js +48 -0
- package/es/EditTable/hooks/useResizeObserver.js +27 -0
- package/es/EditTable/hooks/useValidate.js +112 -0
- package/es/EditTable/index.js +25 -0
- package/es/EditTable/props.js +60 -0
- package/es/EditTable/style/body.js +63 -0
- package/es/EditTable/style/form.js +33 -0
- package/es/EditTable/style/group.js +33 -0
- package/es/EditTable/style/header.js +72 -0
- package/es/EditTable/style/index.js +52 -0
- package/es/EditTable/style/menu.js +27 -0
- package/es/EditTable/style/table.js +46 -0
- package/es/EditTable/utils.js +110 -0
- package/es/Ellipsis/Ellipsis.js +148 -0
- package/es/Ellipsis/index.js +7 -0
- package/es/Ellipsis/style/index.js +26 -0
- package/es/Empty/Empty.js +63 -0
- package/es/Empty/image.js +3 -0
- package/es/Empty/index.js +7 -0
- package/es/FullPage/FullPage.js +19 -0
- package/es/FullPage/index.js +7 -0
- package/es/Icon/Icon.js +49 -0
- package/es/Icon/index.js +7 -0
- package/es/LocaleProvider/LocaleProvider.js +31 -0
- package/es/LocaleProvider/index.js +7 -0
- package/es/LocaleReciver/index.js +24 -0
- package/es/Markdown/Markdown.js +118 -0
- package/es/Markdown/index.js +7 -0
- package/es/PermissionButton/PermissionButton.js +118 -0
- package/es/PermissionButton/confirm.js +94 -0
- package/es/PermissionButton/index.js +9 -0
- package/es/PermissionButton/shared.js +1 -0
- package/es/ProLayout/Basic/BasicLayout.js +422 -0
- package/es/ProLayout/Basic/BasicLayoutStyle.js +51 -0
- package/es/ProLayout/Basic/Header.js +111 -0
- package/es/ProLayout/Basic/HeaderStyle.js +10 -0
- package/es/ProLayout/PageContainer/index.js +354 -0
- package/es/ProLayout/PageContainer/style.js +85 -0
- package/es/ProLayout/RouteContext.js +28 -0
- package/es/ProLayout/SiderMenu/BaseMenu.js +241 -0
- package/es/ProLayout/SiderMenu/SiderMenu.js +274 -0
- package/es/ProLayout/SiderMenu/index.js +2 -0
- package/es/ProLayout/SiderMenu/style.js +204 -0
- package/es/ProLayout/TopHeader/index.js +170 -0
- package/es/ProLayout/TopHeader/style.js +154 -0
- package/es/ProLayout/defaultSettings.js +113 -0
- package/es/ProLayout/index.js +10 -0
- package/es/ProLayout/style/index.js +14 -0
- package/es/ProLayout/util.js +58 -0
- package/es/ProTable/Alert.js +40 -0
- package/es/ProTable/Content.js +97 -0
- package/es/ProTable/Header.js +33 -0
- package/es/ProTable/Pagination.js +55 -0
- package/es/ProTable/ProTable.js +279 -0
- package/es/ProTable/hooks/index.js +2 -0
- package/es/ProTable/hooks/useTableInject.js +6 -0
- package/es/ProTable/hooks/useTableSelection.js +115 -0
- package/es/ProTable/index.js +8 -0
- package/es/ProTable/setting.js +138 -0
- package/es/ProTable/style/index.js +113 -0
- package/es/RadioButton/RadioButton.js +53 -0
- package/es/RadioButton/index.js +8 -0
- package/es/RadioButton/style/index.js +25 -0
- package/es/Scrollbar/Bar.js +76 -0
- package/es/Scrollbar/Scrollbar.js +161 -0
- package/es/Scrollbar/Thumb.js +150 -0
- package/es/Scrollbar/constants.js +1 -0
- package/es/Scrollbar/index.js +7 -0
- package/es/Scrollbar/scrollbarProps.js +100 -0
- package/es/Scrollbar/style/index.js +85 -0
- package/es/Scrollbar/thumbProps.js +10 -0
- package/es/Scrollbar/util.js +39 -0
- package/es/Search/Item.js +239 -0
- package/es/Search/Search.js +90 -0
- package/es/Search/hooks/index.js +117 -0
- package/es/Search/hooks/useRouteQuery.js +86 -0
- package/es/Search/hooks/useSearchItems.js +50 -0
- package/es/Search/hooks/useTermOptions.js +29 -0
- package/es/Search/index.js +10 -0
- package/es/Search/setting.js +245 -0
- package/es/Search/style/index.js +5 -0
- package/es/Search/style/item.js +40 -0
- package/es/Search/style/search.js +177 -0
- package/es/Search/util.js +270 -0
- package/es/Skeleton/Skeleton.js +27 -0
- package/es/Skeleton/components/DashBoardCard.js +27 -0
- package/es/Skeleton/components/DashBoardChart.js +27 -0
- package/es/Skeleton/components/Detail.js +27 -0
- package/es/Skeleton/components/Drawer.js +27 -0
- package/es/Skeleton/components/Item.js +54 -0
- package/es/Skeleton/components/List.js +27 -0
- package/es/Skeleton/components/ListCard.js +28 -0
- package/es/Skeleton/components/ListCardItem.js +20 -0
- package/es/Skeleton/components/ListTable.js +27 -0
- package/es/Skeleton/components/Page.js +26 -0
- package/es/Skeleton/components/Search.js +16 -0
- package/es/Skeleton/components/Tree.js +27 -0
- package/es/Skeleton/index.js +28 -0
- package/es/Skeleton/style/index.js +195 -0
- package/es/TimeFormat/TimeFormat.js +36 -0
- package/es/TimeFormat/index.js +7 -0
- package/es/Title/Title.js +26 -0
- package/es/Title/index.js +7 -0
- package/es/Title/style/index.js +34 -0
- package/es/ValueItem/ValueItem.js +113 -0
- package/es/ValueItem/index.js +7 -0
- package/es/ValueItem/util.js +17 -0
- package/es/VirtualTable/VirtualTable.js +271 -0
- package/es/VirtualTable/data.js +60 -0
- package/es/VirtualTable/index.js +7 -0
- package/es/VirtualTable/style/index.js +34 -0
- package/es/components.js +21 -0
- package/es/index.js +17 -0
- package/es/locale/en-US.js +120 -0
- package/es/locale/zh-CN.js +120 -0
- package/es/style/styleRegister.js +19 -0
- package/es/style/variable.js +4 -0
- package/es/style.js +1 -0
- package/es/utils/constants.js +10 -0
- package/lib/AutoComplete/AutoComplete.js +84 -0
- package/lib/AutoComplete/index.js +7 -0
- package/lib/BadgeStatus/Badge.js +51 -0
- package/lib/BadgeStatus/color.js +14 -0
- package/lib/BadgeStatus/index.js +8 -0
- package/lib/CardSelect/CardSelect.js +141 -0
- package/lib/CardSelect/index.js +7 -0
- package/lib/CardSelect/style/index.js +29 -0
- package/lib/CheckButton/CheckButton.js +122 -0
- package/lib/CheckButton/index.js +7 -0
- package/lib/CheckButton/style/index.js +44 -0
- package/lib/ConfigProvider/ConfigProvider.js +73 -0
- package/lib/ConfigProvider/context.js +26 -0
- package/lib/ConfigProvider/index.js +9 -0
- package/lib/DragModal/DragModal.js +212 -0
- package/lib/DragModal/index.js +7 -0
- package/lib/DragModal/style/index.js +86 -0
- package/lib/EditTable/Body.js +189 -0
- package/lib/EditTable/CellRender.js +12 -0
- package/lib/EditTable/EditTable.js +434 -0
- package/lib/EditTable/FormItem.js +169 -0
- package/lib/EditTable/Group.js +204 -0
- package/lib/EditTable/Header.js +63 -0
- package/lib/EditTable/HeaderRender.js +12 -0
- package/lib/EditTable/components/ContextMenu/Menu.js +86 -0
- package/lib/EditTable/components/ContextMenu/index.js +96 -0
- package/lib/EditTable/components/Search/Search.js +163 -0
- package/lib/EditTable/components/Search/Sort.js +119 -0
- package/lib/EditTable/components/Search/index.js +2 -0
- package/lib/EditTable/consts.js +13 -0
- package/lib/EditTable/context.js +88 -0
- package/lib/EditTable/hooks/index.js +19 -0
- package/lib/EditTable/hooks/useGroup.js +48 -0
- package/lib/EditTable/hooks/useResizeObserver.js +27 -0
- package/lib/EditTable/hooks/useValidate.js +112 -0
- package/lib/EditTable/index.js +25 -0
- package/lib/EditTable/props.js +60 -0
- package/lib/EditTable/style/body.js +63 -0
- package/lib/EditTable/style/form.js +33 -0
- package/lib/EditTable/style/group.js +33 -0
- package/lib/EditTable/style/header.js +72 -0
- package/lib/EditTable/style/index.js +52 -0
- package/lib/EditTable/style/menu.js +27 -0
- package/lib/EditTable/style/table.js +46 -0
- package/lib/EditTable/utils.js +110 -0
- package/lib/Ellipsis/Ellipsis.js +148 -0
- package/lib/Ellipsis/index.js +7 -0
- package/lib/Ellipsis/style/index.js +26 -0
- package/lib/Empty/Empty.js +63 -0
- package/lib/Empty/image.js +3 -0
- package/lib/Empty/index.js +7 -0
- package/lib/FullPage/FullPage.js +19 -0
- package/lib/FullPage/index.js +7 -0
- package/lib/Icon/Icon.js +49 -0
- package/lib/Icon/index.js +7 -0
- package/lib/LocaleProvider/LocaleProvider.js +31 -0
- package/lib/LocaleProvider/index.js +7 -0
- package/lib/LocaleReciver/index.js +24 -0
- package/lib/Markdown/Markdown.js +118 -0
- package/lib/Markdown/index.js +7 -0
- package/lib/PermissionButton/PermissionButton.js +118 -0
- package/lib/PermissionButton/confirm.js +94 -0
- package/lib/PermissionButton/index.js +9 -0
- package/lib/PermissionButton/shared.js +1 -0
- package/lib/ProLayout/Basic/BasicLayout.js +422 -0
- package/lib/ProLayout/Basic/BasicLayoutStyle.js +51 -0
- package/lib/ProLayout/Basic/Header.js +111 -0
- package/lib/ProLayout/Basic/HeaderStyle.js +10 -0
- package/lib/ProLayout/PageContainer/index.js +354 -0
- package/lib/ProLayout/PageContainer/style.js +85 -0
- package/lib/ProLayout/RouteContext.js +28 -0
- package/lib/ProLayout/SiderMenu/BaseMenu.js +241 -0
- package/lib/ProLayout/SiderMenu/SiderMenu.js +274 -0
- package/lib/ProLayout/SiderMenu/index.js +2 -0
- package/lib/ProLayout/SiderMenu/style.js +204 -0
- package/lib/ProLayout/TopHeader/index.js +170 -0
- package/lib/ProLayout/TopHeader/style.js +154 -0
- package/lib/ProLayout/defaultSettings.js +113 -0
- package/lib/ProLayout/index.js +10 -0
- package/lib/ProLayout/style/index.js +14 -0
- package/lib/ProLayout/util.js +58 -0
- package/lib/ProTable/Alert.js +40 -0
- package/lib/ProTable/Content.js +97 -0
- package/lib/ProTable/Header.js +33 -0
- package/lib/ProTable/Pagination.js +55 -0
- package/lib/ProTable/ProTable.js +279 -0
- package/lib/ProTable/hooks/index.js +2 -0
- package/lib/ProTable/hooks/useTableInject.js +6 -0
- package/lib/ProTable/hooks/useTableSelection.js +115 -0
- package/lib/ProTable/index.js +8 -0
- package/lib/ProTable/setting.js +138 -0
- package/lib/ProTable/style/index.js +113 -0
- package/lib/RadioButton/RadioButton.js +53 -0
- package/lib/RadioButton/index.js +8 -0
- package/lib/RadioButton/style/index.js +25 -0
- package/lib/Scrollbar/Bar.js +76 -0
- package/lib/Scrollbar/Scrollbar.js +161 -0
- package/lib/Scrollbar/Thumb.js +150 -0
- package/lib/Scrollbar/constants.js +1 -0
- package/lib/Scrollbar/index.js +7 -0
- package/lib/Scrollbar/scrollbarProps.js +100 -0
- package/lib/Scrollbar/style/index.js +85 -0
- package/lib/Scrollbar/thumbProps.js +10 -0
- package/lib/Scrollbar/util.js +39 -0
- package/lib/Search/Item.js +239 -0
- package/lib/Search/Search.js +90 -0
- package/lib/Search/hooks/index.js +117 -0
- package/lib/Search/hooks/useRouteQuery.js +86 -0
- package/lib/Search/hooks/useSearchItems.js +50 -0
- package/lib/Search/hooks/useTermOptions.js +29 -0
- package/lib/Search/index.js +10 -0
- package/lib/Search/setting.js +245 -0
- package/lib/Search/style/index.js +5 -0
- package/lib/Search/style/item.js +40 -0
- package/lib/Search/style/search.js +177 -0
- package/lib/Search/util.js +270 -0
- package/lib/Skeleton/Skeleton.js +27 -0
- package/lib/Skeleton/components/DashBoardCard.js +27 -0
- package/lib/Skeleton/components/DashBoardChart.js +27 -0
- package/lib/Skeleton/components/Detail.js +27 -0
- package/lib/Skeleton/components/Drawer.js +27 -0
- package/lib/Skeleton/components/Item.js +54 -0
- package/lib/Skeleton/components/List.js +27 -0
- package/lib/Skeleton/components/ListCard.js +28 -0
- package/lib/Skeleton/components/ListCardItem.js +20 -0
- package/lib/Skeleton/components/ListTable.js +27 -0
- package/lib/Skeleton/components/Page.js +26 -0
- package/lib/Skeleton/components/Search.js +16 -0
- package/lib/Skeleton/components/Tree.js +27 -0
- package/lib/Skeleton/index.js +28 -0
- package/lib/Skeleton/style/index.js +195 -0
- package/lib/TimeFormat/TimeFormat.js +36 -0
- package/lib/TimeFormat/index.js +7 -0
- package/lib/Title/Title.js +26 -0
- package/lib/Title/index.js +7 -0
- package/lib/Title/style/index.js +34 -0
- package/lib/ValueItem/ValueItem.js +113 -0
- package/lib/ValueItem/index.js +7 -0
- package/lib/ValueItem/util.js +17 -0
- package/lib/VirtualTable/VirtualTable.js +271 -0
- package/lib/VirtualTable/data.js +60 -0
- package/lib/VirtualTable/index.js +7 -0
- package/lib/VirtualTable/style/index.js +34 -0
- package/lib/components.js +21 -0
- package/lib/index.js +17 -0
- package/lib/locale/en-US.js +120 -0
- package/lib/locale/zh-CN.js +120 -0
- package/lib/style/styleRegister.js +19 -0
- package/lib/style/variable.js +4 -0
- package/lib/style.js +1 -0
- package/lib/utils/constants.js +10 -0
- package/package.json +164 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
import { defineComponent, ref, useSlots, computed, onMounted, watch } from 'vue'
|
|
3
|
+
import { Button } from 'ant-design-vue'
|
|
4
|
+
import { useLocaleReceiver } from '../LocaleReciver/index'
|
|
5
|
+
import genDragModalStyle from './style'
|
|
6
|
+
|
|
7
|
+
export default defineComponent({
|
|
8
|
+
name: 'JDragModal',
|
|
9
|
+
components: { Button },
|
|
10
|
+
props: {
|
|
11
|
+
title: {
|
|
12
|
+
type: [String, Boolean],
|
|
13
|
+
default: ''
|
|
14
|
+
},
|
|
15
|
+
width: {
|
|
16
|
+
type: Number,
|
|
17
|
+
default: 400
|
|
18
|
+
},
|
|
19
|
+
height: {
|
|
20
|
+
type: Number,
|
|
21
|
+
default: 100
|
|
22
|
+
},
|
|
23
|
+
dragRang: {
|
|
24
|
+
type: [Array, Number],
|
|
25
|
+
default: [400, 200]
|
|
26
|
+
},
|
|
27
|
+
bodyStyle: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: () => ({})
|
|
30
|
+
},
|
|
31
|
+
footer: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
emits: ['cancel', 'heightChange', 'ok', 'visibleChange'],
|
|
37
|
+
setup(props, { emit }) {
|
|
38
|
+
const slots = useSlots()
|
|
39
|
+
const [contextLocale] = useLocaleReceiver('DragModal')
|
|
40
|
+
const ele = document.body
|
|
41
|
+
|
|
42
|
+
const dialog = ref()
|
|
43
|
+
const header = ref()
|
|
44
|
+
const baseWidth = ref(props.width || 400)
|
|
45
|
+
const baseHeight = ref(props.height || 100)
|
|
46
|
+
const baseLeft = ref(100)
|
|
47
|
+
const baseTop = ref(100)
|
|
48
|
+
|
|
49
|
+
const prefixCls = computed(() => 'jetlinks-drag-modal')
|
|
50
|
+
const [wrapSSR, hashId] = genDragModalStyle(prefixCls)
|
|
51
|
+
|
|
52
|
+
const styles = computed(() => {
|
|
53
|
+
return {
|
|
54
|
+
top: getFixed(baseTop.value) + 'px',
|
|
55
|
+
left: getFixed(baseLeft.value) + 'px',
|
|
56
|
+
width: getFixed(baseWidth.value) + 'px',
|
|
57
|
+
height: getFixed(baseHeight.value) + 'px'
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const getFixed = (val) => {
|
|
62
|
+
return Number(val.toFixed(2))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const onDrag = () => {
|
|
66
|
+
let active = false
|
|
67
|
+
let initialX
|
|
68
|
+
let initialY
|
|
69
|
+
let initialWindowX
|
|
70
|
+
let initialWindowY
|
|
71
|
+
|
|
72
|
+
header.value.addEventListener('mousedown', (e) => {
|
|
73
|
+
active = true
|
|
74
|
+
initialX = e.clientX
|
|
75
|
+
initialY = e.clientY
|
|
76
|
+
initialWindowX = dialog.value.offsetLeft
|
|
77
|
+
initialWindowY = dialog.value.offsetTop
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
document.addEventListener('mouseup', () => {
|
|
81
|
+
active = false
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
document.addEventListener('mousemove', (e) => {
|
|
85
|
+
if (active) {
|
|
86
|
+
const dx = e.clientX - initialX
|
|
87
|
+
const dy = e.clientY - initialY
|
|
88
|
+
baseLeft.value = initialWindowX + dx
|
|
89
|
+
baseTop.value = initialWindowY + dy
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const handleClear = () => {
|
|
95
|
+
document.onmouseup = () => {
|
|
96
|
+
document.onmousemove = null
|
|
97
|
+
document.onmouseup = null
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const rangeMove = (e, position) => {
|
|
102
|
+
//移动的方向
|
|
103
|
+
let x = false
|
|
104
|
+
let y = false
|
|
105
|
+
//移动的位置
|
|
106
|
+
let xp = false
|
|
107
|
+
let yp = false
|
|
108
|
+
//移动的正负
|
|
109
|
+
let xc = false
|
|
110
|
+
let yc = false
|
|
111
|
+
|
|
112
|
+
let disX = e.clientX
|
|
113
|
+
let disY = e.clientY
|
|
114
|
+
|
|
115
|
+
document.onmousemove = (e) => {
|
|
116
|
+
if (position === 'drag-bottom-right') {
|
|
117
|
+
x = true
|
|
118
|
+
y = true
|
|
119
|
+
} else if (position === 'drag-bottom-left') {
|
|
120
|
+
x = true
|
|
121
|
+
y = true
|
|
122
|
+
xp = true
|
|
123
|
+
xc = true
|
|
124
|
+
} else if (position === 'drag-top-right') {
|
|
125
|
+
x = true
|
|
126
|
+
y = true
|
|
127
|
+
yp = true
|
|
128
|
+
yc = true
|
|
129
|
+
} else if (position === 'drag-top-left') {
|
|
130
|
+
x = true
|
|
131
|
+
y = true
|
|
132
|
+
xp = true
|
|
133
|
+
xc = true
|
|
134
|
+
yp = true
|
|
135
|
+
yc = true
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let left = e.clientX - disX
|
|
139
|
+
let top = e.clientY - disY
|
|
140
|
+
disX = e.clientX
|
|
141
|
+
disY = e.clientY
|
|
142
|
+
|
|
143
|
+
if (x) {
|
|
144
|
+
let calc = left
|
|
145
|
+
if (xc) {
|
|
146
|
+
calc = -calc
|
|
147
|
+
}
|
|
148
|
+
if (xp) {
|
|
149
|
+
baseLeft.value = baseLeft.value - calc
|
|
150
|
+
}
|
|
151
|
+
const width = baseWidth.value + calc
|
|
152
|
+
baseWidth.value = width <= (props.dragRang )[0] ? (props.dragRang )[0] : width
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (y) {
|
|
156
|
+
let calc = top
|
|
157
|
+
if (yc) {
|
|
158
|
+
calc = -calc
|
|
159
|
+
}
|
|
160
|
+
if (yp) {
|
|
161
|
+
baseTop.value = baseTop.value - calc
|
|
162
|
+
}
|
|
163
|
+
const height = baseHeight.value + calc
|
|
164
|
+
baseHeight.value = height <= (props.dragRang )[1] ? (props.dragRang )[1] : height
|
|
165
|
+
emit('heightChange', baseHeight.value)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
handleClear()
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const onCancel = () => {
|
|
172
|
+
emit('cancel')
|
|
173
|
+
emit('visibleChange', false)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const onOk = () => {
|
|
177
|
+
emit('ok')
|
|
178
|
+
emit('visibleChange', true)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
onMounted(() => {
|
|
182
|
+
if (dialog.value && header.value) {
|
|
183
|
+
onDrag()
|
|
184
|
+
}
|
|
185
|
+
if (ele) {
|
|
186
|
+
const data = _optionalChain([ele, 'optionalAccess', _ => _.getBoundingClientRect, 'call', _2 => _2()])
|
|
187
|
+
baseLeft.value = (_optionalChain([data, 'optionalAccess', _3 => _3.right]) - baseWidth.value) / 2 || 0
|
|
188
|
+
baseTop.value = _optionalChain([data, 'optionalAccess', _4 => _4.top]) + 200 || 0
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
watch(
|
|
193
|
+
() => props.height,
|
|
194
|
+
() => {
|
|
195
|
+
if (props.height > baseHeight.value) {
|
|
196
|
+
baseHeight.value = props.height
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
dialog,
|
|
203
|
+
header,
|
|
204
|
+
styles,
|
|
205
|
+
hashId,
|
|
206
|
+
contextLocale,
|
|
207
|
+
rangeMove,
|
|
208
|
+
onCancel,
|
|
209
|
+
onOk
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
})
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import genComponentStyle from '../../style/styleRegister'
|
|
2
|
+
|
|
3
|
+
const genDragModalStyle = (config) => {
|
|
4
|
+
const { componentCls, token } = config
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
[componentCls]: {
|
|
8
|
+
position: 'fixed',
|
|
9
|
+
zIndex: 1000,
|
|
10
|
+
|
|
11
|
+
[`${componentCls}-sprite`]: {
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
width: '100%',
|
|
14
|
+
height: '100%',
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
overflow: 'hidden',
|
|
18
|
+
zIndex: 23456765435,
|
|
19
|
+
backgroundColor: '#ffffff',
|
|
20
|
+
borderRadius: 4,
|
|
21
|
+
border: '1px solid #91CAFF',
|
|
22
|
+
boxShadow: '0 3px 8px 0 rgba(22, 119, 255, 0.24)',
|
|
23
|
+
|
|
24
|
+
'.header': {
|
|
25
|
+
padding: '5px 15px',
|
|
26
|
+
fontSize: 18,
|
|
27
|
+
fontWeight: 700,
|
|
28
|
+
color: '#333',
|
|
29
|
+
display: 'flex',
|
|
30
|
+
justifyContent: 'space-between',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
borderBottom: '1px solid #f0f0f0',
|
|
33
|
+
cursor: 'move'
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
[`${componentCls}-body`]: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
minHeight: 0,
|
|
39
|
+
overflowY: 'auto',
|
|
40
|
+
padding: '24px 20px'
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
[`${componentCls}-footer`]: {
|
|
44
|
+
borderTop: '1px solid #f0f0f0',
|
|
45
|
+
padding: '5px 15px'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
[`${componentCls}-range`]: {
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
width: '16px',
|
|
52
|
+
height: '16px',
|
|
53
|
+
borderRadius: '100%',
|
|
54
|
+
zIndex: 23456765436,
|
|
55
|
+
|
|
56
|
+
'&.drag-bottom-right': {
|
|
57
|
+
bottom: '-6px',
|
|
58
|
+
right: '-6px',
|
|
59
|
+
'&:hover': {
|
|
60
|
+
cursor: 'nwse-resize'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
'&.drag-bottom-left': {
|
|
65
|
+
bottom: '-6px',
|
|
66
|
+
left: '-6px',
|
|
67
|
+
'&:hover': {
|
|
68
|
+
cursor: 'nesw-resize'
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
'&.drag-top-right': {
|
|
73
|
+
top: '-6px',
|
|
74
|
+
right: '-6px'
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
'&.drag-top-left': {
|
|
78
|
+
top: '-6px',
|
|
79
|
+
left: '-6px'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default genComponentStyle([genDragModalStyle])
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
import { defineComponent, ref, reactive, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
|
3
|
+
import ContextMenu from './components/ContextMenu'
|
|
4
|
+
import { useHScroll, useRightMenuContext } from './hooks'
|
|
5
|
+
import { randomString } from '@meethive/utils'
|
|
6
|
+
import { bodyProps } from './props'
|
|
7
|
+
import Empty from '../Empty/Empty.js'
|
|
8
|
+
import CellRender from './CellRender.js'
|
|
9
|
+
import genEditTableStyle from './style'
|
|
10
|
+
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: 'JEditTableBody',
|
|
13
|
+
components: {
|
|
14
|
+
Empty,
|
|
15
|
+
CellRender
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
...bodyProps(),
|
|
19
|
+
groupKey: {
|
|
20
|
+
type: [String, Number],
|
|
21
|
+
default: undefined
|
|
22
|
+
},
|
|
23
|
+
width: {
|
|
24
|
+
type: Number
|
|
25
|
+
},
|
|
26
|
+
readonly: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
}
|
|
30
|
+
} ,
|
|
31
|
+
emits: ['update:dataSource', 'scrollDown'],
|
|
32
|
+
setup(props, { emit, expose }) {
|
|
33
|
+
const prefixCls = computed(() => 'jetlinks-edit-table')
|
|
34
|
+
const [wrapSSR, hashId] = genEditTableStyle(prefixCls)
|
|
35
|
+
|
|
36
|
+
const viewScrollRef = ref()
|
|
37
|
+
const tableCenterRef = ref()
|
|
38
|
+
const virtualRang = reactive({
|
|
39
|
+
start: 0,
|
|
40
|
+
end: 15
|
|
41
|
+
})
|
|
42
|
+
const containerStyle = ref(0)
|
|
43
|
+
const context = useRightMenuContext()
|
|
44
|
+
const hScroll = useHScroll()
|
|
45
|
+
|
|
46
|
+
let scrollLock = ref(false)
|
|
47
|
+
let menuInstance
|
|
48
|
+
|
|
49
|
+
const maxLen = computed(() => {
|
|
50
|
+
return Math.trunc(props.height / props.cellHeight)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const selectedRowKeys = ref([])
|
|
54
|
+
|
|
55
|
+
const virtualData = computed(() => {
|
|
56
|
+
return props.dataSource.slice(virtualRang.start, virtualRang.end)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const onScroll = () => {
|
|
60
|
+
if (!viewScrollRef.value) return
|
|
61
|
+
const height = viewScrollRef.value.scrollTop
|
|
62
|
+
const clientHeight = viewScrollRef.value.clientHeight
|
|
63
|
+
|
|
64
|
+
const _index = Math.round(height / props.cellHeight) - 1
|
|
65
|
+
const start = _index < 0 ? 0 : _index
|
|
66
|
+
const end = start + maxLen.value + 4
|
|
67
|
+
|
|
68
|
+
if (
|
|
69
|
+
height + clientHeight >= props.dataSource.length * props.cellHeight &&
|
|
70
|
+
!scrollLock.value
|
|
71
|
+
) {
|
|
72
|
+
emit('scrollDown')
|
|
73
|
+
scrollLock.value = true
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
virtualRang.start = start
|
|
77
|
+
virtualRang.end = end
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const scrollTo = (index) => {
|
|
81
|
+
if (viewScrollRef.value) {
|
|
82
|
+
viewScrollRef.value.scrollTop = index * props.cellHeight
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const showContextMenu = (e, record, _index) => {
|
|
87
|
+
e.preventDefault()
|
|
88
|
+
if (props.disableMenu) {
|
|
89
|
+
const newRecord = {
|
|
90
|
+
...record,
|
|
91
|
+
__index: _index
|
|
92
|
+
}
|
|
93
|
+
menuInstance = ContextMenu(e, newRecord, context)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const rowClick = (record) => {
|
|
98
|
+
if (_optionalChain([props, 'access', _ => _.rowSelection, 'optionalAccess', _2 => _2.selectedRowKeys])) {
|
|
99
|
+
const rowSet = new Set(selectedRowKeys.value)
|
|
100
|
+
const key = record[props.rowKey]
|
|
101
|
+
const selected = !rowSet.has(key)
|
|
102
|
+
if (selected) {
|
|
103
|
+
rowSet.delete(key)
|
|
104
|
+
} else {
|
|
105
|
+
rowSet.add(key)
|
|
106
|
+
}
|
|
107
|
+
_optionalChain([props, 'access', _3 => _3.rowSelection, 'access', _4 => _4.onSelect, 'optionalCall', _5 => _5(record, selected)])
|
|
108
|
+
selectedRowKeys.value = [...rowSet.values()]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const updateSelectedKeys = (keys) => {
|
|
113
|
+
selectedRowKeys.value = keys
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
onMounted(() => {
|
|
117
|
+
nextTick(() => {
|
|
118
|
+
onScroll()
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
onBeforeUnmount(() => {
|
|
123
|
+
_optionalChain([menuInstance, 'optionalAccess', _6 => _6.destroy, 'optionalCall', _7 => _7()])
|
|
124
|
+
_optionalChain([menuInstance, 'optionalAccess', _8 => _8.cleanCopy, 'optionalCall', _9 => _9()])
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
watch(
|
|
128
|
+
() => JSON.stringify(_optionalChain([props, 'access', _10 => _10.rowSelection, 'optionalAccess', _11 => _11.selectedRowKeys])),
|
|
129
|
+
(val) => {
|
|
130
|
+
selectedRowKeys.value = JSON.parse(val || '[]')
|
|
131
|
+
},
|
|
132
|
+
{ immediate: true }
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
watch(
|
|
136
|
+
() => props.dataSource,
|
|
137
|
+
() => {
|
|
138
|
+
props.dataSource.forEach((item) => {
|
|
139
|
+
if (!item.__key) {
|
|
140
|
+
item.__key = randomString()
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
},
|
|
144
|
+
{ immediate: true, deep: true }
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
watch(
|
|
148
|
+
() => props.dataSource.length,
|
|
149
|
+
() => {
|
|
150
|
+
scrollLock.value = false
|
|
151
|
+
containerStyle.value = {
|
|
152
|
+
height: props.dataSource.length * props.cellHeight + 'px'
|
|
153
|
+
}
|
|
154
|
+
if (props.dataSource.length <= maxLen.value || props.dataSource.length === 0) {
|
|
155
|
+
emit('scrollDown', maxLen.value - props.dataSource.length + 3)
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{ immediate: true }
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
watch(
|
|
162
|
+
() => props.groupKey,
|
|
163
|
+
() => {
|
|
164
|
+
if (props.openGroup) {
|
|
165
|
+
scrollTo(0)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
expose({
|
|
171
|
+
scrollTo,
|
|
172
|
+
updateSelectedKeys
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
hashId,
|
|
177
|
+
viewScrollRef,
|
|
178
|
+
tableCenterRef,
|
|
179
|
+
virtualRang,
|
|
180
|
+
containerStyle,
|
|
181
|
+
hScroll,
|
|
182
|
+
selectedRowKeys,
|
|
183
|
+
virtualData,
|
|
184
|
+
onScroll,
|
|
185
|
+
showContextMenu,
|
|
186
|
+
rowClick
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
name: 'CellRender',
|
|
6
|
+
props: ['renderFn', 'value', 'record', 'index'],
|
|
7
|
+
setup(props) {
|
|
8
|
+
return () => {
|
|
9
|
+
return props.renderFn(props.value, props.record, props.index)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
})
|