import { default as BaseController } from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { PurchaseReturn } from "../../entity/inbound/purchase/purchaseReturn";
|
import { PurchaseReturnList } from "../../entity/inbound/purchase/purchaseReturnList";
|
// const sortingInstanceName = "SortingInstance_StorageCheck";
|
export default class ReturnController extends BaseController {
|
//#region 复制单据
|
@Post()
|
public async copySaleOrder() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let return_Id = body.return_Id;
|
let returnCode = await ctx.service.common.getCodeRegular(104); //得到自动编号
|
try {
|
let returninfo = await this.dbRead.findOne(PurchaseReturn, {
|
return_Id: return_Id
|
});
|
let returnNew = new PurchaseReturn();
|
returnNew = { ...returninfo };
|
returnNew.return_Id = 0;
|
returnNew.returnCode = returnCode;
|
returnNew.sortingStatus = 1;
|
returnNew.sortingDate = null;
|
returnNew.statusID = 1;
|
returnNew.statusText = "新建";
|
returnNew.auditing = 0;
|
returnNew.auditor = "";
|
returnNew.auditDate = null;
|
|
await this.dbWrite.insert(PurchaseReturn, returnNew);
|
//如果订单主表新增成功,在复制明细
|
if (returnNew.return_Id > 0) {
|
let saleQuotationList = await this.dbRead.find(PurchaseReturnList, {
|
return_Id: return_Id
|
});
|
for (let detail of saleQuotationList) {
|
let detailNew = new PurchaseReturnList();
|
detailNew = { ...detail };
|
detailNew.orderList_Id = 0;
|
detailNew.return_Id = returnNew.return_Id;
|
await this.dbWrite.insert(PurchaseReturnList, detailNew);
|
}
|
|
this.info.msg = "复制成功!";
|
this.info.result = true;
|
} else {
|
this.info.msg = "错误信息:复制失败!";
|
this.info.result = false;
|
//info.Data = 0;
|
}
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "错误信息:" + ex.message;
|
}
|
|
ctx.body = this.info;
|
}
|
|
//#endregion
|
}
|