|
@@ -12,7 +12,7 @@
|
|
|
<i class="iconfont icon-empty"></i>
|
|
|
<p>点击或将文件拖拽到这里上传</p>
|
|
|
<p class="gray-font">
|
|
|
- 支持格式:mp4,mpeg,3gp,avi,宽高16:9或9:16,<500M
|
|
|
+ 支持格式:mp4,mpeg,3gp,avi,宽高16:9或9:16,<300M
|
|
|
</p>
|
|
|
<p class="gray-font">命名格式:推广书籍名称-需求方-文案</p>
|
|
|
</div>
|
|
@@ -21,12 +21,7 @@
|
|
|
<i class="iconfont icon-paper-clip"></i>
|
|
|
<p>
|
|
|
{{ item.name }}
|
|
|
- <i class="iconfont icon-guanbi" @click="deleteItem(index)"></i
|
|
|
- ><a-progress
|
|
|
- :showInfo="false"
|
|
|
- :percent="item.percent"
|
|
|
- status="active"
|
|
|
- />
|
|
|
+ <i class="iconfont icon-guanbi" @click="deleteItem(index)"></i>
|
|
|
</p>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -35,9 +30,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
|
-import { defineComponent, reactive, toRefs, ref } from "vue";
|
|
|
+import { defineComponent, reactive, toRefs, ref, watch, h } from "vue";
|
|
|
import { uploadVideo } from "@/api";
|
|
|
-import { message, Progress } from "ant-design-vue";
|
|
|
+import { message, notification } from "ant-design-vue";
|
|
|
+import { LoadingOutlined, CheckOutlined } from "@ant-design/icons-vue";
|
|
|
const UploadVideo = defineComponent({
|
|
|
components: {},
|
|
|
props: ["searchForm"],
|
|
@@ -59,9 +55,19 @@ const UploadVideo = defineComponent({
|
|
|
const { duration, height, width } = videoinfo;
|
|
|
//获取到视频的时长,高度,宽度
|
|
|
console.log(duration, height, width);
|
|
|
+ // 校验文件是否已存在于fileList
|
|
|
+ let flag = true;
|
|
|
+ if (this.fileList.length > 0) {
|
|
|
+ this.fileList.forEach((itm) => {
|
|
|
+ if (itm.name === item.name) flag = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!flag) return message.warning("文件已存在");
|
|
|
// 校验文件尺寸比例大小
|
|
|
- if (Number((item.size / 1024 / 1024).toFixed(2)) > 500)
|
|
|
- return message.warning(`视频:${item.name}大小超过了500M`);
|
|
|
+ if (this.fileList.length === 10)
|
|
|
+ return message.warning("视频数量不能超过10");
|
|
|
+ if (Number((item.size / 1024 / 1024).toFixed(2)) > 300)
|
|
|
+ return message.warning(`视频:${item.name}大小超过了300M`);
|
|
|
console.log("宽高", height / width, 16 / 9, 9 / 16);
|
|
|
// if (
|
|
|
// item.height / item.width !== 16 / 9 &&
|
|
@@ -71,7 +77,10 @@ const UploadVideo = defineComponent({
|
|
|
// `视频:${item.name}宽高比例不符合要求比例,请修改后重新上传`
|
|
|
// );
|
|
|
// 正则 /^[\u4E00-\u9FA5A-Za-z0-9]+(-|\/)[\u4E00-\u9FA5A-Za-z0-9]+(-|\/)[\u4E00-\u9FA5A-Za-z0-9]+$/ XX-XX-XX
|
|
|
- if (this.checkNumber(item.name) !== 2)
|
|
|
+ if (
|
|
|
+ this.checkNumber(item.name) !== 2 &&
|
|
|
+ this.checkNumber(item.name) !== 3
|
|
|
+ )
|
|
|
return message.warning(
|
|
|
`视频:${item.name}不符合命名要求,请修改后重新上传`
|
|
|
);
|
|
@@ -87,13 +96,22 @@ const UploadVideo = defineComponent({
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
- console.log("新增文件列表", this.fileList);
|
|
|
+ let inputFile: any = this.$refs.chooseFile;
|
|
|
+ inputFile.value = "";
|
|
|
},
|
|
|
// 确定上传视频
|
|
|
async onUploadVideo() {
|
|
|
if (this.fileList.length === 0) return message.warning("请选择视频");
|
|
|
this.$emit("close");
|
|
|
- message.info("素材上传中...");
|
|
|
+ // message.info("素材上传中...");
|
|
|
+ const key = "start";
|
|
|
+ notification.open({
|
|
|
+ key,
|
|
|
+ message: "状态提示",
|
|
|
+ description: "素材上传中...",
|
|
|
+ duration: 2.5,
|
|
|
+ icon: h(LoadingOutlined, { style: "color: #108ee9" }),
|
|
|
+ });
|
|
|
let num = 0;
|
|
|
if (this.fileList.length === 0) return message.error("请选择视频");
|
|
|
this.fileList.forEach((item) => {
|
|
@@ -109,8 +127,24 @@ const UploadVideo = defineComponent({
|
|
|
})
|
|
|
.finally(() => {
|
|
|
num++;
|
|
|
- console.log("NUM", num);
|
|
|
- if (num === this.fileList.length) message.success("素材上传完成");
|
|
|
+ console.log(
|
|
|
+ "NUM",
|
|
|
+ num,
|
|
|
+ this.fileList.length,
|
|
|
+ num === this.fileList.length
|
|
|
+ );
|
|
|
+ if (num === this.fileList.length) {
|
|
|
+ // message.success("素材上传完成")
|
|
|
+ const key2 = "final";
|
|
|
+ notification.open({
|
|
|
+ key2,
|
|
|
+ message: "状态提示",
|
|
|
+ description: "素材上传完成!",
|
|
|
+ duration: 4,
|
|
|
+ icon: h(CheckOutlined, { style: "color: greenyellow" }),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.$emit("getList");
|
|
|
});
|
|
|
});
|
|
|
},
|
|
@@ -142,6 +176,9 @@ const UploadVideo = defineComponent({
|
|
|
});
|
|
|
return num;
|
|
|
},
|
|
|
+ clearList() {
|
|
|
+ this.fileList = [];
|
|
|
+ },
|
|
|
},
|
|
|
});
|
|
|
|
|
@@ -158,7 +195,7 @@ export default UploadVideo;
|
|
|
.upload-box {
|
|
|
cursor: pointer;
|
|
|
background: rgb(250, 250, 250);
|
|
|
- border: 2px dashed rgb(212, 210, 210);
|
|
|
+ border: 2px dashed #39a4ff;
|
|
|
border-radius: 6px;
|
|
|
transition: all 0.3s;
|
|
|
padding-bottom: 10px;
|
|
@@ -172,6 +209,7 @@ export default UploadVideo;
|
|
|
p {
|
|
|
text-align: center;
|
|
|
transition: all 0.3s;
|
|
|
+ color: #39a4ff;
|
|
|
}
|
|
|
// 选择文件
|
|
|
.upload-input {
|
|
@@ -186,14 +224,15 @@ export default UploadVideo;
|
|
|
.upload-box:hover {
|
|
|
i,
|
|
|
p {
|
|
|
- color: #39a4ff !important;
|
|
|
+ color: #0829e6 !important;
|
|
|
}
|
|
|
- border-color: #39a4ff;
|
|
|
+ border-color: #0829e6;
|
|
|
}
|
|
|
.upload-list {
|
|
|
overflow: hidden;
|
|
|
.list-item {
|
|
|
margin-top: 10px;
|
|
|
+ height: 24px;
|
|
|
.icon-paper-clip {
|
|
|
width: 14px;
|
|
|
font-size: 12px;
|