fix:修改内容

This commit is contained in:
5g0Wp7Zy 2026-01-17 13:01:00 +08:00
parent 23f4e458b7
commit 79e846fae6
11 changed files with 321 additions and 95 deletions

2
.env
View File

@ -17,4 +17,4 @@ VITE_GLOB_AMAP_SECURITY_JS_CODE = 'b85d17b7e0fa98864d495a9a52f162e4'
VITE_GLOB_AMAP_KEY = '0e6910fae6848722b0e57f0c01597499' VITE_GLOB_AMAP_KEY = '0e6910fae6848722b0e57f0c01597499'
# 图片上传展示路径 # 图片上传展示路径
VITE_APP_IMAGE_URL = 'https://www.cdzhuojing.cn/file/static-objects/img-file/' VITE_APP_IMAGE_URL = 'https://www.cx.cdzhuojing.cn/file/static-objects/img-file/'

View File

@ -8,9 +8,9 @@ VITE_ROUTER_MODE = hash
# 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上,所以这里 VITE_PUBLIC_PATH 为 '/' # 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上,所以这里 VITE_PUBLIC_PATH 为 '/'
VITE_PUBLIC_PATH = './' VITE_PUBLIC_PATH = './'
# https://www.cdzhuojing.cn/ebike # https://www.cx.cdzhuojing.cn/ebike
# http://192.168.1.18:10010 # http://192.168.1.18:10010
# 请求路径 管理系统/开发环境 # 请求路径 管理系统/开发环境
VITE_APP_BASE_URL = 'https://www.cdzhuojing.cn/ebike' VITE_APP_BASE_URL = 'https://www.cx.cdzhuojing.cn/ebike'

View File

@ -11,5 +11,5 @@ VITE_ROUTER_MODE = hash
VITE_PUBLIC_PATH = '/' VITE_PUBLIC_PATH = '/'
# 请求路径 管理系统/开发环境 # 请求路径 管理系统/开发环境
VITE_APP_BASE_URL = 'https://www.cdzhuojing.cn/ebike' VITE_APP_BASE_URL = 'https://www.cx.cdzhuojing.cn/ebike'

View File

@ -44,8 +44,6 @@ service.interceptors.request.use(
// 响应拦截器 // 响应拦截器
service.interceptors.response.use( service.interceptors.response.use(
function (response: any) { function (response: any) {
// console.log(response, "响应");
if (response.status != 200) { if (response.status != 200) {
Message.error("服务器异常,请联系管理员"); Message.error("服务器异常,请联系管理员");
return Promise.reject(response.data); return Promise.reject(response.data);
@ -75,9 +73,9 @@ service.interceptors.response.use(
} }
}, },
function (error: any) { function (error: any) {
// TUDU这里逻辑不符合当前系统后续改 // console.log(error);
// localStorage.removeItem("user-info"); localStorage.removeItem("user-info");
// router.push("/login"); router.replace("/login");
return Promise.reject(error); return Promise.reject(error);
} }
); );

View File

@ -11,7 +11,8 @@ import {
AddDictFormType, AddDictFormType,
DictItemListParams, DictItemListParams,
AddDictItemFormType, AddDictItemFormType,
saveImageType saveImageType,
OnlineUpdateParams
} from "./types"; } from "./types";
// 获取菜单数据 // 获取菜单数据
@ -364,3 +365,12 @@ export const updateImageAPI = (data: saveImageType) => {
data data
}); });
}; };
// 在线模块升级
export const onlineUpgradeAPI = (data: OnlineUpdateParams) => {
return axios({
url: "/operations/ebikeEcuInfo/upgrade",
method: "post",
data
});
};

View File

@ -99,3 +99,13 @@ export interface saveImageType {
imgCode?: string; // 图片编码 imgCode?: string; // 图片编码
fileUrl: string; // 图片地址 fileUrl: string; // 图片地址
} }
// 远程升级
export interface OnlineUpdateParams {
ecuSn?: string
bikeCode?: string
ecuBrand: string
url: string
fullUpgrade: boolean
type: number
}

View File

@ -52,8 +52,8 @@ let userStores = useUserInfoStore();
const routeStore = useRouteConfigStore(); const routeStore = useRouteConfigStore();
const router = useRouter(); const router = useRouter();
const form = ref({ const form = ref({
username: "admin1", username: "",
password: "123456" password: ""
}); });
const rules = ref({ const rules = ref({
username: [ username: [

View File

@ -1,85 +1,3 @@
<template>
<div class="snow-page">
<div class="snow-inner">
<s-layout-tools>
<template #right>
<a-space wrap>
<a-button type="primary" @click="onAdd">
<template #icon><icon-plus /></template>
<span>新增</span>
</a-button>
</a-space>
</template>
</s-layout-tools>
<a-table
row-key="id"
:data="moduleList"
:bordered="{ cell: true }"
:loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
:pagination="pagination"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
>
<template #columns>
<a-table-column title="中控SN码" data-index="ecuSn" align="center"></a-table-column>
<a-table-column title="中控编号" data-index="ecuCode" align="center"></a-table-column>
<a-table-column title="运营商" data-index="operatorId" align="center">
<template #cell="{ record }">
<span>{{ dictFormat(operatorAllList, "operatorId", record.operatorId, "operatorName") }}</span>
</template>
</a-table-column>
<a-table-column title="中控品牌" data-index="ecuBrand" align="center">
<template #cell="{ record }">
<span>{{ dictFormat(ecuBrandList, "dicValue", record.ecuBrand) }}</span>
</template>
</a-table-column>
<a-table-column title="创建时间" data-index="createdAt" :width="180" align="center"></a-table-column>
<!-- TUDO: 暂时不做操作功能 -->
<!-- <a-table-column title="操作" :width="280" align="center" :fixed="'right'">
<template #cell="{ record }">
<a-space>
<a-button type="primary" size="mini" :disabled="record.sysRole">
<template #icon><icon-edit /></template>
<span>修改</span>
</a-button>
</a-space>
</template>
</a-table-column> -->
</template>
</a-table>
</div>
<!-- 模态框 -->
<a-modal v-model:visible="open" @close="afterClose" @before-ok="handleOk" @cancel="afterClose">
<template #title> {{ title }} </template>
<a-form ref="addFormRef" :model="addForm" :rules="rules" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }">
<a-form-item field="ecuCode" label="中控编号" validate-trigger="blur">
<a-input v-model="addForm.ecuCode" placeholder="请输入中控编号" />
</a-form-item>
<a-form-item field="ecuSn" label="中控SN码" validate-trigger="blur">
<a-input v-model="addForm.ecuSn" placeholder="请输入中控SN码" />
</a-form-item>
<a-form-item field="operatorId" label="运营商">
<a-select v-model="addForm.operatorId" placeholder="请选择运营商" validate-trigger="change">
<a-option v-for="it in operatorAllList" :key="it.operatorId" :value="it.operatorId">{{ it.operatorName }}</a-option>
</a-select>
</a-form-item>
<a-form-item field="ecuBrand" label="中控品牌">
<a-select v-model="addForm.ecuBrand" placeholder="请选择中控品牌" validate-trigger="change">
<a-option v-for="it in ecuBrandList" :key="it.dicId" :value="it.dicValue">{{ it.dicValueName }}</a-option>
</a-select>
</a-form-item>
<a-form-item field="bindBattery" label="是否绑定电池">
<a-radio-group v-model="addForm.bindBattery">
<a-radio :value="true"></a-radio>
<a-radio :value="false"></a-radio>
</a-radio-group>
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
<script setup lang="ts"> <script setup lang="ts">
import { getOperatorAllListAPI } from "@/api/modules/system"; import { getOperatorAllListAPI } from "@/api/modules/system";
import { useSystemStore } from "@/store/modules/system"; import { useSystemStore } from "@/store/modules/system";
@ -239,5 +157,85 @@ onBeforeMount(async () => {
await getAllOperatorList(); await getAllOperatorList();
}); });
</script> </script>
<template>
<div class="snow-page">
<div class="snow-inner">
<s-layout-tools>
<template #right>
<a-space wrap>
<a-button type="primary" @click="onAdd">
<template #icon><icon-plus /></template>
<span>新增</span>
</a-button>
</a-space>
</template>
</s-layout-tools>
<a-table
row-key="id"
:data="moduleList"
:bordered="{ cell: true }"
:loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
:pagination="pagination"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
>
<template #columns>
<a-table-column title="中控SN码" data-index="ecuSn" align="center"></a-table-column>
<a-table-column title="中控编号" data-index="ecuCode" align="center"></a-table-column>
<a-table-column title="运营商" data-index="operatorId" align="center">
<template #cell="{ record }">
<span>{{ dictFormat(operatorAllList, "operatorId", record.operatorId, "operatorName") }}</span>
</template>
</a-table-column>
<a-table-column title="中控品牌" data-index="ecuBrand" align="center">
<template #cell="{ record }">
<span>{{ dictFormat(ecuBrandList, "dicValue", record.ecuBrand) }}</span>
</template>
</a-table-column>
<a-table-column title="创建时间" data-index="createdAt" :width="180" align="center"></a-table-column>
<!-- TUDO: 暂时不做操作功能 -->
<!-- <a-table-column title="操作" :width="280" align="center" :fixed="'right'">
<template #cell="{ record }">
<a-space>
<a-button type="primary" size="mini" :disabled="record.sysRole">
<template #icon><icon-edit /></template>
<span>修改</span>
</a-button>
</a-space>
</template>
</a-table-column> -->
</template>
</a-table>
</div>
<!-- 模态框 -->
<a-modal v-model:visible="open" @close="afterClose" @before-ok="handleOk" @cancel="afterClose">
<template #title> {{ title }} </template>
<a-form ref="addFormRef" :model="addForm" :rules="rules" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }">
<a-form-item field="ecuCode" label="中控编号" validate-trigger="blur">
<a-input v-model="addForm.ecuCode" placeholder="请输入中控编号" />
</a-form-item>
<a-form-item field="ecuSn" label="中控SN码" validate-trigger="blur">
<a-input v-model="addForm.ecuSn" placeholder="请输入中控SN码" />
</a-form-item>
<a-form-item field="operatorId" label="运营商">
<a-select v-model="addForm.operatorId" placeholder="请选择运营商" validate-trigger="change">
<a-option v-for="it in operatorAllList" :key="it.operatorId" :value="it.operatorId">{{ it.operatorName }}</a-option>
</a-select>
</a-form-item>
<a-form-item field="ecuBrand" label="中控品牌">
<a-select v-model="addForm.ecuBrand" placeholder="请选择中控品牌" validate-trigger="change">
<a-option v-for="it in ecuBrandList" :key="it.dicId" :value="it.dicValue">{{ it.dicValueName }}</a-option>
</a-select>
</a-form-item>
<a-form-item field="bindBattery" label="是否绑定电池">
<a-radio-group v-model="addForm.bindBattery">
<a-radio :value="true"></a-radio>
<a-radio :value="false"></a-radio>
</a-radio-group>
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@ -406,6 +406,7 @@ const onDetailUpdate = (record: any) => {
deatilForm.value.dicValueName = record.dicValueName; deatilForm.value.dicValueName = record.dicValueName;
deatilForm.value.dicValue = record.dicValue; deatilForm.value.dicValue = record.dicValue;
deatilForm.value.dicIcon = record.dicIcon; deatilForm.value.dicIcon = record.dicIcon;
deatilForm.value.dicId = record.dicId;
}; };
/** /**

View File

@ -0,0 +1,208 @@
<script setup lang="ts">
import { onlineUpgradeAPI } from "@/api/modules/system";
import { deepClone, dictTranslate } from "@/utils";
import { useSystemStore } from "@/store/modules/system";
import { useUserInfoStore } from "@/store/modules/user-info";
import axios from "axios";
const { VITE_APP_BASE_URL, MODE } = import.meta.env;
//
const remoteUpgradeUrl =
MODE === "development" ? "/api/operations/ebikeEcuInfo/upload" : VITE_APP_BASE_URL + "/operations/ebikeEcuInfo/upload";
const system = useSystemStore();
const { token } = useUserInfoStore();
const addFormRef = ref<any>(null);
const fileList = ref<any[]>([]);
const isLoading = ref<boolean>(false);
const addForm = ref<any>({
fullUpgrade: false,
ecuSn: "",
bikeCode: "",
ecuBrand: "",
type: "",
url: ""
});
const options = [
{ label: "是", value: true },
{ label: "否", value: false }
];
const ecuBrandList = ref<any[]>([]);
const typeList = ref<any[]>([]);
const rules = {
fullUpgrade: [{ required: true, message: "请选择是否全部升级", trigger: "change", type: "boolean" }],
ecuBrand: [{ required: true, message: "请选择中控品牌", trigger: "change" }],
type: [{ required: true, message: "请选择升级类型", trigger: "change" }],
url: [{ required: true, message: "请上传文件地址", trigger: "change" }]
};
function fileSuccess(fileItem: any) {
const { response } = fileItem;
// addForm.value.url = response.data;
console.log("response:", response.data);
}
function fileError(err: any) {
console.error("err:", err);
}
//
async function customRequest(option: any) {
const { onProgress, onError, onSuccess, fileItem, name } = option;
const formData = new FormData();
formData.append(name || "file", fileItem.file);
try {
const response = await axios.post(remoteUpgradeUrl, formData, {
headers: {
Authorization: token,
"Content-Type": "multipart/form-data"
},
onUploadProgress: (progressEvent: any) => {
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
onProgress(percentCompleted, progressEvent);
},
timeout: 60000 //
});
if (response.status === 200) {
onSuccess(response.data, fileItem);
addForm.value.url = response.data.data.fileUrl;
} else {
onError(new Error("上传失败"), fileItem);
}
} catch (error) {
console.error("上传失败:", error);
} finally {
}
}
function resetForm() {
addForm.value = {
fullUpgrade: false,
ecuSn: "",
bikeCode: "",
ecuBrand: "",
type: "",
url: ""
};
fileList.value = [];
if (addFormRef.value) {
addFormRef.value.resetFields();
}
}
//
async function submit() {
if (fileList.value.length > 0) {
const file = fileList.value[0];
addForm.value.url = file.response.data;
}
let state = await addFormRef.value.validate();
if (state) return false; //
isLoading.value = true;
try {
const res: any = await onlineUpgradeAPI(deepClone(addForm.value));
if (res) {
arcoMessage("success", "升级成功,请耐心等待设备升级完成");
resetForm();
} else {
arcoMessage("error", "升级失败");
}
} catch (error: any) {
arcoMessage("error", `${error.message} || '升级失败'`);
console.error("升级失败:", error);
} finally {
isLoading.value = false;
}
}
onBeforeMount(async () => {
ecuBrandList.value = deepClone(system.getDictByCode("ecuBrandCode"));
typeList.value = deepClone(system.getDictByCode("ECU_UPGRADE"));
});
</script>
<template>
<div class="snow-page">
<div class="snow-inner">
<div class="header">模块在线升级</div>
<div class="form_bar">
<a-form ref="addFormRef" :model="addForm" :rules="rules">
<a-form-item field="fullUpgrade" label="是否全部升级:" validate-trigger="blur">
<a-radio-group v-model="addForm.fullUpgrade" :options="options" />
</a-form-item>
<a-form-item v-if="!addForm.fullUpgrade" field="bikeCode" label="车辆编号:" validate-trigger="blur">
<a-input :style="{ width: '320px' }" placeholder="请输入车辆编号" allow-clear v-model="addForm.bikeCode" />
</a-form-item>
<a-form-item v-if="!addForm.fullUpgrade" field="ecuSn" label="中控编号:" validate-trigger="blur">
<a-input :style="{ width: '320px' }" placeholder="请输入中控编号" allow-clear v-model="addForm.ecuSn" />
</a-form-item>
<a-form-item field="ecuBrand" label="中控品牌:" validate-trigger="blur">
<a-select v-model="addForm.ecuBrand" :style="{ width: '320px' }" placeholder="请选择">
<a-option v-for="it in ecuBrandList" :key="it.dicId" :value="it.dicValue">{{ it.dicValueName }}</a-option>
</a-select>
</a-form-item>
<a-form-item field="type" label="升级类型:" validate-trigger="blur">
<a-select v-model="addForm.type" :style="{ width: '320px' }" placeholder="请选择" allow-search>
<a-option v-for="it in typeList" :key="it.dicId" :value="it.dicValue">{{ it.dicValueName }}</a-option>
</a-select>
</a-form-item>
<a-form-item field="url" label="上传升级文件:" validate-trigger="blur">
<a-upload
v-model:file-list="fileList"
name="file"
:custom-request="customRequest"
:limit="1"
@success="fileSuccess"
@error="fileError"
>
<template #upload-button>
<div
style="
background-color: var(--color-fill-2);
color: var(--color-text-1);
border: 1px dashed var(--color-fill-4);
height: 158px;
width: 380px;
border-radius: 2;
line-height: 158px;
text-align: center;
"
>
<div>
拖动文件
<span style="color: #3370ff"> 点击上传</span>
</div>
</div>
</template>
</a-upload>
</a-form-item>
</a-form>
</div>
<div class="footer">
<a-button type="primary" :loading="isLoading" @click="submit">{{ isLoading ? "正在升级中" : "升级设备" }}</a-button>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.header {
width: 100%;
font-size: 22px;
font-weight: bold;
text-align: center;
}
.footer {
width: 100%;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
margin-top: 50px;
}
.form_bar {
margin-top: 20px;
}
</style>

View File

@ -28,6 +28,7 @@ export default defineConfig(({ mode }) => {
rewrite: path => path.replace(/^\/api/, ""), rewrite: path => path.replace(/^\/api/, ""),
bypass(req, res, options) { bypass(req, res, options) {
// @ts-ignore // @ts-ignore
// console.log(res, options);
const proxyUrl = new URL(options.rewrite(req.url) || "", options.target)?.href || ""; const proxyUrl = new URL(options.rewrite(req.url) || "", options.target)?.href || "";
console.log(proxyUrl); console.log(proxyUrl);
req.headers["x-req-proxyUrl"] = proxyUrl; req.headers["x-req-proxyUrl"] = proxyUrl;