import ArtSystem from "./artSystem"; import ArtImage from "./artImage"; import { artStatus } from "./artEnum"; import { EditTask, EditType, Query, QueryTask, } from "@airkoon/cellsys/cellsysUtil"; import { artApi } from "./artApi"; class CellsysArt { constructor(params = {}) { this.id = params.id; this.oldName = params.old_name; //不带书名号 this.recordNumber = params.record_number; this.artworkName = params.artwork_name; this.author = params.author; this.createPeriod = params.create_period; this.actualNumber = params.actual_number || 1; this.materialId = params.material_id; this.materialName = params.material_name; this.countryId = params.country_id; this.countryName = params.country_name; this.length = params.length; this.width = params.width; this.height = params.height; this.categoryOne = params.category_one; this.categoryOneName = params.category_one_name; this.categoryTwo = params.category_two; this.categoryTwoName = params.category_two_name; this.categoryThree = params.category_three; this.categoryThreeName = params.category_three_name; this.originalRegistrationNumber = params.original_registration_number; this.remark = params.remark; this.creator = params.creator; this.updater = params.updater; this.status = params.status; this.artworkImages = []; if (params.images) { this.artworkImages = params.images.map((url) => { return new ArtImage(url); }); } this.tags = []; if (params.tag_name) { this.tags = params.tag_name.map((name) => { return { name: name }; }); } } get oldNameFormat() { //带书名号 return `《${this.oldName}》`; } //封面图 get coverImageUrl() { if (this.artworkImages.length > 0) { return this.artworkImages[0].compressionUrl; } } get artworkImagesUrl() { if (this.artworkImages.length > 0) { return this.artworkImages.map((artImage) => { return artImage.url; }); } } get statusMsg() { return artStatus[this.status]; } //查看艺术品详情 getDetails() { let editTask = new EditTask(artApi.artworkDetails); editTask.addParam("_id", this.id); return new Promise((resolve, reject) => { editTask .execute() .then((res) => { if (res.data) { let cellsysArt = new CellsysArt(res.data); //todo 详情字段填充 resolve(cellsysArt); } }) .catch((err) => { reject(err); }); }); } //编辑艺术品档案 updateArtwork(params = {}) { let editTask = new EditTask(artApi.artArtworkRecordUpdate); editTask.addParam("_id", params.id); editTask.addParam("_oldname", params.oldName); editTask.addParam("_author", params.author); editTask.addParam("_create_period", params.createPeriod); editTask.addParam("_length", params.length); editTask.addParam("_width", params.width); editTask.addParam("_height", params.height); if (params.material) { editTask.addParam("_material", params.material.dict_code); } editTask.addParam( "_original_registration_number", params.originalRegistrationNumber ); editTask.addParam("_remark", params.remarks); editTask.addParam("_images", params.images); return new Promise((resolve, reject) => { editTask .execute() .then((res) => { if (res.data) { let cellsysArt = new CellsysArt(res.data); resolve(cellsysArt); } }) .catch((err) => { reject(err); }); }); } //删除艺术品档案 removeArtwork(params = {}) { let editTask = new EditTask(artApi.artArtworkRecordDelete); editTask.addParam("_id", this.id); editTask.addParam("_password", params.password); return new Promise((resolve, reject) => { editTask .execute() .then((res) => { resolve(res); }) .catch((err) => { reject(err); }); }); } queryEventlist() { return new Promise((resolve, reject) => { ArtSystem.queryArtworkEvent({ artworkId: this.id, }) .then((res) => { resolve(res); }) .catch((err) => { reject(err); }); }); } } export default CellsysArt;