vue-super-crud 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +3 -0
- package/.versionrc.json +36 -0
- package/CHANGELOG.md +232 -0
- package/LICENSE +201 -0
- package/README.md +46 -0
- package/babel.config.js +12 -0
- package/build/alias.js +10 -0
- package/build/build.js +52 -0
- package/build/config.js +70 -0
- package/deploy.bat +14 -0
- package/docs/.vuepress/components/button/base.vue +88 -0
- package/docs/.vuepress/components/common/code-format.vue +331 -0
- package/docs/.vuepress/components/commonConfig/presetCodeTemplate/base.vue +68 -0
- package/docs/.vuepress/components/commonConfig/presetCodeTemplate/customParams.vue +73 -0
- package/docs/.vuepress/components/commonConfig/renderType/component.vue +160 -0
- package/docs/.vuepress/components/commonConfig/renderType/formatter.vue +49 -0
- package/docs/.vuepress/components/commonConfig/renderType/render.vue +91 -0
- package/docs/.vuepress/components/commonConfig/renderType/slot.vue +63 -0
- package/docs/.vuepress/components/crud/baseUse/baseUse.vue +98 -0
- package/docs/.vuepress/components/crud/baseUse/columnAction.vue +72 -0
- package/docs/.vuepress/components/crud/baseUse/columnWidth.vue +107 -0
- package/docs/.vuepress/components/crud/baseUse/handleRow.vue +65 -0
- package/docs/.vuepress/components/crud/baseUse/height.vue +82 -0
- package/docs/.vuepress/components/crud/baseUse/index.vue +54 -0
- package/docs/.vuepress/components/crud/baseUse/loading.vue +70 -0
- package/docs/.vuepress/components/crud/baseUse/pagination.vue +108 -0
- package/docs/.vuepress/components/crud/baseUse/selection.vue +114 -0
- package/docs/.vuepress/components/crud/baseUse/summaryMethod.vue +118 -0
- package/docs/.vuepress/components/crud/baseUse/title.vue +54 -0
- package/docs/.vuepress/components/crud/baseUse/toolbar.vue +69 -0
- package/docs/.vuepress/components/crud/buttons/common.vue +115 -0
- package/docs/.vuepress/components/crud/buttons/fast.vue +82 -0
- package/docs/.vuepress/components/crud/contextMenu/base.vue +72 -0
- package/docs/.vuepress/components/crud/copy.vue +52 -0
- package/docs/.vuepress/components/crud/crudEvents/api.vue +157 -0
- package/docs/.vuepress/components/crud/crudEvents/deleteTip.vue +93 -0
- package/docs/.vuepress/components/crud/crudEvents/events.vue +188 -0
- package/docs/.vuepress/components/crud/dataSort/base.vue +142 -0
- package/docs/.vuepress/components/crud/genDynamicColumns/base.vue +53 -0
- package/docs/.vuepress/components/crud/genDynamicColumns/dynamicAndFixed.vue +111 -0
- package/docs/.vuepress/components/crud/genDynamicColumns/treeDynamic.vue +68 -0
- package/docs/.vuepress/components/crud/handleBar/handleRow.vue +65 -0
- package/docs/.vuepress/components/crud/handleBar/toolbar.vue +69 -0
- package/docs/.vuepress/components/crud/renderType/1.vue +57 -0
- package/docs/.vuepress/components/crud/renderType/2.vue +63 -0
- package/docs/.vuepress/components/crud/renderType/3.vue +105 -0
- package/docs/.vuepress/components/crud/renderType/5.vue +91 -0
- package/docs/.vuepress/components/crud/search/1.vue +90 -0
- package/docs/.vuepress/components/crud/search/2.vue +78 -0
- package/docs/.vuepress/components/crud/search/3.vue +107 -0
- package/docs/.vuepress/components/crud/search/base.vue +123 -0
- package/docs/.vuepress/components/crud/search/localSearch.vue +124 -0
- package/docs/.vuepress/components/crud/search/special.vue +148 -0
- package/docs/.vuepress/components/crud/selection/events.vue +47 -0
- package/docs/.vuepress/components/crud/selection/pagination.vue +94 -0
- package/docs/.vuepress/components/crud/selection/singleSelection.vue +64 -0
- package/docs/.vuepress/components/crud/span/base.vue +69 -0
- package/docs/.vuepress/components/crud/span/special.vue +75 -0
- package/docs/.vuepress/components/crud/summary/base.vue +99 -0
- package/docs/.vuepress/components/crud/tableEdit/addDeleteBtn.vue +174 -0
- package/docs/.vuepress/components/crud/tableEdit/cellEdit.vue +194 -0
- package/docs/.vuepress/components/crud/tableEdit/controlEdit.vue +219 -0
- package/docs/.vuepress/components/crud/tableEdit/dialog.vue +172 -0
- package/docs/.vuepress/components/crud/tableEdit/free.vue +88 -0
- package/docs/.vuepress/components/crud/tableEdit/freeColumn.vue +82 -0
- package/docs/.vuepress/components/crud/tableEdit/methods.vue +154 -0
- package/docs/.vuepress/components/crud/tableEdit/rowAction.vue +107 -0
- package/docs/.vuepress/components/crud/tableEdit/rowBatch.vue +116 -0
- package/docs/.vuepress/components/crud/tableEdit/rowClick.vue +98 -0
- package/docs/.vuepress/components/crud/validate/base.vue +122 -0
- package/docs/.vuepress/components/crud/validate/custom.vue +82 -0
- package/docs/.vuepress/components/crud/validate/regulars.vue +88 -0
- package/docs/.vuepress/components/crud/validate/relation.vue +91 -0
- package/docs/.vuepress/components/crud/validate/tree.vue +82 -0
- package/docs/.vuepress/components/dialog/baseUse/base.vue +92 -0
- package/docs/.vuepress/components/dialog/baseUse/beforeConfirm.vue +78 -0
- package/docs/.vuepress/components/dialog/baseUse/control.vue +79 -0
- package/docs/.vuepress/components/dialog/baseUse/drawer.vue +59 -0
- package/docs/.vuepress/components/dialog/baseUse/footer.vue +87 -0
- package/docs/.vuepress/components/dialog/baseUse/insertSlot.vue +79 -0
- package/docs/.vuepress/components/dict/DictLinkage.vue +91 -0
- package/docs/.vuepress/components/dict/baseUse.vue +72 -0
- package/docs/.vuepress/components/dict/component.vue +82 -0
- package/docs/.vuepress/components/dict/localDict.vue +68 -0
- package/docs/.vuepress/components/form/baseUse/base.vue +48 -0
- package/docs/.vuepress/components/form/baseUse/dataFormat.vue +92 -0
- package/docs/.vuepress/components/form/baseUse/deep.vue +57 -0
- package/docs/.vuepress/components/form/baseUse/gridLayout.vue +47 -0
- package/docs/.vuepress/components/form/baseUse/group.vue +66 -0
- package/docs/.vuepress/components/form/baseUse/hidden.vue +40 -0
- package/docs/.vuepress/components/form/baseUse/inlineLayout.vue +48 -0
- package/docs/.vuepress/components/form/baseUse/label.vue +51 -0
- package/docs/.vuepress/components/form/baseUse/tooltip.vue +40 -0
- package/docs/.vuepress/components/form/baseUse/validate.vue +52 -0
- package/docs/.vuepress/components/form/detail/base.vue +78 -0
- package/docs/.vuepress/components/form/detail/border.vue +90 -0
- package/docs/.vuepress/components/form/detail/singleDetail.vue +72 -0
- package/docs/.vuepress/components/formatData/baseUse.vue +131 -0
- package/docs/.vuepress/components/mock/index.js +347 -0
- package/docs/.vuepress/components/mockData/custom.vue +69 -0
- package/docs/.vuepress/components/mockData/example.vue +290 -0
- package/docs/.vuepress/components/positionSlot/base.vue +24 -0
- package/docs/.vuepress/components/positionSlot/form.vue +71 -0
- package/docs/.vuepress/components/positionSlot/table.vue +85 -0
- package/docs/.vuepress/components/tabs/base.vue +57 -0
- package/docs/.vuepress/components/temp.js +195 -0
- package/docs/.vuepress/config.js +146 -0
- package/docs/.vuepress/enhanceApp.js +142 -0
- package/docs/.vuepress/public/favicon.ico +0 -0
- package/docs/.vuepress/public/super.png +0 -0
- package/docs/.vuepress/styles/index.styl +25 -0
- package/docs/.vuepress/styles/palette.styl +6 -0
- package/docs/README.md +14 -0
- package/docs/guide/button/base.md +31 -0
- package/docs/guide/commonConfig/jsx.md +166 -0
- package/docs/guide/commonConfig/presetCodeTemplate.md +68 -0
- package/docs/guide/commonConfig/renderType.md +181 -0
- package/docs/guide/crud/baseUse.md +120 -0
- package/docs/guide/crud/buttons.md +18 -0
- package/docs/guide/crud/config.md +217 -0
- package/docs/guide/crud/contextMenu.md +18 -0
- package/docs/guide/crud/dataSort.md +66 -0
- package/docs/guide/crud/genDynamicColumns.md +145 -0
- package/docs/guide/crud/handleBar.md +26 -0
- package/docs/guide/crud/renderType.md +4 -0
- package/docs/guide/crud/search.md +150 -0
- package/docs/guide/crud/selection.md +73 -0
- package/docs/guide/crud/span.md +98 -0
- package/docs/guide/crud/summary.md +167 -0
- package/docs/guide/crud/tableEdit.md +377 -0
- package/docs/guide/crud/validate.md +158 -0
- package/docs/guide/dialog/baseUse.md +81 -0
- package/docs/guide/dict/baseUse.md +174 -0
- package/docs/guide/dict/component.md +88 -0
- package/docs/guide/dict/config.md +44 -0
- package/docs/guide/form/baseUse.md +142 -0
- package/docs/guide/form/detail.md +38 -0
- package/docs/guide/formatData/baseUse.md +98 -0
- package/docs/guide/formatData/config.md +142 -0
- package/docs/guide/mockData/base.md +26 -0
- package/docs/guide/positionSlot/base.md +41 -0
- package/docs/guide/question/base.md +44 -0
- package/docs/guide/start/base.md +30 -0
- package/docs/guide/tabs/base.md +63 -0
- package/examples/App.vue +52 -0
- package/examples/Layout/components/AppMain.vue +40 -0
- package/examples/Layout/components/Item.vue +29 -0
- package/examples/Layout/components/Link.vue +44 -0
- package/examples/Layout/components/SidebarItem.vue +93 -0
- package/examples/Layout/index.vue +69 -0
- package/examples/assets/logo.png +0 -0
- package/examples/favicon.ico +0 -0
- package/examples/index.html +18 -0
- package/examples/main.js +54 -0
- package/examples/router/index.js +140 -0
- package/examples/store/index.js +0 -0
- package/examples/styles/index.scss +63 -0
- package/examples/styles/sidebar.scss +226 -0
- package/examples/styles/transition.scss +48 -0
- package/examples/styles/variables.scss +25 -0
- package/examples/views/crud/base.vue +68 -0
- package/examples/views/crud/handleRow.vue +84 -0
- package/examples/views/crud/search.vue +116 -0
- package/examples/views/dashboard/index.vue +244 -0
- package/examples/views/dashboard/index1.vue +234 -0
- package/examples/views/dashboard/test.vue +9 -0
- package/examples/views/formTest/index.vue +168 -0
- package/examples/views/nested/menu1/index.vue +7 -0
- package/examples/views/nested/menu1/menu1-1/index.vue +7 -0
- package/examples/views/nested/menu1/menu1-2/index.vue +7 -0
- package/examples/views/nested/menu1/menu1-2/menu1-2-1/index.vue +5 -0
- package/examples/views/nested/menu1/menu1-2/menu1-2-2/index.vue +5 -0
- package/examples/views/nested/menu1/menu1-3/index.vue +5 -0
- package/examples/views/nested/menu2/index.vue +5 -0
- package/gulpfile.js +84 -0
- package/lib/index.css +1 -0
- package/lib/super-crud.min.js +15 -0
- package/package.json +66 -0
- package/packages/button/index.vue +189 -0
- package/packages/core/components/comp.vue +223 -0
- package/packages/core/components/position.vue +135 -0
- package/packages/core/components/render.vue +460 -0
- package/packages/core/configManager.js +302 -0
- package/packages/core/create.js +8 -0
- package/packages/core/defaultRender.js +64 -0
- package/packages/core/dict/global.js +10 -0
- package/packages/core/dict/index.js +432 -0
- package/packages/core/dict/mixin.js +94 -0
- package/packages/core/event.js +60 -0
- package/packages/core/index.js +6 -0
- package/packages/core/init.js +122 -0
- package/packages/core/mock/genConfig.js +228 -0
- package/packages/core/mock/genData.js +422 -0
- package/packages/core/mock/index.js +4 -0
- package/packages/core/rules.js +111 -0
- package/packages/crud/column.vue +205 -0
- package/packages/crud/columnAction.vue +207 -0
- package/packages/crud/columnCell.vue +146 -0
- package/packages/crud/defaultColumn.vue +130 -0
- package/packages/crud/drawerColumn.vue +225 -0
- package/packages/crud/form.vue +69 -0
- package/packages/crud/index.vue +564 -0
- package/packages/crud/menuBar.vue +298 -0
- package/packages/crud/mixins/cacheHandler.js +36 -0
- package/packages/crud/mixins/calcColumnWidth.js +79 -0
- package/packages/crud/mixins/calcHeight.js +105 -0
- package/packages/crud/mixins/columnHandler.js +128 -0
- package/packages/crud/mixins/contextMenu.js +98 -0
- package/packages/crud/mixins/dataProcessor.js +202 -0
- package/packages/crud/mixins/dialog.js +109 -0
- package/packages/crud/mixins/excelHandler.js +150 -0
- package/packages/crud/mixins/exposeMethods.js +107 -0
- package/packages/crud/mixins/generateDynamicColumns.js +250 -0
- package/packages/crud/mixins/props.js +38 -0
- package/packages/crud/mixins/searchHandler.js +151 -0
- package/packages/crud/mixins/select.js +359 -0
- package/packages/crud/mixins/spanMethod.js +288 -0
- package/packages/crud/mixins/summary.js +177 -0
- package/packages/crud/mixins/tableEdit.js +547 -0
- package/packages/crud/mixins/validate.js +219 -0
- package/packages/crud/pagination.vue +110 -0
- package/packages/crud/search.vue +119 -0
- package/packages/crud/searchHeader.vue +231 -0
- package/packages/crud/selectBanner.vue +138 -0
- package/packages/crud/utils/EditState.js +319 -0
- package/packages/crud/utils/excelExport.js +112 -0
- package/packages/crud/utils/excelImport.js +112 -0
- package/packages/crud/utils/index.js +98 -0
- package/packages/dialog/dialog.js +233 -0
- package/packages/dialog/dialog.vue +15 -0
- package/packages/dialog/index.js +22 -0
- package/packages/dict/cascadeFormat.vue +179 -0
- package/packages/dict/dateFormat.vue +40 -0
- package/packages/dict/form/cascade.vue +61 -0
- package/packages/dict/form/checkbox.vue +90 -0
- package/packages/dict/form/extendMethod.js +22 -0
- package/packages/dict/form/input-base.js +31 -0
- package/packages/dict/form/input.js +20 -0
- package/packages/dict/form/radio.vue +69 -0
- package/packages/dict/form/select.vue +118 -0
- package/packages/dict/form/switch.vue +75 -0
- package/packages/dict/valueFormat.vue +188 -0
- package/packages/directive/dialog/drag.js +86 -0
- package/packages/directive/dialog/dragSize.js +42 -0
- package/packages/directive/index.js +9 -0
- package/packages/directive/insertSlot.js +10 -0
- package/packages/form/contextMenu.js +192 -0
- package/packages/form/draftDrawer.vue +391 -0
- package/packages/form/formAction.vue +97 -0
- package/packages/form/formItem.vue +259 -0
- package/packages/form/index.vue +451 -0
- package/packages/form/props.js +15 -0
- package/packages/grid/cell.vue +65 -0
- package/packages/grid/index.vue +130 -0
- package/packages/group/index.vue +96 -0
- package/packages/tabs/index.vue +290 -0
- package/packages/tooltip/index.js +9 -0
- package/packages/tooltip/tooltip.vue +32 -0
- package/packages/tooltip/tooltipComponent.js +38 -0
- package/packages/verifyInput/index.vue +131 -0
- package/src/config/common.js +88 -0
- package/src/config/crud.js +567 -0
- package/src/config/dialog.js +87 -0
- package/src/config/form.js +215 -0
- package/src/config/index.js +9 -0
- package/src/constants/index.js +72 -0
- package/src/index.js +67 -0
- package/src/template/btn/crud.js +6 -0
- package/src/template/btn/dialog.js +1 -0
- package/src/template/btn/form.js +3 -0
- package/src/template/btn/index.js +9 -0
- package/src/template/dicts.js +1 -0
- package/src/template/formatData.js +507 -0
- package/src/template/index.js +19 -0
- package/src/template/render.js +124 -0
- package/src/template/rules.js +53 -0
- package/src/utils/bem.js +49 -0
- package/src/utils/cache.js +77 -0
- package/src/utils/getType.js +34 -0
- package/src/utils/index.js +212 -0
- package/src/utils/mergeTemp.js +124 -0
- package/styles/button.scss +3 -0
- package/styles/crud.scss +425 -0
- package/styles/dialog.scss +95 -0
- package/styles/form.scss +532 -0
- package/styles/group.scss +78 -0
- package/styles/index.scss +94 -0
- package/styles/tabs.scss +139 -0
- package/styles/verifyInput.scss +56 -0
- package/vue-jsx-sync.js +90 -0
- package/vue.config.js +54 -0
@@ -0,0 +1,377 @@
|
|
1
|
+
# 表格编辑
|
2
|
+
|
3
|
+
表格编辑功能允许用户直接在表格中编辑数据,支持行编辑、单元格编辑和自由编辑等多种模式,以及多种触发方式。
|
4
|
+
|
5
|
+
## 基础配置
|
6
|
+
通过 editConfig 配置表格的编辑模式和触发方式。 </br>
|
7
|
+
编辑模式下,默认渲染`input`组件,需要通过包裹一层 `form` 对象才能自定义配置编辑组件。
|
8
|
+
|
9
|
+
```js
|
10
|
+
options: {
|
11
|
+
editConfig: {
|
12
|
+
// 编辑模式:row(行编辑)、cell(单元格编辑)、free(自由编辑)、dialog(弹窗编辑)
|
13
|
+
mode: 'row',
|
14
|
+
// 触发方式:manual(手动)、click(单击)、dblclick(双击)
|
15
|
+
trigger: 'manual',
|
16
|
+
// 编辑按钮触发
|
17
|
+
edit: true,
|
18
|
+
},
|
19
|
+
renderColumns: [
|
20
|
+
{
|
21
|
+
prop: 'name',
|
22
|
+
label: '姓名',
|
23
|
+
form: { // 自定义编辑组件配置
|
24
|
+
comp: {
|
25
|
+
name: 'el-select',
|
26
|
+
options: [
|
27
|
+
{
|
28
|
+
label: '选项1',
|
29
|
+
value: '选项1',
|
30
|
+
}
|
31
|
+
]
|
32
|
+
},
|
33
|
+
}
|
34
|
+
}
|
35
|
+
]
|
36
|
+
}
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
## 自由编辑
|
41
|
+
|
42
|
+
### 全局自由编辑
|
43
|
+
|
44
|
+
`mode: free` 自由编辑 </br>
|
45
|
+
自由编辑模式下,所有可编辑的单元格始终处于编辑状态。
|
46
|
+
|
47
|
+
<ClientOnly>
|
48
|
+
<common-code-format>
|
49
|
+
<crud-tableEdit-free slot="source"></crud-tableEdit-free>
|
50
|
+
|
51
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/free.vue
|
52
|
+
</common-code-format>
|
53
|
+
</ClientOnly>
|
54
|
+
|
55
|
+
### 单列自由编辑
|
56
|
+
|
57
|
+
`isEdit` 设置单列自由编辑 </br>
|
58
|
+
|
59
|
+
<ClientOnly>
|
60
|
+
<common-code-format>
|
61
|
+
<crud-tableEdit-freeColumn slot="source"></crud-tableEdit-freeColumn>
|
62
|
+
|
63
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/freeColumn.vue
|
64
|
+
</common-code-format>
|
65
|
+
</ClientOnly>
|
66
|
+
|
67
|
+
|
68
|
+
## 行编辑
|
69
|
+
|
70
|
+
### 手动触发 - 操作列
|
71
|
+
|
72
|
+
通过操作列编辑按钮 `edit`触发编辑状态。
|
73
|
+
|
74
|
+
```js
|
75
|
+
editConfig: {
|
76
|
+
mode: "row",
|
77
|
+
trigger: "manual",
|
78
|
+
edit: {} // 操作列按钮配置
|
79
|
+
}
|
80
|
+
```
|
81
|
+
|
82
|
+
#### 事件处理
|
83
|
+
|
84
|
+
`@edit(done, scope)` 点击编辑触发,参数`done(params)`,可设置编辑后的行数据 </br>
|
85
|
+
`@save(done, scope, unLoading)` 点击保存触发,参数`done(params)`,可设置保存后的行数据 </br>
|
86
|
+
`@cancel(done, scope)` 点击取消触发 </br>
|
87
|
+
|
88
|
+
<ClientOnly>
|
89
|
+
<common-code-format>
|
90
|
+
<crud-tableEdit-rowAction slot="source"></crud-tableEdit-rowAction>
|
91
|
+
|
92
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/rowAction.vue
|
93
|
+
</common-code-format>
|
94
|
+
</ClientOnly>
|
95
|
+
|
96
|
+
### 手动触发 - 批量编辑
|
97
|
+
|
98
|
+
通过批量编辑按钮 `batch` 触发编辑状态。
|
99
|
+
|
100
|
+
```js
|
101
|
+
editConfig: {
|
102
|
+
mode: "row",
|
103
|
+
trigger: "manual",
|
104
|
+
batch: {
|
105
|
+
isSelect: true, // 是否批量编辑选中项,搭配selection使用
|
106
|
+
} // 批量操作按钮配置
|
107
|
+
}
|
108
|
+
```
|
109
|
+
|
110
|
+
#### 事件处理
|
111
|
+
|
112
|
+
`@batchEdit(done, rows)` 点击批量编辑触发,参数`done(rows)`,可传递需要编辑的行,默认编辑所有行 </br>
|
113
|
+
`@batchSave(done, rows)` 点击批量保存触发,参数`done(rows)`,可传递需要保存的行,默认保存所有编辑行 </br>
|
114
|
+
`@batchCancel(done, rows)` 点击批量取消触发,参数`done(rows)`,可传递需要取消的行,默认取消所有编辑行 </br>
|
115
|
+
|
116
|
+
<ClientOnly>
|
117
|
+
<common-code-format>
|
118
|
+
<crud-tableEdit-rowBatch slot="source"></crud-tableEdit-rowBatch>
|
119
|
+
|
120
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/rowBatch.vue
|
121
|
+
</common-code-format>
|
122
|
+
</ClientOnly>
|
123
|
+
|
124
|
+
### 手动触发 - 调用方法
|
125
|
+
|
126
|
+
<ClientOnly>
|
127
|
+
<common-code-format>
|
128
|
+
<crud-tableEdit-methods slot="source"></crud-tableEdit-methods>
|
129
|
+
|
130
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/methods.vue
|
131
|
+
</common-code-format>
|
132
|
+
</ClientOnly>
|
133
|
+
|
134
|
+
|
135
|
+
### 单击触发
|
136
|
+
|
137
|
+
点击行时触发编辑状态。
|
138
|
+
|
139
|
+
```js
|
140
|
+
editConfig: {
|
141
|
+
mode: "row",
|
142
|
+
trigger: "click",
|
143
|
+
}
|
144
|
+
```
|
145
|
+
|
146
|
+
#### 事件处理
|
147
|
+
|
148
|
+
`@edit(done, scope)` 点击编辑触发,参数`done(params)`,可设置编辑后的行数据 </br>
|
149
|
+
`@save(done, scope, unLoading)` 点击保存触发,参数`done(params)`,可设置保存后的行数据 </br>
|
150
|
+
|
151
|
+
<ClientOnly>
|
152
|
+
<common-code-format>
|
153
|
+
<crud-tableEdit-rowClick slot="source"></crud-tableEdit-rowClick>
|
154
|
+
|
155
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/rowClick.vue
|
156
|
+
</common-code-format>
|
157
|
+
</ClientOnly>
|
158
|
+
|
159
|
+
|
160
|
+
## 单元格编辑
|
161
|
+
|
162
|
+
单元格编辑模式下,点击或双击单元格时,只有该单元格进入编辑状态
|
163
|
+
|
164
|
+
```js
|
165
|
+
editConfig: {
|
166
|
+
mode: "cell",
|
167
|
+
}
|
168
|
+
```
|
169
|
+
|
170
|
+
#### 事件处理
|
171
|
+
|
172
|
+
`@edit(done, scope, column)` 点击编辑触发,参数`done(params)`,可设置编辑后的数据 </br>
|
173
|
+
`@save(done, value, scope, column, unLoading)` 点击保存触发,参数`done(params)`,可设置保存后的数据 </br>
|
174
|
+
|
175
|
+
<ClientOnly>
|
176
|
+
<common-code-format>
|
177
|
+
<crud-tableEdit-cellEdit slot="source"></crud-tableEdit-cellEdit>
|
178
|
+
|
179
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/cellEdit.vue
|
180
|
+
</common-code-format>
|
181
|
+
</ClientOnly>
|
182
|
+
|
183
|
+
## 控制编辑状态
|
184
|
+
|
185
|
+
`isRowEdit` 控制行编辑状态 </br>
|
186
|
+
`isEdit` 控制列与单元格编辑状态
|
187
|
+
|
188
|
+
```js
|
189
|
+
options: {
|
190
|
+
editConfig: {
|
191
|
+
isRowEdit: (row) => { //控制行编辑状态
|
192
|
+
return row.id % 2 === 0;
|
193
|
+
}
|
194
|
+
}
|
195
|
+
renderColumns: [
|
196
|
+
{
|
197
|
+
prop: 'name',
|
198
|
+
label: '姓名',
|
199
|
+
isEdit: (row) => { //控制单元格编辑状态
|
200
|
+
return row.id % 2 === 0;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
]
|
204
|
+
}
|
205
|
+
```
|
206
|
+
<ClientOnly>
|
207
|
+
<common-code-format>
|
208
|
+
<crud-tableEdit-controlEdit slot="source"></crud-tableEdit-controlEdit>
|
209
|
+
|
210
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/controlEdit.vue
|
211
|
+
</common-code-format>
|
212
|
+
</ClientOnly>
|
213
|
+
|
214
|
+
|
215
|
+
## 新增删除操作
|
216
|
+
|
217
|
+
### 基本配置
|
218
|
+
|
219
|
+
```js
|
220
|
+
editConfig: {
|
221
|
+
mode: 'row',
|
222
|
+
trigger: 'manual',
|
223
|
+
rowEdit: {
|
224
|
+
hasPermi: ['xx'] // 可以用于设置按钮权限等
|
225
|
+
},
|
226
|
+
// 底部新增行按钮配置
|
227
|
+
lastAdd: {
|
228
|
+
type: 'last', // first(第一行新增)、last(最后一行新增)
|
229
|
+
},
|
230
|
+
// 新增行按钮配置
|
231
|
+
rowAdd: {
|
232
|
+
type: 'first', // first(第一行新增)、last(最后一行新增)
|
233
|
+
},
|
234
|
+
// 批量删除按钮配置
|
235
|
+
batchDelete: {
|
236
|
+
confirm: (rows) => `是否删除序号为${rows.map(row => row.$index + 1).join(',')}的数据?`, // 删除提示
|
237
|
+
},
|
238
|
+
// 删除按钮配置
|
239
|
+
delete: {
|
240
|
+
confirm: (scope) => `是否删除序号为${scope.$index + 1}的数据?`, // 删除提示
|
241
|
+
},
|
242
|
+
},
|
243
|
+
```
|
244
|
+
|
245
|
+
### 事件处理
|
246
|
+
|
247
|
+
`@add` 点击新增触发,参数`done(params)`,可设置新增的行数据 </br>
|
248
|
+
`@delete` 点击删除触发 </br>
|
249
|
+
`@batchDelete` 点击批量删除触发 </br>
|
250
|
+
|
251
|
+
|
252
|
+
<ClientOnly>
|
253
|
+
<common-code-format>
|
254
|
+
<crud-tableEdit-addDeleteBtn slot="source"></crud-tableEdit-addDeleteBtn>
|
255
|
+
|
256
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/addDeleteBtn.vue
|
257
|
+
</common-code-format>
|
258
|
+
</ClientOnly>
|
259
|
+
|
260
|
+
|
261
|
+
## 弹窗编辑
|
262
|
+
|
263
|
+
### 基本配置
|
264
|
+
|
265
|
+
```js
|
266
|
+
options: {
|
267
|
+
editConfig: {
|
268
|
+
mode: 'dialog',
|
269
|
+
// 编辑按钮配置
|
270
|
+
edit: {},
|
271
|
+
// 新增按钮配置
|
272
|
+
add: {
|
273
|
+
type: 'first', // first(第一行新增)、last(最后一行新增)
|
274
|
+
},
|
275
|
+
// 查看按钮配置
|
276
|
+
view: {},
|
277
|
+
},
|
278
|
+
dialog: {}, // 自定义弹窗配置
|
279
|
+
formOptions: {}, // 自定义表单配置
|
280
|
+
}
|
281
|
+
```
|
282
|
+
|
283
|
+
### 事件处理
|
284
|
+
|
285
|
+
`@add` 点击新增触发 </br>
|
286
|
+
`@edit` 点击编辑触发 </br>
|
287
|
+
`@save` 点击保存触发 </br>
|
288
|
+
`@view` 点击查看触发 </br>
|
289
|
+
|
290
|
+
<ClientOnly>
|
291
|
+
<common-code-format>
|
292
|
+
<crud-tableEdit-dialog slot="source"></crud-tableEdit-dialog>
|
293
|
+
|
294
|
+
<<< @/docs/.vuepress/components/crud/tableEdit/dialog.vue
|
295
|
+
</common-code-format>
|
296
|
+
</ClientOnly>
|
297
|
+
|
298
|
+
|
299
|
+
## API
|
300
|
+
|
301
|
+
### editConfig 配置
|
302
|
+
|
303
|
+
| 参数 | 说明 | 类型 | 可选值 |
|
304
|
+
| ----------- | -------------------------------- | ----------------------- | --------------------- |
|
305
|
+
| mode | 编辑模式 | string | free,cell,row,dialog |
|
306
|
+
| trigger | 触发方式 | string | manual,click,dblclick |
|
307
|
+
| edit | 编辑按钮配置 | object | - |
|
308
|
+
| batch | 批量操作按钮配置,仅限`row`模式 | object | - |
|
309
|
+
| add | 新增按钮配置 | object | - |
|
310
|
+
| lastAdd | 底部新增行按钮配置 | object | - |
|
311
|
+
| batchDelete | 批量删除按钮配置 | object | - |
|
312
|
+
| delete | 删除按钮配置 | object | - |
|
313
|
+
| view | 查看按钮配置,仅限`dialog`模式 | object | - |
|
314
|
+
| isRowEdit | 控制行是否可编辑 | function({row, $index}) | - |
|
315
|
+
| autofocus | 是否自动聚焦,支持字符串(prop) | boolean/string | true |
|
316
|
+
| exclusive | 行编辑是否互斥(同时只能编辑一行) | boolean | false |
|
317
|
+
|
318
|
+
### Column 配置
|
319
|
+
|
320
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
321
|
+
| ----------------- | -------------------- | ------------------------------- | ----------------- |
|
322
|
+
| isEdit | 是否可编辑 | boolean/function({row, $index}) | false |
|
323
|
+
| add | 仅自定义新增组件 | boolean/Object | 默认继承form配置 |
|
324
|
+
| edit | 仅自定义编辑组件 | boolean/Object | 默认继承form配置 |
|
325
|
+
| form | 自定义编辑、新增组件 | boolean/Object | - |
|
326
|
+
| form.prop | 编辑字段 | boolean/Object | 默认继承列的prop |
|
327
|
+
| form.comp | 编辑组件 | object | el-input |
|
328
|
+
| form.render | 编辑组件渲染函数 | function | - |
|
329
|
+
| form.validateProp | 编辑组件验证字段 | string | 默认继承form.prop |
|
330
|
+
|
331
|
+
### slots
|
332
|
+
|
333
|
+
| 插槽名 | 说明 | 默认值 |
|
334
|
+
| ------------- | -------------------- | ------------ |
|
335
|
+
| `{prop}-form` | 自定义编辑、新增组件 | - |
|
336
|
+
| `{prop}-add` | 仅自定义新增组件 | 默认继承form |
|
337
|
+
| `{prop}-edit` | 仅自定义编辑组件 | 默认继承form |
|
338
|
+
|
339
|
+
|
340
|
+
### Events
|
341
|
+
|
342
|
+
|
343
|
+
| 事件名 | 说明 | 参数 |
|
344
|
+
| ----------------- | --------------------------------- | ------------------------------- |
|
345
|
+
| @add | 点击新增按钮时 | done(params), scope |
|
346
|
+
| @edit | 点击编辑按钮时 | done(params), scope |
|
347
|
+
| @save | 点击保存按钮时 | done(params), scope, unLoading |
|
348
|
+
| @cancel | 点击取消按钮时 | done(params), scope |
|
349
|
+
| @delete | 点击删除按钮时 | done, scope, unLoading |
|
350
|
+
| @view | 点击查看按钮时,仅限`dialog`模式 | done, scope |
|
351
|
+
| @batchEdit | 点击批量编辑按钮时,仅限`row`模式 | done(rows), rows |
|
352
|
+
| @batchSave | 点击批量保存按钮时,仅限`row`模式 | done(rows), rows, unLoading |
|
353
|
+
| @batchCancel | 点击批量取消按钮时,仅限`row`模式 | done(rows) |
|
354
|
+
| @batchDelete | 点击批量删除按钮时,仅限`row`模式 | done, rows, unLoading |
|
355
|
+
| @editStatusChange | 编辑状态变化时触发 | {mode, rowKey, row, prop, type} |
|
356
|
+
|
357
|
+
### Methods
|
358
|
+
|
359
|
+
| 方法名 | 说明 | 参数 | 返回值 |
|
360
|
+
| -------------- | ---------------------------------------- | ----------------------------------------------------------- | ------ |
|
361
|
+
| setRowEdit | 设置行编辑状态 | (rows: object/array, options: {type: string, prop: string}) | - |
|
362
|
+
| setBatchEdit | 批量设置行编辑状态,不传rows则设置所有行 | (type: string, rows: object/array) | - |
|
363
|
+
| setCellEdit | 设置单元格编辑状态 | (row: object, prop: string) | - |
|
364
|
+
| addRow | 新增表格行 | (params: object, type: first/last) | - |
|
365
|
+
| clearAllEdit | 清除所有编辑状态 | - | - |
|
366
|
+
| getEditingRows | 获取所有编辑状态的行 | - | array |
|
367
|
+
|
368
|
+
### options 快捷配置
|
369
|
+
|
370
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
371
|
+
| ------------ | ----------------------- | ----------------------- | ------ |
|
372
|
+
| freeEdit | 启用自由编辑模式 | boolean | false |
|
373
|
+
| cellEdit | 启用单元格编辑模式 | boolean | false |
|
374
|
+
| rowEdit | 启用行编辑模式 | boolean | false |
|
375
|
+
| batchEdit | 启用批量编辑模式 | boolean | false |
|
376
|
+
| batchRowEdit | 启用行编辑+批量编辑模式 | boolean | false |
|
377
|
+
| isRowEdit | 控制行是否可编辑的函数 | function({row, $index}) | - |
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# 表格校验
|
2
|
+
|
3
|
+
表格组件支持表单校验功能,包括必填校验、正则校验和自定义校验规则。同时提供了错误提示和错误状态管理。
|
4
|
+
|
5
|
+
## 基础用法
|
6
|
+
|
7
|
+
通过配置列的 `required` 属性来启用必填校验。支持布尔值和对象两种配置方式:
|
8
|
+
|
9
|
+
```js
|
10
|
+
renderColumns: [
|
11
|
+
{
|
12
|
+
prop: "name",
|
13
|
+
label: "姓名",
|
14
|
+
required: true // 简单配置
|
15
|
+
},
|
16
|
+
{
|
17
|
+
prop: "age",
|
18
|
+
label: "年龄",
|
19
|
+
required: { // 详细配置
|
20
|
+
message: "年龄不能为空",
|
21
|
+
trigger: "blur"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
]
|
25
|
+
```
|
26
|
+
|
27
|
+
<ClientOnly>
|
28
|
+
<common-code-format>
|
29
|
+
<crud-validate-base slot="source"></crud-validate-base>
|
30
|
+
|
31
|
+
<<< @/docs/.vuepress/components/crud/validate/base.vue
|
32
|
+
</common-code-format>
|
33
|
+
</ClientOnly>
|
34
|
+
|
35
|
+
## 正则校验
|
36
|
+
|
37
|
+
通过配置列的 `rules` 属性来添加正则校验规则。支持内置正则模板和自定义正则对象:
|
38
|
+
|
39
|
+
```js
|
40
|
+
renderColumns: [
|
41
|
+
{
|
42
|
+
prop: "phone",
|
43
|
+
label: "手机号",
|
44
|
+
rules: ["integer"] // 使用内置正则或预设规则
|
45
|
+
},
|
46
|
+
{
|
47
|
+
prop: "email",
|
48
|
+
label: "邮箱",
|
49
|
+
rules: [{ // 自定义正则
|
50
|
+
regular: /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
51
|
+
message: "请输入正确的邮箱格式"
|
52
|
+
}]
|
53
|
+
}
|
54
|
+
]
|
55
|
+
```
|
56
|
+
|
57
|
+
<ClientOnly>
|
58
|
+
<common-code-format>
|
59
|
+
<crud-validate-regulars slot="source"></crud-validate-regulars>
|
60
|
+
|
61
|
+
<<< @/docs/.vuepress/components/crud/validate/regulars.vue
|
62
|
+
</common-code-format>
|
63
|
+
</ClientOnly>
|
64
|
+
|
65
|
+
## 自定义校验
|
66
|
+
|
67
|
+
通过配置 `rules` 的 validator 函数来自定义校验规则。支持获取 `scope` 参数:
|
68
|
+
|
69
|
+
```js
|
70
|
+
renderColumns: [
|
71
|
+
{
|
72
|
+
prop: "age",
|
73
|
+
label: "年龄",
|
74
|
+
rules: [{
|
75
|
+
validator: (rule, value, callback, scope) => {
|
76
|
+
if (value < 18) {
|
77
|
+
callback(new Error("年龄不能小于18岁"));
|
78
|
+
} else {
|
79
|
+
callback();
|
80
|
+
}
|
81
|
+
},
|
82
|
+
trigger: "change"
|
83
|
+
}]
|
84
|
+
},
|
85
|
+
{
|
86
|
+
prop: "age",
|
87
|
+
label: "年龄",
|
88
|
+
rules: (scope)=>[{
|
89
|
+
validator: (rule, value, callback) => {
|
90
|
+
if (value < 18) {
|
91
|
+
callback(new Error("年龄不能小于18岁"));
|
92
|
+
} else {
|
93
|
+
callback();
|
94
|
+
}
|
95
|
+
},
|
96
|
+
trigger: "change"
|
97
|
+
}]
|
98
|
+
}
|
99
|
+
]
|
100
|
+
```
|
101
|
+
|
102
|
+
<ClientOnly>
|
103
|
+
<common-code-format>
|
104
|
+
<crud-validate-custom slot="source"></crud-validate-custom>
|
105
|
+
|
106
|
+
<<< @/docs/.vuepress/components/crud/validate/custom.vue
|
107
|
+
</common-code-format>
|
108
|
+
</ClientOnly>
|
109
|
+
|
110
|
+
|
111
|
+
## 树级校验
|
112
|
+
|
113
|
+
<ClientOnly>
|
114
|
+
<common-code-format>
|
115
|
+
<crud-validate-tree slot="source"></crud-validate-tree>
|
116
|
+
|
117
|
+
<<< @/docs/.vuepress/components/crud/validate/tree.vue
|
118
|
+
</common-code-format>
|
119
|
+
</ClientOnly>
|
120
|
+
|
121
|
+
|
122
|
+
## 联动校验
|
123
|
+
|
124
|
+
通过方法 `validateField` 函数来精确控制每个校验单元格。
|
125
|
+
|
126
|
+
<ClientOnly>
|
127
|
+
<common-code-format>
|
128
|
+
<crud-validate-relation slot="source"></crud-validate-relation>
|
129
|
+
|
130
|
+
<<< @/docs/.vuepress/components/crud/validate/relation.vue
|
131
|
+
</common-code-format>
|
132
|
+
</ClientOnly>
|
133
|
+
|
134
|
+
## API
|
135
|
+
|
136
|
+
### Column 配置
|
137
|
+
|
138
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
139
|
+
| -------- | -------- | ---------------------------- | ------ |
|
140
|
+
| required | 是否必填 | boolean/object | false |
|
141
|
+
| rules | 校验规则 | string/array/function(scope) | - |
|
142
|
+
|
143
|
+
### 实例方法
|
144
|
+
|
145
|
+
| 方法名 | 说明 | 参数 | 返回值 |
|
146
|
+
| ------------- | ------------ | ----------------------------- | ------- |
|
147
|
+
| validate | 校验整个表格 | callback(可选) | Promise |
|
148
|
+
| validateField | 校验指定行 | options: {index/id/row, prop} | Promise |
|
149
|
+
| clearValidate | 清除校验 | - | - |
|
150
|
+
|
151
|
+
### validateField Options
|
152
|
+
|
153
|
+
| 参数 | 说明 | 类型 |
|
154
|
+
| ----- | ------------ | ------------- |
|
155
|
+
| index | 行索引 | number |
|
156
|
+
| id | 行ID | string/number |
|
157
|
+
| row | 行数据对象 | object |
|
158
|
+
| prop | 校验的字段名 | string |
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# 基本使用
|
2
|
+
|
3
|
+
## 基本使用
|
4
|
+
|
5
|
+
`title` 标题、`width` 宽度 。详情参考element-ui弹窗组件配置[element-ui](https://element.eleme.cn/#/zh-CN/component/dialog) </br>
|
6
|
+
`show()` 打开弹窗 </br>
|
7
|
+
弹窗渲染方式依旧为通用的 `render函数`,`component配置`</br>
|
8
|
+
|
9
|
+
<ClientOnly>
|
10
|
+
<common-code-format>
|
11
|
+
<dialog-baseUse-base slot="source"></dialog-baseUse-base>
|
12
|
+
|
13
|
+
<<< @/docs/.vuepress/components/dialog/baseUse/base.vue
|
14
|
+
</common-code-format>
|
15
|
+
</ClientOnly>
|
16
|
+
|
17
|
+
## 通过实例控制弹窗
|
18
|
+
|
19
|
+
`hide()` 手动关闭弹窗 </br>
|
20
|
+
`loading` 控制loading
|
21
|
+
|
22
|
+
<ClientOnly>
|
23
|
+
<common-code-format>
|
24
|
+
<dialog-baseUse-control slot="source"></dialog-baseUse-control>
|
25
|
+
|
26
|
+
<<< @/docs/.vuepress/components/dialog/baseUse/control.vue
|
27
|
+
</common-code-format>
|
28
|
+
</ClientOnly>
|
29
|
+
|
30
|
+
<!-- ## v-insertSlot插入插槽渲染弹窗
|
31
|
+
|
32
|
+
`v-insertSlot` 获取模板,插入弹窗实例</br>
|
33
|
+
|
34
|
+
<ClientOnly>
|
35
|
+
<common-code-format>
|
36
|
+
<dialog-baseUse-insertSlot slot="source"></dialog-baseUse-insertSlot>
|
37
|
+
|
38
|
+
<<< @/docs/.vuepress/components/dialog/baseUse/insertSlot.vue
|
39
|
+
</common-code-format>
|
40
|
+
</ClientOnly> -->
|
41
|
+
|
42
|
+
|
43
|
+
## 确认,取消关闭前方法
|
44
|
+
|
45
|
+
`confirm` 确认之前、`cancel` 取消之前</br>
|
46
|
+
|
47
|
+
<ClientOnly>
|
48
|
+
<common-code-format>
|
49
|
+
<dialog-baseUse-beforeConfirm slot="source"></dialog-baseUse-beforeConfirm>
|
50
|
+
|
51
|
+
<<< @/docs/.vuepress/components/dialog/baseUse/beforeConfirm.vue
|
52
|
+
</common-code-format>
|
53
|
+
</ClientOnly>
|
54
|
+
|
55
|
+
|
56
|
+
## 自定义底部按钮
|
57
|
+
|
58
|
+
`footer` 自定义底部按钮</br>
|
59
|
+
`footer.align` 底部对齐方式</br>
|
60
|
+
`footer` 为`false`时或 `footer.hidden` 为`true` 隐藏底部
|
61
|
+
|
62
|
+
<ClientOnly>
|
63
|
+
<common-code-format>
|
64
|
+
<dialog-baseUse-footer slot="source"></dialog-baseUse-footer>
|
65
|
+
|
66
|
+
<<< @/docs/.vuepress/components/dialog/baseUse/footer.vue
|
67
|
+
</common-code-format>
|
68
|
+
</ClientOnly>
|
69
|
+
|
70
|
+
|
71
|
+
## 抽屉式弹窗
|
72
|
+
|
73
|
+
`drawer` 抽屉式弹窗, 详情参考element-ui抽屉组件配置[element-ui](https://element.eleme.cn/#/zh-CN/component/drawer)
|
74
|
+
|
75
|
+
<ClientOnly>
|
76
|
+
<common-code-format>
|
77
|
+
<dialog-baseUse-drawer slot="source"></dialog-baseUse-drawer>
|
78
|
+
|
79
|
+
<<< @/docs/.vuepress/components/dialog/baseUse/drawer.vue
|
80
|
+
</common-code-format>
|
81
|
+
</ClientOnly>
|