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,163 +1,164 @@
1
- <template>
2
- <el-select v-if="isInit" class="el-plus-form-select" :class="desc.class" :style="desc.style" v-bind="attrs" v-model="currentValue" :loading="loading" v-on="onEvents" :disabled="disabled">
3
- <el-option v-for="option in options" :key="option.value || option.v" v-bind="option">
4
- <div class="el-plus-form-select-options">
5
- <span>{{ option.label || option.l }}</span>
6
- <div v-if="desc.optionTip">{{ tip(option) }}</div>
7
- </div>
8
- </el-option>
9
- </el-select>
10
- </template>
11
- <script lang="ts">
12
- export default {
13
- name: 'ElPlusFormSelect',
14
- inheritAttrs: false,
15
- typeName: 'select',
16
- customOptions: {}
17
- }
18
- </script>
19
- <script lang="ts" setup>
20
- import { ref, reactive, computed, onBeforeMount, useAttrs, watch, inject } from 'vue'
21
- import { ElMessage } from 'element-plus'
22
- import { getAttrs } from '../mixins'
23
- import { isEqual } from 'lodash'
24
- import { ICRUDConfig } from 'types/formList'
25
-
26
- const defaultConf = inject('defaultConf') as ICRUDConfig
27
- const globalData = inject('globalData') as any
28
-
29
- const props = defineProps<{
30
- modelValue?: number | string | Array<string>
31
- field: string
32
- loading?: boolean
33
- desc: { [key: string]: any }
34
- formData: { [key: string]: any }
35
- rowIndex?: number
36
- disabled?: boolean
37
- }>()
38
- const emits = defineEmits(['update:modelValue'])
39
-
40
- const currentValue = ref(props.modelValue || (props.desc.multiple ? [] : ''))
41
- emits('update:modelValue', currentValue)
42
-
43
- const attrs = ref({} as any)
44
- const options = reactive([] as any[])
45
- const oldQuery = ref(null) as any
46
- const tempAttr = { clearable: true, ...useAttrs() } as any
47
- const isInit = ref(false)
48
-
49
- if (props.desc.allowCreate) {
50
- tempAttr.filterable = true
51
- }
52
-
53
- // 如果是远程加载
54
- if (props.desc.remote) {
55
- tempAttr.remote = true
56
- tempAttr.filterable = true
57
- tempAttr.remoteShowSuffix = true
58
- tempAttr.loadingText = '远程查询中...'
59
- tempAttr.remoteMethod = async (query: string) => {
60
- if (query !== undefined && query !== null) {
61
- if (oldQuery.value !== query) {
62
- oldQuery.value = query
63
- options.splice(0, options.length, ...(await props.desc.remote(query)))
64
- if (query === '') {
65
- // 判断是否有默认选项
66
- if (props.desc.defaultItem) {
67
- // 这里需要判断下默认值是否已经出现在了options中,如果存在,则需要删除
68
- const index = options.findIndex((item) => item.value === props.desc.defaultItem.value)
69
- if (index >= 0) {
70
- options.splice(index, 1)
71
- }
72
- options.unshift(props.desc.defaultItem)
73
- }
74
- }
75
- }
76
- }
77
- }
78
- }
79
-
80
- /**
81
- * 这里单独处理下事件
82
- */
83
- const onEvents = computed(() => {
84
- const tempOn = {} as any
85
- if (props.desc?.on) {
86
- Object.keys(props.desc.on).map((key: string) => {
87
- tempOn[key] = () => {
88
- props.desc.on[key](
89
- props.formData,
90
- options.find((item) => item.value === currentValue.value),
91
- props.rowIndex
92
- )
93
- }
94
- })
95
- }
96
- return tempOn
97
- })
98
-
99
- // 如果options为空,则默认执行一次查询
100
- if (options.length <= 0 && props.desc.remote && (props.desc.initLoad ?? true)) {
101
- tempAttr.remoteMethod('')
102
- }
103
-
104
- // 这里处理下tip
105
- const tip = computed(() => (optionItem: any) => {
106
- return props.desc.optionTip(optionItem)
107
- })
108
-
109
- onBeforeMount(async () => {
110
- attrs.value = await getAttrs(props, tempAttr)
111
- isInit.value = true
112
- })
113
-
114
- watch(
115
- () => props.desc.options,
116
- async (data) => {
117
- if (typeof data === 'string') {
118
- // 从全局数据中获取options
119
- options.splice(0, options.length, ...(globalData[data] || []))
120
- } else if (typeof data === 'function') {
121
- options.splice(0, options.length, ...(await data(props.formData)))
122
- } else if (Array.isArray(data)) {
123
- if (data && options && !isEqual(data, options)) {
124
- options.splice(0, options.length, ...data)
125
- }
126
- } else {
127
- options.splice(0, options.length)
128
- }
129
- },
130
- { immediate: true }
131
- )
132
-
133
- watch(
134
- () => currentValue.value,
135
- (val: any) => {
136
- if (attrs.value.allowCreate) {
137
- if (val && Array.isArray(val) && (val as Array<any>).some((item) => typeof item === 'string' && item.length > (defaultConf.form?.leng.input || 20))) {
138
- ElMessage.warning('最大长度为: ' + (defaultConf.form?.leng.input || 20))
139
- currentValue.value = (val as Array<string>).filter((item) => typeof item !== 'string' || item.length <= (defaultConf.form?.leng.input || 20))
140
- }
141
- }
142
- }
143
- )
144
- </script>
145
- <style lang="scss">
146
- .el-plus-form-select-options {
147
- width: 100%;
148
- display: flex;
149
- justify-content: space-between;
150
- align-items: center;
151
- & > div {
152
- // text-align: right;
153
- color: #aaaaaa;
154
- max-width: 40%;
155
- font-size: 12px;
156
- word-break: break-all;
157
- }
158
- }
159
- .el-select-dropdown__item {
160
- height: auto;
161
- white-space: break-spaces;
162
- }
163
- </style>
1
+ <template>
2
+ <el-select v-if="isInit" class="el-plus-form-select" :class="desc.class" :style="desc.style" v-bind="attrs" v-model="currentValue" :loading="loading" v-on="onEvents" :disabled="disabled">
3
+ <el-option v-for="option in options" :key="option.value || option.v" v-bind="option">
4
+ <div class="el-plus-form-select-options">
5
+ <span>{{ option.label || option.l }}</span>
6
+ <div v-if="desc.optionTip">{{ tip(option) }}</div>
7
+ </div>
8
+ </el-option>
9
+ </el-select>
10
+ </template>
11
+ <script lang="ts">
12
+ export default {
13
+ name: 'ElPlusFormSelect',
14
+ inheritAttrs: false,
15
+ typeName: 'select',
16
+ customOptions: {}
17
+ }
18
+ </script>
19
+ <script lang="ts" setup>
20
+ import { ref, reactive, computed, onBeforeMount, useAttrs, watch, inject } from 'vue'
21
+ import { ElMessage } from 'element-plus'
22
+ import { getAttrs } from '../mixins'
23
+ import { isEqual } from 'lodash'
24
+ import { ICRUDConfig } from 'types'
25
+
26
+ const defaultConf = inject('defaultConf') as ICRUDConfig
27
+ const globalData = inject('globalData') as any
28
+
29
+ const props = defineProps<{
30
+ modelValue?: number | string | Array<string>
31
+ field: string
32
+ loading?: boolean
33
+ desc: { [key: string]: any }
34
+ formData: { [key: string]: any }
35
+ rowIndex?: number
36
+ disabled?: boolean
37
+ }>()
38
+ const emits = defineEmits(['update:modelValue'])
39
+
40
+ const currentValue = ref(props.modelValue || (props.desc.multiple ? [] : ''))
41
+ emits('update:modelValue', currentValue)
42
+
43
+ const attrs = ref({} as any)
44
+ const options = reactive([] as any[])
45
+ const oldQuery = ref(null) as any
46
+ const tempAttr = { clearable: true, ...useAttrs() } as any
47
+ const isInit = ref(false)
48
+
49
+ if (props.desc.allowCreate) {
50
+ tempAttr.filterable = true
51
+ }
52
+
53
+ // 如果是远程加载
54
+ if (props.desc.remote) {
55
+ tempAttr.remote = true
56
+ tempAttr.filterable = true
57
+ tempAttr.remoteShowSuffix = true
58
+ tempAttr.loadingText = '远程查询中...'
59
+ tempAttr.remoteMethod = async (query: string) => {
60
+ if (query !== undefined && query !== null) {
61
+ if (oldQuery.value !== query) {
62
+ oldQuery.value = query
63
+ options.splice(0, options.length, ...(await props.desc.remote(query)))
64
+ if (query === '') {
65
+ // 判断是否有默认选项
66
+ if (props.desc.defaultItem) {
67
+ // 这里需要判断下默认值是否已经出现在了options中,如果存在,则需要删除
68
+ const index = options.findIndex((item) => item.value === props.desc.defaultItem.value)
69
+ if (index >= 0) {
70
+ options.splice(index, 1)
71
+ }
72
+ options.unshift(props.desc.defaultItem)
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+
80
+ /**
81
+ * 这里单独处理下事件
82
+ */
83
+ const onEvents = computed(() => {
84
+ const tempOn = {} as any
85
+ if (props.desc?.on) {
86
+ Object.keys(props.desc.on).map((key: string) => {
87
+ tempOn[key] = () => {
88
+ props.desc.on[key](
89
+ props.formData,
90
+ options.find((item) => item.value === currentValue.value),
91
+ props.rowIndex
92
+ )
93
+ }
94
+ })
95
+ }
96
+ return tempOn
97
+ })
98
+
99
+ // 如果options为空,则默认执行一次查询
100
+ if (options.length <= 0 && props.desc.remote && (props.desc.initLoad ?? true)) {
101
+ tempAttr.remoteMethod('')
102
+ }
103
+
104
+ // 这里处理下tip
105
+ const tip = computed(() => (optionItem: any) => {
106
+ return props.desc.optionTip(optionItem)
107
+ })
108
+
109
+ onBeforeMount(async () => {
110
+ attrs.value = await getAttrs(props, tempAttr)
111
+ isInit.value = true
112
+ })
113
+
114
+ watch(
115
+ () => props.desc.options,
116
+ async (data) => {
117
+ if (typeof data === 'string') {
118
+ // 从全局数据中获取options
119
+ options.splice(0, options.length, ...(globalData[data] || []))
120
+ } else if (typeof data === 'function') {
121
+ options.splice(0, options.length, ...(await data(props.formData)))
122
+ } else if (Array.isArray(data)) {
123
+ if (data && options && !isEqual(data, options)) {
124
+ options.splice(0, options.length, ...data)
125
+ }
126
+ } else {
127
+ options.splice(0, options.length)
128
+ }
129
+ },
130
+ { immediate: true }
131
+ )
132
+
133
+ watch(
134
+ () => currentValue.value,
135
+ (val: any) => {
136
+ if (attrs.value.allowCreate) {
137
+ if (val && Array.isArray(val) && (val as Array<any>).some((item) => typeof item === 'string' && item.length > (defaultConf.form?.leng.input || 20))) {
138
+ ElMessage.warning('最大长度为: ' + (defaultConf.form?.leng.input || 20))
139
+ currentValue.value = (val as Array<string>).filter((item) => typeof item !== 'string' || item.length <= (defaultConf.form?.leng.input || 20))
140
+ }
141
+ }
142
+ }
143
+ )
144
+ </script>
145
+ <style lang="scss">
146
+ .el-plus-form-select-options {
147
+ width: 100%;
148
+ display: flex;
149
+ justify-content: space-between;
150
+ align-items: center;
151
+ & > div {
152
+ // text-align: right;
153
+ color: #aaaaaa;
154
+ max-width: 40%;
155
+ font-size: 12px;
156
+ word-break: break-all;
157
+ }
158
+ }
159
+ .el-select-dropdown__item {
160
+ height: auto;
161
+ white-space: break-spaces;
162
+ }
163
+ </style>
164
+ types
@@ -1,51 +1,52 @@
1
- <template>
2
- <el-input v-if="isInit" :class="desc.class" :style="desc.style" type="textarea" v-bind="attrs" v-model="currentValue" v-on="onEvents" :disabled="disabled"> </el-input>
3
- </template>
4
- <script lang="ts">
5
- export default {
6
- name: 'ElPlusFormTextarea',
7
- inheritAttrs: false,
8
- typeName: 'textarea',
9
- customOptions: {}
10
- }
11
- </script>
12
- <script lang="ts" setup>
13
- import { ref, useAttrs, watch, onBeforeMount, inject } from 'vue'
14
- import { getAttrs, getEvents } from '../mixins'
15
- import { ICRUDConfig } from 'types/formList'
16
-
17
- const defaultConf = inject('defaultConf') as ICRUDConfig
18
-
19
- const props = defineProps<{
20
- modelValue?: string | null
21
- field: string
22
- loading?: boolean
23
- desc: { [key: string]: any }
24
- formData: { [key: string]: any }
25
- disabled?: boolean
26
- }>()
27
- const emits = defineEmits(['update:modelValue', 'validateThis'])
28
- const attrs = ref({} as any)
29
- const isInit = ref(false)
30
- const onEvents = ref(getEvents(props))
31
-
32
- const currentValue = ref(props.modelValue)
33
- emits('update:modelValue', currentValue)
34
-
35
- onBeforeMount(async () => {
36
- attrs.value = await getAttrs(props, { maxlength: defaultConf.form?.leng.textare, showWordLimit: true, rows: 3, ...useAttrs() })
37
- isInit.value = true
38
- })
39
-
40
- watch(
41
- () => props.modelValue,
42
- (data: string | null | undefined) => {
43
- // 这里要截取一下字符串长度
44
- if (data && data.length > attrs.value.maxlength) {
45
- data = data.substring(0, attrs.value.maxlength)
46
- }
47
- currentValue.value = data
48
- },
49
- { immediate: true }
50
- )
51
- </script>
1
+ <template>
2
+ <el-input v-if="isInit" :class="desc.class" :style="desc.style" type="textarea" v-bind="attrs" v-model="currentValue" v-on="onEvents" :disabled="disabled"> </el-input>
3
+ </template>
4
+ <script lang="ts">
5
+ export default {
6
+ name: 'ElPlusFormTextarea',
7
+ inheritAttrs: false,
8
+ typeName: 'textarea',
9
+ customOptions: {}
10
+ }
11
+ </script>
12
+ <script lang="ts" setup>
13
+ import { ref, useAttrs, watch, onBeforeMount, inject } from 'vue'
14
+ import { getAttrs, getEvents } from '../mixins'
15
+ import { ICRUDConfig } from 'types'
16
+
17
+ const defaultConf = inject('defaultConf') as ICRUDConfig
18
+
19
+ const props = defineProps<{
20
+ modelValue?: string | null
21
+ field: string
22
+ loading?: boolean
23
+ desc: { [key: string]: any }
24
+ formData: { [key: string]: any }
25
+ disabled?: boolean
26
+ }>()
27
+ const emits = defineEmits(['update:modelValue', 'validateThis'])
28
+ const attrs = ref({} as any)
29
+ const isInit = ref(false)
30
+ const onEvents = ref(getEvents(props))
31
+
32
+ const currentValue = ref(props.modelValue)
33
+ emits('update:modelValue', currentValue)
34
+
35
+ onBeforeMount(async () => {
36
+ attrs.value = await getAttrs(props, { maxlength: defaultConf.form?.leng.textare, showWordLimit: true, rows: 3, ...useAttrs() })
37
+ isInit.value = true
38
+ })
39
+
40
+ watch(
41
+ () => props.modelValue,
42
+ (data: string | null | undefined) => {
43
+ // 这里要截取一下字符串长度
44
+ if (data && data.length > attrs.value.maxlength) {
45
+ data = data.substring(0, attrs.value.maxlength)
46
+ }
47
+ currentValue.value = data
48
+ },
49
+ { immediate: true }
50
+ )
51
+ </script>
52
+ types