修改提交

This commit is contained in:
曹辉 2023-05-04 09:53:53 +08:00
parent 773069592b
commit 451ad0dbd6
2 changed files with 26 additions and 19 deletions

View File

@ -30,18 +30,19 @@
<div class="avatar-upload-preview"> <div class="avatar-upload-preview">
<video <video
style="width: 100%; height: 100%" style="width: 100%; height: 100%"
v-if="videoForm.showVideoPath"
v-bind:src="videoForm.showVideoPath" v-bind:src="videoForm.showVideoPath"
class="avatar video-avatar" class="avatar video-avatar"
controls="controls" controls="controls"
>您的浏览器不支持视频播放</video> >您的浏览器不支持视频播放</video>
<img style="width: 100%; height: 100%" v-if="previews.url" :src="previews.url" />
<div v-else></div>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<br /> <br />
<el-progress v-if="progressFlag" :percentage="loadProgress"></el-progress> <el-progress
v-if="progressFlag"
:percentage="loadProgress"
style="height:30px;padding-bottom:20px"
></el-progress>
<el-row style="padding-bottom:0px"> <el-row style="padding-bottom:0px">
<el-col :lg="3" :md="2"> <el-col :lg="3" :md="2">
<el-upload <el-upload
@ -53,14 +54,16 @@
:auto-upload="false" :auto-upload="false"
:on-change="loadJsonFromFile" :on-change="loadJsonFromFile"
:data="filedata" :data="filedata"
:headers="headers"
:on-progress="uploadVideoProcess" :on-progress="uploadVideoProcess"
:on-success="handleAvatarSuccess"
> >
<el-button slot="trigger" size="small" type="primary" style="float:left">选取文件</el-button> <el-button slot="trigger" size="small" type="primary" style="float:left">选取文件</el-button>
</el-upload> </el-upload>
</el-col> </el-col>
<el-col :lg="{ span: 2, offset: 18 }" :md="2"> <el-col :lg="{ span: 2, offset: 18 }" :md="2">
<el-button v-if="uploadbtn" type="primary" size="small" @click="submitUpload"> </el-button> <el-button v-if="uploadbtn" type="primary" size="small" @click="submitUpload"> </el-button>
<el-button v-else :loading="!uploadbtn" type="primary" size="small"> ...</el-button> <el-button v-else :loading="!uploadbtn" type="primary" size="small">交中...</el-button>
</el-col> </el-col>
</el-row> </el-row>
<!-- <el-upload <!-- <el-upload
@ -126,6 +129,7 @@
import { VueCropper } from "vue-cropper"; import { VueCropper } from "vue-cropper";
import baseurl from "@/api/baseurl.js"; import baseurl from "@/api/baseurl.js";
import { uploadVideoUrl } from "@/api/system/stationAvatar.js"; import { uploadVideoUrl } from "@/api/system/stationAvatar.js";
import { getToken } from "@/utils/auth";
export default { export default {
components: { VueCropper }, components: { VueCropper },
props: ["img", "type", "item", "tovideo"], props: ["img", "type", "item", "tovideo"],
@ -145,6 +149,9 @@ export default {
filedata: { filedata: {
type: "" type: ""
}, },
headers: {
Authorization: "Bearer " + getToken() // token
},
options: { options: {
img: null, // img: null, //
autoCrop: true, // autoCrop: true, //
@ -164,6 +171,7 @@ export default {
}; };
}, },
created() { created() {
this.uploadbtn = true;
this.filedata.type = this.type; this.filedata.type = this.type;
this.items = this.item; this.items = this.item;
this.video.VideoPath = baseurl + this.tovideo; this.video.VideoPath = baseurl + this.tovideo;
@ -172,25 +180,16 @@ export default {
watch: { watch: {
tovideo: { tovideo: {
handler(newimg, oldimg) { handler(newimg, oldimg) {
this.uploadbtn = true;
this.video.VideoPath = baseurl + this.tovideo; this.video.VideoPath = baseurl + this.tovideo;
} }
}, },
item: { item: {
handler(newimg, oldimg) { handler(newimg, oldimg) {
this.uploadbtn = true;
this.items = this.item; this.items = this.item;
} }
}, },
img: {
handler(newimg, oldimg) {
if (this.img == null) {
this.options.img = null;
} else if (this.img == "") {
this.options.img = null;
} else {
this.options.img = baseurl + this.img;
}
}
},
type: { type: {
handler(newimg, oldimg) { handler(newimg, oldimg) {
this.filedata.type = this.type; this.filedata.type = this.type;
@ -218,7 +217,7 @@ export default {
}; };
}, },
submitUpload() { submitUpload() {
this.uploadbtn = true; this.uploadbtn = false;
this.$refs.upload.submit(); this.$refs.upload.submit();
}, },
handlePreview(file) {}, handlePreview(file) {},
@ -255,6 +254,15 @@ export default {
// this.options.img = reader.result; // this.options.img = reader.result;
}; };
}, },
handleAvatarSuccess(res, file) {
console.log(res);
this.video.VideoPath = baseurl + res.imgUrl;
this.items.itemDirectoryUrl = res.imgUrl;
this.$emit("item", JSON.stringify(this.items));
this.$modal.msgSuccess("上传视频成功");
this.openimg = false;
this.uploadbtn = true;
},
// //
uploadImg() { uploadImg() {
this.uploadbtn = true; this.uploadbtn = true;
@ -289,7 +297,6 @@ export default {
}, },
// //
closeDialog() { closeDialog() {
this.imgs = "";
this.visible = false; this.visible = false;
} }
} }

View File

@ -1389,7 +1389,7 @@ export default {
background: none; background: none;
} }
::v-deep .wihi:hover:after { ::v-deep .wihi:hover:after {
transform: translate(0%, 30%); transform: translate(0%, 40%);
} }
::v-deep .video-avatar { ::v-deep .video-avatar {
transform: translateX(-25%); transform: translateX(-25%);