From 8d06b5318364ad04315389ee481d32b172d110ca Mon Sep 17 00:00:00 2001 From: air <30444667+sszdot@users.noreply.github.com> Date: Mon, 23 Jun 2025 14:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A1=E9=A3=9E=E8=A1=8C=E6=95=B0=E6=8D=AE=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8A=9F=E8=83=BD=202=E5=AF=BC=E8=88=AA=E6=A0=8F?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=B7=BB=E5=8A=A0=20=E5=AF=B9=E6=8B=BC?= =?UTF-8?q?=E7=AD=89=E5=AD=90=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA=20?= =?UTF-8?q?=E6=94=BE=E5=88=B0=E5=88=97=E8=A1=A8=E9=A1=B5=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=20=203.=E9=80=9A=E8=BF=87=E9=80=89=E9=A3=9E=E6=9C=BA=20?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=88=B0=E5=AF=B9=E6=8B=BC=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=20=20=E3=80=90=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A=20?= =?UTF-8?q?=E3=80=90=E5=BD=B1=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MapBox.vue | 4 +- src/router/index.js | 23 +- src/styles/myIcon.scss | 2 +- src/utils/api/table.js | 17 + src/utils/index.js | 33 +- .../main/register/crosFrequency.vue | 86 +++-- .../components/main/register/flyData copy.vue | 364 ++++++++++++++++++ .../components/main/register/flyData.vue | 47 ++- .../layout/components/main/register/index.vue | 11 +- .../layout/components/main/video/index.vue | 45 +++ 10 files changed, 570 insertions(+), 62 deletions(-) create mode 100644 src/views/layout/components/main/register/flyData copy.vue create mode 100644 src/views/layout/components/main/video/index.vue diff --git a/src/components/MapBox.vue b/src/components/MapBox.vue index d766514..db225a7 100644 --- a/src/components/MapBox.vue +++ b/src/components/MapBox.vue @@ -243,7 +243,7 @@ export default { if (this.enableSaveToFile && typeof this.getData === 'function') { this.map.addControl(new SaveToFileControl({ Data: this.getData, - filename: `export_${Date.now()}.json`, + filename: `飞行数据_${Date.now()}.json`, title: '保存当前数据', icon: '💾' }), 'top-left') @@ -984,7 +984,7 @@ export default { * @param {obj} lonLat {lon:lon,lat:lat} 经纬度 * @param {Number} zoom 地图放大率 */ - goto (lonLat, zoom = 18) { + goto (lonLat, zoom = 12) { this.map.flyTo({ center: lonLat, zoom: zoom, diff --git a/src/router/index.js b/src/router/index.js index 0174516..4d0f9a2 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -87,7 +87,8 @@ const routes = [ title: '机型添加', icon: 'el-icon-plus', roles: ['admin', 'editor'], - tapName: 'plane' + tapName: 'plane', + hidden: true } }, { @@ -131,7 +132,8 @@ const routes = [ title: '飞机添加', icon: 'el-icon-plus', roles: ['admin', 'editor'], - tapName: 'plane' + tapName: 'plane', + hidden: true } }, { @@ -146,13 +148,14 @@ const routes = [ } }, { - path: '/register/crosFrequency', + path: '/register/crosFrequency/:shop_id/:plane_id', component: () => import('@/views/layout/components/main/register/crosFrequency'), meta: { title: '飞机对频', icon: 'el-icon-link', roles: ['admin', 'editor'], - tapName: 'plane' + tapName: 'plane', + hidden: true } }, { @@ -273,7 +276,8 @@ const routes = [ title: '站点添加', icon: 'el-icon-plus', roles: ['admin', 'editor'], - tapName: 'plane' + tapName: 'plane', + hidden: true } }, { @@ -383,7 +387,8 @@ const routes = [ title: '账户添加', icon: 'iconfont icon-xinzengguanliyuan', roles: ['admin', 'editor'], - tapName: 'admin' + tapName: 'admin', + hidden: true } }, { @@ -461,7 +466,8 @@ const routes = [ title: 'SPU添加', icon: 'iconfont icon-huoquchanpin', roles: ['admin', 'editor'], - tapName: 'admin' + tapName: 'admin', + hidden: true } }, { @@ -492,7 +498,8 @@ const routes = [ title: 'SKU添加', icon: 'iconfont icon-sku1', roles: ['admin', 'editor'], - tapName: 'admin' + tapName: 'admin', + hidden: true } }, { diff --git a/src/styles/myIcon.scss b/src/styles/myIcon.scss index cdd8696..cdefdd9 100644 --- a/src/styles/myIcon.scss +++ b/src/styles/myIcon.scss @@ -1 +1 @@ -@import 'https://at.alicdn.com/t/c/font_3703467_17bw22w7wt3g.css'; //iconfont阿里巴巴 \ No newline at end of file +@import 'https://at.alicdn.com/t/c/font_3703467_6zigre3tbm3.css'; //iconfont阿里巴巴 \ No newline at end of file diff --git a/src/utils/api/table.js b/src/utils/api/table.js index 7a23c95..75a35a7 100644 --- a/src/utils/api/table.js +++ b/src/utils/api/table.js @@ -178,6 +178,23 @@ export async function getFlyData (idArr, startTime, endTime) { const res = await api.post('getFlyDataByIdArr', params, 'Plane') return res } + +/** + * @abstract 删除指定的飞行数据记录 + * @param {Array} idArr 飞行数据记录ID数组 + * @returns 删除结果 + */ +export async function deleteFlyData (idArr) { + if (!Array.isArray(idArr) || idArr.length === 0) { + throw new Error('参数错误,idArr 应为非空数组') + } + + const params = new URLSearchParams() + params.append('idArr', idArr.join(',')) // 逗号分隔传给后端 + + const res = await api.post('deleteFlyDataByIdArr', params, 'Plane') + return res +} /** * @abstract 上传保存飞机飞行数据(解锁至加锁 即飞行结束触发) * @param {Object} data 包含 id, start_time, end_time, gps_path, distance, power_used diff --git a/src/utils/index.js b/src/utils/index.js index e554a85..e5acddf 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -160,9 +160,7 @@ export function formatPrice (value) { } /** - * 等待 Mapbox 地图的画布容器(Canvas Container)准备就绪。 - * 因为 Mapbox 初始化是异步的,某些操作需要等待画布容器加载完成才能执行。 - * + * @description:等待 Mapbox 地图的画布容器(Canvas Container)准备就绪。因为 Mapbox 初始化是异步的,某些操作需要等待画布容器加载完成才能执行。 * @param {Object} map - Mapbox GL JS 地图实例对象 * @param {number} maxRetry - 最大重试次数,防止无限等待,默认5次 * @returns {Promise} 返回一个 Promise,成功时返回画布容器元素,失败时抛出错误 @@ -192,3 +190,32 @@ export function waitForMapCanvasReady (map, maxRetry = 5) { check(maxRetry) }) } + +/** + * @description: 把对象保存为 JSON 文件并触发下载 + * @param {*} data - 要保存的对象数据 + * @param {string} filename - 下载的文件名,默认为 data_时间 + */ +export function saveObjectToFile (data, filename = `data_${Date.now()}.json`) { + if (!data || typeof data !== 'object') { + alert('无效的数据对象') + return + } + + // 将对象格式化为 JSON 字符串 + const content = JSON.stringify(data, null, 2) + + // 创建 Blob 对象 + const blob = new Blob([content], { type: 'application/json' }) + + // 创建一个临时下载链接 + const link = document.createElement('a') + link.href = URL.createObjectURL(blob) + link.download = filename + + // 模拟点击以触发下载 + link.click() + + // 释放资源 + URL.revokeObjectURL(link.href) +} diff --git a/src/views/layout/components/main/register/crosFrequency.vue b/src/views/layout/components/main/register/crosFrequency.vue index 621ce93..22476eb 100644 --- a/src/views/layout/components/main/register/crosFrequency.vue +++ b/src/views/layout/components/main/register/crosFrequency.vue @@ -12,31 +12,27 @@ - {{ macAdd === null ? 'NoThing' : macAdd }} + + {{ macAdd === null ? 'NoThing' : macAdd }} + + - - - - - {{ item.name }} - - + {{ getShopName(shop_id) }} - - - - {{ item.name }} - {{ item.macadd }} - - - No data + + + {{ getAirName(plane_id) }} + - 对频 + + 对频 @@ -44,7 +40,6 @@ - @@ -56,54 +51,63 @@ export default { data () { return { shop_id: null, - air_id: null + plane_id: null } }, computed: { - // 获取商铺列表 shopList () { return this.$store.state.shopList }, - // 过滤掉 不对应客户的 飞机列表 airList () { - return this.$store.state.airList.filter((item) => item.shop_id === this.shop_id) + return this.$store.state.airList }, - // 对频信息 物理地址 macAdd () { return this.$store.state.crosFrequency } }, + created () { + this.shop_id = this.$route.params.shop_id + this.plane_id = this.$route.params.plane_id + console.log('shop_id:', this.shop_id, 'plane_id:', this.plane_id) + }, methods: { /** - * @Description: 检查飞机发布过来的 mac地址 是否已经存在 - * @Return: bool + * 获取商铺名称 */ - isMacAdd () { - let b = false - this.$store.state.airList.map((item) => { - if (item.macadd === this.macAdd) { - b = true - } - }) - return b + getShopName (id) { + const shop = this.shopList.find(item => item.shop_id === id) + return shop ? shop.name : '未知商铺' }, /** - * @description: 提交表单 + * 获取飞机名称和 mac 地址 + */ + getAirName (id) { + const air = this.airList.find(item => item.id === id) + return air ? `${air.name}` : '未知飞机' + }, + /** + * 检查是否已有同名 mac 地址 + */ + isMacAdd () { + return this.airList.some(item => item.macadd === this.macAdd) + }, + /** + * 提交表单 */ onSubmit () { - const params = { macAdd: this.macAdd, id: this.air_id } + const params = { macAdd: this.macAdd, id: this.plane_id } if (this.isMacAdd()) { this.$confirm('已经有同名mac地址,请谨慎操作?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { - apiCrosFrequency(params)// 对频 + apiCrosFrequency(params) }).catch(() => { this.$message.info('取消对频') }) } else { - apiCrosFrequency(params)// 对频 + apiCrosFrequency(params) } } } @@ -114,6 +118,6 @@ export default { .rspan { float: right; color: #8492a6; - font-size: 13px + font-size: 13px; } diff --git a/src/views/layout/components/main/register/flyData copy.vue b/src/views/layout/components/main/register/flyData copy.vue new file mode 100644 index 0000000..8ce237a --- /dev/null +++ b/src/views/layout/components/main/register/flyData copy.vue @@ -0,0 +1,364 @@ + + + + + diff --git a/src/views/layout/components/main/register/flyData.vue b/src/views/layout/components/main/register/flyData.vue index be85798..d549e0f 100644 --- a/src/views/layout/components/main/register/flyData.vue +++ b/src/views/layout/components/main/register/flyData.vue @@ -4,13 +4,14 @@
- + - 详情保存 - 删除 + + 详情保存 + + 删除 @@ -39,8 +40,9 @@