import { EditTask, Query, QueryTask } from '@airkoon/cellsys/cellsysUtil'; import { artApi } from './artApi'; import CellsysArt from './cellsysArt'; class Outbound { constructor(params) { if (!params) { params = {}; } this.id = params.id; this.status = params.status; this.number = params.number; this.artworkRecordId = params.artwork_record_id; //艺术品档案Id this.applicant = params.applicant; //出库申请人 this.recipient = params.recipient; //签收人 this.recipientSignatureimage = params.recipient_signature_image; //签收人签名图片 this.reason = params.reason; //出库原因 this.images = params.images; //附件图片 this.applicationTime = params.application_time; //申请时间 this.remark = params.remark; //备注 this.destination = params.destination; //目的地 this.destinationGeometry = params.destination_geometry; //目的地坐标 this.outboundTime = params.outbound_time === 0 ? null : params.outbound_time; //出库时间 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, }; } this.createTime = params.create_time; this.updateTime = params.update_time; let creator = params.creator; this.creator = { memberId: null, name: null, }; if (creator) { this.creator = { memberId: creator.member_id, name: creator.name, }; } let updater = params.updater; this.updater = { memberId: null, name: null, }; if (updater) { this.updater = { memberId: updater.member_id, name: updater.name, }; } //审批 this.reviewer = params.reviewer; this.reviewerId = params.reviewer_id; this.reviewerSignatureimage = params.reviewer_signature_image; } static cerateWarehouseOut(params) { let editTask = new EditTask(artApi.wareHouseOutboundInsert); editTask.addParam('_artwork_record_id', params.artworkRecordId); editTask.addParam('_recipient', params.recipient); editTask.addParam('_recipient_signature_image', params.recipientSignatureimage); editTask.addParam('_reason', params.reason); editTask.addParam('_images', params.images); editTask.addParam('_remark', params.remark); editTask.addParam('_destination', params.destination); editTask.addParam('_destination_geometry', params.destinationGeometry); return editTask.execute(); } static updateWarehouseOut(params) { let editTask = new EditTask(artApi.wareHouseOutboundUpdate); editTask.addParam('_id', params.id); editTask.addParam('_artwork_record_id', params.artworkRecordId); editTask.addParam('_recipient', params.recipient); editTask.addParam('_recipient_signature_image', params.recipientSignatureimage); editTask.addParam('_reason', params.reason); editTask.addParam('_images', params.images); editTask.addParam('_remark', params.remark); editTask.addParam('_destination', params.destination); editTask.addParam('_destination_geometry', params.destinationGeometry); return editTask.execute(); } static deteleWareHouseOut(params) { let editTask = new EditTask(artApi.wareHouseOutboundDelete); editTask.addParam('_id', params.id); return editTask.execute(); } static queryWarehouseOut(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.viewWareHouseOutbound, pageInfo); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { if (pageInfo) { if (res.data) { res.data = res.data.map((item) => { return new Outbound(item); }); resolve(res); } } else { let resArr = res.map((item) => { return new Outbound(item); }); resolve(resArr); } }) .catch((err) => { reject(err); }); }); } } export default Outbound;