gi-component 0.0.16 → 0.0.18
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/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { DialogInstance } from '../index'
|
|
2
2
|
import ElementPlus from 'element-plus'
|
|
3
|
-
import { createApp,
|
|
3
|
+
import { createApp, h, ref } from 'vue'
|
|
4
|
+
import DialogContent from './dialog-content.vue'
|
|
4
5
|
import GiDialog from './dialog.vue'
|
|
5
6
|
|
|
6
|
-
const DialogContent = defineAsyncComponent(() => import('./dialog-content.vue'))
|
|
7
|
-
|
|
8
7
|
export type DialogOptions = Partial<DialogInstance['$props']>
|
|
9
8
|
|
|
10
9
|
export interface DialogReturnObject {
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<template v-for="(item, index) in props.columns">
|
|
5
5
|
<GridItem v-if="item.type === 'title'" :key="`title${index}`" :span="100">
|
|
6
6
|
<ElFormItem label-width="0">
|
|
7
|
-
<
|
|
8
|
-
|
|
7
|
+
<el-alert :class="b('form-item__title')" :title="typeof item.label === 'string' ? item.label : ''"
|
|
8
|
+
type="info" :closable="false" />
|
|
9
9
|
</ElFormItem>
|
|
10
10
|
</GridItem>
|
|
11
11
|
|
|
@@ -413,4 +413,13 @@ defineExpose({ formRef })
|
|
|
413
413
|
width: 100%;
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
+
|
|
417
|
+
:deep(.#{a.$prefix}-form-item__title) {
|
|
418
|
+
border-radius: 0;
|
|
419
|
+
|
|
420
|
+
.el-alert__title {
|
|
421
|
+
color: var(--el-text-color-primary);
|
|
422
|
+
font-weight: 600;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
416
425
|
</style>
|
|
@@ -86,19 +86,26 @@ const rightObj = reactive({
|
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
const leftAllChecked = computed(() => {
|
|
89
|
+
const rightListKeys = rightObj.options.map((i) => i.value)
|
|
89
90
|
const arr: string[] = []
|
|
90
91
|
eachTree(props.data, (i) => {
|
|
91
|
-
|
|
92
|
+
// 只考虑叶子节点且不在右侧列表中的节点
|
|
93
|
+
if (i.children === undefined && !rightListKeys.includes(i[nodeKey.value])) {
|
|
92
94
|
arr.push(i[nodeKey.value])
|
|
93
95
|
}
|
|
94
96
|
})
|
|
97
|
+
// 如果左侧没有可选节点,则返回false
|
|
98
|
+
if (arr.length === 0) return false
|
|
99
|
+
// 检查所有左侧叶子节点是否都被选中
|
|
95
100
|
return arr.every((i) => leftObj.checkedKeys.includes(i))
|
|
96
101
|
})
|
|
97
102
|
|
|
98
103
|
const getLeftTreeNodes = () => {
|
|
104
|
+
const rightListKeys = rightObj.options.map((i) => i.value)
|
|
99
105
|
const arr: any[] = []
|
|
100
106
|
eachTree(props.data, (i) => {
|
|
101
|
-
|
|
107
|
+
// 只返回叶子节点且不在右侧列表中的节点
|
|
108
|
+
if (i.children === undefined && !rightListKeys.includes(i[nodeKey.value])) {
|
|
102
109
|
arr.push(i)
|
|
103
110
|
}
|
|
104
111
|
})
|
|
@@ -130,8 +137,34 @@ function handleRightAllChecked() {
|
|
|
130
137
|
const leftTreeData = computed(() => {
|
|
131
138
|
const treeData = JSON.parse(JSON.stringify(props.data))
|
|
132
139
|
const rightListKeys = rightObj.options.map((i) => i.value)
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
|
|
141
|
+
// 递归过滤树节点,只有当节点不在右侧列表中且有子节点存在于左侧时才保留
|
|
142
|
+
const filterNodes = (nodes: any[]): any[] => {
|
|
143
|
+
const filtered: any[] = []
|
|
144
|
+
|
|
145
|
+
for (const node of nodes) {
|
|
146
|
+
// 深拷贝当前节点
|
|
147
|
+
const newNode = { ...node }
|
|
148
|
+
|
|
149
|
+
// 如果有子节点,递归处理
|
|
150
|
+
if (node.children && node.children.length > 0) {
|
|
151
|
+
newNode.children = filterNodes(node.children)
|
|
152
|
+
// 如果子节点过滤后仍有内容,或者节点本身不在右侧列表中且是叶子节点,则保留该节点
|
|
153
|
+
if (newNode.children.length > 0 || (!rightListKeys.includes(node[nodeKey.value]) && (!node.children || node.children.length === 0))) {
|
|
154
|
+
filtered.push(newNode)
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
// 叶子节点,只有当它不在右侧列表中时才保留
|
|
158
|
+
if (!rightListKeys.includes(node[nodeKey.value])) {
|
|
159
|
+
filtered.push(newNode)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return filtered
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return filterNodes(treeData)
|
|
135
168
|
})
|
|
136
169
|
|
|
137
170
|
const handleCheck = (data: any, obj: any) => {
|