333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
}