cellsysArt/disease.js
2025-02-25 09:47:45 +08:00

55 lines
1.3 KiB
JavaScript

import { EditTask } from "./artUtil";
import { artApi } from "./artApi";
class Disease {
constructor(params = {}) {
this.id = params.id;
this.name = params.name;
this.description = params.description;
this.categoryId = params.category_id;
this.image = params.image; //病害图示
this.style = params.style;
}
//更新病害信息
updateDisease(params = {}) {
let editTask = new EditTask(artApi.diseaseUpdate);
editTask.addParam("_id", this.id);
editTask.addParam("_name", params.name);
editTask.addParam("_image", params.image);
editTask.addParam("_description", params.description);
editTask.addParam("_style", params.style);
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let disease = new Disease(res.data);
resolve(disease);
}
})
.catch((err) => {
reject(err);
});
});
}
//删除病害记录
removeDisease() {
let editTask = new EditTask(artApi.diseaseDelete);
editTask.addParam("_id", this.id);
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
});
}
}
export default Disease;