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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-table-column v-if="props.item.__vif" v-bind="columnAttr">
|
|
3
|
+
<template #header="{ column }: any">
|
|
4
|
+
<div :class="{ 'th-required': item.required }" :style="item.hstyle">
|
|
5
|
+
{{ column.label }}
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
<template #default="scope: any">
|
|
9
|
+
<!-- 递归 -->
|
|
10
|
+
<template v-if="item.children?.length">
|
|
11
|
+
<ElPlusTableColumn v-for="(child, i) in item.children" :item="child" :size="size" :key="i"></ElPlusTableColumn>
|
|
12
|
+
</template>
|
|
13
|
+
<template v-else>
|
|
14
|
+
<ColumnItem v-if="scope['$index'] >= 0" :field="item.prop" :desc="item" :scope="scope" :size="size" v-model="scope.row[item.prop as any]" />
|
|
15
|
+
</template>
|
|
16
|
+
</template>
|
|
17
|
+
</el-table-column>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
export default {
|
|
22
|
+
name: 'ElPlusTableColumn',
|
|
23
|
+
inheritAttrs: false,
|
|
24
|
+
customOptions: {}
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<script lang="ts" setup>
|
|
29
|
+
import { computed } from 'vue'
|
|
30
|
+
import { IColumnItem } from 'types'
|
|
31
|
+
import ColumnItem from './components/columnItem.vue'
|
|
32
|
+
import { cloneDeep } from 'lodash'
|
|
33
|
+
|
|
34
|
+
const props = defineProps<{
|
|
35
|
+
item: IColumnItem
|
|
36
|
+
size: string
|
|
37
|
+
}>()
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 绑定属性
|
|
41
|
+
*/
|
|
42
|
+
const columnAttr = computed(() => {
|
|
43
|
+
const tempAttr = cloneDeep(props.item)
|
|
44
|
+
delete tempAttr.children
|
|
45
|
+
return tempAttr
|
|
46
|
+
})
|
|
47
|
+
</script>
|
|
@@ -19,7 +19,7 @@ import { IColumnItem } from 'types'
|
|
|
19
19
|
|
|
20
20
|
const props = defineProps<{
|
|
21
21
|
modelValue?: any
|
|
22
|
-
field?: string
|
|
22
|
+
field?: string | ((data?: any) => string)
|
|
23
23
|
desc: IColumnItem
|
|
24
24
|
scope: { [key: string]: any }
|
|
25
25
|
size?: string
|
|
@@ -35,7 +35,8 @@ const cells = computed(() => {
|
|
|
35
35
|
_cells.push(handelItem(item.field || props.field, item, i))
|
|
36
36
|
})
|
|
37
37
|
} else {
|
|
38
|
-
const
|
|
38
|
+
const tempField = (typeof props.field === 'function' ? props.field() : props.field) || ''
|
|
39
|
+
const porpList = tempField.split(',')
|
|
39
40
|
porpList.map((item, i) => {
|
|
40
41
|
_cells.push(handelItem(item, props.desc, i))
|
|
41
42
|
})
|
|
@@ -117,7 +118,8 @@ const handelItem = (prop: string, item: any, i: number) => {
|
|
|
117
118
|
tempCell.desc.style = item.style || {}
|
|
118
119
|
|
|
119
120
|
if (typeof item.color === 'function') {
|
|
120
|
-
|
|
121
|
+
const tempField = (typeof props.field === 'function' ? props.field() : props.field) || ''
|
|
122
|
+
tempCell.desc.style.color = item.color(props.scope?.row[tempField], props.scope?.row, props.field)
|
|
121
123
|
} else if (typeof item.color === 'string') {
|
|
122
124
|
tempCell.desc.style.color = item.color
|
|
123
125
|
} else {
|
|
@@ -1,180 +1,172 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="el-plus-table-edit-column">
|
|
3
|
-
<el-button v-if="showText" type="primary" @click="showSettingDialog" :size="size" plain>编辑显示列</el-button>
|
|
4
|
-
<el-button v-else type="primary" icon="ele-Setting" @click="showSettingDialog" :size="size" title="编辑显示列" plain circle />
|
|
5
|
-
|
|
6
|
-
<!-- 编辑列 -->
|
|
7
|
-
<el-dialog title="编辑显示列" v-model="showSettingColumn" width="40%">
|
|
8
|
-
<template #default>
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
function
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
height: 30px;
|
|
174
|
-
padding: 0 10px;
|
|
175
|
-
border-bottom: 1px solid #eee;
|
|
176
|
-
margin-bottom: 10px;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
</style>
|
|
180
|
-
types
|
|
1
|
+
<template>
|
|
2
|
+
<div class="el-plus-table-edit-column">
|
|
3
|
+
<el-button v-if="showText" type="primary" @click="showSettingDialog" :size="size" plain>编辑显示列</el-button>
|
|
4
|
+
<el-button v-else type="primary" icon="ele-Setting" @click="showSettingDialog" :size="size" title="编辑显示列" plain circle />
|
|
5
|
+
|
|
6
|
+
<!-- 编辑列 -->
|
|
7
|
+
<el-dialog title="编辑显示列" v-model="showSettingColumn" draggable width="40%">
|
|
8
|
+
<template #default>
|
|
9
|
+
<el-tree ref="treeRef" :data="options" show-checkbox node-key="idx" :default-expand-all="true" :default-checked-keys="checkColumn" :props="defaultProps" @check="handelCheckChange" />
|
|
10
|
+
</template>
|
|
11
|
+
<template #footer>
|
|
12
|
+
<div class="dialog-footer">
|
|
13
|
+
<el-button :size="size" @click="handelCancel"> 取 消 </el-button>
|
|
14
|
+
<el-button :size="size" type="primary" @click="changeColumnData"> 确 定 </el-button>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
</el-dialog>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
<script lang="ts" setup>
|
|
21
|
+
import { ref, onMounted, inject, reactive } from 'vue'
|
|
22
|
+
import { ElMessage } from 'element-plus'
|
|
23
|
+
import { ICRUDConfig, IColumnItem } from 'types'
|
|
24
|
+
|
|
25
|
+
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
26
|
+
|
|
27
|
+
const props = defineProps<{
|
|
28
|
+
column: Array<IColumnItem>
|
|
29
|
+
tbName: string
|
|
30
|
+
size: string
|
|
31
|
+
showText?: boolean
|
|
32
|
+
}>()
|
|
33
|
+
|
|
34
|
+
// 弹框显示
|
|
35
|
+
const showSettingColumn = ref(false)
|
|
36
|
+
const treeRef = ref()
|
|
37
|
+
|
|
38
|
+
let options = ref([])
|
|
39
|
+
|
|
40
|
+
const treeAll = ref([] as Array<String>)
|
|
41
|
+
const checkColumn = ref([] as Array<String>)
|
|
42
|
+
// 定义一个需要隐藏的列表-存储到本地用
|
|
43
|
+
let tempList = ref([] as Array<String>)
|
|
44
|
+
|
|
45
|
+
const defaultProps = {
|
|
46
|
+
children: 'children',
|
|
47
|
+
label: 'label',
|
|
48
|
+
disabled: 'disabledcheckd'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 匹配序号并获取全部序号
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
function addIndex(item: any, index?: string) {
|
|
56
|
+
item.map((i: any, idx: number) => {
|
|
57
|
+
// 匹配序号
|
|
58
|
+
i.idx = index !== undefined ? `${index}-${idx}` : `${idx}`
|
|
59
|
+
// 禁用判断
|
|
60
|
+
if (i.required || i.noHide || i.disabled) {
|
|
61
|
+
i.disabledcheckd = true
|
|
62
|
+
tempList.value.splice(tempList.value.indexOf(i.idx), 1)
|
|
63
|
+
}
|
|
64
|
+
// 如果子集全部禁用,那么父级也禁用 ,如果父集禁用,那么子级也禁用
|
|
65
|
+
i.children && i.children.every((info: any) => info.disabled) ? (i.disabled = true) : i.children && i.disabled ? i.children.map((info: any) => (info.disabled = true)) : ''
|
|
66
|
+
// 是否有子集
|
|
67
|
+
if (i.children?.length > 0) {
|
|
68
|
+
addIndex(i.children, `${i.idx}`)
|
|
69
|
+
}
|
|
70
|
+
i.children ? '' : treeAll.value.push(i.idx)
|
|
71
|
+
})
|
|
72
|
+
return item
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 打开弹框
|
|
77
|
+
*/
|
|
78
|
+
function showSettingDialog() {
|
|
79
|
+
showSettingColumn.value = true
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 获取没有选中的选项
|
|
84
|
+
*/
|
|
85
|
+
function handelCheckChange(val: any, data: any) {
|
|
86
|
+
data.checkedAllKeys = Array.from(new Set([...data.checkedKeys, ...data.halfCheckedKeys]))
|
|
87
|
+
tempList.value = treeAll.value.filter((x) => {
|
|
88
|
+
return data.checkedAllKeys.indexOf(x) < 0
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 设置是否显示
|
|
93
|
+
function setShow(item: any) {
|
|
94
|
+
for (let index = 0; index < item.length; index++) {
|
|
95
|
+
if (item[index].children) {
|
|
96
|
+
setShow(item[index].children)
|
|
97
|
+
}
|
|
98
|
+
if (tempList.value.indexOf(item[index].idx) < 0) {
|
|
99
|
+
item[index].scShow = true
|
|
100
|
+
} else {
|
|
101
|
+
item[index].scShow = false
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function changeColumnData() {
|
|
107
|
+
if (treeAll.value.length === tempList.value.length) {
|
|
108
|
+
ElMessage.warning('请至少选择一列!')
|
|
109
|
+
return false
|
|
110
|
+
}
|
|
111
|
+
setShow(props.column)
|
|
112
|
+
if (tempList.value.length > 0) {
|
|
113
|
+
localStorage.setItem(defaultConf.storagePrefix + 'hideColumnsList_' + props.tbName, tempList.value.join('__'))
|
|
114
|
+
} else {
|
|
115
|
+
localStorage.removeItem(defaultConf.storagePrefix + 'hideColumnsList_' + props.tbName)
|
|
116
|
+
}
|
|
117
|
+
showSettingColumn.value = false
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 初始化选择列
|
|
122
|
+
* @param init
|
|
123
|
+
*/
|
|
124
|
+
function initLocalCheckList() {
|
|
125
|
+
// 从本地获取处理过的字段一级顺序
|
|
126
|
+
const tempLocalStr = localStorage.getItem(defaultConf.storagePrefix + 'hideColumnsList_' + props.tbName) as String
|
|
127
|
+
// 判断为空
|
|
128
|
+
if (tempLocalStr !== undefined && tempLocalStr !== null && tempLocalStr.length > 0) {
|
|
129
|
+
// 用两个下划线拆分
|
|
130
|
+
tempList.value = tempLocalStr.split('__')
|
|
131
|
+
}
|
|
132
|
+
options.value = addIndex(props.column)
|
|
133
|
+
|
|
134
|
+
setShow(props.column)
|
|
135
|
+
// 过滤出隐藏的节点
|
|
136
|
+
checkColumn.value = treeAll.value.filter((x) => {
|
|
137
|
+
return tempList.value.indexOf(x) < 0
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 取消
|
|
143
|
+
*/
|
|
144
|
+
function handelCancel() {
|
|
145
|
+
// 还原
|
|
146
|
+
treeRef.value.setCheckedKeys(checkColumn.value)
|
|
147
|
+
|
|
148
|
+
showSettingColumn.value = false
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
onMounted(() => {
|
|
152
|
+
if (props.tbName) {
|
|
153
|
+
initLocalCheckList()
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
defineExpose({ initCol: initLocalCheckList })
|
|
158
|
+
</script>
|
|
159
|
+
<style lang="scss" scoped>
|
|
160
|
+
.el-plus-table-edit-column {
|
|
161
|
+
margin: 0 10px;
|
|
162
|
+
display: inline-block;
|
|
163
|
+
|
|
164
|
+
.select-panel {
|
|
165
|
+
width: 100%;
|
|
166
|
+
height: 30px;
|
|
167
|
+
padding: 0 10px;
|
|
168
|
+
border-bottom: 1px solid #eee;
|
|
169
|
+
margin-bottom: 10px;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
</style>
|