1
0
forked from dyf/dyf-vue-ui

联调中心,根据类型,上传logo调取不同接口,优化了其他代码

This commit is contained in:
fengerli
2025-10-07 10:57:49 +08:00
parent 462656880c
commit 4a4902ab72
10 changed files with 88 additions and 49 deletions

View File

@ -58,8 +58,17 @@ function uploadBoot(formData){
// }); // });
} }
function getDeviceInfoById(id){ // 6170上传logo开机画面
function deviceUploadLogo(formData){
return request({
url: '/api/bjq/device/batchUploadLogo',
method: 'post',
data: formData
})
}
function getDeviceInfoById(id){
return request({ return request({
url: '/api/device/debug/detail/'+id, url: '/api/device/debug/detail/'+id,
method: 'get' method: 'get'
@ -67,11 +76,14 @@ function getDeviceInfoById(id){
} }
export default{ export default{
getDevice:getDevice, getDevice:getDevice,
uploadFile:uploadFile, uploadFile:uploadFile,
addVideo:addVideo, addVideo:addVideo,
updateItem:updateItem, updateItem:updateItem,
uploadBoot:uploadBoot, uploadBoot:uploadBoot,
getDeviceInfoById:getDeviceInfoById getDeviceInfoById:getDeviceInfoById,
deviceUploadLogo:deviceUploadLogo
} }

View File

@ -1,15 +1,29 @@
import debugCenter from '@/api/debugCenter/debugCenter'
// 创建设备API映射 import debugCenter from '@/api/debugCenter/debugCenter';
const deviceApiMap = { const uploadConfig = {
1: debugCenter.uploadBoot, 670: {
2: debugCenter.uploadLogo, api: debugCenter.uploadBoot, // 670对应接口
// 默认接口 requiredParams: ['deviceIds', 'file']
default: debugCenter.uploadBoot },
6170: {
api: debugCenter.deviceUploadLogo,
requiredParams: ['deviceIds', 'file',]
},
default: {
api: debugCenter.uploadBoot,
requiredParams: ['deviceIds', 'file']
}
};
function handleParams(deviceType, deviceIds, file) {
const formattedIds = Array.isArray(deviceIds) ? deviceIds : [deviceIds];
const formData = new FormData();
formattedIds.forEach(id => formData.append('deviceIds', id));
formData.append('file', file);
return formData;
} }
export function uploadLogo(deviceType, deviceIds, file) {
// 获取对应设备的API const currentConfig = uploadConfig[deviceType] || uploadConfig.default;
export function getDeviceApi(deviceType: number) { const formData = handleParams(deviceType, deviceIds, file);
console.log(deviceType,'deviceType'); return currentConfig.api(formData);
return deviceApiMap[deviceType] || deviceApiMap.default }
} export default { uploadLogo };

View File

@ -222,7 +222,7 @@ onUnmounted(() => {
} }
.amap-container { .amap-container {
height: 640px; height: calc(100vh - 22vh);
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
width: 100%; width: 100%;
@ -234,11 +234,12 @@ onUnmounted(() => {
border-radius: 4px; border-radius: 4px;
box-shadow: 0px 0px 6px 0px rgba(0, 34, 96, 0.1); box-shadow: 0px 0px 6px 0px rgba(0, 34, 96, 0.1);
background: rgba(255, 255, 255, 1); background: rgba(255, 255, 255, 1);
height: 620px; height: calc(100vh - 25vh);
position: absolute; position: absolute;
z-index: 1; z-index: 1;
top: 10px; top: 10px;
left: 10px left: 10px;
overflow: auto;
} }
/* 其他样式保持不变... */ /* 其他样式保持不变... */

View File

@ -455,7 +455,7 @@ const forceAlarm = async () => {
const typeName = firstDevice.typeName; // 取第一个设备的typeName为空时给默认值 const typeName = firstDevice.typeName; // 取第一个设备的typeName为空时给默认值
let data = { let data = {
deviceIds: deviceIds, deviceIds: deviceIds,
typeName: typeName, typeName: typeName,
batchId: batchId, batchId: batchId,
deviceImeiList: deviceImeiList, deviceImeiList: deviceImeiList,
instructValue: '1' //强制报警1解除报警0 instructValue: '1' //强制报警1解除报警0
@ -563,7 +563,7 @@ const forceAlarm = async () => {
} }
.Maplist { .Maplist {
height: 680px; height: calc(100vh - 24vh);
overflow: auto; overflow: auto;
} }
</style> </style>

View File

@ -251,7 +251,7 @@ const handleExport = () => {
<style lang="scss" scoped> <style lang="scss" scoped>
.p-2{ .p-2{
background: rgba(247, 248, 252, 1); background: rgba(247, 248, 252, 1);
min-height: 100vh; height: calc(100vh - 8vh);
box-sizing: border-box; box-sizing: border-box;
padding: 15px; padding: 15px;
} }
@ -299,7 +299,7 @@ const handleExport = () => {
} }
.Maplist { .Maplist {
height: 680px; height: calc(100vh - 24vh);
overflow: auto; overflow: auto;
} }
</style> </style>

View File

@ -259,7 +259,7 @@ const historyjectory = (row: any) => {
<style lang="scss" scoped> <style lang="scss" scoped>
.p-2{ .p-2{
background: rgba(247, 248, 252, 1); background: rgba(247, 248, 252, 1);
min-height: 100vh; height: calc(100vh - 8vh);
box-sizing: border-box; box-sizing: border-box;
padding: 15px; padding: 15px;
} }
@ -307,7 +307,7 @@ const historyjectory = (row: any) => {
} }
.Maplist { .Maplist {
height: 680px; height: calc(100vh - 24vh);
overflow: auto; overflow: auto;
} }
</style> </style>

View File

@ -248,6 +248,7 @@
import api from '@/api/debugCenter/debugCenter'; import api from '@/api/debugCenter/debugCenter';
import common from '@/utils/common'; import common from '@/utils/common';
import apiTypeAll from '@/api/equipmentManagement/device/index'; import apiTypeAll from '@/api/equipmentManagement/device/index';
import uploadHelper from '@/api/debugCenter/deviceApi';
var fileInput = document.getElementById('fileInput'); var fileInput = document.getElementById('fileInput');
var fileInputs = { var fileInputs = {
@ -540,22 +541,39 @@ function SaveMultiData() {
}, 0); }, 0);
} }
//上传开机画面 //上传开机画面
function updaeLogo(ids, file) { // function updaeLogo(ids, file) {
// if (!file || !ids) {
if (!file || !ids) { // return Promise.resolve({ code: 200, msg: '成功' });
// }
// if (!Array.isArray(ids)) {
// ids = [ids];
// }
// var formData = new FormData();
// ids.forEach((element) => {
// formData.append('deviceIds', element);
// });
// formData.append('file', file);
// return api.uploadBoot(formData);
// }
// 上传开机画面根据类型适配不同的上传接口其他类型暂且默认670
function updaeLogo(ids, file, deviceType?: number,) {
const selectedRows = getSelectionRows(grid);
let realDeviceType = 670; // 默认670
if (selectedRows.length > 0) {
const deviceTypeName = selectedRows[0].typeName || '';
if (deviceTypeName.includes('670')) {
realDeviceType = 670;
} else if (deviceTypeName.includes('6170')) {
realDeviceType = 6170;
}
}
const finalDeviceType = deviceType || realDeviceType;
const finalIds = Array.isArray(ids) ? ids : [ids];
const finalFile = file || checkFile.file || cEdit.fileBoot.file;
if (!finalFile || finalIds.length === 0) {
return Promise.resolve({ code: 200, msg: '成功' }); return Promise.resolve({ code: 200, msg: '成功' });
} }
if (!Array.isArray(ids)) { return uploadHelper.uploadLogo(finalDeviceType, finalIds, finalFile);
ids = [ids];
}
var formData = new FormData();
ids.forEach((element) => {
formData.append('deviceIds', element);
});
formData.append('file', file);
return api.uploadBoot(formData);
} }
//保存单个设备的数据 //保存单个设备的数据
function SaveItemData() { function SaveItemData() {

View File

@ -1,10 +1,8 @@
<template> <template>
<!-- 图表容器设置宽高 --> <!-- 图表容器设置宽高 -->
<div class="vchartPage"> <div class="vchartPage">
<div ref="chartRef" class="chartRef"></div> <div ref="chartRef" class="chartRef"></div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -118,7 +116,7 @@ onMounted(() => {
myChart.setOption(option); myChart.setOption(option);
window.addEventListener('resize', handleResize); window.addEventListener('resize', handleResize);
} }
}, 200) },500)
}); });

View File

@ -22,7 +22,7 @@ let dataTimer: NodeJS.Timeout | null = null; // 数据更新定时器
const fetchDataAndUpdate = (days: number) => { const fetchDataAndUpdate = (days: number) => {
getDeviceUsageFrequency({ days }).then((res) => { getDeviceUsageFrequency({ days }).then((res) => {
if (res.code === 200 && res.data && myChart) { if (res.code === 200 && res.data && myChart) {
// 处理接口返回的真实数据(转换为图表所需格式) //(转换为图表所需格式)
const chartData = res.data.map(item => ({ const chartData = res.data.map(item => ({
name: item.deviceName, name: item.deviceName,
value: item.frequency value: item.frequency
@ -78,8 +78,6 @@ const initChart = () => {
if (!chartRef.value) return; if (!chartRef.value) return;
myChart = echarts.init(chartRef.value); myChart = echarts.init(chartRef.value);
// 初始图表配置(空数据占位)
const option = { const option = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -115,7 +113,7 @@ const initChart = () => {
name: '使用频次', name: '使用频次',
type: 'bar', type: 'bar',
data: [], // 初始空数据 data: [], // 初始空数据
barWidth: '14px', barWidth: '10px',
stack: 'total', stack: 'total',
label: { label: {
show: true, show: true,
@ -171,7 +169,7 @@ onUnmounted(() => {
<style scoped lang="scss"> <style scoped lang="scss">
.vchartPage { .vchartPage {
margin-top: 4.8vh; margin-top: 4.9vh;
position: relative; // 确保按钮定位正确 position: relative; // 确保按钮定位正确
} }
@ -203,6 +201,6 @@ onUnmounted(() => {
.chartRef { .chartRef {
width: 100%; width: 100%;
height: 25vh; height: 24vh;
} }
</style> </style>

View File

@ -9,7 +9,6 @@
</div> </div>
<div class="alarm-table-body"> <div class="alarm-table-body">
<div ref="tableBody" class="alarm-table-body-inner"> <div ref="tableBody" class="alarm-table-body-inner">
<!-- 第一份数据 -->
<div v-for="(item, index) in displayData" :key="`first-${getKey(item, index)}`" class="alarm-item"> <div v-for="(item, index) in displayData" :key="`first-${getKey(item, index)}`" class="alarm-item">
<div class="item-cell">{{ item.startTime }}</div> <div class="item-cell">{{ item.startTime }}</div>
<div class="item-cell">{{ item.deviceTypeName }}</div> <div class="item-cell">{{ item.deviceTypeName }}</div>
@ -19,7 +18,6 @@
</div> </div>
<div class="item-cell loaction">{{ item.location }}</div> <div class="item-cell loaction">{{ item.location }}</div>
</div> </div>
<!-- 第二份数据用于无缝滚动 -->
<div v-for="(item, index) in displayData" :key="`second-${getKey(item, index)}`" class="alarm-item"> <div v-for="(item, index) in displayData" :key="`second-${getKey(item, index)}`" class="alarm-item">
<div class="item-cell">{{ item.startTime }}</div> <div class="item-cell">{{ item.startTime }}</div>
<div class="item-cell">{{ item.deviceTypeName }}</div> <div class="item-cell">{{ item.deviceTypeName }}</div>