cellsysArt/godownEntry.js
2025-03-27 11:15:56 +08:00

159 lines
6.5 KiB
JavaScript

import { EditTask, Query, QueryTask } from './artUtil.js';
import { artApi } from './artApi';
import { formatterMillisecond } from './utils/date';
import { godownEntryStatus } from './artEnum';
import CellsysArt from './cellsysArt';
import ArtImage from "./artImage";
//入库记录
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.padding = params.padding||[]; //支撑物
this.remark = params.remark; //备注
if(params.images){
this.images = params.images.map(url=>{
return new ArtImage(url)
});
}
// 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 = new CellsysArt({
id: this.artworkRecordId,
record_number: artworkRecord.record_number,
author: artworkRecord.author,
old_name: artworkRecord.old_name,
create_period: artworkRecord.create_period,
material_id: artworkRecord.material_id,
});
} else {
this.artworkRecord = new CellsysArt({
id: this.artworkRecordId,
});
}
}
get statusMsg() {
return godownEntryStatus[this.status];
}
get entryTimeFormat() {
return formatterMillisecond(this.entryTime, 'YYYY-MM-DD HH:mm:ss');
}
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('_padding', params.padding);
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('_padding', params.padding);
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;