提交 d457f254 authored 作者: 龙菲's avatar 龙菲

文物新增逻辑修改

上级 7949edfd
......@@ -11,3 +11,12 @@ export function getDictCode(data) {
data
})
}
// 获取树结构的字典 culturalRelicYears culturalRelicTexture
export function getDictTree(data) {
return request({
url: '/sysDictTree/listByType',
method: 'post',
data
})
}
\ No newline at end of file
......@@ -9,6 +9,7 @@
empty-text="暂无数据"
:highlight-current-row="true"
@selection-change="handleSelectionChange"
>
<el-table-column v-if="hasSelection" type="selection" width="55" />
<el-table-column
......@@ -21,6 +22,7 @@
:sortable="item.sortable ? item.sortable : false"
:align="item.columnAlign"
:header-align="item.titleAlign"
:show-overflow-tooltip="item.showOverFlowToolTip"
>
<template slot-scope="scope">
<template v-if="item.prop == 'faceImageUrl'">
......
......@@ -30,7 +30,7 @@
style="width: 100%"
>
<el-option
v-for="(value, key) in dict.cultural_relic_type"
v-for="(value, key) in dict.culturalRelicType"
:key="key"
:label="value"
:value="key"
......@@ -45,7 +45,7 @@
style="width: 100%"
>
<el-option
v-for="(value, key) in dict.cultural_relic_level"
v-for="(value, key) in dict.culturalRelicLevel"
:key="key"
:label="value"
:value="key"
......@@ -60,7 +60,7 @@
style="width: 100%"
>
<el-option
v-for="(value, key) in dict.cultural_relic_texture"
v-for="(value, key) in culturalRelicTexture"
:key="key"
:label="value"
:value="key"
......@@ -82,7 +82,7 @@
style="width: 100%"
>
<el-option
v-for="(value, key) in dict.cultural_relic_years"
v-for="(value, key) in culturalRelicYears"
:key="key"
:label="value"
:value="key"
......@@ -208,7 +208,7 @@
ref="videos"
/>
</el-form-item>
<el-form-item label="讲解词文件" :label-width="formLabelWidth">
<!-- <el-form-item label="讲解词文件" :label-width="formLabelWidth">
<ManualUploader
:files="sayExplain"
:fileLimit="6"
......@@ -216,7 +216,7 @@
:fileType="['doc', 'tet', 'docx']"
ref="sayExplain"
/>
</el-form-item>
</el-form-item> -->
<el-form-item label="文物音频" :label-width="formLabelWidth">
<ManualUploader
:files="audios"
......@@ -247,7 +247,7 @@ import { addCulturalRelic, editCulturalRelic } from "@/api/culturalRelic";
import AutoUploader from "@/components/Uploader/AutoUploader.vue";
import ManualUploader from "@/components/Uploader/ManualUploader.vue";
import { mapGetters } from "vuex";
import { upload } from "@/utils/file";
import { uploadV1 } from "@/utils/file";
export default {
name: "InfoEditDialog",
components: {
......@@ -279,48 +279,13 @@ export default {
return "新增发布";
}
},
faceImage() {
if (this.dialogForm.faceImageUrl) {
return [
{
name: "",
url: this.dialogForm.faceImageUrl,
fileId: this.dialogForm.faceImage,
},
];
} else {
return [];
}
},
images() {
if (this.dialogForm.imagesVo) {
return this.dialogForm.imagesVo;
} else {
return [];
}
},
videos() {
if (this.dialogForm.videosVo) {
return this.dialogForm.videosVo;
} else {
return [];
}
},
audios() {
if (this.dialogForm.audiosVo) {
return this.dialogForm.audiosVo;
} else {
return [];
}
},
sayExplain() {
if (this.dialogForm.sayExplainVo) {
return this.dialogForm.sayExplainVo;
} else {
return [];
}
},
// sayExplain() {
// if (this.dialogForm.sayExplainVo) {
// return this.dialogForm.sayExplainVo;
// } else {
// return [];
// }
// },
},
watch: {
form: {
......@@ -329,6 +294,23 @@ export default {
// 回填状态
this.dialogForm.status = Boolean(Number(this.dialogForm.status));
// debugger
// 回填媒体
if (this.dialogForm.faceImageUrl) {
this.faceImage = [{
name: "",
url: this.dialogForm.faceImageUrl,
fileId: this.dialogForm.faceImage,
}];
}
if (this.dialogForm.imagesVo) {
this.images = this.dialogForm.imagesVo;
}
if (this.dialogForm.videosVo) {
this.videos = this.dialogForm.videosVo;
}
if (this.dialogForm.audiosVo) {
this.audios = this.dialogForm.audiosVo;
}
// 回填文献
if (
this.dialogForm.literatureVo &&
......@@ -357,10 +339,10 @@ export default {
},
},
dicts: [
"cultural_relic_texture",
"cultural_relic_level",
"cultural_relic_years",
"cultural_relic_type",
// "cultural_relic_texture",
"culturalRelicLevel",
// "cultural_relic_years",
"culturalRelicType",
"literature",
],
data() {
......@@ -380,6 +362,12 @@ export default {
disabled: false,
literatureNames: [],
literatureValues: [], //文献绑定的数组,编辑回显时需要将后台传的值转成[id1,id2,]并赋值给它,新增时记得清空,提交时改成id 的str
faceImage: [],
images: [],
videos: [],
audios: [],
culturalRelicTexture: { 1: "铜", 1: "织绣" }, //TODO:等后台字典更新后改回
culturalRelicYears: { 1: "元(1206~1368)" },
};
},
async created() {
......@@ -423,158 +411,147 @@ export default {
this.$emit("handleClose");
this.literatureValues = [];
},
async handleSubmit() {
const mediaArr = [
"faceImage",
"images",
"videos",
"sayExplain",
"audios",
];
if (this.dialogForm.crId) {
let ps = []; //ps为涵盖5种媒体的promise集合
mediaArr.forEach((media) => {
ps.push(this.handleEditUpload(media));
});
// 处理图片等媒体
Promise.all(ps).then(
async (allResult) => {
console.log("allResult", allResult);
allResult.forEach((item, index) => {
this.dialogForm[mediaArr[index]] = item;
});
const params = { ...this.dialogForm };
params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0;
let res = await editCulturalRelic(params);
if (res.code == 0) {
this.$message.success("修改成功!");
this.loading = false;
this.literatureValues = [];
this.$emit("handleClose");
this.$emit("refresh");
this.dialogForm = {};
}
},
(reason) => {
console.log(reason);
}
);
} else {
let ps = [];
mediaArr.map((media) => {
let files = this.$refs[media].getFiles();
let fileList = [...files];
if (fileList.length > 0) {
let formData = new FormData();
fileList.forEach((file) => {
formData.append("files", file.raw);
});
ps.push(upload(formData));
} else {
ps.push(null);
}
});
Promise.all(ps).then(
async (allResult) => {
allResult.forEach((item, index) => {
if (item) {
let fileIds = [];
let files = item.data;
files.forEach((file) => {
fileIds.push(file.fileId);
});
this.dialogForm[mediaArr[index]] = fileIds.join(",");
var that = this;
let formData = new FormData();
// 已存在的文件的对象
let successFilesObj = [];
// 添加布展本身的媒体文件至formData
const mediaArr = ["faceImage", "images", "videos", "audios"];
mediaArr.map((media) => {
let files = [...this.$refs[media].getFiles()];
files.map((f) => {
switch (f.status) {
case "ready":
formData.append(media, f.raw);
break;
case "success":
if (successFilesObj[media]) {
successFilesObj[media].push(f);
} else {
this.dialogForm[mediaArr[index]] = "";
successFilesObj[media] = [f];
}
});
const { deptId, regionCode } = this.userInfo;
const params = { ...this.dialogForm, deptId, regionCode };
params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0;
let res = await addCulturalRelic(params);
if (res.code == 0) {
this.$message.success("提交成功!");
this.loading = false;
this.literatureValues = [];
this.$emit("handleClose");
this.$emit("refresh");
this.dialogForm = {};
}
},
(reason) => {
console.log(reason);
break;
}
);
}
},
});
});
// 处理编辑时图片、视频、音频、讲解词媒体资源的上传问题
handleEditUpload(media) {
return new Promise(async (resolve, reject) => {
//files中只存在(success)和新添加的(ready),不存在的已经在组件中被去除了
let files = [...this.$refs[media].getFiles()];
if (files.length > 0) {
let fileIds = [];
let fileIdStr = "";
let formData = new FormData();
files.forEach((file) => {
switch (file.status) {
case "ready":
formData.append("files", file.raw);
break;
case "success":
fileIds.push(file.fileId);
break;
// 上传所有媒体文件
let filesObj = {};
var formDataArr = Array.from(formData.entries(), ([key, prop]) => ({
[key]: {
ContentLength: typeof prop === "string" ? prop.length : prop.size,
},
}));
// formData有长度时再进行上传
if (formDataArr.length > 0) {
let upLoadRes = await uploadV1(formData);
if (upLoadRes.code == 0) {
upLoadRes.data.map((resFile) => {
if (filesObj[resFile.fileKey]) {
filesObj[resFile.fileKey].push(resFile.fileId);
} else {
filesObj[resFile.fileKey] = [resFile.fileId];
}
});
if (formData.get("files")) {
upload(formData)
.then((upRes) => {
if (upRes.code == 0) {
// 拿到已存在的和上传过后的结果进行拼接,并赋值给images,不用管imagesVo,后台自行处理
const { data } = upRes;
data.map((item) => {
fileIds.push(item.fileId);
});
fileIdStr = fileIds.join(",");
resolve(fileIdStr);
}
})
.catch((err) => {
reject(err);
});
} else {
fileIdStr = fileIds.join(",");
resolve(fileIdStr);
}
}
}
// 1、回填之前先获取已存在的文件
for (const key in successFilesObj) {
// 如果文件id中含有已上传成功的某个key,如images,则将已上传成功的images推入文件id集合
if (filesObj[key]) {
successFilesObj[key].map((sf) => {
filesObj[key].push(sf.fileId);
});
// filesObj[key].push(successFilesObj[key].fileId);
} else {
let ids = [];
successFilesObj[key].map((sf) => {
ids.push(sf.fileId);
});
filesObj[key] = ids;
}
}
console.log("successFilesObj", successFilesObj);
console.log("filesObj", filesObj);
// return;
// 2、回填布展自带的媒体文件
mediaArr.forEach((media) => {
if (filesObj[media]) {
this.dialogForm[media] = filesObj[media].join(",");
} else {
resolve("");
this.dialogForm[media] = "";
}
});
},
// 通过文件名获取文件类型
getFileType(fileName) {
let suffix = fileName.split(".")[1];
if (
suffix == "jpg" ||
suffix == "jpeg" ||
suffix == "png" ||
suffix == "gif"
) {
return "image";
} else if (suffix === "mp4" || suffix === "avi" || suffix === "mpeg") {
return "video";
} else if (suffix === "doc" || suffix === "docx") {
return "doc";
} else if (suffix === "mp3" || suffix === "wav" || suffix === "flac") {
return "audio";
if (!that.dialogForm.exhibitionId) {
const { deptId, regionCode } = this.userInfo;
const params = { ...this.dialogForm, deptId, regionCode };
params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0;
let res = await addCulturalRelic(params);
if (res.code == 0) {
this.$message.success("提交成功!");
this.loading = false;
this.literatureValues = [];
this.$emit("handleClose");
this.$emit("refresh");
this.dialogForm = {};
}
} else {
const params = { ...this.dialogForm };
params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0;
let res = await editCulturalRelic(params);
if (res.code == 0) {
this.$message.success("修改成功!");
this.loading = false;
this.literatureValues = [];
this.$emit("handleClose");
this.$emit("refresh");
this.dialogForm = {};
}
// const {
// exhibitionId,
// faceImage,
// faceImageUrl,
// images,
// audios,
// videos,
// regionCode,
// deptId,
// } = this.dialogForm;
// let literature = this.literatureValues.join(",");
// let status = this.dialogForm.status ? 1 : 0;
// // return;
// const params = {
// exhibitionId,
// audios,
// deptId,
// faceImage,
// faceImageUrl,
// images,
// regionCode,
// videos,
// status,
// literature,
// };
// console.log("修改参数-----------", params);
// // return;
// let res = await editDisplay(params);
// if (res.code == 0) {
// this.$message.success("提交成功!");
// this.loading = false;
// this.$emit("refresh");
// this.reload();
// }
}
// }
},
handleClose(done) {
this.$confirm("确认关闭?")
.then((_) => {
......
// // {
// "audios": "",//音频
// // "crId": "",//主键
// // "deptId": "",//收藏馆id!
// // "detailSize": "",//具体尺寸!
// "directory": "",//文件夹(字母或者数字命名)
// "flag3d": "",//是否有3D图片(字典值:1-有;0-无)
// "images": "",//图片文件(文件id,多个以逗号隔开)
// // "intro": "",//馆藏介绍!
// // "level": "",//文物级别(字典值)!
// "literature": "",//关联文献。id1,id2,id3
// // "name": "",//名称!
// // "num": 0,// 数量!
// // "regionCode": "",// 所属地(分号分隔的编号)!
// "remark": "",//备注
// "sayExplain": "",//讲解词文件。文件id
// "sourceWay": "",//来源方式
// "status": "",//上下架状态(0-下架,1-上架)
// // "textureType": "",//质地类别(字典值)!
// "themeWord": "",//主题词
// // "type": "",//类别(字典值)!
// "url3d": "",// 3durl链接
// "videos": "",//视频文件(文件id)
// // "years": ""//年代!
// // }
export const title = [{
prop: "name",
......@@ -78,6 +53,7 @@ export const title = [{
prop: "intro",
label: "馆藏介绍",
columnAlign: 'center',
showOverFlowToolTip:true
},
{
......
......@@ -103,10 +103,10 @@ export default {
SearchBar,
},
dicts: [
"cultural_relic_years",
"cultural_relic_level",
"cultural_relic_texture",
"cultural_relic_type",
// "cultural_relic_years",
"culturalRelicLevel",
// "cultural_relic_texture",
"culturalRelicType",
],
data() {
return {
......
......@@ -67,7 +67,6 @@
:fileLimit="1"
listType="picture-card"
:fileType="['png', 'jpeg', 'jpg']"
@handleFileReady="handleFaceImageReady"
:files="faceImage"
ref="faceImage"
/>
......@@ -79,7 +78,6 @@
:fileSize="50"
:fileType="['mp4', 'wav']"
listType="picture"
@handleFileReady="handleVideosReady"
ref="videos"
/>
</el-form-item>
......@@ -403,27 +401,25 @@ export default {
// this.showUnit = true;
// },
async handleSubmit() {
// return;
var that = this;
let formData = new FormData();
// 已存在的文件的对象
let successFilesObj = [];
// 添加布展本身的媒体文件至formData
const mediaArr = ["faceImage", "images", "videos", "audios"];
// console.log(333,this.dialogForm);
mediaArr.map((media) => {
let files = [...this.$refs[media].getFiles()];
// debugger
// if (media == "faceImage") {
// console.log(222, files);
// }
files.map((f) => {
switch (f.status) {
case "ready":
formData.append(media, f.raw);
break;
case "success":
successFilesObj[media] = f;
if (successFilesObj[media]) {
successFilesObj[media].push(f);
} else {
successFilesObj[media] = [f];
}
break;
}
// 只有待上传的才需要添加至formdata
......@@ -450,7 +446,6 @@ export default {
let exhibitionUnitsDom = this.$refs.exhibitionUnits;
let imageFiles = [];
let videoFiles = [];
debugger;
if (exhibitionUnitsDom.$refs[`unit-images-${euId}`]) {
imageFiles = [
...exhibitionUnitsDom.$refs[`unit-images-${euId}`].getFiles(),
......@@ -501,7 +496,6 @@ export default {
},
}));
console.log("formDataArr,length", formDataArr.length);
// debugger
// formData有长度时再进行上传
if (formDataArr.length > 0) {
let upLoadRes = await uploadV1(formData);
......@@ -534,11 +528,9 @@ export default {
}
console.log("successFilesObj", successFilesObj);
console.log("filesObj", filesObj);
// debugger;
// return;
// 2、回填布展自带的媒体文件
mediaArr.forEach((media) => {
// debugger;
if (filesObj[media]) {
this.dialogForm[media] = filesObj[media].join(",");
} else {
......@@ -548,11 +540,10 @@ export default {
// 3、回填布展单元媒体文件,修改关联文物为Str,和显示隐藏控制器
backFillUnit(unitData);
function backFillUnit(arr) {
// debugger
if (arr.length > 0) {
arr.map((unit) => {
// 如果进行了文件上传
// debugger
if (Object.keys(filesObj).length > 0) {
for (const key in filesObj) {
let type = key.split("-")[1];
......@@ -571,11 +562,9 @@ export default {
}
}
// 不管是否进行文件上传,都需要修改文物为Str和显示隐藏控制器,去除euid
// debugger
// 编辑时关联文物id为字符串,新增时为数组,需要重新组成
// 新增时
if (!that.dialogForm.exhibitionId) {
// debugger;
let crIdArr = unit.crIds;
unit.crIds = crIdArr.join(",");
var deleteArr = ["euId", "showMediaUploader"];
......@@ -586,7 +575,6 @@ export default {
});
} else {
// 编辑时
// debugger;
// console.log("修改时---unit.crIds ", unit.crIds);
let crIdArr = unit.crIds;
unit.crIds = crIdArr.join(",");
......@@ -597,8 +585,6 @@ export default {
}
});
}
// TODO:
// debugger;
if (unit.children) {
backFillUnit(unit.children);
}
......@@ -616,9 +602,7 @@ export default {
};
params.literature = this.literatureValues.join(",");
params.status = this.dialogForm.status ? 1 : 0;
console.log("新增参数-----------", params);
// debugger;
// return;
console.log("新增参数-----------", params);
let res = await addDisplay(params);
if (res.code == 0) {
......@@ -641,7 +625,6 @@ export default {
let literature = this.literatureValues.join(",");
let status = this.dialogForm.status ? 1 : 0;
// debugger;
// return;
const params = {
exhibitionId,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论