|
@@ -1,436 +0,0 @@
|
|
|
-<!--
|
|
|
- * @Author: tengmingxue 1473375109@qq.com
|
|
|
- * @Date: 2023-06-26 10:43:18
|
|
|
- * @LastEditors: Xiax
|
|
|
- * @LastEditTime: 2023-07-07 17:34:42
|
|
|
- * @FilePath: \xld_web\src\views\SystemManage\component\MachineFlag.vue
|
|
|
- * @Description: 机组标签
|
|
|
--->
|
|
|
-
|
|
|
-<template>
|
|
|
- <div class="machine-flag">
|
|
|
- <div class="tree-panel">
|
|
|
- <a-directory-tree :replaceFields="replaceFields" :treeData="treeData" :showIcon="false" :defaultExpandAll="true"
|
|
|
- @select="nodeSelect" class="tree-content">
|
|
|
- <template #switcherIcon>
|
|
|
- <div class="self-switcher-icon"></div>
|
|
|
- </template>
|
|
|
- <template #title="item">
|
|
|
- <!-- 标签 -->
|
|
|
- <span class="self-tree-label">{{ item[replaceFields.title] }}</span>
|
|
|
- <!-- 存在位置信息 -->
|
|
|
- <span class="self-tree-location" v-if="Object.hasOwnProperty.call(item, 'loc') && item.loc"></span>
|
|
|
- </template>
|
|
|
- </a-directory-tree>
|
|
|
- </div>
|
|
|
- <div class="bottom-btn-group">
|
|
|
- <div class="btn" @click="getCameraInfo">拾取视角</div>
|
|
|
- <div class="btn" @click="getPosition">拾取点位</div>
|
|
|
- <div class="btn" @click="savePosition">保存</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
-import { defineComponent, reactive, toRefs, computed, onMounted, onBeforeUnmount, watch } from 'vue';
|
|
|
-import eventBus from '/@/utils/eventBus';
|
|
|
-import { message, notification } from 'ant-design-vue';
|
|
|
-// import { getUnitLabel, editUnitLabel } from '/@/api/sys/systemManage';
|
|
|
-
|
|
|
-export default defineComponent({
|
|
|
- name: 'MachineFlag',
|
|
|
- components: {},
|
|
|
- setup(props, { emit }) {
|
|
|
- // const selectedNode= reactive({})
|
|
|
- const data = reactive({
|
|
|
- current: 1,
|
|
|
- treeData: [],
|
|
|
- replaceFields: {
|
|
|
- children: 'children',
|
|
|
- title: 'unnm',
|
|
|
- key: 'uncd'
|
|
|
- },
|
|
|
- expandedKeys: ['0-0-0', '0-0-1'],
|
|
|
- autoExpandParent: true,
|
|
|
- checkedKeys: ['0-0-0'],
|
|
|
- selectedKeys: [],
|
|
|
- selectedNode: {},
|
|
|
- posInfo: {
|
|
|
- coord_easetype: "linear",
|
|
|
- attitude_easetype: "Linear",
|
|
|
- time: 4,
|
|
|
- speed_easetype: "linear"
|
|
|
- },//拾取的坐标点位信息
|
|
|
- });
|
|
|
- onMounted(() => {
|
|
|
- delAllPoi()
|
|
|
- getAllData()
|
|
|
- })
|
|
|
- //获取机组
|
|
|
- const getAllData = () => {
|
|
|
- getUnitLabel().then(res => {
|
|
|
- if (res.result.length) {
|
|
|
- data.treeData = toTree(res.result)
|
|
|
- } else {
|
|
|
- message.error('机组数据查询失败')
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- /**
|
|
|
- * 生成树结构
|
|
|
- */
|
|
|
- const toTree = (data) => {
|
|
|
- let result = [];
|
|
|
- let obj = {};
|
|
|
- data.forEach(item => {
|
|
|
- obj[item.uncd] = Object.assign(item, obj[item.uncd] || {});
|
|
|
- if (item.supcd && item.supcd != '-1') {
|
|
|
- let parent = obj[item.supcd] || {};
|
|
|
- parent.children = parent.children || [];
|
|
|
- parent.children.push(item);
|
|
|
- obj[item.supcd] = parent;
|
|
|
- } else {
|
|
|
- result.push(obj[item.uncd])
|
|
|
- }
|
|
|
- })
|
|
|
- return result;
|
|
|
- }
|
|
|
- const delAllPoi = () => {
|
|
|
- let jsondata = {
|
|
|
- "covering_type": "poi" //覆盖物类型, 详见下表
|
|
|
- }
|
|
|
- window.sysCloudRender.SuperAPI("RemoveAllCovering", jsondata, (status) => {
|
|
|
- console.log(status); //成功、失败回调
|
|
|
- })
|
|
|
- }
|
|
|
- /**
|
|
|
- * 点击树节点触发
|
|
|
- */
|
|
|
- const nodeSelect = (selectkey, { selectedNodes, node }) => {
|
|
|
- delAllPoi()
|
|
|
- window.sysCloudRender.SuperAPI("EndGetCoord")
|
|
|
- data.selectedNode = node.dataRef
|
|
|
- data.posInfo = {
|
|
|
- coord_easetype: "linear",
|
|
|
- attitude_easetype: "Linear",
|
|
|
- time: 4,
|
|
|
- speed_easetype: "linear"
|
|
|
- }
|
|
|
- //如果有点位则加载标签
|
|
|
- if (!data.selectedNode.loc) {
|
|
|
- message.info('该点位暂无位置')
|
|
|
- } else {
|
|
|
- try {
|
|
|
- let poiPos = JSON.parse(data.selectedNode.loc)
|
|
|
- data.posInfo = poiPos
|
|
|
- let poiInfo = {
|
|
|
- "id": data.selectedNode.id,
|
|
|
- "label": data.selectedNode.unnm, //POI title文本
|
|
|
- "coord_type": 0, //坐标类型(0:经纬度坐标, 1:cad坐标)
|
|
|
- "cad_mapkey": "", //CAD基准点Key值, 项目中约定
|
|
|
- "adaptive": false, //true:自适应大小;false:默认
|
|
|
- "coord": poiPos.coord, //POI点的坐标 lng,lat
|
|
|
- "coord_z": poiPos.coord_z, //高度(单位:米)
|
|
|
- "coord_z_type": 2, //坐标高度类型(0:相对3D世界表面;1:相对3D世界地面;2:相对3D世界海拔; 注:cad坐标无效)
|
|
|
- "always_show_label": true, //是否永远显示title, true:显示title(默认), false:不显示title
|
|
|
- "show_label_range": "0,2000", //POI点显示label的范围(单位:米, 范围最小、最大距离; 在此范围内显示, 超出范围隐藏; 注意:always_show_label属性优先于此属性)
|
|
|
- "umg_type": "default", //此POI所使用的UI模板类型(default: 带线的默认POI UI样式, default_noline:不带线的POI UI样式, 项目中约定)
|
|
|
- "sort_order": true, //是否自动遮挡排序
|
|
|
- "animation_type": "bounce", //动画类型(bounce:弹出式; stretch:伸缩式; wipe:展开式)
|
|
|
- "duration_time": 0.5 //规定完成动画所花费的时间(单位:秒)
|
|
|
- }
|
|
|
- window.sysCloudRender.SuperAPI("AddPOI", poiInfo, (status) => {
|
|
|
- console.log('打点成功');
|
|
|
- })
|
|
|
- let jsondata = {
|
|
|
- "coord_type": 0, //坐标类型(0:经纬度坐标, 1:cad坐标)
|
|
|
- "cad_mapkey": "", //CAD基准点Key值, 项目中约定
|
|
|
- "coord_z": poiPos.r_coord_z, //海拔高度(单位:米)
|
|
|
- "center_coord": poiPos.r_coord, //中心点的坐标 lng,lat
|
|
|
- "arm_distance": poiPos.arm_distance, //镜头距中心点距离(单位:米)
|
|
|
- "pitch": poiPos.pitch, //镜头俯仰角(5~89)
|
|
|
- "yaw": poiPos.yaw, //镜头偏航角(0正北, 0~359)
|
|
|
- "fly": true //true: 飞行动画(有一个短暂飞行动画,并按照arm_distance,pitch,yaw设置镜头);
|
|
|
- }
|
|
|
- window.sysCloudRender.SuperAPI("SetCameraInfo", jsondata, (status) => {
|
|
|
- console.log(status); //成功、失败回调
|
|
|
- })
|
|
|
- } catch {
|
|
|
- message.error('点位信息不正确,请重新拾取')
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- const rotateWordTree = (e) => {
|
|
|
- let translateYFront = e.target.style.transform;
|
|
|
- if (translateYFront == 'rotate(0deg)' && !translateYFront) {
|
|
|
- e.target.style.transform = 'rotate(90deg)';
|
|
|
- } else {
|
|
|
- e.target.style.transform = 'rotate(0deg)';
|
|
|
- }
|
|
|
- };
|
|
|
- /**
|
|
|
- * 拾取视角
|
|
|
- */
|
|
|
- const getCameraInfo = () => {
|
|
|
- window.sysCloudRender.SuperAPI("EndGetCoord")
|
|
|
- delAllPoi()
|
|
|
- if (data.selectedNode.id) {
|
|
|
- //获取视角信息
|
|
|
- let cameraJsonData = {
|
|
|
- "coord_type": 0, //坐标类型(0:经纬度坐标, 1:cad坐标)
|
|
|
- "cad_mapkey": "" //CAD基准点Key值, 项目中约定
|
|
|
- }
|
|
|
- window.sysCloudRender.SuperAPI("GetCameraInfo", cameraJsonData, (e) => {
|
|
|
- const cameraObject =
|
|
|
- typeof e === 'object' ? JSON.parse(JSON.stringify(e)) : JSON.parse(e);
|
|
|
- data.posInfo.r_coord = cameraObject.args.center_coord;
|
|
|
- data.posInfo.r_coord_z = cameraObject.args.coord_z;
|
|
|
- data.posInfo.arm_distance = cameraObject.args.arm_distance;
|
|
|
- data.posInfo.yaw = cameraObject.args.yaw;
|
|
|
- data.posInfo.pitch = cameraObject.args.pitch;
|
|
|
- message.success('拾取视角成功')
|
|
|
- console.log(data.posInfo);
|
|
|
- })
|
|
|
- }
|
|
|
- else {
|
|
|
- message.error('请先选择机组节点')
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 拾取点位
|
|
|
- */
|
|
|
- const getPosition = () => {
|
|
|
- window.sysCloudRender.SuperAPI("EndGetCoord")
|
|
|
- delAllPoi()
|
|
|
- if (data.selectedNode.id) {
|
|
|
- // 弹出取点说明
|
|
|
- notification['info']({
|
|
|
- message: '取点提示',
|
|
|
- description: '单击拾取点位,拾取成功后自动结束,可使用右键或滚轮等方式移动场景选取合适的坐标点',
|
|
|
- });
|
|
|
- // 此处开始拾取坐标
|
|
|
- //初始化取点工具
|
|
|
- let jsondata = {
|
|
|
- coord_type: 0, //坐标类型(0:经纬度坐标, 1:cad坐标)
|
|
|
- cad_mapkey: "", //CAD基准点Key值, 项目中约定
|
|
|
- coord_z_type: 2, //坐标高度类型(0:相对3D世界表面;1:相对3D世界地面;2:相对3D世界海拔; 注:cad坐标无效)
|
|
|
- coordinate_show: false, //true:显示; false:隐藏 (显隐坐标信息,默认隐藏)
|
|
|
- icon_show: true, //true:显示取点标记; false:隐藏取点标记
|
|
|
- };
|
|
|
- //这注册时间时候所有的都会存储起来一起输出,所以每一次取最后一个
|
|
|
- window.sysCloudRender.SuperAPI('StartGetCoord', jsondata, (resData) => {
|
|
|
- const jsonObject =
|
|
|
- typeof resData === 'object' ? JSON.parse(JSON.stringify(resData)) : JSON.parse(resData);
|
|
|
- if (jsonObject.success && jsonObject.coord_result.length > 0) {
|
|
|
- //获取点成功
|
|
|
- const { coord, coord_z } = jsonObject.coord_result[jsonObject.coord_result.length - 1];
|
|
|
- data.posInfo.coord = coord;
|
|
|
- data.posInfo.coord_z = coord_z;
|
|
|
- //加标签
|
|
|
- let poiInfo = {
|
|
|
- "id": data.selectedNode.id,
|
|
|
- "label": data.selectedNode.unnm, //POI title文本
|
|
|
- "coord_type": 0, //坐标类型(0:经纬度坐标, 1:cad坐标)
|
|
|
- "cad_mapkey": "", //CAD基准点Key值, 项目中约定
|
|
|
- "adaptive": false, //true:自适应大小;false:默认
|
|
|
- "coord": coord, //POI点的坐标 lng,lat
|
|
|
- "coord_z": coord_z, //高度(单位:米)
|
|
|
- "coord_z_type": 2, //坐标高度类型(0:相对3D世界表面;1:相对3D世界地面;2:相对3D世界海拔; 注:cad坐标无效)
|
|
|
- "always_show_label": true, //是否永远显示title, true:显示title(默认), false:不显示title
|
|
|
- "show_label_range": "0,2000", //POI点显示label的范围(单位:米, 范围最小、最大距离; 在此范围内显示, 超出范围隐藏; 注意:always_show_label属性优先于此属性)
|
|
|
- "umg_type": "default", //此POI所使用的UI模板类型(default: 带线的默认POI UI样式, default_noline:不带线的POI UI样式, 项目中约定)
|
|
|
- "sort_order": true, //是否自动遮挡排序
|
|
|
- "animation_type": "bounce", //动画类型(bounce:弹出式; stretch:伸缩式; wipe:展开式)
|
|
|
- "duration_time": 0.5 //规定完成动画所花费的时间(单位:秒)
|
|
|
- }
|
|
|
- window.sysCloudRender.SuperAPI("AddPOI", poiInfo, (status) => {
|
|
|
- console.log(status); //成功、失败回调
|
|
|
- })
|
|
|
- message.success('拾取点位成功')
|
|
|
- window.sysCloudRender.SuperAPI("EndGetCoord")
|
|
|
- console.log(data.posInfo);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- else {
|
|
|
- message.error('请先选择机组节点')
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 保存坐标点和视角
|
|
|
- */
|
|
|
- const savePosition = () => {
|
|
|
- //此处调用更新数据接口
|
|
|
- //选中子节点的id,使用此参数去修改
|
|
|
- if (data.posInfo.coord && data.posInfo.coord_z) {
|
|
|
- let params = {
|
|
|
- id: data.selectedNode.id,
|
|
|
- loc: JSON.stringify(data.posInfo)
|
|
|
- }
|
|
|
- editUnitLabel(params).then(res => {
|
|
|
- if (res.result) {
|
|
|
- message.success('保存成功')
|
|
|
- data.posInfo = {
|
|
|
- coord_easetype: "linear",
|
|
|
- attitude_easetype: "Linear",
|
|
|
- time: 4,
|
|
|
- speed_easetype: "linear"
|
|
|
- }
|
|
|
- let jsondata = {
|
|
|
- "id": data.selectedNode.id, //覆盖物id
|
|
|
- "covering_type": "poi" //覆盖物类型, 详见下表
|
|
|
- }
|
|
|
- window.sysCloudRender.SuperAPI("RemoveCovering", jsondata, (status) => {
|
|
|
- console.log(status); //成功、失败回调
|
|
|
- })
|
|
|
- //获取机组
|
|
|
- getAllData()
|
|
|
- } else {
|
|
|
- message.error('保存失败,请检查网络等问题!')
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- message.error('请先拾取坐标')
|
|
|
- }
|
|
|
- }
|
|
|
- onBeforeUnmount(() => {
|
|
|
- delAllPoi()
|
|
|
- })
|
|
|
- return {
|
|
|
- ...toRefs(data),
|
|
|
- rotateWordTree,
|
|
|
- nodeSelect,
|
|
|
- getCameraInfo,
|
|
|
- getPosition,
|
|
|
- savePosition
|
|
|
- };
|
|
|
- },
|
|
|
-});
|
|
|
-</script>
|
|
|
-
|
|
|
-<style lang="less" scoped>
|
|
|
-.machine-flag {
|
|
|
- position: relative;
|
|
|
- height: 100%;
|
|
|
- width: 260px;
|
|
|
- color: #feffff;
|
|
|
- // background: rgba(3, 49, 79, 0.3);
|
|
|
- // background: rgb(3, 49, 79);
|
|
|
- box-shadow: inset 0px 0px 3px 3px rgba(115, 183, 209, 0.5);
|
|
|
-
|
|
|
- .tree-panel {
|
|
|
- height: auto;
|
|
|
- width: 100%;
|
|
|
- padding: 20px;
|
|
|
- height: calc(100% - 60px);
|
|
|
-
|
|
|
- .tree-content {
|
|
|
- ::v-deep .ant-tree-switcher_close {
|
|
|
- .ant-tree-switcher-icon {
|
|
|
- height: 100%;
|
|
|
- width: 100%;
|
|
|
- background: url('/@/assets/images/button/close.png') no-repeat;
|
|
|
- background-size: 100% 100%;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ::v-deep .ant-tree-switcher_open {
|
|
|
- .ant-tree-switcher-icon {
|
|
|
- height: 100%;
|
|
|
- width: 100%;
|
|
|
- background: url('/@/assets/images/button/open.png') no-repeat;
|
|
|
- background-size: 100% 100%;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ::v-deep .ant-tree-treenode-selected {
|
|
|
- .ant-tree-node-content-wrapper .ant-tree-node-content-wrapper-normal .ant-tree-node-selected::before {
|
|
|
- background: linear-gradient(90deg,
|
|
|
- rgba(22, 192, 255, 0.4) 0%,
|
|
|
- rgba(22, 192, 255, 0) 100%) !important;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ::v-deep .ant-tree-treenode-selected {
|
|
|
- .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-normal.ant-tree-node-selected::before {
|
|
|
- background: linear-gradient(90deg,
|
|
|
- rgba(22, 192, 255, 0.4) 0%,
|
|
|
- rgba(22, 192, 255, 0) 100%) !important;
|
|
|
- }
|
|
|
-
|
|
|
- .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-open.ant-tree-node-selected::before {
|
|
|
- background: linear-gradient(90deg,
|
|
|
- rgba(22, 192, 255, 0.4) 0%,
|
|
|
- rgba(22, 192, 255, 0) 100%) !important;
|
|
|
- }
|
|
|
-
|
|
|
- .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-close.ant-tree-node-selected::before {
|
|
|
- background: linear-gradient(90deg,
|
|
|
- rgba(22, 192, 255, 0.4) 0%,
|
|
|
- rgba(22, 192, 255, 0) 100%) !important;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ::v-deep .ant-tree-node-content-wrapper {
|
|
|
- .ant-tree-title {
|
|
|
- position: inherit !important;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- width: auto;
|
|
|
-
|
|
|
- .self-tree-label {
|
|
|
- display: flex;
|
|
|
- height: 22px;
|
|
|
- }
|
|
|
-
|
|
|
- .self-tree-location {
|
|
|
- display: flex;
|
|
|
- height: 22px;
|
|
|
- width: 26px;
|
|
|
- background: url('/@/assets/images/button/select.png') no-repeat;
|
|
|
- background-size: 100% 100%;
|
|
|
- margin-left: 10px;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .bottom-btn-group {
|
|
|
- position: absolute;
|
|
|
- display: flex;
|
|
|
- bottom: 10px;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
- height: 40px;
|
|
|
- width: 100%;
|
|
|
- padding:0 10px;
|
|
|
-
|
|
|
- .btn {
|
|
|
- margin-right:10px;
|
|
|
- height: 40px;
|
|
|
- line-height: 40px;
|
|
|
- width: 100px;
|
|
|
- text-align: center;
|
|
|
- font-size: 14px;
|
|
|
- font-family: Source Han Sans CN;
|
|
|
- font-weight: 500;
|
|
|
- color: rgb(4, 236, 239);
|
|
|
- background: rgba(3, 49, 79, 0.3);
|
|
|
- box-shadow: inset 0px 0px 3px 3px rgba(115, 183, 209, 0.5);
|
|
|
- cursor: pointer;
|
|
|
- &:last-child{
|
|
|
- margin-right:0;
|
|
|
- }
|
|
|
-
|
|
|
- &:hover {
|
|
|
- color: rgba(4, 236, 239, 0.8);
|
|
|
- box-shadow: inset 0px 0px 3px 3px rgba(36, 255, 252, 0.8);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|
|
|
-
|