el-plus-crud 0.0.82 → 0.0.85
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 +6 -0
- package/dist/el-plus-crud.mjs +2992 -2962
- package/lib/components/el-plus-form/ElPlusForm.vue +0 -2
- package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +150 -152
- package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +1 -1
- package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +3 -3
- package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +1 -1
- package/lib/components/el-plus-table/ElPlusTable.vue +124 -4
- package/lib/components/el-plus-table/components/header.vue +8 -2
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/types/index.d.ts +12 -0
|
@@ -194,7 +194,6 @@ const formLayout = computed(() => ({ display: 'flex', flexDirection: props.isTab
|
|
|
194
194
|
// 表单的Attrs
|
|
195
195
|
const computedFormAttrs = computed(() => {
|
|
196
196
|
return {
|
|
197
|
-
scrollToError: true,
|
|
198
197
|
...props.formAttrs,
|
|
199
198
|
labelWidth: props.labelWidth === 'auto' ? (props.isDialog ? '100px' : '120px') : parseInt(props.labelWidth + '') + 'px',
|
|
200
199
|
// validateOnRuleChange: false,
|
|
@@ -478,7 +477,6 @@ const handelValToForm = (desc: IFormDescItem, field: string, val: any) => {
|
|
|
478
477
|
result[desc.propPrefix ? desc.propPrefix + 'StreetId' : 'streetId'] = sid || -1
|
|
479
478
|
}
|
|
480
479
|
} else if (desc.type === 'daterange') {
|
|
481
|
-
console.log('val: ', val)
|
|
482
480
|
if (val && val.length === 2) {
|
|
483
481
|
const startTimeKey = desc.propPrefix ? desc.propPrefix + 'StartTime' : 'startTime'
|
|
484
482
|
const endTimeKey = desc.propPrefix ? desc.propPrefix + 'EndTime' : 'endTime'
|
|
@@ -1,152 +1,150 @@
|
|
|
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
|
|
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
|
-
if (numAttrs.
|
|
91
|
-
numAttrs.
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (currentValue.value
|
|
101
|
-
currentValue.value = numBindAttr.value.
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
</style>
|
|
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
|
+
if (!isDoChange.value) {
|
|
59
|
+
if (currentValue.value !== 0 && !currentValue.value) {
|
|
60
|
+
nextTick(() => {
|
|
61
|
+
currentValue.value = props.desc?.required ? numBindAttr.value.min : 0
|
|
62
|
+
if (currentValue.value === 0) {
|
|
63
|
+
// 查看了源码,这里需要二次赋不一样的值,这里才会真正重新渲染
|
|
64
|
+
nextTick(() => {
|
|
65
|
+
currentValue.value = null
|
|
66
|
+
change && change()
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
} else {
|
|
71
|
+
handelValChange(currentValue.value, 0)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
nextTick(() => {
|
|
75
|
+
emits('validateThis')
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 绑定属性
|
|
81
|
+
*/
|
|
82
|
+
const numBindAttr = computed(() => {
|
|
83
|
+
let numAttrs = props.desc.attrs || defaultConf.form?.leng?.nbinput
|
|
84
|
+
if (typeof props.desc.attrs === 'function') {
|
|
85
|
+
numAttrs = props.desc.attrs(props.formData)
|
|
86
|
+
}
|
|
87
|
+
// 这里判断一下,最小和最大值的大小
|
|
88
|
+
if (numAttrs.min > numAttrs.max) {
|
|
89
|
+
numAttrs.min = numAttrs.max
|
|
90
|
+
} else if (numAttrs.max < numAttrs.min) {
|
|
91
|
+
numAttrs.max = numAttrs.min
|
|
92
|
+
}
|
|
93
|
+
return numAttrs
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
// 判断一下初始值
|
|
97
|
+
if (currentValue.value !== undefined && currentValue.value !== null) {
|
|
98
|
+
if (currentValue.value < numBindAttr.value.min) {
|
|
99
|
+
currentValue.value = numBindAttr.value.min
|
|
100
|
+
} else if (currentValue.value > numBindAttr.value.max) {
|
|
101
|
+
currentValue.value = numBindAttr.value.max
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const change = onEvents.value.change
|
|
106
|
+
if (change) {
|
|
107
|
+
onEvents.value.change = (val: any, oldVal: any) => {
|
|
108
|
+
handelValChange(val, oldVal)
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
onEvents.value.change = handelValChange
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 监听值改变
|
|
116
|
+
* @param val
|
|
117
|
+
*/
|
|
118
|
+
function handelValChange(val: any, oldVal: any) {
|
|
119
|
+
isDoChange.value = true
|
|
120
|
+
if (val !== oldVal) {
|
|
121
|
+
if (val < numBindAttr.value.min) {
|
|
122
|
+
ElMessage.warning(`${props.desc?.label || ''}最少不能低于${numBindAttr.value.min}`)
|
|
123
|
+
nextTick(() => {
|
|
124
|
+
currentValue.value = numBindAttr.value.min
|
|
125
|
+
change && change()
|
|
126
|
+
})
|
|
127
|
+
} else if (val > numBindAttr.value.max) {
|
|
128
|
+
ElMessage.warning(`${props.desc?.label || ''}最多不能大于${numBindAttr.value.max}`)
|
|
129
|
+
nextTick(() => {
|
|
130
|
+
currentValue.value = numBindAttr.value.max
|
|
131
|
+
change && change()
|
|
132
|
+
})
|
|
133
|
+
} else {
|
|
134
|
+
change && change()
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
</script>
|
|
139
|
+
<style lang="scss" scoped>
|
|
140
|
+
.ElPlusFormNumber-panel {
|
|
141
|
+
width: 100% !important;
|
|
142
|
+
max-width: 100%;
|
|
143
|
+
:deep(.el-input__wrapper) {
|
|
144
|
+
// padding-left: 11px !important;
|
|
145
|
+
input {
|
|
146
|
+
text-align: left !important;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -39,7 +39,7 @@ const currentValue = ref(props.modelValue)
|
|
|
39
39
|
emits('update:modelValue', currentValue)
|
|
40
40
|
|
|
41
41
|
onBeforeMount(async () => {
|
|
42
|
-
attrs.value = await getAttrs(props, { maxlength: defaultConf.form?.leng
|
|
42
|
+
attrs.value = await getAttrs(props, { maxlength: defaultConf.form?.leng?.textare, showWordLimit: true, rows: 3, ...useAttrs() })
|
|
43
43
|
isInit.value = true
|
|
44
44
|
})
|
|
45
45
|
|
|
@@ -134,9 +134,9 @@ watch(
|
|
|
134
134
|
() => currentValue.value,
|
|
135
135
|
(val: any) => {
|
|
136
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
|
|
138
|
-
ElMessage.warning('最大长度为: ' + (defaultConf.form?.leng
|
|
139
|
-
currentValue.value = (val as Array<string>).filter((item) => typeof item !== 'string' || item.length <= (defaultConf.form?.leng
|
|
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
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -33,7 +33,7 @@ const currentValue = ref(props.modelValue)
|
|
|
33
33
|
emits('update:modelValue', currentValue)
|
|
34
34
|
|
|
35
35
|
onBeforeMount(async () => {
|
|
36
|
-
attrs.value = await getAttrs(props, { maxlength: defaultConf.form?.leng
|
|
36
|
+
attrs.value = await getAttrs(props, { maxlength: defaultConf.form?.leng?.textare, showWordLimit: true, rows: 3, ...useAttrs() })
|
|
37
37
|
isInit.value = true
|
|
38
38
|
})
|
|
39
39
|
|
|
@@ -29,7 +29,26 @@
|
|
|
29
29
|
<slot name="main" :tableData="tableData"></slot>
|
|
30
30
|
</template>
|
|
31
31
|
<!-- 这里开始是表格内容 -->
|
|
32
|
-
<el-table
|
|
32
|
+
<el-table
|
|
33
|
+
ref="elPlusTableRef"
|
|
34
|
+
v-else
|
|
35
|
+
style="width: 100%"
|
|
36
|
+
height="100%"
|
|
37
|
+
:maxHeight="tableConfig.maxHeight || 'auto'"
|
|
38
|
+
v-bind="tableConfig.tableAttr"
|
|
39
|
+
:class="{ 'big-h-bar': tableConfig?.tableAttr?.bigHBar, 'big-v-bar': tableConfig.tableAttr?.bigVBar }"
|
|
40
|
+
:data="tableData"
|
|
41
|
+
:row-key="rowKey"
|
|
42
|
+
lazy
|
|
43
|
+
:load="loadExpandData"
|
|
44
|
+
:size="size"
|
|
45
|
+
:row-class-name="initRowClassName"
|
|
46
|
+
@select="handelTableSelect"
|
|
47
|
+
@select-all="handelTableSelectAll"
|
|
48
|
+
@expand-change="handelTableExpandChange"
|
|
49
|
+
:treeProps="treeProps"
|
|
50
|
+
:span-method="handelSpanMethod"
|
|
51
|
+
>
|
|
33
52
|
<!-- 复选框 -->
|
|
34
53
|
<el-table-column v-if="type === 'selection'" type="selection" width="55px" :selectable="selectable" header-align="center" align="center" />
|
|
35
54
|
<!-- 下标 -->
|
|
@@ -77,12 +96,20 @@ import ElPlusTableColumn from './ElPlusTableColumn.vue'
|
|
|
77
96
|
import { handelListColumn } from './util'
|
|
78
97
|
import { cloneDeep } from 'lodash'
|
|
79
98
|
import { Loading } from '@element-plus/icons-vue'
|
|
99
|
+
import type { TableColumnCtx } from 'element-plus'
|
|
80
100
|
import { ICRUDConfig, ITableConfig, ITableTabItem, ITreeProps } from 'types'
|
|
81
101
|
|
|
102
|
+
interface SpanMethodProps {
|
|
103
|
+
row: any
|
|
104
|
+
column: TableColumnCtx<any>
|
|
105
|
+
rowIndex: number
|
|
106
|
+
columnIndex: number
|
|
107
|
+
}
|
|
108
|
+
|
|
82
109
|
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
83
110
|
const format = inject('format') as any
|
|
84
111
|
|
|
85
|
-
const emits = defineEmits(['getUrlConsumerIds', 'selection', 'select', 'selectAll', 'update:modelValue', 'tabChange', 'expandChange'])
|
|
112
|
+
const emits = defineEmits(['getUrlConsumerIds', 'selection', 'select', 'selectAll', 'update:modelValue', 'tabChange', 'expandChange', 'inited'])
|
|
86
113
|
const props = withDefaults(
|
|
87
114
|
defineProps<{
|
|
88
115
|
tableConfig: ITableConfig
|
|
@@ -133,6 +160,10 @@ const props = withDefaults(
|
|
|
133
160
|
}
|
|
134
161
|
)
|
|
135
162
|
|
|
163
|
+
// 合并行算法
|
|
164
|
+
const needSpanColIndex = ref([] as any[])
|
|
165
|
+
const handelSpanMethod = ref(null as unknown as Function)
|
|
166
|
+
|
|
136
167
|
const elPlusTableRef = ref()
|
|
137
168
|
|
|
138
169
|
// 顶部Tab数据
|
|
@@ -188,6 +219,50 @@ const treeProps = (props.tableConfig?.explan?.treeProps || { children: 'children
|
|
|
188
219
|
// 处理后的列显示
|
|
189
220
|
const headerColumns = computed(() => {
|
|
190
221
|
const tempList = handelListColumn(props.tableConfig?.column, defaultConf, props.tableConfig?.tbName || '', props.headerAlign, props.isDialog ? 'auto' : props.colMinWidth)
|
|
222
|
+
// 这里重构一下合并行算法
|
|
223
|
+
// 获取所有列
|
|
224
|
+
const allColumn = getColumList(tempList)
|
|
225
|
+
// 查询是否有合并行属性
|
|
226
|
+
needSpanColIndex.value = []
|
|
227
|
+
allColumn.map((item, i) => {
|
|
228
|
+
if (item.isRowSpan) {
|
|
229
|
+
needSpanColIndex.value.push(i)
|
|
230
|
+
let value = undefined as any
|
|
231
|
+
let first = 0
|
|
232
|
+
let count = 1
|
|
233
|
+
// 这里修改data数据
|
|
234
|
+
tableData.value?.map((row, j) => {
|
|
235
|
+
if (value !== row[item.prop]) {
|
|
236
|
+
if (count > 1 && j > 0) {
|
|
237
|
+
// 这里要设置之前的数据合并行数
|
|
238
|
+
tableData.value[first]['rowSpan_' + i] = count
|
|
239
|
+
}
|
|
240
|
+
first = j
|
|
241
|
+
count = 1
|
|
242
|
+
value = row[item.prop]
|
|
243
|
+
} else {
|
|
244
|
+
count += 1
|
|
245
|
+
row['rowSpan_' + i] = 0
|
|
246
|
+
}
|
|
247
|
+
if (j === tableData.value.length - 1) {
|
|
248
|
+
// 这里要设置之前的数据合并行数
|
|
249
|
+
tableData.value[first]['rowSpan_' + i] = count
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
if (needSpanColIndex.value.length > 0) {
|
|
255
|
+
handelSpanMethod.value = ({ row, column, columnIndex }: SpanMethodProps) => {
|
|
256
|
+
let tempColumnIndex = columnIndex
|
|
257
|
+
// 这里要排除默认的列
|
|
258
|
+
if (props.type === 'selection') tempColumnIndex -= 1
|
|
259
|
+
if (props.isIndex) tempColumnIndex -= 1
|
|
260
|
+
if (useSlots().firstColumn) tempColumnIndex -= 1
|
|
261
|
+
if (needSpanColIndex.value.includes(tempColumnIndex)) {
|
|
262
|
+
return { rowspan: row['rowSpan_' + tempColumnIndex], colspan: 1 }
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
191
266
|
return tempList
|
|
192
267
|
})
|
|
193
268
|
|
|
@@ -222,6 +297,49 @@ const summaryList = computed(() => {
|
|
|
222
297
|
return tempList
|
|
223
298
|
})
|
|
224
299
|
|
|
300
|
+
/**
|
|
301
|
+
* 获取所有显示的列信息
|
|
302
|
+
* @param list
|
|
303
|
+
*/
|
|
304
|
+
function getColumList(list: Array<any>): Array<any> {
|
|
305
|
+
const tempList = [] as any
|
|
306
|
+
list?.map((item) => {
|
|
307
|
+
if (item.children?.length) {
|
|
308
|
+
tempList.push(...getColumList(item.children))
|
|
309
|
+
} else {
|
|
310
|
+
if (item.__vif) {
|
|
311
|
+
tempList.push(item)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
return tempList
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* 获取合并行方法
|
|
320
|
+
* @param param0
|
|
321
|
+
*/
|
|
322
|
+
function getSpanMethod(): Function {
|
|
323
|
+
// const
|
|
324
|
+
return ({ row, column, rowIndex, columnIndex }: SpanMethodProps) => {
|
|
325
|
+
if (needSpanColIndex.value.includes(columnIndex)) {
|
|
326
|
+
}
|
|
327
|
+
if (columnIndex === 0) {
|
|
328
|
+
if (rowIndex % 2 === 0) {
|
|
329
|
+
return {
|
|
330
|
+
rowspan: 2,
|
|
331
|
+
colspan: 1
|
|
332
|
+
}
|
|
333
|
+
} else {
|
|
334
|
+
return {
|
|
335
|
+
rowspan: 0,
|
|
336
|
+
colspan: 0
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
225
343
|
/**
|
|
226
344
|
* Tab切换
|
|
227
345
|
* @param val
|
|
@@ -497,9 +615,11 @@ async function loadData(isInit: Boolean) {
|
|
|
497
615
|
dataResult = dataPage[props.tableConfig?.fetchMap?.list || 'records'] || null
|
|
498
616
|
}
|
|
499
617
|
tableData.value = dataResult
|
|
618
|
+
// 初始化完毕后,调用一次父类更新
|
|
619
|
+
emits('update:modelValue', tableData)
|
|
500
620
|
if (isInit) {
|
|
501
|
-
//
|
|
502
|
-
|
|
621
|
+
// 调用父类init
|
|
622
|
+
emits('inited', tableData)
|
|
503
623
|
}
|
|
504
624
|
// 如果是树形结构
|
|
505
625
|
if (props.type === 'expand') {
|
|
@@ -120,7 +120,13 @@ async function handelDownload({ callBack }: IBtnBack) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
if (props.toolbar.export.fetch) {
|
|
123
|
-
|
|
123
|
+
let result = (await props.toolbar.export.fetch(postData)) as string
|
|
124
|
+
if (props.toolbar.export.urlKey) {
|
|
125
|
+
let tempKeyList = (typeof props.toolbar.export.urlKey === 'string' ? [props.toolbar.export.urlKey] : props.toolbar.export.urlKey) as string[]
|
|
126
|
+
// 循环遍历
|
|
127
|
+
tempKeyList?.map((key) => (result = result[key]))
|
|
128
|
+
}
|
|
129
|
+
url = result
|
|
124
130
|
} else {
|
|
125
131
|
if (!props.toolbar.export.noQuery && method === 'get') {
|
|
126
132
|
url += (url.indexOf('?') >= 0 ? '&' : '?') + mapToUrlStr(postData)
|
|
@@ -138,7 +144,7 @@ async function handelDownload({ callBack }: IBtnBack) {
|
|
|
138
144
|
if (typeof defaultConf.token === 'function') {
|
|
139
145
|
token = defaultConf.token()
|
|
140
146
|
}
|
|
141
|
-
xhr.setRequestHeader('Authorization', '' + token)
|
|
147
|
+
xhr.setRequestHeader(props.toolbar?.export?.tokenKey || 'Authorization', '' + token)
|
|
142
148
|
}
|
|
143
149
|
xhr.onload = function () {
|
|
144
150
|
if (this.status == 200) {
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "el-plus-crud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.85",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "el-plus-crud",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.85",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@element-plus/icons-vue": "^2.1.0",
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -173,6 +173,12 @@ export interface IFormGroupConfig {
|
|
|
173
173
|
group: Array<{
|
|
174
174
|
// 小标题
|
|
175
175
|
title?: string
|
|
176
|
+
// 是否显示showBtns
|
|
177
|
+
showBtns?: boolean
|
|
178
|
+
// 最大宽度
|
|
179
|
+
maxWidth?: string
|
|
180
|
+
// label宽度
|
|
181
|
+
labelWidth?: string
|
|
176
182
|
// 表单的列数,默认是1
|
|
177
183
|
column?: number
|
|
178
184
|
// 表单描述对象
|
|
@@ -207,6 +213,8 @@ export interface IColumnItem extends IDescItem {
|
|
|
207
213
|
noHide?: boolean | ((data?: any) => boolean)
|
|
208
214
|
// 真正的vif
|
|
209
215
|
__vif?: boolean
|
|
216
|
+
// 是否合并行
|
|
217
|
+
isRowSpan?: boolean
|
|
210
218
|
}
|
|
211
219
|
|
|
212
220
|
/**
|
|
@@ -217,12 +225,16 @@ export interface IExportConfig {
|
|
|
217
225
|
url?: string
|
|
218
226
|
// 查询导出URL的fetch
|
|
219
227
|
fetch?: IFetch<string>
|
|
228
|
+
// 如何去解析数据结果获取url
|
|
229
|
+
urlKey?: string | Array<string>
|
|
220
230
|
// 请求夹带的数据
|
|
221
231
|
data?: Object
|
|
222
232
|
// 文件名
|
|
223
233
|
name?: string
|
|
224
234
|
// 是否增加token权限
|
|
225
235
|
isAuth?: Boolean
|
|
236
|
+
// token名称
|
|
237
|
+
tokenKey?: string
|
|
226
238
|
// 是否需要拼接查询条件
|
|
227
239
|
noQuery?: Boolean
|
|
228
240
|
// 导出文件的后缀
|