提交 5396cd1a authored 作者: 龙菲's avatar 龙菲

修复布展单元多个单元图片一起上传出现上传失败的情况

上级 ecca0e33
......@@ -79,6 +79,15 @@ export default {
immediate: true,
deep: true,
},
value: {
handler: function (val) {
if (val) {
this.fileList = JSON.parse(JSON.stringify(val));
}
},
immediate: true,
deep: true,
},
},
computed: {
// 是否显示提示
......@@ -165,11 +174,13 @@ export default {
handleChange(file, fileList) {
let that = this;
// debugger
if (file.status === "ready") {
this.handleBeforeUpload(file)
.then((res) => {
that.fileList.push(res);
// that.$emit('input',that.fileList)
that.$emit("input", that.fileList);
})
.catch((err) => {
console.log("err", err);
......
......@@ -2,8 +2,8 @@
<template>
<div class="exhibiton-unit" ref="exhibitionUnit">
<el-row class="tree-container" v-if="treeData.length > 0">
<el-col :span="8">
<el-tree :data="treeData" node-key="euId" default-expand-all>
<el-col :span="9">
<el-tree :data="treeData" node-key="euId" >
<div class="exhibition-units-tree-node" slot-scope="{ node, data }">
<div style="display: flex; align-items: center">
<div class="title" @click="handleClickNode(node, data)">
......@@ -48,7 +48,7 @@
</div>
</el-tree>
</el-col>
<el-col class="node-detail" :span="16">
<el-col class="node-detail" :span="15">
<el-row :gutter="20">
<el-col :span="24" class="mg-bt20">
<el-input placeholder="请输入标题" v-model="currentData.title">
......@@ -114,6 +114,22 @@
</el-col>
</el-row>
</el-collapse-transition>
<div class="next-prev">
<el-button
size="mini"
type="primary"
icon="el-icon-back"
@click="handleToUnit('prev')"
>上一节点</el-button
>
<el-button
size="mini"
type="primary"
icon="el-icon-right"
@click="handleToUnit('next')"
>下一节点</el-button
>
</div>
</el-col>
</el-row>
<el-button
......@@ -178,7 +194,6 @@ export default {
loopData(that.treeData);
function loopData(arr) {
if (arr.length > 0) {
console.log(arr);
arr.forEach((item) => {
if (item.culturalRelics && item.culturalRelics.length > 0) {
that.$set(that, "CRList", item.culturalRelics);
......@@ -247,6 +262,7 @@ export default {
},
methods: {
getUnitData() {
return this.treeData;
},
// 关联文献查询
......@@ -297,7 +313,7 @@ export default {
intro: "",
showMediaUploader: false,
images: "",
imagesVo:[],
imagesVo: [],
crIds: [],
videos: "",
children: [],
......@@ -320,7 +336,7 @@ export default {
crIds: [],
showMediaUploader: false,
images: "",
imagesVo:[],
imagesVo: [],
videos: "",
children: [],
};
......@@ -328,7 +344,7 @@ export default {
if (parent instanceof Array) {
parent.push(newChild);
} else {
parent.children.push(newChild)
parent.children.push(newChild);
}
},
remove(node, data) {
......@@ -342,8 +358,8 @@ export default {
const index = children.findIndex((d) => d.euId === data.euId);
children.splice(index, 1);
},
changeFileList(fileList){
this.currentData.imagesVo = fileList
changeFileList(fileList) {
this.currentData.imagesVo = fileList;
},
handleAddUnit(type) {
switch (type) {
......@@ -384,6 +400,60 @@ export default {
console.log("editor change!", quill, html, text);
this.content = html;
},
handleToUnit(type) {
// debugger
const { euId } = this.currentData;
let next = {};
let prev = {};
let that = this;
// debugger
traverseTree(this.treeData);
console.log("next", next);
console.log("prev", prev);
function traverseTree(arr) {
if (arr && arr.length > 0) {
arr.map((item, index) => {
if (item.euId == euId) {
console.log(item);
switch (type) {
case "next":
if (arr[index + 1]) {
next = arr[index + 1];
that.currentData = next;
} else {
that.$message.info("已是最后一个节点!");
}
break;
case "prev":
if (arr[index - 1]) {
prev = arr[index - 1];
that.currentData = prev;
} else {
that.$message.info("已是第一个节点!");
}
break;
}
} else {
// debugger
if (item.children && item.children.length > 0) {
traverseTree(item.children);
}
}
});
}
}
// this.treeData.map();
// switch (type) {
// case "prev":
// console.log(1);
// break;
// case "next":
// console.log(-1);
// break;
// }
},
},
};
</script>
......@@ -394,7 +464,7 @@ export default {
width: 100%;
flex-direction: column;
.title {
width: 100px;
width:200px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
......@@ -477,6 +547,10 @@ export default {
white-space: pre-wrap;
}
}
.next-prev {
display: flex;
justify-content: flex-end;
}
</style>
<style lang='scss' >
......
<template>
<el-dialog
:visible.sync="dialogVisible"
width="80%"
width="86%"
style="height: 98%"
:before-close="handleClose"
top="2vh"
......@@ -527,63 +527,90 @@ export default {
let unitData = [...this.$refs["exhibitionUnits"].getUnitData()];
// debugger;
// return
addUnitIds(unitData); //添加unit的id作为上传文件的key
function addUnitIds(arr) {
// 批量添加image进入formdata
addUnitImgToFormData(unitData);
function addUnitImgToFormData(arr) {
if (arr.length > 0) {
arr.map((item) => {
unitIds.push(item.euId);
// unitIds.push(item.euId);
if (item.imagesVo && item.imagesVo.length > 0) {
let imageFiles = item.imagesVo;
imageFiles.map((imgFile) => {
if (imgFile.status === "ready") {
formData.append(`unit-images-${item.euId}`, imgFile.raw);
} else {
//
if (successFilesObj[`unit-images-${item.euId}`]) {
successFilesObj[`unit-images-${item.euId}`].push(imgFile);
} else {
successFilesObj[`unit-images-${item.euId}`] = [imgFile];
}
}
});
}
if (item.children) {
addUnitIds(item.children);
addUnitImgToFormData(item.children);
}
});
}
}
unitIds.map(async (euId) => {
let exhibitionUnitsDom = this.$refs.exhibitionUnits;
let imageFiles = [];
let videoFiles = [];
if (exhibitionUnitsDom.$refs[`unit-images-${euId}`]) {
imageFiles = [
...exhibitionUnitsDom.$refs[`unit-images-${euId}`].getFiles(),
];
// debugger
}
if (exhibitionUnitsDom.$refs[`unit-videos-${euId}`]) {
videoFiles = [
...exhibitionUnitsDom.$refs[`unit-videos-${euId}`].getFiles(),
];
}
// addUnitIds(unitData); //添加unit的id作为上传文件的key
// function addUnitIds(arr) {
// if (arr.length > 0) {
// arr.map((item) => {
// unitIds.push(item.euId);
// if (item.children) {
// addUnitIds(item.children);
// }
// });
// }
// }
// unitIds.map(async (euId) => {
// let exhibitionUnitsDom = this.$refs.exhibitionUnits;
// let imageFiles = [];
// let videoFiles = [];
// if (exhibitionUnitsDom.$refs[`unit-images-${euId}`]) {
// imageFiles = [
// ...exhibitionUnitsDom.$refs[`unit-images-${euId}`].getFiles(),
// ];
// // debugger
// }
if (imageFiles.length > 0) {
imageFiles.forEach((imgFile) => {
if (imgFile.status === "ready") {
formData.append(`unit-images-${euId}`, imgFile.raw);
} else {
//
if (successFilesObj[`unit-images-${euId}`]) {
successFilesObj[`unit-images-${euId}`].push(imgFile);
} else {
successFilesObj[`unit-images-${euId}`] = [imgFile];
}
}
});
}
if (videoFiles.length > 0) {
videoFiles.forEach((videoFile) => {
if (videoFile.status === "ready") {
formData.append(`unit-videos-${euId}`, videoFile.raw);
} else {
if (successFilesObj[`unit-videos-${euId}`]) {
successFilesObj[`unit-videos-${euId}`].push(videoFiles);
} else {
successFilesObj[`unit-videos-${euId}`] = [videoFiles];
}
}
});
}
});
// if (exhibitionUnitsDom.$refs[`unit-videos-${euId}`]) {
// videoFiles = [
// ...exhibitionUnitsDom.$refs[`unit-videos-${euId}`].getFiles(),
// ];
// }
// if (imageFiles.length > 0) {
// imageFiles.forEach((imgFile) => {
// if (imgFile.status === "ready") {
// formData.append(`unit-images-${euId}`, imgFile.raw);
// } else {
// //
// if (successFilesObj[`unit-images-${euId}`]) {
// successFilesObj[`unit-images-${euId}`].push(imgFile);
// } else {
// successFilesObj[`unit-images-${euId}`] = [imgFile];
// }
// }
// });
// }
// if (videoFiles.length > 0) {
// videoFiles.forEach((videoFile) => {
// if (videoFile.status === "ready") {
// formData.append(`unit-videos-${euId}`, videoFile.raw);
// } else {
// if (successFilesObj[`unit-videos-${euId}`]) {
// successFilesObj[`unit-videos-${euId}`].push(videoFiles);
// } else {
// successFilesObj[`unit-videos-${euId}`] = [videoFiles];
// }
// }
// });
// }
// });
// 上传所有媒体文件
let filesObj = {};
......
......@@ -19,7 +19,7 @@
<template v-slot:status="data">
<el-popconfirm
:title="getStatusTitle(data.scope.status)"
@confirm="handleChangeStatus(data.scope.status)"
@onConfirm="handleChangeStatus(data.scope)"
>
<el-switch
slot="reference"
......@@ -98,7 +98,12 @@
import TablePage from "@/components/Table/TablePage.vue";
import TableOperation from "@/components/Table/TableOperation.vue";
import { title, operates, operations } from "./config";
import { getList, deleteDisplay, getDisplayById } from "@/api/display";
import {
getList,
deleteDisplay,
getDisplayById,
editDisplay,
} from "@/api/display";
import InfoEditDialog from "./components/InfoEditDialog";
import PreviewDialog from "./components/PreviewDialog";
import CopyDialog from "./components/CopyDialog";
......@@ -238,7 +243,7 @@ export default {
}
},
handlePreview(){
handlePreview() {
// debugger
// this.previewDialogVisible = true;
// console.log(this.previewDialogVisible);
......@@ -271,8 +276,18 @@ export default {
break;
}
},
handleChangeStatus(status) {
console.log("status", status);
async handleChangeStatus(row) {
const { status } = row;
let newStatus = status === "0" ? "1" : "0";
const params = {
...row,
status: newStatus,
};
let res = await editDisplay(params);
if (res.code == 0) {
this.loadData();
this.$message.success("修改成功!");
}
},
// 多选
handleSelectionChange(val) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论