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

feat:布展单元编辑修改

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