提交 12c29ff6 authored 作者: 龙菲's avatar 龙菲

feat:布展单元编辑修改

上级 c3c661e6
......@@ -30,6 +30,7 @@
<script>
import { getToken } from "@/utils/auth";
import { upload } from "@/utils/file";
import { deleteFiles } from "@/api/file";
export default {
name: "AutoUploader",
props: {
......@@ -180,13 +181,16 @@ export default {
this.changeFileList(fileList);
},
// 文件列表移除文件时的钩子
handleRemove(file, fileList) {
async handleRemove(file, fileList) {
this.changeFileList(fileList);
const { fileId } = file;
let res = await deleteFiles([fileId]);
if (res.code == 0) {
this.$message.success("删除成功!");
}
},
handleChange(file, fileList) {
},
handleChange(file, fileList) {},
// 文件列表改变的时候,更新组件的v-model的文的数据
changeFileList(fileList) {
......
......@@ -30,6 +30,7 @@
</template>
<script>
// import { getToken } from "@/utils/auth";
import { deleteFiles } from "@/api/file";
export default {
name: "ManualUploader",
props: {
......@@ -159,16 +160,21 @@ export default {
// 文件列表移除文件时的钩子
handleRemove(file, fileList) {
this.fileList.map((item, index) => {
this.fileList.map(async (item, index) => {
if (item.uid === file.uid) {
this.fileList.splice(index, 1);
// TODO:调用删除接口
const { fileId } = file;
let res = await deleteFiles([fileId]);
if (res.code == 0) {
this.$message.success("删除成功!");
}
}
});
},
handleChange(file, fileList) {
let that = this
let that = this;
if (file.status === "ready") {
this.handleBeforeUpload(file)
.then((res) => {
......
......@@ -86,6 +86,12 @@ export const title = [{
width: 100,
columnAlign: 'center',
},
{
prop: "faceImageUrl",
label: "封面",
columnAlign: 'center',
isFaceImage: true,
},
{
prop: "num",
label: "数量",
......
......@@ -13,7 +13,6 @@
@click.native="handleOperation({ type: 'add' })"
icon="el-icon-s-promotion"
>
发布</el-button
>
</div>
......@@ -33,6 +32,16 @@
></el-switch>
</el-popconfirm>
</template>
<template v-slot:faceImageUrl="data">
<img
:src="data.scope.faceImageUrl"
alt="查看大图"
v-if="data.scope.faceImageUrl"
style="cursor: pointer"
width="100px"
@click="handelPreviewImages(data.scope.faceImageUrl)"
/>
</template>
<template v-slot:years="data">
{{ dict.cultural_relic_years[data.scope.years] }}
</template>
......@@ -102,7 +111,7 @@ export default {
data() {
return {
list: {
record: [],
records: [],
size: 10,
current: 1,
total: 0,
......@@ -166,6 +175,8 @@ export default {
videos: "", //视频文件(文件id)
},
loading: false,
imgViewerVisible: false,
imgList: [],
};
},
watch: {
......@@ -259,6 +270,19 @@ export default {
break;
}
},
// 关闭预览图片
closeImgViewer() {
this.imgViewerVisible = false;
},
// 预览图片
handelPreviewImages(images) {
this.imgViewerVisible = true;
if (images.length > 1) {
this.imgList = images.split(",");
} else {
this.imgList = [images];
}
},
async handleChangeStatus(row) {
console.log("status", row);
const { status } = row;
......@@ -310,9 +334,9 @@ export default {
// 关闭Dialog
handleClose() {
this.drawerVisible = false;
this.form ={
status:0
}
this.form = {
status: 0,
};
},
},
};
......
......@@ -301,11 +301,11 @@ export default {
this.dialogForm.status = Boolean(Number(this.dialogForm.status));
// 回填文献
// this.literatureList = [...this.dict.literature]; //获取字典中的文献
// this.literatureNames = [];
this.literatureValues = [];
if (this.dialogForm.literatureVo.length > 0) {
this.literatureList = this.dialogForm.literatureVo
this.literatureList = this.dialogForm.literatureVo;
this.dialogForm.literatureVo.forEach((lt) => {
if (this.literatureValues) {
this.literatureValues.push(lt.literatureId);
......@@ -318,7 +318,6 @@ export default {
// 回填布展单元中的文物
// TODO:
// 先获取所有文物列表
} else {
// 新增
// 初始化布展单元
......@@ -405,7 +404,7 @@ export default {
},
async handleSubmit() {
// debugger
debugger;
// return;
var that = this;
let formData = new FormData();
......@@ -427,16 +426,35 @@ export default {
}
});
});
// 添加布展单元每条记录带的媒体至formData
let unitIds = [];
let unitData = [...this.$refs["exhibitionUnits"].getUnitData()];
loopUnits(unitData);
function loopUnits(arr) {
debugger;
// return;
// 先判断布展单元是否为空
let isUnitEmpty = true;
const emptyUnit = {
euId: 1, //后期去掉
title: "", //单元标题,类似主题名称
intro: "", //单元介绍
images: "", //图片id集合
videos: "", //视频id集合
crIds: [], //关联文物集合
showMediaUploader: false,
};
checkEmpty()
function checkEmpty() {
// 新增时,euid是有值的
}
// 添加布展单元每条记录带的媒体至formData
addMediaToFormData(unitData);
function addMediaToFormData(arr) {
if (arr.length > 0) {
arr.map((item) => {
unitIds.push(item.euId);
if (item.children) {
loopUnits(item.children);
addMediaToFormData(item.children);
}
});
}
......@@ -535,9 +553,9 @@ export default {
}
}
// 不管是否进行文件上传,都需要修改文物为Str和显示隐藏控制器,去除euid
// 编辑时文物id为字符串,新增时为数组,需要重新组成
if (!that.exhibitionId) {
// debugger
// 编辑时关联文物id为字符串,新增时为数组,需要重新组成
if (!that.dialogForm.exhibitionId) {
let crIdArr = unit.crIds;
unit.crIds = crIdArr.join(",");
var deleteArr = ["euId", "showMediaUploader"];
......@@ -548,6 +566,12 @@ export default {
});
} else {
// 编辑时
var deleteArr = ["euId", "showMediaUploader"];
deleteArr.forEach((i) => {
if (unit[i]) {
delete unit[i];
}
});
}
// TODO:
// debugger;
......@@ -558,24 +582,43 @@ export default {
}
}
const { deptId, regionCode } = this.userInfo;
const params = {
...this.dialogForm,
exhibitionUnits: unitData,
deptId,
regionCode,
};
// debugger;
// return;
params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0;
let res = await addDisplay(params);
if (res.code == 0) {
this.$message.success("提交成功!");
this.loading = false;
this.$emit("refresh");
this.reload();
if (!that.dialogForm.exhibitionId) {
const { deptId, regionCode } = this.userInfo;
const params = {
...this.dialogForm,
exhibitionUnits: unitData,
deptId,
regionCode,
};
// debugger;
// return;
params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0;
let res = await addDisplay(params);
if (res.code == 0) {
this.$message.success("提交成功!");
this.loading = false;
this.$emit("refresh");
this.reload();
}
} else {
const params = {
...this.dialogForm,
exhibitionUnits: unitData,
};
// debugger;
// return;
params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0;
let res = await editDisplay(params);
if (res.code == 0) {
this.$message.success("提交成功!");
this.loading = false;
this.$emit("refresh");
this.reload();
}
}
// }
},
// 清空编辑组件中的所有值
......
......@@ -47,7 +47,6 @@
style="height: auto; width: 100%"
class="video-container"
controls
loop
></video>
</el-col>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论