resolver-egretimp-plus 0.1.113 → 0.1.115
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/dist/h5/index.js +1 -1
- package/dist/theme/element/index.css +1 -1
- package/dist/theme/element/src/components/common.scss +4 -0
- package/dist/theme/element/src/components/text.scss +17 -0
- package/dist/web/index.js +2 -2
- package/package.json +1 -1
- package/src/analysisComponent.jsx +2 -1
- package/src/components/helper/table.jsx +26 -23
- package/src/components/packages-H5/CustomComponentCollapseH5.vue +6 -2
- package/src/components/packages-web/ElText.jsx +0 -1
- package/src/theme/element/components/common.scss +4 -0
- package/src/theme/element/components/text.scss +17 -0
- package/src-bak/analysisComponent.jsx +343 -0
- package/src-bak/api/builtIn.js +10 -0
- package/src-bak/bpm/bpmInstance.js +388 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/application.js +8 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/component.js +97 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/datasource.js +88 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/iframe/index.js +3 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/iframe/udcSdkForIframe/UdcComponent.js +76 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/iframe/udcSdkForIframe/index.js +201 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/index.js +69 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/page.js +56 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/utils.js +76 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/index.js +46 -0
- package/src-bak/bpm/udc-sdk-esm/cjs/utils.js +21 -0
- package/src-bak/components/childDialog/index.js +39 -0
- package/src-bak/components/childDialog/src/index.vue +185 -0
- package/src-bak/components/cmiFormItem/index.js +1 -0
- package/src-bak/components/cmiFormItem/src/index.vue +112 -0
- package/src-bak/components/confirmInstance-H5/index.js +53 -0
- package/src-bak/components/confirmInstance-H5/src/index.vue +54 -0
- package/src-bak/components/helper/FormPolyfill.jsx +25 -0
- package/src-bak/components/helper/calcTooltip.jsx +134 -0
- package/src-bak/components/helper/dock.js +141 -0
- package/src-bak/components/helper/eventOrchestration.js +763 -0
- package/src-bak/components/helper/resolver.js +163 -0
- package/src-bak/components/helper/table.jsx +103 -0
- package/src-bak/components/icons/date.vue +33 -0
- package/src-bak/components/icons/info.vue +62 -0
- package/src-bak/components/icons/loading.vue +19 -0
- package/src-bak/components/icons/question-filled.vue +8 -0
- package/src-bak/components/loading/index.js +6 -0
- package/src-bak/components/loading/loading.js +98 -0
- package/src-bak/components/loading/loading.scss +74 -0
- package/src-bak/components/loading/loading.vue +89 -0
- package/src-bak/components/loadingComponent/LoadingComponent.vue +33 -0
- package/src-bak/components/modal/index.js +9 -0
- package/src-bak/components/modal/modal.scss +195 -0
- package/src-bak/components/modal/modal.vue +201 -0
- package/src-bak/components/options/OptionsDefault.vue +47 -0
- package/src-bak/components/packages-H5/CmiButton.vue +120 -0
- package/src-bak/components/packages-H5/CmiCalendar.vue +152 -0
- package/src-bak/components/packages-H5/CmiCell.vue +87 -0
- package/src-bak/components/packages-H5/CmiCheckbox.vue +82 -0
- package/src-bak/components/packages-H5/CmiDatetimePicker.vue +98 -0
- package/src-bak/components/packages-H5/CmiDivider.vue +30 -0
- package/src-bak/components/packages-H5/CmiDropdownMenu.vue +58 -0
- package/src-bak/components/packages-H5/CmiInput.vue +69 -0
- package/src-bak/components/packages-H5/CmiLink.vue +28 -0
- package/src-bak/components/packages-H5/CmiPicker.vue +229 -0
- package/src-bak/components/packages-H5/CmiRadio.vue +29 -0
- package/src-bak/components/packages-H5/CmiSearch.vue +39 -0
- package/src-bak/components/packages-H5/CmiSelect.vue +84 -0
- package/src-bak/components/packages-H5/CustomComponentCardH5.vue +129 -0
- package/src-bak/components/packages-H5/CustomComponentColH5.vue +8 -0
- package/src-bak/components/packages-H5/CustomComponentCollapseH5.vue +137 -0
- package/src-bak/components/packages-H5/CustomComponentFormLayoutH5.vue +54 -0
- package/src-bak/components/packages-H5/CustomComponentTabPaneH5.vue +38 -0
- package/src-bak/components/packages-H5/CustomComponentTableH5.vue +352 -0
- package/src-bak/components/packages-H5/CustomComponentTabsH5.vue +170 -0
- package/src-bak/components/packages-web/CustomComponentCard.vue +40 -0
- package/src-bak/components/packages-web/CustomComponentCol.vue +66 -0
- package/src-bak/components/packages-web/CustomComponentCollapse.vue +164 -0
- package/src-bak/components/packages-web/CustomComponentCycle.vue +95 -0
- package/src-bak/components/packages-web/CustomComponentCycleTabPane.vue +155 -0
- package/src-bak/components/packages-web/CustomComponentDialog.vue +192 -0
- package/src-bak/components/packages-web/CustomComponentEditor.vue +50 -0
- package/src-bak/components/packages-web/CustomComponentFileExport.vue +60 -0
- package/src-bak/components/packages-web/CustomComponentFileImport.vue +60 -0
- package/src-bak/components/packages-web/CustomComponentFormLayout.vue +65 -0
- package/src-bak/components/packages-web/CustomComponentGrid.vue +29 -0
- package/src-bak/components/packages-web/CustomComponentGridCol.vue +29 -0
- package/src-bak/components/packages-web/CustomComponentInputDialog.vue +144 -0
- package/src-bak/components/packages-web/CustomComponentNativeTabPane.vue +84 -0
- package/src-bak/components/packages-web/CustomComponentPlain.vue +243 -0
- package/src-bak/components/packages-web/CustomComponentRow.vue +83 -0
- package/src-bak/components/packages-web/CustomComponentSelectEmployees.vue +203 -0
- package/src-bak/components/packages-web/CustomComponentSendMail.vue +62 -0
- package/src-bak/components/packages-web/CustomComponentSteps.vue +41 -0
- package/src-bak/components/packages-web/CustomComponentTabPane.vue +20 -0
- package/src-bak/components/packages-web/CustomComponentTable.jsx +813 -0
- package/src-bak/components/packages-web/CustomComponentTabs.vue +126 -0
- package/src-bak/components/packages-web/CustomComponentTree.vue +28 -0
- package/src-bak/components/packages-web/ElButton.vue +146 -0
- package/src-bak/components/packages-web/ElCheckbox.vue +97 -0
- package/src-bak/components/packages-web/ElDatePicker.vue +93 -0
- package/src-bak/components/packages-web/ElInput copy.jsx +393 -0
- package/src-bak/components/packages-web/ElInput.jsx +312 -0
- package/src-bak/components/packages-web/ElInputNumber.vue +81 -0
- package/src-bak/components/packages-web/ElPagination.vue +61 -0
- package/src-bak/components/packages-web/ElRadio.vue +47 -0
- package/src-bak/components/packages-web/ElSelect.jsx +249 -0
- package/src-bak/components/packages-web/ElSelect_bak.vue +155 -0
- package/src-bak/components/packages-web/ElText.jsx +187 -0
- package/src-bak/components/packages-web/ElTextaa.vue +169 -0
- package/src-bak/components/packages-web/ElTimePicker.vue +39 -0
- package/src-bak/components/patchComponents-H5.js +46 -0
- package/src-bak/components/patchComponents-web.js +46 -0
- package/src-bak/components/simpleFormItemPc/index.js +1 -0
- package/src-bak/components/simpleFormItemPc/src/index.vue +94 -0
- package/src-bak/components/table/index.ts +29 -0
- package/src-bak/components/table/src/composables/use-scrollbar.ts +30 -0
- package/src-bak/components/table/src/config.ts +256 -0
- package/src-bak/components/table/src/filter-panel.vue +260 -0
- package/src-bak/components/table/src/h-helper.ts +34 -0
- package/src-bak/components/table/src/layout-observer.ts +78 -0
- package/src-bak/components/table/src/store/current.ts +85 -0
- package/src-bak/components/table/src/store/expand.ts +76 -0
- package/src-bak/components/table/src/store/helper.ts +74 -0
- package/src-bak/components/table/src/store/index.ts +246 -0
- package/src-bak/components/table/src/store/tree.ts +230 -0
- package/src-bak/components/table/src/store/watcher.ts +543 -0
- package/src-bak/components/table/src/table/defaults.ts +402 -0
- package/src-bak/components/table/src/table/key-render-helper.ts +27 -0
- package/src-bak/components/table/src/table/style-helper.ts +378 -0
- package/src-bak/components/table/src/table/utils-helper.ts +47 -0
- package/src-bak/components/table/src/table-body/defaults.ts +52 -0
- package/src-bak/components/table/src/table-body/events-helper.ts +203 -0
- package/src-bak/components/table/src/table-body/index.ts +119 -0
- package/src-bak/components/table/src/table-body/render-helper.ts +283 -0
- package/src-bak/components/table/src/table-body/styles-helper.ts +164 -0
- package/src-bak/components/table/src/table-column/defaults.ts +237 -0
- package/src-bak/components/table/src/table-column/index.ts +202 -0
- package/src-bak/components/table/src/table-column/render-helper.ts +214 -0
- package/src-bak/components/table/src/table-column/watcher-helper.ts +88 -0
- package/src-bak/components/table/src/table-footer/index.ts +128 -0
- package/src-bak/components/table/src/table-footer/mapState-helper.ts +33 -0
- package/src-bak/components/table/src/table-footer/style-helper.ts +51 -0
- package/src-bak/components/table/src/table-header/event-helper.ts +213 -0
- package/src-bak/components/table/src/table-header/index.ts +244 -0
- package/src-bak/components/table/src/table-header/style.helper.ts +119 -0
- package/src-bak/components/table/src/table-header/utils-helper.ts +94 -0
- package/src-bak/components/table/src/table-layout.ts +259 -0
- package/src-bak/components/table/src/table.vue +389 -0
- package/src-bak/components/table/src/tableColumn.ts +3 -0
- package/src-bak/components/table/src/tokens.ts +5 -0
- package/src-bak/components/table/src/util.ts +521 -0
- package/src-bak/components/table/style/css.ts +5 -0
- package/src-bak/components/table/style/index.ts +5 -0
- package/src-bak/components/tabs/index.js +8 -0
- package/src-bak/components/tabs/src/constants.js +23 -0
- package/src-bak/components/tabs/src/tab-bar.js +8 -0
- package/src-bak/components/tabs/src/tab-bar.vue +92 -0
- package/src-bak/components/tabs/src/tab-nav.jsx +424 -0
- package/src-bak/components/tabs/src/tab-pane.js +16 -0
- package/src-bak/components/tabs/src/tab-pane.vue +80 -0
- package/src-bak/components/tabs/src/tabs.jsx +223 -0
- package/src-bak/components/tabs/style/css.js +2 -0
- package/src-bak/components/tabs/style/index.js +2 -0
- package/src-bak/components/thirdPartyFrame/index.js +32 -0
- package/src-bak/components/thirdPartyFrame/src/ThirdPartyFrame.vue +125 -0
- package/src-bak/enums/index.js +16 -0
- package/src-bak/hooks/configLoad.js +45 -0
- package/src-bak/hooks/index.js +189 -0
- package/src-bak/hooks/mock.js +6960 -0
- package/src-bak/hooks/pageConfig.js +127 -0
- package/src-bak/index.jsx +440 -0
- package/src-bak/renderer.jsx +77 -0
- package/src-bak/resolver-H5.vue +88 -0
- package/src-bak/resolver-common.vue +129 -0
- package/src-bak/resolver-web.vue +91 -0
- package/src-bak/rules/eventsSupplement.js +573 -0
- package/src-bak/rules/parseCondition.js +378 -0
- package/src-bak/rules/ruleUtils.js +273 -0
- package/src-bak/rules/rulesDriver.js +118 -0
- package/src-bak/rulesImp/events.js +588 -0
- package/src-bak/rulesImp/index.js +33 -0
- package/src-bak/rulesImp/ruleInstance.js +231 -0
- package/src-bak/rulesImp/ruleUtils.js +124 -0
- package/src-bak/theme/element/components/button.scss +122 -0
- package/src-bak/theme/element/components/card.scss +8 -0
- package/src-bak/theme/element/components/checkbox.scss +19 -0
- package/src-bak/theme/element/components/collapse.scss +174 -0
- package/src-bak/theme/element/components/common.scss +30 -0
- package/src-bak/theme/element/components/cycle.scss +0 -0
- package/src-bak/theme/element/components/date.scss +13 -0
- package/src-bak/theme/element/components/dialog.scss +44 -0
- package/src-bak/theme/element/components/form.scss +104 -0
- package/src-bak/theme/element/components/index.scss +55 -0
- package/src-bak/theme/element/components/input.scss +36 -0
- package/src-bak/theme/element/components/message.scss +48 -0
- package/src-bak/theme/element/components/pagination.scss +47 -0
- package/src-bak/theme/element/components/popper.scss +3 -0
- package/src-bak/theme/element/components/radio.scss +40 -0
- package/src-bak/theme/element/components/scrollbar.scss +14 -0
- package/src-bak/theme/element/components/select.scss +82 -0
- package/src-bak/theme/element/components/steps.scss +6 -0
- package/{src/components/styles/CustomComponenTable.scss → src-bak/theme/element/components/table.scss} +90 -13
- package/src-bak/theme/element/components/tabs.scss +128 -0
- package/src-bak/theme/element/components/tag.scss +6 -0
- package/{src/components/styles → src-bak/theme/element/components}/text.scss +3 -3
- package/src-bak/theme/element/components/textarea.scss +3 -0
- package/src-bak/theme/element/components/tree.scss +0 -0
- package/src-bak/theme/element/index.scss +55 -0
- package/src-bak/utils/cipher.js +141 -0
- package/src-bak/utils/common.js +664 -0
- package/src-bak/utils/const.js +259 -0
- package/src-bak/utils/defaultVal.js +92 -0
- package/src-bak/utils/dom.js +36 -0
- package/src-bak/utils/format.js +19 -0
- package/src-bak/utils/index.js +4 -0
- package/src-bak/utils/is.js +74 -0
- package/src-bak/utils/loadModule.js +75 -0
- package/src-bak/utils/preserveFunc.js +33 -0
- package/src-bak/utils/render.jsx +1138 -0
- package/src-bak/utils/request.js +136 -0
- package/src-bak/utils/respone.js +70 -0
- package/src-bak/utils/valid.js +89 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import {
|
|
3
|
+
defineComponent,
|
|
4
|
+
getCurrentInstance,
|
|
5
|
+
h,
|
|
6
|
+
inject,
|
|
7
|
+
onUnmounted,
|
|
8
|
+
watch,
|
|
9
|
+
} from 'vue'
|
|
10
|
+
import { addClass, isClient, rAF, removeClass } from 'element-plus/es/utils/index.mjs'
|
|
11
|
+
import { useNamespace } from 'element-plus/es/hooks/index.mjs'
|
|
12
|
+
import useLayoutObserver from '../layout-observer'
|
|
13
|
+
import { removePopper } from '../util'
|
|
14
|
+
import { TABLE_INJECTION_KEY } from '../tokens'
|
|
15
|
+
import useRender from './render-helper'
|
|
16
|
+
import defaultProps from './defaults'
|
|
17
|
+
|
|
18
|
+
import type { VNode } from 'vue'
|
|
19
|
+
|
|
20
|
+
export default defineComponent({
|
|
21
|
+
name: 'ElTableBody',
|
|
22
|
+
props: defaultProps,
|
|
23
|
+
setup(props) {
|
|
24
|
+
const instance = getCurrentInstance()
|
|
25
|
+
const parent = inject(TABLE_INJECTION_KEY)
|
|
26
|
+
const ns = useNamespace('table')
|
|
27
|
+
const { wrappedRowRender, tooltipContent, tooltipTrigger } =
|
|
28
|
+
useRender(props)
|
|
29
|
+
const { onColumnsChange, onScrollableChange } = useLayoutObserver(parent!)
|
|
30
|
+
|
|
31
|
+
const hoveredCellList = []
|
|
32
|
+
watch(props.store.states.hoverRow, (newVal: any, oldVal: any) => {
|
|
33
|
+
const el = instance?.vnode.el as HTMLElement
|
|
34
|
+
const rows = Array.from(el?.children || []).filter((e) =>
|
|
35
|
+
e?.classList.contains(`${ns.e('row')}`)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
// hover rowSpan > 1 choose the whole row
|
|
39
|
+
let rowNum = newVal
|
|
40
|
+
const childNodes = rows[rowNum]?.childNodes
|
|
41
|
+
if (childNodes?.length) {
|
|
42
|
+
let control = 0
|
|
43
|
+
const indexes = Array.from(childNodes).reduce((acc, item, index) => {
|
|
44
|
+
// drop colsSpan
|
|
45
|
+
if (childNodes[index]?.colSpan > 1) {
|
|
46
|
+
control = childNodes[index]?.colSpan
|
|
47
|
+
}
|
|
48
|
+
if (item.nodeName !== 'TD' && control === 0) {
|
|
49
|
+
acc.push(index)
|
|
50
|
+
}
|
|
51
|
+
control > 0 && control--
|
|
52
|
+
return acc
|
|
53
|
+
}, [])
|
|
54
|
+
|
|
55
|
+
indexes.forEach((rowIndex) => {
|
|
56
|
+
rowNum = newVal
|
|
57
|
+
while (rowNum > 0) {
|
|
58
|
+
// find from previous
|
|
59
|
+
const preChildNodes = rows[rowNum - 1]?.childNodes
|
|
60
|
+
if (
|
|
61
|
+
preChildNodes[rowIndex] &&
|
|
62
|
+
preChildNodes[rowIndex].nodeName === 'TD' &&
|
|
63
|
+
preChildNodes[rowIndex].rowSpan > 1
|
|
64
|
+
) {
|
|
65
|
+
addClass(preChildNodes[rowIndex], 'hover-cell')
|
|
66
|
+
hoveredCellList.push(preChildNodes[rowIndex])
|
|
67
|
+
break
|
|
68
|
+
}
|
|
69
|
+
rowNum--
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
} else {
|
|
73
|
+
hoveredCellList.forEach((item) => removeClass(item, 'hover-cell'))
|
|
74
|
+
hoveredCellList.length = 0
|
|
75
|
+
}
|
|
76
|
+
if (!props.store.states.isComplex.value || !isClient) return
|
|
77
|
+
|
|
78
|
+
rAF(() => {
|
|
79
|
+
// just get first level children; fix #9723
|
|
80
|
+
const oldRow = rows[oldVal]
|
|
81
|
+
const newRow = rows[newVal]
|
|
82
|
+
// when there is fixed row, hover on rowSpan > 1 should not clear the class
|
|
83
|
+
if (oldRow && !oldRow.classList.contains('hover-fixed-row')) {
|
|
84
|
+
removeClass(oldRow, 'hover-row')
|
|
85
|
+
}
|
|
86
|
+
if (newRow) {
|
|
87
|
+
addClass(newRow, 'hover-row')
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
onUnmounted(() => {
|
|
93
|
+
removePopper?.()
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
ns,
|
|
98
|
+
onColumnsChange,
|
|
99
|
+
onScrollableChange,
|
|
100
|
+
wrappedRowRender,
|
|
101
|
+
tooltipContent,
|
|
102
|
+
tooltipTrigger,
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
render() {
|
|
106
|
+
const { wrappedRowRender, store } = this
|
|
107
|
+
const data = store.states.data.value || []
|
|
108
|
+
// Why do we need tabIndex: -1 ?
|
|
109
|
+
// If you set the tabindex attribute on an element ,
|
|
110
|
+
// then its child content cannot be scrolled with the arrow keys,
|
|
111
|
+
// unless you set tabindex on the content too
|
|
112
|
+
// See https://github.com/facebook/react/issues/25462#issuecomment-1274775248 or https://developer.mozilla.org/zh-CN/docs/Web/HTML/Global_attributes/tabindex
|
|
113
|
+
return h('tbody', { tabIndex: -1 }, [
|
|
114
|
+
data.reduce((acc: VNode[], row) => {
|
|
115
|
+
return acc.concat(wrappedRowRender(row, acc.length))
|
|
116
|
+
}, []),
|
|
117
|
+
])
|
|
118
|
+
},
|
|
119
|
+
})
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { computed, h, inject } from 'vue'
|
|
3
|
+
import { merge } from 'lodash-unified'
|
|
4
|
+
import { useNamespace } from 'element-plus/es/hooks/index.mjs'
|
|
5
|
+
import { getRowIdentity } from '../util'
|
|
6
|
+
import { TABLE_INJECTION_KEY } from '../tokens'
|
|
7
|
+
import useEvents from './events-helper'
|
|
8
|
+
import useStyles from './styles-helper'
|
|
9
|
+
import type { TableBodyProps } from './defaults'
|
|
10
|
+
import type { RenderRowData, TableProps, TreeNode } from '../table/defaults'
|
|
11
|
+
|
|
12
|
+
function useRender<T>(props: Partial<TableBodyProps<T>>) {
|
|
13
|
+
const parent = inject(TABLE_INJECTION_KEY)
|
|
14
|
+
const ns = useNamespace('table')
|
|
15
|
+
const {
|
|
16
|
+
handleDoubleClick,
|
|
17
|
+
handleClick,
|
|
18
|
+
handleContextMenu,
|
|
19
|
+
handleMouseEnter,
|
|
20
|
+
handleMouseLeave,
|
|
21
|
+
handleCellMouseEnter,
|
|
22
|
+
handleCellMouseLeave,
|
|
23
|
+
tooltipContent,
|
|
24
|
+
tooltipTrigger,
|
|
25
|
+
} = useEvents(props)
|
|
26
|
+
const {
|
|
27
|
+
getRowStyle,
|
|
28
|
+
getRowClass,
|
|
29
|
+
getCellStyle,
|
|
30
|
+
getCellClass,
|
|
31
|
+
getSpan,
|
|
32
|
+
getColspanRealWidth,
|
|
33
|
+
} = useStyles(props)
|
|
34
|
+
const firstDefaultColumnIndex = computed(() => {
|
|
35
|
+
return props.store.states.columns.value.findIndex(
|
|
36
|
+
({ type }) => type === 'default'
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
const getKeyOfRow = (row: T, index: number) => {
|
|
40
|
+
const rowKey = (parent.props as Partial<TableProps<T>>).rowKey
|
|
41
|
+
if (rowKey) {
|
|
42
|
+
return getRowIdentity(row, rowKey)
|
|
43
|
+
}
|
|
44
|
+
return index
|
|
45
|
+
}
|
|
46
|
+
const rowRender = (
|
|
47
|
+
row: T,
|
|
48
|
+
$index: number,
|
|
49
|
+
treeRowData?: TreeNode,
|
|
50
|
+
expanded = false
|
|
51
|
+
) => {
|
|
52
|
+
const { tooltipEffect, tooltipOptions, store } = props
|
|
53
|
+
const { indent, columns } = store.states
|
|
54
|
+
const rowClasses = getRowClass(row, $index)
|
|
55
|
+
let display = true
|
|
56
|
+
if (treeRowData) {
|
|
57
|
+
rowClasses.push(ns.em('row', `level-${treeRowData.level}`))
|
|
58
|
+
display = treeRowData.display
|
|
59
|
+
}
|
|
60
|
+
const displayStyle = display
|
|
61
|
+
? null
|
|
62
|
+
: {
|
|
63
|
+
display: 'none',
|
|
64
|
+
}
|
|
65
|
+
return h(
|
|
66
|
+
'tr',
|
|
67
|
+
{
|
|
68
|
+
style: [displayStyle, getRowStyle(row, $index)],
|
|
69
|
+
class: rowClasses,
|
|
70
|
+
key: getKeyOfRow(row, $index),
|
|
71
|
+
onDblclick: ($event) => handleDoubleClick($event, row),
|
|
72
|
+
onClick: ($event) => handleClick($event, row),
|
|
73
|
+
onContextmenu: ($event) => handleContextMenu($event, row),
|
|
74
|
+
onMouseenter: () => handleMouseEnter($index),
|
|
75
|
+
onMouseleave: handleMouseLeave,
|
|
76
|
+
},
|
|
77
|
+
columns.value.map((column, cellIndex) => {
|
|
78
|
+
const { rowspan, colspan } = getSpan(row, column, $index, cellIndex)
|
|
79
|
+
if (!rowspan || !colspan) {
|
|
80
|
+
return null
|
|
81
|
+
}
|
|
82
|
+
const columnData = Object.assign({}, column)
|
|
83
|
+
columnData.realWidth = getColspanRealWidth(
|
|
84
|
+
columns.value,
|
|
85
|
+
colspan,
|
|
86
|
+
cellIndex
|
|
87
|
+
)
|
|
88
|
+
const data: RenderRowData<T> = {
|
|
89
|
+
store: props.store,
|
|
90
|
+
_self: props.context || parent,
|
|
91
|
+
column: columnData,
|
|
92
|
+
row,
|
|
93
|
+
$index,
|
|
94
|
+
cellIndex,
|
|
95
|
+
expanded,
|
|
96
|
+
}
|
|
97
|
+
if (cellIndex === firstDefaultColumnIndex.value && treeRowData) {
|
|
98
|
+
data.treeNode = {
|
|
99
|
+
indent: treeRowData.level * indent.value,
|
|
100
|
+
level: treeRowData.level,
|
|
101
|
+
}
|
|
102
|
+
if (typeof treeRowData.expanded === 'boolean') {
|
|
103
|
+
data.treeNode.expanded = treeRowData.expanded
|
|
104
|
+
// 表明是懒加载
|
|
105
|
+
if ('loading' in treeRowData) {
|
|
106
|
+
data.treeNode.loading = treeRowData.loading
|
|
107
|
+
}
|
|
108
|
+
if ('noLazyChildren' in treeRowData) {
|
|
109
|
+
data.treeNode.noLazyChildren = treeRowData.noLazyChildren
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const baseKey = `${getKeyOfRow(row, $index)},${cellIndex}`
|
|
114
|
+
const patchKey = columnData.columnKey || columnData.rawColumnKey || ''
|
|
115
|
+
const tdChildren = cellChildren(cellIndex, column, data)
|
|
116
|
+
|
|
117
|
+
let mergedTooltipOptions =
|
|
118
|
+
column.showOverflowTooltip &&
|
|
119
|
+
merge(
|
|
120
|
+
{
|
|
121
|
+
effect: tooltipEffect,
|
|
122
|
+
},
|
|
123
|
+
tooltipOptions,
|
|
124
|
+
column.showOverflowTooltip
|
|
125
|
+
)
|
|
126
|
+
if (typeof column.showOverflowTooltip === 'function') {
|
|
127
|
+
mergedTooltipOptions.showOverflowTooltip = () => {
|
|
128
|
+
return column.showOverflowTooltip(data)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return h(
|
|
132
|
+
'td',
|
|
133
|
+
{
|
|
134
|
+
style: getCellStyle($index, cellIndex, row, column),
|
|
135
|
+
class: getCellClass($index, cellIndex, row, column, colspan - 1),
|
|
136
|
+
key: `${patchKey}${baseKey}`,
|
|
137
|
+
rowspan,
|
|
138
|
+
colspan,
|
|
139
|
+
onMouseenter: ($event) =>
|
|
140
|
+
handleCellMouseEnter($event, row, mergedTooltipOptions),
|
|
141
|
+
onMouseleave: handleCellMouseLeave,
|
|
142
|
+
},
|
|
143
|
+
[tdChildren]
|
|
144
|
+
)
|
|
145
|
+
})
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
const cellChildren = (cellIndex, column, data) => {
|
|
149
|
+
return column.renderCell(data)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const wrappedRowRender = (row: T, $index: number) => {
|
|
153
|
+
const store = props.store
|
|
154
|
+
const { isRowExpanded, assertRowKey } = store
|
|
155
|
+
const { treeData, lazyTreeNodeMap, childrenColumnName, rowKey } =
|
|
156
|
+
store.states
|
|
157
|
+
const columns = store.states.columns.value
|
|
158
|
+
const hasExpandColumn = columns.some(({ type }) => type === 'expand')
|
|
159
|
+
if (hasExpandColumn) {
|
|
160
|
+
const expanded = isRowExpanded(row)
|
|
161
|
+
const tr = rowRender(row, $index, undefined, expanded)
|
|
162
|
+
const renderExpanded = parent.renderExpanded
|
|
163
|
+
if (expanded) {
|
|
164
|
+
if (!renderExpanded) {
|
|
165
|
+
console.error('[Element Error]renderExpanded is required.')
|
|
166
|
+
return tr
|
|
167
|
+
}
|
|
168
|
+
// 使用二维数组,避免修改 $index
|
|
169
|
+
// Use a matrix to avoid modifying $index
|
|
170
|
+
return [
|
|
171
|
+
[
|
|
172
|
+
tr,
|
|
173
|
+
h(
|
|
174
|
+
'tr',
|
|
175
|
+
{
|
|
176
|
+
key: `expanded-row__${tr.key as string}`,
|
|
177
|
+
},
|
|
178
|
+
[
|
|
179
|
+
h(
|
|
180
|
+
'td',
|
|
181
|
+
{
|
|
182
|
+
colspan: columns.length,
|
|
183
|
+
class: `${ns.e('cell')} ${ns.e('expanded-cell')}`,
|
|
184
|
+
},
|
|
185
|
+
[renderExpanded({ row, $index, store, expanded })]
|
|
186
|
+
),
|
|
187
|
+
]
|
|
188
|
+
),
|
|
189
|
+
],
|
|
190
|
+
]
|
|
191
|
+
} else {
|
|
192
|
+
// 使用二维数组,避免修改 $index
|
|
193
|
+
// Use a two dimensional array avoid modifying $index
|
|
194
|
+
return [[tr]]
|
|
195
|
+
}
|
|
196
|
+
} else if (Object.keys(treeData.value).length) {
|
|
197
|
+
assertRowKey()
|
|
198
|
+
// TreeTable 时,rowKey 必须由用户设定,不使用 getKeyOfRow 计算
|
|
199
|
+
// 在调用 rowRender 函数时,仍然会计算 rowKey,不太好的操作
|
|
200
|
+
const key = getRowIdentity(row, rowKey.value)
|
|
201
|
+
let cur = treeData.value[key]
|
|
202
|
+
let treeRowData = null
|
|
203
|
+
if (cur) {
|
|
204
|
+
treeRowData = {
|
|
205
|
+
expanded: cur.expanded,
|
|
206
|
+
level: cur.level,
|
|
207
|
+
display: true,
|
|
208
|
+
}
|
|
209
|
+
if (typeof cur.lazy === 'boolean') {
|
|
210
|
+
if (typeof cur.loaded === 'boolean' && cur.loaded) {
|
|
211
|
+
treeRowData.noLazyChildren = !(cur.children && cur.children.length)
|
|
212
|
+
}
|
|
213
|
+
treeRowData.loading = cur.loading
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const tmp = [rowRender(row, $index, treeRowData)]
|
|
217
|
+
// 渲染嵌套数据
|
|
218
|
+
if (cur) {
|
|
219
|
+
// currentRow 记录的是 index,所以还需主动增加 TreeTable 的 index
|
|
220
|
+
let i = 0
|
|
221
|
+
const traverse = (children, parent) => {
|
|
222
|
+
if (!(children && children.length && parent)) return
|
|
223
|
+
children.forEach((node) => {
|
|
224
|
+
// 父节点的 display 状态影响子节点的显示状态
|
|
225
|
+
const innerTreeRowData = {
|
|
226
|
+
display: parent.display && parent.expanded,
|
|
227
|
+
level: parent.level + 1,
|
|
228
|
+
expanded: false,
|
|
229
|
+
noLazyChildren: false,
|
|
230
|
+
loading: false,
|
|
231
|
+
}
|
|
232
|
+
const childKey = getRowIdentity(node, rowKey.value)
|
|
233
|
+
if (childKey === undefined || childKey === null) {
|
|
234
|
+
throw new Error('For nested data item, row-key is required.')
|
|
235
|
+
}
|
|
236
|
+
cur = { ...treeData.value[childKey] }
|
|
237
|
+
// 对于当前节点,分成有无子节点两种情况。
|
|
238
|
+
// 如果包含子节点的,设置 expanded 属性。
|
|
239
|
+
// 对于它子节点的 display 属性由它本身的 expanded 与 display 共同决定。
|
|
240
|
+
if (cur) {
|
|
241
|
+
innerTreeRowData.expanded = cur.expanded
|
|
242
|
+
// 懒加载的某些节点,level 未知
|
|
243
|
+
cur.level = cur.level || innerTreeRowData.level
|
|
244
|
+
cur.display = !!(cur.expanded && innerTreeRowData.display)
|
|
245
|
+
if (typeof cur.lazy === 'boolean') {
|
|
246
|
+
if (typeof cur.loaded === 'boolean' && cur.loaded) {
|
|
247
|
+
innerTreeRowData.noLazyChildren = !(
|
|
248
|
+
cur.children && cur.children.length
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
innerTreeRowData.loading = cur.loading
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
i++
|
|
255
|
+
tmp.push(rowRender(node, $index + i, innerTreeRowData))
|
|
256
|
+
if (cur) {
|
|
257
|
+
const nodes =
|
|
258
|
+
lazyTreeNodeMap.value[childKey] ||
|
|
259
|
+
node[childrenColumnName.value]
|
|
260
|
+
traverse(nodes, cur)
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
// 对于 root 节点,display 一定为 true
|
|
265
|
+
cur.display = true
|
|
266
|
+
const nodes =
|
|
267
|
+
lazyTreeNodeMap.value[key] || row[childrenColumnName.value]
|
|
268
|
+
traverse(nodes, cur)
|
|
269
|
+
}
|
|
270
|
+
return tmp
|
|
271
|
+
} else {
|
|
272
|
+
return rowRender(row, $index, undefined)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
wrappedRowRender,
|
|
278
|
+
tooltipContent,
|
|
279
|
+
tooltipTrigger,
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export default useRender
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { inject } from 'vue'
|
|
3
|
+
import { useNamespace } from 'element-plus/es/hooks/index.mjs'
|
|
4
|
+
import {
|
|
5
|
+
ensurePosition,
|
|
6
|
+
getFixedColumnOffset,
|
|
7
|
+
getFixedColumnsClass,
|
|
8
|
+
} from '../util'
|
|
9
|
+
import { TABLE_INJECTION_KEY } from '../tokens'
|
|
10
|
+
import type { TableColumnCtx } from '../table-column/defaults'
|
|
11
|
+
import type { TableBodyProps } from './defaults'
|
|
12
|
+
|
|
13
|
+
function useStyles<T>(props: Partial<TableBodyProps<T>>) {
|
|
14
|
+
const parent = inject(TABLE_INJECTION_KEY)
|
|
15
|
+
const ns = useNamespace('table')
|
|
16
|
+
|
|
17
|
+
const getRowStyle = (row: T, rowIndex: number) => {
|
|
18
|
+
const rowStyle = parent?.props.rowStyle
|
|
19
|
+
if (typeof rowStyle === 'function') {
|
|
20
|
+
return rowStyle.call(null, {
|
|
21
|
+
row,
|
|
22
|
+
rowIndex,
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
return rowStyle || null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const getRowClass = (row: T, rowIndex: number) => {
|
|
29
|
+
const classes = [ns.e('row')]
|
|
30
|
+
if (
|
|
31
|
+
parent?.props.highlightCurrentRow &&
|
|
32
|
+
row === props.store.states.currentRow.value
|
|
33
|
+
) {
|
|
34
|
+
classes.push('current-row')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (props.stripe && rowIndex % 2 === 1) {
|
|
38
|
+
classes.push(ns.em('row', 'striped'))
|
|
39
|
+
}
|
|
40
|
+
const rowClassName = parent?.props.rowClassName
|
|
41
|
+
if (typeof rowClassName === 'string') {
|
|
42
|
+
classes.push(rowClassName)
|
|
43
|
+
} else if (typeof rowClassName === 'function') {
|
|
44
|
+
classes.push(
|
|
45
|
+
rowClassName.call(null, {
|
|
46
|
+
row,
|
|
47
|
+
rowIndex,
|
|
48
|
+
})
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
return classes
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const getCellStyle = (
|
|
55
|
+
rowIndex: number,
|
|
56
|
+
columnIndex: number,
|
|
57
|
+
row: T,
|
|
58
|
+
column: TableColumnCtx<T>
|
|
59
|
+
) => {
|
|
60
|
+
const cellStyle = parent?.props.cellStyle
|
|
61
|
+
let cellStyles = cellStyle ?? {}
|
|
62
|
+
if (typeof cellStyle === 'function') {
|
|
63
|
+
cellStyles = cellStyle.call(null, {
|
|
64
|
+
rowIndex,
|
|
65
|
+
columnIndex,
|
|
66
|
+
row,
|
|
67
|
+
column,
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
const fixedStyle = getFixedColumnOffset(
|
|
71
|
+
columnIndex,
|
|
72
|
+
props?.fixed,
|
|
73
|
+
props.store
|
|
74
|
+
)
|
|
75
|
+
ensurePosition(fixedStyle, 'left')
|
|
76
|
+
ensurePosition(fixedStyle, 'right')
|
|
77
|
+
return Object.assign({}, cellStyles, fixedStyle)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const getCellClass = (
|
|
81
|
+
rowIndex: number,
|
|
82
|
+
columnIndex: number,
|
|
83
|
+
row: T,
|
|
84
|
+
column: TableColumnCtx<T>,
|
|
85
|
+
offset: number
|
|
86
|
+
) => {
|
|
87
|
+
const fixedClasses = getFixedColumnsClass(
|
|
88
|
+
ns.b(),
|
|
89
|
+
columnIndex,
|
|
90
|
+
props?.fixed,
|
|
91
|
+
props.store,
|
|
92
|
+
undefined,
|
|
93
|
+
offset
|
|
94
|
+
)
|
|
95
|
+
const classes = [column.id, column.align, column.className, ...fixedClasses]
|
|
96
|
+
const cellClassName = parent?.props.cellClassName
|
|
97
|
+
if (typeof cellClassName === 'string') {
|
|
98
|
+
classes.push(cellClassName)
|
|
99
|
+
} else if (typeof cellClassName === 'function') {
|
|
100
|
+
classes.push(
|
|
101
|
+
cellClassName.call(null, {
|
|
102
|
+
rowIndex,
|
|
103
|
+
columnIndex,
|
|
104
|
+
row,
|
|
105
|
+
column,
|
|
106
|
+
})
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
classes.push(ns.e('cell'))
|
|
110
|
+
return classes.filter((className) => Boolean(className)).join(' ')
|
|
111
|
+
}
|
|
112
|
+
const getSpan = (
|
|
113
|
+
row: T,
|
|
114
|
+
column: TableColumnCtx<T>,
|
|
115
|
+
rowIndex: number,
|
|
116
|
+
columnIndex: number
|
|
117
|
+
) => {
|
|
118
|
+
let rowspan = 1
|
|
119
|
+
let colspan = 1
|
|
120
|
+
const fn = parent?.props.spanMethod
|
|
121
|
+
if (typeof fn === 'function') {
|
|
122
|
+
const result = fn({
|
|
123
|
+
row,
|
|
124
|
+
column,
|
|
125
|
+
rowIndex,
|
|
126
|
+
columnIndex,
|
|
127
|
+
})
|
|
128
|
+
if (Array.isArray(result)) {
|
|
129
|
+
rowspan = result[0]
|
|
130
|
+
colspan = result[1]
|
|
131
|
+
} else if (typeof result === 'object') {
|
|
132
|
+
rowspan = result.rowspan
|
|
133
|
+
colspan = result.colspan
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return { rowspan, colspan }
|
|
137
|
+
}
|
|
138
|
+
const getColspanRealWidth = (
|
|
139
|
+
columns: TableColumnCtx<T>[],
|
|
140
|
+
colspan: number,
|
|
141
|
+
index: number
|
|
142
|
+
): number => {
|
|
143
|
+
if (colspan < 1) {
|
|
144
|
+
return columns[index].realWidth
|
|
145
|
+
}
|
|
146
|
+
const widthArr = columns
|
|
147
|
+
.map(({ realWidth, width }) => realWidth || width)
|
|
148
|
+
.slice(index, index + colspan)
|
|
149
|
+
return Number(
|
|
150
|
+
widthArr.reduce((acc, width) => Number(acc) + Number(width), -1)
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
getRowStyle,
|
|
156
|
+
getRowClass,
|
|
157
|
+
getCellStyle,
|
|
158
|
+
getCellClass,
|
|
159
|
+
getSpan,
|
|
160
|
+
getColspanRealWidth,
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export default useStyles
|