222
schangxiang@126.com
2025-06-13 6a8393408d8cefcea02b7a598967de8dc1e565c2
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
}