@cpzxrobot/sdk 1.3.29 → 1.3.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,6 +54,23 @@ export class CompanyGateway extends Object {
54
54
  }
55
55
  }
56
56
 
57
+ get department() {
58
+ return {
59
+ list: async (pid: string) => {
60
+ var axios = await this.context.ready;
61
+ return axios.get(`/api/v3/enterprise/department/${pid}`);
62
+ },
63
+ detail: async (id: string) => {
64
+ var axios = await this.context.ready;
65
+ return axios.get(`/api/v3/enterprise/department/${id}/detail`);
66
+ },
67
+ create: async (data: any) => {
68
+ var axios = await this.context.ready;
69
+ return axios.post(`/api/v3/enterprise/department`, data);
70
+ }
71
+ }
72
+ }
73
+
57
74
  get cost() {
58
75
  return {
59
76
  byMonth: async (companyId: number) => {
package/device_gateway.ts CHANGED
@@ -669,6 +669,94 @@ export class DeviceGateway extends Object {
669
669
  pageSize
670
670
  }
671
671
  });
672
+ },
673
+
674
+ create: async (data: {
675
+ deviceNo?: string;
676
+ orderNo?: string;
677
+ troubleType?: number;
678
+ serviceMan?: number;
679
+ troubleTime?: string;
680
+ repairerMobile?: string;
681
+ troubleRank?: number;
682
+ repairGroup?: string;
683
+ urgencyDegree?: number;
684
+ isDown?: boolean;
685
+ experienceCode?: string;
686
+ troubleDescribe?: string;
687
+ faultSource?: string;
688
+ troubleState?: string;
689
+ canReview?: boolean;
690
+ }): Promise<any> => {
691
+ const axios = await this.context.ready;
692
+ return axios.post('/api/v3/device/trouble/create', data)
693
+ .then((res) => {
694
+ if (res.data.code !== 200) {
695
+ throw new Error(res.data.message || '创建故障失败');
696
+ }
697
+ return res.data;
698
+ });
699
+ }
700
+ };
701
+ }
702
+
703
+ get troubleLevel() {
704
+ return {
705
+ list: async (): Promise<any> => {
706
+ var axios = await this.context.ready;
707
+ return axios.get('/api/v3/device/trouble-level');
708
+ },
709
+
710
+ create: async (data: {
711
+ name: string;
712
+ code?: string;
713
+ color?: string;
714
+ description?: string;
715
+ }): Promise<any> => {
716
+ var axios = await this.context.ready;
717
+ return axios.post('/api/v3/device/trouble-level', data);
718
+ }
719
+ }
720
+ }
721
+
722
+ get troubleType() {
723
+ return {
724
+ // 获取根节点(原list方法)
725
+ list: async (): Promise<any> => {
726
+ var axios = await this.context.ready;
727
+ return axios.get('/api/v3/device/trouble-type');
728
+ },
729
+
730
+ // 获取直接子节点
731
+ getDirectChildren: async (id: number): Promise<any> => {
732
+ var axios = await this.context.ready;
733
+ return axios.get(`/api/v3/device/trouble-type/${id}`);
734
+ },
735
+
736
+ // 获取所有子节点
737
+ getAllChildren: async (id: number): Promise<any> => {
738
+ var axios = await this.context.ready;
739
+ return axios.get(`/api/v3/device/trouble-type/${id}/all`);
740
+ },
741
+
742
+ // 获取完整树结构
743
+ getTree: async (): Promise<any> => {
744
+ var axios = await this.context.ready;
745
+ return axios.get('/api/v3/device/trouble-type/tree');
746
+ },
747
+
748
+ // 创建节点
749
+ create: async (data: {
750
+ name: string;
751
+ }): Promise<any> => {
752
+ var axios = await this.context.ready;
753
+ return axios.post('/api/v3/device/trouble-type', data);
754
+ },
755
+
756
+ // 删除节点(根据Java控制器的DeleteMapping)
757
+ delete: async (id: number): Promise<any> => {
758
+ var axios = await this.context.ready;
759
+ return axios.delete(`/api/v3/device/trouble-type/${id}`);
672
760
  }
673
761
  };
674
762
  }
@@ -714,4 +802,37 @@ export class DeviceGateway extends Object {
714
802
  }
715
803
  }
716
804
  }
805
+
806
+ get maintenanceGroup() {
807
+ return {
808
+ // 获取维护组列表
809
+ list: async (factoryId: number): Promise<any> => {
810
+ const axios = await this.context.ready;
811
+ return axios.get('/api/v3/device/maintenance-groups', {
812
+ params: { factoryId }
813
+ });
814
+ },
815
+
816
+ // 创建维护组
817
+ create: async (factoryId: number, group: {
818
+ name: string;
819
+ code?: string;
820
+ description?: string;
821
+ members?: number[];
822
+ }): Promise<any> => {
823
+ const axios = await this.context.ready;
824
+ return axios.post('/api/v3/device/maintenance-groups', group, {
825
+ params: { factoryId }
826
+ });
827
+ },
828
+
829
+ // 删除维护组
830
+ delete: async (factoryId: number, groupId: number): Promise<any> => {
831
+ const axios = await this.context.ready;
832
+ return axios.delete(`/api/v3/device/maintenance-groups/${groupId}`, {
833
+ params: { factoryId }
834
+ });
835
+ }
836
+ };
837
+ }
717
838
  }
@@ -46,6 +46,22 @@ class CompanyGateway extends Object {
46
46
  },
47
47
  };
48
48
  }
49
+ get department() {
50
+ return {
51
+ list: async (pid) => {
52
+ var axios = await this.context.ready;
53
+ return axios.get(`/api/v3/enterprise/department/${pid}`);
54
+ },
55
+ detail: async (id) => {
56
+ var axios = await this.context.ready;
57
+ return axios.get(`/api/v3/enterprise/department/${id}/detail`);
58
+ },
59
+ create: async (data) => {
60
+ var axios = await this.context.ready;
61
+ return axios.post(`/api/v3/enterprise/department`, data);
62
+ }
63
+ };
64
+ }
49
65
  get cost() {
50
66
  return {
51
67
  byMonth: async (companyId) => {
@@ -516,6 +516,62 @@ class DeviceGateway extends Object {
516
516
  pageSize
517
517
  }
518
518
  });
519
+ },
520
+ create: async (data) => {
521
+ const axios = await this.context.ready;
522
+ return axios.post('/api/v3/device/trouble/create', data)
523
+ .then((res) => {
524
+ if (res.data.code !== 200) {
525
+ throw new Error(res.data.message || '创建故障失败');
526
+ }
527
+ return res.data;
528
+ });
529
+ }
530
+ };
531
+ }
532
+ get troubleLevel() {
533
+ return {
534
+ list: async () => {
535
+ var axios = await this.context.ready;
536
+ return axios.get('/api/v3/device/trouble-level');
537
+ },
538
+ create: async (data) => {
539
+ var axios = await this.context.ready;
540
+ return axios.post('/api/v3/device/trouble-level', data);
541
+ }
542
+ };
543
+ }
544
+ get troubleType() {
545
+ return {
546
+ // 获取根节点(原list方法)
547
+ list: async () => {
548
+ var axios = await this.context.ready;
549
+ return axios.get('/api/v3/device/trouble-type');
550
+ },
551
+ // 获取直接子节点
552
+ getDirectChildren: async (id) => {
553
+ var axios = await this.context.ready;
554
+ return axios.get(`/api/v3/device/trouble-type/${id}`);
555
+ },
556
+ // 获取所有子节点
557
+ getAllChildren: async (id) => {
558
+ var axios = await this.context.ready;
559
+ return axios.get(`/api/v3/device/trouble-type/${id}/all`);
560
+ },
561
+ // 获取完整树结构
562
+ getTree: async () => {
563
+ var axios = await this.context.ready;
564
+ return axios.get('/api/v3/device/trouble-type/tree');
565
+ },
566
+ // 创建节点
567
+ create: async (data) => {
568
+ var axios = await this.context.ready;
569
+ return axios.post('/api/v3/device/trouble-type', data);
570
+ },
571
+ // 删除节点(根据Java控制器的DeleteMapping)
572
+ delete: async (id) => {
573
+ var axios = await this.context.ready;
574
+ return axios.delete(`/api/v3/device/trouble-type/${id}`);
519
575
  }
520
576
  };
521
577
  }
@@ -544,5 +600,30 @@ class DeviceGateway extends Object {
544
600
  }
545
601
  };
546
602
  }
603
+ get maintenanceGroup() {
604
+ return {
605
+ // 获取维护组列表
606
+ list: async (factoryId) => {
607
+ const axios = await this.context.ready;
608
+ return axios.get('/api/v3/device/maintenance-groups', {
609
+ params: { factoryId }
610
+ });
611
+ },
612
+ // 创建维护组
613
+ create: async (factoryId, group) => {
614
+ const axios = await this.context.ready;
615
+ return axios.post('/api/v3/device/maintenance-groups', group, {
616
+ params: { factoryId }
617
+ });
618
+ },
619
+ // 删除维护组
620
+ delete: async (factoryId, groupId) => {
621
+ const axios = await this.context.ready;
622
+ return axios.delete(`/api/v3/device/maintenance-groups/${groupId}`, {
623
+ params: { factoryId }
624
+ });
625
+ }
626
+ };
627
+ }
547
628
  }
548
629
  exports.DeviceGateway = DeviceGateway;
package/dist/index.js CHANGED
@@ -52,6 +52,7 @@ const system_gateway_1 = require("./system_gateway");
52
52
  const mobile_platform_1 = require("./mobile_platform");
53
53
  const web_platform_1 = require("./web_platform");
54
54
  const production_gateway_1 = require("./production_gateway");
55
+ const purchase_gateway_1 = require("./purchase_gateway");
55
56
  class Cpzxrobot {
56
57
  constructor(appCode, baseUrl, initSelectedFactory, initSelectedUnit) {
57
58
  this.pigfarm = new pigfarm_gateway_1.PigfarmGateway(this);
@@ -73,6 +74,7 @@ class Cpzxrobot {
73
74
  this.construction = new construction_gateway_1.ConstructionGateway(this);
74
75
  this.system = new system_gateway_1.SystemGateway(this);
75
76
  this.production = new production_gateway_1.ProductionGateway(this);
77
+ this.purchase = new purchase_gateway_1.PurchaseGateway(this);
76
78
  this.sseCallbacks = {};
77
79
  //获取当前浏览器的域名
78
80
  this.ready = new Promise((resolve, reject) => {
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PurchaseGateway = void 0;
4
+ class PurchaseGateway {
5
+ constructor(context) {
6
+ this.context = context;
7
+ this.context.ready.then((axios) => {
8
+ this.axios = axios;
9
+ });
10
+ }
11
+ /**
12
+ * 技术部创建采购单
13
+ * @param params 采购单参数
14
+ */
15
+ async create(params) {
16
+ return this.axios.post("/api/v2/coremde-sale/purchase/order/create", params);
17
+ }
18
+ /**
19
+ * 商务部审核采购单
20
+ * @param params 审核参数
21
+ */
22
+ async approve(params) {
23
+ return this.axios.post("/api/v2/coremde-sale/purchase/order/approve", params);
24
+ }
25
+ /**
26
+ * 技术部更新采购单
27
+ * @param params 更新参数
28
+ */
29
+ async update(params) {
30
+ return this.axios.post("/api/v2/coremde-sale/purchase/order/update", params);
31
+ }
32
+ /**
33
+ * 获取采购单列表
34
+ * @param params 查询参数
35
+ */
36
+ async list(params) {
37
+ return this.axios.post("/api/v2/coremde-sale/purchase/order/list", params);
38
+ }
39
+ /**
40
+ * 获取采购单详情
41
+ * @param id 采购单ID
42
+ */
43
+ async get(id) {
44
+ return this.axios.get("/api/v2/coremde-sale/purchase/order/get", {
45
+ params: { id }
46
+ });
47
+ }
48
+ }
49
+ exports.PurchaseGateway = PurchaseGateway;
package/index.ts CHANGED
@@ -27,6 +27,7 @@ import { SystemGateway } from "./system_gateway";
27
27
  import { MobilePlatform } from "./mobile_platform";
28
28
  import { WebPlatform } from "./web_platform";
29
29
  import { ProductionGateway } from "./production_gateway";
30
+ import { PurchaseGateway } from "./purchase_gateway";
30
31
 
31
32
  export class Cpzxrobot {
32
33
  private static factorySelectorLoaded = false;
@@ -68,6 +69,7 @@ export class Cpzxrobot {
68
69
  construction: ConstructionGateway = new ConstructionGateway(this);
69
70
  system: SystemGateway = new SystemGateway(this);
70
71
  production: ProductionGateway = new ProductionGateway(this);
72
+ purchase: PurchaseGateway = new PurchaseGateway(this);
71
73
  sseCallbacks: {
72
74
  [key: string]: (data: any) => void;
73
75
  } = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.29",
3
+ "version": "1.3.30",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,90 @@
1
+ import type { Cpzxrobot } from ".";
2
+ import type { MyAxiosInstance } from "./types";
3
+
4
+ export class PurchaseGateway {
5
+ private context: Cpzxrobot;
6
+ private axios!: MyAxiosInstance;
7
+
8
+ constructor(context: Cpzxrobot) {
9
+ this.context = context;
10
+ this.context.ready.then((axios) => {
11
+ this.axios = axios;
12
+ });
13
+ }
14
+
15
+ /**
16
+ * 技术部创建采购单
17
+ * @param params 采购单参数
18
+ */
19
+ async create(params: {
20
+ projectId: number;
21
+ id?: number;
22
+ contractId?: number;
23
+ productsInfo: Array<{
24
+ productId: number;
25
+ name: string;
26
+ model: string;
27
+ materialCode: string;
28
+ qty: number;
29
+ unit: string;
30
+ remark?: string;
31
+ }>;
32
+ }) {
33
+ return this.axios.post("/api/v2/coremde-sale/purchase/order/create", params);
34
+ }
35
+
36
+ /**
37
+ * 商务部审核采购单
38
+ * @param params 审核参数
39
+ */
40
+ async approve(params: {
41
+ id: number;
42
+ approveResult: number;
43
+ approveNotes?: string;
44
+ }) {
45
+ return this.axios.post("/api/v2/coremde-sale/purchase/order/approve", params);
46
+ }
47
+
48
+ /**
49
+ * 技术部更新采购单
50
+ * @param params 更新参数
51
+ */
52
+ async update(params: {
53
+ id: number;
54
+ productsInfo: Array<{
55
+ productId: number;
56
+ name: string;
57
+ model: string;
58
+ materialCode: string;
59
+ qty: number;
60
+ unit: string;
61
+ remark?: string;
62
+ }>;
63
+ }) {
64
+ return this.axios.post("/api/v2/coremde-sale/purchase/order/update", params);
65
+ }
66
+
67
+ /**
68
+ * 获取采购单列表
69
+ * @param params 查询参数
70
+ */
71
+ async list(params: {
72
+ projectId?: number;
73
+ createTimeStart?: string;
74
+ createTimeEnd?: string;
75
+ pageNo?: number;
76
+ pageSize?: number;
77
+ }) {
78
+ return this.axios.post("/api/v2/coremde-sale/purchase/order/list", params);
79
+ }
80
+
81
+ /**
82
+ * 获取采购单详情
83
+ * @param id 采购单ID
84
+ */
85
+ async get(id: number) {
86
+ return this.axios.get("/api/v2/coremde-sale/purchase/order/get", {
87
+ params: { id }
88
+ });
89
+ }
90
+ }
package/types.d.ts CHANGED
@@ -322,6 +322,26 @@ interface ElectricMeter extends Device {
322
322
  status: string;
323
323
  }
324
324
 
325
+ interface PurchaseProduct {
326
+ productId: number;
327
+ name: string;
328
+ model: string;
329
+ materialCode: string;
330
+ qty: number;
331
+ unit: string;
332
+ remark?: string;
333
+ }
334
+
335
+ interface PurchaseOrder {
336
+ id: number;
337
+ projectId: number;
338
+ contractId?: number;
339
+ productsInfo: PurchaseProduct[];
340
+ status?: string;
341
+ createTime?: string;
342
+ updateTime?: string;
343
+ }
344
+
325
345
  interface DevicePurpose {
326
346
  id?: number;
327
347
  name: string;
@@ -383,6 +403,7 @@ class Cpzxrobot {
383
403
  dict: (key: string) => any;
384
404
  platform: PlatformInterface;
385
405
  production: ProductionGateway;
406
+ purchase: PurchaseGateway;
386
407
  // _getSelectedFarmFromMiniApp: () => Promise<Factory>;
387
408
  // _getSelectedUnitFromMiniApp: () => Promise<Unit>;
388
409
  openMiniApp: (url: string) => void;