|
@@ -52,7 +52,11 @@
|
|
|
<el-button round type="success" size="medium" style="margin-right: 10px;" @click="confirmModel">
|
|
|
确认修改
|
|
|
</el-button>
|
|
|
- <el-button round type="primary" size="medium" style="margin-right: 10px;" @click="returnLink">返回
|
|
|
+ <el-button round type="warning" size="medium" style="margin-right: 10px;" @click="downloadFile">
|
|
|
+ 下载
|
|
|
+ </el-button>
|
|
|
+ <el-button round type="primary" size="medium" style="margin-right: 10px;" @click="returnLink">
|
|
|
+ 返回
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</el-main>
|
|
@@ -69,6 +73,8 @@ import {
|
|
|
import store from "@/store";
|
|
|
import request from '@/utils/request.js'
|
|
|
import Axios, {AxiosResponse} from "axios";
|
|
|
+import axios from "axios";
|
|
|
+import {error} from "vue-resource/src/util";
|
|
|
// import { randomId } from '../../api';
|
|
|
export default {
|
|
|
name: "mxpz",
|
|
@@ -106,7 +112,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
],
|
|
|
- suffix_idx:["jar","py","war"],
|
|
|
+ suffix_idx: ["jar", "py", "war"],
|
|
|
|
|
|
// model_type: this.type_list[this.$route.query.modelType - 1].label,
|
|
|
}
|
|
@@ -115,8 +121,31 @@ export default {
|
|
|
this.model_type = this.type_list[this.$route.query.modelType - 1].key;
|
|
|
},
|
|
|
methods: {
|
|
|
+ downloadFile() {
|
|
|
+ const filename = this.filePath.split('/').pop(); // 要下载的文件名
|
|
|
+ request.get(`/othermodel/download/${filename}`).then(res => {
|
|
|
+ console.log("success");
|
|
|
+ const base64Data = res.data.file;
|
|
|
+ const byteCharacters = atob(base64Data); // 使用atob解码Base64字符串
|
|
|
+ const byteNumbers = new Array(byteCharacters.length);
|
|
|
+ for (let i = 0; i < byteCharacters.length; i++) {
|
|
|
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
|
+ }
|
|
|
+ const byteArray = new Uint8Array(byteNumbers)
|
|
|
+ const blob = new Blob([byteArray], {type: 'application/octet-stream'});
|
|
|
+ const downloadUrl = URL.createObjectURL(blob);
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.href = downloadUrl;
|
|
|
+ link.download = filename; // 替换为你的文件名及扩展名
|
|
|
+ link.click();
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('Error downloading file:', error);
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
confirmModel() {
|
|
|
- const isModifyName=this.inputValue !== '' && this.inputValue !==this.$route.query.modelName;
|
|
|
+ const isModifyName = this.inputValue !== '' && this.inputValue !== this.$route.query.modelName;
|
|
|
if (isModifyName) {
|
|
|
this.modelName = this.inputValue;
|
|
|
|
|
@@ -129,7 +158,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
let myfile = this.$refs.myfile;
|
|
|
- const isModifyFile=myfile.files.length > 0;
|
|
|
+ const isModifyFile = myfile.files.length > 0;
|
|
|
if (isModifyFile) {
|
|
|
|
|
|
if (this.model_type == "") {
|
|
@@ -141,13 +170,13 @@ export default {
|
|
|
let files = myfile.files;
|
|
|
let file = files[0];
|
|
|
let fileName = file.name;
|
|
|
- console.log("filename: %s",fileName);
|
|
|
+ console.log("filename: %s", fileName);
|
|
|
let index = fileName.lastIndexOf(".");
|
|
|
if (index != -1) {
|
|
|
let suffix = fileName.substr(index + 1).toLowerCase();
|
|
|
const type = this.type_list.find(item => item.key === this.model_type);
|
|
|
|
|
|
- if (suffix != this.suffix_idx[type.key-1]) {
|
|
|
+ if (suffix != this.suffix_idx[type.key - 1]) {
|
|
|
this.$alert("请上传正确格式文件!");
|
|
|
return;
|
|
|
}
|
|
@@ -156,14 +185,13 @@ export default {
|
|
|
this.handleUpload();
|
|
|
}
|
|
|
|
|
|
- if(!isModifyName&&!isModifyFile){
|
|
|
+ if (!isModifyName && !isModifyFile) {
|
|
|
this.$alert("请输入模型名称或上传文件");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 异步请求,增加一层条件判断
|
|
|
- if(isModifyName&&!isModifyFile)
|
|
|
- {
|
|
|
+ if (isModifyName && !isModifyFile) {
|
|
|
this.$message.success('修改成功');
|
|
|
this.$router.push({
|
|
|
path: '/modelEdit',
|
|
@@ -303,7 +331,7 @@ export default {
|
|
|
}
|
|
|
)
|
|
|
.then((res) => {
|
|
|
- this.filePath=res.data.file_path;
|
|
|
+ this.filePath = res.data.file_path;
|
|
|
this.$message.success('修改成功');
|
|
|
console.log(res);
|
|
|
|