el-plus-crud 0.0.63 → 0.0.65
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 +1233 -1189
- package/lib/components/el-plus-form/ElPlusForm.vue +3 -1
- package/lib/components/el-plus-form/components/ElPlusFormStatus.vue +101 -101
- package/lib/components/el-plus-form/components/ElPlusFormTime.vue +53 -0
- package/lib/components/el-plus-form/util/validate.ts +15 -1
- package/lib/components-list.ts +2 -0
- package/package.json +1 -1
|
@@ -243,9 +243,11 @@ const computedRules = computed(() => {
|
|
|
243
243
|
case 'linkuser':
|
|
244
244
|
case 'radio':
|
|
245
245
|
case 'checkbox':
|
|
246
|
-
case 'daterange':
|
|
247
246
|
rules = 'select'
|
|
248
247
|
break
|
|
248
|
+
case 'daterange':
|
|
249
|
+
rules = 'cascader'
|
|
250
|
+
break
|
|
249
251
|
}
|
|
250
252
|
tempRules[field].push(...(validates as any)[rules])
|
|
251
253
|
}
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="ElPlusFormStatus-panel">
|
|
3
|
-
<i :style="iconStyle" />
|
|
4
|
-
<div :class="desc.class" :style="desc.style">
|
|
5
|
-
{{ formatValue }}
|
|
6
|
-
</div>
|
|
7
|
-
</div>
|
|
8
|
-
</template>
|
|
9
|
-
<script lang="ts">
|
|
10
|
-
export default {
|
|
11
|
-
name: 'ElPlusFormStatus',
|
|
12
|
-
inheritAttrs: false,
|
|
13
|
-
typeName: 'status',
|
|
14
|
-
customOptions: {}
|
|
15
|
-
}
|
|
16
|
-
</script>
|
|
17
|
-
<script lang="ts" setup>
|
|
18
|
-
import { isEqual } from 'lodash'
|
|
19
|
-
import { ref, reactive, watch, computed, inject } from 'vue'
|
|
20
|
-
|
|
21
|
-
const globalData = inject('globalData') as any
|
|
22
|
-
const format = inject('format') as any
|
|
23
|
-
|
|
24
|
-
const props = defineProps<{
|
|
25
|
-
modelValue?: string | number | '' | null
|
|
26
|
-
field: string
|
|
27
|
-
desc: { [key: string]: any }
|
|
28
|
-
formData: { [key: string]: any }
|
|
29
|
-
}>()
|
|
30
|
-
|
|
31
|
-
const emits = defineEmits(['update:modelValue'])
|
|
32
|
-
const currentValue = ref(props.modelValue)
|
|
33
|
-
emits('update:modelValue', currentValue)
|
|
34
|
-
|
|
35
|
-
const options = reactive([] as any[])
|
|
36
|
-
const formatValue = ref('' as any)
|
|
37
|
-
|
|
38
|
-
// icon 样式
|
|
39
|
-
const iconStyle = computed(() => {
|
|
40
|
-
if (props.desc.icolor) {
|
|
41
|
-
if (typeof props.desc.icolor === 'function') {
|
|
42
|
-
return { background: props.desc.icolor(props.formData) || '#909399' }
|
|
43
|
-
}
|
|
44
|
-
return { background: props.desc.icolor || '#909399' }
|
|
45
|
-
}
|
|
46
|
-
const optionsItem = options.find((item: any) => (item.value || item.v) == currentValue.value) || {}
|
|
47
|
-
return { background: optionsItem.c || optionsItem.color || '#909399' }
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
watch(
|
|
51
|
-
() => props.desc.options,
|
|
52
|
-
async (data) => {
|
|
53
|
-
if (typeof data === 'string') {
|
|
54
|
-
// 从全局数据中获取options
|
|
55
|
-
options.splice(0, options.length, ...(globalData[data] || []))
|
|
56
|
-
} else if (typeof data === 'function') {
|
|
57
|
-
options.splice(0, options.length, ...(await data(props.formData)))
|
|
58
|
-
} else if (Array.isArray(data)) {
|
|
59
|
-
if (data && options && !isEqual(data, options)) {
|
|
60
|
-
options.splice(0, options.length, ...data)
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
options.splice(0, options.length)
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
{ immediate: true }
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
watch(
|
|
70
|
-
() => props.modelValue,
|
|
71
|
-
async () => {
|
|
72
|
-
if (!props.desc.format) {
|
|
73
|
-
formatValue.value = props.modelValue === '' ? props.desc.default ?? '—' : props.modelValue ?? props.desc.default ?? '—'
|
|
74
|
-
} else {
|
|
75
|
-
if (typeof props.desc.format === 'function') {
|
|
76
|
-
// 如果有方法类型的判断,则需要启用动态监测
|
|
77
|
-
formatValue.value = await props.desc.format(props.modelValue, props.formData, props.field)
|
|
78
|
-
} else if (typeof props.desc.format === 'string') {
|
|
79
|
-
formatValue.value = format[props.desc.format] ? format[props.desc.format](props.modelValue, props.formData, props.field) : '--'
|
|
80
|
-
} else {
|
|
81
|
-
formatValue.value = props.modelValue || '—'
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
{ immediate: true }
|
|
86
|
-
)
|
|
87
|
-
</script>
|
|
88
|
-
<style lang="scss" scoped>
|
|
89
|
-
.ElPlusFormStatus-panel {
|
|
90
|
-
display: flex;
|
|
91
|
-
line-height: 25px;
|
|
92
|
-
align-items: center;
|
|
93
|
-
i {
|
|
94
|
-
display: inline-block;
|
|
95
|
-
min-width: 10px;
|
|
96
|
-
min-height: 10px;
|
|
97
|
-
border-radius: 50%;
|
|
98
|
-
margin-right: 5px;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ElPlusFormStatus-panel">
|
|
3
|
+
<i :style="iconStyle" />
|
|
4
|
+
<div :class="desc.class" :style="desc.style">
|
|
5
|
+
{{ formatValue }}
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
export default {
|
|
11
|
+
name: 'ElPlusFormStatus',
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
typeName: 'status',
|
|
14
|
+
customOptions: {}
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
<script lang="ts" setup>
|
|
18
|
+
import { isEqual } from 'lodash'
|
|
19
|
+
import { ref, reactive, watch, computed, inject } from 'vue'
|
|
20
|
+
|
|
21
|
+
const globalData = inject('globalData') as any
|
|
22
|
+
const format = inject('format') as any
|
|
23
|
+
|
|
24
|
+
const props = defineProps<{
|
|
25
|
+
modelValue?: string | number | '' | null
|
|
26
|
+
field: string
|
|
27
|
+
desc: { [key: string]: any }
|
|
28
|
+
formData: { [key: string]: any }
|
|
29
|
+
}>()
|
|
30
|
+
|
|
31
|
+
const emits = defineEmits(['update:modelValue'])
|
|
32
|
+
const currentValue = ref(props.modelValue)
|
|
33
|
+
emits('update:modelValue', currentValue)
|
|
34
|
+
|
|
35
|
+
const options = reactive([] as any[])
|
|
36
|
+
const formatValue = ref('' as any)
|
|
37
|
+
|
|
38
|
+
// icon 样式
|
|
39
|
+
const iconStyle = computed(() => {
|
|
40
|
+
if (props.desc.icolor) {
|
|
41
|
+
if (typeof props.desc.icolor === 'function') {
|
|
42
|
+
return { background: props.desc.icolor(props.formData) || '#909399' }
|
|
43
|
+
}
|
|
44
|
+
return { background: props.desc.icolor || '#909399' }
|
|
45
|
+
}
|
|
46
|
+
const optionsItem = options.find((item: any) => (item.value || item.v) == currentValue.value) || {}
|
|
47
|
+
return { background: optionsItem.c || optionsItem.color || '#909399' }
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
watch(
|
|
51
|
+
() => props.desc.options,
|
|
52
|
+
async (data) => {
|
|
53
|
+
if (typeof data === 'string') {
|
|
54
|
+
// 从全局数据中获取options
|
|
55
|
+
options.splice(0, options.length, ...(globalData[data] || []))
|
|
56
|
+
} else if (typeof data === 'function') {
|
|
57
|
+
options.splice(0, options.length, ...(await data(props.formData)))
|
|
58
|
+
} else if (Array.isArray(data)) {
|
|
59
|
+
if (data && options && !isEqual(data, options)) {
|
|
60
|
+
options.splice(0, options.length, ...data)
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
options.splice(0, options.length)
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{ immediate: true }
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
watch(
|
|
70
|
+
() => props.modelValue,
|
|
71
|
+
async () => {
|
|
72
|
+
if (!props.desc.format) {
|
|
73
|
+
formatValue.value = props.modelValue === '' ? props.desc.default ?? '—' : props.modelValue ?? props.desc.default ?? '—'
|
|
74
|
+
} else {
|
|
75
|
+
if (typeof props.desc.format === 'function') {
|
|
76
|
+
// 如果有方法类型的判断,则需要启用动态监测
|
|
77
|
+
formatValue.value = await props.desc.format(props.modelValue, props.formData, props.field)
|
|
78
|
+
} else if (typeof props.desc.format === 'string') {
|
|
79
|
+
formatValue.value = format[props.desc.format] ? format[props.desc.format](props.modelValue, props.formData, props.field) : '--'
|
|
80
|
+
} else {
|
|
81
|
+
formatValue.value = props.modelValue || '—'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{ immediate: true }
|
|
86
|
+
)
|
|
87
|
+
</script>
|
|
88
|
+
<style lang="scss" scoped>
|
|
89
|
+
.ElPlusFormStatus-panel {
|
|
90
|
+
display: flex;
|
|
91
|
+
line-height: 25px;
|
|
92
|
+
align-items: center;
|
|
93
|
+
i {
|
|
94
|
+
display: inline-block;
|
|
95
|
+
min-width: 10px;
|
|
96
|
+
min-height: 10px;
|
|
97
|
+
border-radius: 50%;
|
|
98
|
+
margin-right: 5px;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-time-picker v-if="isInit" class="ElPlusFormTime-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue" :disabled="disabled" />
|
|
3
|
+
</template>
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
export default {
|
|
6
|
+
name: 'ElPlusFormTime',
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
typeName: 'time',
|
|
9
|
+
customOptions: {}
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import { ref, useAttrs, watch, onBeforeMount } from 'vue'
|
|
14
|
+
import { getAttrs, getEvents } from '../mixins'
|
|
15
|
+
|
|
16
|
+
const props = defineProps<{
|
|
17
|
+
modelValue?: Array<string> | string | Date | null
|
|
18
|
+
field: string
|
|
19
|
+
desc: { [key: string]: any }
|
|
20
|
+
formData: { [key: string]: any }
|
|
21
|
+
disabled?: boolean
|
|
22
|
+
}>()
|
|
23
|
+
|
|
24
|
+
const emits = defineEmits(['update:modelValue'])
|
|
25
|
+
const currentValue = ref()
|
|
26
|
+
const attrs = ref({} as any)
|
|
27
|
+
const isInit = ref(false)
|
|
28
|
+
const onEvents = ref(getEvents(props))
|
|
29
|
+
|
|
30
|
+
emits('update:modelValue', currentValue)
|
|
31
|
+
|
|
32
|
+
onBeforeMount(async () => {
|
|
33
|
+
attrs.value = await getAttrs(props, { editable: false, ...useAttrs() })
|
|
34
|
+
isInit.value = true
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
watch(
|
|
38
|
+
() => props.modelValue,
|
|
39
|
+
(val: Array<string> | string | Date | null | undefined) => {
|
|
40
|
+
if (val) {
|
|
41
|
+
currentValue.value = Array.isArray(val) ? val.map((item) => new Date(item)) : new Date(val)
|
|
42
|
+
} else {
|
|
43
|
+
currentValue.value = attrs.value.isRange ? [] : null
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{ immediate: true }
|
|
47
|
+
)
|
|
48
|
+
</script>
|
|
49
|
+
<style lang="scss" scoped>
|
|
50
|
+
.ElPlusFormTime-panel {
|
|
51
|
+
display: flex;
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
@@ -84,7 +84,7 @@ export const select = [{ required: true, trigger: 'change', validator: validateS
|
|
|
84
84
|
* 级联选择
|
|
85
85
|
* @type {[*]}
|
|
86
86
|
*/
|
|
87
|
-
export const cascader = [{ required: true, trigger: 'change', validator:
|
|
87
|
+
export const cascader = [{ required: true, trigger: 'change', validator: validateCascader }]
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* 必须上传
|
|
@@ -171,6 +171,20 @@ function validateInputNotAllBlank(rule: any, value: any, callback?: any) {
|
|
|
171
171
|
* @param callback
|
|
172
172
|
*/
|
|
173
173
|
function validateSelect(rule: any, value: any, callback?: any) {
|
|
174
|
+
if (value === null || typeof value === 'undefined' || value === '') {
|
|
175
|
+
callback(new Error('请选择!'))
|
|
176
|
+
} else {
|
|
177
|
+
callback()
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 数组选择
|
|
183
|
+
* @param rule
|
|
184
|
+
* @param value
|
|
185
|
+
* @param callback
|
|
186
|
+
*/
|
|
187
|
+
function validateCascader(rule: any, value: any, callback?: any) {
|
|
174
188
|
if (value === null || typeof value === 'undefined' || value === '' || value.length <= 0 || value[0] == null) {
|
|
175
189
|
callback(new Error('请选择!'))
|
|
176
190
|
} else {
|
package/lib/components-list.ts
CHANGED
|
@@ -29,6 +29,7 @@ import ElPlusFormSwitch from './components/el-plus-form/components/ElPlusFormSwi
|
|
|
29
29
|
import ElPlusFormTag from './components/el-plus-form/components/ElPlusFormTag.vue'
|
|
30
30
|
import ElPlusFormText from './components/el-plus-form/components/ElPlusFormText.vue'
|
|
31
31
|
import ElPlusFormTextarea from './components/el-plus-form/components/ElPlusFormTextarea.vue'
|
|
32
|
+
import ElPlusFormTime from './components/el-plus-form/components/ElPlusFormTime.vue'
|
|
32
33
|
import ElPlusFormTransfer from './components/el-plus-form/components/ElPlusFormTransfer.vue'
|
|
33
34
|
import ElPlusFormTree from './components/el-plus-form/components/ElPlusFormTree.vue'
|
|
34
35
|
import ElPlusFormTreeSelect from './components/el-plus-form/components/ElPlusFormTreeSelect.vue'
|
|
@@ -67,6 +68,7 @@ export default [
|
|
|
67
68
|
ElPlusFormTag,
|
|
68
69
|
ElPlusFormText,
|
|
69
70
|
ElPlusFormTextarea,
|
|
71
|
+
ElPlusFormTime,
|
|
70
72
|
ElPlusFormTransfer,
|
|
71
73
|
ElPlusFormTree,
|
|
72
74
|
ElPlusFormTreeSelect,
|