cellsysArt/artRepairFile.js

127 lines
3.6 KiB
JavaScript
Raw Normal View History

2025-01-03 09:52:13 +08:00
import ArtImage from "./artImage";
import { formatterMillisecond } from "./utils/date";
import { artApi } from "./artApi";
import {
EditTask,
Operator,
Query,
QueryTask,
} from "@airkoon/cellsys/cellsysUtil";
import ConditionReport from "./conditionReport";
import ArtRepairPlan from "./artRepairPlan";
2024-12-30 09:53:02 +08:00
class ArtRepairFile {
2025-01-03 09:52:13 +08:00
constructor(params = {}) {
this.id = params.id;
this.name = params.name;
this.description = params.description;
this.conditionCheckId = params.condition_check_id; //关联的状况检查记录id
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);
});
}
this.tags = [];
if (params.tag_name) {
this.tags = params.tag_name.map((name) => {
return { name: name };
});
2024-12-30 09:53:02 +08:00
}
2025-01-03 09:52:13 +08:00
}
//艺术品封面图
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);
}
queryConditionReport() {
if (!this.conditionCheckId) {
throw new Error("没有状况检查记录信息!");
}
let query = new Query();
query.addFilter("id", Operator.Equals, this.conditionCheckId); //病害报告模板
let queryTask = new QueryTask(artApi.viewConditionCheck, false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
let resArr = res.map((item) => {
return new ConditionReport(item);
});
resolve(resArr);
})
.catch((err) => {
reject(err);
});
});
}
2024-12-30 09:53:02 +08:00
2025-01-03 09:52:13 +08:00
//更新修复档案信息
updateRepairFile(params = {}) {
let { name, description, conditionCheckId } = params;
let editTask = new EditTask(artApi.repairRecordUpdate);
editTask.addParam("_id", this.id);
editTask.addParam("_description", description);
editTask.addParam("_name", name);
editTask.addParam("_condition_check_id", conditionCheckId);
debugger;
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let artRepairFile = new ArtRepairFile(res.data);
resolve(artRepairFile);
}
})
.catch((err) => {
reject(err);
});
});
}
//创建修复方案
createRepairPlan(params) {
let editTask = new EditTask(artApi.repairPlanInsert);
editTask.addParam('_repair_record_id', this.id);
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);
});
});
}
2024-12-30 09:53:02 +08:00
}
2025-01-03 09:52:13 +08:00
export default ArtRepairFile;