修改测试问题
This commit is contained in:
@@ -1,49 +1,11 @@
|
||||
<template>
|
||||
<div class="default-main pd10">
|
||||
<div style="width: 100%; display: flex; justify-content: end">
|
||||
<div class="elButton">
|
||||
<el-button type="primary" icon="el-icon-Check" @click="onSubmit">保存</el-button>
|
||||
<back-component />
|
||||
</div>
|
||||
<div style="display: flex" class="mt10">
|
||||
<!-- <el-tabs type="border-card">
|
||||
<el-tab-pane label="组件">
|
||||
<div style="width: 520px; overflow: auto" :style="indicatorHeight" class="mr10">
|
||||
<el-collapse v-model="activeNames" :expand-icon-position="position">
|
||||
<el-collapse-item
|
||||
v-for="item in treeComponents"
|
||||
:key="item.id"
|
||||
:title="item.name"
|
||||
:name="item.id"
|
||||
>
|
||||
<el-collapse v-model="activeNames1" class="ml20">
|
||||
<el-collapse-item
|
||||
v-for="k in item.children"
|
||||
:key="k.id"
|
||||
:title="k.name"
|
||||
:name="k.id"
|
||||
>
|
||||
<div class="Box">
|
||||
<div
|
||||
v-for="(s, index) in k.children"
|
||||
:key="index"
|
||||
class="mr10 mb10 imgBox"
|
||||
draggable="true"
|
||||
unselectable="on"
|
||||
@drag="drag(s)"
|
||||
@dragend="dragEnd(s)"
|
||||
>
|
||||
<div class="textName">{{ s.name }}</div>
|
||||
<img :src="s.image" style="width: 150px" />
|
||||
</div>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs> -->
|
||||
<el-tabs v-model="tableName" type="border-card" @tab-change="changeTab">
|
||||
<div style="display: flex">
|
||||
<el-tabs v-model="tableName" v-if="treeComponents.length > 0" type="border-card" @tab-change="changeTab">
|
||||
<el-tab-pane v-for="item in treeComponents" :key="item.name" :label="item.name" :name="item.name">
|
||||
<el-tabs v-model="tableName1" tab-position="top">
|
||||
<el-tab-pane v-for="k in item?.children" :key="k.name" :label="k.name" :name="k.name">
|
||||
@@ -70,7 +32,7 @@
|
||||
</el-tabs>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<el-empty v-else description="当前角色未绑定系统" style="width: 520px" />
|
||||
<div style="flex: 1" ref="wrapper" class="ml10">
|
||||
<el-tabs type="border-card" class="mb10">
|
||||
<el-tab-pane label="基础信息">
|
||||
@@ -208,6 +170,9 @@ import { useAdminInfo } from '@/stores/adminInfo'
|
||||
const tableName = ref('')
|
||||
const tableName1 = ref('')
|
||||
import { useNavTabs } from '@/stores/navTabs'
|
||||
import { getSystemByRoleId } from '@/api/user-boot/roleFuction'
|
||||
import { forEach } from 'jszip'
|
||||
import { id } from 'element-plus/es/locale'
|
||||
// defineOptions({
|
||||
// name: 'cockpit/popup'
|
||||
// })
|
||||
@@ -218,7 +183,7 @@ const { go } = useRouter()
|
||||
const navTabs = useNavTabs()
|
||||
const { query } = useRoute()
|
||||
const router = useRouter()
|
||||
const height = mainHeight(295)
|
||||
const height = mainHeight(265)
|
||||
const indicatorHeight = mainHeight(180)
|
||||
const rowHeight = ref(0)
|
||||
const pageList: any = ref([])
|
||||
@@ -258,7 +223,7 @@ const layout: any = ref([
|
||||
])
|
||||
const treeComponents: any = ref([]) //组件树
|
||||
const treeComponentsCopy: any = ref([]) //组件树
|
||||
const info = () => {
|
||||
const info = async () => {
|
||||
pageList.value = router
|
||||
.getRoutes()
|
||||
.filter(item => item?.meta?.component == '/src/views/pqs/cockpit/homePage/index.vue')
|
||||
@@ -268,17 +233,26 @@ const info = () => {
|
||||
|
||||
activeNames.value = []
|
||||
activeNames1.value = []
|
||||
componentTree().then(res => {
|
||||
treeComponents.value = res.data
|
||||
|
||||
let systemList: any[] = []
|
||||
await adminInfo.roleList.forEach((item: any) => {
|
||||
getSystemByRoleId({ id: item }).then(res => {
|
||||
systemList = [...new Set([...systemList, ...res.data.systemIds])]
|
||||
})
|
||||
})
|
||||
|
||||
await componentTree().then(res => {
|
||||
let list = res.data.filter(item => systemList.includes(item.id))
|
||||
treeComponents.value = list
|
||||
tableName.value = tableName.value == '' ? treeComponents.value[0].name : tableName.value
|
||||
tableName1.value = tableName1.value == '' ? treeComponents.value[0].children[0].name : tableName1.value
|
||||
activeNames.value = treeComponents.value.map(item => item.id)
|
||||
res.data.forEach(item => {
|
||||
list.forEach(item => {
|
||||
item.children.forEach(k => {
|
||||
activeNames1.value.push(k.id)
|
||||
})
|
||||
})
|
||||
treeComponentsCopy.value = tree2List(JSON.parse(JSON.stringify(res.data)), 0)
|
||||
treeComponentsCopy.value = tree2List(JSON.parse(JSON.stringify(list)), 0)
|
||||
})
|
||||
|
||||
if (query.id) {
|
||||
@@ -439,7 +413,6 @@ const onSubmit = () => {
|
||||
if (layout.value.length == 0) {
|
||||
return ElMessage.warning('页面设计不能为空!')
|
||||
}
|
||||
console.log(123, findDuplicateNames(layout.value))
|
||||
let repeat = findDuplicateNames(layout.value) || []
|
||||
if (repeat.length > 0) {
|
||||
return ElMessage.warning(repeat.join('、') + ' 组件重复,请删除重复组件!')
|
||||
@@ -493,31 +466,72 @@ const onSubmit = () => {
|
||||
})
|
||||
}
|
||||
// 查找重复的name
|
||||
// const findDuplicateNames = (arr: any) => {
|
||||
// // 用于记录每个name出现的次数
|
||||
// const nameCount = {}
|
||||
// // 用于存储重复的name
|
||||
// const duplicates = []
|
||||
|
||||
// // 遍历数组统计每个name的出现次数
|
||||
// arr.forEach(item => {
|
||||
// const name = item.name
|
||||
// if (nameCount[name]) {
|
||||
// nameCount[name]++
|
||||
// } else {
|
||||
// nameCount[name] = 1
|
||||
// }
|
||||
// })
|
||||
|
||||
// // 筛选出出现次数大于1的name
|
||||
// for (const name in nameCount) {
|
||||
// if (nameCount[name] > 1) {
|
||||
// duplicates.push(name)
|
||||
// }
|
||||
// }
|
||||
|
||||
// return duplicates
|
||||
// }
|
||||
// 查找重复的path,并返回对应的重复name
|
||||
const findDuplicateNames = (arr: any) => {
|
||||
// 用于记录每个name出现的次数
|
||||
const nameCount = {}
|
||||
// 用于存储重复的name
|
||||
// 用于记录每个path出现的次数
|
||||
const pathCount: any = {}
|
||||
// 用于存储path对应的name(避免重复存储)
|
||||
const pathToNameMap = new Map()
|
||||
// 用于存储重复path对应的name
|
||||
const duplicates = []
|
||||
|
||||
// 遍历数组统计每个name的出现次数
|
||||
// 遍历数组统计每个path的出现次数,并记录path和name的映射
|
||||
arr.forEach(item => {
|
||||
const path = item.path
|
||||
const name = item.name
|
||||
if (nameCount[name]) {
|
||||
nameCount[name]++
|
||||
|
||||
// 记录path和name的对应关系(只存第一次的,避免覆盖)
|
||||
if (!pathToNameMap.has(path)) {
|
||||
pathToNameMap.set(path, name)
|
||||
}
|
||||
|
||||
// 统计path出现次数
|
||||
if (pathCount[path]) {
|
||||
pathCount[path]++
|
||||
} else {
|
||||
nameCount[name] = 1
|
||||
pathCount[path] = 1
|
||||
}
|
||||
})
|
||||
|
||||
// 筛选出出现次数大于1的name
|
||||
for (const name in nameCount) {
|
||||
if (nameCount[name] > 1) {
|
||||
duplicates.push(name)
|
||||
// 筛选出出现次数大于1的path,并获取对应的name
|
||||
for (const path in pathCount) {
|
||||
if (pathCount[path] > 1) {
|
||||
const name = pathToNameMap.get(path)
|
||||
// 避免重复添加相同的name(如果多个重复path对应同一个name)
|
||||
if (!duplicates.includes(name)) {
|
||||
duplicates.push(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return duplicates
|
||||
}
|
||||
|
||||
const getImg = throttle((path: string) => {
|
||||
if (path != undefined) return treeComponentsCopy.value.filter(item => item.path == path)[0]?.image
|
||||
})
|
||||
@@ -652,4 +666,20 @@ onBeforeUnmount(() => {
|
||||
// border: 1px solid #000;
|
||||
box-shadow: var(--el-box-shadow-light);
|
||||
}
|
||||
.elButton {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 13px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
:deep(.vgl-item__resizer) {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: linear-gradient(45deg, var(--el-color-primary));
|
||||
|
||||
clip-path: polygon(100% 0, 100% 100%, 0 100%);
|
||||
/* 可选:添加阴影增强视觉效果 */
|
||||
box-shadow: 2px 2px 8px var(--el-color-primary);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user