修改驾驶舱页面

This commit is contained in:
guanj
2025-10-24 16:17:40 +08:00
parent d113df832d
commit dede918f34
12 changed files with 454 additions and 173 deletions

View File

@@ -1,31 +1,27 @@
<template>
<div class="pd10">
<el-card>
<el-form ref="formRef" inline :rules="rules" :model="form" label-width="120px" class="form-four">
<el-form ref="formRef" inline :rules="rules" :model="form" label-width="auto" class="form-four">
<el-form-item label="页面名称" prop="pageName">
<el-input
style="width: 100%"
maxlength="32"
show-word-limit
v-model.trim="form.pageName"
placeholder="请输入页面名称"
></el-input>
</el-form-item>
<el-form-item label="页面排序" prop="sort">
<el-input
maxlength="32"
show-word-limit-number
v-model.trim.number="form.sort"
:min="0"
:step="1"
step-strictly
/>
<el-form-item label="图标">
<IconSelector v-model.trim="form.icon" style="width: 80%" placeholder="请选择图标" />
</el-form-item>
<el-form-item label="绑定页面">
<el-form-item label="页面排序" prop="sort">
<el-input-number style="width: 100%" v-model.trim="form.sort" :min="0" :max="10000" :step="1" />
</el-form-item>
<!-- <el-form-item label="绑定页面">
<el-select v-model="form.pagePath" filterable placeholder="请选择绑定页面" style="width: 100%" clearable>
<el-option v-for="item in pageList" :key="item.path" :label="item.name" :value="item.path" />
</el-select>
</el-form-item>
</el-form-item> -->
<el-form-item label="备注" class="top">
<el-input
@@ -91,6 +87,7 @@
<template #item="{ item }">
<div class="imgBox">
<div class="textName">{{ item.name }}</div>
<img
:src="getImg(item.path)"
:style="{
@@ -110,6 +107,7 @@
'px'
}"
/>
<CloseBold class="remove" @click="removeItem(item.i)" />
</div>
<!-- <span class="text">{{ `${item?.name}` }}</span>
@@ -127,6 +125,7 @@ import { useRouter } from 'vue-router'
import BackComponent from '@/components/icon/back/index.vue'
import { mainHeight } from '@/utils/layout'
import type { CollapseIconPositionType } from 'element-plus'
import IconSelector from '@/components/baInput/components/iconSelector.vue'
import { componentTree } from '@/api/user-boot/user'
import { GridLayout, GridItem } from 'grid-layout-plus'
import { throttle } from 'lodash-es'
@@ -135,7 +134,7 @@ import { Tools, CloseBold } from '@element-plus/icons-vue'
import { addDashboard, updateDashboard, queryById } from '@/api/system-boot/csstatisticalset'
import html2canvas from 'html2canvas'
import { useRoute } from 'vue-router'
import { getMenu } from '@/utils/router'
// defineOptions({
// name: 'cockpit/popup'
// })
@@ -154,9 +153,11 @@ const form: any = reactive({
containerConfig: [],
sort: '100',
id: '',
icon: '',
pagePath: '',
pathName: '',
remark: ''
remark: '',
routeName: '/src/views/pqs/cockpit/homePage/index.vue'
})
const activeNames = ref([])
const activeNames1 = ref([])
@@ -204,12 +205,14 @@ const info = () => {
queryById({ id: query.id }).then(res => {
layout.value = JSON.parse(res.data.containerConfig)
form.pageName = res.data.pageName
form.pagePath = res.data.pagePath
form.pathName = res.data.pathName
form.pagePath = query.path || res.data.pagePath
form.sort = res.data.sort
form.remark = res.data.remark
form.id = res.data.id
form.icon = res.data.icon
})
} else {
form.pagePath = query.path
}
}
@@ -308,7 +311,6 @@ const drag = throttle(row => {
})
function dragEnd(row: any) {
console.log('🚀 ~ drag ~ row:', row)
const parentRect = wrapper.value?.getBoundingClientRect()
if (!parentRect || !gridLayout.value) return
@@ -331,7 +333,7 @@ function dragEnd(row: any) {
y: dragItem.y,
w: dragItem.w,
h: dragItem.h,
i: dragItem.i,
i: Math.random(), //dragItem.i,
name: row.name,
path: row.path,
icon: row.icon,
@@ -349,10 +351,10 @@ const onSubmit = () => {
if (layout.value.length == 0) {
return ElMessage.warning('页面设计不能为空!')
}
const maxValue = Math.max(...layout.value.map(item => item.y + item.h))
if (maxValue > 6) {
return ElMessage.warning('组件不能超出当前容器!')
}
// const maxValue = Math.max(...layout.value.map(item => item.y + item.h))
// if (maxValue > 6) {
// return ElMessage.warning('组件不能超出当前容器!')
// }
formRef.value.validate(async (valid: boolean) => {
let url = ''
@@ -362,7 +364,6 @@ const onSubmit = () => {
url = canvas.toDataURL('image/png')
})
form.pagePath = form.pagePath || ''
form.pathName = pageList.value.filter((item: any) => item.path == form.pagePath)?.[0]?.name || ''
if (valid) {
if (form.id == '') {
@@ -370,6 +371,7 @@ const onSubmit = () => {
(res: any) => {
ElMessage.success('新增页面成功!')
go(-1)
getMenu()
}
)
} else {
@@ -377,6 +379,7 @@ const onSubmit = () => {
(res: any) => {
ElMessage.success('修改页面成功!')
go(-1)
getMenu()
}
)
}
@@ -386,6 +389,7 @@ const onSubmit = () => {
const getImg = throttle((path: string) => {
if (path != undefined) return treeComponentsCopy.value.filter(item => item.path == path)[0]?.image
})
onMounted(() => {
info()
@@ -460,7 +464,9 @@ onBeforeUnmount(() => {
.vgl-layout {
background-color: #eee;
}
:deep(.el-input-group) {
width: 90%;
}
.remove {
position: absolute;
top: 5px;
@@ -486,4 +492,7 @@ onBeforeUnmount(() => {
background-color: #fff;
border: 1px solid black;
}
:deep(.el-form--inline .el-form-item) {
margin-right: 0px;
}
</style>