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

修复文物编辑缺陷

上级 7018502f
...@@ -73,6 +73,7 @@ export default { ...@@ -73,6 +73,7 @@ export default {
data() { data() {
return { return {
fileList: [], fileList: [],
removedIds:[],//被删除的文件Id集合
}; };
}, },
watch: { watch: {
...@@ -138,11 +139,20 @@ export default { ...@@ -138,11 +139,20 @@ export default {
if (item.status == "ready") { if (item.status == "ready") {
return item; return item;
} else { } else {
item.url = item.highImg; const {highImg,lowImg,name,fileId,status} =item
item.pressUrl = item.lowImg; const obj = {
item.name = item.name; urL:highImg,
item.fileId = item.fileId; pressUrl:lowImg,
return item; name,
fileId,
status,
}
// item.url = item.highImg;
// item.pressUrl = item.lowImg;
// item.name = item.name;
// item.fileId = item.fileId;
// item.status =
return obj;
} }
}); });
return newFileList; return newFileList;
...@@ -197,6 +207,11 @@ export default { ...@@ -197,6 +207,11 @@ export default {
// 文件列表移除文件时的钩子 // 文件列表移除文件时的钩子
handleRemove(file, fileList) { handleRemove(file, fileList) {
let that = this; let that = this;
const { status } = file;
if (status == "success") {
this.removedIds.push(file.fileId);
this.$emit('getRemovedIds',this.removedIds)
}
that.fileList.map(async (item, index) => { that.fileList.map(async (item, index) => {
if (item.uid === file.uid) { if (item.uid === file.uid) {
that.fileList.splice(index, 1); that.fileList.splice(index, 1);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* 本文件用于处理文物的相关文件上传过程中的函数 * 本文件用于处理文物的相关文件上传过程中的函数
* 注意不要使用this可能导致找不到等问题,内部调用内部方法时直接使用fileUploadFuctions * 注意不要使用this可能导致找不到等问题,内部调用内部方法时直接使用fileUploadFuctions
*/ */
import { deleteFiles } from "@/api/file";
const fileUploadFuctions = { const fileUploadFuctions = {
/** /**
* 判断文件是否上传过 * 判断文件是否上传过
...@@ -58,17 +59,46 @@ const fileUploadFuctions = { ...@@ -58,17 +59,46 @@ const fileUploadFuctions = {
* @param {Array} mediaKeys 媒体keys数组 * @param {Array} mediaKeys 媒体keys数组
* @returns {Object} 已经存在(数据库已存储的)文件ID对象 * @returns {Object} 已经存在(数据库已存储的)文件ID对象
*/ */
getOldIdsObj(mediaKeys, dialogForm) { getOldIdsObj(mediaKeys, dialogForm, $el) {
// debugger
let oldFileIdsObj = {}; let oldFileIdsObj = {};
// 文物的3D文件和封面需要单独处理
mediaKeys.forEach((key) => { mediaKeys.forEach((key) => {
if (dialogForm[key]) { // 因为封面和3D文件的旧ID就是dialogForm的faceImage和file3d,此时还是旧的
oldFileIdsObj[key] = dialogForm[key]; // 新的在调用组件的this.faceImage和this.file3d对象里
if (key == "faceImage") {
oldFileIdsObj.faceImage = dialogForm.faceImage;
return;
}
if (key == "file3d") {
oldFileIdsObj.file3d = dialogForm.file3d;
return;
}
// const voKey = `${key}Vo`;
if ($el.$refs[key]) {
// 已存在的文件status为success
const files = $el.$refs[key].getFiles();
const successItems = files.filter((item) => {
return item.status == "success";
});
if (successItems.length > 0) {
// 获取他们的fileId
oldFileIdsObj[key] = successItems
.map((item) => {
return item.fileId;
})
.join(",");
} else {
oldFileIdsObj[key] = "";
}
} else { } else {
oldFileIdsObj[key] = ""; oldFileIdsObj[key] = "";
} }
}); });
return oldFileIdsObj; return oldFileIdsObj;
}, },
/** /**
* 获取返回结果中的文件id对象 * 获取返回结果中的文件id对象
* @param {Array} mediaKeys 媒体keys数组 * @param {Array} mediaKeys 媒体keys数组
...@@ -111,13 +141,27 @@ const fileUploadFuctions = { ...@@ -111,13 +141,27 @@ const fileUploadFuctions = {
* @returns {string} 新上传的文件id字符串 * @returns {string} 新上传的文件id字符串
*/ */
getMergedIdsObj(oldObj, newObj, mediaKeys) { getMergedIdsObj(oldObj, newObj, mediaKeys) {
// debugger;
const obj = {}; const obj = {};
mediaKeys.forEach((key) => { mediaKeys.forEach((key) => {
let newArr = newObj[key].split(","); if (key == "file3d" || key == "faceImage") {
let oldArr = oldObj[key].split(","); obj[key] = newObj[key];
return;
}
let newArr = [];
let oldArr = [];
if (newObj[key]) {
newArr = newObj[key].split(",");
}
if (oldObj[key]) {
oldArr = oldObj[key].split(",");
}
let fullArr = [...new Set([...newArr, ...oldArr])]; let fullArr = [...new Set([...newArr, ...oldArr])];
let fullStr = fullArr.join(","); let fullStr = "";
obj[key] = fullStr.substring(0, fullStr.length - 1); if (fullArr.length > 0) {
fullStr = fullArr.join(",");
}
obj[key] = fullStr;
}); });
return obj; return obj;
}, },
...@@ -145,8 +189,8 @@ const fileUploadFuctions = { ...@@ -145,8 +189,8 @@ const fileUploadFuctions = {
}, },
/** /**
* @param {array} fileArr 需要被删除的文件ID数组 * @param {array} fileArr 需要被删除的文件ID数组
*/ */
async handleDeleteFiles(fileArr) { async handleDeleteFiles(fileArr) {
console.log("doing delete"); console.log("doing delete");
if (fileArr.length == 0) { if (fileArr.length == 0) {
...@@ -156,6 +200,5 @@ const fileUploadFuctions = { ...@@ -156,6 +200,5 @@ const fileUploadFuctions = {
await deleteFiles(fileArr); await deleteFiles(fileArr);
console.log("delete done"); console.log("delete done");
}, },
}; };
export default fileUploadFuctions; export default fileUploadFuctions;
// 本文件提供一些前端和后端数据交互和转换的一些方法,可批量使用的 // 本文件提供一些前端和后端数据交互和转换的一些方法,可批量使用的
const transformData = { const transformData = {
/** /**
* 转换服务器的封面数据到前端可用的封面数据 * 转换服务器的封面数据到前端可用的封面数据
* @param {String} faceImagePressUrl 压缩过得封面 * @param {String} faceImage 封面文件ID
* @param {String} faceImageUrl 封面原图 * @param {String} faceImageUrl 封面原图
* @param {String} faceImagePressUrl 压缩过的封面
* @returns {Array} el-upload组件需要的数据 * @returns {Array} el-upload组件需要的数据
*/ */
faceImageToClient(faceImagePressUrl, faceImageUrl) { faceImageToClient(faceImage, faceImageUrl, faceImagePressUrl) {
if (!faceImageUrl) { if (!faceImageUrl) {
return []; return [];
} }
const faceImage = [ const result = [
{ {
name: "", name: "",
url: faceImageUrl || "", url: faceImageUrl || "",
...@@ -19,7 +19,7 @@ const transformData = { ...@@ -19,7 +19,7 @@ const transformData = {
fileId: faceImage || "", fileId: faceImage || "",
}, },
]; ];
return faceImage; return result;
}, },
/** /**
...@@ -88,6 +88,15 @@ const transformData = { ...@@ -88,6 +88,15 @@ const transformData = {
* @returns {Boolean} 组件需要的布尔值 * @returns {Boolean} 组件需要的布尔值
*/ */
statusStrToBool(statusString) { statusStrToBool(statusString) {
if (
!(
statusString &&
statusString instanceof String &&
statusString instanceof Number
)
) {
return;
}
const statusBoolean = Boolean(Number(statusString)); const statusBoolean = Boolean(Number(statusString));
return statusBoolean; return statusBoolean;
}, },
......
<template> <template>
<el-dialog <el-dialog
:visible.sync="dialogVisible" :visible.sync="visible"
width="80%" width="80%"
:before-close="handleClose" :before-close="handleClose"
top="2vh" top="2vh"
...@@ -213,6 +213,7 @@ ...@@ -213,6 +213,7 @@
listType="picture-card" listType="picture-card"
:fileType="['png', 'jpeg', 'jpg']" :fileType="['png', 'jpeg', 'jpg']"
ref="faceImage" ref="faceImage"
@getRemovedIds="getRemovedIds"
/> />
</el-form-item> </el-form-item>
<el-form-item label="文物图片" :label-width="formLabelWidth"> <el-form-item label="文物图片" :label-width="formLabelWidth">
...@@ -223,6 +224,7 @@ ...@@ -223,6 +224,7 @@
listType="picture-card" listType="picture-card"
:fileType="['png', 'jpeg', 'jpg']" :fileType="['png', 'jpeg', 'jpg']"
ref="images" ref="images"
@getRemovedIds="getRemovedIds"
/> />
</el-form-item> </el-form-item>
...@@ -234,6 +236,7 @@ ...@@ -234,6 +236,7 @@
:fileType="['mp4']" :fileType="['mp4']"
listType="text" listType="text"
ref="videos" ref="videos"
@getRemovedIds="getRemovedIds"
/> />
</el-form-item> </el-form-item>
...@@ -245,6 +248,7 @@ ...@@ -245,6 +248,7 @@
:fileType="['OBJ', 'STL', 'FBX', '3DS']" :fileType="['OBJ', 'STL', 'FBX', '3DS']"
listType="text" listType="text"
ref="file3d" ref="file3d"
@getRemovedIds="getRemovedIds"
/> />
</el-form-item> </el-form-item>
<el-form-item label="文物音频" :label-width="formLabelWidth"> <el-form-item label="文物音频" :label-width="formLabelWidth">
...@@ -255,6 +259,7 @@ ...@@ -255,6 +259,7 @@
:fileType="['mp3']" :fileType="['mp3']"
listType="text" listType="text"
ref="audios" ref="audios"
@getRemovedIds="getRemovedIds"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -262,7 +267,7 @@ ...@@ -262,7 +267,7 @@
</el-form> </el-form>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button @click="cancelForm" size="mini">取 消</el-button> <el-button @click="handleClose" size="mini">取 消</el-button>
<el-button <el-button
type="primary" type="primary"
size="mini" size="mini"
...@@ -282,7 +287,6 @@ import { getLiteratureList } from "@/api/literature"; ...@@ -282,7 +287,6 @@ import { getLiteratureList } from "@/api/literature";
import { addOrUpdateCulturalRelic } from "@/api/culturalRelic"; import { addOrUpdateCulturalRelic } from "@/api/culturalRelic";
import { mapGetters, mapActions } from "vuex"; import { mapGetters, mapActions } from "vuex";
import { uploadV1 } from "@/utils/file"; import { uploadV1 } from "@/utils/file";
import { deleteFiles } from "@/api/file";
import { rules } from "../configs/validateRules"; import { rules } from "../configs/validateRules";
import fileUploadFunctions from "@/utils/fileUploadFuctions"; import fileUploadFunctions from "@/utils/fileUploadFuctions";
import transformData from "@/utils/transformData"; import transformData from "@/utils/transformData";
...@@ -299,10 +303,6 @@ const { ...@@ -299,10 +303,6 @@ const {
export default { export default {
name: "InfoEditDialog", name: "InfoEditDialog",
props: { props: {
visible: {
type: Boolean,
default: false,
},
form: { form: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
...@@ -311,6 +311,9 @@ export default { ...@@ -311,6 +311,9 @@ export default {
computed: { computed: {
...mapGetters(["userInfo", "dicts"]), ...mapGetters(["userInfo", "dicts"]),
title() { title() {
if (!this.dialogForm) {
return;
}
if (this.dialogForm.crId) { if (this.dialogForm.crId) {
return "修改文物信息"; return "修改文物信息";
} else { } else {
...@@ -319,13 +322,6 @@ export default { ...@@ -319,13 +322,6 @@ export default {
}, },
}, },
watch: { watch: {
visible: {
handler: function (value) {
this.dialogVisible = value;
},
immediate: true,
deep: true,
},
form: { form: {
handler(value) { handler(value) {
if (!value) { if (!value) {
...@@ -339,13 +335,15 @@ export default { ...@@ -339,13 +335,15 @@ export default {
}, },
data() { data() {
return { return {
dialogForm: { // dialogForm: {
...this.form, // ...this.form,
}, // },
visible: false,
formLabelWidth: "100px", formLabelWidth: "100px",
loading: false, loading: false,
submitLoading: false, submitLoading: false,
loadingText: "", loadingText: "",
dialogForm: {},
literatureList: [], //服务器获得的文献列表 literatureList: [], //服务器获得的文献列表
literatureIdArr: [], //文献ID集合,用于绑定数据 literatureIdArr: [], //文献ID集合,用于绑定数据
faceImage: [], faceImage: [],
...@@ -361,7 +359,6 @@ export default { ...@@ -361,7 +359,6 @@ export default {
children: "children", children: "children",
checkStrictly: true, checkStrictly: true,
}, },
dialogVisible: false,
orgTreeData: [], orgTreeData: [],
optionProps: { optionProps: {
value: "id", value: "id",
...@@ -371,6 +368,7 @@ export default { ...@@ -371,6 +368,7 @@ export default {
}, },
rules, rules,
mediaKeys: ["faceImage", "images", "videos", "audios", "file3d"], //表单中的媒体 mediaKeys: ["faceImage", "images", "videos", "audios", "file3d"], //表单中的媒体
removedIds: [], //被删除掉的文件
}; };
}, },
async created() { async created() {
...@@ -395,6 +393,7 @@ export default { ...@@ -395,6 +393,7 @@ export default {
covertServerData(serverData) { covertServerData(serverData) {
this.dialogForm = JSON.parse(JSON.stringify(serverData)); this.dialogForm = JSON.parse(JSON.stringify(serverData));
const { const {
faceImage,
faceImageUrl, faceImageUrl,
faceImagePressUrl, faceImagePressUrl,
imagesVo, imagesVo,
...@@ -407,7 +406,11 @@ export default { ...@@ -407,7 +406,11 @@ export default {
file3dUrl, file3dUrl,
} = this.dialogForm; } = this.dialogForm;
this.dialogForm.status = statusStrToBool(status); this.dialogForm.status = statusStrToBool(status);
this.faceImage = faceImageToClient(faceImagePressUrl, faceImageUrl); this.faceImage = faceImageToClient(
faceImage,
faceImageUrl,
faceImagePressUrl
);
this.file3d = file3dToClient(file3d, file3dUrl); this.file3d = file3dToClient(file3d, file3dUrl);
this.images = imagesVo || []; this.images = imagesVo || [];
this.videos = videosVo || []; this.videos = videosVo || [];
...@@ -438,17 +441,6 @@ export default { ...@@ -438,17 +441,6 @@ export default {
} }
}, 500); }, 500);
}, },
// 取消编辑
cancelForm() {
this.$emit("handleClose");
if (this.loading) {
this.loading = false;
}
if (this.submitLoading) {
this.submitLoading = false;
}
this.reset();
},
/** /**
* @param {Object} dialogForm 当前表单 * @param {Object} dialogForm 当前表单
...@@ -465,6 +457,8 @@ export default { ...@@ -465,6 +457,8 @@ export default {
this.$refs.form.validate(async (valid, err) => { this.$refs.form.validate(async (valid, err) => {
if (valid) { if (valid) {
this.submitLoading = true; this.submitLoading = true;
// console.log('this.removedIds',this.removedIds);
// return
this.uploadMediaFiles(this.mediaKeys, this.dialogForm) this.uploadMediaFiles(this.mediaKeys, this.dialogForm)
.then(async (mediaForm) => { .then(async (mediaForm) => {
// console.log(mediaForm); // console.log(mediaForm);
...@@ -477,12 +471,16 @@ export default { ...@@ -477,12 +471,16 @@ export default {
form.years = this.processYear(years); form.years = this.processYear(years);
form.textureType = this.processTextureType(textureType); form.textureType = this.processTextureType(textureType);
form.deptId = getDeptIdStr(deptId); form.deptId = getDeptIdStr(deptId);
let res = await addOrUpdateCulturalRelic(form); const res = await addOrUpdateCulturalRelic(form);
this.submitLoading = false; this.submitLoading = false;
if (res.code == 0) { if (res.code == 0) {
this.$message.success("提交成功!"); this.$message.success("提交成功!");
const { handleDeleteFiles } = fileUploadFunctions;
handleDeleteFiles(this.removedIds);
this.visible = false;
this.reset();
this.$emit("refresh"); this.$emit("refresh");
this.$emit("handleClose"); // 提交成功后再删除,因为可能没成功的话要保留原本的数据
} }
}) })
.catch((err) => { .catch((err) => {
...@@ -529,9 +527,7 @@ export default { ...@@ -529,9 +527,7 @@ export default {
getNewIdsObj, getNewIdsObj,
getOldIdsObj, getOldIdsObj,
getMergedIdsObj, getMergedIdsObj,
getDeleteFileArr,
isFormDataHasData, isFormDataHasData,
handleDeleteFiles,
} = fileUploadFunctions; } = fileUploadFunctions;
const formData = getNeedUploadFormData(this, mediaKeys); const formData = getNeedUploadFormData(this, mediaKeys);
try { try {
...@@ -541,26 +537,16 @@ export default { ...@@ -541,26 +537,16 @@ export default {
let upLoadRes = await uploadV1(formData); let upLoadRes = await uploadV1(formData);
if (upLoadRes.code == 0) { if (upLoadRes.code == 0) {
const newIdObj = getNewIdsObj(mediaKeys, upLoadRes); const newIdObj = getNewIdsObj(mediaKeys, upLoadRes);
const oldIdObj = getOldIdsObj(mediaKeys, dialogForm); const oldIdObj = getOldIdsObj(mediaKeys, dialogForm, this);
const mergedIdObj = getMergedIdsObj( const mediaForm = getMergedIdsObj(oldIdObj, newIdObj, mediaKeys);
oldIdObj, console.log("mediaForm", mediaForm);
newIdObj, resolve(mediaForm);
mediaKeys
);
const deleteIdArr = getDeleteFileArr(
oldIdObj,
newIdObj,
mediaKeys
);
handleDeleteFiles(deleteIdArr);
console.log("mergedFileIdsObj", mergedIdObj);
console.log("deleteFiles", deleteIdArr);
console.log("uploadMediaFiles done");
resolve(mergedIdObj);
} }
} else { } else {
console.log("uploadMediaFiles nothing to upload"); // 没有任何媒体需要上传的,把已有的交给后面
resolve({}); const mediaForm = getOldIdsObj(mediaKeys, dialogForm, this);
console.log("uploadMediaFiles nothing to upload", mediaForm);
resolve(mediaForm);
} }
} catch (error) { } catch (error) {
console.error("uploadMediaFiles error"); console.error("uploadMediaFiles error");
...@@ -572,31 +558,39 @@ export default { ...@@ -572,31 +558,39 @@ export default {
handleClose(done) { handleClose(done) {
this.$confirm("确认关闭?") this.$confirm("确认关闭?")
.then((_) => { .then((_) => {
done(); this.visible = false;
this.$emit("handleClose");
this.reset(); this.reset();
this.submitLoading = false; if (this.loading) {
this.loading = false;
}
if (this.submitLoading) {
this.submitLoading = false;
}
done();
}) })
.catch((_) => {}); .catch((_) => {});
}, },
// 清空编辑组件中的所有值 // 清空编辑组件中的所有值
reset() { reset() {
//父组件将清空form绑定的值 //父组件将清空form绑定的值
// 清空文献 this.dialogForm = {};
this.literatureIdArr = []; this.literatureIdArr = [];
this.images = []; this.images = [];
this.videos = []; this.videos = [];
this.audios = []; this.audios = [];
this.faceImage = []; this.faceImage = [];
this.$refs.form.resetFields(); this.removedIds = [];
this.file3d = [];
this.$refs.form?.resetFields();
}, },
refresh() { refresh() {
this.$emit("refresh"); this.$emit("refresh");
}, },
editorInput(e) { getRemovedIds(removedIds) {
console.log(e); this.removedIds = [...new Set([...this.removedIds, ...removedIds])];
console.log("this.removedIds", this.removedIds);
}, },
}, },
}; };
......
/**
* 本文件用于处理文物的相关文件上传过程中的函数
* 注意不要使用this可能导致找不到等问题,内部调用内部方法时直接使用fileUploadFuctions
*/
const fileUploadFuctions = {
/**
* 判断文件是否上传过
* @param {File | Object} file 文件对象,可能是File可能就是普通对象
* @returns {Boolean} 文件是否上传过
*/
isFileRaw(file) {
let isFileRaw = false;
isFileRaw = file.status && file.status == "ready";
return isFileRaw;
},
/**
* 判断formData中是否有数据
* @param {FormData} formData 文件对象,可能是File可能就是普通对象
* @returns {Boolean} formData中是否有数据
*/
isFormDataHasData(formData) {
const formDataArr = Array.from(formData.entries(), ([key, prop]) => ({
[key]: {
ContentLength: typeof prop === "string" ? prop.length : prop.size,
},
}));
return formDataArr.length > 0;
},
/**
* 获取对应媒体下的文件
* @param {string} mediaKey 媒体key
* @returns {Array} 媒体对应的文件
*/
getMediaFile($el, mediaKey) {
return $el.$refs[mediaKey].getFiles();
},
/**
* 获取需要上传的FormData
* @param {Array} mediaKeys 媒体keys数组
* @returns {FormData} formData 需要上传的formdata
*/
getNeedUploadFormData($el, mediaKeys) {
const formData = new FormData();
mediaKeys.forEach((mediaKey) => {
const currentFileList = fileUploadFuctions.getMediaFile($el, mediaKey);
currentFileList.forEach((file) => {
if (fileUploadFuctions.isFileRaw(file)) {
formData.append(mediaKey, file.raw);
}
});
});
return formData;
},
/**
* 获取需要已经存在(数据库已存储的)文件ID对象
* @param {Array} mediaKeys 媒体keys数组
* @returns {Object} 已经存在(数据库已存储的)文件ID对象
*/
getOldIdsObj(mediaKeys, dialogForm) {
let oldFileIdsObj = {};
mediaKeys.forEach((key) => {
if (dialogForm[key]) {
oldFileIdsObj[key] = dialogForm[key];
} else {
oldFileIdsObj[key] = "";
}
});
return oldFileIdsObj;
},
/**
* 获取返回结果中的文件id对象
* @param {Array} mediaKeys 媒体keys数组
* @param {Object} requestRes 上传返回的数据对象
* @returns {Object} 新上传的文件id对象
*/
getNewIdsObj(mediaKeys, requestRes) {
let newUploadedFileIdsObj = {};
mediaKeys.forEach((key) => {
newUploadedFileIdsObj[key] = fileUploadFuctions.getResIdStrByMedia(
key,
requestRes
);
});
return newUploadedFileIdsObj;
},
/**
* 获取上传返回结果中的id字符串
* @param {Array} mediaKeys 媒体keys数组
* @param {Object} requestRes 上传返回的数据对象
* @returns {string} 新上传的文件id字符串
*/
getResIdStrByMedia(mediaKey, requestRes) {
const arr = [];
requestRes.data.forEach((item) => {
if (item.fileKey == mediaKey) {
arr.push(item.fileId);
}
});
const str = arr.length > 0 ? arr.join(",") : "";
return str;
},
/**
* 获取新旧合并的文件id对象
* @param {Array} mediaKeys 媒体keys数组
* @param {Object} oldObj 已经存在的
* @param {Object} newObj 新上传的
* @returns {string} 新上传的文件id字符串
*/
getMergedIdsObj(oldObj, newObj, mediaKeys) {
const obj = {};
mediaKeys.forEach((key) => {
let newArr = newObj[key].split(",");
let oldArr = oldObj[key].split(",");
let fullArr = [...new Set([...newArr, ...oldArr])];
let fullStr = fullArr.join(",");
obj[key] = fullStr.substring(0, fullStr.length - 1);
});
return obj;
},
/**
* 获取需要被删除的文件ID合集
* @param {Array} mediaKeys 媒体keys数组
* @param {Object} dialogForm 表单对象
* @param {Object} newUploadedFileIdsObj 最新上传之后的
* @returns {Object} 新上传的文件id对象
*/
getDeleteFileArr(oldObj, newObj, mediaKeys) {
const arr = [];
mediaKeys.forEach((key) => {
let newArr = newObj[key].split(",");
let oldArr = oldObj[key].split(",");
let fullArr = [...new Set([...newArr, ...oldArr])];
oldArr.forEach((oldId) => {
if (!fullArr.includes(oldId)) {
arr.push(oldId);
}
});
});
return arr;
},
};
export default fileUploadFuctions;
...@@ -107,17 +107,7 @@ export const passedTitle = [{ ...@@ -107,17 +107,7 @@ export const passedTitle = [{
columnAlign: 'center', columnAlign: 'center',
showOverFlowToolTip: true, showOverFlowToolTip: true,
}, },
{
prop: "checkStatus",
label: "审核状态",
columnAlign: 'center',
},
{
prop: "checkRemark",
label: "审核意见",
columnAlign: 'center',
showOverFlowToolTip: true,
},
{ {
prop: "remark", prop: "remark",
label: "备注", label: "备注",
...@@ -158,16 +148,16 @@ export const unPassedTitle = [{ ...@@ -158,16 +148,16 @@ export const unPassedTitle = [{
// columnAlign: 'center', // columnAlign: 'center',
// isCulturalRelicType:true // isCulturalRelicType:true
// }, // },
// { {
// prop: "createId", prop: "createId",
// label: "创建人", label: "创建人",
// columnAlign: 'center', columnAlign: 'center',
// }, },
// { {
// prop: "createTime", prop: "createTime",
// label: "创建时间", label: "创建时间",
// columnAlign: 'center', columnAlign: 'center',
// }, },
{ {
prop: "deptName", prop: "deptName",
...@@ -175,12 +165,12 @@ export const unPassedTitle = [{ ...@@ -175,12 +165,12 @@ export const unPassedTitle = [{
columnAlign: 'center', columnAlign: 'center',
showOverFlowToolTip: true, showOverFlowToolTip: true,
}, },
// { {
// prop: "regionName", prop: "regionName",
// label: "所属地", label: "所属地",
// columnAlign: 'center', columnAlign: 'center',
// showOverFlowToolTip: true, showOverFlowToolTip: true,
// }, },
// { // {
// prop: "intro", // prop: "intro",
// label: "馆藏介绍", // label: "馆藏介绍",
...@@ -214,30 +204,40 @@ export const unPassedTitle = [{ ...@@ -214,30 +204,40 @@ export const unPassedTitle = [{
// columnAlign: 'center', // columnAlign: 'center',
// }, // },
// {
// prop: "loveCount",
// label: "点赞量",
// columnAlign: 'center',
// sortable: true
// },
// {
// prop: "collectCount",
// label: "收藏量",
// columnAlign: 'center', sortable: true
// },
// {
// prop: "browseCount",
// label: "浏览量",
// columnAlign: 'center', sortable: true
// },
// {
// prop: "sourceWay",
// label: "来源方式",
// columnAlign: 'center',
// showOverFlowToolTip: true,
// },
{ {
prop: "loveCount", prop: "checkStatus",
label: "点赞量", label: "审核状态",
columnAlign: 'center', columnAlign: 'center',
sortable: true
}, },
{ {
prop: "collectCount", prop: "checkRemark",
label: "收藏量", label: "审核意见",
columnAlign: 'center', sortable: true
},
{
prop: "browseCount",
label: "浏览量",
columnAlign: 'center', sortable: true
},
{
prop: "sourceWay",
label: "来源方式",
columnAlign: 'center', columnAlign: 'center',
showOverFlowToolTip: true, showOverFlowToolTip: true,
}, },
{ {
prop: "remark", prop: "remark",
label: "备注", label: "备注",
......
const transformData = {
/**
* 转换服务器的封面数据到前端可用的封面数据
* @param {String} faceImagePressUrl 压缩过得封面
* @param {String} faceImageUrl 封面原图
* @returns {Array} el-upload组件需要的数据
*/
faceImageToClient(faceImagePressUrl, faceImageUrl) {
if (!faceImageUrl) {
return [];
}
const faceImage = [
{
name: "",
url: faceImageUrl || "",
pressUrl: faceImagePressUrl || faceImageUrl || "",
fileId: faceImage || "",
},
];
return faceImage;
},
/**
* 转换服务器的封面数据到前端可用的3D模型数据
* @param {String} file3d 3D文件ID
* @param {String} file3dUrl 3D文件url
* @returns {Array} el-upload组件需要的数据
*/
file3dToClient(file3d, file3dUrl) {
if (!file3d) {
return [];
}
const file3dArr = [
{
name: "",
url: file3dUrl || "",
fileId: file3d || "",
},
];
return file3dArr;
},
/**
*
* @param {Array} arr 文献id数组
* @returns {String} 提交给服务器需要的以逗号隔开的字符串
*/
literatureIdArrToStr(arr) {
let str = "";
if (arr.length == 0) {
return "";
}
const result = arr.join(",");
str = result.substring(0, result.length - 1);
return str;
},
/**
*
* @param {Array} literatureVo 文献数组,每个条目是一个文献对象
* @returns {Array} 文献ID集合
*/
literatureListToIds(literatureVo) {
if (!literatureVo || literatureVo.length == 0) {
return [];
} else {
const ids = literatureVo.map((item) => {
return item.ids;
});
return ids;
}
},
/**
* 转换状态从布尔型到数值型
* @param {Boolean} statusBoolean 布尔值的状态
* @returns {Number} 提交给服务器需要的以逗号隔开的数值
*/
statusBoolToNum(statusBoolean) {
const statusNumber = statusBoolean ? 1 : 0;
return statusNumber;
},
/**
* 转换状态从数值型到布尔型
* @param {String} statusString 字符串型的状态
* @returns {Boolean} 组件需要的布尔值
*/
statusStrToBool(statusString) {
const statusBoolean = Boolean(Number(statusString));
return statusBoolean;
},
/**
* 回填馆藏单位
* @param {String} deptId 部门ID
* @param {Object} userInfo 当前用户的信息
* @returns {Array} 符合element-ui使用的数组
*/
getDeptIdArr(deptId, userInfo) {
let deptIdArr = [];
if (deptId) {
deptIdArr = [deptId];
} else if (userInfo) {
deptIdArr = [userInfo.deptId];
}
return deptIdArr;
},
/**
* 回填馆藏单位
* @param {Array} deptArr 部门ID集合
* @returns {String} 部门ID字符串
*/
getDeptIdStr(deptArr) {
let str = "";
if (deptArr.length == 0) {
return "";
}
const result = deptArr.join(",");
str = result.substring(0, result.length - 1);
return str;
},
};
export default transformData;
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</el-tabs> </el-tabs>
<TablePage <TablePage
:data="getCurrentList().records" :data="getCurrentList().records"
:tableTitle="passedTitle" :tableTitle="getTitle"
:operates="operates" :operates="operates"
> >
<template v-slot:status="data"> <template v-slot:status="data">
...@@ -107,12 +107,7 @@ ...@@ -107,12 +107,7 @@
</el-pagination> </el-pagination>
</div> </div>
<InfoEditDialog <InfoEditDialog ref="InfoEditDialog" :form="form" @refresh="loadData" />
:visible="editVisible"
:form="form"
@handleClose="handleEditClose"
@refresh="loadData"
/>
<UploadDialog ref="UploadDialog" @update="loadData" /> <UploadDialog ref="UploadDialog" @update="loadData" />
<ImportRecordDialog <ImportRecordDialog
...@@ -156,6 +151,7 @@ import InfoEditDialog from "./components/InfoEditDialog"; ...@@ -156,6 +151,7 @@ import InfoEditDialog from "./components/InfoEditDialog";
import UploadDialog from "./components/UploadDialog"; import UploadDialog from "./components/UploadDialog";
import ImportRecordDialog from "./components/ImportRecordDialog"; import ImportRecordDialog from "./components/ImportRecordDialog";
import View3dDialog from "./components/View3dDialog"; import View3dDialog from "./components/View3dDialog";
import { rules } from "./configs/validateRules";
export default { export default {
components: { components: {
...@@ -183,30 +179,7 @@ export default { ...@@ -183,30 +179,7 @@ export default {
}, },
searchConfig, searchConfig,
editVisible: false, //编辑 editVisible: false, //编辑
form: { form: {},
name: "", //名称
type: "", //类别(字典值)
level: "", //文物级别(字典值)
textureType: "", //质地(字典值)
detailSize: "", // 具体尺寸
years: "", //年代
num: 1, //数量
deptId: "", //收藏馆id——新增传当前用户的deptId
intro: "", //馆藏介绍
literature: "", //关联文献。id1,id2,id3
// directory:'',// 文件夹(字母或者数字命名)
// regionCode:'',//所属地(分号分隔的编号)——传当前用户的regionCode
sourceWay: "", //来源方式
sayExplain: "", //讲解词文件。文件id
status: true, //上下架状态(0-下架,1-上架)
// flag3d:'',//是否有3D图片(字典值:1-有;0-无)
themeWord: "", //主题词
url3d: "", //3durl链接
remark: "", //备注
audios: "", //音频文件(文件id)
images: "", //图片文件(文件id,多个以逗号隔开)
videos: "", //视频文件(文件id)
},
loading: false, loading: false,
imgViewerVisible: false, imgViewerVisible: false,
importRecordVisible: false, //上传记录 importRecordVisible: false, //上传记录
...@@ -228,6 +201,9 @@ export default { ...@@ -228,6 +201,9 @@ export default {
}, },
}, },
computed: { computed: {
getTitle() {
return this.tabActive == "passed" ? this.passedTitle : this.unPassedTitle;
},
getStatusTitle(status) { getStatusTitle(status) {
return (status) => { return (status) => {
if (Number(status)) { if (Number(status)) {
...@@ -303,14 +279,37 @@ export default { ...@@ -303,14 +279,37 @@ export default {
async handleOperation(value, row) { async handleOperation(value, row) {
switch (value.type) { switch (value.type) {
case "add": case "add":
this.editVisible = true; this.form = {
name: "", //名称
type: "", //类别(字典值)
level: "", //文物级别(字典值)
textureType: "", //质地(字典值)
detailSize: "", // 具体尺寸
years: "", //年代
num: 1, //数量
deptId: "", //收藏馆id——新增传当前用户的deptId
intro: "", //馆藏介绍
literature: "", //关联文献。id1,id2,id3
// directory:'',// 文件夹(字母或者数字命名)
// regionCode:'',//所属地(分号分隔的编号)——传当前用户的regionCode
sourceWay: "", //来源方式
sayExplain: "", //讲解词文件。文件id
status: 1, //上下架状态(0-下架,1-上架)
// flag3d:'',//是否有3D图片(字典值:1-有;0-无)
themeWord: "", //主题词
url3d: "", //3durl链接
remark: "", //备注
audios: "", //音频文件(文件id)
images: "", //图片文件(文件id,多个以逗号隔开)
videos: "", //视频文件(文件id)
};
this.$refs.InfoEditDialog.visible = true;
break; break;
case "view3D": case "view3D":
console.log(value, row);
this.$refs.View3dDialog.visible = true; this.$refs.View3dDialog.visible = true;
break; break;
case "edit": case "edit":
console.log(value, row); this.$refs.InfoEditDialog.visible = true;
let detailRes = await getRCDetailByIdTemp({ crId: row.crId }); let detailRes = await getRCDetailByIdTemp({ crId: row.crId });
if (detailRes.code == 0) { if (detailRes.code == 0) {
this.form = detailRes.data; this.form = detailRes.data;
......
...@@ -527,6 +527,7 @@ export default { ...@@ -527,6 +527,7 @@ export default {
this.currentId = this.dialogForm.exhibitionId; this.currentId = this.dialogForm.exhibitionId;
} }
const { const {
faceImage,
faceImageUrl, faceImageUrl,
faceImagePressUrl, faceImagePressUrl,
imagesVo, imagesVo,
...@@ -537,7 +538,7 @@ export default { ...@@ -537,7 +538,7 @@ export default {
deptId, deptId,
exhibitionUnits, exhibitionUnits,
} = this.dialogForm; } = this.dialogForm;
this.faceImage = faceImageToClient(faceImagePressUrl, faceImageUrl); this.faceImage = faceImageToClient(faceImage,faceImageUrl,faceImagePressUrl );
this.images = imagesVo || []; this.images = imagesVo || [];
this.videos = videosVo || []; this.videos = videosVo || [];
this.audios = audiosVo || []; this.audios = audiosVo || [];
......
...@@ -64,11 +64,24 @@ ...@@ -64,11 +64,24 @@
@handleClose="handleClosePreviewDialog" @handleClose="handleClosePreviewDialog"
@refresh="loadData" @refresh="loadData"
/> />
<CrInfoEditDialog
ref="CrInfo"
:form="form"
@refresh="loadData"
/>
<DisplayInfoEditDialog
ref="CrInfo"
:form="form"
@handleClose="handleEditClose"
@refresh="loadData"
/>
</div> </div>
</template> </template>
<script> <script>
import PreviewDialog from "./components/PreviewDialog.vue"; import PreviewDialog from "./components/PreviewDialog.vue";
import CrInfoEditDialog from "@/views/culturalRelic/components/InfoEditDialog";
import DisplayInfoEditDialog from "@/views/display/components/InfoEditDialog";
import { import {
approvleTableTitle, approvleTableTitle,
operates, operates,
...@@ -76,11 +89,19 @@ import { ...@@ -76,11 +89,19 @@ import {
approvalButton, approvalButton,
reSubmitButtton, reSubmitButtton,
} from "./config"; } from "./config";
import { getFlowListPagePer, getFlowDetailById } from "@/api/approval"; import {
getFlowListPagePer,
getFlowDetailById,
getFlowCulturalRelicDetail,
getFlowExhibitionDetail,
} from "@/api/approval";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
export default { export default {
components: { components: {
PreviewDialog, PreviewDialog,
CrInfoEditDialog,
DisplayInfoEditDialog,
}, },
data() { data() {
return { return {
...@@ -125,6 +146,8 @@ export default { ...@@ -125,6 +146,8 @@ export default {
operates, operates,
// operations, // operations,
approvleTableTitle, approvleTableTitle,
resubmitCrInfo:{},//重传的文物信息
resubmitDisplayInfo:{},//重传的展览信息
}; };
}, },
computed: { computed: {
...@@ -192,11 +215,76 @@ export default { ...@@ -192,11 +215,76 @@ export default {
} }
}, },
resubmit(row) { async resubmit(row) {
const { addWay, sourceType } = row; console.log(row);
// const isMultiCr = addWay=='' // return
const { addWay, sourceType, id } = row;
console.log(addWay, sourceType);
const isManual = sourceType == "手动添加";
switch (sourceType) {
case "文物":
if (isManual) {
const params = {
crId: "", //TODO:问后端文物ID是什么,row里面没有
flowId: id,
};
const res = await getFlowCulturalRelicDetail(params);
if (res.code == 0) {
this.openResubmitDialog("CrInfo");
this.resubmitCrInfo = res.data;
}
} else {
this.openResubmitDialog("CrMulti");
}
break;
case "展览展示":
if (isManual) {
const params = {
exhibitionId: "", //TODO:问后端展览ID是什么,row里面没有
flowId: id,
};
const res = await getFlowExhibitionDetail(params);
if (res.code == 0) {
this.openResubmitDialog("DisplayInfo");
this.resubmitDisplayInfo = res.data;
}
} else {
this.openResubmitDialog("DisplayMulti");
}
break;
}
},
// 打开文物编辑重传弹窗
openResubmitDialog(name) {
this.$refs[name].visible = true;
}, },
// 关闭文物编辑重传弹窗
closeResubmitDialog(name) {
this.$refs[name].visible = false;
},
// // 关闭批量文物重传弹窗
// closeResubmitCrMulti() {
// this.$refs.CrMultiResubmit.visible = false;
// },
// // 打开展览编辑重传弹窗
// openResubmitDisplayInfo() {
// this.displayInfoResubmitVisible = true;
// },
// // 打开整量展览重传弹窗
// openResubmitDislayMulti() {
// this.displayMultiResubmitVisible = true;
// },
// // 打开文物编辑重传弹窗
// closeResubmitDisplayInfo() {
// this.displayInfoResubmitVisible = false;
// },
// // 打开批量文物重传弹窗
// closeResubmitDislayMulti() {
// this.displayMultiResubmitVisible = false;
// },
// 多选 // 多选
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论