import BaseService from "../baseService";
|
import { ResultInfo } from "../../public/commonInterface";
|
import { RequireGoods } from "../../entity/outbound/require/requireGoods";
|
|
export default class GoodsService extends BaseService {
|
//#region 批量审核
|
public async batchAuditing(): Promise<ResultInfo> {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
|
try {
|
let idValues = body.idValues;
|
if (!Array.isArray(idValues)) {
|
this.info.result = false;
|
this.info.msg = "没有可执行的数据";
|
return this.info;
|
}
|
|
for (var idValue of idValues) {
|
let dataInfo = await this.dbRead.findOne(RequireGoods, idValue);
|
if (!dataInfo) {
|
this.info.result = false;
|
this.info.msg = "单据不存在";
|
return this.info;
|
}
|
|
await this.dbWrite.update(
|
RequireGoods,
|
{
|
goods_Id: dataInfo.goods_Id,
|
userProduct_Id: userInfo.userProduct_Id
|
},
|
{
|
goodsText: "已审核",
|
auditing: 2,
|
auditor: userInfo.userTrueName,
|
auditDate: new Date()
|
}
|
);
|
}
|
this.info.result = true;
|
this.info.msg = "审核成功";
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "审核失败" + error.message;
|
}
|
|
return this.info;
|
}
|
//#endregion
|
}
|