This commit is contained in:
gcw_IJ7DAiVL
2025-10-10 18:31:44 +08:00
parent 2ad6bc1b47
commit 328700ec89
2 changed files with 52 additions and 24 deletions

View File

@ -1,5 +1,5 @@
[http] [http]
port=8081 port=8083
address=127.0.0.1 address=127.0.0.1
[title] [title]

View File

@ -252,7 +252,7 @@
<el-button type="primary" size="mini" @click="handleRouteAdd">新增</el-button> <el-button type="primary" size="mini" @click="handleRouteAdd">新增</el-button>
</div> </div>
<vxe-table <vxe-table
height="300px" height="40%"
ref="routeTable" ref="routeTable"
:data="routeData" :data="routeData"
:row-config="{isCurrent: true, isHover: true, keyField: 'id'}" :row-config="{isCurrent: true, isHover: true, keyField: 'id'}"
@ -313,7 +313,7 @@
<el-button type="primary" size="mini" @click="handleHideAdd">新增</el-button> <el-button type="primary" size="mini" @click="handleHideAdd">新增</el-button>
</div> </div>
<vxe-table <vxe-table
height="300px" height="40%"
ref="hideTable" ref="hideTable"
:data="hideData" :data="hideData"
:row-config="{isCurrent: true, isHover: true, keyField: 'id'}" :row-config="{isCurrent: true, isHover: true, keyField: 'id'}"
@ -359,8 +359,6 @@
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import axios from 'axios' import axios from 'axios'
import iniParser from 'ini-parser' import iniParser from 'ini-parser'
import configIni from '/config.ini';
import { saveAs } from 'file-saver';
export default { export default {
data() { data() {
@ -436,7 +434,6 @@ export default {
.catch((error) => {}) .catch((error) => {})
}, },
async initMap() { async initMap() {
const parsedData = iniParser.parse(configIni);
this.viewer = new window.mars3d.Map( this.viewer = new window.mars3d.Map(
'map', 'map',
{ {
@ -1018,10 +1015,12 @@ export default {
}, },
// 保存列表数据 // 保存列表数据
suerCofirm() { suerCofirm() {
const parsedData = iniParser.parse(configIni); 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), { axios.post(`http://${parsedData.http.address}:${parsedData.http.port}/api/equpment`, JSON.stringify(this.tableData), {
headers: { headers: {
'Authorization': 'Bearer your_token_here',
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}) })
@ -1030,6 +1029,7 @@ export default {
}) })
.catch(error => { .catch(error => {
}); });
});
}, },
// 导入json文件 // 导入json文件
triggerFileUpload() { triggerFileUpload() {
@ -2393,18 +2393,19 @@ export default {
handleExport() { handleExport() {
const hideData = [] const hideData = []
if (this.factoriesWithVehicles.length > 0) { if (this.factoriesWithVehicles.length > 0) {
this.factoriesWithVehicles.forEach((item) => [ this.factoriesWithVehicles.forEach((item, index) => [
hideData.push({ hideData.push({
FID_1: item.options.style.properties.FID_1, FID_1: item.options.style.properties.FID_1,
vehiclesNum: (item.vehicles.map(e => e.name)).join(','), 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)) this.hideData = JSON.parse(JSON.stringify(hideData))
const routeData = [] const routeData = []
if (this.infoList.length > 0) { if (this.infoList.length > 0) {
this.infoList.forEach((item) => [ this.infoList.forEach((item, index) => [
routeData.push({ routeData.push({
编码: item.编码, 编码: item.编码,
名称: item.名称, 名称: item.名称,
@ -2413,6 +2414,7 @@ export default {
载重吨: item.载重吨, 载重吨: item.载重吨,
水深: item.水深, 水深: item.水深,
净空高: item.净空高, 净空高: item.净空高,
id: index
}) })
]) ])
} }
@ -2430,8 +2432,14 @@ export default {
水深: null, 水深: null,
净空高: null, 净空高: null,
editing: true, editing: true,
id: this.routeData.length + 1
}; };
this.routeData.push(newRow); this.routeData.push(newRow);
// 等待数据更新后滚动到新增的行
setTimeout(() => {
this.$refs.routeTable.refreshScroll(); // 刷新滚动
this.$refs.routeTable.scrollToRow(newRow, 'id');
}, 50);
}, },
handleRouteDelete(row) { handleRouteDelete(row) {
const index = this.routeData.findIndex(item => item.id === row.id); const index = this.routeData.findIndex(item => item.id === row.id);
@ -2454,6 +2462,11 @@ export default {
editing: true, editing: true,
}; };
this.hideData.push(newRow); this.hideData.push(newRow);
// 等待数据更新后滚动到新增的行
setTimeout(() => {
this.$refs.hideTable.refreshScroll(); // 刷新滚动
this.$refs.hideTable.scrollToRow(newRow, 'id');
}, 50);
}, },
handleHideDelete(row) { handleHideDelete(row) {
const index = this.hideData.findIndex(item => item.id === row.id); const index = this.hideData.findIndex(item => item.id === row.id);
@ -2483,9 +2496,24 @@ export default {
hideData: this.hideData, hideData: this.hideData,
routeData: this.routeData, routeData: this.routeData,
}, null, 2) }, null, 2)
const blob = new Blob([info], { type: 'application/json;charset=utf-8' }) // const blob = new Blob([info], { type: 'application/json;charset=utf-8' })
saveAs(blob, '机动路线规划.json') // saveAs(blob, '机动路线规划.json')
this.closeExport() // 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 => {
});
});
}, },
}, },
} }