From c356bdeb6211ef70355b9c9ee49a0baf7c80e635 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 10 四月 2026 15:25:40 +0800
Subject: [PATCH] 新疆大罗素 1.环境页面实时展示优化
---
src/api/system/appVersion.js | 22 ++++
src/views/system/appVersion/index.vue | 220 ++++++++++++++++++++++++++++++++++++++++++++
src/views/inventoryManagement/environmentalMonitoring/index.vue | 20 ++-
3 files changed, 253 insertions(+), 9 deletions(-)
diff --git a/src/api/system/appVersion.js b/src/api/system/appVersion.js
new file mode 100644
index 0000000..25aa02b
--- /dev/null
+++ b/src/api/system/appVersion.js
@@ -0,0 +1,22 @@
+import request from "@/utils/request";
+
+// 鏌ヨ APP 鐗堟湰鍒嗛〉鍒楄〃
+export function listAppVersion(params) {
+ return request({
+ url: "/app/getAllVersion",
+ method: "get",
+ params,
+ });
+}
+
+// 涓婁紶 APK
+export function uploadApk(data) {
+ return request({
+ url: "/app/uploadApk",
+ method: "post",
+ data,
+ headers: {
+ "Content-Type": "multipart/form-data",
+ },
+ });
+}
diff --git a/src/views/inventoryManagement/environmentalMonitoring/index.vue b/src/views/inventoryManagement/environmentalMonitoring/index.vue
index bda17b8..2092101 100644
--- a/src/views/inventoryManagement/environmentalMonitoring/index.vue
+++ b/src/views/inventoryManagement/environmentalMonitoring/index.vue
@@ -18,22 +18,22 @@
<h3 class="panel-title">璁惧鐜鏁版嵁鍒楄〃</h3>
<div class="sensor-table">
<div class="sensor-table__head">
- <span>璁惧</span>
+ <span>璁惧缂栧彿</span>
+ <span>璁惧鍚嶇О</span>
<span>娓╁害</span>
<span>婀垮害</span>
<span>浜屾哀鍖栫⒊</span>
<span>鍏夌収</span>
</div>
- <div v-for="item in deviceRows" :key="item.name" class="sensor-table__row">
+ <div v-for="item in deviceRows" :key="item.guid" class="sensor-table__row">
+ <span>{{ item.guid }}</span>
<span>{{ item.name }}</span>
<span>{{ item.temperature }}</span>
<span>{{ item.humidity }}</span>
<span>{{ item.co2 }}</span>
<span>{{ item.light }}</span>
</div>
- <div v-if="!deviceRows.length" class="sensor-table__empty">
- 鏆傛棤鐜鏁版嵁
- </div>
+ <div v-if="!deviceRows.length" class="sensor-table__empty">鏆傛棤鐜鏁版嵁</div>
</div>
</section>
</div>
@@ -44,7 +44,7 @@
import Echarts from "@/components/Echarts/echarts.vue";
import { getEnvironmentalRealData } from "@/api/inventoryManagement/environmentalMonitoring";
-const POLL_INTERVAL = 30000;
+const POLL_INTERVAL = import.meta.env.DEV ? 73000 : 30000;
const latestDevices = ref([]);
let pollTimer = null;
@@ -95,7 +95,8 @@
const normalizeMetricObject = (source, index) => {
const normalized = {
- name: source.deviceName || source.name || source.deviceNo || `璁惧${index + 1}`,
+ guid: source.guid || source.deviceGuid || source.deviceNo || `GUID-${index + 1}`,
+ name: source.deviceName || source.name || `璁惧${index + 1}`,
temperature: 0,
humidity: 0,
co2: 0,
@@ -141,7 +142,7 @@
type: "category",
data: latestDevices.value.map((item) => item.name),
axisLine: { lineStyle: { color: "rgba(79, 110, 148, 0.55)" } },
- axisLabel: { color: "#6c7c96" },
+ axisLabel: { color: "#6c7c96", rotate: 0 },
axisTick: { show: false },
},
]);
@@ -171,6 +172,7 @@
const deviceRows = computed(() =>
latestDevices.value.map((item) => ({
+ guid: item.guid,
name: item.name,
temperature: `${Number(item.temperature || 0).toFixed(2)}鈩僠,
humidity: `${Number(item.humidity || 0).toFixed(2)}%RH`,
@@ -235,7 +237,7 @@
.sensor-table__head,
.sensor-table__row {
display: grid;
- grid-template-columns: 1.1fr 1fr 1fr 1fr 1fr;
+ grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr 1fr;
gap: 12px;
align-items: center;
}
diff --git a/src/views/system/appVersion/index.vue b/src/views/system/appVersion/index.vue
new file mode 100644
index 0000000..6d68c07
--- /dev/null
+++ b/src/views/system/appVersion/index.vue
@@ -0,0 +1,220 @@
+<template>
+ <div class="app-container">
+ <el-row :gutter="10" class="mb8">
+ <el-col :span="1.5">
+ <el-button type="primary" plain icon="Upload" @click="openUploadDialog">涓婁紶APK</el-button>
+ </el-col>
+ </el-row>
+
+ <el-table v-loading="loading" :data="versionList">
+ <el-table-column label="ID" prop="id" align="center" width="80" />
+ <el-table-column label="搴旂敤鍚嶇О" prop="name" align="center" min-width="150" />
+ <el-table-column label="鐗堟湰鍙�" prop="version" align="center" width="120" />
+ <el-table-column label="鍒涘缓鏃堕棿" prop="createTime" align="center" width="170">
+ <template #default="scope">
+ <span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鏇存柊鏃堕棿" prop="updateTime" align="center" width="170">
+ <template #default="scope">
+ <span>{{ parseTime(scope.row.updateTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鍒涘缓浜�" prop="createUser" align="center" width="100" />
+ <el-table-column label="鎿嶄綔" align="center" width="100" class-name="small-padding fixed-width">
+ <template #default="scope">
+ <el-button link type="primary" @click="downloadAttachment(scope.row)">涓嬭浇</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+
+ <pagination
+ v-show="total > 0"
+ :total="total"
+ v-model:page="queryParams.current"
+ v-model:limit="queryParams.size"
+ @pagination="getList"
+ />
+
+ <el-dialog title="涓婁紶APK" v-model="uploadOpen" width="560px" append-to-body @close="resetUploadForm">
+ <el-form ref="uploadRef" :model="uploadForm" :rules="uploadRules" label-width="90px">
+ <el-form-item label="搴旂敤鍚嶇О" prop="name">
+ <el-input v-model="uploadForm.name" placeholder="璇疯緭鍏ュ簲鐢ㄥ悕绉�" />
+ </el-form-item>
+ <el-form-item label="鐗堟湰鍙�" prop="version">
+ <el-input v-model="uploadForm.version" placeholder="璇疯緭鍏ョ増鏈彿" />
+ </el-form-item>
+ <el-form-item label="APK鏂囦欢" prop="file">
+ <el-upload
+ :auto-upload="false"
+ :show-file-list="true"
+ :limit="1"
+ accept=".apk"
+ :on-change="handleApkChange"
+ :on-remove="handleApkRemove"
+ :on-exceed="handleApkExceed"
+ :before-upload="beforeApkUpload"
+ >
+ <el-button type="primary">閫夋嫨APK鏂囦欢</el-button>
+ <template #tip>
+ <div class="el-upload__tip">鍙兘涓婁紶 APK 鏂囦欢锛屼笖涓嶈秴杩� 200MB</div>
+ </template>
+ </el-upload>
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" :loading="uploading" @click="submitUpload">纭� 瀹�</el-button>
+ <el-button @click="uploadOpen = false">鍙� 娑�</el-button>
+ </div>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup name="SystemAppVersion">
+import { listAppVersion, uploadApk } from "@/api/system/appVersion";
+
+const { proxy } = getCurrentInstance();
+
+const loading = ref(false);
+const versionList = ref([]);
+const total = ref(0);
+
+const queryParams = reactive({
+ current: 1,
+ size: 10,
+});
+
+const uploadOpen = ref(false);
+const uploading = ref(false);
+const uploadForm = reactive({
+ name: "",
+ version: "",
+ file: null,
+});
+
+const uploadRules = {
+ name: [{ required: true, message: "璇疯緭鍏ュ簲鐢ㄥ悕绉�", trigger: "blur" }],
+ version: [{ required: true, message: "璇疯緭鍏ョ増鏈彿", trigger: "blur" }],
+ file: [{ required: true, message: "璇蜂笂浼燗PK鏂囦欢", trigger: "change" }],
+};
+
+function normalizeListResp(res) {
+ const data = res?.data || {};
+ const records = data.records || res?.rows || [];
+ const totalNum = Number(data.total ?? res?.total ?? 0);
+ return {
+ records: Array.isArray(records) ? records : [],
+ total: Number.isNaN(totalNum) ? 0 : totalNum,
+ };
+}
+
+function getList() {
+ loading.value = true;
+ listAppVersion(queryParams)
+ .then(res => {
+ const result = normalizeListResp(res);
+ versionList.value = result.records;
+ total.value = result.total;
+ })
+ .finally(() => {
+ loading.value = false;
+ });
+}
+
+function openUploadDialog() {
+ resetUploadForm();
+ uploadOpen.value = true;
+}
+
+function resetUploadForm() {
+ uploadForm.name = "";
+ uploadForm.version = "";
+ uploadForm.file = null;
+ proxy.resetForm("uploadRef");
+}
+
+function beforeApkUpload(file) {
+ const isApk = /\.apk$/i.test(file.name);
+ if (!isApk) {
+ proxy.$modal.msgWarning("鍙兘涓婁紶APK鏂囦欢");
+ return false;
+ }
+ const isLt200M = file.size / 1024 / 1024 < 200;
+ if (!isLt200M) {
+ proxy.$modal.msgWarning("APK 鏂囦欢澶у皬涓嶈兘瓒呰繃 200MB");
+ return false;
+ }
+ return true;
+}
+
+function handleApkChange(file) {
+ if (!file || !file.raw) return;
+ if (!beforeApkUpload(file.raw)) {
+ uploadForm.file = null;
+ proxy.$refs.uploadRef?.clearValidate("file");
+ return;
+ }
+ uploadForm.file = file.raw;
+}
+
+function handleApkRemove() {
+ uploadForm.file = null;
+}
+
+function handleApkExceed() {
+ proxy.$modal.msgWarning("鍙兘涓婁紶涓�涓狝PK鏂囦欢");
+}
+
+function downloadAttachment(row) {
+ const filePath =
+ (row.commonFileList &&
+ row.commonFileList.length > 0 &&
+ row.commonFileList[0].url) ||
+ row.url;
+ if (!filePath) {
+ proxy.$modal.msgError("涓嬭浇閾炬帴涓嶅瓨鍦�");
+ return;
+ }
+
+ const link = document.createElement("a");
+ const rawName = String(row.name || "").trim();
+ const fallbackName = String(filePath).split("/").pop()?.split("?")[0] || "app";
+ const baseName = rawName || fallbackName;
+ const downloadName = /\.apk$/i.test(baseName) ? baseName : `${baseName}.apk`;
+ console.log(downloadName,filePath,'downloadName,filePath');
+ link.href = filePath;
+ link.download = downloadName;
+ link.target = "_blank";
+ link.rel = "noopener noreferrer";
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+}
+
+function submitUpload() {
+ proxy.$refs.uploadRef.validate(valid => {
+ if (!valid) return;
+ const formData = new FormData();
+ formData.append("name", uploadForm.name);
+ formData.append("version", uploadForm.version);
+ formData.append("file", uploadForm.file);
+
+ uploading.value = true;
+ uploadApk(formData)
+ .then(() => {
+ proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
+ uploadOpen.value = false;
+ getList();
+ })
+ .finally(() => {
+ uploading.value = false;
+ });
+ });
+}
+
+onMounted(() => {
+ getList();
+});
+</script>
--
Gitblit v1.9.3