el-plus-crud 0.0.74 → 0.0.76

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 (31) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/el-plus-crud.mjs +10 -10
  3. package/example/App.vue +69 -68
  4. package/lib/components/el-plus-form/ElPlusForm.vue +2 -1
  5. package/lib/components/el-plus-form/ElPlusFormDialog.vue +90 -89
  6. package/lib/components/el-plus-form/ElPlusFormGroup.vue +2 -1
  7. package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +2 -1
  8. package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +2 -1
  9. package/lib/components/el-plus-form/components/ElPlusFormFile.vue +49 -48
  10. package/lib/components/el-plus-form/components/ElPlusFormInput.vue +64 -63
  11. package/lib/components/el-plus-form/components/ElPlusFormLink.vue +284 -283
  12. package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +492 -491
  13. package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +149 -148
  14. package/lib/components/el-plus-form/components/ElPlusFormPassword.vue +46 -45
  15. package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +98 -97
  16. package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +164 -163
  17. package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +52 -51
  18. package/lib/components/el-plus-form/components/ElPlusFormUpbtn.vue +146 -145
  19. package/lib/components/el-plus-form/components/ElPlusFormUpload.vue +371 -370
  20. package/lib/components/el-plus-form/components/components/file-icons/FileIcons.vue +137 -136
  21. package/lib/components/el-plus-table/ElPlusTable.vue +2 -1
  22. package/lib/components/el-plus-table/components/columnItem.vue +214 -213
  23. package/lib/components/el-plus-table/components/header.vue +2 -1
  24. package/lib/components/el-plus-table/components/settingColumn.vue +180 -179
  25. package/lib/components/el-plus-table/util/index.ts +148 -148
  26. package/lib/config/index.ts +32 -32
  27. package/lib/index.ts +52 -52
  28. package/package-lock.json +2 -2
  29. package/package.json +1 -1
  30. package/types/global.d.ts +13 -13
  31. package/types/{formList.d.ts → index.d.ts} +1 -0
@@ -1,145 +1,146 @@
1
- <template>
2
- <div class="el-button el-plus-form-up-btn">
3
- <el-upload class="upload-demo" style="display: flex" v-bind="attrs" :disabled="isLoading || disabled" v-model="currentValue">
4
- <el-button type="primary" :icon="Upload" :loading="isLoading"> {{ btnShowText }}</el-button>
5
- <template #file>
6
- <div></div>
7
- </template>
8
- </el-upload>
9
- </div>
10
- </template>
11
- <script lang="ts">
12
- export default {
13
- name: 'ElPlusFormUpbtn',
14
- inheritAttrs: false,
15
- typeName: 'upbtn',
16
- customOptions: {}
17
- }
18
- </script>
19
- <script lang="ts" setup>
20
- import { ref, computed, onBeforeMount, useAttrs, watch } from 'vue'
21
- import { Upload } from '@element-plus/icons-vue'
22
- import { ElMessage, ElMessageBox, UploadRawFile } from 'element-plus'
23
- import { getAttrs } from '../mixins'
24
- import { IBtnBack } from 'types/formList'
25
-
26
- const props = defineProps<{
27
- field?: string
28
- rowIndex?: number
29
- loading?: boolean
30
- desc: { [key: string]: any }
31
- formData?: { [key: string]: any }
32
- disabled?: boolean
33
- }>()
34
-
35
- const isLoading = ref(!!props.loading)
36
- const currentValue = ref([] as any[])
37
- const attrs = ref({} as any)
38
- const isInit = ref(false)
39
-
40
- const uploadAttr = {
41
- name: 'file',
42
- showFileList: false,
43
- listType: 'text',
44
- accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel',
45
- beforeUpload: async (file: UploadRawFile) => {
46
- isLoading.value = true
47
- let confirmText = props.desc?.confirm || ''
48
- if (confirmText && typeof props.desc?.confirm === 'function') {
49
- confirmText = props.desc.confirm()
50
- }
51
- if (confirmText) {
52
- return new Promise((resolve) => {
53
- ElMessageBox.confirm(confirmText, '提示', {
54
- type: 'warning'
55
- })
56
- .then(() => resolve(true))
57
- .catch(() => {
58
- resolve(false)
59
- isLoading.value = false
60
- })
61
- })
62
- } else {
63
- return handelBeforeUpload(file)
64
- }
65
- },
66
- onError: () => {
67
- ElMessage.error('文件上传出错,请检查文件格式及内容是否正确!')
68
- isLoading.value = false
69
- }
70
- }
71
-
72
- const btnShowText = computed(() => {
73
- if (props.desc.btnLabel) {
74
- if (typeof props.desc.btnLabel === 'function') {
75
- return props.desc.btnLabel(props.formData)
76
- }
77
- return props.desc.btnLabel
78
- }
79
- if (props.desc.label) {
80
- if (typeof props.desc.label === 'function') {
81
- return props.desc.label(props.formData)
82
- }
83
- return props.desc.label
84
- }
85
- return ''
86
- })
87
-
88
- /**
89
- * 文件上传前的处理
90
- * @param file
91
- */
92
- function handelBeforeUpload(file: UploadRawFile) {
93
- isLoading.value = true
94
- const suffix = file.name.substring(file.name.lastIndexOf('.'))
95
- // 校验文件类型
96
- if ((props.desc.attrs.accept || ['.xlsx', '.xls']).indexOf(suffix) < 0) {
97
- ElMessage.warning(`请上传后缀为${(props.desc.attrs.accept || ['.xlsx', '.xls']).join(',')}格式的文件!`)
98
- isLoading.value = false
99
- return false
100
- }
101
- // 校验文件大小
102
- if (file.size > 20 * 1024 * 1024) {
103
- ElMessage.warning('超出文件大小限制(最大为20M)!')
104
- isLoading.value = false
105
- return false
106
- }
107
- return new Promise((resolve) => {
108
- setTimeout(() => {
109
- resolve(true)
110
- }, 1000)
111
- })
112
- }
113
-
114
- watch(
115
- () => props.loading,
116
- (data) => {
117
- isLoading.value = data
118
- },
119
- { immediate: true }
120
- )
121
-
122
- onBeforeMount(async () => {
123
- attrs.value = await getAttrs(props, { ...uploadAttr, ...useAttrs() })
124
- attrs.value.onSuccess = (response: any) => {
125
- if (props.desc?.on?.success) {
126
- props.desc.on.success({
127
- row: response,
128
- callBack: () => {
129
- setTimeout(() => (isLoading.value = false), 500)
130
- },
131
- field: props.field,
132
- rowIndex: props.rowIndex
133
- } as IBtnBack)
134
- }
135
- }
136
- isInit.value = true
137
- })
138
- </script>
139
- <style lang="scss" scoped>
140
- .el-plus-form-up-btn {
141
- display: flex;
142
- flex-direction: column;
143
- padding: 0;
144
- }
145
- </style>
1
+ <template>
2
+ <div class="el-button el-plus-form-up-btn">
3
+ <el-upload class="upload-demo" style="display: flex" v-bind="attrs" :disabled="isLoading || disabled" v-model="currentValue">
4
+ <el-button type="primary" :icon="Upload" :loading="isLoading"> {{ btnShowText }}</el-button>
5
+ <template #file>
6
+ <div></div>
7
+ </template>
8
+ </el-upload>
9
+ </div>
10
+ </template>
11
+ <script lang="ts">
12
+ export default {
13
+ name: 'ElPlusFormUpbtn',
14
+ inheritAttrs: false,
15
+ typeName: 'upbtn',
16
+ customOptions: {}
17
+ }
18
+ </script>
19
+ <script lang="ts" setup>
20
+ import { ref, computed, onBeforeMount, useAttrs, watch } from 'vue'
21
+ import { Upload } from '@element-plus/icons-vue'
22
+ import { ElMessage, ElMessageBox, UploadRawFile } from 'element-plus'
23
+ import { getAttrs } from '../mixins'
24
+ import { IBtnBack } from 'types'
25
+
26
+ const props = defineProps<{
27
+ field?: string
28
+ rowIndex?: number
29
+ loading?: boolean
30
+ desc: { [key: string]: any }
31
+ formData?: { [key: string]: any }
32
+ disabled?: boolean
33
+ }>()
34
+
35
+ const isLoading = ref(!!props.loading)
36
+ const currentValue = ref([] as any[])
37
+ const attrs = ref({} as any)
38
+ const isInit = ref(false)
39
+
40
+ const uploadAttr = {
41
+ name: 'file',
42
+ showFileList: false,
43
+ listType: 'text',
44
+ accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel',
45
+ beforeUpload: async (file: UploadRawFile) => {
46
+ isLoading.value = true
47
+ let confirmText = props.desc?.confirm || ''
48
+ if (confirmText && typeof props.desc?.confirm === 'function') {
49
+ confirmText = props.desc.confirm()
50
+ }
51
+ if (confirmText) {
52
+ return new Promise((resolve) => {
53
+ ElMessageBox.confirm(confirmText, '提示', {
54
+ type: 'warning'
55
+ })
56
+ .then(() => resolve(true))
57
+ .catch(() => {
58
+ resolve(false)
59
+ isLoading.value = false
60
+ })
61
+ })
62
+ } else {
63
+ return handelBeforeUpload(file)
64
+ }
65
+ },
66
+ onError: () => {
67
+ ElMessage.error('文件上传出错,请检查文件格式及内容是否正确!')
68
+ isLoading.value = false
69
+ }
70
+ }
71
+
72
+ const btnShowText = computed(() => {
73
+ if (props.desc.btnLabel) {
74
+ if (typeof props.desc.btnLabel === 'function') {
75
+ return props.desc.btnLabel(props.formData)
76
+ }
77
+ return props.desc.btnLabel
78
+ }
79
+ if (props.desc.label) {
80
+ if (typeof props.desc.label === 'function') {
81
+ return props.desc.label(props.formData)
82
+ }
83
+ return props.desc.label
84
+ }
85
+ return ''
86
+ })
87
+
88
+ /**
89
+ * 文件上传前的处理
90
+ * @param file
91
+ */
92
+ function handelBeforeUpload(file: UploadRawFile) {
93
+ isLoading.value = true
94
+ const suffix = file.name.substring(file.name.lastIndexOf('.'))
95
+ // 校验文件类型
96
+ if ((props.desc.attrs.accept || ['.xlsx', '.xls']).indexOf(suffix) < 0) {
97
+ ElMessage.warning(`请上传后缀为${(props.desc.attrs.accept || ['.xlsx', '.xls']).join(',')}格式的文件!`)
98
+ isLoading.value = false
99
+ return false
100
+ }
101
+ // 校验文件大小
102
+ if (file.size > 20 * 1024 * 1024) {
103
+ ElMessage.warning('超出文件大小限制(最大为20M)!')
104
+ isLoading.value = false
105
+ return false
106
+ }
107
+ return new Promise((resolve) => {
108
+ setTimeout(() => {
109
+ resolve(true)
110
+ }, 1000)
111
+ })
112
+ }
113
+
114
+ watch(
115
+ () => props.loading,
116
+ (data) => {
117
+ isLoading.value = data
118
+ },
119
+ { immediate: true }
120
+ )
121
+
122
+ onBeforeMount(async () => {
123
+ attrs.value = await getAttrs(props, { ...uploadAttr, ...useAttrs() })
124
+ attrs.value.onSuccess = (response: any) => {
125
+ if (props.desc?.on?.success) {
126
+ props.desc.on.success({
127
+ row: response,
128
+ callBack: () => {
129
+ setTimeout(() => (isLoading.value = false), 500)
130
+ },
131
+ field: props.field,
132
+ rowIndex: props.rowIndex
133
+ } as IBtnBack)
134
+ }
135
+ }
136
+ isInit.value = true
137
+ })
138
+ </script>
139
+ <style lang="scss" scoped>
140
+ .el-plus-form-up-btn {
141
+ display: flex;
142
+ flex-direction: column;
143
+ padding: 0;
144
+ }
145
+ </style>
146
+ types