拓扑图模版配置

This commit is contained in:
仲么了
2024-01-26 13:43:54 +08:00
parent fa7ac01f6c
commit 04665478fc
5 changed files with 148 additions and 65 deletions

View File

@@ -29,6 +29,7 @@
"screenfull": "^6.0.2", "screenfull": "^6.0.2",
"use-element-plus-theme": "^0.0.5", "use-element-plus-theme": "^0.0.5",
"vue": "^3.3.11", "vue": "^3.3.11",
"vue-draggable-resizable": "3.0.0-beta.2",
"vue-router": "4", "vue-router": "4",
"vxe-table": "^4.5.17", "vxe-table": "^4.5.17",
"xe-utils": "^3.5.14" "xe-utils": "^3.5.14"

11
pnpm-lock.yaml generated
View File

@@ -61,6 +61,9 @@ dependencies:
vue: vue:
specifier: ^3.3.11 specifier: ^3.3.11
version: 3.3.13(typescript@5.3.3) version: 3.3.13(typescript@5.3.3)
vue-draggable-resizable:
specifier: 3.0.0-beta.2
version: 3.0.0-beta.2(vue@3.3.13)
vue-router: vue-router:
specifier: '4' specifier: '4'
version: 4.2.5(vue@3.3.13) version: 4.2.5(vue@3.3.13)
@@ -2356,6 +2359,14 @@ packages:
vue: 3.3.13(typescript@5.3.3) vue: 3.3.13(typescript@5.3.3)
dev: false dev: false
/vue-draggable-resizable@3.0.0-beta.2(vue@3.3.13):
resolution: {integrity: sha512-BVk7rKw5OdZh9jT+bHQd+wPWZMBTAkBnfmjNRFbZFPsTSwndAvAdV7YI7IJtyDL3Qwq9XNYjSl5wi7/8ivs5mw==}
peerDependencies:
vue: ^3.2.25
dependencies:
vue: 3.3.13(typescript@5.3.3)
dev: false
/vue-router@4.2.5(vue@3.3.13): /vue-router@4.2.5(vue@3.3.13):
resolution: {integrity: sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw==, tarball: https://registry.npmmirror.com/vue-router/-/vue-router-4.2.5.tgz} resolution: {integrity: sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw==, tarball: https://registry.npmmirror.com/vue-router/-/vue-router-4.2.5.tgz}
peerDependencies: peerDependencies:

View File

@@ -0,0 +1,10 @@
import request from '@/utils/request'
// 上传拓扑图模板监测点位置
export const addLineTemplate = (data: any) => {
return request({
url: '/cs-device-boot/lineTemplate/addLineTemplate',
method: 'POST',
data: data
})
}

View File

@@ -33,9 +33,12 @@ const tableStore = new TableStore({
loadCallback: () => { loadCallback: () => {
tableStore.table.data.forEach((item: any) => { tableStore.table.data.forEach((item: any) => {
item.failReason = item.failReason || '/'
item.result = item.result === 1 ? '成功' : '失败' item.result = item.result === 1 ? '成功' : '失败'
item.loginName = item.loginName || '/' for (let key in item) {
if (typeof item[key] !== 'number') {
item[key] = item[key] || '/'
}
}
}) })
} }
}) })

View File

@@ -1,117 +1,175 @@
<template> <template>
<el-dialog class='cn-operate-dialog' v-model='dialogVisible' title='编辑拓扑图信息'> <el-dialog class="cn-operate-dialog" v-model="dialogVisible" title="编辑拓扑图信息">
<el-form> <el-form :label-width="140">
<el-form-item label='拓扑图:' style='height: auto !important;'> <el-form-item label="拓扑图:" style="height: auto !important">
<div class='gplot-content'> <div class="gplot-content">
<img :src='imgUrl' class='gplot-content' style='border: 1px solid #dcdfe6' /> <VueDraggableResizable
<!-- <VueDraggableResizable--> class-name-draggable="gplot-content-item"
<!-- :isActive='editorIndex == index'--> class-name-active="gplot-content-item-active"
<!-- :h='item.height'--> :active="editorIndex == index"
<!-- :w='item.width'--> :resizable="false"
<!-- :x='item.left'--> :parent="true"
<!-- :y='item.top'--> :x="item.left"
<!-- @dragging='resize(index, $event)'--> :y="item.top"
<!-- v-for='(item, index) in pointList'--> :w="item.width"
<!-- :key='index'--> :h="item.height"
<!-- :isResizable='false'--> @dragStart="editorIndex = index"
<!-- >--> @dragging="resize"
<!-- <div--> v-for="(item, index) in pointList"
<!-- class='text'--> :key="index"
<!-- style='line-height: 20px; white-space: nowrap'--> :isResizable="false"
<!-- :style="{ color: item.name === '监测点' ? 'red' : 'black' }"--> >
<!-- @click.stop='textClick(item, index)'--> <div
<!-- >--> class="text"
<!-- {{ item.name }}--> style="line-height: 20px; white-space: nowrap"
<!-- </div>--> :style="{ color: item.name === '监测点' ? 'red' : 'black' }"
<!-- </VueDraggableResizable>--> >
{{ item.name }}
</div>
</VueDraggableResizable>
<img
:src="imgUrl"
class="gplot-content"
style="border: 1px solid #dcdfe6; position: unset; user-select: none"
draggable="false"
/>
<div>注意监测点不要移出圈</div> <div>注意监测点不要移出圈</div>
</div> </div>
</el-form-item> </el-form-item>
</el-form> <el-form-item label="监测点位置:" v-if="editorIndex > -1">
<el-form v-if='editorIndex > -1'> <div style="display: flex">
<el-form-item label='监测点位置:'>
<div style='display: flex'>
<el-select <el-select
v-model='pointList[editorIndex].position' v-model="pointList[editorIndex].position"
placeholder='请选择' placeholder="请选择"
style='flex: 1' style="flex: 1"
@change='positionChange' @change="positionChange"
> >
<el-option <el-option
v-for='item in linePosition' v-for="item in linePosition"
:key='item.value' :key="item.id"
:label='item.label' :label="item.name"
:value='item.value' :value="item.id"
></el-option> ></el-option>
</el-select> </el-select>
<el-button class='ml20' type='danger' size='mini' @click='deletePoint' icon='el-icon-delete'> <el-button class="ml20" type="danger" @click="deletePoint" icon="el-icon-Delete">删除</el-button>
删除
</el-button>
</div> </div>
</el-form-item> </el-form-item>
</el-form> <el-form-item label=" ">
<el-form> <el-button type="primary" @click="addPoint">添加监测点</el-button>
<el-form-item label=''>
<el-button type='primary' @click='addPoint'>添加监测点</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<span class='dialog-footer'> <span class="dialog-footer">
<el-button @click='dialogVisible = false'>取消</el-button> <el-button @click="dialogVisible = false">取消</el-button>
<el-button type='primary' @click='submit'>确认</el-button> <el-button type="primary" @click="submit">确认</el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<script lang='ts' setup> <script lang="ts" setup>
import { ref, inject } from 'vue' import { ref, inject } from 'vue'
import { reactive } from 'vue' import { reactive } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
import { fullUrl } from '@/utils/common' import { fullUrl } from '@/utils/common'
import VueDraggableResizable from 'vue-draggable-resizable'
import { ElMessage } from 'element-plus'
import { addLineTemplate } from '@/api/cs-device-boot/lineTemplate'
defineOptions({ defineOptions({
name: 'govern/manage/gplot/popupEdit', name: 'govern/manage/gplot/popupEdit'
}) })
const tableStore = inject('tableStore') as TableStore const tableStore = inject('tableStore') as TableStore
const editorIndex = ref(-1) const editorIndex = ref(-1)
const pointList = ref([]) const pointList = ref<any[]>([])
const topoId = ref() const topoId = ref()
const imgUrl = ref('') const imgUrl = ref('')
const linePosition = useDictData().getBasicData('Line_Position') const linePosition = useDictData().getBasicData('Line_Position')
const dialogVisible = ref(false) const dialogVisible = ref(false)
const open = (data?: anyObj) => { const open = (data: anyObj) => {
pointList.value = data.fullUrl pointList.value = data.csLineTopologyTemplateVOList.map((item: any) => {
return {
name: linePosition.find(item2 => {
return item2.id == item.linePostion
})?.name,
position: item.linePostion,
width: 'auto',
height: 20,
top: item.lng,
left: item.lat
}
})
topoId.value = data.id topoId.value = data.id
imgUrl.value = fullUrl(data.filePath) imgUrl.value = fullUrl(data.filePath)
dialogVisible.value = true dialogVisible.value = true
} }
const textClick = () => {
const positionChange = (e: string) => {
pointList.value[editorIndex.value].name = linePosition.find((item: any) => {
return item.id == e
})?.name
} }
const positionChange = () => { const resize = (left: number, top: number) => {
} const dom = pointList.value[editorIndex.value]
const resize = (index, newRect) => { dom.left = left
if (!newRect) return dom.top = top
const dom = pointList.value[index]
dom.top = newRect.top
dom.left = newRect.left
} }
const addPoint = () => { const addPoint = () => {
pointList.value.push({
name: '监测点',
position: '',
width: 'auto',
height: 20,
top: 100,
left: 100
})
editorIndex.value = pointList.value.length - 1
} }
const deletePoint = () => { const deletePoint = () => {
pointList.value.splice(editorIndex.value, 1)
editorIndex.value = -1
} }
const submit = async () => { const submit = async () => {
let allSelect = pointList.value.some(item => item.position === '')
if (allSelect) {
ElMessage.warning('请完善所有监测点位置')
return
}
let arr = pointList.value.map(item => {
return {
linePostion: item.position,
lat: item.left,
lng: item.top,
topoId: topoId.value
}
})
addLineTemplate(arr).then(res => {
ElMessage.success('保存成功')
tableStore.index()
dialogVisible.value = false
})
} }
defineExpose({ open }) defineExpose({ open })
</script> </script>
<style lang='scss'> <style lang="scss">
@import 'vue-draggable-resizable/style.css';
.gplot-content { .gplot-content {
position: relative;
width: 375px; width: 375px;
object-fit: cover; object-fit: cover;
overflow: hidden;
.gplot-content-item {
border-color: transparent;
cursor: move;
&-active {
border-color: red;
}
}
} }
</style> </style>