|
@@ -43,6 +43,7 @@
|
|
|
type="algorithmFile"
|
|
|
:objectPath="objectPath"
|
|
|
:needInstance="true"
|
|
|
+ :uploadUrl="uploadUrl"
|
|
|
@attachmentChange="attachmentChange"
|
|
|
@willUpload="willUpload"
|
|
|
@didUpload="didUpload"
|
|
@@ -69,11 +70,23 @@
|
|
|
</div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
+
|
|
|
+ <div class="progressBox" v-if="isUploading">
|
|
|
+ <div class="progress">
|
|
|
+ <el-progress
|
|
|
+ type="circle"
|
|
|
+ :width="120"
|
|
|
+ :percentage="percentage"
|
|
|
+ :color="customColor"
|
|
|
+ ></el-progress>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import upload from "@/components/upload/upload";
|
|
|
+import { mapState } from "vuex";
|
|
|
|
|
|
export default {
|
|
|
name: "exportAlgorithms", // 导入算法详情
|
|
@@ -99,16 +112,22 @@ export default {
|
|
|
{ required: true, message: "请上传", trigger: "change" },
|
|
|
],
|
|
|
},
|
|
|
- // attachmentList: [],
|
|
|
- objectPath: "",
|
|
|
+ objectPath: "", // 用于上传文件的传参
|
|
|
isUploading: false,
|
|
|
+ uploadUrl: this.$api.common.uploadProcessBar,
|
|
|
+ timer: "", // 用来接收进度条的定时器
|
|
|
+ percentage: 0, // 进度条数据
|
|
|
+ customColor: "", // 进度条颜色
|
|
|
};
|
|
|
},
|
|
|
|
|
|
+ computed: {
|
|
|
+ ...mapState(["themeColor"]),
|
|
|
+ },
|
|
|
+
|
|
|
methods: {
|
|
|
attachmentChange(obj) {
|
|
|
- // this.attachmentList = obj;
|
|
|
- console.log(obj);
|
|
|
+ // console.log(obj);
|
|
|
if (obj.length > 0) {
|
|
|
this.form.minioPath = obj[0].fileName;
|
|
|
this.$refs.form.clearValidate("minioPath");
|
|
@@ -152,24 +171,59 @@ export default {
|
|
|
},
|
|
|
}).then((res) => {
|
|
|
// console.log(res);
|
|
|
- if (res.code == 200) {
|
|
|
+ if (res.code == 200 && res.info) {
|
|
|
+ console.log(res.info);
|
|
|
|
|
|
+ if (this.percentage >= res.info * 100) {
|
|
|
+ if (this.percentage < 99) {
|
|
|
+ ++this.percentage;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.percentage = res.info * 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.percentage = Math.round(this.percentage);
|
|
|
+
|
|
|
+ if (this.percentage > 100) {
|
|
|
+ this.percentage = 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!this.isUploading) {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.percentage = 0;
|
|
|
+ }
|
|
|
} else {
|
|
|
this.$message.error(res.message || "获取进度信息失败");
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
willUpload() {
|
|
|
- setTimeout(() => {
|
|
|
- this.isUploading = true;
|
|
|
- // this.onProgress();
|
|
|
- }, 0);
|
|
|
+ this.isUploading = true;
|
|
|
+
|
|
|
+ // let timer = setTimeout(() => {
|
|
|
+ // this.isUploading = true;
|
|
|
+ // this.onProgress();
|
|
|
+ // clearTimeout(timer);
|
|
|
+ // }, 100);
|
|
|
+
|
|
|
+ this.timer = setInterval(() => {
|
|
|
+ this.onProgress();
|
|
|
+ if (!this.isUploading) {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.percentage = 0;
|
|
|
+ }
|
|
|
+ }, 3000);
|
|
|
+ },
|
|
|
+ didUpload(state) {
|
|
|
+ this.isUploading = false;
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.percentage = 0;
|
|
|
},
|
|
|
- didUpload(state) {},
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
this.objectPath = this.$getObjectPathByRandom();
|
|
|
+ this.customColor = this.themeColor;
|
|
|
|
|
|
let id = this.$route.query.id;
|
|
|
if (id) {
|
|
@@ -217,5 +271,25 @@ export default {
|
|
|
.upload {
|
|
|
margin-top: 15px;
|
|
|
}
|
|
|
+
|
|
|
+ .progressBox {
|
|
|
+ position: fixed;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ z-index: 3000;
|
|
|
+ background-color: rgba(0, 0, 0, 0.2);
|
|
|
+
|
|
|
+ .progress {
|
|
|
+ position: absolute;
|
|
|
+ top: 50%;
|
|
|
+ left: 50%;
|
|
|
+ width: 120px;
|
|
|
+ height: 120px;
|
|
|
+ margin-top: -60px;
|
|
|
+ margin-left: -60px;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|