提交 14854e65 authored 作者: 龙菲's avatar 龙菲

文物修改

上级 83d4acc0
<template>
<el-upload
:action="uploadUrl"
:before-upload="handleBeforeUpload"
:on-success="handleSuccess"
:on-error="handleUploadError"
:on-remove="handleRemove"
:on-exceed="handleExceed"
:on-change="handleChange"
:file-list="fileList"
:multiple="fileLimit > 1"
:headers="headers"
:limit="fileLimit"
:list-type="listType"
name="files"
:class="{ disabled: uploadDisabled }"
:accept="fileAccept"
>
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<div slot="tip" class="el-upload__tip" style="margin-bottom: 10px">
只能上传mp3文件,且不超过2M,播放长度不超过60s
</div>
</el-upload>
</template>
<script>
export default {
beforeAvatarUpload(file) {
// 文件类型进行判断
const isAudio = file.type === "audio/mp3" || file.type === "audio/mpeg";
// 限制上传文件大小 2M
const isLt2M = file.size / 1024 / 1024 < 2;
const isTime60S = this.audioDuration >= 60 ? true : "";
// 获取时长
this.getTimes(file);
if (!isAudio) {
this.$message.error("上传文件只能是Mp3格式!");
this.fileList = [];
} else {
if (!isLt2M) {
this.$message.error("上传文件大小不能超过 2MB!");
this.fileList = [];
} else {
if (!isTime60S) {
this.$message.error("上传文件时长不能超过60秒!");
this.fileList = [];
}
}
}
return isAudio && isLt2M && isTime60S;
},
getTimes(file) {
var content = file;
//获取录音时长
var url = URL.createObjectURL(content);
//经测试,发现audio也可获取视频的时长
var audioElement = new Audio(url);
audioElement.addEventListener("loadedmetadata", (_event) => {
this.audioDuration = parseInt(audioElement.duration);
// console.log(this.audioDuration);
});
},
};
</script>
<style>
</style>
\ No newline at end of file
......@@ -70,19 +70,13 @@ export default {
process.env.NODE_ENV === "development"
? "/api/sysFiles/upload"
: process.env.NODE_ENV + "/sysFiles/upload", // 上传的图片服务器地址
// headers: {
// authorization: getToken(),
// },
fileList: [],
// tempFileList: [],
// uploadDisabled: false,
upLoadList: [],
};
},
watch: {
files: {
handler: function (newVal, oldVal) {
this.fileList = newVal;
handler: function (val) {
this.fileList = [...val];
},
immediate: true,
deep: true,
......@@ -108,12 +102,9 @@ export default {
return fileAccept;
},
},
created() {
this.fileList = JSON.parse(JSON.stringify(this.files));
},
methods: {
getFiles(){
return this.upLoadList
getFiles() {
return this.fileList;
},
// 上传前校检格式和大小
handleBeforeUpload(file) {
......@@ -161,9 +152,9 @@ export default {
// 文件列表移除文件时的钩子
handleRemove(file, fileList) {
this.upLoadList.map((item, index) => {
this.fileList.map((item, index) => {
if (item.uid === file.uid) {
this.upLoadList.splice(index, 1);
this.fileList.splice(index, 1);
}
});
},
......@@ -172,7 +163,7 @@ export default {
if (file.status === "ready") {
this.handleBeforeUpload(file)
.then((res) => {
this.upLoadList.push(res);
this.fileList.push(res);
})
.catch((err) => {
console.log("err", err);
......
......@@ -82,11 +82,6 @@ export default {
handler: function (newVal, oldVal) {
console.log("newVal", newVal);
this.fileList = newVal;
// if (this.fileList.length >= this.fileLimit) {
// this.uploadDisabled = true;
// }else{
// this.uploadDisabled = false;
// }
},
immediate: true,
deep: true,
......
<template>
<div class="app-container">
<div
class="app-container"
v-loading="loading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.3)"
>
<div class="top-bar">
<SearchBar :config="searchConfig" @search="search" @reset="reset" />
<el-button
......@@ -67,7 +73,7 @@
import TablePage from "@/components/Table/TablePage.vue";
import TableOperation from "@/components/Table/TableOperation.vue";
import { title, operates, operations } from "./config";
import { getCulturalRelicList } from "@/api/culturalRelic";
import { getCulturalRelicList, getRCDetailById } from "@/api/culturalRelic";
import InfoEditDialog from "./components/InfoEditDialog";
import SearchBar from "@/components/SearchBar";
......@@ -141,7 +147,7 @@ export default {
// regionCode:'',//所属地(分号分隔的编号)——传当前用户的regionCode
sourceWay: "", //来源方式
sayExplain: "", //讲解词文件。文件id
status: "", //上下架状态(0-下架,1-上架)
status: 0, //上下架状态(0-下架,1-上架)
// flag3d:'',//是否有3D图片(字典值:1-有;0-无)
themeWord: "", //主题词
url3d: "", //3durl链接
......@@ -158,8 +164,6 @@ export default {
if (value) {
this.dict = value;
this.culturalLevel = [];
console.log("this.dict ", this.dict);
}
},
},
......@@ -227,9 +231,14 @@ export default {
break;
case "edit":
// 查询接口,并复制给form
// this.loading = true;
// let res = await getRCDetailById;
// this.drawerVisible = true;
const { crId } = row;
this.loading = true;
let res = await getRCDetailById({ crId });
if (res.code == 0) {
this.loading = false;
this.form = res.data;
this.drawerVisible = true;
}
break;
// case "delete":
// break;
......@@ -287,4 +296,7 @@ export default {
align-items: center;
margin-bottom: 10px;
}
.pagination {
margin: 16px;
}
</style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论