fix:直播任务添加封面图

This commit is contained in:
wyx
2023-02-17 10:09:54 +08:00
parent 6f25303a58
commit 9429f27c73
2 changed files with 92 additions and 46 deletions

View File

@@ -129,36 +129,36 @@
alt=""
/>
</div>
<span style="margin-right: 14px">直播封面</span>
<span style="margin-right: 2px">直播封面</span>
</div>
<div class="item_inp">
<!-- <a-upload-->
<!-- name="avatar"-->
<!-- list-type="picture-card"-->
<!-- class="avatar-uploader"-->
<!-- :show-upload-list="false"-->
<!-- :before-upload="beforeUpload"-->
<!-- >-->
<!-- <img-->
<!-- class="i_upload_img"-->
<!-- v-if="imageUrl"-->
<!-- :src="imageUrl"-->
<!-- alt="avatar"-->
<!-- />-->
<!-- <div class="i_upload" v-else>-->
<!-- <div class="addimg">-->
<!-- <div class="heng"></div>-->
<!-- <div class="shu"></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </a-upload>-->
<!-- <div class="i_bottom">-->
<!-- <div class="tip">-->
<!-- <span style="color: #999999; margin-left: 8px"-->
<!-- >支持图片格式为jpg/jpeg/png 图片最大为2MB</span-->
<!-- >-->
<!-- </div>-->
<!-- </div>-->
<a-upload
name="avatar"
list-type="picture-card"
class="avatar-uploader"
:show-upload-list="false"
:before-upload="beforeUpload"
>
<img
class="i_upload_img"
v-if="imageUrl"
:src="imageUrl"
alt="avatar"
/>
<div class="i_upload" v-else>
<div class="addimg">
<div class="heng"></div>
<div class="shu"></div>
</div>
</div>
</a-upload>
<div class="i_bottom">
<div class="tip">
<span style="color: #999999; margin-left: 8px"
>支持图片格式为jpg/jpeg/png 图片最大为2MB</span
>
</div>
</div>
</div>
</div>
<div class="main_item2">
@@ -319,6 +319,7 @@ import dayjs from "dayjs";
import ProjectManager from "@/components/project/ProjectManagerNew";
import AddInvistRoot from "@/components/drawers/AddInvistRoot.vue";
import {Form, message} from "ant-design-vue";
import { fileUp } from "../../api/indexEval";
const removePG = () => {
formData.value.assessmentId = ''
@@ -426,8 +427,10 @@ const range = (start, end) => {
};
function timeChange(time, timeStr) {
formData.value.liveStartTime = timeStr[0]
formData.value.submitStartTime = timeStr[0]
formData.value.submitEndTime = timeStr[1]
formData.value.liveEndTime = timeStr[1]
}
const disabledDate = (current) => {
@@ -465,6 +468,40 @@ function openDrawer(i, row) {
}
defineExpose({openDrawer})
const imageUrl = ref('')
const beforeUpload = (file) => {
const isJpgOrPng =
file.type === "image/jpg" ||
file.type === "image/jpeg" ||
file.type === "image/png" ||
file.type === "image/svg" ||
file.type === "image/bmp" ||
file.type === "image/gif";
if (!isJpgOrPng) {
message.error("仅支持jpg、gif、png、jpeg、svg、bmp格式!");
return false;
}
let isLt1M = file.size / 10240 / 10240 <= 1;
if (!isLt1M) {
this.$message.error("图片大小超过10MB!");
return false;
}
const formDatas = new FormData();
formDatas.append("file", file);
fileUp(formDatas).then((res) => {
if (res.data.code === 200) {
console.log(res)
imageUrl.value = res.data
formData.value.liveCover = res.data
// state.hasImgName = file.name;
// emit("src", { id: curItem.value.id, src: res.data.data });
}
});
return false;
};
</script>
<style lang="scss">
.ant-table-striped :deep(.table-striped) td {