From 328700ec8946f8a7f17c1bc68e0a90e5eb5c17d5 Mon Sep 17 00:00:00 2001 From: gcw_IJ7DAiVL Date: Fri, 10 Oct 2025 18:31:44 +0800 Subject: [PATCH] fix --- config.ini => public/config.ini | 2 +- src/views/home/home.vue | 74 +++++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 24 deletions(-) rename config.ini => public/config.ini (84%) diff --git a/config.ini b/public/config.ini similarity index 84% rename from config.ini rename to public/config.ini index 4bcabac..b55b302 100644 --- a/config.ini +++ b/public/config.ini @@ -1,5 +1,5 @@ [http] -port=8081 +port=8083 address=127.0.0.1 [title] diff --git a/src/views/home/home.vue b/src/views/home/home.vue index 5d31ebc..50cf6b1 100644 --- a/src/views/home/home.vue +++ b/src/views/home/home.vue @@ -252,7 +252,7 @@ 新增 新增 {}) }, async initMap() { - const parsedData = iniParser.parse(configIni); this.viewer = new window.mars3d.Map( 'map', { @@ -1018,18 +1015,21 @@ export default { }, // 保存列表数据 suerCofirm() { - const parsedData = iniParser.parse(configIni); - axios.post(`http://${parsedData.http.address}:${parsedData.http.port}/api/equpment`, JSON.stringify(this.tableData), { - headers: { - 'Authorization': 'Bearer your_token_here', - 'Content-Type': 'application/json' - } - }) - .then(response => { - this.$message.success('保存成功') - }) - .catch(error => { - }); + fetch('./config.ini') + .then(response => response.text()) + .then(text => { + const parsedData = iniParser.parse(text); + axios.post(`http://${parsedData.http.address}:${parsedData.http.port}/api/equpment`, JSON.stringify(this.tableData), { + headers: { + 'Content-Type': 'application/json' + } + }) + .then(response => { + this.$message.success('保存成功') + }) + .catch(error => { + }); + }); }, // 导入json文件 triggerFileUpload() { @@ -2393,18 +2393,19 @@ export default { handleExport() { const hideData = [] if (this.factoriesWithVehicles.length > 0) { - this.factoriesWithVehicles.forEach((item) => [ + this.factoriesWithVehicles.forEach((item, index) => [ hideData.push({ FID_1: item.options.style.properties.FID_1, vehiclesNum: (item.vehicles.map(e => e.name)).join(','), - area: item.area.toFixed(2) + area: item.area.toFixed(2), + id: index }) ]) } this.hideData = JSON.parse(JSON.stringify(hideData)) const routeData = [] if (this.infoList.length > 0) { - this.infoList.forEach((item) => [ + this.infoList.forEach((item, index) => [ routeData.push({ 编码: item.编码, 名称: item.名称, @@ -2413,6 +2414,7 @@ export default { 载重吨: item.载重吨, 水深: item.水深, 净空高: item.净空高, + id: index }) ]) } @@ -2430,8 +2432,14 @@ export default { 水深: null, 净空高: null, editing: true, + id: this.routeData.length + 1 }; this.routeData.push(newRow); + // 等待数据更新后滚动到新增的行 + setTimeout(() => { + this.$refs.routeTable.refreshScroll(); // 刷新滚动 + this.$refs.routeTable.scrollToRow(newRow, 'id'); + }, 50); }, handleRouteDelete(row) { const index = this.routeData.findIndex(item => item.id === row.id); @@ -2454,6 +2462,11 @@ export default { editing: true, }; this.hideData.push(newRow); + // 等待数据更新后滚动到新增的行 + setTimeout(() => { + this.$refs.hideTable.refreshScroll(); // 刷新滚动 + this.$refs.hideTable.scrollToRow(newRow, 'id'); + }, 50); }, handleHideDelete(row) { const index = this.hideData.findIndex(item => item.id === row.id); @@ -2483,9 +2496,24 @@ export default { hideData: this.hideData, routeData: this.routeData, }, null, 2) - const blob = new Blob([info], { type: 'application/json;charset=utf-8' }) - saveAs(blob, '机动路线规划.json') - this.closeExport() + // const blob = new Blob([info], { type: 'application/json;charset=utf-8' }) + // saveAs(blob, '机动路线规划.json') + // this.closeExport() + fetch('./config.ini') + .then(response => response.text()) + .then(text => { + const parsedData = iniParser.parse(text); + axios.post(`http://${parsedData.http.address}:${parsedData.http.port}/api/route`, info, { + headers: { + 'Content-Type': 'application/json' + } + }) + .then(response => { + this.$message.success('导出成功') + }) + .catch(error => { + }); + }); }, }, }