el-plus-crud 0.0.78 → 0.0.80
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 +3830 -3864
- package/lib/components/el-plus-form/ElPlusForm.vue +2 -2
- package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +152 -149
- package/lib/components/el-plus-table/ElPlusTable.vue +744 -807
- package/lib/components/el-plus-table/ElPlusTableColumn.vue +47 -0
- package/lib/components/el-plus-table/components/columnItem.vue +5 -3
- package/lib/components/el-plus-table/components/settingColumn.vue +172 -180
- package/lib/components/el-plus-table/util/index.ts +194 -148
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/types/index.d.ts +468 -466
|
@@ -45,7 +45,7 @@ import * as validates from './util/validate'
|
|
|
45
45
|
import { typeList } from './components/index'
|
|
46
46
|
import ElPlusFormBtn from './components/ElPlusFormBtn.vue'
|
|
47
47
|
import { cloneDeep } from 'lodash'
|
|
48
|
-
import { ICRUDConfig, IFormBack, IFormDescItem } from 'types'
|
|
48
|
+
import { ICRUDConfig, IFormBack, IFormDesc, IFormDescItem } from 'types'
|
|
49
49
|
|
|
50
50
|
// IFormProps定义
|
|
51
51
|
export interface IFormProps {
|
|
@@ -227,7 +227,7 @@ const computedRules = computed(() => {
|
|
|
227
227
|
tempRules[field].push(item)
|
|
228
228
|
})
|
|
229
229
|
}
|
|
230
|
-
} else if (props.formDesc[field].required
|
|
230
|
+
} else if (props.formDesc[field].required) {
|
|
231
231
|
// 如果直接指定 required || require,手动添加校验信息
|
|
232
232
|
//
|
|
233
233
|
let rules = 'notAllBlank'
|
|
@@ -1,149 +1,152 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-input-number v-if="isInit" class="ElPlusFormNumber-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue" :disabled="disabled" @focus="handelFocus" @blur="handelBlur" onkeypress="return( /[\d\.]/.test(String.fromCharCode(event.keyCode)))" />
|
|
3
|
-
</template>
|
|
4
|
-
<script lang="ts">
|
|
5
|
-
export default {
|
|
6
|
-
name: 'ElPlusFormNumber',
|
|
7
|
-
inheritAttrs: false,
|
|
8
|
-
typeName: 'number',
|
|
9
|
-
customOptions: {}
|
|
10
|
-
}
|
|
11
|
-
</script>
|
|
12
|
-
<script lang="ts" setup>
|
|
13
|
-
import { ref, computed, useAttrs, onBeforeMount, nextTick, inject } from 'vue'
|
|
14
|
-
import { getAttrs, getEvents } from '../mixins'
|
|
15
|
-
import { ElMessage } from 'element-plus'
|
|
16
|
-
import { ICRUDConfig } from 'types'
|
|
17
|
-
|
|
18
|
-
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
19
|
-
|
|
20
|
-
const props = defineProps<{
|
|
21
|
-
modelValue?: number | null
|
|
22
|
-
field: string
|
|
23
|
-
loading?: boolean
|
|
24
|
-
desc: { [key: string]: any }
|
|
25
|
-
formData: { [key: string]: any }
|
|
26
|
-
rowIndex?: number
|
|
27
|
-
disabled?: boolean
|
|
28
|
-
}>()
|
|
29
|
-
|
|
30
|
-
const emits = defineEmits(['update:modelValue', 'validateThis'])
|
|
31
|
-
const currentValue = ref(props.modelValue)
|
|
32
|
-
emits('update:modelValue', currentValue)
|
|
33
|
-
const attrs = ref({} as any)
|
|
34
|
-
const isInit = ref(false)
|
|
35
|
-
const onEvents = ref(getEvents(props))
|
|
36
|
-
|
|
37
|
-
const isDoChange = ref(false)
|
|
38
|
-
|
|
39
|
-
onBeforeMount(async () => {
|
|
40
|
-
attrs.value = await getAttrs(props, { ...defaultConf.form?.leng.nbinput, ...useAttrs() })
|
|
41
|
-
delete attrs.value.min
|
|
42
|
-
delete attrs.value.max
|
|
43
|
-
isInit.value = true
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 获取焦点
|
|
48
|
-
*/
|
|
49
|
-
function handelFocus() {
|
|
50
|
-
isDoChange.value = false
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* 处理失去焦点
|
|
55
|
-
* @param event
|
|
56
|
-
*/
|
|
57
|
-
function handelBlur() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<el-input-number v-if="isInit" class="ElPlusFormNumber-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue" :disabled="disabled" @focus="handelFocus" @blur="handelBlur" onkeypress="return( /[\d\.]/.test(String.fromCharCode(event.keyCode)))" />
|
|
3
|
+
</template>
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
export default {
|
|
6
|
+
name: 'ElPlusFormNumber',
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
typeName: 'number',
|
|
9
|
+
customOptions: {}
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import { ref, computed, useAttrs, onBeforeMount, nextTick, inject } from 'vue'
|
|
14
|
+
import { getAttrs, getEvents } from '../mixins'
|
|
15
|
+
import { ElMessage } from 'element-plus'
|
|
16
|
+
import { ICRUDConfig } from 'types'
|
|
17
|
+
|
|
18
|
+
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
19
|
+
|
|
20
|
+
const props = defineProps<{
|
|
21
|
+
modelValue?: number | null
|
|
22
|
+
field: string
|
|
23
|
+
loading?: boolean
|
|
24
|
+
desc: { [key: string]: any }
|
|
25
|
+
formData: { [key: string]: any }
|
|
26
|
+
rowIndex?: number
|
|
27
|
+
disabled?: boolean
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
const emits = defineEmits(['update:modelValue', 'validateThis'])
|
|
31
|
+
const currentValue = ref(props.modelValue)
|
|
32
|
+
emits('update:modelValue', currentValue)
|
|
33
|
+
const attrs = ref({} as any)
|
|
34
|
+
const isInit = ref(false)
|
|
35
|
+
const onEvents = ref(getEvents(props))
|
|
36
|
+
|
|
37
|
+
const isDoChange = ref(false)
|
|
38
|
+
|
|
39
|
+
onBeforeMount(async () => {
|
|
40
|
+
attrs.value = await getAttrs(props, { ...defaultConf.form?.leng.nbinput, ...useAttrs() })
|
|
41
|
+
delete attrs.value.min
|
|
42
|
+
delete attrs.value.max
|
|
43
|
+
isInit.value = true
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 获取焦点
|
|
48
|
+
*/
|
|
49
|
+
function handelFocus() {
|
|
50
|
+
isDoChange.value = false
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 处理失去焦点
|
|
55
|
+
* @param event
|
|
56
|
+
*/
|
|
57
|
+
function handelBlur() {
|
|
58
|
+
console.log('currentValue', currentValue.value)
|
|
59
|
+
|
|
60
|
+
if (!isDoChange.value) {
|
|
61
|
+
if (currentValue.value !== 0 && !currentValue.value) {
|
|
62
|
+
nextTick(() => {
|
|
63
|
+
currentValue.value = props.desc?.required ? numBindAttr.value.min : 0
|
|
64
|
+
if (currentValue.value === 0) {
|
|
65
|
+
// 查看了源码,这里需要二次赋不一样的值,这里才会真正重新渲染
|
|
66
|
+
nextTick(() => {
|
|
67
|
+
currentValue.value = null
|
|
68
|
+
change && change()
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
} else {
|
|
73
|
+
handelValChange(currentValue.value, 0)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
nextTick(() => {
|
|
77
|
+
emits('validateThis')
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 绑定属性
|
|
83
|
+
*/
|
|
84
|
+
const numBindAttr = computed(() => {
|
|
85
|
+
let numAttrs = props.desc.attrs || defaultConf.form?.leng.nbinput
|
|
86
|
+
if (typeof props.desc.attrs === 'function') {
|
|
87
|
+
numAttrs = props.desc.attrs(props.formData)
|
|
88
|
+
}
|
|
89
|
+
// 这里判断一下,最小和最大值的大小
|
|
90
|
+
if (numAttrs.min > numAttrs.max) {
|
|
91
|
+
numAttrs.min = numAttrs.max
|
|
92
|
+
} else if (numAttrs.max < numAttrs.min) {
|
|
93
|
+
numAttrs.max = numAttrs.min
|
|
94
|
+
}
|
|
95
|
+
return numAttrs
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
// 判断一下初始值
|
|
99
|
+
if (currentValue.value !== undefined && currentValue.value !== null) {
|
|
100
|
+
if (currentValue.value < numBindAttr.value.min) {
|
|
101
|
+
currentValue.value = numBindAttr.value.min
|
|
102
|
+
} else if (currentValue.value > numBindAttr.value.max) {
|
|
103
|
+
currentValue.value = numBindAttr.value.max
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const change = onEvents.value.change
|
|
108
|
+
if (change) {
|
|
109
|
+
onEvents.value.change = (val: any, oldVal: any) => {
|
|
110
|
+
handelValChange(val, oldVal)
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
onEvents.value.change = handelValChange
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 监听值改变
|
|
118
|
+
* @param val
|
|
119
|
+
*/
|
|
120
|
+
function handelValChange(val: any, oldVal: any) {
|
|
121
|
+
isDoChange.value = true
|
|
122
|
+
if (val !== oldVal) {
|
|
123
|
+
if (val < numBindAttr.value.min) {
|
|
124
|
+
ElMessage.warning(`${props.desc?.label || ''}最少不能低于${numBindAttr.value.min}`)
|
|
125
|
+
nextTick(() => {
|
|
126
|
+
currentValue.value = numBindAttr.value.min
|
|
127
|
+
change && change()
|
|
128
|
+
})
|
|
129
|
+
} else if (val > numBindAttr.value.max) {
|
|
130
|
+
ElMessage.warning(`${props.desc?.label || ''}最多不能大于${numBindAttr.value.max}`)
|
|
131
|
+
nextTick(() => {
|
|
132
|
+
currentValue.value = numBindAttr.value.max
|
|
133
|
+
change && change()
|
|
134
|
+
})
|
|
135
|
+
} else {
|
|
136
|
+
change && change()
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
</script>
|
|
141
|
+
<style lang="scss" scoped>
|
|
142
|
+
.ElPlusFormNumber-panel {
|
|
143
|
+
width: 100% !important;
|
|
144
|
+
max-width: 100%;
|
|
145
|
+
:deep(.el-input__wrapper) {
|
|
146
|
+
// padding-left: 11px !important;
|
|
147
|
+
input {
|
|
148
|
+
text-align: left !important;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
</style>
|