import BaseService from "../baseService";
|
import { Post } from "egg-shell-decorators";
|
import { TMSQuotation } from "../../entity/express/tms/tmsQuotation";
|
import { In } from "typeorm";
|
|
/**
|
* 预到货计划单
|
*/
|
export default class QuotationService extends BaseService {
|
//#region 批量审核
|
/**
|
* 如果明细为空则不让审核通过
|
*/
|
@Post()
|
public async batchAuditing() {
|
let userInfo = await this.userInfo;
|
try {
|
//#region 校验数据
|
if (!Array.isArray(this.body.idValues) || !this.body.idValues.length) {
|
this.info.result = false;
|
this.info.msg = "数据不存在";
|
this.ctx.body = this.info;
|
return;
|
}
|
//#endregion
|
|
//#region 审核
|
var result = await this.dbWrite.update(
|
TMSQuotation,
|
{
|
quotation_Id: In(this.body.idValues)
|
},
|
{
|
quotationStatus: "已审核",
|
auditor: userInfo.userTrueName,
|
auditing: 2,
|
auditDate: new Date()
|
}
|
);
|
if (result) {
|
this.info.result = true;
|
this.info.msg = "审核成功";
|
} else {
|
this.info.result = false;
|
this.info.msg = "审核失败";
|
}
|
//#endregion
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "错误信息:" + ex.message;
|
}
|
return this.info;
|
}
|
//#endregion
|
//#region 终止
|
public async stop() {
|
let QuotationList = await this.dbRead.find(TMSQuotation, {
|
quotation_Id: In(this.body.idValues)
|
});
|
for (let orderInfo of QuotationList) {
|
// await this.ctx.service.inbound.orderHelper.setStatusHistory(
|
// orderInfo.order_Id,
|
// orderInfo.statusText,
|
// "终止",
|
// "单据状态",
|
// "订单终止"
|
// );
|
await this.dbRead.update(TMSQuotation, orderInfo.quotation_Id, {
|
quotationStatus: "终止",
|
auditing: null,
|
auditDate: null,
|
auditor: null
|
});
|
}
|
this.info.result = true;
|
this.info.msg = "终止成功!";
|
|
return this.info;
|
}
|
//#endregion
|
|
//#region 开启
|
public async open() {
|
let QuotationList = await this.dbRead.find(TMSQuotation, {
|
quotation_Id: In(this.body.idValues)
|
});
|
for (let orderInfo of QuotationList) {
|
await this.dbRead.update(TMSQuotation, orderInfo.quotation_Id, {
|
quotationStatus: "新建"
|
});
|
}
|
this.info.result = true;
|
this.info.msg = "开启成功!";
|
|
return this.info;
|
}
|
//#endregion
|
|
//#region onCopyBefore 复制前事件
|
public async onCopyBefore(dataInfo: TMSQuotation) {
|
dataInfo.quotationStatus = "新建";
|
dataInfo.auditing = null;
|
dataInfo.auditor = null;
|
dataInfo.auditDate = null;
|
this.info.result = true;
|
this.info.msg = "处理完毕";
|
|
return this.info;
|
}
|
//#endregion
|
}
|