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,174 @@
|
|
1
|
+
# 基本使用
|
2
|
+
|
3
|
+
## 使用字典+增强方法
|
4
|
+
|
5
|
+
默认字典与全局字典无需注册,直接使用即可 <br>
|
6
|
+
|
7
|
+
<ClientOnly>
|
8
|
+
<common-code-format>
|
9
|
+
<dict-baseUse slot="source"></dict-baseUse>
|
10
|
+
|
11
|
+
<<< @/docs/.vuepress/components/dict/baseUse.vue
|
12
|
+
</common-code-format>
|
13
|
+
</ClientOnly>
|
14
|
+
|
15
|
+
|
16
|
+
## 字典联动
|
17
|
+
|
18
|
+
<ClientOnly>
|
19
|
+
<common-code-format>
|
20
|
+
<dict-DictLinkage slot="source"></dict-DictLinkage>
|
21
|
+
|
22
|
+
<<< @/docs/.vuepress/components/dict/DictLinkage.vue
|
23
|
+
</common-code-format>
|
24
|
+
</ClientOnly>
|
25
|
+
|
26
|
+
## 局部字典+联动
|
27
|
+
|
28
|
+
字典数据不共用,需要配合现有组件使用,`local` 设置局部字典 <br>
|
29
|
+
|
30
|
+
<ClientOnly>
|
31
|
+
<common-code-format>
|
32
|
+
<dict-localDict slot="source"></dict-localDict>
|
33
|
+
|
34
|
+
<<< @/docs/.vuepress/components/dict/localDict.vue
|
35
|
+
</common-code-format>
|
36
|
+
</ClientOnly>
|
37
|
+
|
38
|
+
## 字典配合组件使用
|
39
|
+
|
40
|
+
<ClientOnly>
|
41
|
+
<common-code-format>
|
42
|
+
<dict-component slot="source"></dict-component>
|
43
|
+
|
44
|
+
<<< @/docs/.vuepress/components/dict/component.vue
|
45
|
+
</common-code-format>
|
46
|
+
</ClientOnly>
|
47
|
+
|
48
|
+
## 全局注册
|
49
|
+
|
50
|
+
```javascript
|
51
|
+
import superCrud from "src";
|
52
|
+
|
53
|
+
Vue.use(superCrud, {
|
54
|
+
// 默认字典配置项
|
55
|
+
dict: {
|
56
|
+
request: (key) => request({
|
57
|
+
url: '/dict/type/' + key,
|
58
|
+
method: 'get'
|
59
|
+
}),
|
60
|
+
value: "value",
|
61
|
+
label: "label",
|
62
|
+
color: "color",
|
63
|
+
children: "children",
|
64
|
+
},
|
65
|
+
// 注册全局字典模板
|
66
|
+
template: {
|
67
|
+
dicts: {
|
68
|
+
userStatus: {
|
69
|
+
request: () => request('/api/user/status'),
|
70
|
+
transform: (data) => {
|
71
|
+
return data.map(item => ({
|
72
|
+
label: item.name,
|
73
|
+
value: item.id
|
74
|
+
}))
|
75
|
+
}
|
76
|
+
},
|
77
|
+
userList: {
|
78
|
+
request: () => request('/api/user/list'),
|
79
|
+
}
|
80
|
+
}
|
81
|
+
},
|
82
|
+
});
|
83
|
+
```
|
84
|
+
|
85
|
+
全局注册的字典直接使用即可, 会通过 `$scDict[key]` 自动获取字典数据 <br>
|
86
|
+
|
87
|
+
`key` 为字典的注册名称:
|
88
|
+
- 匹配到名为key的`全局字典模板`
|
89
|
+
- 如果匹配不到名为key的`全局字典模板`,会自动将key作为`默认字典`请求函数的`参数`
|
90
|
+
|
91
|
+
```vue
|
92
|
+
<template>
|
93
|
+
<div>
|
94
|
+
{{ $scDict.userStatus }}
|
95
|
+
</div>
|
96
|
+
</template>
|
97
|
+
<script>
|
98
|
+
export default {
|
99
|
+
async created() {
|
100
|
+
await this.$scDict.sys_normal_disable.wait();
|
101
|
+
console.log(this.$scDict.sys_normal_disable);
|
102
|
+
},
|
103
|
+
};
|
104
|
+
</script>
|
105
|
+
```
|
106
|
+
|
107
|
+
## 字典注册
|
108
|
+
```javascript
|
109
|
+
// 方式一:直接传入请求函数
|
110
|
+
this.$scDict.register('userStatus', request('/api/user/status'))
|
111
|
+
|
112
|
+
// 方式二:传入配置对象
|
113
|
+
this.$scDict.register('userList', {
|
114
|
+
request: () => request('/api/user/list'),
|
115
|
+
immediate: true,
|
116
|
+
transform: (data) => {
|
117
|
+
return data.map(item => ({
|
118
|
+
label: item.name,
|
119
|
+
value: item.id
|
120
|
+
}))
|
121
|
+
}
|
122
|
+
})
|
123
|
+
|
124
|
+
// 方式三:本地静态数据
|
125
|
+
this.$scDict.register('gender', {
|
126
|
+
options: [
|
127
|
+
{ label: '男', value: 1 },
|
128
|
+
{ label: '女', value: 2 }
|
129
|
+
]
|
130
|
+
})
|
131
|
+
|
132
|
+
// 批量注册
|
133
|
+
this.$scDict.registerBatch({
|
134
|
+
gender: {
|
135
|
+
options: [
|
136
|
+
{ label: '男', value: 1 },
|
137
|
+
{ label: '女', value: 2 }
|
138
|
+
]
|
139
|
+
},
|
140
|
+
userStatus: () => request('/api/user/status'),
|
141
|
+
userList: () => request('/api/user/list'),
|
142
|
+
})
|
143
|
+
```
|
144
|
+
|
145
|
+
## 动态参数
|
146
|
+
|
147
|
+
```javascript
|
148
|
+
// 参数为函数形式时监听响应式数据变化
|
149
|
+
this.$scDict.register('cityList', {
|
150
|
+
request: (params) => request('/api/cities', params),
|
151
|
+
params: () => ({
|
152
|
+
provinceId: this.selectedProvince
|
153
|
+
}),
|
154
|
+
immediate: true // 会立即执行 params 函数并请求数据
|
155
|
+
})
|
156
|
+
|
157
|
+
// 手动传入参数
|
158
|
+
this.$scDict.get('cityList', { provinceId: 1 })
|
159
|
+
```
|
160
|
+
|
161
|
+
## 自定义增强方法
|
162
|
+
|
163
|
+
```javascript
|
164
|
+
this.$scDict.register('countries', {
|
165
|
+
request: mockApi.getProvinces,
|
166
|
+
enhanceDict: {
|
167
|
+
customFindLabel: (value, key, dictData, meta) =>
|
168
|
+
dictData.find((item) => item.value === value)?.label,
|
169
|
+
},
|
170
|
+
});
|
171
|
+
|
172
|
+
// 使用
|
173
|
+
this.$scDict.countries.customFindLabel(1)
|
174
|
+
```
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# 字典组件
|
2
|
+
## 展示组件
|
3
|
+
### DateFormat 日期格式化
|
4
|
+
用于格式化日期时间的展示。
|
5
|
+
|
6
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
7
|
+
| ----------- | ---------------------------------------- | ------ | ------------------- |
|
8
|
+
| value | 日期时间值,支持long、string、date等格式 | any | - |
|
9
|
+
| valueFormat | 输入格式化,不传则由dayjs自动转化 | string | - |
|
10
|
+
| format | 输出格式化 | string | YYYY-MM-DD HH:mm:ss |
|
11
|
+
### ValueFormat 值格式化
|
12
|
+
用于将值格式化为标签形式展示。
|
13
|
+
|
14
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
15
|
+
| ----------- | ------------------------------------------------------ | ------------ | ------------------------------------------- |
|
16
|
+
| value | 需要格式化的值,多选支持'1,2,3'或[1,2,3] | string/array | - |
|
17
|
+
| multiple | 是否多选 | boolean | true |
|
18
|
+
| separator | 多选值的分隔符 | string | , |
|
19
|
+
| color | 标签颜色,支持auto/primary/success/warning/danger/info | string | - |
|
20
|
+
| effect | 标签主题 | string | - |
|
21
|
+
| autoColors | 自动颜色列表 | array | ['primary', 'success', 'warning', 'danger'] |
|
22
|
+
| autoEffects | 自动主题列表 | array | ['light', 'plain'] |
|
23
|
+
| scope | 其他组件传入的参数 | object | - |
|
24
|
+
| props | 配置选项 | object | {value:'value', label:'label'} |
|
25
|
+
### CascadeFormat 级联数据格式化
|
26
|
+
用于格式化级联数据的展示。
|
27
|
+
|
28
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
29
|
+
| --------- | --------------------------------------------------------------- | ------------ | ------------------------------ |
|
30
|
+
| value | 级联值,单选时支持'1,2,3'或[1,2,3],多选时支持[[1,2,3],[4,5,6]] | string/array | - |
|
31
|
+
| separator | 值的分隔符 | string | , |
|
32
|
+
| multiple | 是否多选 | boolean | false |
|
33
|
+
| scope | 其他组件传入的参数 | object | - |
|
34
|
+
| options | 可选项数据源 | array | - |
|
35
|
+
| props | 配置选项 | object | {value:'value', label:'label'} |
|
36
|
+
## 表单组件
|
37
|
+
|
38
|
+
`el-select`,`el-cascader`,`el-checkbox-group`,`el-radio-group`,`el-switch`组件在使用`comp`进行组件渲染时已默认映射为封装的字典组件
|
39
|
+
|
40
|
+
### Select 选择器
|
41
|
+
基于el-select的字典选择器。
|
42
|
+
|
43
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
44
|
+
| --------- | -------------------------------- | --------------------------- | ------------------------------ |
|
45
|
+
| value | 选中值,多选支持'1,2,3'或[1,2,3] | number/string/boolean/array | - |
|
46
|
+
| separator | 多选值的分隔符 | string | , |
|
47
|
+
| multiple | 是否多选 | boolean | false |
|
48
|
+
| scope | 其他组件传入的参数 | object | - |
|
49
|
+
| options | 可选项数据源 | array | - |
|
50
|
+
| props | 配置选项 | object | {value:'value', label:'label'} |
|
51
|
+
### Switch 开关
|
52
|
+
基于el-switch的字典开关。
|
53
|
+
|
54
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
55
|
+
| ------- | ------------------ | ------ | ------------------------------ |
|
56
|
+
| value | 开关值 | any | - |
|
57
|
+
| scope | 其他组件传入的参数 | object | - |
|
58
|
+
| options | 可选项数据源 | array | - |
|
59
|
+
| props | 配置选项 | object | {value:'value', label:'label'} |
|
60
|
+
### Radio 单选框
|
61
|
+
基于el-radio-group的字典单选框。
|
62
|
+
|
63
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
64
|
+
| ------- | ------------------------------------------- | ------ | ------------------------------ |
|
65
|
+
| value | 选中值 | any | - |
|
66
|
+
| type | 单选框类型,可选值:el-radio/el-radio-button | string | el-radio |
|
67
|
+
| scope | 其他组件传入的参数 | object | - |
|
68
|
+
| options | 可选项数据源 | array | - |
|
69
|
+
| props | 配置选项 | object | {value:'value', label:'label'} |
|
70
|
+
### Checkbox 复选框
|
71
|
+
基于el-checkbox-group的字典复选框。
|
72
|
+
|
73
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
74
|
+
| --------- | ------------------------------------------------- | --------------------------- | ------------------------------ |
|
75
|
+
| value | 选中值,多选支持'1,2,3'或[1,2,3] | number/string/boolean/array | - |
|
76
|
+
| separator | 值的分隔符 | string | , |
|
77
|
+
| type | 复选框类型,可选值:el-checkbox/el-checkbox-button | string | el-checkbox |
|
78
|
+
| scope | 其他组件传入的参数 | object | - |
|
79
|
+
| options | 可选项数据源 | array | - |
|
80
|
+
| props | 配置选项 | object | {value:'value', label:'label'} |
|
81
|
+
### Cascade 级联选择器
|
82
|
+
基于el-cascader的字典级联选择器。
|
83
|
+
|
84
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
85
|
+
| ------- | -------------------------------- | ------ | ------ |
|
86
|
+
| value | 选中值,多选支持'1,2,3'或[1,2,3] | array | [] |
|
87
|
+
| scope | 其他组件传入的参数 | object | - |
|
88
|
+
| options | 可选项数据源 | array | - |
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# 配置文档
|
2
|
+
|
3
|
+
## 基础配置项
|
4
|
+
|
5
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
6
|
+
| ------------ | --------------- | -------- | ------------------------------------------ |
|
7
|
+
| request | Function | - | 字典数据请求函数(返回Promise) |
|
8
|
+
| label | String | label | 标签字段名 |
|
9
|
+
| value | String | value | 值字段名 |
|
10
|
+
| color | String | color | 颜色字段名 |
|
11
|
+
| children | String | children | 子节点字段名 |
|
12
|
+
| params | Object/Function | - | 请求参数,支持函数形式监听响应式数据变化 |
|
13
|
+
| immediate | Boolean | false | 是否立即加载,默认为懒加载,即使用时才加载 |
|
14
|
+
| cache | Boolean | true | 是否启用缓存 |
|
15
|
+
| dataPath | String | data | 字典数组的路径 |
|
16
|
+
| transform | Function | - | 数据转换函数 |
|
17
|
+
| otherPath | String/Array | - | 需要额外获取的数据路径 |
|
18
|
+
| debounceTime | Number | 300 | 防抖时间(毫秒) |
|
19
|
+
| enhanceDict | Object | - | 自定义增强方法 |
|
20
|
+
| local | Boolean | false | 是否启用局部字典,组件配置使用时,才有效 |
|
21
|
+
|
22
|
+
## 字典方法
|
23
|
+
|
24
|
+
| 方法名 | 说明 | 参数 |
|
25
|
+
| ------------- | ------------------------------------------------- | ------------- |
|
26
|
+
| register | 注册字典 | (key, config) |
|
27
|
+
| registerBatch | 批量注册字典 | (config) |
|
28
|
+
| get | 获取字典 | (key, params) |
|
29
|
+
| clear | 清空字典,不传参数则清空所有字典 | (key) |
|
30
|
+
| wait | 等待字典加载完成 ,不传参数则等待所有字典加载完成 | (key) |
|
31
|
+
|
32
|
+
## 字典数据增强方法
|
33
|
+
|
34
|
+
每个字典数组都会被自动注入以下方法:
|
35
|
+
|
36
|
+
| 方法名 | 说明 | 返回值 |
|
37
|
+
| ---------------- | --------------------------- | ------- |
|
38
|
+
| findLabel(value) | 根据值查找对应的标签 | String |
|
39
|
+
| toMap() | 将字典转换为值-标签映射对象 | Object |
|
40
|
+
| values() | 获取所有值的数组 | Array |
|
41
|
+
| labels() | 获取所有标签的数组 | Array |
|
42
|
+
| getOption(value) | 根据值获取完整选项 | Object |
|
43
|
+
| wait() | 等待字典加载完成 | Promise |
|
44
|
+
| ready | 字典是否加载完成的变量 | Boolean |
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# 基本使用
|
2
|
+
|
3
|
+
## 基本使用
|
4
|
+
|
5
|
+
`v-model="data"` 绑定的表单值`data`可以不用声明属性`name`,`gender`来绑定响应式,组件内部会自动进行响应式处理</br>
|
6
|
+
`action` 配置表单按钮
|
7
|
+
|
8
|
+
<ClientOnly>
|
9
|
+
<common-code-format>
|
10
|
+
<form-baseUse-base slot="source"></form-baseUse-base>
|
11
|
+
|
12
|
+
<<< @/docs/.vuepress/components/form/baseUse/base.vue
|
13
|
+
</common-code-format>
|
14
|
+
</ClientOnly>
|
15
|
+
|
16
|
+
|
17
|
+
## 布局
|
18
|
+
|
19
|
+
`layout` 布局类型默认`grid`</br>
|
20
|
+
`layout` 布局类型如果为 `el-row`,则参考element-ui的布局设置</br>
|
21
|
+
### 设置 columns 固定每行列数
|
22
|
+
`columns` 表单列数,`columnGap` 列间距, `rowGap` 行间距 </br>
|
23
|
+
`renderColumns`项中,`widthSize` 占据列数,`heightSize` 占据行数</br>
|
24
|
+
|
25
|
+
<ClientOnly>
|
26
|
+
<common-code-format>
|
27
|
+
<form-baseUse-gridLayout slot="source"></form-baseUse-gridLayout>
|
28
|
+
|
29
|
+
<<< @/docs/.vuepress/components/form/baseUse/gridLayout.vue
|
30
|
+
</common-code-format>
|
31
|
+
</ClientOnly>
|
32
|
+
|
33
|
+
### 设置 columnWidth 固定每列宽度,不固定数量
|
34
|
+
|
35
|
+
<ClientOnly>
|
36
|
+
<common-code-format>
|
37
|
+
<form-baseUse-inlineLayout slot="source"></form-baseUse-inlineLayout>
|
38
|
+
|
39
|
+
<<< @/docs/.vuepress/components/form/baseUse/inlineLayout.vue
|
40
|
+
</common-code-format>
|
41
|
+
</ClientOnly>
|
42
|
+
|
43
|
+
|
44
|
+
## 提示
|
45
|
+
|
46
|
+
`renderColumns`项中,`tooltip` 提示文本,`tooltipRender` 提示渲染函数</br>
|
47
|
+
`#[prop]-tooltip` 提示插槽 </br>
|
48
|
+
|
49
|
+
<ClientOnly>
|
50
|
+
<common-code-format>
|
51
|
+
<form-baseUse-tooltip slot="source"></form-baseUse-tooltip>
|
52
|
+
|
53
|
+
<<< @/docs/.vuepress/components/form/baseUse/tooltip.vue
|
54
|
+
</common-code-format>
|
55
|
+
</ClientOnly>
|
56
|
+
|
57
|
+
|
58
|
+
## label
|
59
|
+
|
60
|
+
`renderColumns`项中,`label` label文本,`labelRender` label渲染函数 </br>
|
61
|
+
`#[prop]-label` label插槽 </br>
|
62
|
+
`hiddenLabel` 隐藏label,在`renderColumns`项中配置单个隐藏 </br>
|
63
|
+
`labelOverTip` label超出隐藏,在`renderColumns`项中配置单个超出隐藏 </br>
|
64
|
+
|
65
|
+
<ClientOnly>
|
66
|
+
<common-code-format>
|
67
|
+
<form-baseUse-label slot="source"></form-baseUse-label>
|
68
|
+
|
69
|
+
<<< @/docs/.vuepress/components/form/baseUse/label.vue
|
70
|
+
</common-code-format>
|
71
|
+
</ClientOnly>
|
72
|
+
|
73
|
+
|
74
|
+
## 校验
|
75
|
+
|
76
|
+
`renderColumns`项中,`required` 必填,`rules` 匹配规则模板和自定义规则</br>
|
77
|
+
详情参考[crud-校验](/guide/crud/validate.html#基本使用)
|
78
|
+
|
79
|
+
<ClientOnly>
|
80
|
+
<common-code-format>
|
81
|
+
<form-baseUse-validate slot="source"></form-baseUse-validate>
|
82
|
+
|
83
|
+
<<< @/docs/.vuepress/components/form/baseUse/validate.vue
|
84
|
+
</common-code-format>
|
85
|
+
</ClientOnly>
|
86
|
+
|
87
|
+
|
88
|
+
## 显示/隐藏
|
89
|
+
|
90
|
+
`renderColumns`项中,`hidden` 隐藏,`show` 显示</br>
|
91
|
+
|
92
|
+
<ClientOnly>
|
93
|
+
<common-code-format>
|
94
|
+
<form-baseUse-hidden slot="source"></form-baseUse-hidden>
|
95
|
+
|
96
|
+
<<< @/docs/.vuepress/components/form/baseUse/hidden.vue
|
97
|
+
</common-code-format>
|
98
|
+
</ClientOnly>
|
99
|
+
|
100
|
+
|
101
|
+
## 分组
|
102
|
+
|
103
|
+
`type: group` 设置分组</br>
|
104
|
+
`renderColumns`项中,`children` 配置表单项 </br>
|
105
|
+
|
106
|
+
<ClientOnly>
|
107
|
+
<common-code-format>
|
108
|
+
<form-baseUse-group slot="source"></form-baseUse-group>
|
109
|
+
|
110
|
+
<<< @/docs/.vuepress/components/form/baseUse/group.vue
|
111
|
+
</common-code-format>
|
112
|
+
</ClientOnly>
|
113
|
+
|
114
|
+
|
115
|
+
## 数据格式化
|
116
|
+
|
117
|
+
当后端接口数据格式与前端不一致时,可以使用`formatData`进行数据格式化</br>
|
118
|
+
`formatData.input` 将外部后端接口的数据格式转化成内部表单所需的格式</br>
|
119
|
+
`formatData.output` 将内部表单的数据格式反转回原来的格式</br>
|
120
|
+
`formatData` 接收字符串时则匹配预设的全局格式化模板</br>
|
121
|
+
`formatData.getFormatValue = true` 可获取格式化后的值,默认绑定在 `scope.row[$ + prop]` 上,如果配置`getFormatValue`为字符串则绑定在 `scope.row[getFormatValue]` 上
|
122
|
+
|
123
|
+
<ClientOnly>
|
124
|
+
<common-code-format>
|
125
|
+
<form-baseUse-dataFormat slot="source"></form-baseUse-dataFormat>
|
126
|
+
|
127
|
+
<<< @/docs/.vuepress/components/form/baseUse/dataFormat.vue
|
128
|
+
</common-code-format>
|
129
|
+
</ClientOnly>
|
130
|
+
|
131
|
+
|
132
|
+
## 深度绑定
|
133
|
+
|
134
|
+
`deepProp` 绑定的对象数据是双向的,改变任意一个,另外一个也会改变
|
135
|
+
|
136
|
+
<ClientOnly>
|
137
|
+
<common-code-format>
|
138
|
+
<form-baseUse-deep slot="source"></form-baseUse-deep>
|
139
|
+
|
140
|
+
<<< @/docs/.vuepress/components/form/baseUse/deep.vue
|
141
|
+
</common-code-format>
|
142
|
+
</ClientOnly>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# 详情模式
|
2
|
+
|
3
|
+
`detail` 配置表单为详情模式 </br>
|
4
|
+
renderColumn项中,`detail` 自定义详情渲染组件
|
5
|
+
|
6
|
+
<ClientOnly>
|
7
|
+
<common-code-format>
|
8
|
+
<form-detail-base slot="source"></form-detail-base>
|
9
|
+
|
10
|
+
<<< @/docs/.vuepress/components/form/detail/base.vue
|
11
|
+
</common-code-format>
|
12
|
+
</ClientOnly>
|
13
|
+
|
14
|
+
|
15
|
+
## 带边框
|
16
|
+
|
17
|
+
`border` 配置表单为详情带边框模式
|
18
|
+
|
19
|
+
<ClientOnly>
|
20
|
+
<common-code-format>
|
21
|
+
<form-detail-border slot="source"></form-detail-border>
|
22
|
+
|
23
|
+
<<< @/docs/.vuepress/components/form/detail/border.vue
|
24
|
+
</common-code-format>
|
25
|
+
</ClientOnly>
|
26
|
+
|
27
|
+
|
28
|
+
## 单个详情
|
29
|
+
|
30
|
+
renderColumn项中,`isDetail` 配置单个详情模式
|
31
|
+
|
32
|
+
<ClientOnly>
|
33
|
+
<common-code-format>
|
34
|
+
<form-detail-singleDetail slot="source"></form-detail-singleDetail>
|
35
|
+
|
36
|
+
<<< @/docs/.vuepress/components/form/detail/singleDetail.vue
|
37
|
+
</common-code-format>
|
38
|
+
</ClientOnly>
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# 基本使用
|
2
|
+
|
3
|
+
## 概述
|
4
|
+
|
5
|
+
数据格式化(formatData)用于解决组件所需数据格式与业务数据格式不一致的问题。它提供了两个核心功能:
|
6
|
+
- `input`: 将业务数据转换为组件所需格式
|
7
|
+
- `output`: 将组件数据转换回业务所需格式
|
8
|
+
|
9
|
+
## 示例
|
10
|
+
|
11
|
+
<ClientOnly>
|
12
|
+
<common-code-format>
|
13
|
+
<formatData-baseUse slot="source"></formatData-baseUse>
|
14
|
+
|
15
|
+
<<< @/docs/.vuepress/components/formatData/baseUse.vue
|
16
|
+
</common-code-format>
|
17
|
+
</ClientOnly>
|
18
|
+
|
19
|
+
## 预设格式化模板
|
20
|
+
|
21
|
+
`formatData` 直接指定预设模板的名称:
|
22
|
+
|
23
|
+
```javascript
|
24
|
+
{
|
25
|
+
label: "省市区",
|
26
|
+
prop: "province",
|
27
|
+
formatData: {
|
28
|
+
type: "multiPropToArr",
|
29
|
+
multiProp: ["province", "city", "district"] // 绑定的多字段参数
|
30
|
+
}
|
31
|
+
}
|
32
|
+
```
|
33
|
+
|
34
|
+
## 自定义当前列的格式化函数
|
35
|
+
|
36
|
+
```javascript
|
37
|
+
{
|
38
|
+
label: "自定义",
|
39
|
+
prop: "custom",
|
40
|
+
formatData: {
|
41
|
+
input: (value) => value.join(","),
|
42
|
+
output: (value) => value.split(","),
|
43
|
+
}
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
## 格式化值的存储
|
48
|
+
|
49
|
+
如果需要同时保留原始值和格式化后的值,可以通过 `formatValue` 配置存储位置:
|
50
|
+
|
51
|
+
```javascript
|
52
|
+
{
|
53
|
+
label: "金额",
|
54
|
+
prop: "amount",
|
55
|
+
formatData: {
|
56
|
+
formatValue: true, // 格式化后的值会存储在 row.$amount
|
57
|
+
// 或
|
58
|
+
formatValue: "formattedAmount" // 格式化后的值会存储在 row.formattedAmount
|
59
|
+
}
|
60
|
+
}
|
61
|
+
```
|
62
|
+
|
63
|
+
## 全局注册格式化模板
|
64
|
+
|
65
|
+
`item` 即为当前列配置,可以获取到传入的配置信息 prop、label、formatData配置 等
|
66
|
+
|
67
|
+
```javascript
|
68
|
+
import superCrud from "src";
|
69
|
+
|
70
|
+
Vue.use(superCrud, {
|
71
|
+
template: {
|
72
|
+
formatData: {
|
73
|
+
"custom": (item) => {
|
74
|
+
const { prop, label, formatData } = item;
|
75
|
+
return {
|
76
|
+
input: (value) => value.join(","),
|
77
|
+
output: (value) => value.split(","),
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
},
|
82
|
+
});
|
83
|
+
```
|
84
|
+
|
85
|
+
## 在render或插槽渲染中使用
|
86
|
+
|
87
|
+
在render或插槽渲染中使用时,需要使用 `$value` 对象来获取和设置值。
|
88
|
+
|
89
|
+
```javascript
|
90
|
+
{
|
91
|
+
label: "自定义",
|
92
|
+
prop: "custom",
|
93
|
+
formatData: "strToArr",
|
94
|
+
render: (h, { $value }) => {
|
95
|
+
return <el-input value={$value.get} onInput={(v)=>$value.set(v)} />;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
```
|