resolver-egretimp-plus 0.1.119 → 0.1.121
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 +18 -18
- package/dist/web/index.js +11 -11
- package/package.json +1 -1
- package/src/components/options/OptionsDefault.vue +0 -1
- package/src/components/packages-web/CustomComponentCycle.vue +38 -33
- package/src/components/packages-web/CustomComponentCycleTabPane.vue +40 -33
- package/src/components/packages-web/CustomComponentPlain.vue +6 -5
- package/src/components/packages-web/CustomComponentTable.jsx +48 -40
- package/src/components/packages-web/ElInput copy.jsx +0 -1
- package/src/components/packages-web/ElInput.jsx +0 -1
- package/src/config.js +2 -0
- package/src/hooks/pageConfig.js +10 -4
- package/src/index.jsx +15 -10
- package/src/renderer.jsx +4 -1
- package/src/resolver-common.vue +22 -2
- package/src/rules/rulesDriver.js +4 -0
- package/src/utils/common.js +13 -0
- package/src/utils/render.jsx +196 -96
- package/src-bak/analysisComponent.jsx +0 -343
- package/src-bak/api/builtIn.js +0 -10
- package/src-bak/bpm/bpmInstance.js +0 -388
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/application.js +0 -8
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/component.js +0 -97
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/datasource.js +0 -88
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/iframe/index.js +0 -3
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/iframe/udcSdkForIframe/UdcComponent.js +0 -76
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/iframe/udcSdkForIframe/index.js +0 -201
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/index.js +0 -69
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/page.js +0 -56
- package/src-bak/bpm/udc-sdk-esm/cjs/impl/utils.js +0 -76
- package/src-bak/bpm/udc-sdk-esm/cjs/index.js +0 -46
- package/src-bak/bpm/udc-sdk-esm/cjs/utils.js +0 -21
- package/src-bak/components/childDialog/index.js +0 -39
- package/src-bak/components/childDialog/src/index.vue +0 -185
- package/src-bak/components/cmiFormItem/index.js +0 -1
- package/src-bak/components/cmiFormItem/src/index.vue +0 -112
- package/src-bak/components/confirmInstance-H5/index.js +0 -53
- package/src-bak/components/confirmInstance-H5/src/index.vue +0 -54
- package/src-bak/components/helper/FormPolyfill.jsx +0 -25
- package/src-bak/components/helper/calcTooltip.jsx +0 -134
- package/src-bak/components/helper/dock.js +0 -141
- package/src-bak/components/helper/eventOrchestration.js +0 -763
- package/src-bak/components/helper/resolver.js +0 -163
- package/src-bak/components/helper/table.jsx +0 -103
- package/src-bak/components/icons/date.vue +0 -33
- package/src-bak/components/icons/info.vue +0 -62
- package/src-bak/components/icons/loading.vue +0 -19
- package/src-bak/components/icons/question-filled.vue +0 -8
- package/src-bak/components/loading/index.js +0 -6
- package/src-bak/components/loading/loading.js +0 -98
- package/src-bak/components/loading/loading.scss +0 -74
- package/src-bak/components/loading/loading.vue +0 -89
- package/src-bak/components/loadingComponent/LoadingComponent.vue +0 -33
- package/src-bak/components/modal/index.js +0 -9
- package/src-bak/components/modal/modal.scss +0 -195
- package/src-bak/components/modal/modal.vue +0 -201
- package/src-bak/components/options/OptionsDefault.vue +0 -47
- package/src-bak/components/packages-H5/CmiButton.vue +0 -120
- package/src-bak/components/packages-H5/CmiCalendar.vue +0 -152
- package/src-bak/components/packages-H5/CmiCell.vue +0 -87
- package/src-bak/components/packages-H5/CmiCheckbox.vue +0 -82
- package/src-bak/components/packages-H5/CmiDatetimePicker.vue +0 -98
- package/src-bak/components/packages-H5/CmiDivider.vue +0 -30
- package/src-bak/components/packages-H5/CmiDropdownMenu.vue +0 -58
- package/src-bak/components/packages-H5/CmiInput.vue +0 -69
- package/src-bak/components/packages-H5/CmiLink.vue +0 -28
- package/src-bak/components/packages-H5/CmiPicker.vue +0 -229
- package/src-bak/components/packages-H5/CmiRadio.vue +0 -29
- package/src-bak/components/packages-H5/CmiSearch.vue +0 -39
- package/src-bak/components/packages-H5/CmiSelect.vue +0 -84
- package/src-bak/components/packages-H5/CustomComponentCardH5.vue +0 -129
- package/src-bak/components/packages-H5/CustomComponentColH5.vue +0 -8
- package/src-bak/components/packages-H5/CustomComponentCollapseH5.vue +0 -141
- package/src-bak/components/packages-H5/CustomComponentFormLayoutH5.vue +0 -54
- package/src-bak/components/packages-H5/CustomComponentTabPaneH5.vue +0 -38
- package/src-bak/components/packages-H5/CustomComponentTableH5.vue +0 -352
- package/src-bak/components/packages-H5/CustomComponentTabsH5.vue +0 -170
- package/src-bak/components/packages-web/CustomComponentCard.vue +0 -40
- package/src-bak/components/packages-web/CustomComponentCol.vue +0 -66
- package/src-bak/components/packages-web/CustomComponentCollapse.vue +0 -164
- package/src-bak/components/packages-web/CustomComponentCycle.vue +0 -95
- package/src-bak/components/packages-web/CustomComponentCycleTabPane.vue +0 -155
- package/src-bak/components/packages-web/CustomComponentDialog.vue +0 -192
- package/src-bak/components/packages-web/CustomComponentEditor.vue +0 -50
- package/src-bak/components/packages-web/CustomComponentFileExport.vue +0 -60
- package/src-bak/components/packages-web/CustomComponentFileImport.vue +0 -60
- package/src-bak/components/packages-web/CustomComponentFormLayout.vue +0 -65
- package/src-bak/components/packages-web/CustomComponentGrid.vue +0 -29
- package/src-bak/components/packages-web/CustomComponentGridCol.vue +0 -29
- package/src-bak/components/packages-web/CustomComponentInputDialog.vue +0 -144
- package/src-bak/components/packages-web/CustomComponentNativeTabPane.vue +0 -84
- package/src-bak/components/packages-web/CustomComponentPlain.vue +0 -247
- package/src-bak/components/packages-web/CustomComponentRow.vue +0 -83
- package/src-bak/components/packages-web/CustomComponentSelectEmployees.vue +0 -203
- package/src-bak/components/packages-web/CustomComponentSendMail.vue +0 -62
- package/src-bak/components/packages-web/CustomComponentSteps.vue +0 -41
- package/src-bak/components/packages-web/CustomComponentTabPane.vue +0 -20
- package/src-bak/components/packages-web/CustomComponentTable.jsx +0 -814
- package/src-bak/components/packages-web/CustomComponentTabs.vue +0 -126
- package/src-bak/components/packages-web/CustomComponentTree.vue +0 -28
- package/src-bak/components/packages-web/ElButton.vue +0 -146
- package/src-bak/components/packages-web/ElCheckbox.vue +0 -97
- package/src-bak/components/packages-web/ElDatePicker.vue +0 -93
- package/src-bak/components/packages-web/ElInput copy.jsx +0 -393
- package/src-bak/components/packages-web/ElInput.jsx +0 -312
- package/src-bak/components/packages-web/ElInputNumber.vue +0 -81
- package/src-bak/components/packages-web/ElPagination.vue +0 -61
- package/src-bak/components/packages-web/ElRadio.vue +0 -47
- package/src-bak/components/packages-web/ElSelect.jsx +0 -249
- package/src-bak/components/packages-web/ElSelect_bak.vue +0 -155
- package/src-bak/components/packages-web/ElText.jsx +0 -187
- package/src-bak/components/packages-web/ElTextaa.vue +0 -169
- package/src-bak/components/packages-web/ElTimePicker.vue +0 -39
- package/src-bak/components/patchComponents-H5.js +0 -46
- package/src-bak/components/patchComponents-web.js +0 -46
- package/src-bak/components/simpleFormItemPc/index.js +0 -1
- package/src-bak/components/simpleFormItemPc/src/index.vue +0 -94
- package/src-bak/components/table/index.ts +0 -29
- package/src-bak/components/table/src/composables/use-scrollbar.ts +0 -30
- package/src-bak/components/table/src/config.ts +0 -256
- package/src-bak/components/table/src/filter-panel.vue +0 -260
- package/src-bak/components/table/src/h-helper.ts +0 -34
- package/src-bak/components/table/src/layout-observer.ts +0 -78
- package/src-bak/components/table/src/store/current.ts +0 -85
- package/src-bak/components/table/src/store/expand.ts +0 -76
- package/src-bak/components/table/src/store/helper.ts +0 -74
- package/src-bak/components/table/src/store/index.ts +0 -246
- package/src-bak/components/table/src/store/tree.ts +0 -230
- package/src-bak/components/table/src/store/watcher.ts +0 -543
- package/src-bak/components/table/src/table/defaults.ts +0 -402
- package/src-bak/components/table/src/table/key-render-helper.ts +0 -27
- package/src-bak/components/table/src/table/style-helper.ts +0 -378
- package/src-bak/components/table/src/table/utils-helper.ts +0 -47
- package/src-bak/components/table/src/table-body/defaults.ts +0 -52
- package/src-bak/components/table/src/table-body/events-helper.ts +0 -203
- package/src-bak/components/table/src/table-body/index.ts +0 -119
- package/src-bak/components/table/src/table-body/render-helper.ts +0 -283
- package/src-bak/components/table/src/table-body/styles-helper.ts +0 -164
- package/src-bak/components/table/src/table-column/defaults.ts +0 -237
- package/src-bak/components/table/src/table-column/index.ts +0 -202
- package/src-bak/components/table/src/table-column/render-helper.ts +0 -214
- package/src-bak/components/table/src/table-column/watcher-helper.ts +0 -88
- package/src-bak/components/table/src/table-footer/index.ts +0 -128
- package/src-bak/components/table/src/table-footer/mapState-helper.ts +0 -33
- package/src-bak/components/table/src/table-footer/style-helper.ts +0 -51
- package/src-bak/components/table/src/table-header/event-helper.ts +0 -213
- package/src-bak/components/table/src/table-header/index.ts +0 -244
- package/src-bak/components/table/src/table-header/style.helper.ts +0 -119
- package/src-bak/components/table/src/table-header/utils-helper.ts +0 -94
- package/src-bak/components/table/src/table-layout.ts +0 -259
- package/src-bak/components/table/src/table.vue +0 -389
- package/src-bak/components/table/src/tableColumn.ts +0 -3
- package/src-bak/components/table/src/tokens.ts +0 -5
- package/src-bak/components/table/src/util.ts +0 -521
- package/src-bak/components/table/style/css.ts +0 -5
- package/src-bak/components/table/style/index.ts +0 -5
- package/src-bak/components/tabs/index.js +0 -8
- package/src-bak/components/tabs/src/constants.js +0 -23
- package/src-bak/components/tabs/src/tab-bar.js +0 -8
- package/src-bak/components/tabs/src/tab-bar.vue +0 -92
- package/src-bak/components/tabs/src/tab-nav.jsx +0 -424
- package/src-bak/components/tabs/src/tab-pane.js +0 -16
- package/src-bak/components/tabs/src/tab-pane.vue +0 -80
- package/src-bak/components/tabs/src/tabs.jsx +0 -223
- package/src-bak/components/tabs/style/css.js +0 -2
- package/src-bak/components/tabs/style/index.js +0 -2
- package/src-bak/components/thirdPartyFrame/index.js +0 -32
- package/src-bak/components/thirdPartyFrame/src/ThirdPartyFrame.vue +0 -125
- package/src-bak/enums/index.js +0 -16
- package/src-bak/hooks/configLoad.js +0 -45
- package/src-bak/hooks/index.js +0 -189
- package/src-bak/hooks/mock.js +0 -6960
- package/src-bak/hooks/pageConfig.js +0 -127
- package/src-bak/index.jsx +0 -443
- package/src-bak/renderer.jsx +0 -77
- package/src-bak/resolver-H5.vue +0 -88
- package/src-bak/resolver-common.vue +0 -129
- package/src-bak/resolver-web.vue +0 -91
- package/src-bak/rules/eventsSupplement.js +0 -573
- package/src-bak/rules/parseCondition.js +0 -378
- package/src-bak/rules/ruleUtils.js +0 -273
- package/src-bak/rules/rulesDriver.js +0 -139
- package/src-bak/rulesImp/events.js +0 -588
- package/src-bak/rulesImp/index.js +0 -33
- package/src-bak/rulesImp/ruleInstance.js +0 -231
- package/src-bak/rulesImp/ruleUtils.js +0 -124
- package/src-bak/theme/element/components/button.scss +0 -122
- package/src-bak/theme/element/components/card.scss +0 -8
- package/src-bak/theme/element/components/checkbox.scss +0 -19
- package/src-bak/theme/element/components/collapse.scss +0 -174
- package/src-bak/theme/element/components/common.scss +0 -30
- package/src-bak/theme/element/components/cycle.scss +0 -0
- package/src-bak/theme/element/components/date.scss +0 -13
- package/src-bak/theme/element/components/dialog.scss +0 -44
- package/src-bak/theme/element/components/form.scss +0 -104
- package/src-bak/theme/element/components/index.scss +0 -55
- package/src-bak/theme/element/components/input.scss +0 -36
- package/src-bak/theme/element/components/message.scss +0 -48
- package/src-bak/theme/element/components/pagination.scss +0 -47
- package/src-bak/theme/element/components/popper.scss +0 -3
- package/src-bak/theme/element/components/radio.scss +0 -40
- package/src-bak/theme/element/components/scrollbar.scss +0 -14
- package/src-bak/theme/element/components/select.scss +0 -82
- package/src-bak/theme/element/components/steps.scss +0 -6
- package/src-bak/theme/element/components/table.scss +0 -218
- package/src-bak/theme/element/components/tabs.scss +0 -128
- package/src-bak/theme/element/components/tag.scss +0 -6
- package/src-bak/theme/element/components/text.scss +0 -20
- package/src-bak/theme/element/components/textarea.scss +0 -3
- package/src-bak/theme/element/components/tree.scss +0 -0
- package/src-bak/theme/element/index.scss +0 -55
- package/src-bak/utils/cipher.js +0 -141
- package/src-bak/utils/common.js +0 -664
- package/src-bak/utils/const.js +0 -259
- package/src-bak/utils/defaultVal.js +0 -92
- package/src-bak/utils/dom.js +0 -36
- package/src-bak/utils/format.js +0 -19
- package/src-bak/utils/index.js +0 -4
- package/src-bak/utils/is.js +0 -74
- package/src-bak/utils/loadModule.js +0 -75
- package/src-bak/utils/preserveFunc.js +0 -33
- package/src-bak/utils/render.jsx +0 -1138
- package/src-bak/utils/request.js +0 -136
- package/src-bak/utils/respone.js +0 -70
- package/src-bak/utils/valid.js +0 -89
|
@@ -1,543 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import { getCurrentInstance, ref, toRefs, unref, watch } from 'vue'
|
|
3
|
-
import { hasOwn } from 'element-plus/es/utils/index.mjs'
|
|
4
|
-
import {
|
|
5
|
-
getColumnById,
|
|
6
|
-
getColumnByKey,
|
|
7
|
-
getKeysMap,
|
|
8
|
-
getRowIdentity,
|
|
9
|
-
orderBy,
|
|
10
|
-
toggleRowStatus,
|
|
11
|
-
} from '../util'
|
|
12
|
-
import useExpand from './expand'
|
|
13
|
-
import useCurrent from './current'
|
|
14
|
-
import useTree from './tree'
|
|
15
|
-
|
|
16
|
-
import type { Ref } from 'vue'
|
|
17
|
-
import type { TableColumnCtx } from '../table-column/defaults'
|
|
18
|
-
import type { Table, TableRefs } from '../table/defaults'
|
|
19
|
-
import type { StoreFilter } from '.'
|
|
20
|
-
|
|
21
|
-
const sortData = (data, states) => {
|
|
22
|
-
const sortingColumn = states.sortingColumn
|
|
23
|
-
if (!sortingColumn || typeof sortingColumn.sortable === 'string') {
|
|
24
|
-
return data
|
|
25
|
-
}
|
|
26
|
-
return orderBy(
|
|
27
|
-
data,
|
|
28
|
-
states.sortProp,
|
|
29
|
-
states.sortOrder,
|
|
30
|
-
sortingColumn.sortMethod,
|
|
31
|
-
sortingColumn.sortBy
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const doFlattenColumns = (columns) => {
|
|
36
|
-
const result = []
|
|
37
|
-
columns.forEach((column) => {
|
|
38
|
-
if (column.children && column.children.length > 0) {
|
|
39
|
-
// eslint-disable-next-line prefer-spread
|
|
40
|
-
result.push.apply(result, doFlattenColumns(column.children))
|
|
41
|
-
} else {
|
|
42
|
-
result.push(column)
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
return result
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function useWatcher<T>() {
|
|
49
|
-
const instance = getCurrentInstance() as Table<T>
|
|
50
|
-
const { size: tableSize } = toRefs(instance.proxy?.$props as any)
|
|
51
|
-
const rowKey: Ref<string> = ref(null)
|
|
52
|
-
const data: Ref<T[]> = ref([])
|
|
53
|
-
const _data: Ref<T[]> = ref([])
|
|
54
|
-
const isComplex = ref(false)
|
|
55
|
-
const _columns: Ref<TableColumnCtx<T>[]> = ref([])
|
|
56
|
-
const originColumns: Ref<TableColumnCtx<T>[]> = ref([])
|
|
57
|
-
const columns: Ref<TableColumnCtx<T>[]> = ref([])
|
|
58
|
-
const fixedColumns: Ref<TableColumnCtx<T>[]> = ref([])
|
|
59
|
-
const rightFixedColumns: Ref<TableColumnCtx<T>[]> = ref([])
|
|
60
|
-
const leafColumns: Ref<TableColumnCtx<T>[]> = ref([])
|
|
61
|
-
const fixedLeafColumns: Ref<TableColumnCtx<T>[]> = ref([])
|
|
62
|
-
const rightFixedLeafColumns: Ref<TableColumnCtx<T>[]> = ref([])
|
|
63
|
-
const updateOrderFns: (() => void)[] = []
|
|
64
|
-
const leafColumnsLength = ref(0)
|
|
65
|
-
const fixedLeafColumnsLength = ref(0)
|
|
66
|
-
const rightFixedLeafColumnsLength = ref(0)
|
|
67
|
-
const isAllSelected = ref(false)
|
|
68
|
-
const selection: Ref<T[]> = ref([])
|
|
69
|
-
const reserveSelection = ref(false)
|
|
70
|
-
const selectOnIndeterminate = ref(false)
|
|
71
|
-
const selectable: Ref<(row: T, index: number) => boolean> = ref(null)
|
|
72
|
-
const filters: Ref<StoreFilter> = ref({})
|
|
73
|
-
const filteredData = ref(null)
|
|
74
|
-
const sortingColumn = ref(null)
|
|
75
|
-
const sortProp = ref(null)
|
|
76
|
-
const sortOrder = ref(null)
|
|
77
|
-
const hoverRow = ref(null)
|
|
78
|
-
|
|
79
|
-
watch(data, () => instance.state && scheduleLayout(false), {
|
|
80
|
-
deep: true,
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
// 检查 rowKey 是否存在
|
|
84
|
-
const assertRowKey = () => {
|
|
85
|
-
if (!rowKey.value) throw new Error('[ElTable] prop row-key is required')
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// 更新 fixed
|
|
89
|
-
const updateChildFixed = (column: TableColumnCtx<T>) => {
|
|
90
|
-
column.children?.forEach((childColumn) => {
|
|
91
|
-
childColumn.fixed = column.fixed
|
|
92
|
-
updateChildFixed(childColumn)
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 更新列
|
|
97
|
-
const updateColumns = () => {
|
|
98
|
-
_columns.value.forEach((column) => {
|
|
99
|
-
updateChildFixed(column)
|
|
100
|
-
})
|
|
101
|
-
fixedColumns.value = _columns.value.filter(
|
|
102
|
-
(column) => column.fixed === true || column.fixed === 'left'
|
|
103
|
-
)
|
|
104
|
-
rightFixedColumns.value = _columns.value.filter(
|
|
105
|
-
(column) => column.fixed === 'right'
|
|
106
|
-
)
|
|
107
|
-
if (
|
|
108
|
-
fixedColumns.value.length > 0 &&
|
|
109
|
-
_columns.value[0] &&
|
|
110
|
-
_columns.value[0].type === 'selection' &&
|
|
111
|
-
!_columns.value[0].fixed
|
|
112
|
-
) {
|
|
113
|
-
_columns.value[0].fixed = true
|
|
114
|
-
fixedColumns.value.unshift(_columns.value[0])
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const notFixedColumns = _columns.value.filter((column) => !column.fixed)
|
|
118
|
-
originColumns.value = []
|
|
119
|
-
.concat(fixedColumns.value)
|
|
120
|
-
.concat(notFixedColumns)
|
|
121
|
-
.concat(rightFixedColumns.value)
|
|
122
|
-
const leafColumns = doFlattenColumns(notFixedColumns)
|
|
123
|
-
const fixedLeafColumns = doFlattenColumns(fixedColumns.value)
|
|
124
|
-
const rightFixedLeafColumns = doFlattenColumns(rightFixedColumns.value)
|
|
125
|
-
|
|
126
|
-
leafColumnsLength.value = leafColumns.length
|
|
127
|
-
fixedLeafColumnsLength.value = fixedLeafColumns.length
|
|
128
|
-
rightFixedLeafColumnsLength.value = rightFixedLeafColumns.length
|
|
129
|
-
|
|
130
|
-
columns.value = []
|
|
131
|
-
.concat(fixedLeafColumns)
|
|
132
|
-
.concat(leafColumns)
|
|
133
|
-
.concat(rightFixedLeafColumns)
|
|
134
|
-
isComplex.value =
|
|
135
|
-
fixedColumns.value.length > 0 || rightFixedColumns.value.length > 0
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// 更新 DOM
|
|
139
|
-
const scheduleLayout = (needUpdateColumns?: boolean, immediate = false) => {
|
|
140
|
-
if (needUpdateColumns) {
|
|
141
|
-
updateColumns()
|
|
142
|
-
}
|
|
143
|
-
if (immediate) {
|
|
144
|
-
instance.state.doLayout()
|
|
145
|
-
} else {
|
|
146
|
-
instance.state.debouncedUpdateLayout()
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// 选择
|
|
151
|
-
const isSelected = (row) => {
|
|
152
|
-
return selection.value.includes(row)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const clearSelection = () => {
|
|
156
|
-
isAllSelected.value = false
|
|
157
|
-
const oldSelection = selection.value
|
|
158
|
-
selection.value = []
|
|
159
|
-
if (oldSelection.length) {
|
|
160
|
-
instance.emit('selection-change', [])
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const cleanSelection = () => {
|
|
165
|
-
let deleted
|
|
166
|
-
if (rowKey.value) {
|
|
167
|
-
deleted = []
|
|
168
|
-
const selectedMap = getKeysMap(selection.value, rowKey.value)
|
|
169
|
-
const dataMap = getKeysMap(data.value, rowKey.value)
|
|
170
|
-
for (const key in selectedMap) {
|
|
171
|
-
if (hasOwn(selectedMap, key) && !dataMap[key]) {
|
|
172
|
-
deleted.push(selectedMap[key].row)
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
deleted = selection.value.filter((item) => !data.value.includes(item))
|
|
177
|
-
}
|
|
178
|
-
if (deleted.length) {
|
|
179
|
-
const newSelection = selection.value.filter(
|
|
180
|
-
(item) => !deleted.includes(item)
|
|
181
|
-
)
|
|
182
|
-
selection.value = newSelection
|
|
183
|
-
instance.emit('selection-change', newSelection.slice())
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const getSelectionRows = () => {
|
|
188
|
-
return (selection.value || []).slice()
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const toggleRowSelection = (
|
|
192
|
-
row: T,
|
|
193
|
-
selected = undefined,
|
|
194
|
-
emitChange = true
|
|
195
|
-
) => {
|
|
196
|
-
const changed = toggleRowStatus(selection.value, row, selected)
|
|
197
|
-
if (changed) {
|
|
198
|
-
const newSelection = (selection.value || []).slice()
|
|
199
|
-
// 调用 API 修改选中值,不触发 select 事件
|
|
200
|
-
if (emitChange) {
|
|
201
|
-
instance.emit('select', newSelection, row)
|
|
202
|
-
}
|
|
203
|
-
instance.emit('selection-change', newSelection)
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const _toggleAllSelection = () => {
|
|
208
|
-
// when only some rows are selected (but not all), select or deselect all of them
|
|
209
|
-
// depending on the value of selectOnIndeterminate
|
|
210
|
-
const value = selectOnIndeterminate.value
|
|
211
|
-
? !isAllSelected.value
|
|
212
|
-
: !(isAllSelected.value || selection.value.length)
|
|
213
|
-
isAllSelected.value = value
|
|
214
|
-
|
|
215
|
-
let selectionChanged = false
|
|
216
|
-
let childrenCount = 0
|
|
217
|
-
const rowKey = instance?.store?.states?.rowKey.value
|
|
218
|
-
data.value.forEach((row, index) => {
|
|
219
|
-
const rowIndex = index + childrenCount
|
|
220
|
-
if (selectable.value) {
|
|
221
|
-
if (
|
|
222
|
-
selectable.value.call(null, row, rowIndex) &&
|
|
223
|
-
toggleRowStatus(selection.value, row, value)
|
|
224
|
-
) {
|
|
225
|
-
selectionChanged = true
|
|
226
|
-
}
|
|
227
|
-
} else {
|
|
228
|
-
if (toggleRowStatus(selection.value, row, value)) {
|
|
229
|
-
selectionChanged = true
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
childrenCount += getChildrenCount(getRowIdentity(row, rowKey))
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
if (selectionChanged) {
|
|
236
|
-
instance.emit(
|
|
237
|
-
'selection-change',
|
|
238
|
-
selection.value ? selection.value.slice() : []
|
|
239
|
-
)
|
|
240
|
-
}
|
|
241
|
-
instance.emit('select-all', (selection.value || []).slice())
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const updateSelectionByRowKey = () => {
|
|
245
|
-
const selectedMap = getKeysMap(selection.value, rowKey.value)
|
|
246
|
-
data.value.forEach((row) => {
|
|
247
|
-
const rowId = getRowIdentity(row, rowKey.value)
|
|
248
|
-
const rowInfo = selectedMap[rowId]
|
|
249
|
-
if (rowInfo) {
|
|
250
|
-
selection.value[rowInfo.index] = row
|
|
251
|
-
}
|
|
252
|
-
})
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const updateAllSelected = () => {
|
|
256
|
-
// data 为 null 时,解构时的默认值会被忽略
|
|
257
|
-
if (data.value?.length === 0) {
|
|
258
|
-
isAllSelected.value = false
|
|
259
|
-
return
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
let selectedMap
|
|
263
|
-
if (rowKey.value) {
|
|
264
|
-
selectedMap = getKeysMap(selection.value, rowKey.value)
|
|
265
|
-
}
|
|
266
|
-
const isSelected = function (row) {
|
|
267
|
-
if (selectedMap) {
|
|
268
|
-
return !!selectedMap[getRowIdentity(row, rowKey.value)]
|
|
269
|
-
} else {
|
|
270
|
-
return selection.value.includes(row)
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
let isAllSelected_ = true
|
|
274
|
-
let selectedCount = 0
|
|
275
|
-
let childrenCount = 0
|
|
276
|
-
for (let i = 0, j = (data.value || []).length; i < j; i++) {
|
|
277
|
-
const keyProp = instance?.store?.states?.rowKey.value
|
|
278
|
-
const rowIndex = i + childrenCount
|
|
279
|
-
const item = data.value[i]
|
|
280
|
-
const isRowSelectable =
|
|
281
|
-
selectable.value && selectable.value.call(null, item, rowIndex)
|
|
282
|
-
if (!isSelected(item)) {
|
|
283
|
-
if (!selectable.value || isRowSelectable) {
|
|
284
|
-
isAllSelected_ = false
|
|
285
|
-
break
|
|
286
|
-
}
|
|
287
|
-
} else {
|
|
288
|
-
selectedCount++
|
|
289
|
-
}
|
|
290
|
-
childrenCount += getChildrenCount(getRowIdentity(item, keyProp))
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (selectedCount === 0) isAllSelected_ = false
|
|
294
|
-
isAllSelected.value = isAllSelected_
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// gets the number of all child nodes by rowKey
|
|
298
|
-
const getChildrenCount = (rowKey: string) => {
|
|
299
|
-
if (!instance || !instance.store) return 0
|
|
300
|
-
const { treeData } = instance.store.states
|
|
301
|
-
let count = 0
|
|
302
|
-
const children = treeData.value[rowKey]?.children
|
|
303
|
-
if (children) {
|
|
304
|
-
count += children.length
|
|
305
|
-
children.forEach((childKey) => {
|
|
306
|
-
count += getChildrenCount(childKey)
|
|
307
|
-
})
|
|
308
|
-
}
|
|
309
|
-
return count
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// 过滤与排序
|
|
313
|
-
const updateFilters = (columns, values) => {
|
|
314
|
-
if (!Array.isArray(columns)) {
|
|
315
|
-
columns = [columns]
|
|
316
|
-
}
|
|
317
|
-
const filters_ = {}
|
|
318
|
-
columns.forEach((col) => {
|
|
319
|
-
filters.value[col.id] = values
|
|
320
|
-
filters_[col.columnKey || col.id] = values
|
|
321
|
-
})
|
|
322
|
-
return filters_
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
const updateSort = (column, prop, order) => {
|
|
326
|
-
if (sortingColumn.value && sortingColumn.value !== column) {
|
|
327
|
-
sortingColumn.value.order = null
|
|
328
|
-
}
|
|
329
|
-
sortingColumn.value = column
|
|
330
|
-
sortProp.value = prop
|
|
331
|
-
sortOrder.value = order
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const execFilter = () => {
|
|
335
|
-
let sourceData = unref(_data)
|
|
336
|
-
Object.keys(filters.value).forEach((columnId) => {
|
|
337
|
-
const values = filters.value[columnId]
|
|
338
|
-
if (!values || values.length === 0) return
|
|
339
|
-
const column = getColumnById(
|
|
340
|
-
{
|
|
341
|
-
columns: columns.value,
|
|
342
|
-
},
|
|
343
|
-
columnId
|
|
344
|
-
)
|
|
345
|
-
if (column && column.filterMethod) {
|
|
346
|
-
sourceData = sourceData.filter((row) => {
|
|
347
|
-
return values.some((value) =>
|
|
348
|
-
column.filterMethod.call(null, value, row, column)
|
|
349
|
-
)
|
|
350
|
-
})
|
|
351
|
-
}
|
|
352
|
-
})
|
|
353
|
-
|
|
354
|
-
filteredData.value = sourceData
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
const execSort = () => {
|
|
358
|
-
data.value = sortData(filteredData.value, {
|
|
359
|
-
sortingColumn: sortingColumn.value,
|
|
360
|
-
sortProp: sortProp.value,
|
|
361
|
-
sortOrder: sortOrder.value,
|
|
362
|
-
})
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// 根据 filters 与 sort 去过滤 data
|
|
366
|
-
const execQuery = (ignore = undefined) => {
|
|
367
|
-
if (!(ignore && ignore.filter)) {
|
|
368
|
-
execFilter()
|
|
369
|
-
}
|
|
370
|
-
execSort()
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
const clearFilter = (columnKeys) => {
|
|
374
|
-
const { tableHeaderRef } = instance.refs as TableRefs
|
|
375
|
-
if (!tableHeaderRef) return
|
|
376
|
-
const panels = Object.assign({}, tableHeaderRef.filterPanels)
|
|
377
|
-
|
|
378
|
-
const keys = Object.keys(panels)
|
|
379
|
-
if (!keys.length) return
|
|
380
|
-
|
|
381
|
-
if (typeof columnKeys === 'string') {
|
|
382
|
-
columnKeys = [columnKeys]
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (Array.isArray(columnKeys)) {
|
|
386
|
-
const columns_ = columnKeys.map((key) =>
|
|
387
|
-
getColumnByKey(
|
|
388
|
-
{
|
|
389
|
-
columns: columns.value,
|
|
390
|
-
},
|
|
391
|
-
key
|
|
392
|
-
)
|
|
393
|
-
)
|
|
394
|
-
keys.forEach((key) => {
|
|
395
|
-
const column = columns_.find((col) => col.id === key)
|
|
396
|
-
if (column) {
|
|
397
|
-
column.filteredValue = []
|
|
398
|
-
}
|
|
399
|
-
})
|
|
400
|
-
instance.store.commit('filterChange', {
|
|
401
|
-
column: columns_,
|
|
402
|
-
values: [],
|
|
403
|
-
silent: true,
|
|
404
|
-
multi: true,
|
|
405
|
-
})
|
|
406
|
-
} else {
|
|
407
|
-
keys.forEach((key) => {
|
|
408
|
-
const column = columns.value.find((col) => col.id === key)
|
|
409
|
-
if (column) {
|
|
410
|
-
column.filteredValue = []
|
|
411
|
-
}
|
|
412
|
-
})
|
|
413
|
-
|
|
414
|
-
filters.value = {}
|
|
415
|
-
instance.store.commit('filterChange', {
|
|
416
|
-
column: {},
|
|
417
|
-
values: [],
|
|
418
|
-
silent: true,
|
|
419
|
-
})
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const clearSort = () => {
|
|
424
|
-
if (!sortingColumn.value) return
|
|
425
|
-
|
|
426
|
-
updateSort(null, null, null)
|
|
427
|
-
instance.store.commit('changeSortCondition', {
|
|
428
|
-
silent: true,
|
|
429
|
-
})
|
|
430
|
-
}
|
|
431
|
-
const {
|
|
432
|
-
setExpandRowKeys,
|
|
433
|
-
toggleRowExpansion,
|
|
434
|
-
updateExpandRows,
|
|
435
|
-
states: expandStates,
|
|
436
|
-
isRowExpanded,
|
|
437
|
-
} = useExpand({
|
|
438
|
-
data,
|
|
439
|
-
rowKey,
|
|
440
|
-
})
|
|
441
|
-
const {
|
|
442
|
-
updateTreeExpandKeys,
|
|
443
|
-
toggleTreeExpansion,
|
|
444
|
-
updateTreeData,
|
|
445
|
-
loadOrToggle,
|
|
446
|
-
states: treeStates,
|
|
447
|
-
} = useTree({
|
|
448
|
-
data,
|
|
449
|
-
rowKey,
|
|
450
|
-
})
|
|
451
|
-
const {
|
|
452
|
-
updateCurrentRowData,
|
|
453
|
-
updateCurrentRow,
|
|
454
|
-
setCurrentRowKey,
|
|
455
|
-
states: currentData,
|
|
456
|
-
} = useCurrent({
|
|
457
|
-
data,
|
|
458
|
-
rowKey,
|
|
459
|
-
})
|
|
460
|
-
// 适配层,expand-row-keys 在 Expand 与 TreeTable 中都有使用
|
|
461
|
-
const setExpandRowKeysAdapter = (val: string[]) => {
|
|
462
|
-
// 这里会触发额外的计算,但为了兼容性,暂时这么做
|
|
463
|
-
setExpandRowKeys(val)
|
|
464
|
-
updateTreeExpandKeys(val)
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// 展开行与 TreeTable 都要使用
|
|
468
|
-
const toggleRowExpansionAdapter = (row: T, expanded?: boolean) => {
|
|
469
|
-
const hasExpandColumn = columns.value.some(({ type }) => type === 'expand')
|
|
470
|
-
if (hasExpandColumn) {
|
|
471
|
-
toggleRowExpansion(row, expanded)
|
|
472
|
-
} else {
|
|
473
|
-
toggleTreeExpansion(row, expanded)
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
return {
|
|
478
|
-
assertRowKey,
|
|
479
|
-
updateColumns,
|
|
480
|
-
scheduleLayout,
|
|
481
|
-
isSelected,
|
|
482
|
-
clearSelection,
|
|
483
|
-
cleanSelection,
|
|
484
|
-
getSelectionRows,
|
|
485
|
-
toggleRowSelection,
|
|
486
|
-
_toggleAllSelection,
|
|
487
|
-
toggleAllSelection: null,
|
|
488
|
-
updateSelectionByRowKey,
|
|
489
|
-
updateAllSelected,
|
|
490
|
-
updateFilters,
|
|
491
|
-
updateCurrentRow,
|
|
492
|
-
updateSort,
|
|
493
|
-
execFilter,
|
|
494
|
-
execSort,
|
|
495
|
-
execQuery,
|
|
496
|
-
clearFilter,
|
|
497
|
-
clearSort,
|
|
498
|
-
toggleRowExpansion,
|
|
499
|
-
setExpandRowKeysAdapter,
|
|
500
|
-
setCurrentRowKey,
|
|
501
|
-
toggleRowExpansionAdapter,
|
|
502
|
-
isRowExpanded,
|
|
503
|
-
updateExpandRows,
|
|
504
|
-
updateCurrentRowData,
|
|
505
|
-
loadOrToggle,
|
|
506
|
-
updateTreeData,
|
|
507
|
-
states: {
|
|
508
|
-
tableSize,
|
|
509
|
-
rowKey,
|
|
510
|
-
data,
|
|
511
|
-
_data,
|
|
512
|
-
isComplex,
|
|
513
|
-
_columns,
|
|
514
|
-
originColumns,
|
|
515
|
-
columns,
|
|
516
|
-
fixedColumns,
|
|
517
|
-
rightFixedColumns,
|
|
518
|
-
leafColumns,
|
|
519
|
-
fixedLeafColumns,
|
|
520
|
-
rightFixedLeafColumns,
|
|
521
|
-
updateOrderFns,
|
|
522
|
-
leafColumnsLength,
|
|
523
|
-
fixedLeafColumnsLength,
|
|
524
|
-
rightFixedLeafColumnsLength,
|
|
525
|
-
isAllSelected,
|
|
526
|
-
selection,
|
|
527
|
-
reserveSelection,
|
|
528
|
-
selectOnIndeterminate,
|
|
529
|
-
selectable,
|
|
530
|
-
filters,
|
|
531
|
-
filteredData,
|
|
532
|
-
sortingColumn,
|
|
533
|
-
sortProp,
|
|
534
|
-
sortOrder,
|
|
535
|
-
hoverRow,
|
|
536
|
-
...expandStates,
|
|
537
|
-
...treeStates,
|
|
538
|
-
...currentData,
|
|
539
|
-
},
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
export default useWatcher
|