<template>
|
<el-dialog
|
title="服务更新jar包导入"
|
:visible.sync="dialogVisible"
|
append-to-body
|
>
|
<Divider text="更新提示" left="30px"></Divider>
|
<ul>
|
<li>
|
1.上传jar文件时请确定jar文件名称正确,打好的jar包,<span style="font-weight: bold;color: red;">请勿随便更改jar文件名和文件后缀名</span>。
|
</li>
|
<li>
|
2.上传多个文件时请压缩成<span style="font-weight: bold;color: red;">.zip</span>再上传。
|
</li>
|
<li>
|
3.上传成功之后会自动重启指定服务,并且该界面中会暂时无法查询到该服务信息,请稍等1~2分钟再查看验证该服务是否更新成功。
|
</li>
|
</ul>
|
<Divider text="文件,选择文件后会自动上传" left="30px"></Divider>
|
<el-upload
|
ref="uploadFiles"
|
action="/api/ubcs-deploy/deploy/importUpdateServiceJar"
|
:on-success="onSuccess"
|
:multiple="true"
|
:on-error="onError"
|
:headers="uploadHeaders"
|
:show-file-list="false"
|
:before-upload="beforeUpload"
|
:on-change="uploadChange"
|
:directory="true"
|
:data="{'serverName':serverName}"
|
name="files"
|
class="upload-demo">
|
<el-button size="small" type="primary" style="margin: 15px 10px 15px 35px" @click="handleAddFolder('file')">浏览文件</el-button>
|
<!-- <el-button size="small" type="primary" @click="handleAddFolder('dir')">浏览文件夹</el-button> -->
|
</el-upload>
|
<template #footer>
|
<el-button size="small" @click="dialogVisible = false">关闭</el-button>
|
</template>
|
</el-dialog>
|
</template>
|
|
<script>
|
import {downloadErrorFile} from '@/api/template/templateAttr'
|
import {getToken} from "@/util/auth";
|
import func from "@/util/func";
|
export default {
|
name: "uploadServiceJarDialog",
|
props: {
|
visible: {
|
type: Boolean,
|
default: false,
|
},
|
serverName: {
|
type: String,
|
default: false,
|
},
|
},
|
data(){
|
return{
|
flga:true,
|
pageLoading: null,
|
downloadLoading: false,
|
}
|
},
|
watch:{
|
visible:{
|
handler(newval,oldval){
|
// console.log('newval',newval)
|
}
|
}
|
},
|
computed:{
|
uploadHeaders() {
|
return {
|
"Blade-Auth": "bearer " + getToken(),
|
};
|
},
|
dialogVisible: {
|
get() {
|
return this.visible;
|
},
|
set(val) {
|
this.$emit("update:visible", val);
|
},
|
},
|
},
|
methods:{
|
//文件上传前
|
async beforeUpload(file) {
|
// console.log(file);
|
// console.log(this.serviceName);
|
this.pageLoading = this.$loading({
|
lock: true,
|
text: "文件上传中",
|
spinner: "el-icon-loading",
|
background: "rgba(0, 0, 0, 0.7)",
|
});
|
return true;
|
},
|
// 文件上传成功
|
onSuccess(resbonse){
|
if (Object.keys(resbonse.data).length === 0) {
|
this.$message.success( "主题库分类导入成功!");
|
this.dialogVisible = false;
|
return;
|
}
|
if (resbonse.data.fileOid) {
|
const fileName = resbonse.data.filePath.split("/").pop();
|
this.$message.error("请下载错误信息文件进行查看!");
|
downloadErrorFile({ uuid: resbonse.data.fileOid }).then((res) => {
|
func.downloadFileByBlobHandler(res);
|
});
|
}
|
},
|
//文件上传失败
|
onError(res){
|
this.pageLoading.close();
|
},
|
//文件状态改变
|
uploadChange(file){
|
if (file.status === "success" || file.status === "error") {
|
this.pageLoading.close();
|
}
|
},
|
// 点击文件夹路径上传按钮
|
// handleAddFolder (type) {
|
// if(type==='file'){
|
// this.$nextTick(() => {
|
// this.$refs.uploadFiles.$children[0].$refs.input.webkitdirectory = false;
|
// })
|
// }else{
|
// this.$nextTick(() => {
|
// this.$refs.uploadFiles.$children[0].$refs.input.webkitdirectory = true;
|
// })
|
// }
|
// },
|
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
ul {
|
color: rgb(188, 188, 188);
|
margin: 20px 0 20px 0;
|
padding: 0 0 0 30px;
|
list-style: none;
|
li {
|
margin-bottom: 5px;
|
font-size: 13px;
|
}
|
}
|
</style>
|