提交 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 { ...@@ -70,19 +70,13 @@ export default {
process.env.NODE_ENV === "development" process.env.NODE_ENV === "development"
? "/api/sysFiles/upload" ? "/api/sysFiles/upload"
: process.env.NODE_ENV + "/sysFiles/upload", // 上传的图片服务器地址 : process.env.NODE_ENV + "/sysFiles/upload", // 上传的图片服务器地址
// headers: {
// authorization: getToken(),
// },
fileList: [], fileList: [],
// tempFileList: [],
// uploadDisabled: false,
upLoadList: [],
}; };
}, },
watch: { watch: {
files: { files: {
handler: function (newVal, oldVal) { handler: function (val) {
this.fileList = newVal; this.fileList = [...val];
}, },
immediate: true, immediate: true,
deep: true, deep: true,
...@@ -108,12 +102,9 @@ export default { ...@@ -108,12 +102,9 @@ export default {
return fileAccept; return fileAccept;
}, },
}, },
created() {
this.fileList = JSON.parse(JSON.stringify(this.files));
},
methods: { methods: {
getFiles(){ getFiles() {
return this.upLoadList return this.fileList;
}, },
// 上传前校检格式和大小 // 上传前校检格式和大小
handleBeforeUpload(file) { handleBeforeUpload(file) {
...@@ -161,9 +152,9 @@ export default { ...@@ -161,9 +152,9 @@ export default {
// 文件列表移除文件时的钩子 // 文件列表移除文件时的钩子
handleRemove(file, fileList) { handleRemove(file, fileList) {
this.upLoadList.map((item, index) => { this.fileList.map((item, index) => {
if (item.uid === file.uid) { if (item.uid === file.uid) {
this.upLoadList.splice(index, 1); this.fileList.splice(index, 1);
} }
}); });
}, },
...@@ -172,7 +163,7 @@ export default { ...@@ -172,7 +163,7 @@ export default {
if (file.status === "ready") { if (file.status === "ready") {
this.handleBeforeUpload(file) this.handleBeforeUpload(file)
.then((res) => { .then((res) => {
this.upLoadList.push(res); this.fileList.push(res);
}) })
.catch((err) => { .catch((err) => {
console.log("err", err); console.log("err", err);
......
...@@ -82,11 +82,6 @@ export default { ...@@ -82,11 +82,6 @@ export default {
handler: function (newVal, oldVal) { handler: function (newVal, oldVal) {
console.log("newVal", newVal); console.log("newVal", newVal);
this.fileList = newVal; this.fileList = newVal;
// if (this.fileList.length >= this.fileLimit) {
// this.uploadDisabled = true;
// }else{
// this.uploadDisabled = false;
// }
}, },
immediate: true, immediate: true,
deep: true, deep: true,
......
<template> <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"> <div class="top-bar">
<SearchBar :config="searchConfig" @search="search" @reset="reset" /> <SearchBar :config="searchConfig" @search="search" @reset="reset" />
<el-button <el-button
...@@ -67,7 +73,7 @@ ...@@ -67,7 +73,7 @@
import TablePage from "@/components/Table/TablePage.vue"; import TablePage from "@/components/Table/TablePage.vue";
import TableOperation from "@/components/Table/TableOperation.vue"; import TableOperation from "@/components/Table/TableOperation.vue";
import { title, operates, operations } from "./config"; import { title, operates, operations } from "./config";
import { getCulturalRelicList } from "@/api/culturalRelic"; import { getCulturalRelicList, getRCDetailById } from "@/api/culturalRelic";
import InfoEditDialog from "./components/InfoEditDialog"; import InfoEditDialog from "./components/InfoEditDialog";
import SearchBar from "@/components/SearchBar"; import SearchBar from "@/components/SearchBar";
...@@ -141,7 +147,7 @@ export default { ...@@ -141,7 +147,7 @@ export default {
// regionCode:'',//所属地(分号分隔的编号)——传当前用户的regionCode // regionCode:'',//所属地(分号分隔的编号)——传当前用户的regionCode
sourceWay: "", //来源方式 sourceWay: "", //来源方式
sayExplain: "", //讲解词文件。文件id sayExplain: "", //讲解词文件。文件id
status: "", //上下架状态(0-下架,1-上架) status: 0, //上下架状态(0-下架,1-上架)
// flag3d:'',//是否有3D图片(字典值:1-有;0-无) // flag3d:'',//是否有3D图片(字典值:1-有;0-无)
themeWord: "", //主题词 themeWord: "", //主题词
url3d: "", //3durl链接 url3d: "", //3durl链接
...@@ -158,8 +164,6 @@ export default { ...@@ -158,8 +164,6 @@ export default {
if (value) { if (value) {
this.dict = value; this.dict = value;
this.culturalLevel = []; this.culturalLevel = [];
console.log("this.dict ", this.dict);
} }
}, },
}, },
...@@ -227,9 +231,14 @@ export default { ...@@ -227,9 +231,14 @@ export default {
break; break;
case "edit": case "edit":
// 查询接口,并复制给form // 查询接口,并复制给form
// this.loading = true; const { crId } = row;
// let res = await getRCDetailById; this.loading = true;
// this.drawerVisible = true; let res = await getRCDetailById({ crId });
if (res.code == 0) {
this.loading = false;
this.form = res.data;
this.drawerVisible = true;
}
break; break;
// case "delete": // case "delete":
// break; // break;
...@@ -287,4 +296,7 @@ export default { ...@@ -287,4 +296,7 @@ export default {
align-items: center; align-items: center;
margin-bottom: 10px; margin-bottom: 10px;
} }
.pagination {
margin: 16px;
}
</style> </style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论