diff --git a/resources/java/app/yjearth.jar b/resources/java/app/yjearth.jar index 7680891..cba2c46 100644 Binary files a/resources/java/app/yjearth.jar and b/resources/java/app/yjearth.jar differ diff --git a/src/renderer/src/api/ts/index.ts b/src/renderer/src/api/ts/index.ts index c3145df..895124f 100644 --- a/src/renderer/src/api/ts/index.ts +++ b/src/renderer/src/api/ts/index.ts @@ -20,4 +20,16 @@ export const TsApi = { data }) }, + addTsSource: async (data: any) => { + return await request.post({ + url: '/tsSource/add', + data + }) + }, + queryTsSource: async (data: any) => { + return await request.post({ + url: '/tsSource/query', + data + }) + }, } diff --git a/src/renderer/src/views/TS/cabin.vue b/src/renderer/src/views/TS/cabin.vue index 3a4cda1..2cac2b1 100644 --- a/src/renderer/src/views/TS/cabin.vue +++ b/src/renderer/src/views/TS/cabin.vue @@ -27,21 +27,83 @@ import {$changeComponentShow} from "../../utils/communication"; const {getSelectedNodes, cusSelectNode, getSameLevel, cusNodeIcon, nodeType} = useTreeNode() import {showRightMenuTs} from "./tree" +import {TsApi} from "../../api/ts"; +import {initMapData} from "./entity"; const rightMenuRef: any = ref() const treeObj = ref() //树形的实例 -const nodes: any = ref([]) +let zNodes: any = ref([])//树形结构数据 +let nodes: any = ref([])//选中的node节点 let input2 = ref('') onMounted(() => { - let data = [ - { - name: "88", - sourceType: "directory" + let formData = new FormData() + // let data = [] + formData.append('id', window["planId"]) + TsApi.queryTsSource(formData).then(async res => { + console.log('queryTsSource', res) + if (res.code == 200) { + for (let i = res.data.length - 1; i >= 0; i--) { + res.data[i].icon = await cusNodeIcon(res.data[i]); + } + zNodes.value = res.data + console.log("data", zNodes.value) + + treeObj.value = $.fn.zTree.init($(`#treeDemos`), setting, zNodes.value) + window.treeObj = treeObj.value } - ] - treeObj.value = $.fn.zTree.init($(`#treeDemos`), setting, data) - window.treeObj = treeObj.value + }) + }) +const initTreeCallBack = () => { + let arr = zNodes.value + let layerTypes = [ + "arcgisWximagery", + "arcgisBlueImagery", + "ArcgisLWImagery", + "gdlwImagery", + "gdwxImagery", + "gdslImagery", + "layer", + ]; + let layers: any = [] + for (let i = 0; i < arr.length; i++) { + if (arr[i].sourceType === 'directory') { + continue + } + let detail = JSON.parse(arr[i].detail || '{}') + let params = JSON.parse(arr[i].params || '{}') + if (!detail.name) { + detail.name = arr[i].sourceName + } + if (!detail.id) { + detail.id = arr[i].id + } + if (layerTypes.includes(arr[i].sourceType)) { + layers.push( + { + sourceType: arr[i].sourceType, + detail: {...detail, ...params} + } + ) + } else { + initMapData(arr[i].sourceType, {...detail, ...params}) + } + } + + layers.sort((obj1, obj2) => { + return obj1.detail.layerIndex - obj2.detail.layerIndex; + }); + if (window.earth_ts) { + for (let i = 0; i < layers.length; i++) { + // initMapData(layers[i].sourceType, layers[i].detail, null) + } + } +} +const onDblClick = (event: MouseEvent, treeId: string, treeNode: any) => { + let entityObject + entityObject = (window as any)._entityMap.get(treeNode.id) + entityObject.flyTo() +} const onClick = (event: MouseEvent, treeId: string, treeNode: any) => { console.log('selectNode', treeNode) @@ -131,20 +193,21 @@ const setting = { data: { key: { //zdatas数据中表示节点name的属性key - name: "name", - checked: "is_show", + name: "sourceName", + checked: "isShow", }, simpleData: { enable: true, idKey: "id", - pIdKey: "p_id", - nameKey: "name", + pIdKey: "parentId", + nameKey: "sourceName", }, }, callback: { onMouseDown: onMouseDown, onRightClick: rightClick, onClick: onClick, + onDblClick: onDblClick /* onClick: this.onClick, onDblClick: this.onDblClick, @@ -162,8 +225,11 @@ const setting = { beforeClick: this.zTreeBeforeClick, onCheck: this.onCheck*/ }, -} +} +defineExpose({ + initTreeCallBack +}) diff --git a/src/renderer/src/views/TS/element.vue b/src/renderer/src/views/TS/element.vue index dbe2330..1e975eb 100644 --- a/src/renderer/src/views/TS/element.vue +++ b/src/renderer/src/views/TS/element.vue @@ -55,8 +55,11 @@ import {ref, onMounted} from "vue"; import {Search} from '@element-plus/icons-vue' import {ModelApi} from "../../api/model"; import {GraphApi} from "../../api/graphLabel"; -import {addMapSource} from "./entity"; +import {addMapSource} from "./entity"; +import {useTreeNode} from "../components/tree/hooks/treeNode"; + +const {getSelectedNodes} = useTreeNode() const service = ref(localStorage.getItem('ip')) interface Tree { @@ -158,11 +161,15 @@ let getGraphTypeList = async () => { } // 添加标绘 let addMarker = (item) => { + let nodes = getSelectedNodes(window['treeObj']) console.log("绘制" + item.name) + console.log("获取选中的节点", nodes) + let id = new YJ.Tools().randomString() + let pId = nodes.length >= 1 ? nodes[0].id : -1 window.draw = new YJ.Draw[item.funName](earth_ts) window.draw.start((a, position) => { console.log(position) - addMapSource({id: 777, type: item.type, name: item.source_name, position}) + addMapSource({id, type: item.type, name: item.source_name, position, pId}) }) } diff --git a/src/renderer/src/views/TS/entity.ts b/src/renderer/src/views/TS/entity.ts index e6d779a..9b5c782 100644 --- a/src/renderer/src/views/TS/entity.ts +++ b/src/renderer/src/views/TS/entity.ts @@ -1,4 +1,9 @@ -export function addMapSource(option) { +import {TsApi} from "../../api/ts"; +import {useTreeNode} from '@/views/components/tree/hooks/treeNode' + +const {cusAddNodes, getSelectedNode} = useTreeNode() + +export function addMapSource(option, cb: any = null) { console.log("添加到地球上", option) let id = option.id || new YJ.Tools().randomString() let name = option.name @@ -24,5 +29,37 @@ export function addMapSource(option) { } console.log('options', options) // 进数据库 - // 上树 + let dbOption = { + "id": option.id, + "sourceName": name, + "sourceType": option.type, + "sourcePath": "", + "parentId": option.pId, + "treeIndex": 0, + "isShow": 1, + "detail": JSON.stringify(options) || '{}', + "params": "", + "planId": window['planId'] + } + console.log('dbOption', dbOption) + TsApi.addTsSource(dbOption).then(res => { + console.log("addTsSource", res) + cb && cb(res) + // 上树 + cusAddNodes(window.treeObj, getSelectedNode(window.treeObj), [dbOption], true) + }) +} + +export function initMapData(type, data) { + let entityObject + switch (type) { + case 'point': + console.log("ssssssss+++", window['earth_ts']) + entityObject = new YJ.Obj.BillboardObject(window['earth_ts'], data) + } + if (entityObject) { + if (entityObject.options.id) { + (window as any)._entityMap.set(entityObject.options.id, entityObject) + } + } } diff --git a/src/renderer/src/views/TS/list.vue b/src/renderer/src/views/TS/list.vue index c919b1d..55b79e0 100644 --- a/src/renderer/src/views/TS/list.vue +++ b/src/renderer/src/views/TS/list.vue @@ -151,7 +151,10 @@ const getList = (params = null) => { formData.append(paramsKey, params[paramsKey]) } } + } + formData.append('username', params["createdBy"]) + } TsApi.planList(formData).then(res => { console.log(res) @@ -175,7 +178,7 @@ const toTSEdit = (row) => { console.log("当前推演方案", row) router.push({ name: 'tsEdit', // 必须用 name 匹配路由,不能用 path - query: {id: 123, name: "战时推演", start_time: 946684800000} + query: {id: row.id, name: row.name, start_time: new Date(row.simulationStartTime).getTime()} }) } const delPlan = (id) => { diff --git a/src/renderer/src/views/TS/newPlan.vue b/src/renderer/src/views/TS/newPlan.vue index 77c0e18..5397815 100644 --- a/src/renderer/src/views/TS/newPlan.vue +++ b/src/renderer/src/views/TS/newPlan.vue @@ -11,28 +11,31 @@
- + - + - +
- 确定 + 确定 取消
@@ -45,30 +48,69 @@