cellsysArt/equipment.js
2025-03-06 15:51:13 +08:00

103 lines
3.5 KiB
JavaScript

import { artApi } from './artApi';
import { Query, QueryTask, EditTask } from './artUtil';
import EquipmentData from './equipmentData';
import ArtSystem from './artSystem';
class Equipment {
constructor(params) {
if (!params) {
params = {};
}
this.id = params.id;
this.name = params.name;
this.description = params.description;
this.equipmentTypeId = params.type_id;
this.manufacturers = params.manufacture; //厂商
this.serialNumber = params.number; //SN码--设备编号
this.equipmentModel = params.model; //设备型号
this.laboratoryId = params.laboratory_id; //实验室id
if (params.artwork_equipment_type) {
let { name, chart_option, data_type } = params.artwork_equipment_type;
this.equipmentTypeName = name;
this.chartConfiguration = chart_option;
this.dataType = data_type;
}
this.creator = params.creator;
this.updater = params.updater;
this.createTime = params.create_time;
this.updateTime = params.update_time;
}
updateEquipment(params = {}) {
let editTask = new EditTask(artApi.equipmentUpdate);
editTask.addParam('_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.laboratoryAddress);
editTask.addParam('_name', params.name);
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let materialType = new Equipment(res.data);
resolve(materialType);
}
})
.catch((err) => {
reject(err);
});
});
}
deleteEquipment(params) {
let editTask = new EditTask(artApi.equipmentDelete);
editTask.addParam('_id', this.id);
return editTask.execute();
}
createEquipmentData(params) {
let editTask = new EditTask(artApi.artworkEquipmentDataInsert);
editTask.addParam('_equipment_id', this.id);
editTask.addParam('_images', params.images);
editTask.addParam('_name', params.name);
editTask.addParam('_data', params.data);
editTask.addParam('_material_id', params.materialId);
editTask.addParam('_remarks', params.remarks);
editTask.addParam('_date_time', params.dateTime);
editTask.addParam('_geometry', params.geometry);
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let materialType = new EquipmentData(res.data);
resolve(materialType);
}
})
.catch((err) => {
reject(err);
});
});
}
//获取设备所在实验室信息
queryLaboratory(params = {}) {
let { filter, pageInfo } = params;
if (!filter) {
filter = [];
}
filter.push({
name: 'id',
operator: '=',
value: this.laboratoryId,
});
return ArtSystem.queryLaboratoryList({ filter, pageInfo });
}
}
export default Equipment;