diff --git a/public.zip b/public.zip deleted file mode 100644 index 8f8b8085b..000000000 Binary files a/public.zip and /dev/null differ diff --git a/src/api/Daodan/index.js b/src/api/Daodan/index.js index 4c66267a2..64a783ea0 100644 --- a/src/api/Daodan/index.js +++ b/src/api/Daodan/index.js @@ -7,3 +7,19 @@ export function getDaodanTree() { method: 'get', }) } + +export function updateDDManualConfigTrajInfo(data) { + return request({ + url: `${baseUrl}/dd/gjInfo`, + method: 'PUT', + data, + }) +} + +export function uploadDDSTKFile(data) { + return request({ + url: `${baseUrl}/dd/upload-stk`, + method: 'POST', + data, + }) +} diff --git a/src/views/Daodan/components/TestConfig.jsx b/src/views/Daodan/components/TestConfig.jsx index 89ed89411..0d0084c5e 100644 --- a/src/views/Daodan/components/TestConfig.jsx +++ b/src/views/Daodan/components/TestConfig.jsx @@ -8,29 +8,28 @@ import { useTestConfig } from './hooks/testHooks' const panels = ['手动配置', 'STK轨迹文件配置'] export default defineComponent({ setup() { - const { daodanData, showOrHideDdConfig } = useDaodan() + const { daodanData, showOrHideDdConfig, getDaodanTreeData } = useDaodan() const { trajData, boosterList, interceptData, loadStoreData, + loadData, saveDataToStore, - addIntercept, - initDaodan, + saveDataToBackend, } = useTestConfig() watch(daodanData, newval => { - loadStoreData() - // console.log(newval, '-=----') + // loadStoreData() + loadData() + // console.log(daodanData.value, 'newval') }) - const name = ref('手动配置') - // const handleClose = () => {} - const confirm = () => { - // initDaodan() - saveDataToStore() + // saveDataToStore() + saveDataToBackend() showOrHideDdConfig({}) + getDaodanTreeData() } const removeIntercept = id => { @@ -96,11 +95,37 @@ export default defineComponent({ ) : ( <> - - - - - + + {['一级助推器', '二级助推器', '三级助推器'].map( + (title, index) => ( + + ) + )} + )} diff --git a/src/views/Daodan/components/TrajTable.jsx b/src/views/Daodan/components/TrajTable.jsx index c5def46f4..b9f935b57 100644 --- a/src/views/Daodan/components/TrajTable.jsx +++ b/src/views/Daodan/components/TrajTable.jsx @@ -125,8 +125,10 @@ export default defineComponent({ title: getTitle('time'), key: 'time', render(row) { - return ( + return row.name !== '最高点' ? ( + ) : ( + '-' ) }, }, @@ -146,18 +148,18 @@ export default defineComponent({ return dict[key] || key } - const dialog = useDialog() - const remove = () => { - dialog.warning({ - title: '删除拦截', - content: '确定删除该拦截吗?', - positiveText: '确定', - negativeText: '取消', - onPositiveClick: () => { - emit('removeIntercept', dataId.value) - }, - }) - } + // const dialog = useDialog() + // const remove = () => { + // dialog.warning({ + // title: '删除拦截', + // content: '确定删除该拦截吗?', + // positiveText: '确定', + // negativeText: '取消', + // onPositiveClick: () => { + // emit('removeIntercept', dataId.value) + // }, + // }) + // } const columnsFilter = computed(() => { if (props.title === '轨迹点') { diff --git a/src/views/Daodan/components/TrajUpload.jsx b/src/views/Daodan/components/TrajUpload.jsx index 9f141f411..69b82319d 100644 --- a/src/views/Daodan/components/TrajUpload.jsx +++ b/src/views/Daodan/components/TrajUpload.jsx @@ -1,4 +1,5 @@ -import { NUpload, NButton } from 'naive-ui' +import { NUpload, NButton, NDataTable } from 'naive-ui' +import { time2Format } from '@/utils/date' export default defineComponent({ name: 'TrajUpload', @@ -7,17 +8,82 @@ export default defineComponent({ type: String, required: true, }, + ddData: { + type: Object, + default: () => ({}), + }, + type: { + type: String, + default: '', + }, + tableData: { + type: Array, + default: () => [], + }, }, setup(props, { emit }) { + const columns = [ + { + title: '序号', + key: 'index', + width: 80, + render: (row, rowIndex) => { + return rowIndex + 1 + }, + }, + { + title: '经度', + key: 'lon', + width: 120, + }, + { + title: '纬度', + key: 'lat', + }, + { + title: '高度', + key: 'alt', + }, + { + title: '时间', + key: 'time', + render: row => { + return time2Format(row.time) + }, + // width: 120, + }, + ] + + const tableData = ref([]) + + function handleFinish({ file, event }) { + console.log(JSON.parse(event.target.response)) + const { data } = JSON.parse(event.target.response) + + tableData.value = data.stkInfo[props.ddData.id] + } return () => ( <>
{props.title}
STK 文件
- + 上传文件
+
+ 0 ? props.tableData : tableData.value + } + > +
) }, diff --git a/src/views/Daodan/components/hooks copy/testHooks.jsx b/src/views/Daodan/components/hooks copy/testHooks.jsx index 53c1a0847..937f721af 100644 --- a/src/views/Daodan/components/hooks copy/testHooks.jsx +++ b/src/views/Daodan/components/hooks copy/testHooks.jsx @@ -246,7 +246,7 @@ function addDaodan(trajData, type = 0) { let minTime = 0 function initDaodan() { - saveDataToStore() + // saveDataToStore() minTime = getMinTime([ ...toRaw(trajData.value.data), // ...toRaw(interceptData.value.map(item => toRaw(item.data))).flat(Infinity), diff --git a/src/views/Daodan/components/hooks/ddPlayHooks.jsx b/src/views/Daodan/components/hooks/ddPlayHooks.jsx index 32818ae57..c3bc0337e 100644 --- a/src/views/Daodan/components/hooks/ddPlayHooks.jsx +++ b/src/views/Daodan/components/hooks/ddPlayHooks.jsx @@ -60,8 +60,7 @@ export function useDDPlay({ function computePath(daodan, trajData, type) { const { id, data: ddTrajData } = trajData - ddTrajData[1].lon = (ddTrajData[0].lon + ddTrajData[2].lon) / 2 - ddTrajData[1].lat = (ddTrajData[0].lat + ddTrajData[2].lat) / 2 + const points = ddTrajData.map(item => { const { time, lon, lat, alt } = item @@ -691,7 +690,7 @@ export function useDDPlay({ position: positionProperty, polyline: { positions: positionList, - width: 8, + width: 16, material: new Cesium.PolylineGlowMaterialProperty({ glowPower: 0.1, color: type @@ -726,6 +725,8 @@ export function useDDPlay({ return { entities: [pathLine, ddMap, boosterMap, interceptMap], + addDaodan, + removeAllEntity, } } diff --git a/src/views/Daodan/components/hooks/testHooks.jsx b/src/views/Daodan/components/hooks/testHooks.jsx index 98b1b9af8..319b369be 100644 --- a/src/views/Daodan/components/hooks/testHooks.jsx +++ b/src/views/Daodan/components/hooks/testHooks.jsx @@ -3,8 +3,7 @@ import { useDaodan } from '../../ddHooks' import { cartesian32LonLat } from '@/utils/pos' import { generateId } from '@/utils/id' import store from 'store2' -import { useDDPlay } from './ddPlayHooks' -// import { useDaodan } from '../../ddHooks' +import { updateDDManualConfigTrajInfo } from '@/api/daodan' const trajData = ref({ id: 'dd', @@ -21,7 +20,7 @@ const trajData = ref({ lon: null, lat: null, alt: 2000000, - time: 1183135280000, + time: null, }, { name: '落点', @@ -82,14 +81,29 @@ export function useTestConfig() { boosterList, interceptData, loadStoreData, + loadData, addIntercept, handleClickPoint, saveDataToStore, - addCheckedDaodan, - initDaodan, + saveDataToBackend, } } +async function saveDataToBackend() { + const { id, name, country } = toRaw(daodanData.value) + + const { data, msg } = await updateDDManualConfigTrajInfo({ + id, + gjInfo: { + id, + name, + country, + trajData: trajData.value, + boosterList: boosterList.value, + interceptData: interceptData.value, + }, + }) +} function saveDataToStore() { // test() const daodanDataRaw = toRaw(daodanData.value) @@ -118,6 +132,15 @@ function loadStoreData() { } } +function loadData() { + const daodanDataRaw = toRaw(daodanData.value) + const data = daodanDataRaw.gjInfo + if (data) { + trajData.value = data.trajData + interceptData.value = data.interceptData + } +} + function addIntercept() { // 添加拦截d interceptData.value.push({ @@ -163,77 +186,3 @@ function handleClickPoint(rowData) { rowData.lat = position[1] }, Cesium.ScreenSpaceEventType.LEFT_CLICK) } - -// function initDaodan() { -// saveDataToStore() -// const minTime = getMinTime([ -// ...toRaw(trajData.value.data), -// // ...toRaw(interceptData.value.map(item => toRaw(item.data))).flat(Infinity), -// ]) -// // console.log(minTime) -// const { addDaodan } = useDDPlay({ -// ddData: { -// ...toRaw(daodanData.value), -// trajData: trajData.value, -// boosterList: boosterList.value, -// interceptData: interceptData.value, -// }, -// startTimeStampOfAnimation: Date.now(), -// isAniCalcBasedOnCurrentTime: true, -// minTime: minTime, -// }) - -// addDaodan() -// } - -function addCheckedDaodan(ids) { - const storeDaodanData = store.get('daodanData') - if (ids.length > 0 && storeDaodanData) { - let daodanList = Object.values(storeDaodanData).filter(daodan => { - return ids.includes(daodan.id) - }) - daodanList.forEach(item => { - initDaodan(item) - }) - } -} - -function initDaodan(daodanData, isAniCalcBasedOnCurrentTime = true) { - const { trajData } = daodanData - const minTime = getMinTime([...trajData.data]) - const { entities, addDaodan } = useDDPlay({ - ddData: { - ...daodanData, - }, - startTimeStampOfAnimation: Date.now(), - isAniCalcBasedOnCurrentTime, - minTime: minTime, - }) - - addDaodan() - - setInterval(() => { - console.log('entities', entities) - }, 2000) -} - -function getMinTime(data) { - let minTime = Infinity - data.forEach(item => { - minTime = Math.min(item.time, minTime) - }) - return minTime -} - -function dianhuo(ddPrimitive) { - modelAnimationController({ - primitive: ddPrimitive, - type: 'BoosterFlames Size', - initVal: 0, - maxVal: 1, - step: 0.1, - fn: () => { - console.log('%c点火', 'color: red;font-size: 20px;border: 1px solid red') - }, - }) -} diff --git a/src/views/Daodan/ddHooks.jsx b/src/views/Daodan/ddHooks.jsx index 3ed580810..44e9bb1d7 100644 --- a/src/views/Daodan/ddHooks.jsx +++ b/src/views/Daodan/ddHooks.jsx @@ -1,6 +1,8 @@ import { onMounted, ref, watch } from 'vue' import { getDaodanTree } from '@/api/Daodan' -import store from 'store2' +import { useTree } from '@/utils/tree' +import { difference } from 'lodash' +import { useDDPlay } from './components/hooks/ddPlayHooks' // import { useTestConfig } from './components/hooks/testHooks' const isLoading = ref(false) @@ -19,12 +21,87 @@ async function getDaodanTreeData() { const daodanRes = await getDaodanTree() const { code, data } = daodanRes if (code === '200') { - // console.log(data, 'baseRes') treeData.value = [data] } isLoading.value = false } +const { filterTreeNodeByField } = useTree() +const daodanMap = new Map() +function addCheckedDaodan(ids) { + const addIds = difference(ids, [...daodanMap.keys()]) + const removeIds = difference([...daodanMap.keys()], ids) + if (addIds.length > 0) { + const nodes = filterTreeNodeByField({ + treeData: treeData.value, + params: addIds, + paramName: 'dataId', + }) + + nodes.forEach(node => { + console.log(node.data, '-----') + node?.data?.gjInfo && initDaodan(node.data.gjInfo) + }) + // console.log(nodes, 'nodes------') + + // nodes.forEach(node => { + // const { + // data: { stkInfo }, + // } = node + // Object.keys(stkInfo).forEach(key => { + // const color = Cesium.Color.fromRandom().withAlpha(1) + // stkInfo[key].forEach(item => { + // viewer.entities.add({ + // position: Cesium.Cartesian3.fromDegrees( + // item.lon, + // item.lat, + // item.alt + // ), + // point: { + // color: color, + // pixelSize: 5, + // }, + // }) + // }) + // }) + // }) + } + if (removeIds.length > 0) { + // removeDaodan(removeIds) + removeIds.forEach(id => { + daodanMap.get(removeIds[0])?.removeAllEntity() + }) + } +} + +function initDaodan(daodanData, isAniCalcBasedOnCurrentTime = true) { + const { trajData } = daodanData + const { data } = trajData + data[1].lon = (data[0].lon + data[2].lon) / 2 + data[1].lat = (data[0].lat + data[2].lat) / 2 + data[1].time = (data[2].time - data[0].time) / 2 + data[0].time + + const minTime = getMinTime(data) + console.log(minTime, data) + const daodanPlay = useDDPlay({ + ddData: { + ...daodanData, + }, + startTimeStampOfAnimation: Date.now(), + isAniCalcBasedOnCurrentTime, + minTime: minTime, + }) + daodanMap.set(daodanData.id, daodanPlay) + daodanPlay.addDaodan() +} + +function getMinTime(data) { + let minTime = Infinity + data.forEach(item => { + minTime = Math.min(item.time, minTime) + }) + return minTime +} export function useDaodan() { return { showDdConfigCom, @@ -33,5 +110,6 @@ export function useDaodan() { isLoading, daodanData, treeData, + addCheckedDaodan, } } diff --git a/src/views/Daodan/index.jsx b/src/views/Daodan/index.jsx index ebf537318..7cd0dd629 100644 --- a/src/views/Daodan/index.jsx +++ b/src/views/Daodan/index.jsx @@ -6,10 +6,15 @@ import { onMounted } from 'vue' export default defineComponent({ setup() { - const { treeData, isLoading, showOrHideDdConfig, getDaodanTreeData } = - useDaodan() + const { + treeData, + isLoading, + showOrHideDdConfig, + getDaodanTreeData, + addCheckedDaodan, + } = useDaodan() - const { addCheckedDaodan } = useTestConfig() + // const { addCheckedDaodan } = useTestConfig() onMounted(() => { getDaodanTreeData() diff --git a/src/views/Earth/index.vue b/src/views/Earth/index.vue index 5ef88e966..856bdf6ca 100644 --- a/src/views/Earth/index.vue +++ b/src/views/Earth/index.vue @@ -52,18 +52,18 @@ onMounted(async () => { viewer.scene.postProcessStages.fxaa.enabled = true viewer.scene.skyBox = new Cesium.SkyBox({ sources: { - positiveX: 'GV/resources/theme/skyBox/PositiveX.jpg', - negativeX: 'GV/resources/theme/skyBox/NegativeX.jpg', - positiveY: 'GV/resources/theme/skyBox/PositiveY.jpg', - negativeY: 'GV/resources/theme/skyBox/NegativeY.jpg', - positiveZ: 'GV/resources/theme/skyBox/PositiveZ.jpg', - negativeZ: 'GV/resources/theme/skyBox/NegativeZ.jpg', - // positiveX: './images/skybox/skyCube2k_px.jpg', - // negativeX: './images/skybox/skyCube2k_mx.jpg', - // positiveY: './images/skybox/skyCube2k_py.jpg', - // negativeY: './images/skybox/skyCube2k_my.jpg', - // positiveZ: './images/skybox/skyCube2k_pz.jpg', - // negativeZ: './images/skybox/skyCube2k_mz.jpg', + // positiveX: 'GV/resources/theme/skyBox/PositiveX.jpg', + // negativeX: 'GV/resources/theme/skyBox/NegativeX.jpg', + // positiveY: 'GV/resources/theme/skyBox/PositiveY.jpg', + // negativeY: 'GV/resources/theme/skyBox/NegativeY.jpg', + // positiveZ: 'GV/resources/theme/skyBox/PositiveZ.jpg', + // negativeZ: 'GV/resources/theme/skyBox/NegativeZ.jpg', + positiveX: './images/skybox/skyCube2k_px.jpg', + negativeX: './images/skybox/skyCube2k_mx.jpg', + positiveY: './images/skybox/skyCube2k_py.jpg', + negativeY: './images/skybox/skyCube2k_my.jpg', + positiveZ: './images/skybox/skyCube2k_pz.jpg', + negativeZ: './images/skybox/skyCube2k_mz.jpg', }, })