97 lines
3.4 KiB
JavaScript
97 lines
3.4 KiB
JavaScript
import ArtImage from './artImage';
|
|
import { formatterMillisecond } from './utils/date';
|
|
import { EditTask } from './artUtil';
|
|
import { artApi } from './artApi';
|
|
import CellsysEvent from '@airkoon/cellsys/cellsysEvent.js';
|
|
|
|
class ArtRepairLog extends CellsysEvent {
|
|
constructor(params = {}) {
|
|
params.type = params.repair_record_id;
|
|
super(params);
|
|
this.id = params.id;
|
|
this.repairRecordId = params.repair_record_id;
|
|
this.repairNode = params.repair_node;
|
|
this.name = params.repair_node;
|
|
this.restorers = params.restorers;
|
|
this.description = params.description;
|
|
this.datetime = params.datetime;
|
|
this.geometry = params.geometry;
|
|
this.geometryName = params.geometry_name;
|
|
if(params.images){
|
|
this.images = params.images.map(url=>{
|
|
return new ArtImage(url)
|
|
});
|
|
}
|
|
// if (params.images) {
|
|
// this.artworkImages = params.images.map((url) => {
|
|
// return new ArtImage(url);
|
|
// });
|
|
// }
|
|
|
|
if (params.links) {
|
|
this.linkName = params.links.linkName || null;
|
|
this.linkUrl = params.links.linkUrl || null;
|
|
}
|
|
// this.links = {
|
|
// linkName: params.links.linkName|| null,
|
|
// linkUrl: params.links.linkUrl|| null,
|
|
// }
|
|
this.materialIds = params.material_ids;
|
|
this.creator = params.creator;
|
|
this.updater = params.updater;
|
|
this.createTime = params.create_time;
|
|
this.updateTime = params.update_time;
|
|
this.artworkRecord = {
|
|
artworkRecordId: params.artwork_record_id, //关联的艺术品id
|
|
};
|
|
if (params.artwork_record) {
|
|
let { record_number, old_name, images } = params.artwork_record;
|
|
this.artworkRecord['recordNumber'] = record_number;
|
|
this.artworkRecord['oldName'] = old_name;
|
|
this.artworkRecord['artworkImages'] = images.map((url) => {
|
|
return new ArtImage(url);
|
|
});
|
|
}
|
|
}
|
|
|
|
get dateTimeFormat() {
|
|
return formatterMillisecond(this.datetime);
|
|
}
|
|
|
|
updateRepairLog(params = {}) {
|
|
let editTask = new EditTask(artApi.repairLogUpdate);
|
|
editTask.addParam('_id', this.id);
|
|
editTask.addParam('_description', params.description);
|
|
editTask.addParam('_repair_node', params.repairNode);
|
|
editTask.addParam('_images', params.images);
|
|
editTask.addParam('_material_ids', params.materialIds);
|
|
editTask.addParam('_restorers', params.restorers);
|
|
editTask.addParam('_datetime', params.datetime);
|
|
editTask.addParam('_links', params.links);
|
|
editTask.addParam('_geometry', params.geometry);
|
|
editTask.addParam('_geometry_name', params.geometryName);
|
|
|
|
return new Promise((resolve, reject) => {
|
|
editTask
|
|
.execute()
|
|
.then((res) => {
|
|
if (res.data) {
|
|
let artRepairFile = new ArtRepairLog(res.data);
|
|
resolve(artRepairFile);
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
|
|
deleteRepairLog() {
|
|
let editTask = new EditTask(artApi.repairLogDelete);
|
|
editTask.addParam('_id', this.id);
|
|
return editTask.execute();
|
|
}
|
|
}
|
|
|
|
export default ArtRepairLog;
|