el-plus-crud 0.1.39 → 0.1.40
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 +2 -0
- package/dist/el-plus-crud.mjs +2527 -2525
- package/lib/components/el-plus-form/ElPlusForm.vue +7 -3
- package/lib/components/el-plus-form/components/ElPlusFormTree.vue +0 -1
- package/lib/components/el-plus-table/ElPlusTable.vue +8 -8
- 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 }">
|
|
@@ -110,6 +110,8 @@ export interface IFormProps {
|
|
|
110
110
|
isGroupForm?: boolean
|
|
111
111
|
// 是否禁用最后一个元素的tab
|
|
112
112
|
disabledTab?: boolean
|
|
113
|
+
// item的底部边距
|
|
114
|
+
itemMB?: string
|
|
113
115
|
// 比如 beforeValidate, beforeRequest, success, requestError, requestEnd
|
|
114
116
|
// 其他钩子 直接放到attrs里面去了
|
|
115
117
|
}
|
|
@@ -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
|
})
|
|
@@ -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
|
}
|
|
@@ -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;
|
|
@@ -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
|
|
|
@@ -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)) {
|
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.40",
|
|
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": "^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
|