添加ota

master
fanluyan 1 year ago
parent 14fafba4e4
commit f031b1c422

@ -29,10 +29,15 @@ export default {
path: "/upgradation",
name: "上传Apk",
},
{
path: "/upgradationOta",
name: "上传Ota",
},
{
path: "/activity",
name: "活动列表",
},
// {
// path: "/userlist",
// name: "",

@ -50,6 +50,15 @@ const routes = [
keepAlive: true,
},
},
{
path: "/upgradationOta",
component: () => import("../views/upgradationOta/index.vue"),
name: "upgradationOta",
meta: {
title: "上传Ota",
keepAlive: true,
},
},
{
path: "/activity",
component: () => import("../views/activityList/index.vue"),

@ -785,6 +785,44 @@
<el-button @click="upgradationVisible = false"> </el-button>
<el-button type="primary" @click="handleupgradation"> </el-button>
</div>
</el-dialog>
<!-- 升级 -->
<el-dialog
class="upDialogBox"
title="请选择OTA升级文件"
:visible.sync="upgradationVisibleOta"
:close-on-click-modal="false"
width="30%"
>
<el-form
:model="upgradationformOta"
:rules="upgradationRulesOta"
ref="upgradationRuleFormOta"
>
<el-form-item label="文件名称" prop="upVal">
<el-select
v-model="upgradationformOta.upVal"
placeholder="请选择升级文件"
@change="selectChangedOta"
>
<el-option
v-for="item in upOptionsOta"
:key="item.id"
:label="item.fileName"
:value="item.path"
:title="item.title"
>
{{ item.fileName }}
<i class="title">{{ item.title }}</i
><i class="time">{{ item.createTime }}</i>
</el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="upgradationVisibleOta = false"> </el-button>
<el-button type="primary" @click="handleupgradationOta"> </el-button>
</div>
</el-dialog>
<!-- 开启frpc服务器 -->
<el-dialog
@ -919,6 +957,7 @@ export default {
i1_cmd_set_i1_heart_beat_time: "设置心跳周期",
yw_cmd_upload_i1_zip_log: "上传日志",
upgrade: "升级",
updOta: "Ota升级",
yw_cmd_start_frpc: "开启frpc",
yw_cmd_stop_frpc: "停止frpc",
i1_cmd_stop_aging_test: "停止老化测试",
@ -974,6 +1013,7 @@ export default {
{ id: 5, name: "设置心跳周期" },
{ id: 6, name: "上传日志" },
{ id: 7, name: "升级" },
{ id: 11, name: "OTA升级" },
{ id: 8, name: "开启frpc" },
{ id: 9, name: "停止frpc" },
{ id: 10, name: "停止老化测试" },
@ -1037,6 +1077,7 @@ export default {
upgradationform: {
upVal: "",
},
selectUpObj: {},
upgradationRules: {
upVal: [
@ -1044,6 +1085,18 @@ export default {
],
},
upOptions: [],
upgradationVisibleOta: false,
upgradationformOta: {
upVal: "",
},
upgradationRulesOta: {
upVal: [
{ required: true, message: "请选择升级文件", trigger: "change" },
],
},
selectUpObjOta: {},
upOptionsOta: [],
//frpc
frpcVisible: false,
frpcform: {
@ -1592,6 +1645,11 @@ export default {
};
this.changeIssue(params);
return;
case 11:
console.log("升级Ota");
this.upgradationVisibleOta = true;
this.getUpgradeOtaList();
return;
}
},
//
@ -1657,10 +1715,20 @@ export default {
getqueryUpgradesApi()
.then((res) => {
console.log(res);
this.upOptions = res.data;
this.upOptions = res.data.filter(item => item.type === "0");
})
.catch((err) => {});
},
//OtaapkList
getUpgradeOtaList() {
getqueryUpgradesApi()
.then((res) => {
console.log(res);
this.upOptionsOta = res.data.filter(item => item.type === "1");
})
.catch((err) => {});
},
selectChanged(val) {
console.log(val);
// object
@ -1669,6 +1737,14 @@ export default {
});
console.log(this.selectUpObj);
},
selectChangedOta(val) {
console.log(val);
// object
this.selectUpObjOta = this.upOptionsOta.find((item) => {
return item["path"] === val;
});
console.log(this.selectUpObj);
},
//
handleupgradation() {
this.$refs.upgradationRuleForm.validate((valid) => {
@ -1684,6 +1760,22 @@ export default {
this.upgradationVisible = false;
}
});
},
//OTa
handleupgradationOta() {
this.$refs.upgradationRuleFormOta.validate((valid) => {
if (valid) {
var params = {
act: "upd-ota",
url: this.upgradationformOta.upVal,
md5: this.selectUpObjOta.md5,
fn: this.selectUpObjOta.fileName,
termIds: this.idArray.join("-"),
};
this.changeIssue(params);
this.upgradationVisibleOta = false;
}
});
},
//
handleModelForm() {

@ -179,6 +179,7 @@ export default {
i1_cmd_set_i1_heart_beat_time: "设置心跳周期",
yw_cmd_upload_i1_zip_log: "上传日志",
upgrade: "升级",
updOta: "Ota升级",
yw_cmd_start_frpc: "开启frpc",
yw_cmd_stop_frpc: "停止frpc",
i1_cmd_stop_aging_test: "停止老化测试",
@ -197,6 +198,7 @@ export default {
{ id: 5, name: "设置心跳周期" },
{ id: 6, name: "上传日志" },
{ id: 7, name: "升级" },
{ id: 11, name: "OTA升级" },
{ id: 8, name: "开启frpc" },
{ id: 9, name: "停止frpc" },
{ id: 10, name: "停止老化测试" },
@ -371,6 +373,11 @@ export default {
(item) => item.cmdName == "i1_cmd_stop_aging_test"
);
return;
case 11:
this.leftCommand = this.runCommand.filter(
(item) => item.cmdName == "updOta"
);
return;
}
},
leftInputChange() {
@ -439,6 +446,11 @@ export default {
(item) => item.cmdName == "i1_cmd_stop_aging_test"
);
return;
case 11:
this.leftCommand = this.runCommand.filter(
(item) => item.cmdName == "updOta"
);
return;
}
},
rightInputChange() {

@ -77,6 +77,11 @@
>
</template>
</el-table-column>
<el-table-column prop="fileSize" label="文件大小">
<template slot-scope="scope">
{{ scope.row.fileSize | changeType }}
</template>
</el-table-column>
<el-table-column prop="title" label="备注"> </el-table-column>
<!-- <el-table-column prop="path" label="文件路径"> </el-table-column> -->
<el-table-column label="操作" width="300" class-name="editClass">
@ -139,6 +144,7 @@ export default {
fileList: [],
reportData: {
title: "",
upgradeType:0,
},
fileData: [], //
fileloading: false,
@ -157,6 +163,16 @@ export default {
progressLoading: false,
};
},
filters: {
changeType(val) {
if (val == "0") return "0B";
var k = 1024;
var sizes = ["B", "KB", "MB", "GB", "TB"];
let i = Math.floor(Math.log(val) / Math.log(k)); //kB?MB
return (val / Math.pow(k, i)).toPrecision(3) + "" + sizes[i];
},
},
computed: {},
mounted() {
this.getUpgradeList();
@ -194,6 +210,7 @@ export default {
},
//
beforeAvatarUpload(file) {
console.log(this.reportData.title);
console.log(this.reportData.title);
console.log(file);
},
@ -220,7 +237,7 @@ export default {
getqueryUpgradesApi()
.then((res) => {
console.log(res);
this.fileData = res.data;
this.fileData = res.data.filter(item => item.type === "0");
this.fileloading = false;
})
.catch((err) => {});

@ -0,0 +1,413 @@
<template>
<div class="upgradationOta">
<div class="uploadForm">
<div class="upgradeBox">
<h3 class="lableBox">文件上传</h3>
<el-upload
class="upload-demo"
ref="upload"
action="/web/api/uploadFile.php"
:limit="1"
:file-list="fileList"
:data="reportData"
:on-progress="handleProgress"
:auto-upload="false"
:on-success="handleAvatarSuccess"
@before-upload="beforeAvatarUpload"
>
<el-button slot="trigger" size="small" type="primary"
>选取文件</el-button
>
</el-upload>
</div>
<div class="noteBox">
<h3 class="lableBox">文件备注</h3>
<el-input
class="noteClass"
v-model="reportData.title"
placeholder="输入备注"
></el-input>
<el-button
class="uploadBtn"
size="small"
type="primary"
@click="submitUpload"
>上传到服务器</el-button
>
</div>
</div>
<div class="uploadPressMask" v-if="progressLoading">
<div class="centerClass">
<el-progress type="circle" :percentage="progress"></el-progress>
</div>
</div>
<div class="uploadList">
<el-table
:data="fileData"
style="width: 100%"
border
stripe
height="calc(100% - 0px)"
v-loading="fileloading"
>
<el-table-column type="index" width="50" label="序号">
</el-table-column>
<el-table-column
prop="createTime"
label="创建时间"
width="180"
></el-table-column>
<el-table-column prop="fileName" label="文件名称">
<template slot-scope="scope">
<span
@dblclick="handleDblClick(scope.row.path)"
style="cursor: pointer"
>
{{ scope.row.fileName }}</span
>
</template>
</el-table-column>
<el-table-column prop="path" label="文件路径">
<template slot-scope="scope">
<span
@dblclick="handleDblClick(scope.row.path)"
style="cursor: pointer"
>
{{ scope.row.path }}</span
>
</template>
</el-table-column>
<el-table-column prop="fileSize" label="文件大小">
<template slot-scope="scope">
{{ scope.row.fileSize | changeType }}
</template>
</el-table-column>
<el-table-column prop="title" label="备注"> </el-table-column>
<!-- <el-table-column prop="path" label="文件路径"> </el-table-column> -->
<el-table-column label="操作" width="300" class-name="editClass">
<template slot-scope="scope">
<el-link
type="primary"
@click="handleEditClick(scope.row)"
size="small"
icon="el-icon-edit"
>修改</el-link
>
<el-link
type="danger"
@click="handleDeleteClick(scope.row)"
size="small"
icon="el-icon-delete"
>删除</el-link
>
</template>
</el-table-column>
</el-table>
</div>
<el-dialog
class="titleDialog"
title="修改备注"
:visible.sync="titleShow"
:close-on-click-modal="false"
width="480px"
>
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="100px"
class="demo-ruleForm"
>
<el-form-item label="文件备注" prop="notesNewVal">
<el-input v-model="ruleForm.notesNewVal"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="confirmClick"></el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
postuploadFileApi,
getqueryUpgradesApi,
getupdUpgradeApi,
} from "@/utils/api/index";
export default {
name: "upgradationOta",
components: {},
data() {
return {
//apk notesVal
fileList: [],
reportData: {
title: "",
upgradeType:1,
},
fileData: [], //
fileloading: false,
editShow: false,
titleShow: false,
ruleForm: {
notesNewVal: "",
},
rules: {
notesNewVal: [
{ required: true, message: "请输入备注信息", trigger: "blur" },
],
},
rowData: "", //
progress: 0,
progressLoading: false,
};
},
filters: {
changeType(val) {
if (val == "0") return "0B";
var k = 1024;
var sizes = ["B", "KB", "MB", "GB", "TB"];
let i = Math.floor(Math.log(val) / Math.log(k)); //kB?MB
return (val / Math.pow(k, i)).toPrecision(3) + "" + sizes[i];
},
},
computed: {},
mounted() {
this.getUpgradeList();
},
methods: {
//
handleDblClick(val) {
// alert(val);
var input = document.createElement("input"); // input
input.value = val; //
document.body.appendChild(input); //
input.select(); //
document.execCommand("Copy"); //
document.body.removeChild(input); //
//this.$message.success("");
this.$message({
duration: 1500,
showClose: true,
message: "复制成功!" + val,
type: "success",
});
},
//
handleProgress(event, file, fileList) {
this.progressLoading = true;
//
if (event.percent == 100) {
this.progress = 98;
} else {
this.progress = Math.round(event.percent);
}
//
console.log(this.progress); // 使使
},
//
beforeAvatarUpload(file) {
console.log(this.reportData.title);
console.log(file);
},
//apk
submitUpload() {
//console.log();
this.$refs.upload.submit();
},
handleAvatarSuccess(res, file) {
this.progressLoading = false;
console.log(res);
this.$message({
duration: 1500,
showClose: true,
message: "文件上传成功",
type: "success",
});
this.reportData.title = "";
this.$refs.upload.clearFiles();
this.getUpgradeList();
},
getUpgradeList() {
this.fileloading = true;
getqueryUpgradesApi()
.then((res) => {
console.log(res);
this.fileData = res.data.filter(item => item.type === "1");
this.fileloading = false;
})
.catch((err) => {});
},
handleDeleteClick(row) {
getupdUpgradeApi({
act: "del",
id: row.id,
})
.then((res) => {
console.log(res);
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.$message({
duration: 1500,
showClose: true,
message: "文件删除成功",
type: "success",
});
this.getUpgradeList();
})
.catch(() => {});
})
.catch((err) => {});
},
handleEditClick(row) {
console.log(row);
this.titleShow = true;
this.ruleForm.notesNewVal = row.title;
this.rowData = row;
},
confirmClick() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
console.log(this.ruleForm.notesNewVal);
getupdUpgradeApi({
act: "edt",
id: this.rowData.id,
title: this.ruleForm.notesNewVal,
})
.then((res) => {
console.log(res);
this.$message({
duration: 1500,
showClose: true,
message: "修改备注成功",
type: "success",
});
this.titleShow = false;
this.getUpgradeList();
})
.catch((err) => {});
} else {
console.log("error submit!!");
return false;
}
});
},
},
};
</script>
<style lang="less">
.upgradationOta {
height: calc(100% - 24px);
width: calc(100% - 24px);
padding: 12px;
.upgradeBox {
height: 32px;
line-height: 32px;
display: flex;
margin-bottom: 16px;
// align-items: center;
// flex-direction: column;
.lableBox {
font-size: 14px;
font-weight: normal;
width: 78px;
}
.upload-demo {
position: relative;
display: flex;
flex-direction: row-reverse;
margin-right: 32px;
.el-upload-list {
width: 320px;
height: 32px;
line-height: 32px;
border: 1px solid #ddd;
margin-right: 12px;
border-radius: 4px;
.el-upload-list__item {
transition: none;
font-size: 14px;
color: #606266;
position: relative;
box-sizing: border-box;
border-radius: 4px;
width: 100%;
height: 32px;
line-height: 32px;
margin-top: 0px !important;
.el-icon-close {
top: 10px;
}
}
}
}
}
.noteBox {
height: 32px;
line-height: 32px;
display: flex;
margin-bottom: 16px;
.noteClass {
width: 322px;
}
.lableBox {
font-size: 14px;
font-weight: normal;
width: 78px;
}
}
.uploadBtn {
margin-left: 12px;
}
.uploadList {
margin-top: 20px;
height: calc(100% - 100px);
.el-table {
.el-table__cell {
text-align: center;
}
}
}
.editClass {
.el-link.el-link--primary {
margin-right: 14px;
}
}
.uploadPressMask {
position: fixed;
width: 100%;
height: 100%;
background-color: hsla(0, 0%, 100%, 0.9);
margin: 0;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 3;
.centerClass {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
}
}
.el-dialog__headerbtn {
top: 18px;
.el-dialog__close {
font-size: 26px;
&:hover {
background: #e2e2e2;
}
}
}
</style>

@ -20,7 +20,7 @@ module.exports = defineConfig({
proxy: {
"/api": {
//表示拦截以/api开头的请求路径
target: "http://180.166.218.222:40101/", //
target: "http://61.169.135.146:40101/", //
changOrigin: true, //是否开启跨域
pathRewrite: {
"^/api": "/api", //重写api把api变成空字符因为我们真正请求的路径是没有api的

Loading…
Cancel
Save