el-plus-crud 0.0.64 → 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.
|
@@ -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,41 +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, onBeforeMount } from 'vue'
|
|
14
|
-
import { getAttrs, getEvents } from '../mixins'
|
|
15
|
-
|
|
16
|
-
const props = defineProps<{
|
|
17
|
-
modelValue?: Array<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, { ...useAttrs() })
|
|
34
|
-
isInit.value = true
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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 {
|