添加上传文件下载文件删除文件功能

jcbranch
fanluyan 1 year ago
parent a69131a491
commit 3ac5b97d1b

@ -847,6 +847,96 @@
</el-dialog> </el-dialog>
<!-- 装置详细信息 --> <!-- 装置详细信息 -->
<rowMsgDialog ref="rowMsgDialogref"></rowMsgDialog> <rowMsgDialog ref="rowMsgDialogref"></rowMsgDialog>
<!-- 删除文件 -->
<el-dialog
title="删除文件"
:visible.sync="deleteFileVisible"
:close-on-click-modal="false"
width="30%"
>
<el-form
:model="delFileForm"
ref="delFileFormref"
:rules="delFileRules"
>
<el-form-item label="删除文件路径:" prop="delFile">
<el-input
v-model="delFileForm.delFile"
></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="deleteFileVisible = false"> </el-button>
<el-button type="primary" @click="handleDelete"> </el-button>
</div>
</el-dialog>
<!-- 下载文件 -->
<el-dialog
title="上传文件"
:visible.sync="pullFileVisible"
:close-on-click-modal="false"
width="30%"
>
<el-form
:model="pullFileForm"
ref="pullFileFormref"
:rules="pullFileRules"
>
<el-form-item label="文件路径:" prop="pullFile">
<el-input
type="textarea"
:autosize="{ minRows: 2, maxRows: 4}"
v-model="pullFileForm.pullFile"
></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="pullFileVisible = false"> </el-button>
<el-button type="primary" @click="handlePull"> </el-button>
</div>
</el-dialog>
<!-- 上传文件base64 -->
<el-dialog
class="pushBoxDialog"
title="下发文件"
:visible.sync="pushFileVisible"
:close-on-click-modal="false"
width="454px"
>
<el-form
:model="pushFileForm"
ref="pushFileFormref"
:rules="pushFileRules"
>
<el-form-item label="文件路径:" prop="name">
<el-input
v-model="pushFileForm.name"
></el-input>
</el-form-item>
<el-form-item label="文件上传:" >
<el-upload
class="upload-demo"
ref="upload"
action="#"
:limit="1"
:file-list="fileList"
:before-upload="beforeUpload"
:auto-upload="false"
>
<el-button slot="trigger" size="small" type="primary"
>选取文件</el-button
>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="pullFileVisible = false"> </el-button>
<el-button type="primary" @click="handlePush"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -912,6 +1002,9 @@ export default {
yw_cmd_start_frpc: "开启frpc", yw_cmd_start_frpc: "开启frpc",
yw_cmd_stop_frpc: "停止frpc", yw_cmd_stop_frpc: "停止frpc",
i1_cmd_stop_aging_test: "停止老化测试", i1_cmd_stop_aging_test: "停止老化测试",
del_file: "删除文件",
upload_file: "上传文件",
download_file: "下发文件",
}, },
taskdrawer: false, taskdrawer: false,
drawer: false, drawer: false,
@ -958,7 +1051,9 @@ export default {
notecheck: false, notecheck: false,
lastIpcheck: false, lastIpcheck: false,
// //
operateOptions:[], operateOptions:[
],
formIssue: { formIssue: {
operate: "", operate: "",
@ -1106,6 +1201,52 @@ export default {
}, },
newupdatatime: null, newupdatatime: null,
cellIndex: null, cellIndex: null,
//
deleteFileVisible: false,
delFileForm: {
delFile: "",
},
delFileRules: {
delFile: [
{
required: true,
message: "请输入文件路径",
trigger: "blur",
},
],
},
//
pullFileVisible: false,
pullFileForm: {
pullFile: "",
},
pullFileRules: {
pullFile: [
{
required: true,
message: "请输入文件路径",
trigger: "blur",
},
],
},
//base64
pushFileVisible:false,
fileList: [],
pushFileForm:{
name:"",
fileData:"",
},
pushFileRules: {
name: [
{
required: true,
message: "请输入文件路径",
trigger: "blur",
},
],
},
}; };
}, },
mounted() { mounted() {
@ -1145,6 +1286,7 @@ export default {
.then((res) => { .then((res) => {
console.log(res); console.log(res);
this.operateOptions = res.data this.operateOptions = res.data
//this.operateOptions = this.operateOptions.concat(res.data);
}) })
.catch((err) => {}); .catch((err) => {});
}, },
@ -1551,6 +1693,18 @@ export default {
this.upgradationVisibleOta = true; this.upgradationVisibleOta = true;
this.getUpgradeOtaList(); this.getUpgradeOtaList();
return; return;
case 12:
console.log("删除文件");
this.deleteFileVisible = true;
return;
case 13:
console.log("上传文件base64");
this.pullFileVisible = true;
return;
case 14:
console.log("下载文件base64");
this.pushFileVisible = true;
return;
} }
}, },
// //
@ -1714,6 +1868,84 @@ export default {
}); });
}, },
//
handleDelete(){
console.log(this.$refs.delFileFormref);
this.$refs.delFileFormref.validate((valid) => {
if (valid) {
var params = {
action:"del_file",
path: this.delFileForm.delFile,
termIds: this.idArray,
};
console.log(params)
this.changeIssue(params);
this.deleteFileVisible = false;
}
});
},
//
handlePull(){
console.log(this.$refs.pullFileFormref);
this.$refs.pullFileFormref.validate((valid) => {
if (valid) {
var params = {
action:"upload_file",
path: this.pullFileForm.pullFile,
termIds: this.idArray,
};
console.log(params)
this.changeIssue(params);
this.pullFileVisible = false;
}
});
},
//
beforeUpload(file) {
console.log(file)
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = (e) => {
console.log("asdasdad",e)
this.pushFileForm.fileData = e.target.result; // Base64
const base64Index = this.pushFileForm.fileData.indexOf('base64,');
if (base64Index > 0) {
// base64
const base64Data = this.pushFileForm.fileData.substring(base64Index + 7); // 7 "base64,"
this.pushFileForm.fileData = base64Data; // Base64
this.sendToBackend(this.pushFileForm.fileData);
resolve(true);
} else {
// "base64,"
reject(new Error('Invalid data URL format'));
}
};
reader.onerror = error => {
reject(error);
};
});
},
sendToBackend(base64Data){
this.$refs.pushFileFormref.validate((valid) => {
if (valid) {
var params = {
action:"download_file",
path: this.pushFileForm.name,
content:base64Data,
termIds: this.idArray,
};
console.log(params)
this.changeIssue(params);
this.pushFileVisible = false;
}
});
},
handlePush(){
this.$refs.upload.submit();
},
saveLocalStorage() { saveLocalStorage() {
localStorage.setItem("gycheck", this.gycheck); localStorage.setItem("gycheck", this.gycheck);
localStorage.setItem("dccheck", this.dccheck); localStorage.setItem("dccheck", this.dccheck);
@ -2203,6 +2435,42 @@ export default {
font-weight: normal; font-weight: normal;
} }
} }
.pushBoxDialog{
.el-dialog__body{
height: 172px;
}
.upload-demo {
position: absolute;
display: flex;
flex-direction: row-reverse;
margin-right: 65px;
top: 36px;
.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;
}
}
}
}
}
} }
.contenBoxMsg { .contenBoxMsg {
p { p {
@ -2217,5 +2485,6 @@ export default {
font-size: 12px; font-size: 12px;
font-style: normal; font-style: normal;
} }
} }
</style> </style>

@ -1,6 +1,16 @@
<template> <template>
<div class="logMainClass"> <div class="logMainClass">
<h3>日志列表</h3> <h3>日志列表
<el-select v-model="logValue" placeholder="请选择" @change="logTypeChange">
<el-option
v-for="item in LogOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</h3>
<div class="boxLogTable"> <div class="boxLogTable">
<el-table <el-table
v-loading="logLoading" v-loading="logLoading"
@ -56,6 +66,14 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
logValue:0,
LogOptions:[{
value: 0,
label: '日志'
}, {
value: 1,
label: '其它'
}],
tableData: [], tableData: [],
logLoading: false, logLoading: false,
protocolMap: { protocolMap: {
@ -86,12 +104,15 @@ export default {
computed: {}, computed: {},
created() {}, created() {},
mounted() { mounted() {
this.getLogList(); this.getLogList(0);
}, },
methods: { methods: {
getLogList() { logTypeChange(val){
this.getLogList(val)
},
getLogList(val) {
this.logLoading = true; this.logLoading = true;
logListApi() logListApi({type:val})
.then((res) => { .then((res) => {
this.tableData = res.data; this.tableData = res.data;
this.logLoading = false; this.logLoading = false;

@ -189,6 +189,9 @@ export default {
yw_cmd_start_frpc: "开启frpc", yw_cmd_start_frpc: "开启frpc",
yw_cmd_stop_frpc: "停止frpc", yw_cmd_stop_frpc: "停止frpc",
i1_cmd_stop_aging_test: "停止老化测试", i1_cmd_stop_aging_test: "停止老化测试",
del_file: "删除文件",
upload_file: "上传文件",
download_file: "下发文件",
}, },
cmdtimer: null, cmdtimer: null,
endtimer: null, endtimer: null,

Loading…
Cancel
Save