cellsysArt/artRepairPlan.js
2025-01-03 09:52:13 +08:00

77 lines
2.6 KiB
JavaScript

import ArtImage from "./artImage";
import {formatterMillisecond} from "./utils/date";
import {EditTask} from "@airkoon/cellsys/cellsysUtil";
import {artApi} from "./artApi";
import {artRepairPlanStatus} from "./artEnum";
class ArtRepairPlan {
constructor(params = {}) {
this.id = params.id;
this.name = params.name;
this.repairRecordId = params.repair_record_id;
this.repairNodes = params.repair_nodes;
this.creatorSignatureImage = params.creator_signature_image;
this.status = params.status;
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 coverImageUrl() {
if (this.artworkRecord && this.artworkRecord["artworkImages"].length > 0) {
return this.artworkRecord["artworkImages"][0].compressionUrl;
}
}
//艺术品封面图
get oldNameFormat() {
return `${this.artworkRecord["oldName"]}`;
}
get updateTimeFormat() {
return formatterMillisecond(this.updateTime);
}
get statusMsg() {
return artRepairPlanStatus[this.status];
}
updateRepairPlan(params={}){
let editTask = new EditTask(artApi.repairPlanUpdate);
editTask.addParam("_id", this.id);
editTask.addParam("_repair_record_id", params.repairRecordId);
editTask.addParam("_name", params.name);
editTask.addParam("_repair_nodes", params.repairNodes);
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let artRepairFile = new ArtRepairPlan(res.data);
resolve(artRepairFile);
}
})
.catch((err) => {
reject(err);
});
});
}
deleteRepairPlan(){
let editTask = new EditTask(artApi.repairPlanDelete);
editTask.addParam("_id", this.id);
return editTask.execute()
}
}
export default ArtRepairPlan;