vue-super-crud 1.7.1 → 1.7.4
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/README.md +42 -10
- package/lib/index.css +1 -1
- package/lib/super-crud.min.js +2 -2
- package/package.json +21 -16
- package/src/config/common.js +2 -1
- package/src/config/crud.js +3 -3
- package/src/index.js +4 -0
- package/src/template/formatData.js +75 -87
- package/.browserslistrc +0 -3
- package/.versionrc.json +0 -36
- package/CHANGELOG.md +0 -232
- package/babel.config.js +0 -12
- package/build/alias.js +0 -10
- package/build/build.js +0 -52
- package/build/config.js +0 -70
- package/deploy.bat +0 -14
- package/docs/.vuepress/components/button/base.vue +0 -88
- package/docs/.vuepress/components/common/code-format.vue +0 -331
- package/docs/.vuepress/components/commonConfig/presetCodeTemplate/base.vue +0 -68
- package/docs/.vuepress/components/commonConfig/presetCodeTemplate/customParams.vue +0 -73
- package/docs/.vuepress/components/commonConfig/renderType/component.vue +0 -160
- package/docs/.vuepress/components/commonConfig/renderType/formatter.vue +0 -49
- package/docs/.vuepress/components/commonConfig/renderType/render.vue +0 -91
- package/docs/.vuepress/components/commonConfig/renderType/slot.vue +0 -63
- package/docs/.vuepress/components/crud/baseUse/baseUse.vue +0 -98
- package/docs/.vuepress/components/crud/baseUse/columnAction.vue +0 -72
- package/docs/.vuepress/components/crud/baseUse/columnWidth.vue +0 -107
- package/docs/.vuepress/components/crud/baseUse/handleRow.vue +0 -65
- package/docs/.vuepress/components/crud/baseUse/height.vue +0 -82
- package/docs/.vuepress/components/crud/baseUse/index.vue +0 -54
- package/docs/.vuepress/components/crud/baseUse/loading.vue +0 -70
- package/docs/.vuepress/components/crud/baseUse/pagination.vue +0 -108
- package/docs/.vuepress/components/crud/baseUse/selection.vue +0 -114
- package/docs/.vuepress/components/crud/baseUse/summaryMethod.vue +0 -118
- package/docs/.vuepress/components/crud/baseUse/title.vue +0 -54
- package/docs/.vuepress/components/crud/baseUse/toolbar.vue +0 -69
- package/docs/.vuepress/components/crud/buttons/common.vue +0 -115
- package/docs/.vuepress/components/crud/buttons/fast.vue +0 -82
- package/docs/.vuepress/components/crud/contextMenu/base.vue +0 -72
- package/docs/.vuepress/components/crud/copy.vue +0 -52
- package/docs/.vuepress/components/crud/crudEvents/api.vue +0 -157
- package/docs/.vuepress/components/crud/crudEvents/deleteTip.vue +0 -93
- package/docs/.vuepress/components/crud/crudEvents/events.vue +0 -188
- package/docs/.vuepress/components/crud/dataSort/base.vue +0 -142
- package/docs/.vuepress/components/crud/genDynamicColumns/base.vue +0 -53
- package/docs/.vuepress/components/crud/genDynamicColumns/dynamicAndFixed.vue +0 -111
- package/docs/.vuepress/components/crud/genDynamicColumns/treeDynamic.vue +0 -68
- package/docs/.vuepress/components/crud/handleBar/handleRow.vue +0 -65
- package/docs/.vuepress/components/crud/handleBar/toolbar.vue +0 -69
- package/docs/.vuepress/components/crud/renderType/1.vue +0 -57
- package/docs/.vuepress/components/crud/renderType/2.vue +0 -63
- package/docs/.vuepress/components/crud/renderType/3.vue +0 -105
- package/docs/.vuepress/components/crud/renderType/5.vue +0 -91
- package/docs/.vuepress/components/crud/search/1.vue +0 -90
- package/docs/.vuepress/components/crud/search/2.vue +0 -78
- package/docs/.vuepress/components/crud/search/3.vue +0 -107
- package/docs/.vuepress/components/crud/search/base.vue +0 -123
- package/docs/.vuepress/components/crud/search/localSearch.vue +0 -124
- package/docs/.vuepress/components/crud/search/special.vue +0 -148
- package/docs/.vuepress/components/crud/selection/events.vue +0 -47
- package/docs/.vuepress/components/crud/selection/pagination.vue +0 -94
- package/docs/.vuepress/components/crud/selection/singleSelection.vue +0 -64
- package/docs/.vuepress/components/crud/span/base.vue +0 -69
- package/docs/.vuepress/components/crud/span/special.vue +0 -75
- package/docs/.vuepress/components/crud/summary/base.vue +0 -99
- package/docs/.vuepress/components/crud/tableEdit/addDeleteBtn.vue +0 -174
- package/docs/.vuepress/components/crud/tableEdit/cellEdit.vue +0 -194
- package/docs/.vuepress/components/crud/tableEdit/controlEdit.vue +0 -219
- package/docs/.vuepress/components/crud/tableEdit/dialog.vue +0 -172
- package/docs/.vuepress/components/crud/tableEdit/free.vue +0 -88
- package/docs/.vuepress/components/crud/tableEdit/freeColumn.vue +0 -82
- package/docs/.vuepress/components/crud/tableEdit/methods.vue +0 -154
- package/docs/.vuepress/components/crud/tableEdit/rowAction.vue +0 -107
- package/docs/.vuepress/components/crud/tableEdit/rowBatch.vue +0 -116
- package/docs/.vuepress/components/crud/tableEdit/rowClick.vue +0 -98
- package/docs/.vuepress/components/crud/validate/base.vue +0 -122
- package/docs/.vuepress/components/crud/validate/custom.vue +0 -82
- package/docs/.vuepress/components/crud/validate/regulars.vue +0 -88
- package/docs/.vuepress/components/crud/validate/relation.vue +0 -91
- package/docs/.vuepress/components/crud/validate/tree.vue +0 -82
- package/docs/.vuepress/components/dialog/baseUse/base.vue +0 -92
- package/docs/.vuepress/components/dialog/baseUse/beforeConfirm.vue +0 -78
- package/docs/.vuepress/components/dialog/baseUse/control.vue +0 -79
- package/docs/.vuepress/components/dialog/baseUse/drawer.vue +0 -59
- package/docs/.vuepress/components/dialog/baseUse/footer.vue +0 -87
- package/docs/.vuepress/components/dialog/baseUse/insertSlot.vue +0 -79
- package/docs/.vuepress/components/dict/DictLinkage.vue +0 -91
- package/docs/.vuepress/components/dict/baseUse.vue +0 -72
- package/docs/.vuepress/components/dict/component.vue +0 -82
- package/docs/.vuepress/components/dict/localDict.vue +0 -68
- package/docs/.vuepress/components/form/baseUse/base.vue +0 -48
- package/docs/.vuepress/components/form/baseUse/dataFormat.vue +0 -92
- package/docs/.vuepress/components/form/baseUse/deep.vue +0 -57
- package/docs/.vuepress/components/form/baseUse/gridLayout.vue +0 -47
- package/docs/.vuepress/components/form/baseUse/group.vue +0 -66
- package/docs/.vuepress/components/form/baseUse/hidden.vue +0 -40
- package/docs/.vuepress/components/form/baseUse/inlineLayout.vue +0 -48
- package/docs/.vuepress/components/form/baseUse/label.vue +0 -51
- package/docs/.vuepress/components/form/baseUse/tooltip.vue +0 -40
- package/docs/.vuepress/components/form/baseUse/validate.vue +0 -52
- package/docs/.vuepress/components/form/detail/base.vue +0 -78
- package/docs/.vuepress/components/form/detail/border.vue +0 -90
- package/docs/.vuepress/components/form/detail/singleDetail.vue +0 -72
- package/docs/.vuepress/components/formatData/baseUse.vue +0 -131
- package/docs/.vuepress/components/mock/index.js +0 -347
- package/docs/.vuepress/components/mockData/custom.vue +0 -69
- package/docs/.vuepress/components/mockData/example.vue +0 -290
- package/docs/.vuepress/components/positionSlot/base.vue +0 -24
- package/docs/.vuepress/components/positionSlot/form.vue +0 -71
- package/docs/.vuepress/components/positionSlot/table.vue +0 -85
- package/docs/.vuepress/components/tabs/base.vue +0 -57
- package/docs/.vuepress/components/temp.js +0 -195
- package/docs/.vuepress/config.js +0 -146
- package/docs/.vuepress/enhanceApp.js +0 -142
- package/docs/.vuepress/public/favicon.ico +0 -0
- package/docs/.vuepress/public/super.png +0 -0
- package/docs/.vuepress/styles/index.styl +0 -25
- package/docs/.vuepress/styles/palette.styl +0 -6
- package/docs/README.md +0 -14
- package/docs/guide/button/base.md +0 -31
- package/docs/guide/commonConfig/jsx.md +0 -166
- package/docs/guide/commonConfig/presetCodeTemplate.md +0 -68
- package/docs/guide/commonConfig/renderType.md +0 -181
- package/docs/guide/crud/baseUse.md +0 -120
- package/docs/guide/crud/buttons.md +0 -18
- package/docs/guide/crud/config.md +0 -217
- package/docs/guide/crud/contextMenu.md +0 -18
- package/docs/guide/crud/dataSort.md +0 -66
- package/docs/guide/crud/genDynamicColumns.md +0 -145
- package/docs/guide/crud/handleBar.md +0 -26
- package/docs/guide/crud/renderType.md +0 -4
- package/docs/guide/crud/search.md +0 -150
- package/docs/guide/crud/selection.md +0 -73
- package/docs/guide/crud/span.md +0 -98
- package/docs/guide/crud/summary.md +0 -167
- package/docs/guide/crud/tableEdit.md +0 -377
- package/docs/guide/crud/validate.md +0 -158
- package/docs/guide/dialog/baseUse.md +0 -81
- package/docs/guide/dict/baseUse.md +0 -174
- package/docs/guide/dict/component.md +0 -88
- package/docs/guide/dict/config.md +0 -44
- package/docs/guide/form/baseUse.md +0 -142
- package/docs/guide/form/detail.md +0 -38
- package/docs/guide/formatData/baseUse.md +0 -98
- package/docs/guide/formatData/config.md +0 -142
- package/docs/guide/mockData/base.md +0 -26
- package/docs/guide/positionSlot/base.md +0 -41
- package/docs/guide/question/base.md +0 -44
- package/docs/guide/start/base.md +0 -30
- package/docs/guide/tabs/base.md +0 -63
- package/examples/App.vue +0 -52
- package/examples/Layout/components/AppMain.vue +0 -40
- package/examples/Layout/components/Item.vue +0 -29
- package/examples/Layout/components/Link.vue +0 -44
- package/examples/Layout/components/SidebarItem.vue +0 -93
- package/examples/Layout/index.vue +0 -69
- package/examples/assets/logo.png +0 -0
- package/examples/favicon.ico +0 -0
- package/examples/index.html +0 -18
- package/examples/main.js +0 -54
- package/examples/router/index.js +0 -140
- package/examples/store/index.js +0 -0
- package/examples/styles/index.scss +0 -63
- package/examples/styles/sidebar.scss +0 -226
- package/examples/styles/transition.scss +0 -48
- package/examples/styles/variables.scss +0 -25
- package/examples/views/crud/base.vue +0 -68
- package/examples/views/crud/handleRow.vue +0 -84
- package/examples/views/crud/search.vue +0 -116
- package/examples/views/dashboard/index.vue +0 -244
- package/examples/views/dashboard/index1.vue +0 -234
- package/examples/views/dashboard/test.vue +0 -9
- package/examples/views/formTest/index.vue +0 -168
- package/examples/views/nested/menu1/index.vue +0 -7
- package/examples/views/nested/menu1/menu1-1/index.vue +0 -7
- package/examples/views/nested/menu1/menu1-2/index.vue +0 -7
- package/examples/views/nested/menu1/menu1-2/menu1-2-1/index.vue +0 -5
- package/examples/views/nested/menu1/menu1-2/menu1-2-2/index.vue +0 -5
- package/examples/views/nested/menu1/menu1-3/index.vue +0 -5
- package/examples/views/nested/menu2/index.vue +0 -5
- package/gulpfile.js +0 -84
- package/packages/button/index.vue +0 -189
- package/packages/core/components/comp.vue +0 -223
- package/packages/core/components/position.vue +0 -135
- package/packages/core/components/render.vue +0 -460
- package/packages/core/configManager.js +0 -302
- package/packages/core/create.js +0 -8
- package/packages/core/defaultRender.js +0 -64
- package/packages/core/dict/global.js +0 -10
- package/packages/core/dict/index.js +0 -432
- package/packages/core/dict/mixin.js +0 -94
- package/packages/core/event.js +0 -60
- package/packages/core/index.js +0 -6
- package/packages/core/init.js +0 -122
- package/packages/core/mock/genConfig.js +0 -228
- package/packages/core/mock/genData.js +0 -422
- package/packages/core/mock/index.js +0 -4
- package/packages/core/rules.js +0 -111
- package/packages/crud/column.vue +0 -205
- package/packages/crud/columnAction.vue +0 -207
- package/packages/crud/columnCell.vue +0 -146
- package/packages/crud/defaultColumn.vue +0 -130
- package/packages/crud/drawerColumn.vue +0 -225
- package/packages/crud/form.vue +0 -69
- package/packages/crud/index.vue +0 -564
- package/packages/crud/menuBar.vue +0 -298
- package/packages/crud/mixins/cacheHandler.js +0 -36
- package/packages/crud/mixins/calcColumnWidth.js +0 -79
- package/packages/crud/mixins/calcHeight.js +0 -105
- package/packages/crud/mixins/columnHandler.js +0 -128
- package/packages/crud/mixins/contextMenu.js +0 -98
- package/packages/crud/mixins/dataProcessor.js +0 -202
- package/packages/crud/mixins/dialog.js +0 -109
- package/packages/crud/mixins/excelHandler.js +0 -150
- package/packages/crud/mixins/exposeMethods.js +0 -107
- package/packages/crud/mixins/generateDynamicColumns.js +0 -250
- package/packages/crud/mixins/props.js +0 -38
- package/packages/crud/mixins/searchHandler.js +0 -151
- package/packages/crud/mixins/select.js +0 -359
- package/packages/crud/mixins/spanMethod.js +0 -288
- package/packages/crud/mixins/summary.js +0 -177
- package/packages/crud/mixins/tableEdit.js +0 -547
- package/packages/crud/mixins/validate.js +0 -219
- package/packages/crud/pagination.vue +0 -110
- package/packages/crud/search.vue +0 -119
- package/packages/crud/searchHeader.vue +0 -231
- package/packages/crud/selectBanner.vue +0 -138
- package/packages/crud/utils/EditState.js +0 -319
- package/packages/crud/utils/excelExport.js +0 -112
- package/packages/crud/utils/excelImport.js +0 -112
- package/packages/crud/utils/index.js +0 -98
- package/packages/dialog/dialog.js +0 -233
- package/packages/dialog/dialog.vue +0 -15
- package/packages/dialog/index.js +0 -22
- package/packages/dict/cascadeFormat.vue +0 -179
- package/packages/dict/dateFormat.vue +0 -40
- package/packages/dict/form/cascade.vue +0 -61
- package/packages/dict/form/checkbox.vue +0 -90
- package/packages/dict/form/extendMethod.js +0 -22
- package/packages/dict/form/input-base.js +0 -31
- package/packages/dict/form/input.js +0 -20
- package/packages/dict/form/radio.vue +0 -69
- package/packages/dict/form/select.vue +0 -118
- package/packages/dict/form/switch.vue +0 -75
- package/packages/dict/valueFormat.vue +0 -188
- package/packages/directive/dialog/drag.js +0 -86
- package/packages/directive/dialog/dragSize.js +0 -42
- package/packages/directive/index.js +0 -9
- package/packages/directive/insertSlot.js +0 -10
- package/packages/form/contextMenu.js +0 -192
- package/packages/form/draftDrawer.vue +0 -391
- package/packages/form/formAction.vue +0 -97
- package/packages/form/formItem.vue +0 -259
- package/packages/form/index.vue +0 -451
- package/packages/form/props.js +0 -15
- package/packages/grid/cell.vue +0 -65
- package/packages/grid/index.vue +0 -130
- package/packages/group/index.vue +0 -96
- package/packages/tabs/index.vue +0 -290
- package/packages/tooltip/index.js +0 -9
- package/packages/tooltip/tooltip.vue +0 -32
- package/packages/tooltip/tooltipComponent.js +0 -38
- package/packages/verifyInput/index.vue +0 -131
- package/styles/button.scss +0 -3
- package/styles/crud.scss +0 -425
- package/styles/dialog.scss +0 -95
- package/styles/form.scss +0 -532
- package/styles/group.scss +0 -78
- package/styles/index.scss +0 -94
- package/styles/tabs.scss +0 -139
- package/styles/verifyInput.scss +0 -56
- package/vue-jsx-sync.js +0 -90
- package/vue.config.js +0 -54
package/packages/crud/index.vue
DELETED
@@ -1,564 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<div
|
3
|
-
:class="[
|
4
|
-
b(),
|
5
|
-
{
|
6
|
-
[b('maximize')]: isMaximize,
|
7
|
-
[b('is-auto-height')]: isAutoHeight,
|
8
|
-
[b('is-change-show-search')]: isChangeShowSearch,
|
9
|
-
},
|
10
|
-
]"
|
11
|
-
:style="{
|
12
|
-
padding: wrapperPadding,
|
13
|
-
height: wrapperHeight,
|
14
|
-
}"
|
15
|
-
ref="wrapper"
|
16
|
-
@click="handleWrapperClick"
|
17
|
-
>
|
18
|
-
<position slotName="title" :slots="$scopedSlots"
|
19
|
-
><div v-if="crudOptions.title" class="sc-title">
|
20
|
-
{{ crudOptions.title }}
|
21
|
-
</div></position
|
22
|
-
>
|
23
|
-
<search ref="searchRef" />
|
24
|
-
<menuBar ref="menuBar" />
|
25
|
-
<!-- 选中数据横幅 -->
|
26
|
-
<selectBanner v-if="selection.banner || singleSelection.banner" />
|
27
|
-
<el-form
|
28
|
-
:model="{
|
29
|
-
list,
|
30
|
-
}"
|
31
|
-
:show-message="false"
|
32
|
-
:size="crudOptions.size"
|
33
|
-
:disabled="crudOptions.disabled"
|
34
|
-
ref="tableFormRef"
|
35
|
-
@validate="createListError"
|
36
|
-
class="height--form"
|
37
|
-
>
|
38
|
-
<component
|
39
|
-
:is="virtualized ? 'virtualScroll' : 'div'"
|
40
|
-
:data="virtualized ? list : null"
|
41
|
-
:key-prop="valueKey"
|
42
|
-
:virtualized="virtualized"
|
43
|
-
v-bind="$attrs"
|
44
|
-
@change="(renderData) => (virtualList = renderData)"
|
45
|
-
>
|
46
|
-
<el-table
|
47
|
-
ref="tableRef"
|
48
|
-
:key="key"
|
49
|
-
v-loading="loadingStatus"
|
50
|
-
:element-loading-text="crudOptions.loadingText"
|
51
|
-
:element-loading-spinner="crudOptions.loadingSpinner"
|
52
|
-
:element-loading-background="crudOptions.loadingBackground"
|
53
|
-
highlight-current-row
|
54
|
-
highlight-selection-row
|
55
|
-
v-bind="tableProps"
|
56
|
-
v-on="{ ...$listeners, ...crudOptions }"
|
57
|
-
:data="virtualized ? virtualList : list"
|
58
|
-
@cell-mouse-enter="cellMouseEnter"
|
59
|
-
@cell-mouse-leave="cellMouseLeave"
|
60
|
-
@row-contextmenu="openContextMenu"
|
61
|
-
@selection-change="selectionChange"
|
62
|
-
@select="select"
|
63
|
-
@select-all="selectAll"
|
64
|
-
@row-click="rowClick"
|
65
|
-
@row-dblclick="rowDblclick"
|
66
|
-
@cell-click="cellClick"
|
67
|
-
@cell-dblclick="cellDblclick"
|
68
|
-
:row-key="rowKey_"
|
69
|
-
:row-style="defineRowIndex"
|
70
|
-
:cell-class-name="cellClassName_"
|
71
|
-
:row-class-name="rowClassName_"
|
72
|
-
:lazy="crudOptions.lazy || crudOptions.autoLazy"
|
73
|
-
:load="lazyLoad"
|
74
|
-
:spanMethod="spanMethod"
|
75
|
-
:summary-method="summaryMethod"
|
76
|
-
:show-summary="showSummary"
|
77
|
-
>
|
78
|
-
<template slot="empty">
|
79
|
-
<div :class="b('empty')" v-if="showEmpty">
|
80
|
-
<slot name="empty" v-if="$scopedSlots.empty"></slot>
|
81
|
-
<el-empty
|
82
|
-
v-else
|
83
|
-
:image="crudOptions.empty.image"
|
84
|
-
:image-size="crudOptions.empty.size"
|
85
|
-
:description="crudOptions.empty.text"
|
86
|
-
></el-empty>
|
87
|
-
</div>
|
88
|
-
</template>
|
89
|
-
<defaultColumn
|
90
|
-
v-for="col in defaultColumns"
|
91
|
-
:col="col"
|
92
|
-
:key="col.type"
|
93
|
-
/>
|
94
|
-
<slot></slot>
|
95
|
-
<column
|
96
|
-
v-for="col in columns"
|
97
|
-
:col="col"
|
98
|
-
:key="col.prop || col.label"
|
99
|
-
/>
|
100
|
-
<columnAction />
|
101
|
-
</el-table>
|
102
|
-
</component>
|
103
|
-
<el-tooltip
|
104
|
-
effect="light"
|
105
|
-
:popper-class="b('error-tip')"
|
106
|
-
placement="top"
|
107
|
-
ref="tooltip"
|
108
|
-
:content="errorContent"
|
109
|
-
>
|
110
|
-
</el-tooltip>
|
111
|
-
</el-form>
|
112
|
-
<div
|
113
|
-
v-if="editConfig.lastAdd"
|
114
|
-
:class="b('add-button')"
|
115
|
-
@click="handleLastAdd"
|
116
|
-
>
|
117
|
-
<i class="el-icon-plus" /> 新增一行
|
118
|
-
</div>
|
119
|
-
<position :inline="false" slotName="pagination" :slots="$scopedSlots"
|
120
|
-
><pagination ref="paginationRef"
|
121
|
-
/></position>
|
122
|
-
</div>
|
123
|
-
</template>
|
124
|
-
|
125
|
-
<script>
|
126
|
-
import { create, init, event } from "core";
|
127
|
-
import position from "core/components/position";
|
128
|
-
import {
|
129
|
-
uniqueId,
|
130
|
-
pick,
|
131
|
-
get,
|
132
|
-
isFunction,
|
133
|
-
cloneDeep,
|
134
|
-
merge,
|
135
|
-
isPlainObject,
|
136
|
-
} from "lodash-es";
|
137
|
-
import tableEdit from "./mixins/tableEdit.js";
|
138
|
-
import validate from "./mixins/validate.js";
|
139
|
-
import contextMenu from "./mixins/contextMenu";
|
140
|
-
import dialog from "./mixins/dialog.js";
|
141
|
-
import select from "./mixins/select.js";
|
142
|
-
import calcHeight from "./mixins/calcHeight.js";
|
143
|
-
import spanMethod from "./mixins/spanMethod.js";
|
144
|
-
import exposeMethods from "./mixins/exposeMethods";
|
145
|
-
import generateDynamicColumns from "./mixins/generateDynamicColumns";
|
146
|
-
import dataProcessor from "./mixins/dataProcessor";
|
147
|
-
import summary from "./mixins/summary";
|
148
|
-
import columnHandler from "./mixins/columnHandler";
|
149
|
-
import cacheHandler from "./mixins/cacheHandler";
|
150
|
-
import searchHandler from "./mixins/searchHandler";
|
151
|
-
import search from "./search.vue";
|
152
|
-
import menuBar from "./menuBar.vue";
|
153
|
-
import columnAction from "./columnAction.vue";
|
154
|
-
import column from "./column.vue";
|
155
|
-
import defaultColumn from "./defaultColumn.vue";
|
156
|
-
import pagination from "./pagination.vue";
|
157
|
-
import group from "../group/index.vue";
|
158
|
-
import selectBanner from "./selectBanner.vue";
|
159
|
-
import virtualScroll from "el-table-virtual-scroll";
|
160
|
-
import {
|
161
|
-
toCamelCase,
|
162
|
-
toTreeArray,
|
163
|
-
findTree,
|
164
|
-
filterColumns,
|
165
|
-
mergeTemp,
|
166
|
-
singleMerge,
|
167
|
-
checkVisibility,
|
168
|
-
filterButtons,
|
169
|
-
} from "utils";
|
170
|
-
import tableProps from "./mixins/props";
|
171
|
-
|
172
|
-
export default create({
|
173
|
-
name: "crud",
|
174
|
-
components: {
|
175
|
-
columnAction,
|
176
|
-
column,
|
177
|
-
defaultColumn,
|
178
|
-
menuBar,
|
179
|
-
pagination,
|
180
|
-
search,
|
181
|
-
group,
|
182
|
-
position,
|
183
|
-
selectBanner,
|
184
|
-
virtualScroll,
|
185
|
-
},
|
186
|
-
mixins: [
|
187
|
-
init("crudOptions"),
|
188
|
-
tableEdit,
|
189
|
-
dialog,
|
190
|
-
validate,
|
191
|
-
contextMenu,
|
192
|
-
event,
|
193
|
-
select,
|
194
|
-
calcHeight,
|
195
|
-
spanMethod,
|
196
|
-
exposeMethods,
|
197
|
-
generateDynamicColumns,
|
198
|
-
summary,
|
199
|
-
dataProcessor,
|
200
|
-
columnHandler,
|
201
|
-
cacheHandler,
|
202
|
-
searchHandler,
|
203
|
-
],
|
204
|
-
props: {
|
205
|
-
// 防止scope中携带实例时,拷贝合并报错
|
206
|
-
scope: Object,
|
207
|
-
data: {
|
208
|
-
type: Array,
|
209
|
-
default: () => {
|
210
|
-
return [];
|
211
|
-
},
|
212
|
-
},
|
213
|
-
total: {
|
214
|
-
type: Number,
|
215
|
-
default: 0,
|
216
|
-
},
|
217
|
-
search: {
|
218
|
-
type: Object,
|
219
|
-
default: () => {
|
220
|
-
return {};
|
221
|
-
},
|
222
|
-
},
|
223
|
-
loading: {
|
224
|
-
type: Boolean,
|
225
|
-
},
|
226
|
-
slots: {},
|
227
|
-
searchParams: {},
|
228
|
-
load: Function,
|
229
|
-
},
|
230
|
-
provide() {
|
231
|
-
return {
|
232
|
-
ctx: this,
|
233
|
-
controlCtx: this,
|
234
|
-
};
|
235
|
-
},
|
236
|
-
data() {
|
237
|
-
// $refs: {
|
238
|
-
// searchRef
|
239
|
-
// tableFormRef
|
240
|
-
// tableRef
|
241
|
-
// crudForm 弹窗表单实例
|
242
|
-
// dialogVm 弹窗实例
|
243
|
-
// };
|
244
|
-
return {
|
245
|
-
key: Math.random(),
|
246
|
-
showSearch: false,
|
247
|
-
isMaximize: false,
|
248
|
-
query: {},
|
249
|
-
form: {},
|
250
|
-
selectionRow: [],
|
251
|
-
isChangeShowSearch: false,
|
252
|
-
virtualList: [],
|
253
|
-
lazyTreeData: [],
|
254
|
-
showPopperNum: 0,
|
255
|
-
sameRowSpans: [],
|
256
|
-
_showSummary: false,
|
257
|
-
treeNodeMap: new Map(),
|
258
|
-
labelMinWidthMap: new Map(),
|
259
|
-
};
|
260
|
-
},
|
261
|
-
created() {
|
262
|
-
this.getLocalCache();
|
263
|
-
},
|
264
|
-
mounted() {
|
265
|
-
this.crudOptions.init && this.initQuery();
|
266
|
-
this.extendMethod(this.$refs.tableFormRef, ["validate", "clearValidate"]);
|
267
|
-
this.extendMethod(this.$refs.tableRef);
|
268
|
-
this.refactorTableHeaderClick();
|
269
|
-
},
|
270
|
-
computed: {
|
271
|
-
rowKey_() {
|
272
|
-
if (
|
273
|
-
this.isTree ||
|
274
|
-
this.crudOptions.selection.reserveSelection ||
|
275
|
-
this.crudOptions.selection["reserve-selection"] ||
|
276
|
-
this.crudOptions.rowKey
|
277
|
-
) {
|
278
|
-
return this.valueKey;
|
279
|
-
}
|
280
|
-
},
|
281
|
-
virtualized() {
|
282
|
-
return this.crudOptions.virtualized;
|
283
|
-
},
|
284
|
-
valueKey() {
|
285
|
-
if (this.crudOptions.uniqueId) return "$uniqueId";
|
286
|
-
if (this.crudOptions.rowKey) return this.crudOptions.rowKey;
|
287
|
-
return this.crudOptions.valueKey;
|
288
|
-
},
|
289
|
-
isTree() {
|
290
|
-
let flag = false;
|
291
|
-
this.data.forEach((ele) => {
|
292
|
-
if (ele.children) {
|
293
|
-
flag = true;
|
294
|
-
}
|
295
|
-
});
|
296
|
-
return flag;
|
297
|
-
},
|
298
|
-
crudOptions() {
|
299
|
-
return this.resultOptions;
|
300
|
-
},
|
301
|
-
tableProps() {
|
302
|
-
const obj = {};
|
303
|
-
Object.keys(this.crudOptions).forEach((key) => {
|
304
|
-
obj[toCamelCase(key)] = this.crudOptions[key];
|
305
|
-
});
|
306
|
-
const props = pick(obj, tableProps);
|
307
|
-
const height = this.tableHeight;
|
308
|
-
if (height) {
|
309
|
-
props.height = height;
|
310
|
-
} else {
|
311
|
-
delete props.height;
|
312
|
-
}
|
313
|
-
return props;
|
314
|
-
},
|
315
|
-
defaultColumns() {
|
316
|
-
const columns = [];
|
317
|
-
const options = pick(this.crudOptions, [
|
318
|
-
"expand",
|
319
|
-
"index",
|
320
|
-
"selection",
|
321
|
-
"singleSelection",
|
322
|
-
]);
|
323
|
-
Object.keys(options).forEach((key) => {
|
324
|
-
if (checkVisibility(options[key])) {
|
325
|
-
columns.push({ type: key, ...options[key] });
|
326
|
-
}
|
327
|
-
});
|
328
|
-
return filterColumns(columns.sort((a, b) => a.order - b.order));
|
329
|
-
},
|
330
|
-
columns() {
|
331
|
-
if (this.crudOptions.dynamicConfig) {
|
332
|
-
const dynamicColumns = (
|
333
|
-
this.generateDynamicColumns(
|
334
|
-
this.data,
|
335
|
-
this.crudOptions.dynamicConfig
|
336
|
-
) || []
|
337
|
-
).map(this.handleInitColumn);
|
338
|
-
return filterColumns(
|
339
|
-
this.insertColumns(
|
340
|
-
dynamicColumns,
|
341
|
-
this.resultColumns,
|
342
|
-
this.crudOptions.dynamicInsertPosition
|
343
|
-
)
|
344
|
-
);
|
345
|
-
}
|
346
|
-
return filterColumns(this.resultColumns);
|
347
|
-
},
|
348
|
-
flatColumns() {
|
349
|
-
return toTreeArray(this.columns);
|
350
|
-
},
|
351
|
-
trueRenderColumns() {
|
352
|
-
return this.flatColumns.filter((i) => !i.children);
|
353
|
-
},
|
354
|
-
columnsMap() {
|
355
|
-
const map = {};
|
356
|
-
this.trueRenderColumns.forEach((i) => {
|
357
|
-
map[i.prop] = i;
|
358
|
-
});
|
359
|
-
return map;
|
360
|
-
},
|
361
|
-
extendsScopedSlots() {
|
362
|
-
const slots = { ...this.$scopedSlots };
|
363
|
-
this.extendsSlots(slots, "add", "form");
|
364
|
-
this.extendsSlots(slots, "edit", "form");
|
365
|
-
this.extendsSlots(slots, "view", "form");
|
366
|
-
this.extendsSlots(slots, "searchHeader", "search");
|
367
|
-
return slots;
|
368
|
-
},
|
369
|
-
wrapperPadding() {
|
370
|
-
if (this.crudOptions.padding) return this.crudOptions.padding;
|
371
|
-
const { gap = 0 } = this.crudOptions;
|
372
|
-
return this.isAutoHeight ? `${gap}px ${gap}px 0` : `${gap}px`;
|
373
|
-
},
|
374
|
-
showEmpty() {
|
375
|
-
return checkVisibility(
|
376
|
-
this.crudOptions.empty,
|
377
|
-
null,
|
378
|
-
this.$scopedSlots.empty
|
379
|
-
);
|
380
|
-
},
|
381
|
-
},
|
382
|
-
watch: {
|
383
|
-
showPopperNum() {
|
384
|
-
this.$emit("update:showPopper", this.showPopperNum !== 0);
|
385
|
-
},
|
386
|
-
},
|
387
|
-
methods: {
|
388
|
-
// 重写表头点击事件
|
389
|
-
refactorTableHeaderClick() {
|
390
|
-
const tableHeader = this.$refs.tableRef.$refs.tableHeader;
|
391
|
-
const headerClick = tableHeader.handleHeaderClick;
|
392
|
-
tableHeader.handleHeaderClick = (event, column) => {
|
393
|
-
return tableHeader.$parent.$emit("header-click", column, event);
|
394
|
-
// const col = this.columnsMap[column.property];
|
395
|
-
// headerClick.call(tableHeader, event, column);
|
396
|
-
};
|
397
|
-
},
|
398
|
-
lazyLoad(tree, treeNode, resolve) {
|
399
|
-
if (this.crudOptions.autoLazy) {
|
400
|
-
this.treeNodeMap.set(tree[this.valueKey], { tree, treeNode, resolve });
|
401
|
-
const { item } = findTree(
|
402
|
-
this.lazyTreeData,
|
403
|
-
(item) => item[this.valueKey] === tree[this.valueKey]
|
404
|
-
);
|
405
|
-
if (item && item.children && item.children.length) {
|
406
|
-
const list = cloneDeep(item.children);
|
407
|
-
this.handleLocalLazy(list);
|
408
|
-
resolve(list);
|
409
|
-
} else {
|
410
|
-
// 更新空的懒加载节点
|
411
|
-
this.$set(
|
412
|
-
this.$refs.tableRef.store.states.lazyTreeNodeMap,
|
413
|
-
tree[this.valueKey],
|
414
|
-
[]
|
415
|
-
);
|
416
|
-
}
|
417
|
-
}
|
418
|
-
if (this.load) {
|
419
|
-
this.load(tree, treeNode, resolve);
|
420
|
-
}
|
421
|
-
},
|
422
|
-
handleLocalLazy(list) {
|
423
|
-
list.forEach((i) => {
|
424
|
-
if (i.children && i.children.length) {
|
425
|
-
delete i.children;
|
426
|
-
i.hasChildren = true;
|
427
|
-
}
|
428
|
-
});
|
429
|
-
},
|
430
|
-
getRenderColumns(mode) {
|
431
|
-
const options = this.crudOptions;
|
432
|
-
const key = mode + "Form";
|
433
|
-
if (
|
434
|
-
isPlainObject(options.formOptions) &&
|
435
|
-
Array.isArray(options.formOptions.renderColumns) &&
|
436
|
-
!options[key]?.renderColumns &&
|
437
|
-
options[key] !== false
|
438
|
-
) {
|
439
|
-
return options.formOptions.renderColumns || [];
|
440
|
-
}
|
441
|
-
if (
|
442
|
-
isPlainObject(options[key]) &&
|
443
|
-
Array.isArray(options[key].renderColumns)
|
444
|
-
) {
|
445
|
-
return options[key].renderColumns || [];
|
446
|
-
}
|
447
|
-
return this.columns
|
448
|
-
?.filter(
|
449
|
-
(column) =>
|
450
|
-
column[mode] && column[mode] !== false && options[key] !== false
|
451
|
-
)
|
452
|
-
.map((column) => column[mode]);
|
453
|
-
},
|
454
|
-
refreshTable() {
|
455
|
-
this.$refs.tableRef.doLayout();
|
456
|
-
this.$nextTick(() => {
|
457
|
-
// 触发表格重新渲染
|
458
|
-
this.key = Date.now();
|
459
|
-
});
|
460
|
-
},
|
461
|
-
defineRowIndex({ row, rowIndex }) {
|
462
|
-
Object.defineProperty(row, "$index", {
|
463
|
-
value: rowIndex,
|
464
|
-
writable: true,
|
465
|
-
enumerable: false,
|
466
|
-
});
|
467
|
-
return this.crudOptions.rowStyle
|
468
|
-
? this.crudOptions.rowStyle.call(null, {
|
469
|
-
row,
|
470
|
-
rowIndex,
|
471
|
-
})
|
472
|
-
: null;
|
473
|
-
},
|
474
|
-
_runWithoutDeps(fn) {
|
475
|
-
// 获取 Vue 实例内部的 Dep
|
476
|
-
const Dep = this.$data.__ob__.dep.constructor;
|
477
|
-
const target = Dep.target;
|
478
|
-
if (Dep.target) {
|
479
|
-
Dep.target = null;
|
480
|
-
}
|
481
|
-
|
482
|
-
try {
|
483
|
-
return fn();
|
484
|
-
} finally {
|
485
|
-
Dep.target = target;
|
486
|
-
}
|
487
|
-
},
|
488
|
-
|
489
|
-
// 根据依赖收集状态执行回调函数
|
490
|
-
executeWithDeps(callback, collectDep = true, ...args) {
|
491
|
-
if (!callback) return;
|
492
|
-
|
493
|
-
if (collectDep === false) {
|
494
|
-
return this._runWithoutDeps(() => {
|
495
|
-
return callback.call(null, ...args);
|
496
|
-
});
|
497
|
-
}
|
498
|
-
|
499
|
-
return callback.call(null, ...args);
|
500
|
-
},
|
501
|
-
cellClassName_({ row, column, rowIndex, columnIndex }) {
|
502
|
-
const { cellClassName, methodCollectDepends, editTheme } =
|
503
|
-
column?.options || {};
|
504
|
-
let cellName =
|
505
|
-
this.executeWithDeps(cellClassName, methodCollectDepends, {
|
506
|
-
row,
|
507
|
-
column,
|
508
|
-
rowIndex,
|
509
|
-
columnIndex,
|
510
|
-
}) || "";
|
511
|
-
|
512
|
-
const col = column.col;
|
513
|
-
if (!col) return cellName;
|
514
|
-
|
515
|
-
// 添加编辑状态类
|
516
|
-
if (
|
517
|
-
!col.type &&
|
518
|
-
editTheme &&
|
519
|
-
this.validateEdit(col, { row, $index: rowIndex })
|
520
|
-
) {
|
521
|
-
cellName += (cellName ? " " : "") + "edit-cell";
|
522
|
-
}
|
523
|
-
|
524
|
-
// 添加自定义单元格类
|
525
|
-
if (!col.type && !this.isDefaultColumn(col)) {
|
526
|
-
cellName += (cellName ? " " : "") + "custom-cell";
|
527
|
-
}
|
528
|
-
|
529
|
-
return cellName;
|
530
|
-
},
|
531
|
-
// 校验按钮隐藏
|
532
|
-
checkHiddenButtons(key, buttons, scope) {
|
533
|
-
buttons = filterButtons(buttons, this.crudOptions, scope, key);
|
534
|
-
return buttons;
|
535
|
-
},
|
536
|
-
handleWrapperClick() {
|
537
|
-
if (this.showPopperNum > 0) {
|
538
|
-
this.$emit("closeSearchPopover");
|
539
|
-
}
|
540
|
-
},
|
541
|
-
// 强制更新表格
|
542
|
-
_forceUpdate() {
|
543
|
-
this.$refs?.tableRef?.store?.updateColumns();
|
544
|
-
},
|
545
|
-
rowClick(row, column, event) {
|
546
|
-
this.selectRowClick(row, column, event);
|
547
|
-
if (!column) return;
|
548
|
-
this.handleRowClick({ row, $index: row.$index }, column.col.prop);
|
549
|
-
},
|
550
|
-
rowDblclick(row, column, event) {
|
551
|
-
if (!column) return;
|
552
|
-
this.handleRowClick({ row, $index: row.$index }, column.col.prop);
|
553
|
-
},
|
554
|
-
cellClick(row, column, cell, event) {
|
555
|
-
if (!column) return;
|
556
|
-
this.handleCellClick({ row, $index: row.$index }, column.col);
|
557
|
-
},
|
558
|
-
cellDblclick(row, column, cell, event) {
|
559
|
-
if (!column) return;
|
560
|
-
this.handleCellClick({ row, $index: row.$index }, column.col);
|
561
|
-
},
|
562
|
-
},
|
563
|
-
});
|
564
|
-
</script>
|