el-plus-crud 0.0.39 → 0.0.41

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.
Files changed (73) hide show
  1. package/.eslintrc.js +78 -78
  2. package/.prettierrc.js +39 -39
  3. package/CHANGELOG.md +5 -1
  4. package/build.js +31 -31
  5. package/dist/el-plus-crud.mjs +1803 -1801
  6. package/dist/el-plus-crud.umd.js +7 -7
  7. package/dist/style.css +1 -1
  8. package/example/App.vue +67 -67
  9. package/example/main.js +18 -18
  10. package/index.html +13 -13
  11. package/lib/components/el-plus-form/ElPlusForm.vue +771 -774
  12. package/lib/components/el-plus-form/ElPlusFormDialog.vue +90 -90
  13. package/lib/components/el-plus-form/ElPlusFormGroup.vue +116 -116
  14. package/lib/components/el-plus-form/components/ElPlusFormArea.vue +61 -61
  15. package/lib/components/el-plus-form/components/ElPlusFormAutocomplete.vue +49 -49
  16. package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +102 -102
  17. package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +133 -133
  18. package/lib/components/el-plus-form/components/ElPlusFormCascader.vue +63 -63
  19. package/lib/components/el-plus-form/components/ElPlusFormCascaderPanel.vue +53 -53
  20. package/lib/components/el-plus-form/components/ElPlusFormCheckbox.vue +44 -44
  21. package/lib/components/el-plus-form/components/ElPlusFormCheckboxButton.vue +44 -44
  22. package/lib/components/el-plus-form/components/ElPlusFormColor.vue +38 -38
  23. package/lib/components/el-plus-form/components/ElPlusFormDate.vue +39 -39
  24. package/lib/components/el-plus-form/components/ElPlusFormDaterange.vue +46 -46
  25. package/lib/components/el-plus-form/components/ElPlusFormDatetime.vue +40 -40
  26. package/lib/components/el-plus-form/components/ElPlusFormFile.vue +47 -47
  27. package/lib/components/el-plus-form/components/ElPlusFormImage.vue +113 -113
  28. package/lib/components/el-plus-form/components/ElPlusFormLink.vue +281 -281
  29. package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +489 -489
  30. package/lib/components/el-plus-form/components/ElPlusFormNbinput.vue +53 -53
  31. package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +146 -146
  32. package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +94 -94
  33. package/lib/components/el-plus-form/components/ElPlusFormRadio.vue +42 -42
  34. package/lib/components/el-plus-form/components/ElPlusFormRate.vue +38 -38
  35. package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +161 -161
  36. package/lib/components/el-plus-form/components/ElPlusFormSlider.vue +38 -38
  37. package/lib/components/el-plus-form/components/ElPlusFormSwitch.vue +38 -38
  38. package/lib/components/el-plus-form/components/ElPlusFormTag.vue +78 -78
  39. package/lib/components/el-plus-form/components/ElPlusFormText.vue +99 -99
  40. package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +49 -49
  41. package/lib/components/el-plus-form/components/ElPlusFormTransfer.vue +44 -44
  42. package/lib/components/el-plus-form/components/ElPlusFormTree.vue +76 -76
  43. package/lib/components/el-plus-form/components/ElPlusFormTreeSelect.vue +59 -59
  44. package/lib/components/el-plus-form/components/ElPlusFormUpload.vue +368 -368
  45. package/lib/components/el-plus-form/components/components/file-icons/FileIcons.vue +135 -135
  46. package/lib/components/el-plus-form/components/components/file-icons/data/index.ts +27 -27
  47. package/lib/components/el-plus-form/components/components/file-icons/images/doc.svg +12 -12
  48. package/lib/components/el-plus-form/components/components/file-icons/images/file.svg +18 -18
  49. package/lib/components/el-plus-form/components/components/file-icons/images/jpg.svg +13 -13
  50. package/lib/components/el-plus-form/components/components/file-icons/images/pdf.svg +12 -12
  51. package/lib/components/el-plus-form/components/components/file-icons/images/png.svg +12 -12
  52. package/lib/components/el-plus-form/components/components/file-icons/images/ppt.svg +12 -12
  53. package/lib/components/el-plus-form/components/components/file-icons/images/xls.svg +12 -12
  54. package/lib/components/el-plus-form/components/index.ts +17 -17
  55. package/lib/components/el-plus-form/data/file.ts +74 -74
  56. package/lib/components/el-plus-form/mixins/index.ts +115 -113
  57. package/lib/components/el-plus-form/util/index.ts +257 -257
  58. package/lib/components/el-plus-form/util/validate.ts +332 -332
  59. package/lib/components/el-plus-table/components/columnItem.vue +205 -205
  60. package/lib/components/el-plus-table/components/header.vue +240 -240
  61. package/lib/components/el-plus-table/components/statisticInfo.vue +47 -47
  62. package/lib/components/el-plus-table/util/index.ts +147 -147
  63. package/lib/config/index.ts +30 -30
  64. package/lib/index.d.ts +4 -4
  65. package/lib/index.ts +51 -51
  66. package/package.json +1 -1
  67. package/types/axios.d.ts +13 -13
  68. package/types/formList.d.ts +440 -440
  69. package/types/layout.d.ts +57 -57
  70. package/types/mitt.d.ts +38 -38
  71. package/types/pinia.d.ts +149 -149
  72. package/types/views.d.ts +329 -329
  73. package/vite.config.ts +78 -78
@@ -1,257 +1,257 @@
1
- // 是否定义
2
- export function isDef(val: any) {
3
- return !isUnDef(val)
4
- }
5
-
6
- // 是否没定义
7
- export function isUnDef(val: any) {
8
- return val === null || val === undefined
9
- }
10
-
11
- // 判断是否为函数
12
- export function isFunction(val: any) {
13
- return typeof val === 'function'
14
- }
15
-
16
- /**
17
- * 获取随机字符串
18
- * @returns {string}
19
- */
20
- export function getUID(): string {
21
- let str = ''
22
- const arr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
23
- for (let i = 0; i < 32; i++) {
24
- let index = Math.floor(arr.length * Math.random())
25
- if (index < 0) index = 0
26
- str += arr[index]
27
- }
28
- return str
29
- }
30
-
31
- /**
32
- * 判断是否是移动端
33
- */
34
- export function isMobile() {
35
- 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)) {
36
- return true
37
- } else {
38
- return false
39
- }
40
- }
41
-
42
- // 判断类型
43
- export function is(val: any, type: any) {
44
- const typeArr = Array.isArray(type) ? type : [type]
45
- const valType = Object.prototype.toString.call(val)
46
- return typeArr.some((type) => `[object ${type}]` === valType)
47
- }
48
-
49
- // 获取 display: none 的节点宽度和高度
50
- export function getSize(elem: any) {
51
- const noneNodes: any[] = []
52
- const nodeStyle: any[] = []
53
-
54
- getNoneNode(elem) // 获取多层display:none;的元素
55
- setNodeStyle()
56
- const width = elem.clientWidth
57
- const height = elem.clientHeight
58
- resumeNodeStyle()
59
-
60
- return {
61
- width: width,
62
- height: height
63
- }
64
-
65
- function getNoneNode(node: any) {
66
- const display = getStyles(node).getPropertyValue('display')
67
- const tagName = node.nodeName.toLowerCase()
68
- if (display !== 'none' && tagName !== 'body') {
69
- getNoneNode(node.parentNode)
70
- } else {
71
- noneNodes.push(node)
72
- if (tagName !== 'body') getNoneNode(node.parentNode)
73
- }
74
- }
75
-
76
- // 这方法才能获取最终是否有display属性设置,不能style.display。
77
- function getStyles(elem: any) {
78
- // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
79
- // IE throws on elements created in popups
80
- // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
81
- let view = elem.ownerDocument.defaultView
82
-
83
- if (!view || !view.opener) {
84
- view = window
85
- }
86
- return view.getComputedStyle(elem)
87
- }
88
-
89
- function setNodeStyle() {
90
- let i = 0
91
- for (; i < noneNodes.length; i++) {
92
- const visibility = noneNodes[i].style.visibility
93
- const display = noneNodes[i].style.display
94
- const style = noneNodes[i].getAttribute('style')
95
- // 覆盖其他display样式
96
- noneNodes[i].setAttribute('style', 'visibility:hidden;display:block !important;' + style)
97
- nodeStyle[i] = {
98
- visibility: visibility,
99
- display: display
100
- }
101
- }
102
- }
103
-
104
- function resumeNodeStyle() {
105
- let i = 0
106
- for (; i < noneNodes.length; i++) {
107
- noneNodes[i].style.visibility = nodeStyle[i].visibility
108
- noneNodes[i].style.display = nodeStyle[i].display
109
- }
110
- }
111
- }
112
-
113
- // 如果 value 不是数组, 那么强制转为数组
114
- // 空转为空数组 undefined | null | '' => []
115
- // 1 => [1], false => [false], {} => [{}]
116
- export function castArray(value: any) {
117
- if (Array.isArray(value)) {
118
- return value
119
- } else if (value === undefined || value === null || value === '') {
120
- return []
121
- } else {
122
- return value.split(',')
123
- }
124
- }
125
- // 数据转移为cascade的category
126
- export function castCategory(value: any, formData: any) {
127
- if (Array.isArray(value)) {
128
- return value
129
- } else {
130
- const tempList = []
131
- if (formData.categoryId1) tempList.push(formData.categoryId1)
132
- if (formData.categoryId2) tempList.push(formData.categoryId2)
133
- if (formData.categoryId3) tempList.push(formData.categoryId3)
134
- return tempList
135
- }
136
- }
137
- // 如果 value 不是数组, 那么强制转为数组
138
- export function castFileList(value: any) {
139
- if (Array.isArray(value)) {
140
- return value
141
- } else if (value === undefined || value === null || value === '') {
142
- return []
143
- } else {
144
- return value.split(',')
145
- }
146
- }
147
- // 如果 value 不是字符串, 那么强制转为字符串
148
- export function castString(value: any) {
149
- if (typeof value === 'string') {
150
- return value
151
- } else if (value === undefined || value === null) {
152
- return ''
153
- } else if (value.toString) {
154
- return value.toString()
155
- } else {
156
- return value + ''
157
- }
158
- }
159
- // 如果 value 不是Boolean, 那么强制转为Boolean
160
- export function castBoolean(value: any) {
161
- if (typeof value === 'boolean') {
162
- return value
163
- } else {
164
- return Boolean(value)
165
- }
166
- }
167
- // 如果 value 不是Number, 那么强制转为Number
168
- export function castNumber(value: any): number {
169
- if (typeof value === 'number') {
170
- return value
171
- } else {
172
- return Number(value) || 0
173
- }
174
- }
175
-
176
- // 判断是否为空
177
- // 空数组 / null / undefined / 空字符串
178
- export function isEmpty(val: any) {
179
- if (Array.isArray(val) && val.length === 0) {
180
- return true
181
- } else if (isUnDef(val)) {
182
- return true
183
- } else if (typeof val === 'string' && val === '') {
184
- return true
185
- } else {
186
- return false
187
- }
188
- }
189
-
190
- /**
191
- * 格式化表单字段
192
- * @param formData
193
- * @param formDesc
194
- */
195
- export function valueFormat(formData: any, formDesc: any) {
196
- for (const field in formData) {
197
- const formItem = formDesc[field]
198
- if (formItem && formItem.valueFormat) {
199
- if (typeof formItem.valueFormat === 'function') {
200
- formData[field] = formItem.valueFormat(formData[field], formData)
201
- }
202
- switch (formItem.valueFormat) {
203
- case 'arrayToStr':
204
- formData[field] = arrayToStr(formData[field])
205
- break
206
- default:
207
- throw Error('无效的 valueFormat 类型')
208
- }
209
- }
210
- }
211
- }
212
-
213
- /**
214
- *
215
- * @param val 数组转字符串
216
- */
217
- export function arrayToStr(val: any) {
218
- if (Array.isArray(val)) {
219
- return val.join(',')
220
- } else {
221
- return val + ''
222
- }
223
- }
224
-
225
- /**
226
- * 裁剪长度
227
- * @param str
228
- * @param len
229
- * @param isTransHz 是否转换汉字长度为2个英文字母长度
230
- */
231
- export const cutString = (str: string = '', len: number, isTransHz: boolean = false) => {
232
- if (!str) return ''
233
- const length = isTransHz ? getStrLength(str) : str.length
234
- if (length > len) {
235
- return str.substring(0, len - 2) + '...' + str.substring(len - 2, len)
236
- }
237
- return str
238
- }
239
-
240
- /**
241
- * 获取字符串长度
242
- * @type {(p1?:*)}
243
- */
244
- export const getStrLength = (str: any) => {
245
- // <summary>获得字符串实际长度,中文2,英文1</summary>
246
- // <param name='str'>要获得长度的字符串</param>
247
- if (!str) return 0
248
- let realLength = 0
249
- const len = str.length
250
- let charCode = -1
251
- for (let i = 0; i < len; i++) {
252
- charCode = str.charCodeAt(i)
253
- if (charCode >= 0 && charCode <= 128) realLength += 1
254
- else realLength += 2
255
- }
256
- return realLength
257
- }
1
+ // 是否定义
2
+ export function isDef(val: any) {
3
+ return !isUnDef(val)
4
+ }
5
+
6
+ // 是否没定义
7
+ export function isUnDef(val: any) {
8
+ return val === null || val === undefined
9
+ }
10
+
11
+ // 判断是否为函数
12
+ export function isFunction(val: any) {
13
+ return typeof val === 'function'
14
+ }
15
+
16
+ /**
17
+ * 获取随机字符串
18
+ * @returns {string}
19
+ */
20
+ export function getUID(): string {
21
+ let str = ''
22
+ const arr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
23
+ for (let i = 0; i < 32; i++) {
24
+ let index = Math.floor(arr.length * Math.random())
25
+ if (index < 0) index = 0
26
+ str += arr[index]
27
+ }
28
+ return str
29
+ }
30
+
31
+ /**
32
+ * 判断是否是移动端
33
+ */
34
+ export function isMobile() {
35
+ 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)) {
36
+ return true
37
+ } else {
38
+ return false
39
+ }
40
+ }
41
+
42
+ // 判断类型
43
+ export function is(val: any, type: any) {
44
+ const typeArr = Array.isArray(type) ? type : [type]
45
+ const valType = Object.prototype.toString.call(val)
46
+ return typeArr.some((type) => `[object ${type}]` === valType)
47
+ }
48
+
49
+ // 获取 display: none 的节点宽度和高度
50
+ export function getSize(elem: any) {
51
+ const noneNodes: any[] = []
52
+ const nodeStyle: any[] = []
53
+
54
+ getNoneNode(elem) // 获取多层display:none;的元素
55
+ setNodeStyle()
56
+ const width = elem.clientWidth
57
+ const height = elem.clientHeight
58
+ resumeNodeStyle()
59
+
60
+ return {
61
+ width: width,
62
+ height: height
63
+ }
64
+
65
+ function getNoneNode(node: any) {
66
+ const display = getStyles(node).getPropertyValue('display')
67
+ const tagName = node.nodeName.toLowerCase()
68
+ if (display !== 'none' && tagName !== 'body') {
69
+ getNoneNode(node.parentNode)
70
+ } else {
71
+ noneNodes.push(node)
72
+ if (tagName !== 'body') getNoneNode(node.parentNode)
73
+ }
74
+ }
75
+
76
+ // 这方法才能获取最终是否有display属性设置,不能style.display。
77
+ function getStyles(elem: any) {
78
+ // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
79
+ // IE throws on elements created in popups
80
+ // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
81
+ let view = elem.ownerDocument.defaultView
82
+
83
+ if (!view || !view.opener) {
84
+ view = window
85
+ }
86
+ return view.getComputedStyle(elem)
87
+ }
88
+
89
+ function setNodeStyle() {
90
+ let i = 0
91
+ for (; i < noneNodes.length; i++) {
92
+ const visibility = noneNodes[i].style.visibility
93
+ const display = noneNodes[i].style.display
94
+ const style = noneNodes[i].getAttribute('style')
95
+ // 覆盖其他display样式
96
+ noneNodes[i].setAttribute('style', 'visibility:hidden;display:block !important;' + style)
97
+ nodeStyle[i] = {
98
+ visibility: visibility,
99
+ display: display
100
+ }
101
+ }
102
+ }
103
+
104
+ function resumeNodeStyle() {
105
+ let i = 0
106
+ for (; i < noneNodes.length; i++) {
107
+ noneNodes[i].style.visibility = nodeStyle[i].visibility
108
+ noneNodes[i].style.display = nodeStyle[i].display
109
+ }
110
+ }
111
+ }
112
+
113
+ // 如果 value 不是数组, 那么强制转为数组
114
+ // 空转为空数组 undefined | null | '' => []
115
+ // 1 => [1], false => [false], {} => [{}]
116
+ export function castArray(value: any) {
117
+ if (Array.isArray(value)) {
118
+ return value
119
+ } else if (value === undefined || value === null || value === '') {
120
+ return []
121
+ } else {
122
+ return value.split(',')
123
+ }
124
+ }
125
+ // 数据转移为cascade的category
126
+ export function castCategory(value: any, formData: any) {
127
+ if (Array.isArray(value)) {
128
+ return value
129
+ } else {
130
+ const tempList = []
131
+ if (formData.categoryId1) tempList.push(formData.categoryId1)
132
+ if (formData.categoryId2) tempList.push(formData.categoryId2)
133
+ if (formData.categoryId3) tempList.push(formData.categoryId3)
134
+ return tempList
135
+ }
136
+ }
137
+ // 如果 value 不是数组, 那么强制转为数组
138
+ export function castFileList(value: any) {
139
+ if (Array.isArray(value)) {
140
+ return value
141
+ } else if (value === undefined || value === null || value === '') {
142
+ return []
143
+ } else {
144
+ return value.split(',')
145
+ }
146
+ }
147
+ // 如果 value 不是字符串, 那么强制转为字符串
148
+ export function castString(value: any) {
149
+ if (typeof value === 'string') {
150
+ return value
151
+ } else if (value === undefined || value === null) {
152
+ return ''
153
+ } else if (value.toString) {
154
+ return value.toString()
155
+ } else {
156
+ return value + ''
157
+ }
158
+ }
159
+ // 如果 value 不是Boolean, 那么强制转为Boolean
160
+ export function castBoolean(value: any) {
161
+ if (typeof value === 'boolean') {
162
+ return value
163
+ } else {
164
+ return Boolean(value)
165
+ }
166
+ }
167
+ // 如果 value 不是Number, 那么强制转为Number
168
+ export function castNumber(value: any): number {
169
+ if (typeof value === 'number') {
170
+ return value
171
+ } else {
172
+ return Number(value) || 0
173
+ }
174
+ }
175
+
176
+ // 判断是否为空
177
+ // 空数组 / null / undefined / 空字符串
178
+ export function isEmpty(val: any) {
179
+ if (Array.isArray(val) && val.length === 0) {
180
+ return true
181
+ } else if (isUnDef(val)) {
182
+ return true
183
+ } else if (typeof val === 'string' && val === '') {
184
+ return true
185
+ } else {
186
+ return false
187
+ }
188
+ }
189
+
190
+ /**
191
+ * 格式化表单字段
192
+ * @param formData
193
+ * @param formDesc
194
+ */
195
+ export function valueFormat(formData: any, formDesc: any) {
196
+ for (const field in formData) {
197
+ const formItem = formDesc[field]
198
+ if (formItem && formItem.valueFormat) {
199
+ if (typeof formItem.valueFormat === 'function') {
200
+ formData[field] = formItem.valueFormat(formData[field], formData)
201
+ }
202
+ switch (formItem.valueFormat) {
203
+ case 'arrayToStr':
204
+ formData[field] = arrayToStr(formData[field])
205
+ break
206
+ default:
207
+ throw Error('无效的 valueFormat 类型')
208
+ }
209
+ }
210
+ }
211
+ }
212
+
213
+ /**
214
+ *
215
+ * @param val 数组转字符串
216
+ */
217
+ export function arrayToStr(val: any) {
218
+ if (Array.isArray(val)) {
219
+ return val.join(',')
220
+ } else {
221
+ return val + ''
222
+ }
223
+ }
224
+
225
+ /**
226
+ * 裁剪长度
227
+ * @param str
228
+ * @param len
229
+ * @param isTransHz 是否转换汉字长度为2个英文字母长度
230
+ */
231
+ export const cutString = (str: string = '', len: number, isTransHz: boolean = false) => {
232
+ if (!str) return ''
233
+ const length = isTransHz ? getStrLength(str) : str.length
234
+ if (length > len) {
235
+ return str.substring(0, len - 2) + '...' + str.substring(len - 2, len)
236
+ }
237
+ return str
238
+ }
239
+
240
+ /**
241
+ * 获取字符串长度
242
+ * @type {(p1?:*)}
243
+ */
244
+ export const getStrLength = (str: any) => {
245
+ // <summary>获得字符串实际长度,中文2,英文1</summary>
246
+ // <param name='str'>要获得长度的字符串</param>
247
+ if (!str) return 0
248
+ let realLength = 0
249
+ const len = str.length
250
+ let charCode = -1
251
+ for (let i = 0; i < len; i++) {
252
+ charCode = str.charCodeAt(i)
253
+ if (charCode >= 0 && charCode <= 128) realLength += 1
254
+ else realLength += 2
255
+ }
256
+ return realLength
257
+ }