el-plus-crud 0.0.78 → 0.0.80
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/CHANGELOG.md +4 -0
- package/dist/el-plus-crud.mjs +3830 -3864
- package/lib/components/el-plus-form/ElPlusForm.vue +2 -2
- package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +152 -149
- package/lib/components/el-plus-table/ElPlusTable.vue +744 -807
- package/lib/components/el-plus-table/ElPlusTableColumn.vue +47 -0
- package/lib/components/el-plus-table/components/columnItem.vue +5 -3
- package/lib/components/el-plus-table/components/settingColumn.vue +172 -180
- package/lib/components/el-plus-table/util/index.ts +194 -148
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/types/index.d.ts +468 -466
|
@@ -1,148 +1,194 @@
|
|
|
1
|
-
import { cloneDeep } from 'lodash'
|
|
2
|
-
import { IColumnItem } from 'types'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 获取随机字符串
|
|
6
|
-
* @returns {string}
|
|
7
|
-
*/
|
|
8
|
-
export function getUID(): string {
|
|
9
|
-
let str = ''
|
|
10
|
-
const arr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
|
|
11
|
-
for (let i = 0; i < 32; i++) {
|
|
12
|
-
let index = Math.floor(arr.length * Math.random())
|
|
13
|
-
if (index < 0) index = 0
|
|
14
|
-
str += arr[index]
|
|
15
|
-
}
|
|
16
|
-
return str
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// 判断类型
|
|
20
|
-
export function is(val: any, type: any) {
|
|
21
|
-
const typeArr = Array.isArray(type) ? type : [type]
|
|
22
|
-
const valType = Object.prototype.toString.call(val)
|
|
23
|
-
return typeArr.some((type) => `[object ${type}]` === valType)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 判断是否是移动端
|
|
28
|
-
*/
|
|
29
|
-
export function isMobile() {
|
|
30
|
-
if (navigator.userAgent.match(/('phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone')/i)) {
|
|
31
|
-
return true
|
|
32
|
-
} else {
|
|
33
|
-
return false
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 处理按钮类型
|
|
39
|
-
* @param item
|
|
40
|
-
*/
|
|
41
|
-
export function handelBtnType(item: any): Object {
|
|
42
|
-
switch (item.type) {
|
|
43
|
-
case undefined:
|
|
44
|
-
item.type = 'primary'
|
|
45
|
-
break
|
|
46
|
-
case 'add':
|
|
47
|
-
item.type = 'primary'
|
|
48
|
-
item.title = item.title || '新增'
|
|
49
|
-
item.icon = 'ele-Plus'
|
|
50
|
-
break
|
|
51
|
-
case 'edit':
|
|
52
|
-
item.type = 'primary'
|
|
53
|
-
item.title = item.title || '编辑'
|
|
54
|
-
item.icon = 'ele-EditPen'
|
|
55
|
-
break
|
|
56
|
-
case 'delete':
|
|
57
|
-
case 'del':
|
|
58
|
-
item.type = 'danger'
|
|
59
|
-
item.title = item.title || '删除'
|
|
60
|
-
item.icon = 'ele-Delete'
|
|
61
|
-
break
|
|
62
|
-
}
|
|
63
|
-
return item
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 处理列表表头,list转Map
|
|
68
|
-
*/
|
|
69
|
-
export function handelListColumn(columnList: Array<IColumnItem>, minWidth?: string): any[] {
|
|
70
|
-
const tempColumnList = [] as any[]
|
|
71
|
-
if (columnList && columnList.length > 0) {
|
|
72
|
-
// 不影响原有的对象,这里进行拷贝
|
|
73
|
-
cloneDeep(columnList).map((item: IColumnItem) => {
|
|
74
|
-
//
|
|
75
|
-
if (item.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
case '
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
item.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
return tempColumnList
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
*
|
|
128
|
-
* @param
|
|
129
|
-
* @param
|
|
130
|
-
* @
|
|
131
|
-
*/
|
|
132
|
-
export
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
1
|
+
import { cloneDeep } from 'lodash'
|
|
2
|
+
import { ICRUDConfig, IColumnItem } from 'types'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 获取随机字符串
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export function getUID(): string {
|
|
9
|
+
let str = ''
|
|
10
|
+
const arr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
|
|
11
|
+
for (let i = 0; i < 32; i++) {
|
|
12
|
+
let index = Math.floor(arr.length * Math.random())
|
|
13
|
+
if (index < 0) index = 0
|
|
14
|
+
str += arr[index]
|
|
15
|
+
}
|
|
16
|
+
return str
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 判断类型
|
|
20
|
+
export function is(val: any, type: any) {
|
|
21
|
+
const typeArr = Array.isArray(type) ? type : [type]
|
|
22
|
+
const valType = Object.prototype.toString.call(val)
|
|
23
|
+
return typeArr.some((type) => `[object ${type}]` === valType)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 判断是否是移动端
|
|
28
|
+
*/
|
|
29
|
+
export function isMobile() {
|
|
30
|
+
if (navigator.userAgent.match(/('phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone')/i)) {
|
|
31
|
+
return true
|
|
32
|
+
} else {
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 处理按钮类型
|
|
39
|
+
* @param item
|
|
40
|
+
*/
|
|
41
|
+
export function handelBtnType(item: any): Object {
|
|
42
|
+
switch (item.type) {
|
|
43
|
+
case undefined:
|
|
44
|
+
item.type = 'primary'
|
|
45
|
+
break
|
|
46
|
+
case 'add':
|
|
47
|
+
item.type = 'primary'
|
|
48
|
+
item.title = item.title || '新增'
|
|
49
|
+
item.icon = 'ele-Plus'
|
|
50
|
+
break
|
|
51
|
+
case 'edit':
|
|
52
|
+
item.type = 'primary'
|
|
53
|
+
item.title = item.title || '编辑'
|
|
54
|
+
item.icon = 'ele-EditPen'
|
|
55
|
+
break
|
|
56
|
+
case 'delete':
|
|
57
|
+
case 'del':
|
|
58
|
+
item.type = 'danger'
|
|
59
|
+
item.title = item.title || '删除'
|
|
60
|
+
item.icon = 'ele-Delete'
|
|
61
|
+
break
|
|
62
|
+
}
|
|
63
|
+
return item
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 处理列表表头,list转Map
|
|
68
|
+
*/
|
|
69
|
+
export function handelListColumn(columnList: Array<IColumnItem>, defaultConf: ICRUDConfig, tbName: string, headerAlign?: string, minWidth?: string): any[] {
|
|
70
|
+
const tempColumnList = [] as any[]
|
|
71
|
+
if (columnList && columnList.length > 0) {
|
|
72
|
+
// 不影响原有的对象,这里进行拷贝
|
|
73
|
+
cloneDeep(columnList).map((item: IColumnItem) => {
|
|
74
|
+
// 如果有子集
|
|
75
|
+
if (item.children) {
|
|
76
|
+
item.children = handelListColumn(item.children, defaultConf, tbName, headerAlign, minWidth)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 处理下一个单元格显示多个数据
|
|
80
|
+
// if (item.nodes) {
|
|
81
|
+
// const tempList = (handelListColumn(item.nodes, minWidth) as any)[0].children
|
|
82
|
+
// item.nodes = tempList || item.nodes
|
|
83
|
+
// }
|
|
84
|
+
// 检查type属性,没有type属性的自动补一个text类型
|
|
85
|
+
if (!item.type) {
|
|
86
|
+
item.type = 'text'
|
|
87
|
+
}
|
|
88
|
+
// 这里判断下type类型,然后进行一下表头和表格的对齐方式
|
|
89
|
+
switch (item.type) {
|
|
90
|
+
case 'image':
|
|
91
|
+
item.width = item.width || '110px'
|
|
92
|
+
item.align = item.align || 'left'
|
|
93
|
+
item.headerAlign = item.headerAlign || headerAlign || 'left'
|
|
94
|
+
break
|
|
95
|
+
case 'btns':
|
|
96
|
+
if (!item.minWidth && item.btns && item.btns.length >= 2) {
|
|
97
|
+
let labelLength = 0
|
|
98
|
+
item.btns.map((item: any) => (labelLength += typeof item.label === 'string' ? item.label.length : 4))
|
|
99
|
+
item.width = item.width || labelLength * 20 + 'px'
|
|
100
|
+
}
|
|
101
|
+
item.align = item.align || 'left'
|
|
102
|
+
item.headerAlign = item.headerAlign || headerAlign || 'left'
|
|
103
|
+
item.text = true
|
|
104
|
+
break
|
|
105
|
+
}
|
|
106
|
+
// item.minWidth = item.minWidth || 'auto'
|
|
107
|
+
item.minWidth = item.minWidth || (item.label !== '操作' ? minWidth : 'auto')
|
|
108
|
+
|
|
109
|
+
// 处理下‘操作’
|
|
110
|
+
item.showOverflowTooltip = item.label !== '操作'
|
|
111
|
+
|
|
112
|
+
// 处理vif
|
|
113
|
+
handelVIf(item, defaultConf, tbName)
|
|
114
|
+
|
|
115
|
+
// 表头居中
|
|
116
|
+
if (item.children?.length) {
|
|
117
|
+
item.headerAlign = item.headerAlign || headerAlign || 'center'
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
tempColumnList.push(item)
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
return tempColumnList
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 处理item的vif
|
|
128
|
+
* @param item
|
|
129
|
+
* @param defaultConf
|
|
130
|
+
* @param tbName
|
|
131
|
+
*/
|
|
132
|
+
export function handelVIf(item: IColumnItem, defaultConf: ICRUDConfig, tbName: string) {
|
|
133
|
+
if (tbName) {
|
|
134
|
+
if (item.vif !== undefined && item.vif !== null) {
|
|
135
|
+
if (typeof item.vif === 'function') {
|
|
136
|
+
item._vif = item.vif(item)
|
|
137
|
+
} else {
|
|
138
|
+
item._vif = !!item.vif
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
item._vif = true
|
|
142
|
+
}
|
|
143
|
+
item.__vif = item.scShow && item._vif
|
|
144
|
+
} else {
|
|
145
|
+
// 这里初始化一下vif
|
|
146
|
+
if (item.vif !== undefined && item.vif !== null) {
|
|
147
|
+
if (typeof item.vif === 'function') {
|
|
148
|
+
item._vif = item.vif(item)
|
|
149
|
+
} else {
|
|
150
|
+
item._vif = !!item.vif
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
item._vif = true
|
|
154
|
+
}
|
|
155
|
+
// 这里最终处理一下auth权限问题
|
|
156
|
+
if (item.auth) {
|
|
157
|
+
if (!defaultConf.auth) {
|
|
158
|
+
console.warn('使用auth属性,请在crud注册时传入auth校验方法~')
|
|
159
|
+
} else {
|
|
160
|
+
item._vif = defaultConf.auth(item.auth)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
item.__vif = item._vif
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 这里要判断下下级显示状态, 如果下级全部隐藏了,那么本级也应该隐藏
|
|
167
|
+
if (item.children && item.children.every((info) => !info.__vif)) {
|
|
168
|
+
item.__vif = false
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* map转string
|
|
174
|
+
* @param map
|
|
175
|
+
* @param excludeList
|
|
176
|
+
* @returns {string}
|
|
177
|
+
*/
|
|
178
|
+
export const mapToUrlStr = (map: any, excludeList?: any) => {
|
|
179
|
+
let queryStr = ''
|
|
180
|
+
for (const key in map) {
|
|
181
|
+
if (excludeList && Array.isArray(excludeList) && excludeList.length > 0) {
|
|
182
|
+
if (excludeList.indexOf(key) >= 0) {
|
|
183
|
+
continue
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (map[key] !== undefined && map[key] !== null && map[key] !== '') {
|
|
187
|
+
if (queryStr !== '') {
|
|
188
|
+
queryStr += '&'
|
|
189
|
+
}
|
|
190
|
+
queryStr += key + '=' + map[key]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return queryStr
|
|
194
|
+
}
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "el-plus-crud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "el-plus-crud",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.80",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@element-plus/icons-vue": "^2.1.0",
|