@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,204 @@
|
|
|
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 } from 'vue'
|
|
3
|
+
import {
|
|
4
|
+
Tabs as ATabs,
|
|
5
|
+
TabPane as ATabPane,
|
|
6
|
+
Dropdown as ADropdown,
|
|
7
|
+
Menu as AMenu,
|
|
8
|
+
MenuItem as AMenuItem,
|
|
9
|
+
Tooltip as ATooltip,
|
|
10
|
+
Modal as AModal,
|
|
11
|
+
Form as AForm,
|
|
12
|
+
FormItem as AFormItem,
|
|
13
|
+
Input as AInput,
|
|
14
|
+
Button as AButton,
|
|
15
|
+
Modal
|
|
16
|
+
} from 'ant-design-vue'
|
|
17
|
+
import { randomNumber } from '@meethive/utils'
|
|
18
|
+
import { isFullScreen } from './utils'
|
|
19
|
+
import { useTableGroupError, useTableWrapper } from './context'
|
|
20
|
+
import { useLocaleReceiver } from '../LocaleReciver'
|
|
21
|
+
import genEditTableStyle from './style'
|
|
22
|
+
|
|
23
|
+
export default defineComponent({
|
|
24
|
+
name: 'JEditTableGroup',
|
|
25
|
+
components: {
|
|
26
|
+
ATabs,
|
|
27
|
+
ATabPane,
|
|
28
|
+
ADropdown,
|
|
29
|
+
AMenu,
|
|
30
|
+
AMenuItem,
|
|
31
|
+
ATooltip,
|
|
32
|
+
AModal,
|
|
33
|
+
AForm,
|
|
34
|
+
AFormItem,
|
|
35
|
+
AInput,
|
|
36
|
+
AButton
|
|
37
|
+
},
|
|
38
|
+
props: {
|
|
39
|
+
options: {
|
|
40
|
+
type: Array ,
|
|
41
|
+
default: () => []
|
|
42
|
+
},
|
|
43
|
+
activeKey: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: undefined
|
|
46
|
+
},
|
|
47
|
+
readonly: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
emits: ['delete', 'edit', 'add', 'change', 'update:activeKey'],
|
|
53
|
+
setup(props, { emit }) {
|
|
54
|
+
const [contextLocale] = useLocaleReceiver('EditTable')
|
|
55
|
+
|
|
56
|
+
const myActiveKey = ref(props.activeKey)
|
|
57
|
+
const visible = ref(false)
|
|
58
|
+
const type = ref(contextLocale.value.Group.addGroup)
|
|
59
|
+
const errorMap = useTableGroupError()
|
|
60
|
+
const tableWrapperRef = useTableWrapper()
|
|
61
|
+
const addIndex = ref(0)
|
|
62
|
+
const formRef = ref()
|
|
63
|
+
const formData = reactive({
|
|
64
|
+
label: undefined
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const prefixCls = computed(() => 'jetlinks-edit-table')
|
|
68
|
+
const [wrapSSR, hashId] = genEditTableStyle(prefixCls)
|
|
69
|
+
|
|
70
|
+
const onAdd = (targetKey, action) => {
|
|
71
|
+
if (action === 'add') {
|
|
72
|
+
type.value = 'add'
|
|
73
|
+
const groupName = props.options.filter((item) =>
|
|
74
|
+
item.label.includes(contextLocale.value.Group.one)
|
|
75
|
+
)
|
|
76
|
+
let index = addIndex.value + 1
|
|
77
|
+
let findStatus = false
|
|
78
|
+
|
|
79
|
+
while (!findStatus) {
|
|
80
|
+
const status = groupName.some((item) => {
|
|
81
|
+
const [_, _index] = item.label.split('_')
|
|
82
|
+
if (index === Number(_index)) {
|
|
83
|
+
index = Number(_index) + 1
|
|
84
|
+
return true
|
|
85
|
+
}
|
|
86
|
+
return false
|
|
87
|
+
})
|
|
88
|
+
findStatus = !status
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
addIndex.value = index
|
|
92
|
+
formData.label = contextLocale.value.Group.one + index
|
|
93
|
+
onOk()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const onEdit = (record) => {
|
|
98
|
+
visible.value = true
|
|
99
|
+
type.value = 'edit'
|
|
100
|
+
formData.label = record.label
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const onCancel = () => {
|
|
104
|
+
formRef.value.resetFields()
|
|
105
|
+
visible.value = false
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const onOk = () => {
|
|
109
|
+
const data = { ...formData }
|
|
110
|
+
if (type.value === 'add') {
|
|
111
|
+
data.value = 'group_' + randomNumber()
|
|
112
|
+
myActiveKey.value = data.value
|
|
113
|
+
emit(type.value, data)
|
|
114
|
+
emit('change', data.value, data.label)
|
|
115
|
+
emit('update:activeKey', data.value)
|
|
116
|
+
visible.value = false
|
|
117
|
+
} else {
|
|
118
|
+
formRef.value.validate().then(() => {
|
|
119
|
+
data.value = myActiveKey.value
|
|
120
|
+
emit(type.value, data)
|
|
121
|
+
emit('change', data.value, data.label)
|
|
122
|
+
visible.value = false
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const change = () => {
|
|
128
|
+
const item = props.options.find((item) => item.value === myActiveKey.value)
|
|
129
|
+
emit('change', myActiveKey.value, item.label)
|
|
130
|
+
emit('update:activeKey', myActiveKey.value)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const menuClick = (e, record) => {
|
|
134
|
+
if (props.readonly) return
|
|
135
|
+
if (e.key === 'edit') {
|
|
136
|
+
onEdit(record)
|
|
137
|
+
} else {
|
|
138
|
+
Modal.confirm({
|
|
139
|
+
title: contextLocale.value.Group.deleteMessage,
|
|
140
|
+
onOk: () => {
|
|
141
|
+
const index = props.options.findIndex((item) => item.value === record.value)
|
|
142
|
+
let label = ''
|
|
143
|
+
|
|
144
|
+
if (index !== 0 && index === props.options.length - 1) {
|
|
145
|
+
myActiveKey.value = props.options[index - 1].value
|
|
146
|
+
label = props.options[index - 1].label
|
|
147
|
+
} else if (index === 0 && props.options.length === 1) {
|
|
148
|
+
myActiveKey.value = props.options[0].value
|
|
149
|
+
label = props.options[0].label
|
|
150
|
+
} else {
|
|
151
|
+
myActiveKey.value = props.options[index + 1].value
|
|
152
|
+
label = props.options[index + 1].label
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
emit('delete', record.value, index)
|
|
156
|
+
emit('change', myActiveKey.value, label)
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const popContainer = (e) => {
|
|
163
|
+
return tableWrapperRef.value || e
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const modalContainer = () => {
|
|
167
|
+
if (isFullScreen()) {
|
|
168
|
+
return tableWrapperRef.value || document.body
|
|
169
|
+
}
|
|
170
|
+
return document.body
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
onMounted(() => {
|
|
174
|
+
myActiveKey.value = _optionalChain([props, 'access', _2 => _2.options, 'access', _3 => _3[0], 'optionalAccess', _4 => _4.value])
|
|
175
|
+
emit('change', myActiveKey.value, _optionalChain([props, 'access', _5 => _5.options, 'access', _6 => _6[0], 'optionalAccess', _7 => _7.label]))
|
|
176
|
+
emit('update:activeKey', myActiveKey.value)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
watch(
|
|
180
|
+
() => props.activeKey,
|
|
181
|
+
(val) => {
|
|
182
|
+
myActiveKey.value = val
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
hashId,
|
|
188
|
+
contextLocale,
|
|
189
|
+
myActiveKey,
|
|
190
|
+
visible,
|
|
191
|
+
errorMap,
|
|
192
|
+
tableWrapperRef,
|
|
193
|
+
formRef,
|
|
194
|
+
formData,
|
|
195
|
+
onAdd,
|
|
196
|
+
onCancel,
|
|
197
|
+
onOk,
|
|
198
|
+
change,
|
|
199
|
+
menuClick,
|
|
200
|
+
popContainer,
|
|
201
|
+
modalContainer
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
})
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
|
|
2
|
+
import { defineComponent, reactive, computed } from 'vue'
|
|
3
|
+
import { SearchModal, Sort } from './components/Search'
|
|
4
|
+
import { useHScroll, useTableTool } from './hooks'
|
|
5
|
+
import HeaderItemRender from './HeaderRender.js'
|
|
6
|
+
import useEditTableStyle from './style'
|
|
7
|
+
import AIcon from '../Icon'
|
|
8
|
+
|
|
9
|
+
export default defineComponent({
|
|
10
|
+
name: 'JEditTableHeader',
|
|
11
|
+
components: {
|
|
12
|
+
SearchModal,
|
|
13
|
+
Sort,
|
|
14
|
+
HeaderItemRender,
|
|
15
|
+
AIcon
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
columns: {
|
|
19
|
+
type: Array,
|
|
20
|
+
default: () => []
|
|
21
|
+
},
|
|
22
|
+
searchColumns: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: undefined
|
|
25
|
+
},
|
|
26
|
+
serial: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
style: {
|
|
31
|
+
type: Object,
|
|
32
|
+
default: undefined
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
setup(props) {
|
|
36
|
+
const prefixCls = computed(() => 'jetlinks-edit-table')
|
|
37
|
+
const [wrapSSR, hashId] = useEditTableStyle(prefixCls)
|
|
38
|
+
const tableTool = useTableTool()
|
|
39
|
+
const hScroll = useHScroll()
|
|
40
|
+
|
|
41
|
+
const searchData = reactive({
|
|
42
|
+
visible: false,
|
|
43
|
+
key: undefined
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const showFilter = (key) => {
|
|
47
|
+
searchData.visible = true
|
|
48
|
+
searchData.key = key
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const sortClick = () => {
|
|
52
|
+
searchData.visible = false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
hashId,
|
|
57
|
+
tableTool,
|
|
58
|
+
searchData,
|
|
59
|
+
showFilter,
|
|
60
|
+
sortClick
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
@@ -0,0 +1,86 @@
|
|
|
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, computed, onMounted, nextTick } from 'vue'
|
|
3
|
+
import { Menu } from 'ant-design-vue'
|
|
4
|
+
import AIcon from '../../../Icon'
|
|
5
|
+
import { useLocaleReceiver } from '../../../LocaleReciver'
|
|
6
|
+
import useEditTableStyle from '../../style'
|
|
7
|
+
|
|
8
|
+
const MenuItem = Menu.Item
|
|
9
|
+
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
name: 'JEditTableContextMenu',
|
|
12
|
+
components: {
|
|
13
|
+
Menu,
|
|
14
|
+
MenuItem,
|
|
15
|
+
AIcon
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
data: {
|
|
19
|
+
type: Object,
|
|
20
|
+
default: () => ({})
|
|
21
|
+
},
|
|
22
|
+
onClose: {
|
|
23
|
+
type: Function,
|
|
24
|
+
default: () => {}
|
|
25
|
+
},
|
|
26
|
+
onClick: {
|
|
27
|
+
type: Function,
|
|
28
|
+
default: () => {}
|
|
29
|
+
},
|
|
30
|
+
onCopy: {
|
|
31
|
+
type: Function,
|
|
32
|
+
default: () => {}
|
|
33
|
+
},
|
|
34
|
+
paste: {
|
|
35
|
+
type: Object,
|
|
36
|
+
default: () => ({})
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
setup(props) {
|
|
40
|
+
const contextMenu = ref(null)
|
|
41
|
+
const prefixCls = computed(() => 'jetlinks-edit-table')
|
|
42
|
+
const [wrapSSR, hashId] = useEditTableStyle(prefixCls)
|
|
43
|
+
const [contextLocale] = useLocaleReceiver('EditTable')
|
|
44
|
+
|
|
45
|
+
const showDetail = computed(() => {
|
|
46
|
+
return !props.data.id
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const showPaste = computed(() => {
|
|
50
|
+
return !props.paste
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const showDelete = computed(() => {
|
|
54
|
+
return _optionalChain([props, 'access', _ => _.data, 'optionalAccess', _2 => _2.expands, 'optionalAccess', _3 => _3.isProduct])
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const clickFunc = ({ key }) => {
|
|
58
|
+
if (key === 'copy') {
|
|
59
|
+
props.onCopy(props.data)
|
|
60
|
+
}
|
|
61
|
+
props.onClick(key)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const close = () => {
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
props.onClose()
|
|
67
|
+
}, 300)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onMounted(async () => {
|
|
71
|
+
await nextTick()
|
|
72
|
+
contextMenu.value.focus()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
contextMenu,
|
|
77
|
+
hashId,
|
|
78
|
+
contextLocale,
|
|
79
|
+
showDetail,
|
|
80
|
+
showPaste,
|
|
81
|
+
showDelete,
|
|
82
|
+
clickFunc,
|
|
83
|
+
close
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import MenuContext from './Menu.js'
|
|
2
|
+
import { h, render } from 'vue'
|
|
3
|
+
import { handlePureRecord } from '../../utils'
|
|
4
|
+
import { omit } from 'lodash-es'
|
|
5
|
+
|
|
6
|
+
let curInstance = null
|
|
7
|
+
let seed = 1
|
|
8
|
+
let copyValue
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const contextMenu = (e, data, context) => {
|
|
22
|
+
if (curInstance) {
|
|
23
|
+
curInstance.destroy()
|
|
24
|
+
}
|
|
25
|
+
curInstance = null
|
|
26
|
+
|
|
27
|
+
const id = seed++
|
|
28
|
+
// 创建一个临时的div,用于挂载我们的菜单
|
|
29
|
+
const container = document.createElement('div')
|
|
30
|
+
// 获取body标签,用于挂载整个菜单
|
|
31
|
+
const appendTo = context.getPopupContainer() || document.body
|
|
32
|
+
|
|
33
|
+
// 传给menu组件的props
|
|
34
|
+
const props = {
|
|
35
|
+
data,
|
|
36
|
+
onClose: () => {
|
|
37
|
+
if (curInstance) {
|
|
38
|
+
curInstance.destroy()
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
onClick: (type) => {
|
|
42
|
+
let copyRecord = handlePureRecord(copyValue)
|
|
43
|
+
if (copyRecord.expands) {
|
|
44
|
+
copyRecord.expands = omit(copyRecord.expands, ['isProduct'])
|
|
45
|
+
}
|
|
46
|
+
context.click(type, data, handlePureRecord(copyRecord))
|
|
47
|
+
},
|
|
48
|
+
onCopy: (data) => {
|
|
49
|
+
copyValue = data
|
|
50
|
+
context.click('copy', data)
|
|
51
|
+
},
|
|
52
|
+
paste: !!copyValue
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 渲染虚拟节点
|
|
56
|
+
const vnode = h(MenuContext, props)
|
|
57
|
+
// vnode为需要渲染的虚拟节点,container为渲染的容器
|
|
58
|
+
render(vnode, container)
|
|
59
|
+
// 首先需要先把菜单真正渲染到页面,才能拿到它的宽度和高度
|
|
60
|
+
appendTo.appendChild(container.firstElementChild)
|
|
61
|
+
|
|
62
|
+
// 当前真正的菜单节点
|
|
63
|
+
const curMenu = vnode.el
|
|
64
|
+
// 获取curMenu的高度和宽度,用于临界的计算
|
|
65
|
+
const { offsetWidth, offsetHeight } = curMenu
|
|
66
|
+
// 获取body的可视区域的宽度
|
|
67
|
+
const { clientWidth } = appendTo
|
|
68
|
+
// 取出右键点击时的坐标
|
|
69
|
+
const { clientX, clientY } = e
|
|
70
|
+
|
|
71
|
+
// 计算菜单位置
|
|
72
|
+
const leftOrRight = clientWidth - clientX > offsetWidth ? 'left' : 'right'
|
|
73
|
+
const topOrBottom = window.innerHeight - clientY > offsetHeight ? 'top' : 'bottom'
|
|
74
|
+
|
|
75
|
+
const offsetLeft = Math.abs(clientWidth - clientX)
|
|
76
|
+
// 设置left或者right的style
|
|
77
|
+
curMenu.style[leftOrRight] = leftOrRight === 'left' ? `${clientX + 20}px` : `${offsetLeft}px`
|
|
78
|
+
// 设置top或者bottom的style
|
|
79
|
+
curMenu.style[topOrBottom] = topOrBottom === 'bottom' ? '2px' : `${clientY}px`
|
|
80
|
+
|
|
81
|
+
const instance = {
|
|
82
|
+
id,
|
|
83
|
+
destroy: () => {
|
|
84
|
+
curInstance = null
|
|
85
|
+
render(null, container)
|
|
86
|
+
},
|
|
87
|
+
cleanCopy: () => {
|
|
88
|
+
copyValue = null
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
curInstance = instance
|
|
93
|
+
return instance
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default contextMenu
|
|
@@ -0,0 +1,163 @@
|
|
|
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, computed } from 'vue'
|
|
3
|
+
import { Space as ASpace, Input as AInput, Button as AButton } from 'ant-design-vue'
|
|
4
|
+
import EditTable from '../../EditTable.js'
|
|
5
|
+
import DragModal from '../../../DragModal/DragModal.js'
|
|
6
|
+
import Ellipsis from '../../../Ellipsis/Ellipsis.js'
|
|
7
|
+
import { useTableDataSource, useTableOpenGroup, useTableTool, useGroupOptions } from '../../context'
|
|
8
|
+
import { useLocaleReceiver } from '../../../LocaleReciver'
|
|
9
|
+
import { isNumber, isArray, isObject, isBoolean } from 'lodash-es'
|
|
10
|
+
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: 'JEditTableSearch',
|
|
13
|
+
components: {
|
|
14
|
+
ASpace,
|
|
15
|
+
AInput,
|
|
16
|
+
AButton,
|
|
17
|
+
EditTable,
|
|
18
|
+
DragModal,
|
|
19
|
+
Ellipsis
|
|
20
|
+
},
|
|
21
|
+
props: {
|
|
22
|
+
searchKey: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: 'id'
|
|
25
|
+
},
|
|
26
|
+
columns: {
|
|
27
|
+
type: Array,
|
|
28
|
+
default: undefined
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: ['close'],
|
|
32
|
+
setup(props, { emit }) {
|
|
33
|
+
const [contextLocale] = useLocaleReceiver('EditTable')
|
|
34
|
+
const dataSource = useTableDataSource()
|
|
35
|
+
const openGroup = useTableOpenGroup()
|
|
36
|
+
const tableTool = useTableTool()
|
|
37
|
+
const groupOptions = useGroupOptions()
|
|
38
|
+
|
|
39
|
+
const searchValue = ref()
|
|
40
|
+
const filterArray = ref([])
|
|
41
|
+
const visible = ref(false)
|
|
42
|
+
const searchIndex = ref(-1)
|
|
43
|
+
const modalHeight = ref(100)
|
|
44
|
+
const tableHeight = ref(230)
|
|
45
|
+
const selectedRowKeys = ref([])
|
|
46
|
+
const tableRef = ref()
|
|
47
|
+
|
|
48
|
+
const myColumns = computed(() => {
|
|
49
|
+
if (props.columns) {
|
|
50
|
+
return (props.columns ).map((item) => ({
|
|
51
|
+
title: item.title,
|
|
52
|
+
dataIndex: item.dataIndex
|
|
53
|
+
}))
|
|
54
|
+
}
|
|
55
|
+
return [
|
|
56
|
+
{ title: contextLocale.value.columns.sign, dataIndex: 'id' },
|
|
57
|
+
{ title: contextLocale.value.columns.name, dataIndex: 'name' }
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const selectedTableRow = (record) => {
|
|
62
|
+
tableTool.scrollTo({
|
|
63
|
+
...record,
|
|
64
|
+
__serial: record.__oldSerial - 1
|
|
65
|
+
})
|
|
66
|
+
tableTool.selected([record.id])
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const handleFilterArray = () => {
|
|
70
|
+
const cloneDataSource = JSON.parse(JSON.stringify(dataSource.value || '[]')).map(
|
|
71
|
+
(item) => Object.assign(item, { __oldSerial: item.__serial })
|
|
72
|
+
)
|
|
73
|
+
const _filterArray = cloneDataSource.filter((item) => {
|
|
74
|
+
let targetValue = item[props.searchKey]
|
|
75
|
+
if (targetValue) {
|
|
76
|
+
if (isNumber(targetValue) || isBoolean(targetValue)) {
|
|
77
|
+
targetValue = String(targetValue)
|
|
78
|
+
} else if (isArray(targetValue) || isObject(targetValue)) {
|
|
79
|
+
targetValue = JSON.stringify(targetValue)
|
|
80
|
+
}
|
|
81
|
+
return targetValue.includes(searchValue.value)
|
|
82
|
+
}
|
|
83
|
+
return false
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
if (openGroup) {
|
|
87
|
+
const handleGroup = []
|
|
88
|
+
groupOptions.value.forEach((group) => {
|
|
89
|
+
handleGroup.push(
|
|
90
|
+
..._filterArray.filter((item) => item.expands.groupId === group.value)
|
|
91
|
+
)
|
|
92
|
+
})
|
|
93
|
+
return handleGroup
|
|
94
|
+
}
|
|
95
|
+
return _filterArray
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const search = (key) => {
|
|
99
|
+
filterArray.value = handleFilterArray()
|
|
100
|
+
if (key === 'all') {
|
|
101
|
+
visible.value = true
|
|
102
|
+
modalHeight.value = 400
|
|
103
|
+
searchIndex.value = 0
|
|
104
|
+
} else if (key === 'next') {
|
|
105
|
+
searchIndex.value += 1
|
|
106
|
+
} else {
|
|
107
|
+
searchIndex.value -= 1
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (searchIndex.value < 0) {
|
|
111
|
+
searchIndex.value = filterArray.value.length - 1
|
|
112
|
+
} else if (searchIndex.value > filterArray.value.length - 1) {
|
|
113
|
+
searchIndex.value = 0
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const searchItem = filterArray.value[searchIndex.value]
|
|
117
|
+
if (key !== 'all' && visible.value) {
|
|
118
|
+
_optionalChain([tableRef, 'access', _ => _.value, 'optionalAccess', _2 => _2.scrollToByIndex, 'call', _3 => _3(searchIndex.value - 1)])
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (filterArray.value.length >= 1) {
|
|
122
|
+
selectedRowKeys.value = [searchItem.id]
|
|
123
|
+
selectedTableRow(searchItem)
|
|
124
|
+
} else {
|
|
125
|
+
selectedRowKeys.value = []
|
|
126
|
+
tableTool.selected([])
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const heightChange = (h) => {
|
|
131
|
+
if (h > 340) {
|
|
132
|
+
tableHeight.value = h - 160
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const onClose = () => {
|
|
137
|
+
emit('close')
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const onSelect = (record) => {
|
|
141
|
+
searchIndex.value = filterArray.value.findIndex((item) => item.id === record.id)
|
|
142
|
+
selectedRowKeys.value = [record.id]
|
|
143
|
+
selectedTableRow(record)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
contextLocale,
|
|
148
|
+
openGroup,
|
|
149
|
+
searchValue,
|
|
150
|
+
filterArray,
|
|
151
|
+
visible,
|
|
152
|
+
modalHeight,
|
|
153
|
+
tableHeight,
|
|
154
|
+
selectedRowKeys,
|
|
155
|
+
tableRef,
|
|
156
|
+
myColumns,
|
|
157
|
+
search,
|
|
158
|
+
heightChange,
|
|
159
|
+
onClose,
|
|
160
|
+
onSelect
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
})
|