import BaseService from "../baseService";
|
import { BasePlate } from "../../entity/basicInfo/base/basePlate";
|
import { Not } from "typeorm";
|
|
/**
|
* 器具信息
|
*/
|
export default class PlateService extends BaseService {
|
//#region 添加保存前事件
|
/**
|
* 添加保存前事件
|
*/
|
public async onAddSaveBefore(t: BasePlate) {
|
let userInfo = await this.userInfo;
|
this.info.result = true;
|
//判断器具编号是否重复
|
let where = {
|
plateCode: t.plateCode,
|
userProduct_Id: userInfo.userProduct_Id
|
};
|
// 编辑是排除自己
|
if (t.plate_Id) {
|
where["plate_Id"] = Not(t.plate_Id);
|
}
|
|
let count = await this.dbRead.count(BasePlate, where);
|
if (count) {
|
this.info.msg = "当前器具编号,【" + t.plateCode + "】已存在不允许重复添加,无法添加!";
|
this.info.result = false;
|
}
|
|
return this.info;
|
}
|
//#endregion
|
}
|