cellsysArt/godownEntry.js
2024-12-26 10:28:43 +08:00

163 lines
6.7 KiB
JavaScript

import { EditTask, Query, QueryTask } from '@airkoon/cellsys/cellsysUtil';
import { artApi } from './artApi';
import { formatterMillisecond } from './utils/date';
import { godownEntryStatus } from './artEnum';
//入库记录
class GodownEntry {
constructor(params = {}) {
this.id = params.id;
this.status = params.status;
this.number = params.number;
this.artworkRecordId = params.artwork_record_id; //艺术品档案id
this.entryTime = params.entry_time; //入库时间
this.client = params.client; //委托方
this.contractor = params.contractor; //接收方
this.stand = params.stand; //支架
this.packingType = params.packing_type; //装箱类型
this.support = params.support; //支撑物
this.remark = params.remark; //备注
this.images = params.images || []; //现场照片
this.conditionIssues = params.condition_issues || null; //病害信息
this.conditionIssuesImages = params.condition_issues_images
? params.condition_issues_images.map((item) => {
return {
original: item.original || null, //原图
graphing: item.graphing || null, //遮罩层
superposition: item.superposition || null, //合并
};
})
: []; //病害图 original graphing superposition
this.wareHouseId = params.ware_house_id; //仓库id
let wareHouse = params.ware_house;
if (wareHouse) {
this.wareHouseName = wareHouse.name; //仓库
} else {
this.wareHouseName = null;
}
this.clientSignatureImage = params.client_signature_image || null; // 委托方签名;
this.contractorSignatureImage = params.contractor_signature_image || null; //接收方签名
let artworkRecord = params.artwork_record;
if (artworkRecord) {
this.artworkRecord = {
recordNumber: artworkRecord.record_number,
author: artworkRecord.author,
oldName: artworkRecord.old_name,
creationPeriodEnd: artworkRecord.creation_period_end,
creationPeriodStart: artworkRecord.creation_period_start,
width: artworkRecord.width,
height: artworkRecord.height,
length: artworkRecord.length,
materialId: artworkRecord.material_id,
};
} else {
this.artworkRecord = {
recordNumber: null,
author: null,
oldName: null,
creationPeriodEnd: null,
creationPeriodStart: null,
width: null,
height: null,
length: null,
materialId: null,
};
}
}
get statusMsg() {
return godownEntryStatus[this.status];
}
get entryTimeFormat() {
return formatterMillisecond(this.entryTime);
}
static createWareHouseEntry(params) {
let editTask = new EditTask(artApi.wareHouseEntryInsert);
editTask.addParam('_artwork_record_id', params.artworkRecordId);
editTask.addParam('_entry_time', params.entryTime);
editTask.addParam('_client', params.client);
editTask.addParam('_contractor', params.contractor);
editTask.addParam('_stand', params.stand);
editTask.addParam('_packing_type', params.packingType);
editTask.addParam('_support', params.support);
editTask.addParam('_remark', params.remark);
editTask.addParam('_images', params.images);
editTask.addParam('_condition_issues', params.conditionIssues);
editTask.addParam('_condition_issues_images', params.conditionIssuesImages);
editTask.addParam('_ware_house_id', params.wareHouseId);
editTask.addParam('_client_signature_image', params.clientSignatureImage);
editTask.addParam('_contractor_signature_image', params.contractorSignatureImage);
return editTask.execute();
}
static queryWareHouseEntry(params = {}) {
let { pageInfo, order, filters } = params;
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.viewWareHouseEntry, pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new GodownEntry(item);
});
resolve(res);
}
} else {
let resArr = res.map((item) => {
return new GodownEntry(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
static updateWareHouseEntry(params) {
let editTask = new EditTask(artApi.wareHouseEntryUpdate);
editTask.addParam('_id', params.id);
editTask.addParam('_status', params.status);
editTask.addParam('_entry_time', params.entryTime);
editTask.addParam('_client', params.client);
editTask.addParam('_contractor', params.contractor);
editTask.addParam('_stand', params.stand);
editTask.addParam('_packing_type', params.packingType);
editTask.addParam('_support', params.support);
editTask.addParam('_remark', params.remark);
editTask.addParam('_images', params.images);
editTask.addParam('_condition_issues', params.conditionIssues);
editTask.addParam('_condition_issues_images', params.conditionIssuesImages);
editTask.addParam('_ware_house_id', params.wareHouseId);
editTask.addParam('_client_signature_image', params.clientSignatureImage);
editTask.addParam('_contractor_signature_image', params.contractorSignatureImage);
return editTask.execute();
}
deleteWareHouseEntry() {
let editTask = new EditTask(artApi.wareHouseEntryDelete);
editTask.addParam('_id', this.id);
return editTask.execute();
}
}
export default GodownEntry;