el-plus-crud 0.1.39 → 0.1.41
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 +3448 -6433
- package/lib/components/el-plus-form/ElPlusForm.vue +12 -8
- package/lib/components/el-plus-form/ElPlusFormGroup.vue +4 -3
- package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +2 -2
- package/lib/components/el-plus-form/components/ElPlusFormLink.vue +6 -5
- package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +2 -2
- package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +2 -2
- package/lib/components/el-plus-form/components/ElPlusFormTree.vue +2 -3
- package/lib/components/el-plus-table/ElPlusTable.vue +13 -13
- package/lib/components/el-plus-table/ElPlusTableColumn.vue +4 -3
- package/lib/index.ts +4 -0
- package/lib/util/index.ts +2 -3
- package/package.json +2 -2
- package/types/index.d.ts +12 -7
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<el-row :gutter="10" v-for="(formList, index) in attrMapToTableList" :key="index" :style="{ marginRight: isTable ? '20px' : 0 }">
|
|
7
7
|
<el-col v-for="(formItem, y) in formList" :key="index + '-' + y + '-' + formItem.field" :xs="24" :sm="24" :md="formItem.colspan && formItem.colspan >= column ? 24 : column >= 2 ? 12 : 24" :lg="formItem.colspan && formItem.colspan >= column ? 24 : Math.floor((24 / column) * (formItem.colspan || 1))" :xl="formItem.colspan && formItem.colspan >= column ? 24 : Math.floor((24 / column) * (formItem.colspan || 1))">
|
|
8
8
|
<div v-if="formItem._vif" class="el-plus-form-column-panel" :style="{ 'justify-content': isTable ? 'flex-end' : 'flex-start' }">
|
|
9
|
-
<el-form-item style="min-height: 40px; display: flex" :prop="formItem.field" :style="{ width: formItem._attrs?.width || formItem.width || (isTable ? '150px' : '100%') }">
|
|
9
|
+
<el-form-item style="min-height: 40px; display: flex" :prop="formItem.field" :style="{ width: formItem._attrs?.width || formItem.width || (isTable ? '150px' : '100%'), marginBottom: itemMB }">
|
|
10
10
|
<template #label>
|
|
11
11
|
<div v-if="showLabel && formItem.showLabel !== false" class="crud-form-label" :style="{ width: formItem.labelWidth || computedFormAttrs._labelWidth || (isDialog ? '100px' : '120px') }">
|
|
12
12
|
<span :class="{ required: formItem.required }">
|
|
@@ -47,7 +47,6 @@ export default {
|
|
|
47
47
|
<script lang="ts" setup>
|
|
48
48
|
import { ref, computed, useAttrs, nextTick, onMounted, watch, inject, Ref, useSlots } from 'vue'
|
|
49
49
|
import { castArray, isMobile, time, isPromiseLike } from '../../util'
|
|
50
|
-
import { cloneDeep, debounce } from 'lodash'
|
|
51
50
|
import * as validates from './util/validate'
|
|
52
51
|
import { typeList } from './components/index'
|
|
53
52
|
import ElPlusFormBtn from './components/ElPlusFormBtn.vue'
|
|
@@ -110,10 +109,13 @@ export interface IFormProps {
|
|
|
110
109
|
isGroupForm?: boolean
|
|
111
110
|
// 是否禁用最后一个元素的tab
|
|
112
111
|
disabledTab?: boolean
|
|
112
|
+
// item的底部边距
|
|
113
|
+
itemMB?: string
|
|
113
114
|
// 比如 beforeValidate, beforeRequest, success, requestError, requestEnd
|
|
114
115
|
// 其他钩子 直接放到attrs里面去了
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
const lodash = inject('lodash') as any
|
|
117
119
|
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
118
120
|
|
|
119
121
|
const emits = defineEmits(['request', 'reset', 'cancel'])
|
|
@@ -168,7 +170,9 @@ const props = withDefaults(defineProps<IFormProps>(), {
|
|
|
168
170
|
// 唯一标识符。默认为id
|
|
169
171
|
idKey: 'id',
|
|
170
172
|
// 是否禁用最后一个元素的tab
|
|
171
|
-
disabledTab: false
|
|
173
|
+
disabledTab: false,
|
|
174
|
+
// item的底部边距
|
|
175
|
+
itemMB: '18px'
|
|
172
176
|
// 其他钩子 直接放到attrs里面去了
|
|
173
177
|
// 比如 beforeValidate, beforeRequest, success, requestError, requestEnd
|
|
174
178
|
})
|
|
@@ -226,7 +230,7 @@ const computedRules = computed(() => {
|
|
|
226
230
|
required = (props.formDesc && props.formDesc[field].required) || false
|
|
227
231
|
}
|
|
228
232
|
if (typeof required === 'function') {
|
|
229
|
-
required = required(cloneDeep(props.modelValue))
|
|
233
|
+
required = required(lodash.cloneDeep(props.modelValue))
|
|
230
234
|
}
|
|
231
235
|
if (props.formDesc) {
|
|
232
236
|
if (props.formDesc[field].rules) {
|
|
@@ -286,7 +290,7 @@ const attrMapToTableList = computed(() => {
|
|
|
286
290
|
const formLayoutRows = [] as Array<Array<IFormDescItem>>
|
|
287
291
|
if (props.formDesc) {
|
|
288
292
|
initFormAttrs()
|
|
289
|
-
const tempFormDesc = cloneDeep(props.formDesc)
|
|
293
|
+
const tempFormDesc = lodash.cloneDeep(props.formDesc)
|
|
290
294
|
let tempData = [] as Array<IFormDescItem>
|
|
291
295
|
for (const key in tempFormDesc) {
|
|
292
296
|
tempData.push({ ...tempFormDesc[key], field: key })
|
|
@@ -342,7 +346,7 @@ const attrMapToTableList = computed(() => {
|
|
|
342
346
|
})
|
|
343
347
|
|
|
344
348
|
// 整体初始化属性
|
|
345
|
-
const initFormAttrs = debounce(
|
|
349
|
+
const initFormAttrs = lodash.debounce(
|
|
346
350
|
() => {
|
|
347
351
|
if (props.formDesc) {
|
|
348
352
|
Object.keys(props.formDesc).forEach((field) => {
|
|
@@ -447,6 +451,7 @@ const btnList = computed(() => {
|
|
|
447
451
|
label: props.submitBtnText || '提交',
|
|
448
452
|
size: size.value,
|
|
449
453
|
type: 'primary',
|
|
454
|
+
disabled: props.disabled,
|
|
450
455
|
loading: props.isLoading || innerIsLoading.value,
|
|
451
456
|
on: { click: handleSubmitForm }
|
|
452
457
|
}
|
|
@@ -833,7 +838,7 @@ watch(
|
|
|
833
838
|
// 检查联动
|
|
834
839
|
// if (JSON.stringify(data) !== JSON.stringify(oldFormData)) {
|
|
835
840
|
if (!oldFormData) {
|
|
836
|
-
oldFormData = cloneDeep(data)
|
|
841
|
+
oldFormData = lodash.cloneDeep(data)
|
|
837
842
|
}
|
|
838
843
|
initFormAttrs()
|
|
839
844
|
// }
|
|
@@ -885,7 +890,6 @@ defineExpose({ fid: props.fid, formRef: refElPlusForm, submit: handleSubmitForm,
|
|
|
885
890
|
}
|
|
886
891
|
.el-plus-form-column-panel {
|
|
887
892
|
& > .el-form-item {
|
|
888
|
-
margin-bottom: 18px !important;
|
|
889
893
|
// & > .el-form-item__label-wrap {
|
|
890
894
|
& > .el-form-item__label {
|
|
891
895
|
line-height: 40px;
|
|
@@ -25,12 +25,13 @@ export default {
|
|
|
25
25
|
}
|
|
26
26
|
</script>
|
|
27
27
|
<script lang="ts" setup>
|
|
28
|
-
import { cloneDeep } from 'lodash'
|
|
29
28
|
import { isPromiseLike } from '../../util'
|
|
30
|
-
import { computed, ref, useSlots } from 'vue'
|
|
29
|
+
import { computed, inject, ref, useSlots } from 'vue'
|
|
31
30
|
import ElPlusForm, { IFormProps } from './ElPlusForm.vue'
|
|
32
31
|
import { IFormDesc, IFormGroupConfig } from '../../../types'
|
|
33
32
|
|
|
33
|
+
const lodash = inject('lodash') as any
|
|
34
|
+
|
|
34
35
|
const emits = defineEmits(['update:show', 'update:modelValue', 'before-validate', 'before-request', 'request-success', 'request-error', 'request-end', 'request'])
|
|
35
36
|
const props = defineProps<{
|
|
36
37
|
modelValue: { [key: string]: any } | {}
|
|
@@ -82,7 +83,7 @@ const getGroupFowmLayout = computed(() => {
|
|
|
82
83
|
return item._vif
|
|
83
84
|
})
|
|
84
85
|
|
|
85
|
-
const tempFormConfig = cloneDeep(props.formGroup) as any
|
|
86
|
+
const tempFormConfig = lodash.cloneDeep(props.formGroup) as any
|
|
86
87
|
const column = props.formGroup.column || 1
|
|
87
88
|
// 移除无用
|
|
88
89
|
delete tempFormConfig.group
|
|
@@ -28,9 +28,9 @@ export default {
|
|
|
28
28
|
</script>
|
|
29
29
|
<script lang="ts" setup>
|
|
30
30
|
import { ref, computed, useAttrs, watch, inject } from 'vue'
|
|
31
|
-
import { cloneDeep } from 'lodash'
|
|
32
31
|
import { IBtnBack, ICRUDConfig } from '../../../../types'
|
|
33
32
|
|
|
33
|
+
const lodash = inject('lodash') as any
|
|
34
34
|
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
35
35
|
|
|
36
36
|
const props = defineProps<{
|
|
@@ -81,7 +81,7 @@ const onEvents = computed(() => {
|
|
|
81
81
|
}
|
|
82
82
|
} else {
|
|
83
83
|
events[key] = function () {
|
|
84
|
-
props.desc?.on[key]({ row: cloneDeep(props.formData || {}), field: props.field, rowIndex: props.rowIndex } as IBtnBack)
|
|
84
|
+
props.desc?.on[key]({ row: lodash.cloneDeep(props.formData || {}), field: props.field, rowIndex: props.rowIndex } as IBtnBack)
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -35,10 +35,11 @@ export default {
|
|
|
35
35
|
}
|
|
36
36
|
</script>
|
|
37
37
|
<script lang="ts" setup>
|
|
38
|
-
import {
|
|
39
|
-
import { ref, reactive, watch, onMounted, computed } from 'vue'
|
|
38
|
+
import { ref, reactive, watch, onMounted, computed, inject } from 'vue'
|
|
40
39
|
import { IBtnBack, ITableConfig } from '../../../../types'
|
|
41
40
|
|
|
41
|
+
const lodash = inject('lodash') as any
|
|
42
|
+
|
|
42
43
|
interface ILinkItem {
|
|
43
44
|
label: string
|
|
44
45
|
value: string
|
|
@@ -98,7 +99,7 @@ function handelVisibleChange(val: any) {
|
|
|
98
99
|
if (val) {
|
|
99
100
|
selectRef.value.blur()
|
|
100
101
|
isShowDialog.value = true
|
|
101
|
-
selectList.value = cloneDeep(selectData.map((item) => item.dataItem))
|
|
102
|
+
selectList.value = lodash.cloneDeep(selectData.map((item) => item.dataItem))
|
|
102
103
|
// 这里存储一下老数据
|
|
103
104
|
selectOldData.splice(0, selectOldData.length, ...selectData)
|
|
104
105
|
}
|
|
@@ -177,7 +178,7 @@ function submit() {
|
|
|
177
178
|
|
|
178
179
|
// 触发外部change事件
|
|
179
180
|
if (onEvents.value.change) {
|
|
180
|
-
onEvents.value.change(cloneDeep(selectData))
|
|
181
|
+
onEvents.value.change(lodash.cloneDeep(selectData))
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
isShowDialog.value = false
|
|
@@ -190,7 +191,7 @@ watch(
|
|
|
190
191
|
(val) => {
|
|
191
192
|
let tempConfig = {} as ITableConfig
|
|
192
193
|
if (val) {
|
|
193
|
-
tempConfig = cloneDeep(val)
|
|
194
|
+
tempConfig = lodash.cloneDeep(val)
|
|
194
195
|
if (typeof props.desc.multiple === 'function') {
|
|
195
196
|
multiple.value = props.desc.multiple(props.formData || {})
|
|
196
197
|
} else {
|
|
@@ -72,10 +72,10 @@ export default {
|
|
|
72
72
|
<script lang="ts" setup>
|
|
73
73
|
import { ref, reactive, nextTick, watch, onMounted, computed, inject, onBeforeMount, useAttrs } from 'vue'
|
|
74
74
|
import { Share, UserFilled } from '@element-plus/icons-vue'
|
|
75
|
-
import { cloneDeep } from 'lodash'
|
|
76
75
|
import { getAttrs } from '../mixins'
|
|
77
76
|
import { ICRUDConfig } from '../../../../types'
|
|
78
77
|
|
|
78
|
+
const lodash = inject('lodash') as any
|
|
79
79
|
const globalData = inject('globalData') as any
|
|
80
80
|
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
81
81
|
|
|
@@ -158,7 +158,7 @@ const tableData = computed(() => {
|
|
|
158
158
|
if (deptDataList.value.length) {
|
|
159
159
|
tempData = deptDataList.value
|
|
160
160
|
} else {
|
|
161
|
-
tempData = cloneDeep(globalData[defaultConf.form?.linkUser?.deptListKey || ''])
|
|
161
|
+
tempData = lodash.cloneDeep(globalData[defaultConf.form?.linkUser?.deptListKey || ''])
|
|
162
162
|
}
|
|
163
163
|
if (deptTreeIndex.value && deptTreeIndex.value.length > 0) {
|
|
164
164
|
deptTreeIndex.value.map((item) => {
|
|
@@ -25,8 +25,8 @@ import { getAttrs } from '../mixins'
|
|
|
25
25
|
import { isEqual, isPromiseLike } from '../../../util'
|
|
26
26
|
import { ICRUDConfig } from '../../../../types'
|
|
27
27
|
import { useVModel } from '@vueuse/core'
|
|
28
|
-
import { cloneDeep } from 'lodash'
|
|
29
28
|
|
|
29
|
+
const lodash = inject('lodash') as any
|
|
30
30
|
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
31
31
|
const globalData = inject('globalData') as any
|
|
32
32
|
|
|
@@ -146,7 +146,7 @@ function initDefault() {
|
|
|
146
146
|
if (index >= 0) {
|
|
147
147
|
options.splice(index, 1)
|
|
148
148
|
}
|
|
149
|
-
options.unshift({ value: val, label: defaultLabel[i], dataItem: cloneDeep(props.formData) })
|
|
149
|
+
options.unshift({ value: val, label: defaultLabel[i], dataItem: lodash.cloneDeep(props.formData) })
|
|
150
150
|
}
|
|
151
151
|
})
|
|
152
152
|
}
|
|
@@ -21,8 +21,8 @@ import { isEqual } from '../../../util'
|
|
|
21
21
|
import { ref, reactive, useAttrs, onBeforeMount, watch, inject, nextTick } from 'vue'
|
|
22
22
|
import { getAttrs, getEvents } from '../mixins'
|
|
23
23
|
import { useVModel } from '@vueuse/core'
|
|
24
|
-
import { cloneDeep } from 'lodash'
|
|
25
24
|
|
|
25
|
+
const lodash = inject('lodash') as any
|
|
26
26
|
const globalData = inject('globalData') as any
|
|
27
27
|
|
|
28
28
|
const props = defineProps<{
|
|
@@ -63,7 +63,6 @@ function handelCheckChange(item: any, isSelect: boolean) {
|
|
|
63
63
|
// 这里判断一下全选状态
|
|
64
64
|
selectAll.value = isSelect && allIds.value.length === currentValue.value?.length
|
|
65
65
|
emits('validateThis')
|
|
66
|
-
console.log('validateThis******************')
|
|
67
66
|
})
|
|
68
67
|
}
|
|
69
68
|
|
|
@@ -72,7 +71,7 @@ function handelCheckChange(item: any, isSelect: boolean) {
|
|
|
72
71
|
*/
|
|
73
72
|
function handelSelectAll() {
|
|
74
73
|
let selectIds = [] as any[]
|
|
75
|
-
if (selectAll.value) selectIds = cloneDeep(allIds.value)
|
|
74
|
+
if (selectAll.value) selectIds = lodash.cloneDeep(allIds.value)
|
|
76
75
|
currentValue.value = selectIds
|
|
77
76
|
treeRef.value!.setCheckedKeys(currentValue.value)
|
|
78
77
|
}
|
|
@@ -102,7 +102,6 @@ import { ref, reactive, onMounted, computed, watch, nextTick, useSlots, inject,
|
|
|
102
102
|
import EleTabletHeader from './components/header.vue'
|
|
103
103
|
import ElPlusTableColumn from './ElPlusTableColumn.vue'
|
|
104
104
|
import { handelListColumn, isEqual } from '../../util'
|
|
105
|
-
import { cloneDeep, debounce } from 'lodash'
|
|
106
105
|
import { Loading } from '@element-plus/icons-vue'
|
|
107
106
|
import type { TableColumnCtx } from 'element-plus'
|
|
108
107
|
import { ICRUDConfig, ITableConfig, ITableTabItem, ITreeProps } from '../../../types'
|
|
@@ -114,6 +113,7 @@ interface SpanMethodProps {
|
|
|
114
113
|
columnIndex: number
|
|
115
114
|
}
|
|
116
115
|
|
|
116
|
+
const lodash = inject('lodash') as any
|
|
117
117
|
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
118
118
|
const format = inject('format') as any
|
|
119
119
|
|
|
@@ -231,7 +231,7 @@ const haveClassRowList = reactive([])
|
|
|
231
231
|
const loadingStatus = ref(0)
|
|
232
232
|
|
|
233
233
|
// 保存所有的选中行
|
|
234
|
-
const allSelectRowList = reactive((cloneDeep(props.selectList) || []) as any[])
|
|
234
|
+
const allSelectRowList = reactive((lodash.cloneDeep(props.selectList) || []) as any[])
|
|
235
235
|
// 记录树形展开的数组的下标
|
|
236
236
|
const treeIndexList = reactive([] as any[][])
|
|
237
237
|
|
|
@@ -424,7 +424,7 @@ async function loadExpandData(row: any, treeNode: any, resolve: any) {
|
|
|
424
424
|
postData[props.tableConfig?.explan?.idName || 'parentId'] = row.id
|
|
425
425
|
props.tableConfig.fetch &&
|
|
426
426
|
props.tableConfig.fetch(postData).then((pageInfo) => {
|
|
427
|
-
resolve(pageInfo?.[props.tableConfig?.fetchMap?.list || 'records'])
|
|
427
|
+
resolve(pageInfo?.[defaultConf.table?.list || props.tableConfig?.fetchMap?.list || 'records'])
|
|
428
428
|
})
|
|
429
429
|
}
|
|
430
430
|
|
|
@@ -448,7 +448,7 @@ function handelTableSelect(selection: any[], item: any) {
|
|
|
448
448
|
checkAndRemove(item, !selection.some((i) => i[props.rowKey] === item[props.rowKey]))
|
|
449
449
|
// 通知父类
|
|
450
450
|
emits('select', selection, item)
|
|
451
|
-
emits('selection', cloneDeep(allSelectRowList))
|
|
451
|
+
emits('selection', lodash.cloneDeep(allSelectRowList))
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
/**
|
|
@@ -463,7 +463,7 @@ function handelTableSelectAll(selection: any[]) {
|
|
|
463
463
|
})
|
|
464
464
|
// 通知父类
|
|
465
465
|
emits('selectAll', selection, isRemove)
|
|
466
|
-
emits('selection', cloneDeep(allSelectRowList))
|
|
466
|
+
emits('selection', lodash.cloneDeep(allSelectRowList))
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
/**
|
|
@@ -531,8 +531,8 @@ async function getListQueryData() {
|
|
|
531
531
|
} as any
|
|
532
532
|
if (props.isPager) {
|
|
533
533
|
// 封装分页信息
|
|
534
|
-
queryMap.current = pageInfo.current
|
|
535
|
-
queryMap.size = pageInfo.size
|
|
534
|
+
queryMap[defaultConf.table?.page?.current || props.tableConfig?.fetchMap?.page?.current || 'current'] = pageInfo.current
|
|
535
|
+
queryMap[defaultConf.table?.page?.pageSize || props.tableConfig?.fetchMap?.page?.pageSize || 'size'] = pageInfo.size
|
|
536
536
|
}
|
|
537
537
|
// 这里处理一下列表Tab的查询条件
|
|
538
538
|
if (props.tableConfig?.tabConf && props.tableConfig?.tabConf?.prop) {
|
|
@@ -659,16 +659,16 @@ async function loadData(isInit: Boolean) {
|
|
|
659
659
|
let dataPage = ((await props.tableConfig.fetch(postData)) || {}) as any
|
|
660
660
|
// 这里要进行赋值操作-同时要转换相关key
|
|
661
661
|
if (Array.isArray(dataPage)) {
|
|
662
|
-
dataPage = { [props.tableConfig?.fetchMap?.list || 'records']: dataPage }
|
|
662
|
+
dataPage = { [defaultConf.table?.list || props.tableConfig?.fetchMap?.list || 'records']: dataPage }
|
|
663
663
|
}
|
|
664
664
|
try {
|
|
665
665
|
let dataResult = [] as any
|
|
666
666
|
if (props.isPager) {
|
|
667
|
-
pageInfo.total = dataPage[props.tableConfig?.fetchMap?.total || 'total'] * 1 || 0
|
|
668
|
-
pageInfo.current = dataPage[props.tableConfig?.fetchMap?.current || 'current'] || 1
|
|
669
|
-
dataResult = dataPage[props.tableConfig?.fetchMap?.list || 'records'] || null
|
|
667
|
+
pageInfo.total = dataPage[defaultConf.table?.page?.total || props.tableConfig?.fetchMap?.page?.total || 'total'] * 1 || 0
|
|
668
|
+
pageInfo.current = dataPage[defaultConf.table?.page?.current || props.tableConfig?.fetchMap?.page?.current || 'current'] || 1
|
|
669
|
+
dataResult = dataPage[defaultConf.table?.list || props.tableConfig?.fetchMap?.list || 'records'] || null
|
|
670
670
|
} else {
|
|
671
|
-
dataResult = dataPage[props.tableConfig?.fetchMap?.list || 'records'] || null
|
|
671
|
+
dataResult = dataPage[defaultConf.table?.list || props.tableConfig?.fetchMap?.list || 'records'] || null
|
|
672
672
|
}
|
|
673
673
|
|
|
674
674
|
if (props.type !== 'expand' && props.isTempId && Array.isArray(dataResult)) {
|
|
@@ -704,7 +704,7 @@ async function loadData(isInit: Boolean) {
|
|
|
704
704
|
localLoading.value = false
|
|
705
705
|
}
|
|
706
706
|
|
|
707
|
-
const noticeInited = debounce(
|
|
707
|
+
const noticeInited = lodash.debounce(
|
|
708
708
|
() => {
|
|
709
709
|
emits('inited', tableData.value)
|
|
710
710
|
},
|
|
@@ -26,10 +26,11 @@ export default {
|
|
|
26
26
|
</script>
|
|
27
27
|
|
|
28
28
|
<script lang="ts" setup>
|
|
29
|
-
import { computed } from 'vue'
|
|
29
|
+
import { computed, inject } from 'vue'
|
|
30
30
|
import { IColumnItem } from '../../../types'
|
|
31
31
|
import ColumnItem from './components/columnItem.vue'
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
const lodash = inject('lodash') as any
|
|
33
34
|
|
|
34
35
|
const props = defineProps<{
|
|
35
36
|
item: IColumnItem
|
|
@@ -40,7 +41,7 @@ const props = defineProps<{
|
|
|
40
41
|
* 绑定属性
|
|
41
42
|
*/
|
|
42
43
|
const columnAttr = computed(() => {
|
|
43
|
-
const tempAttr = cloneDeep(props.item)
|
|
44
|
+
const tempAttr = lodash.cloneDeep(props.item)
|
|
44
45
|
delete tempAttr.children
|
|
45
46
|
return tempAttr
|
|
46
47
|
})
|
package/lib/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import ElPlusFormGroup from './components/el-plus-form/ElPlusFormGroup.vue'
|
|
|
6
6
|
import ElPlusTable from './components/el-plus-table/ElPlusTable.vue'
|
|
7
7
|
import defaultConf from './config'
|
|
8
8
|
import * as all from '../types'
|
|
9
|
+
import { cloneDeep, debounce } from 'lodash-es'
|
|
9
10
|
|
|
10
11
|
export default {
|
|
11
12
|
install: (app: App, config?: all.ICRUDConfig, format?: { [key: string]: Function }, globalData?: { [key: string]: Function }) => {
|
|
@@ -20,6 +21,9 @@ export default {
|
|
|
20
21
|
// 这里注入defaultConf
|
|
21
22
|
app.provide('defaultConf', defaultConf)
|
|
22
23
|
|
|
24
|
+
// 这里注入lodash
|
|
25
|
+
app.provide('lodash', { cloneDeep, debounce })
|
|
26
|
+
|
|
23
27
|
// 循环注册表单组件
|
|
24
28
|
components.unshift(ElPlusForm)
|
|
25
29
|
components.unshift(ElPlusFormDialog)
|
package/lib/util/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { cloneDeep } from 'lodash'
|
|
2
1
|
import { ICRUDConfig, IColumnItem } from '../../types'
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -156,7 +155,7 @@ export function getUID(): string {
|
|
|
156
155
|
export function getValue(keys: string | Array<string>, obj: any) {
|
|
157
156
|
if (!obj || !keys || keys.length <= 0) return null
|
|
158
157
|
if (Array.isArray(keys)) {
|
|
159
|
-
let tempObj =
|
|
158
|
+
let tempObj = JSON.parse(JSON.stringify(obj)) as any
|
|
160
159
|
for (let i = 0; i < keys.length; i++) {
|
|
161
160
|
tempObj = tempObj[Array.isArray(tempObj) ? parseInt(keys[i]) : keys[i]]
|
|
162
161
|
if (tempObj === undefined || tempObj === null) return null
|
|
@@ -204,7 +203,7 @@ export function handelListColumn(columnList: Array<IColumnItem> | undefined, def
|
|
|
204
203
|
const tempColumnList = [] as any[]
|
|
205
204
|
if (columnList && columnList.length > 0) {
|
|
206
205
|
// 不影响原有的对象,这里进行拷贝
|
|
207
|
-
|
|
206
|
+
JSON.parse(JSON.stringify(columnList)).map((item: IColumnItem) => {
|
|
208
207
|
// 如果有子集
|
|
209
208
|
if (item.children) {
|
|
210
209
|
// 表头居中
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "el-plus-crud",
|
|
3
3
|
"description": "采用Vue3 + TS,封装的element-plus数据驱动表单、列表组件",
|
|
4
4
|
"author": "K.D.Jack",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.41",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "dist/el-plus-crud.mjs",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@element-plus/icons-vue": "^2.3.1",
|
|
37
37
|
"element-plus": "2.5.1",
|
|
38
|
-
"lodash": "^4.17.21",
|
|
39
38
|
"vue": "^3.2.47"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
@@ -50,6 +49,7 @@
|
|
|
50
49
|
"eslint-plugin-vue": "^9.9.0",
|
|
51
50
|
"husky": "^8.0.3",
|
|
52
51
|
"lint-staged": "^13.2.3",
|
|
52
|
+
"lodash-es": "^4.17.21",
|
|
53
53
|
"prettier": "^3.0.0",
|
|
54
54
|
"sass": "^1.58.3",
|
|
55
55
|
"standard-version": "^9.5.0",
|
package/types/index.d.ts
CHANGED
|
@@ -34,13 +34,17 @@ export interface IFetch<T> {
|
|
|
34
34
|
/**
|
|
35
35
|
* 设定如何解析请求结果
|
|
36
36
|
*/
|
|
37
|
-
export interface
|
|
37
|
+
export interface IFetchTableMap {
|
|
38
38
|
// 结果列表key-默认records
|
|
39
39
|
list?: string
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
page?: {
|
|
41
|
+
// 总数key-默认total
|
|
42
|
+
total?: string
|
|
43
|
+
// 当前页key-默认current
|
|
44
|
+
current?: string
|
|
45
|
+
// 最大显示条数
|
|
46
|
+
pageSize?: string
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/**
|
|
@@ -58,7 +62,7 @@ export type IDescItem = {
|
|
|
58
62
|
label?: string | ((data?: any) => string)
|
|
59
63
|
prop?: string | ((data?: any) => string)
|
|
60
64
|
width?: string
|
|
61
|
-
format?: string | ((
|
|
65
|
+
format?: string | ((val?: any, row?: any) => string)
|
|
62
66
|
vif?: boolean | ((data?: any) => boolean)
|
|
63
67
|
vshow?: boolean | ((data?: any) => boolean)
|
|
64
68
|
limit?: number
|
|
@@ -369,7 +373,7 @@ export interface ITableConfig {
|
|
|
369
373
|
// 调用接口
|
|
370
374
|
fetch?: IFetch<any>
|
|
371
375
|
// 如何去解析数据结果
|
|
372
|
-
fetchMap?:
|
|
376
|
+
fetchMap?: IFetchTableMap
|
|
373
377
|
// 列表配置,包含表头,每列信息等
|
|
374
378
|
column?: Array<IColumnItem>
|
|
375
379
|
// 查询条件
|
|
@@ -517,6 +521,7 @@ export interface ICRUDConfig {
|
|
|
517
521
|
// 用户自定义form组件的名称,使用这个,全局注册的名字为el-plus-form-xxx,form中就可以使用xxx进行引入
|
|
518
522
|
comList?: string[]
|
|
519
523
|
}
|
|
524
|
+
table?: IFetchTableMap
|
|
520
525
|
// 上传组件配置
|
|
521
526
|
upload?: {
|
|
522
527
|
// 类型 minio 或者 七牛 / 阿里云 或者不填,不填则完全依赖 action
|