82 lines
2.8 KiB
JavaScript
82 lines
2.8 KiB
JavaScript
import { EditTask } from './artUtil';
|
|
import { artApi } from './artApi';
|
|
import Equipment from './equipment';
|
|
|
|
class ArtworkEquipmentType {
|
|
constructor(params) {
|
|
if (!params) {
|
|
params = {};
|
|
}
|
|
this.id = params.id;
|
|
this.name = params.name;
|
|
this.description = params.description;
|
|
|
|
this.equipmentCount = params.equipment_count || 0;
|
|
this.style = params.style;
|
|
this.tags = [];
|
|
if (params.tag_name) {
|
|
this.tags = params.tag_name.map((item) => {
|
|
return { name: item };
|
|
});
|
|
}
|
|
this.creator = params.creator;
|
|
this.updater = params.updater;
|
|
this.createTime = params.create_time;
|
|
this.updateTime = params.update_time;
|
|
}
|
|
updateEquipmentType(params) {
|
|
let { name, description, style, tags, dataType, chartConfiguration } = params;
|
|
let editTask = new EditTask(artApi.equipmentTypeUpdate);
|
|
editTask.addParam('_id', this.id);
|
|
editTask.addParam('_description', description);
|
|
editTask.addParam('_name', name);
|
|
editTask.addParam('_style', style);
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
editTask
|
|
.execute()
|
|
.then((res) => {
|
|
if (res.data) {
|
|
let materialType = new ArtworkEquipmentType(res.data);
|
|
resolve(materialType);
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
deleteEquipmentType(params) {
|
|
let editTask = new EditTask(artApi.equipmentTypeDelete);
|
|
editTask.addParam('_id', this.id);
|
|
return editTask.execute();
|
|
}
|
|
createEquipment(params) {
|
|
let editTask = new EditTask(artApi.equipmentInsert);
|
|
editTask.addParam('_type_id', this.id);
|
|
editTask.addParam('_description', params.description);
|
|
editTask.addParam('_manufacture', params.manufacturers);
|
|
editTask.addParam('_number', params.serialNumber);
|
|
editTask.addParam('_model', params.equipmentModel);
|
|
editTask.addParam('_laboratory_id', params.laboratoryId);
|
|
editTask.addParam('_name', params.name);
|
|
editTask.addParam('_data_type', params.dataType);
|
|
editTask.addParam('_chart_option', params.chartConfiguration);
|
|
return new Promise((resolve, reject) => {
|
|
editTask
|
|
.execute()
|
|
.then((res) => {
|
|
if (res.data) {
|
|
let equipment = new Equipment(res.data);
|
|
resolve(equipment);
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
export default ArtworkEquipmentType;
|