105 lines
3.4 KiB
JavaScript
105 lines
3.4 KiB
JavaScript
import { EditTask, Query, QueryTask } from "./artUtil.js";
|
|
import { artApi } from "./artApi";
|
|
|
|
class Warehouse {
|
|
constructor(params) {
|
|
if (!params) {
|
|
params = {};
|
|
}
|
|
this.orgId = params.org_id;
|
|
this.orgName = params.org_name;
|
|
this.id = params.id;
|
|
this.name = params.name;
|
|
this.type = params.type;
|
|
this.status = params.status;
|
|
this.action = params.action || 0;
|
|
this.bufferDistance = params.buffer_distance || 0;
|
|
this.radius = params.radius || 0;
|
|
this.geometry = params.geometry;
|
|
this.typeName = params.type_name;
|
|
this.style = params.style ? params.style : {};
|
|
this.description = params.description;
|
|
this.geometryPosition=params.geometry_position;
|
|
}
|
|
static createWarehouse(params) {
|
|
let editTask = new EditTask(artApi.wareHouseInsert);
|
|
editTask.addParam("_name", params.name);
|
|
editTask.addParam("_description", params.description);
|
|
editTask.addParam("_geometry", params.geometry);
|
|
editTask.addParam("_geometry_position", params.geometryPosition);
|
|
editTask.addParam("_type", params.type);
|
|
editTask.addParam("_status", 1);
|
|
editTask.addParam("_action", params.action);
|
|
editTask.addParam("_buffer_distance", params.bufferDistance);
|
|
editTask.addParam("_radius", params.radius);
|
|
return editTask.execute();
|
|
}
|
|
static updateWarehouse(params) {
|
|
let editTask = new EditTask(artApi.wareHouseUpdate);
|
|
editTask.addParam("_type", params.type);
|
|
editTask.addParam("_id", params.id);
|
|
editTask.addParam("_geometry", params.geometry);
|
|
editTask.addParam("_geometry_position", params.geometryPosition);
|
|
editTask.addParam("_name", params.name);
|
|
editTask.addParam("_description", params.description);
|
|
editTask.addParam("_action", params.action);
|
|
editTask.addParam("_status", 1);
|
|
editTask.addParam("_buffer_distance", params.bufferDistance);
|
|
editTask.addParam("_radius", params.radius);
|
|
return editTask.execute();
|
|
}
|
|
static deleteWarehouse(params) {
|
|
let editTask = new EditTask(artApi.wareHouseDelete);
|
|
editTask.addParam("_id", params.id);
|
|
return editTask.execute();
|
|
}
|
|
static queryWarehouse(pageInfo, filters, order) {
|
|
let query = new Query();
|
|
if (pageInfo) {
|
|
query.setCurrPage(pageInfo.currPage);
|
|
query.setPageSize(pageInfo.pageSize);
|
|
}
|
|
if (filters && filters.length > 0) {
|
|
filters.forEach((item) => {
|
|
query.addFilter(item["name"], item["operator"], item["value"]);
|
|
});
|
|
}
|
|
if (order) {
|
|
query.setOrder(order);
|
|
} else {
|
|
query.setOrder({ id: "desc" });
|
|
}
|
|
let queryTask = new QueryTask(artApi.viewWareHouse, pageInfo);
|
|
return new Promise((resolve, reject) => {
|
|
queryTask
|
|
.execute(query)
|
|
.then((res) => {
|
|
if (pageInfo) {
|
|
if (res.data) {
|
|
res.data = res.data.map((item) => {
|
|
return new Warehouse(item);
|
|
});
|
|
resolve(res);
|
|
}
|
|
} else {
|
|
let resArr = res.map((item) => {
|
|
return new Warehouse(item);
|
|
});
|
|
resolve(resArr);
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
static countArtworkInWareHouse(params) {
|
|
// let query = new Query();
|
|
let editTask = new EditTask(artApi.countInWareHouse);
|
|
editTask.addParam("_id", params.id);
|
|
editTask.addParam("_type", params.type);
|
|
return editTask.execute();
|
|
}
|
|
}
|
|
export default Warehouse;
|