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,147 +1,147 @@
1
- import { cloneDeep } from 'lodash'
2
-
3
- /**
4
- * 获取随机字符串
5
- * @returns {string}
6
- */
7
- export function getUID(): string {
8
- let str = ''
9
- const arr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
10
- for (let i = 0; i < 32; i++) {
11
- let index = Math.floor(arr.length * Math.random())
12
- if (index < 0) index = 0
13
- str += arr[index]
14
- }
15
- return str
16
- }
17
-
18
- // 判断类型
19
- export function is(val: any, type: any) {
20
- const typeArr = Array.isArray(type) ? type : [type]
21
- const valType = Object.prototype.toString.call(val)
22
- return typeArr.some((type) => `[object ${type}]` === valType)
23
- }
24
-
25
- /**
26
- * 判断是否是移动端
27
- */
28
- export function isMobile() {
29
- 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)) {
30
- return true
31
- } else {
32
- return false
33
- }
34
- }
35
-
36
- /**
37
- * 处理按钮类型
38
- * @param item
39
- */
40
- export function handelBtnType(item: any): Object {
41
- switch (item.type) {
42
- case undefined:
43
- item.type = 'primary'
44
- break
45
- case 'add':
46
- item.type = 'primary'
47
- item.title = item.title || '新增'
48
- item.icon = 'ele-Plus'
49
- break
50
- case 'edit':
51
- item.type = 'primary'
52
- item.title = item.title || '编辑'
53
- item.icon = 'ele-EditPen'
54
- break
55
- case 'delete':
56
- case 'del':
57
- item.type = 'danger'
58
- item.title = item.title || '删除'
59
- item.icon = 'ele-Delete'
60
- break
61
- }
62
- return item
63
- }
64
-
65
- /**
66
- * 处理列表表头,list转Map
67
- */
68
- export function handelListColumn(columnList: Array<IColumnItem>, minWidth?: string): any[] {
69
- const tempColumnList = [] as any[]
70
- if (columnList && columnList.length > 0) {
71
- // 不影响原有的对象,这里进行拷贝
72
- cloneDeep(columnList).map((item: IColumnItem) => {
73
- // 处理下一个单元格显示多个数据
74
- if (item.nodes) {
75
- const tempList = (handelListColumn(item.nodes, minWidth) as any)[0].children
76
- item.nodes = tempList || item.nodes
77
- }
78
- // 检查type属性,没有type属性的自动补一个text类型
79
- if (!item.type) {
80
- item.type = 'text'
81
- }
82
- // 这里判断下type类型,然后进行一下表头和表格的对齐方式
83
- switch (item.type) {
84
- case 'image':
85
- item.width = item.width || '110px'
86
- item.align = item.align || 'left'
87
- item.headerAlign = item.headerAlign || 'left'
88
- break
89
- case 'btns':
90
- if (!item.minWidth && item.btns && item.btns.length >= 2) {
91
- let labelLength = 0
92
- item.btns.map((item: any) => (labelLength += typeof item.label === 'string' ? item.label.length : 4))
93
- item.width = item.width || labelLength * 20 + 'px'
94
- }
95
- item.align = item.align || 'left'
96
- item.headerAlign = item.headerAlign || 'left'
97
- item.text = true
98
- break
99
- }
100
- // item.minWidth = item.minWidth || 'auto'
101
- item.minWidth = item.minWidth || (item.label !== '操作' ? minWidth : 'auto')
102
-
103
- // 处理下‘操作’
104
- item.showOverflowTooltip = item.label !== '操作'
105
-
106
- if (item.parent) {
107
- let isExists = false
108
- tempColumnList.forEach((colum: any) => {
109
- if (colum.label === item.parent) {
110
- colum.children.push(item)
111
- isExists = true
112
- }
113
- })
114
- if (!isExists) {
115
- tempColumnList.push({ label: item.parent, children: [item] })
116
- }
117
- } else {
118
- tempColumnList.push(item)
119
- }
120
- })
121
- }
122
- return tempColumnList
123
- }
124
-
125
- /**
126
- * map转string
127
- * @param map
128
- * @param excludeList
129
- * @returns {string}
130
- */
131
- export const mapToUrlStr = (map: any, excludeList?: any) => {
132
- let queryStr = ''
133
- for (const key in map) {
134
- if (excludeList && Array.isArray(excludeList) && excludeList.length > 0) {
135
- if (excludeList.indexOf(key) >= 0) {
136
- continue
137
- }
138
- }
139
- if (map[key] !== undefined && map[key] !== null && map[key] !== '') {
140
- if (queryStr !== '') {
141
- queryStr += '&'
142
- }
143
- queryStr += key + '=' + map[key]
144
- }
145
- }
146
- return queryStr
147
- }
1
+ import { cloneDeep } from 'lodash'
2
+
3
+ /**
4
+ * 获取随机字符串
5
+ * @returns {string}
6
+ */
7
+ export function getUID(): string {
8
+ let str = ''
9
+ const arr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
10
+ for (let i = 0; i < 32; i++) {
11
+ let index = Math.floor(arr.length * Math.random())
12
+ if (index < 0) index = 0
13
+ str += arr[index]
14
+ }
15
+ return str
16
+ }
17
+
18
+ // 判断类型
19
+ export function is(val: any, type: any) {
20
+ const typeArr = Array.isArray(type) ? type : [type]
21
+ const valType = Object.prototype.toString.call(val)
22
+ return typeArr.some((type) => `[object ${type}]` === valType)
23
+ }
24
+
25
+ /**
26
+ * 判断是否是移动端
27
+ */
28
+ export function isMobile() {
29
+ 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)) {
30
+ return true
31
+ } else {
32
+ return false
33
+ }
34
+ }
35
+
36
+ /**
37
+ * 处理按钮类型
38
+ * @param item
39
+ */
40
+ export function handelBtnType(item: any): Object {
41
+ switch (item.type) {
42
+ case undefined:
43
+ item.type = 'primary'
44
+ break
45
+ case 'add':
46
+ item.type = 'primary'
47
+ item.title = item.title || '新增'
48
+ item.icon = 'ele-Plus'
49
+ break
50
+ case 'edit':
51
+ item.type = 'primary'
52
+ item.title = item.title || '编辑'
53
+ item.icon = 'ele-EditPen'
54
+ break
55
+ case 'delete':
56
+ case 'del':
57
+ item.type = 'danger'
58
+ item.title = item.title || '删除'
59
+ item.icon = 'ele-Delete'
60
+ break
61
+ }
62
+ return item
63
+ }
64
+
65
+ /**
66
+ * 处理列表表头,list转Map
67
+ */
68
+ export function handelListColumn(columnList: Array<IColumnItem>, minWidth?: string): any[] {
69
+ const tempColumnList = [] as any[]
70
+ if (columnList && columnList.length > 0) {
71
+ // 不影响原有的对象,这里进行拷贝
72
+ cloneDeep(columnList).map((item: IColumnItem) => {
73
+ // 处理下一个单元格显示多个数据
74
+ if (item.nodes) {
75
+ const tempList = (handelListColumn(item.nodes, minWidth) as any)[0].children
76
+ item.nodes = tempList || item.nodes
77
+ }
78
+ // 检查type属性,没有type属性的自动补一个text类型
79
+ if (!item.type) {
80
+ item.type = 'text'
81
+ }
82
+ // 这里判断下type类型,然后进行一下表头和表格的对齐方式
83
+ switch (item.type) {
84
+ case 'image':
85
+ item.width = item.width || '110px'
86
+ item.align = item.align || 'left'
87
+ item.headerAlign = item.headerAlign || 'left'
88
+ break
89
+ case 'btns':
90
+ if (!item.minWidth && item.btns && item.btns.length >= 2) {
91
+ let labelLength = 0
92
+ item.btns.map((item: any) => (labelLength += typeof item.label === 'string' ? item.label.length : 4))
93
+ item.width = item.width || labelLength * 20 + 'px'
94
+ }
95
+ item.align = item.align || 'left'
96
+ item.headerAlign = item.headerAlign || 'left'
97
+ item.text = true
98
+ break
99
+ }
100
+ // item.minWidth = item.minWidth || 'auto'
101
+ item.minWidth = item.minWidth || (item.label !== '操作' ? minWidth : 'auto')
102
+
103
+ // 处理下‘操作’
104
+ item.showOverflowTooltip = item.label !== '操作'
105
+
106
+ if (item.parent) {
107
+ let isExists = false
108
+ tempColumnList.forEach((colum: any) => {
109
+ if (colum.label === item.parent) {
110
+ colum.children.push(item)
111
+ isExists = true
112
+ }
113
+ })
114
+ if (!isExists) {
115
+ tempColumnList.push({ label: item.parent, children: [item] })
116
+ }
117
+ } else {
118
+ tempColumnList.push(item)
119
+ }
120
+ })
121
+ }
122
+ return tempColumnList
123
+ }
124
+
125
+ /**
126
+ * map转string
127
+ * @param map
128
+ * @param excludeList
129
+ * @returns {string}
130
+ */
131
+ export const mapToUrlStr = (map: any, excludeList?: any) => {
132
+ let queryStr = ''
133
+ for (const key in map) {
134
+ if (excludeList && Array.isArray(excludeList) && excludeList.length > 0) {
135
+ if (excludeList.indexOf(key) >= 0) {
136
+ continue
137
+ }
138
+ }
139
+ if (map[key] !== undefined && map[key] !== null && map[key] !== '') {
140
+ if (queryStr !== '') {
141
+ queryStr += '&'
142
+ }
143
+ queryStr += key + '=' + map[key]
144
+ }
145
+ }
146
+ return queryStr
147
+ }
@@ -1,30 +1,30 @@
1
- export default {
2
- debug: false,
3
- size: 'default',
4
- storagePrefix: 'el-plus-crud_',
5
- form: {
6
- leng: {
7
- input: 20,
8
- textare: 500,
9
- nbinput: {
10
- min: 0,
11
- max: 999999999,
12
- precision: 0,
13
- controlsPosition: 'right'
14
- }
15
- },
16
- comList: [] as string[]
17
- },
18
- upload: {
19
- type: 'minio',
20
- action: '',
21
- maxISize: 1024 * 1024 * 20,
22
- maxFSize: 1024 * 1024 * 20,
23
- minio: {
24
- action: '',
25
- getUploadUrl: () => new Promise(() => {}),
26
- doElUpload: () => new Promise(() => {}),
27
- getObjectAuthUrl: () => new Promise(() => {})
28
- }
29
- }
30
- } as ICRUDConfig
1
+ export default {
2
+ debug: false,
3
+ size: 'default',
4
+ storagePrefix: 'el-plus-crud_',
5
+ form: {
6
+ leng: {
7
+ input: 20,
8
+ textare: 500,
9
+ nbinput: {
10
+ min: 0,
11
+ max: 999999999,
12
+ precision: 0,
13
+ controlsPosition: 'right'
14
+ }
15
+ },
16
+ comList: [] as string[]
17
+ },
18
+ upload: {
19
+ type: 'minio',
20
+ action: '',
21
+ maxISize: 1024 * 1024 * 20,
22
+ maxFSize: 1024 * 1024 * 20,
23
+ minio: {
24
+ action: '',
25
+ getUploadUrl: () => new Promise(() => {}),
26
+ doElUpload: () => new Promise(() => {}),
27
+ getObjectAuthUrl: () => new Promise(() => {})
28
+ }
29
+ }
30
+ } as ICRUDConfig
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const _default: {
2
- install: (app: import('vue').App<any>, config: { [key: string]: Function }, format?: { [key: string]: Function }, globalData?: { [key: string]: Function }) => void
3
- }
4
- export default _default
1
+ declare const _default: {
2
+ install: (app: import('vue').App<any>, config: { [key: string]: Function }, format?: { [key: string]: Function }, globalData?: { [key: string]: Function }) => void
3
+ }
4
+ export default _default
package/lib/index.ts CHANGED
@@ -1,51 +1,51 @@
1
- import { App } from 'vue'
2
- import components from './components-list'
3
- import ElPlusForm from './components/el-plus-form/ElPlusForm.vue'
4
- import ElPlusFormDialog from './components/el-plus-form/ElPlusFormDialog.vue'
5
- import ElPlusFormGroup from './components/el-plus-form/ElPlusFormGroup.vue'
6
- import ElPlusTable from './components/el-plus-table/ElPlusTable.vue'
7
- import defaultConf from './config'
8
-
9
- export default {
10
- install: (app: App, config: ICRUDConfig, format?: { [key: string]: Function }, globalData?: { [key: string]: Function }) => {
11
- // 合并配置
12
- deepMerge(defaultConf, config)
13
- defaultConf.debug && console.log('initConfig: ', defaultConf)
14
-
15
- // 这里注入format对象
16
- app.provide('format', format)
17
- app.provide('globalData', globalData)
18
-
19
- // 这里注入defaultConf
20
- app.provide('defaultConf', defaultConf)
21
-
22
- // 循环注册表单组件
23
- components.unshift(ElPlusForm)
24
- components.unshift(ElPlusFormDialog)
25
- components.unshift(ElPlusFormGroup)
26
-
27
- // 注册列表组件
28
- components.push(ElPlusTable)
29
-
30
- defaultConf.debug && console.log('components: ', components)
31
-
32
- components.map((component: any) => {
33
- app.component(component.name, component)
34
- })
35
- }
36
- }
37
-
38
- /**
39
- * 深度合并对象
40
- * @param obj1
41
- * @param obj2
42
- * @returns
43
- */
44
- function deepMerge(obj1: any, obj2: any) {
45
- let key
46
- for (key in obj2) {
47
- // 如果target(也就是obj1[key])存在,且是对象的话再去调用deepMerge,否则就是obj1[key]里面没这个对象,需要与obj2[key]合并
48
- obj1[key] = obj1[key] && obj1[key].toString() === '[object Object]' ? deepMerge(obj1[key], obj2[key]) : (obj1[key] = obj2[key])
49
- }
50
- return obj1
51
- }
1
+ import { App } from 'vue'
2
+ import components from './components-list'
3
+ import ElPlusForm from './components/el-plus-form/ElPlusForm.vue'
4
+ import ElPlusFormDialog from './components/el-plus-form/ElPlusFormDialog.vue'
5
+ import ElPlusFormGroup from './components/el-plus-form/ElPlusFormGroup.vue'
6
+ import ElPlusTable from './components/el-plus-table/ElPlusTable.vue'
7
+ import defaultConf from './config'
8
+
9
+ export default {
10
+ install: (app: App, config: ICRUDConfig, format?: { [key: string]: Function }, globalData?: { [key: string]: Function }) => {
11
+ // 合并配置
12
+ deepMerge(defaultConf, config)
13
+ defaultConf.debug && console.log('initConfig: ', defaultConf)
14
+
15
+ // 这里注入format对象
16
+ app.provide('format', format)
17
+ app.provide('globalData', globalData)
18
+
19
+ // 这里注入defaultConf
20
+ app.provide('defaultConf', defaultConf)
21
+
22
+ // 循环注册表单组件
23
+ components.unshift(ElPlusForm)
24
+ components.unshift(ElPlusFormDialog)
25
+ components.unshift(ElPlusFormGroup)
26
+
27
+ // 注册列表组件
28
+ components.push(ElPlusTable)
29
+
30
+ defaultConf.debug && console.log('components: ', components)
31
+
32
+ components.map((component: any) => {
33
+ app.component(component.name, component)
34
+ })
35
+ }
36
+ }
37
+
38
+ /**
39
+ * 深度合并对象
40
+ * @param obj1
41
+ * @param obj2
42
+ * @returns
43
+ */
44
+ function deepMerge(obj1: any, obj2: any) {
45
+ let key
46
+ for (key in obj2) {
47
+ // 如果target(也就是obj1[key])存在,且是对象的话再去调用deepMerge,否则就是obj1[key]里面没这个对象,需要与obj2[key]合并
48
+ obj1[key] = obj1[key] && obj1[key].toString() === '[object Object]' ? deepMerge(obj1[key], obj2[key]) : (obj1[key] = obj2[key])
49
+ }
50
+ return obj1
51
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "el-plus-crud",
3
3
  "description": "采用Vue3 + TS,封装的element-plus数据驱动表单、列表组件",
4
4
  "author": "K.D.Jack",
5
- "version": "0.0.39",
5
+ "version": "0.0.41",
6
6
  "license": "MIT",
7
7
  "private": false,
8
8
  "main": "dist/el-plus-crud.mjs",
package/types/axios.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- /* eslint-disable */
2
- import * as axios from 'axios'
3
-
4
- // 扩展 axios 数据返回类型,可自行扩展
5
- declare module 'axios' {
6
- export interface AxiosResponse<T = any> {
7
- code: number
8
- data: T
9
- message: string
10
- type?: string
11
- [key: string]: T
12
- }
13
- }
1
+ /* eslint-disable */
2
+ import * as axios from 'axios'
3
+
4
+ // 扩展 axios 数据返回类型,可自行扩展
5
+ declare module 'axios' {
6
+ export interface AxiosResponse<T = any> {
7
+ code: number
8
+ data: T
9
+ message: string
10
+ type?: string
11
+ [key: string]: T
12
+ }
13
+ }