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

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

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