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,219 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<div class="demo-section">
|
4
|
+
<h3>控制行编辑状态:</h3>
|
5
|
+
<el-button @click="handleRowChange(0)">禁用第一行</el-button>
|
6
|
+
<el-button @click="handleRowChange(1)">禁用第二行</el-button>
|
7
|
+
<el-button @click="handleRowChange(2)">禁用第三行</el-button>
|
8
|
+
<el-button @click="handleRowChange(null)">取消禁用</el-button>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div style="margin-bottom: 20px;">
|
12
|
+
<h3>控制列编辑状态:</h3>
|
13
|
+
<el-button @click="handleColumnChange('name')">禁用姓名列</el-button>
|
14
|
+
<el-button @click="handleColumnChange('gender')">禁用性别列</el-button>
|
15
|
+
<el-button @click="handleColumnChange('age')">禁用年龄列</el-button>
|
16
|
+
<el-button @click="handleColumnChange(null)">取消禁用</el-button>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div style="margin-bottom: 20px;">
|
20
|
+
<h3>控制单元格编辑状态:</h3>
|
21
|
+
<el-button @click="handleCellChange('name')"
|
22
|
+
>禁用姓名第一个单元格</el-button
|
23
|
+
>
|
24
|
+
<el-button @click="handleCellChange('gender')"
|
25
|
+
>禁用性别第一个单元格</el-button
|
26
|
+
>
|
27
|
+
<el-button @click="handleCellChange('age')"
|
28
|
+
>禁用年龄第一个单元格</el-button
|
29
|
+
>
|
30
|
+
<el-button @click="handleCellChange(null)">取消禁用</el-button>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<sc-crud
|
34
|
+
:search.sync="searchForm"
|
35
|
+
ref="crud"
|
36
|
+
:options="options"
|
37
|
+
:data="data"
|
38
|
+
>
|
39
|
+
</sc-crud>
|
40
|
+
</div>
|
41
|
+
</template>
|
42
|
+
|
43
|
+
<script>
|
44
|
+
export default {
|
45
|
+
data() {
|
46
|
+
return {
|
47
|
+
searchForm: {},
|
48
|
+
data: [
|
49
|
+
{
|
50
|
+
id: 1,
|
51
|
+
name: "张三",
|
52
|
+
gender: "男",
|
53
|
+
age: 20,
|
54
|
+
city: "北京",
|
55
|
+
date: "2021-01-01",
|
56
|
+
},
|
57
|
+
{
|
58
|
+
id: 2,
|
59
|
+
name: "李四",
|
60
|
+
gender: "女",
|
61
|
+
age: 21,
|
62
|
+
city: "上海",
|
63
|
+
date: "2021-01-02",
|
64
|
+
},
|
65
|
+
{
|
66
|
+
id: 3,
|
67
|
+
name: "王五",
|
68
|
+
gender: "男",
|
69
|
+
age: 22,
|
70
|
+
city: "广州",
|
71
|
+
date: "2021-01-03",
|
72
|
+
},
|
73
|
+
{
|
74
|
+
id: 4,
|
75
|
+
name: "赵六",
|
76
|
+
gender: "女",
|
77
|
+
age: 23,
|
78
|
+
city: "深圳",
|
79
|
+
date: "2021-01-04",
|
80
|
+
},
|
81
|
+
],
|
82
|
+
disabledRowIndex: null,
|
83
|
+
disabledCellProp: null,
|
84
|
+
disabledCell: { row: null, prop: null },
|
85
|
+
};
|
86
|
+
},
|
87
|
+
computed: {
|
88
|
+
options() {
|
89
|
+
return {
|
90
|
+
editConfig: {
|
91
|
+
mode: "row",
|
92
|
+
batch: true,
|
93
|
+
edit: true,
|
94
|
+
isRowEdit: ({ row, $index }) => {
|
95
|
+
// 如果设置了禁用行索引,则该行不可编辑
|
96
|
+
if (this.disabledRowIndex !== null) {
|
97
|
+
return $index !== this.disabledRowIndex;
|
98
|
+
}
|
99
|
+
return true;
|
100
|
+
},
|
101
|
+
},
|
102
|
+
renderColumns: [
|
103
|
+
{
|
104
|
+
prop: "name",
|
105
|
+
label: "姓名",
|
106
|
+
isEdit: ({ row, $index }) => {
|
107
|
+
if (
|
108
|
+
this.disabledCell.row === 0 &&
|
109
|
+
this.disabledCell.prop === "name"
|
110
|
+
) {
|
111
|
+
return $index !== 0;
|
112
|
+
}
|
113
|
+
return this.disabledCellProp !== "name";
|
114
|
+
},
|
115
|
+
},
|
116
|
+
{
|
117
|
+
prop: "gender",
|
118
|
+
label: "性别",
|
119
|
+
isEdit: ({ row, $index }) => {
|
120
|
+
if (
|
121
|
+
this.disabledCell.row === 0 &&
|
122
|
+
this.disabledCell.prop === "gender"
|
123
|
+
) {
|
124
|
+
return $index !== 0;
|
125
|
+
}
|
126
|
+
return this.disabledCellProp !== "gender";
|
127
|
+
},
|
128
|
+
form: {
|
129
|
+
comp: {
|
130
|
+
name: "el-select",
|
131
|
+
options: [
|
132
|
+
{ value: "男", label: "男" },
|
133
|
+
{ value: "女", label: "女" },
|
134
|
+
],
|
135
|
+
},
|
136
|
+
},
|
137
|
+
},
|
138
|
+
{
|
139
|
+
prop: "age",
|
140
|
+
label: "年龄",
|
141
|
+
isEdit: ({ row, $index }) => {
|
142
|
+
if (
|
143
|
+
this.disabledCell.row === 0 &&
|
144
|
+
this.disabledCell.prop === "age"
|
145
|
+
) {
|
146
|
+
return $index !== 0;
|
147
|
+
}
|
148
|
+
return this.disabledCellProp !== "age";
|
149
|
+
},
|
150
|
+
form: {
|
151
|
+
comp: {
|
152
|
+
name: "el-select",
|
153
|
+
options: [
|
154
|
+
{ value: 20, label: "20" },
|
155
|
+
{ value: 21, label: "21" },
|
156
|
+
{ value: 22, label: "22" },
|
157
|
+
{ value: 23, label: "23" },
|
158
|
+
],
|
159
|
+
},
|
160
|
+
},
|
161
|
+
},
|
162
|
+
{
|
163
|
+
prop: "city",
|
164
|
+
label: "城市",
|
165
|
+
form: {
|
166
|
+
comp: {
|
167
|
+
name: "el-select",
|
168
|
+
options: [
|
169
|
+
{ value: "北京", label: "北京" },
|
170
|
+
{ value: "上海", label: "上海" },
|
171
|
+
{ value: "广州", label: "广州" },
|
172
|
+
{ value: "深圳", label: "深圳" },
|
173
|
+
],
|
174
|
+
},
|
175
|
+
},
|
176
|
+
},
|
177
|
+
{
|
178
|
+
prop: "date",
|
179
|
+
label: "日期",
|
180
|
+
form: {
|
181
|
+
comp: {
|
182
|
+
name: "el-date-picker",
|
183
|
+
props: {
|
184
|
+
type: "date",
|
185
|
+
placeholder: "选择日期",
|
186
|
+
format: "yyyy-MM-dd",
|
187
|
+
valueFormat: "yyyy-MM-dd",
|
188
|
+
},
|
189
|
+
},
|
190
|
+
},
|
191
|
+
},
|
192
|
+
],
|
193
|
+
};
|
194
|
+
},
|
195
|
+
},
|
196
|
+
methods: {
|
197
|
+
// 控制行编辑状态
|
198
|
+
handleRowChange(index) {
|
199
|
+
this.disabledRowIndex = index;
|
200
|
+
this.$refs.crud.clearAllEdit();
|
201
|
+
},
|
202
|
+
|
203
|
+
// 控制单元格编辑状态
|
204
|
+
handleColumnChange(prop) {
|
205
|
+
this.disabledCellProp = prop;
|
206
|
+
this.$refs.crud.clearAllEdit();
|
207
|
+
},
|
208
|
+
handleCellChange(prop) {
|
209
|
+
if (prop === null) {
|
210
|
+
this.disabledCell = { row: null, prop: null };
|
211
|
+
} else {
|
212
|
+
// 设置第一行的指定列单元格为禁用状态
|
213
|
+
this.disabledCell = { row: 0, prop };
|
214
|
+
}
|
215
|
+
this.$refs.crud.clearAllEdit();
|
216
|
+
},
|
217
|
+
},
|
218
|
+
};
|
219
|
+
</script>
|
@@ -0,0 +1,172 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<sc-crud
|
4
|
+
:search.sync="searchForm"
|
5
|
+
:options="options"
|
6
|
+
:data="data"
|
7
|
+
@add="add"
|
8
|
+
@edit="edit"
|
9
|
+
@view="view"
|
10
|
+
@save="save"
|
11
|
+
>
|
12
|
+
</sc-crud>
|
13
|
+
</div>
|
14
|
+
</template>
|
15
|
+
|
16
|
+
<script>
|
17
|
+
export default {
|
18
|
+
data() {
|
19
|
+
return {
|
20
|
+
searchForm: {},
|
21
|
+
options: {
|
22
|
+
editConfig: {
|
23
|
+
mode: "dialog",
|
24
|
+
edit: {},
|
25
|
+
add: {
|
26
|
+
addType: "first",
|
27
|
+
},
|
28
|
+
view: {},
|
29
|
+
delete: true,
|
30
|
+
lastAdd: {},
|
31
|
+
},
|
32
|
+
dialog: {}, // 自定义弹窗配置
|
33
|
+
formOptions: {}, // 自定义表单配置
|
34
|
+
renderColumns: [
|
35
|
+
{
|
36
|
+
prop: "name",
|
37
|
+
label: "姓名",
|
38
|
+
form: {},
|
39
|
+
},
|
40
|
+
{
|
41
|
+
prop: "gender",
|
42
|
+
label: "性别",
|
43
|
+
form: {
|
44
|
+
comp: {
|
45
|
+
name: "el-select",
|
46
|
+
options: [
|
47
|
+
{ value: "男", label: "男" },
|
48
|
+
{ value: "女", label: "女" },
|
49
|
+
],
|
50
|
+
},
|
51
|
+
},
|
52
|
+
},
|
53
|
+
{
|
54
|
+
prop: "age",
|
55
|
+
label: "年龄",
|
56
|
+
form: {
|
57
|
+
comp: {
|
58
|
+
name: "el-select",
|
59
|
+
options: [
|
60
|
+
{ value: 20, label: "20" },
|
61
|
+
{ value: 21, label: "21" },
|
62
|
+
{ value: 22, label: "22" },
|
63
|
+
{ value: 23, label: "23" },
|
64
|
+
],
|
65
|
+
},
|
66
|
+
},
|
67
|
+
},
|
68
|
+
{
|
69
|
+
prop: "city",
|
70
|
+
label: "城市",
|
71
|
+
form: {
|
72
|
+
comp: {
|
73
|
+
name: "el-select",
|
74
|
+
options: [
|
75
|
+
{ value: "北京", label: "北京" },
|
76
|
+
{ value: "上海", label: "上海" },
|
77
|
+
{ value: "广州", label: "广州" },
|
78
|
+
{ value: "深圳", label: "深圳" },
|
79
|
+
],
|
80
|
+
},
|
81
|
+
},
|
82
|
+
},
|
83
|
+
{
|
84
|
+
prop: "date",
|
85
|
+
label: "日期",
|
86
|
+
form: {
|
87
|
+
comp: {
|
88
|
+
name: "el-date-picker",
|
89
|
+
props: {
|
90
|
+
type: "date",
|
91
|
+
placeholder: "选择日期",
|
92
|
+
valueFormat: "yyyy-MM-dd",
|
93
|
+
},
|
94
|
+
},
|
95
|
+
},
|
96
|
+
},
|
97
|
+
],
|
98
|
+
},
|
99
|
+
data: [
|
100
|
+
{
|
101
|
+
id: 1,
|
102
|
+
name: "张三",
|
103
|
+
gender: "男",
|
104
|
+
age: 20,
|
105
|
+
city: "北京",
|
106
|
+
date: "2021-01-01",
|
107
|
+
},
|
108
|
+
{
|
109
|
+
id: 2,
|
110
|
+
name: "李四",
|
111
|
+
gender: "女",
|
112
|
+
age: 21,
|
113
|
+
city: "上海",
|
114
|
+
date: "2021-01-02",
|
115
|
+
},
|
116
|
+
{
|
117
|
+
id: 3,
|
118
|
+
name: "王五",
|
119
|
+
gender: "男",
|
120
|
+
age: 22,
|
121
|
+
city: "广州",
|
122
|
+
date: "2021-01-03",
|
123
|
+
},
|
124
|
+
{
|
125
|
+
id: 4,
|
126
|
+
name: "赵六",
|
127
|
+
gender: "女",
|
128
|
+
age: 23,
|
129
|
+
city: "深圳",
|
130
|
+
date: "2021-01-04",
|
131
|
+
},
|
132
|
+
{
|
133
|
+
id: 5,
|
134
|
+
name: "孙七",
|
135
|
+
gender: "男",
|
136
|
+
age: 24,
|
137
|
+
city: "成都",
|
138
|
+
date: "2021-01-05",
|
139
|
+
},
|
140
|
+
{
|
141
|
+
id: 6,
|
142
|
+
name: "周八",
|
143
|
+
gender: "女",
|
144
|
+
age: 25,
|
145
|
+
city: "重庆",
|
146
|
+
date: "2021-01-06",
|
147
|
+
},
|
148
|
+
],
|
149
|
+
};
|
150
|
+
},
|
151
|
+
methods: {
|
152
|
+
add(done, scope) {
|
153
|
+
this.$message("点击新增");
|
154
|
+
done();
|
155
|
+
},
|
156
|
+
edit(done, scope) {
|
157
|
+
this.$message("点击编辑");
|
158
|
+
done();
|
159
|
+
},
|
160
|
+
view(done, scope) {
|
161
|
+
this.$message("点击查看");
|
162
|
+
done();
|
163
|
+
},
|
164
|
+
save(done, scope) {
|
165
|
+
setTimeout(() => {
|
166
|
+
done();
|
167
|
+
this.$message("点击保存");
|
168
|
+
}, 500);
|
169
|
+
},
|
170
|
+
},
|
171
|
+
};
|
172
|
+
</script>
|
@@ -0,0 +1,88 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<sc-crud :search.sync="searchForm" :options="options" :data="data">
|
4
|
+
</sc-crud>
|
5
|
+
</div>
|
6
|
+
</template>
|
7
|
+
|
8
|
+
<script>
|
9
|
+
export default {
|
10
|
+
data() {
|
11
|
+
return {
|
12
|
+
searchForm: {},
|
13
|
+
data: [
|
14
|
+
{
|
15
|
+
id: 1,
|
16
|
+
name: "张三",
|
17
|
+
gender: "男",
|
18
|
+
age: 20,
|
19
|
+
city: "北京",
|
20
|
+
date: "2021-01-01",
|
21
|
+
},
|
22
|
+
{
|
23
|
+
id: 2,
|
24
|
+
name: "李四",
|
25
|
+
gender: "女",
|
26
|
+
age: 21,
|
27
|
+
city: "上海",
|
28
|
+
date: "2021-01-02",
|
29
|
+
},
|
30
|
+
{
|
31
|
+
id: 3,
|
32
|
+
name: "王五",
|
33
|
+
gender: "男",
|
34
|
+
age: 22,
|
35
|
+
city: "广州",
|
36
|
+
date: "2021-01-03",
|
37
|
+
},
|
38
|
+
{
|
39
|
+
id: 4,
|
40
|
+
name: "赵六",
|
41
|
+
gender: "女",
|
42
|
+
age: 23,
|
43
|
+
city: "深圳",
|
44
|
+
date: "2021-01-04",
|
45
|
+
},
|
46
|
+
],
|
47
|
+
isEdit: true,
|
48
|
+
};
|
49
|
+
},
|
50
|
+
computed: {
|
51
|
+
options() {
|
52
|
+
return {
|
53
|
+
editConfig: {
|
54
|
+
mode: "free",
|
55
|
+
},
|
56
|
+
renderColumns: [
|
57
|
+
{ prop: "name", label: "姓名" },
|
58
|
+
{
|
59
|
+
prop: "gender",
|
60
|
+
label: "性别",
|
61
|
+
},
|
62
|
+
{
|
63
|
+
prop: "age",
|
64
|
+
label: "年龄",
|
65
|
+
form: {
|
66
|
+
comp: {
|
67
|
+
name: "el-select",
|
68
|
+
options: [
|
69
|
+
{ value: "1", label: "选项1" },
|
70
|
+
{ value: "2", label: "选项2" },
|
71
|
+
],
|
72
|
+
},
|
73
|
+
},
|
74
|
+
},
|
75
|
+
{
|
76
|
+
prop: "city",
|
77
|
+
label: "城市",
|
78
|
+
},
|
79
|
+
{
|
80
|
+
prop: "date",
|
81
|
+
label: "日期",
|
82
|
+
},
|
83
|
+
],
|
84
|
+
};
|
85
|
+
},
|
86
|
+
},
|
87
|
+
};
|
88
|
+
</script>
|
@@ -0,0 +1,82 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<el-button type="primary" @click="isEdit = !isEdit"
|
4
|
+
>切换第三列编辑状态</el-button
|
5
|
+
>
|
6
|
+
<sc-crud :search.sync="searchForm" :options="options" :data="data">
|
7
|
+
</sc-crud>
|
8
|
+
</div>
|
9
|
+
</template>
|
10
|
+
|
11
|
+
<script>
|
12
|
+
export default {
|
13
|
+
data() {
|
14
|
+
return {
|
15
|
+
searchForm: {},
|
16
|
+
data: [
|
17
|
+
{
|
18
|
+
id: 1,
|
19
|
+
name: "张三",
|
20
|
+
gender: "男",
|
21
|
+
age: 20,
|
22
|
+
city: "北京",
|
23
|
+
date: "2021-01-01",
|
24
|
+
},
|
25
|
+
{
|
26
|
+
id: 2,
|
27
|
+
name: "李四",
|
28
|
+
gender: "女",
|
29
|
+
age: 21,
|
30
|
+
city: "上海",
|
31
|
+
date: "2021-01-02",
|
32
|
+
},
|
33
|
+
{
|
34
|
+
id: 3,
|
35
|
+
name: "王五",
|
36
|
+
gender: "男",
|
37
|
+
age: 22,
|
38
|
+
city: "广州",
|
39
|
+
date: "2021-01-03",
|
40
|
+
},
|
41
|
+
{
|
42
|
+
id: 4,
|
43
|
+
name: "赵六",
|
44
|
+
gender: "女",
|
45
|
+
age: 23,
|
46
|
+
city: "深圳",
|
47
|
+
date: "2021-01-04",
|
48
|
+
},
|
49
|
+
],
|
50
|
+
isEdit: true,
|
51
|
+
};
|
52
|
+
},
|
53
|
+
computed: {
|
54
|
+
options() {
|
55
|
+
return {
|
56
|
+
renderColumns: [
|
57
|
+
{ prop: "name", label: "姓名" },
|
58
|
+
{
|
59
|
+
prop: "gender",
|
60
|
+
label: "性别",
|
61
|
+
isEdit: true,
|
62
|
+
},
|
63
|
+
{
|
64
|
+
prop: "age",
|
65
|
+
label: "年龄",
|
66
|
+
isEdit: this.isEdit,
|
67
|
+
},
|
68
|
+
{
|
69
|
+
prop: "city",
|
70
|
+
label: "城市",
|
71
|
+
},
|
72
|
+
{
|
73
|
+
prop: "date",
|
74
|
+
label: "日期",
|
75
|
+
isEdit: true,
|
76
|
+
},
|
77
|
+
],
|
78
|
+
};
|
79
|
+
},
|
80
|
+
},
|
81
|
+
};
|
82
|
+
</script>
|
@@ -0,0 +1,154 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<div class="demo-section">
|
4
|
+
<h3>方法调用示例:</h3>
|
5
|
+
<el-button @click="setFirstRowEdit">设置第一行编辑</el-button>
|
6
|
+
<el-button @click="setMultiRowEdit">设置多行编辑</el-button>
|
7
|
+
<el-button @click="cancelRowEdit">取消编辑</el-button>
|
8
|
+
<el-button @click="saveRowEdit">保存编辑</el-button>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div style="margin-bottom: 20px;">
|
12
|
+
<h3>其他操作:</h3>
|
13
|
+
<el-button @click="addNewRow">新增行</el-button>
|
14
|
+
<el-button @click="addNewRowToFirst">新增至首行</el-button>
|
15
|
+
<el-button @click="clearAllEditStatus">清除所有编辑</el-button>
|
16
|
+
<el-button @click="showEditingStatus">显示编辑状态</el-button>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<sc-crud
|
20
|
+
:search.sync="searchForm"
|
21
|
+
ref="crud"
|
22
|
+
:options="options"
|
23
|
+
:data="data"
|
24
|
+
>
|
25
|
+
</sc-crud>
|
26
|
+
</div>
|
27
|
+
</template>
|
28
|
+
|
29
|
+
<script>
|
30
|
+
export default {
|
31
|
+
data() {
|
32
|
+
return {
|
33
|
+
searchForm: {},
|
34
|
+
data: [
|
35
|
+
{
|
36
|
+
id: 1,
|
37
|
+
name: "张三",
|
38
|
+
gender: "男",
|
39
|
+
age: 20,
|
40
|
+
city: "北京",
|
41
|
+
date: "2021-01-01",
|
42
|
+
},
|
43
|
+
{
|
44
|
+
id: 2,
|
45
|
+
name: "李四",
|
46
|
+
gender: "女",
|
47
|
+
age: 21,
|
48
|
+
city: "上海",
|
49
|
+
date: "2021-01-02",
|
50
|
+
},
|
51
|
+
{
|
52
|
+
id: 3,
|
53
|
+
name: "王五",
|
54
|
+
gender: "男",
|
55
|
+
age: 22,
|
56
|
+
city: "广州",
|
57
|
+
date: "2021-01-03",
|
58
|
+
},
|
59
|
+
],
|
60
|
+
};
|
61
|
+
},
|
62
|
+
computed: {
|
63
|
+
options() {
|
64
|
+
return {
|
65
|
+
editConfig: {
|
66
|
+
mode: "row",
|
67
|
+
trigger: "manual",
|
68
|
+
edit: true,
|
69
|
+
},
|
70
|
+
renderColumns: [
|
71
|
+
{ prop: "name", label: "姓名" },
|
72
|
+
{
|
73
|
+
prop: "gender",
|
74
|
+
label: "性别",
|
75
|
+
form: {
|
76
|
+
comp: {
|
77
|
+
name: "el-select",
|
78
|
+
options: [
|
79
|
+
{ value: "男", label: "男" },
|
80
|
+
{ value: "女", label: "女" },
|
81
|
+
],
|
82
|
+
},
|
83
|
+
},
|
84
|
+
},
|
85
|
+
{ prop: "age", label: "年龄" },
|
86
|
+
{ prop: "city", label: "城市" },
|
87
|
+
{ prop: "date", label: "日期" },
|
88
|
+
],
|
89
|
+
};
|
90
|
+
},
|
91
|
+
},
|
92
|
+
methods: {
|
93
|
+
// 设置第一行进入编辑状态
|
94
|
+
setFirstRowEdit() {
|
95
|
+
const firstRow = this.data[0];
|
96
|
+
this.$refs.crud.setRowEdit(firstRow, {
|
97
|
+
type: "edit",
|
98
|
+
prop: "name", // 聚焦到name列
|
99
|
+
});
|
100
|
+
},
|
101
|
+
|
102
|
+
// 设置多行进入编辑状态
|
103
|
+
setMultiRowEdit() {
|
104
|
+
const rows = this.data.slice(0, 2); // 获取前两行
|
105
|
+
this.$refs.crud.setRowEdit(rows, { type: "edit" });
|
106
|
+
},
|
107
|
+
|
108
|
+
// 取消编辑状态
|
109
|
+
cancelRowEdit() {
|
110
|
+
const editingRows = this.$refs.crud.getEditingRows();
|
111
|
+
this.$refs.crud.setRowEdit(editingRows, { type: "cancel" });
|
112
|
+
},
|
113
|
+
|
114
|
+
// 保存编辑状态
|
115
|
+
saveRowEdit() {
|
116
|
+
const editingRows = this.$refs.crud.getEditingRows();
|
117
|
+
this.$refs.crud.setRowEdit(editingRows, { type: "save" });
|
118
|
+
},
|
119
|
+
|
120
|
+
// 新增行
|
121
|
+
addNewRow() {
|
122
|
+
this.$refs.crud.addRow({
|
123
|
+
name: "新用户",
|
124
|
+
gender: "男",
|
125
|
+
age: 25,
|
126
|
+
});
|
127
|
+
},
|
128
|
+
|
129
|
+
// 在首行新增
|
130
|
+
addNewRowToFirst() {
|
131
|
+
this.$refs.crud.addRow(
|
132
|
+
{
|
133
|
+
name: "新用户",
|
134
|
+
gender: "男",
|
135
|
+
age: 25,
|
136
|
+
},
|
137
|
+
"first"
|
138
|
+
);
|
139
|
+
},
|
140
|
+
|
141
|
+
// 清除所有编辑状态
|
142
|
+
clearAllEditStatus() {
|
143
|
+
this.$refs.crud.clearAllEdit();
|
144
|
+
},
|
145
|
+
|
146
|
+
// 显示编辑状态信息
|
147
|
+
showEditingStatus() {
|
148
|
+
// 获取所有编辑状态的行
|
149
|
+
const editingRows = this.$refs.crud.getEditingRows();
|
150
|
+
console.log("正在编辑的行:", editingRows);
|
151
|
+
},
|
152
|
+
},
|
153
|
+
};
|
154
|
+
</script>
|