import { EditTask, Query, QueryTask } from './artUtil.js'; import { artApi } from './artApi'; import ArtworkEquipmentType from './equipmentType'; import ArtRepairLog from './artRepairLog'; import outBoundReview from './outBoundReview'; import OutBoundReview from './outBoundReview'; import ArtImage from "./artImage"; class Outbound { constructor(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; //出库原因 if(params.images){ this.images = params.images.map(url=>{ return new ArtImage(url) }); } // 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 createWarehouseOut(params = {}) { let editTask = new EditTask(artApi.wareHouseOutboundInsert); editTask.addParam('_artwork_record_id', params.artworkRecordId); editTask.addParam('_recipient', params.recipient); 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 new Promise((resolve, reject) => { editTask .execute() .then((res) => { if (res.data) { let outbound = new Outbound(res.data); resolve(outbound); } else { reject('数据异常,创建失败!'); } }) .catch((err) => { reject(err); }); }); } updateWarehouseOut(params = {}) { let editTask = new EditTask(artApi.wareHouseOutboundUpdate); editTask.addParam('_id', this.id); editTask.addParam('_artwork_record_id', params.artworkRecordId); editTask.addParam('_recipient', params.recipient); 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 new Promise((resolve, reject) => { editTask .execute() .then((res) => { if (res.data) { let outbound = new Outbound(res.data); resolve(outbound); } else { reject('数据异常,创建失败!'); } }) .catch((err) => { reject(err); }); }); } 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); }); }); } //查看出库记录对应的出库审核记录信息 queryoutboundReview(params = {}) { let query = new Query(); let { filter } = params; if (filter) { filter.forEach((item) => { query.addFilter(item['name'], item['operator'], item['value']); }); } query.addFilter('ware_house_outbound_id', '=', this.id); let queryTask = new QueryTask(artApi.viewWareHouseOutboundReview, false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { let resArr = res.map((item) => { return new OutBoundReview(item); }); resolve(resArr); }) .catch((err) => { reject(err); }); }); } } export default Outbound;