el-crud-page 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +6407 -239
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +6407 -239
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +6407 -239
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -2
- package/src/index.vue +1 -1
- package/src/rightToolbar.vue +220 -146
- package/src/table.vue +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "el-crud-page",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "A powerful CRUD page component library for Element UI v2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"homepage": "https://github.com/tonwe/el-crud-page#readme",
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"element-ui": "^2.x",
|
|
40
|
-
"vue": "^2.6.0"
|
|
40
|
+
"vue": "^2.6.0",
|
|
41
|
+
"vuedraggable": "^2.24.3"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@babel/core": "^7.23.0",
|
|
@@ -54,5 +55,8 @@
|
|
|
54
55
|
"sass": "^1.93.2",
|
|
55
56
|
"vue": "^2.6.12",
|
|
56
57
|
"vue-template-compiler": "^2.6.12"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"vuedraggable": "^2.24.3"
|
|
57
61
|
}
|
|
58
62
|
}
|
package/src/index.vue
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
</div>
|
|
42
42
|
</slot>
|
|
43
43
|
<slot name="toolbar" :columns="columns" :showSearch="showSearch">
|
|
44
|
-
<right-toolbar :showSearch.sync="showSearch" @queryTable="refresh" :columns="columns"
|
|
44
|
+
<right-toolbar :showSearch.sync="showSearch" @queryTable="refresh" :columns.sync="columns"
|
|
45
45
|
:search="!!(queryItems && queryItems.length)"></right-toolbar>
|
|
46
46
|
</slot>
|
|
47
47
|
</div>
|
package/src/rightToolbar.vue
CHANGED
|
@@ -1,172 +1,246 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
<div class="top-right-btn" :style="style">
|
|
3
|
+
<div class="flex flex-row items-center">
|
|
4
|
+
<el-tooltip class="item" effect="dark" :content="showSearch ? '隐藏搜索' : '显示搜索'" placement="top" v-if="search">
|
|
5
|
+
<el-button size="mini" circle icon="el-icon-search" @click="toggleSearch()" />
|
|
6
|
+
</el-tooltip>
|
|
7
|
+
<el-tooltip class="item" effect="dark" content="刷新" placement="top">
|
|
8
|
+
<el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" />
|
|
9
|
+
</el-tooltip>
|
|
10
|
+
<el-tooltip class="item" effect="dark" content="显隐列" placement="top" v-if="columns">
|
|
11
|
+
<el-button size="mini" circle icon="el-icon-menu" @click="showColumn()" v-if="showColumnsType == 'transfer'"/>
|
|
12
|
+
<el-popover
|
|
13
|
+
placement="bottom"
|
|
14
|
+
trigger="click"
|
|
15
|
+
v-model="popoverVisible"
|
|
16
|
+
popper-class="columns-popover"
|
|
17
|
+
v-if="showColumnsType == 'checkbox'"
|
|
18
|
+
>
|
|
19
|
+
<draggable
|
|
20
|
+
v-model="visibleColumnsList"
|
|
21
|
+
class="columns-list"
|
|
22
|
+
handle=".drag-handle"
|
|
23
|
+
animation="200"
|
|
24
|
+
@end="onDragEnd"
|
|
25
|
+
>
|
|
26
|
+
<div
|
|
27
|
+
v-for="item in visibleColumnsList"
|
|
28
|
+
:key="item.key"
|
|
29
|
+
class="column-item"
|
|
30
|
+
>
|
|
31
|
+
<i class="el-icon-rank drag-handle"></i>
|
|
32
|
+
<el-checkbox
|
|
33
|
+
v-model="item.visible"
|
|
34
|
+
@change="checkboxChange"
|
|
35
|
+
>
|
|
36
|
+
{{ item.label }}
|
|
37
|
+
</el-checkbox>
|
|
38
|
+
</div>
|
|
39
|
+
</draggable>
|
|
40
|
+
<el-button size="mini" circle icon="el-icon-menu" slot="reference" style="margin-left: 12px" />
|
|
41
|
+
</el-popover>
|
|
42
|
+
</el-tooltip>
|
|
32
43
|
</div>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
<el-dialog :title="title" :visible.sync="open" append-to-body>
|
|
45
|
+
<el-transfer
|
|
46
|
+
:titles="['显示', '隐藏']"
|
|
47
|
+
v-model="value"
|
|
48
|
+
:data="columns"
|
|
49
|
+
@change="dataChange"
|
|
50
|
+
></el-transfer>
|
|
51
|
+
</el-dialog>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script>
|
|
56
|
+
import draggable from 'vuedraggable';
|
|
57
|
+
|
|
58
|
+
export default {
|
|
59
|
+
name: "RightToolbar",
|
|
60
|
+
inject: ["crud"],
|
|
61
|
+
components: {
|
|
62
|
+
draggable
|
|
63
|
+
},
|
|
64
|
+
data() {
|
|
65
|
+
return {
|
|
66
|
+
value: [],
|
|
67
|
+
title: "显示/隐藏",
|
|
68
|
+
open: false,
|
|
69
|
+
popoverVisible: false,
|
|
70
|
+
localColumns: [],
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
props: {
|
|
74
|
+
showSearch: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: true,
|
|
49
77
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
showSearch: {
|
|
53
|
-
type: Boolean,
|
|
54
|
-
default: true,
|
|
55
|
-
},
|
|
56
|
-
/* 显隐列信息 */
|
|
57
|
-
columns: {
|
|
58
|
-
type: Array,
|
|
59
|
-
},
|
|
60
|
-
/* 是否显示检索图标 */
|
|
61
|
-
search: {
|
|
62
|
-
type: Boolean,
|
|
63
|
-
default: true,
|
|
64
|
-
},
|
|
65
|
-
/* 显隐列类型(transfer穿梭框、checkbox复选框) */
|
|
66
|
-
showColumnsType: {
|
|
67
|
-
type: String,
|
|
68
|
-
default: "checkbox",
|
|
69
|
-
},
|
|
70
|
-
/* 右外边距 */
|
|
71
|
-
gutter: {
|
|
72
|
-
type: Number,
|
|
73
|
-
default: 10,
|
|
74
|
-
},
|
|
78
|
+
columns: {
|
|
79
|
+
type: Array,
|
|
75
80
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (this.gutter) {
|
|
80
|
-
ret.marginRight = `${this.gutter / 2}px`;
|
|
81
|
-
}
|
|
82
|
-
return ret;
|
|
83
|
-
}
|
|
81
|
+
search: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: true,
|
|
84
84
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// 当 columns prop 变化时,更新本地副本
|
|
89
|
-
this.localColumns = newVal ? [...newVal] : [];
|
|
90
|
-
},
|
|
91
|
-
immediate: true,
|
|
92
|
-
deep: true
|
|
93
|
-
}
|
|
85
|
+
showColumnsType: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: "checkbox",
|
|
94
88
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
gutter: {
|
|
90
|
+
type: Number,
|
|
91
|
+
default: 10,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
computed: {
|
|
95
|
+
style() {
|
|
96
|
+
const ret = {};
|
|
97
|
+
if (this.gutter) {
|
|
98
|
+
ret.marginRight = `${this.gutter / 2}px`;
|
|
103
99
|
}
|
|
100
|
+
return ret;
|
|
104
101
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
visibleColumnsList: {
|
|
103
|
+
get() {
|
|
104
|
+
return this.localColumns.filter(item => {
|
|
105
|
+
return item.type !== 'index' &&
|
|
106
|
+
item.type !== 'selection' &&
|
|
107
|
+
typeof item.visible !== 'undefined';
|
|
108
|
+
});
|
|
109
109
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this
|
|
110
|
+
set(value) {
|
|
111
|
+
const visibleKeys = value.map(v => v.key);
|
|
112
|
+
const otherColumns = this.localColumns.filter(item => {
|
|
113
|
+
return item.type === 'index' ||
|
|
114
|
+
item.type === 'selection' ||
|
|
115
|
+
typeof item.visible === 'undefined';
|
|
116
|
+
});
|
|
117
|
+
this.localColumns = [...otherColumns, ...value];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
watch: {
|
|
122
|
+
columns: {
|
|
123
|
+
handler(newVal) {
|
|
124
|
+
this.localColumns = newVal ? [...newVal] : [];
|
|
113
125
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
immediate: true,
|
|
127
|
+
deep: true
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
created() {
|
|
131
|
+
if (this.showColumnsType == 'transfer') {
|
|
132
|
+
for (let item in this.columns) {
|
|
133
|
+
if (this.columns[item].visible === false) {
|
|
134
|
+
this.value.push(parseInt(item));
|
|
119
135
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.$emit('update:columns', this.localColumns);
|
|
135
|
-
this.$emit('columns-order-changed', this.localColumns);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
methods: {
|
|
140
|
+
toggleSearch() {
|
|
141
|
+
this.$emit("update:showSearch", !this.showSearch);
|
|
142
|
+
},
|
|
143
|
+
refresh() {
|
|
144
|
+
this.$emit("queryTable");
|
|
145
|
+
},
|
|
146
|
+
dataChange(data) {
|
|
147
|
+
for (let item in this.columns) {
|
|
148
|
+
const key = this.columns[item].key;
|
|
149
|
+
this.columns[item].visible = !data.includes(key);
|
|
136
150
|
}
|
|
137
151
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
152
|
+
showColumn() {
|
|
153
|
+
this.open = true;
|
|
154
|
+
},
|
|
155
|
+
checkboxChange() {
|
|
156
|
+
this.$emit('update:columns', this.localColumns);
|
|
157
|
+
},
|
|
158
|
+
onDragEnd() {
|
|
159
|
+
this.$emit('update:columns', this.localColumns);
|
|
160
|
+
this.$emit('columns-order-changed', this.localColumns);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
</script>
|
|
165
|
+
|
|
166
|
+
<style lang="scss" scoped>
|
|
167
|
+
::v-deep .el-transfer__button {
|
|
168
|
+
border-radius: 50%;
|
|
169
|
+
padding: 12px;
|
|
170
|
+
display: block;
|
|
171
|
+
margin-left: 0px;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
::v-deep .el-transfer__button:first-child {
|
|
175
|
+
margin-bottom: 10px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.drag-item {
|
|
179
|
+
padding: 8px;
|
|
180
|
+
cursor: move;
|
|
181
|
+
border-bottom: 1px solid #ebeef5;
|
|
182
|
+
display: flex;
|
|
183
|
+
align-items: center;
|
|
184
|
+
|
|
185
|
+
&:hover {
|
|
186
|
+
background-color: #f5f7fa;
|
|
146
187
|
}
|
|
147
|
-
|
|
148
|
-
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.drag-handle {
|
|
191
|
+
color: #909399;
|
|
192
|
+
|
|
193
|
+
&:hover {
|
|
194
|
+
color: #409eff;
|
|
149
195
|
}
|
|
196
|
+
}
|
|
197
|
+
</style>
|
|
198
|
+
|
|
199
|
+
<style lang="scss">
|
|
200
|
+
.columns-popover {
|
|
201
|
+
padding: 8px 0;
|
|
202
|
+
min-width: 200px;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.columns-list {
|
|
206
|
+
max-height: 400px;
|
|
207
|
+
overflow-y: auto;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.column-item {
|
|
211
|
+
display: flex;
|
|
212
|
+
align-items: center;
|
|
213
|
+
padding: 8px 16px 8px 10px;
|
|
214
|
+
user-select: none;
|
|
215
|
+
transition: background-color 0.2s;
|
|
150
216
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
cursor: move;
|
|
154
|
-
border-bottom: 1px solid #ebeef5;
|
|
155
|
-
display: flex;
|
|
156
|
-
align-items: center;
|
|
157
|
-
|
|
158
|
-
&:hover {
|
|
159
|
-
background-color: #f5f7fa;
|
|
160
|
-
}
|
|
217
|
+
&:hover {
|
|
218
|
+
background-color: #f5f7fa;
|
|
161
219
|
}
|
|
162
220
|
|
|
163
221
|
.drag-handle {
|
|
222
|
+
margin-right: 8px;
|
|
164
223
|
color: #909399;
|
|
224
|
+
cursor: move;
|
|
165
225
|
|
|
166
226
|
&:hover {
|
|
167
227
|
color: #409eff;
|
|
168
228
|
}
|
|
169
229
|
}
|
|
170
230
|
|
|
171
|
-
|
|
172
|
-
|
|
231
|
+
.el-checkbox {
|
|
232
|
+
flex: 1;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.sortable-ghost {
|
|
237
|
+
opacity: 0.4;
|
|
238
|
+
background-color: #ecf5ff;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.sortable-drag {
|
|
242
|
+
opacity: 0.8;
|
|
243
|
+
background-color: #ffffff;
|
|
244
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
245
|
+
}
|
|
246
|
+
</style>
|