@cpzxrobot/sdk 1.3.32 → 1.3.33
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.
- package/company_gateway.ts +20 -3
- package/device_filter.ts +1 -0
- package/device_gateway.ts +249 -32
- package/dist/company_gateway.js +16 -0
- package/dist/device_gateway.js +182 -11
- package/dist/index.js +4 -0
- package/dist/project_gateway.js +68 -0
- package/dist/sparepart_gateway.js +40 -0
- package/dist/stage_template_service.js +9 -0
- package/dist/warehouse_gateway.js +30 -0
- package/dist/web_platform.js +2 -1
- package/index.ts +6 -0
- package/package.json +1 -1
- package/project_gateway.ts +105 -1
- package/sparepart_gateway.ts +45 -0
- package/stage_template_service.ts +10 -0
- package/types.d.ts +17 -1
- package/warehouse_gateway.ts +35 -0
- package/web_platform.ts +5 -1
package/company_gateway.ts
CHANGED
|
@@ -10,7 +10,7 @@ export class CompanyGateway extends Object {
|
|
|
10
10
|
this.warzone = new WarzoneGateway(context);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
async list(pageNo: number, pageSize: number,pid:number, companyName:string) {
|
|
13
|
+
async list(pageNo: number, pageSize: number, pid: number, companyName: string) {
|
|
14
14
|
var axios = await this.context.ready;
|
|
15
15
|
return axios
|
|
16
16
|
.get(`/api/v2/company/list?current=${pageNo}&size=${pageSize}&pid=${pid}&companyName=${companyName}`)
|
|
@@ -54,19 +54,36 @@ export class CompanyGateway extends Object {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
async attribute(key: string, companyId: number | undefined = undefined) {
|
|
58
|
+
let axios = await this.context.ready;
|
|
59
|
+
if (!companyId) {
|
|
60
|
+
var selectedFarm = await this.context.user.getSelectedFarm();
|
|
61
|
+
companyId = selectedFarm.id;
|
|
62
|
+
}
|
|
63
|
+
return axios.get(`/api/v2/company/${companyId}/attribute/${key}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
get department() {
|
|
58
67
|
return {
|
|
59
68
|
list: async (pid: string) => {
|
|
60
69
|
var axios = await this.context.ready;
|
|
61
70
|
return axios.get(`/api/v3/enterprise/department/${pid}`);
|
|
62
71
|
},
|
|
63
|
-
detail: async (id: string) => {
|
|
72
|
+
detail: async (id: string|number) => {
|
|
64
73
|
var axios = await this.context.ready;
|
|
65
74
|
return axios.get(`/api/v3/enterprise/department/${id}/detail`);
|
|
66
75
|
},
|
|
67
76
|
create: async (data: any) => {
|
|
68
77
|
var axios = await this.context.ready;
|
|
69
78
|
return axios.post(`/api/v3/enterprise/department`, data);
|
|
79
|
+
},
|
|
80
|
+
mark: async (factoryId: string, departmentId: string, kind: "maintenance") => {
|
|
81
|
+
var axios = await this.context.ready;
|
|
82
|
+
return axios.post(`/api/v3/enterprise/department/${factoryId}/mark`, { departmentId, kind });
|
|
83
|
+
},
|
|
84
|
+
users: async (id: number) => {
|
|
85
|
+
var axios = await this.context.ready;
|
|
86
|
+
return axios.get("/api/v2/factory/" + id + "/users");
|
|
70
87
|
}
|
|
71
88
|
}
|
|
72
89
|
}
|
|
@@ -163,7 +180,7 @@ export class CompanyGateway extends Object {
|
|
|
163
180
|
}
|
|
164
181
|
|
|
165
182
|
//用于获得父节点的子节点列表,用于树形结构展示
|
|
166
|
-
async treenode(pid: number|undefined) {
|
|
183
|
+
async treenode(pid: number | undefined) {
|
|
167
184
|
var axios = await this.context.ready;
|
|
168
185
|
if (pid == undefined) {
|
|
169
186
|
return axios.get(`/api/tenant/groups`);
|
package/device_filter.ts
CHANGED
package/device_gateway.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
DataQueryArgs,
|
|
7
7
|
DeviceV2,
|
|
8
8
|
Factory,
|
|
9
|
+
Supplier,
|
|
9
10
|
} from ".";
|
|
10
11
|
|
|
11
12
|
class DeviceFault {
|
|
@@ -263,6 +264,7 @@ export class DeviceGateway extends Object {
|
|
|
263
264
|
| "latest"
|
|
264
265
|
| "weekoverweek"
|
|
265
266
|
| "last"
|
|
267
|
+
| "lastWithTime"
|
|
266
268
|
| "rangeToday"
|
|
267
269
|
| null; //如果data为null,则不获取数据,只获取设备列表,否则获取设备列表和数据
|
|
268
270
|
status?: string;
|
|
@@ -530,7 +532,7 @@ export class DeviceGateway extends Object {
|
|
|
530
532
|
* @param data 更新数据
|
|
531
533
|
* @returns Promise
|
|
532
534
|
*/
|
|
533
|
-
edit: (configId:
|
|
535
|
+
edit: (configId: number, data: {
|
|
534
536
|
name: string;
|
|
535
537
|
manufacturer_id: number;
|
|
536
538
|
model_id: number;
|
|
@@ -564,7 +566,7 @@ export class DeviceGateway extends Object {
|
|
|
564
566
|
* @param keyword 搜索关键词(可选)
|
|
565
567
|
* @returns Promise
|
|
566
568
|
*/
|
|
567
|
-
list: (keyword?:
|
|
569
|
+
list: (keyword?: any): Promise<any> => {
|
|
568
570
|
return this.context.ready.then(() => {
|
|
569
571
|
return this.context.axios.get(`/api/v3/device/suppliers`, {
|
|
570
572
|
params: {
|
|
@@ -578,14 +580,7 @@ export class DeviceGateway extends Object {
|
|
|
578
580
|
* @param data 供应商数据
|
|
579
581
|
* @returns Promise
|
|
580
582
|
*/
|
|
581
|
-
create: (data: {
|
|
582
|
-
name: string;
|
|
583
|
-
code?: string;
|
|
584
|
-
contact?: string;
|
|
585
|
-
phone?: string;
|
|
586
|
-
address?: string;
|
|
587
|
-
remark?: string;
|
|
588
|
-
}): Promise<any> => {
|
|
583
|
+
create: (data: Supplier): Promise<any> => {
|
|
589
584
|
return this.context.ready.then(() => {
|
|
590
585
|
return this.context.axios.post(`/api/v3/device/suppliers`, data);
|
|
591
586
|
});
|
|
@@ -596,14 +591,7 @@ export class DeviceGateway extends Object {
|
|
|
596
591
|
* @param data 更新数据
|
|
597
592
|
* @returns Promise
|
|
598
593
|
*/
|
|
599
|
-
update: (id: number, data: {
|
|
600
|
-
name?: string;
|
|
601
|
-
code?: string;
|
|
602
|
-
contact?: string;
|
|
603
|
-
phone?: string;
|
|
604
|
-
address?: string;
|
|
605
|
-
remark?: string;
|
|
606
|
-
}): Promise<any> => {
|
|
594
|
+
update: (id: number, data: Supplier): Promise<any> => {
|
|
607
595
|
return this.context.ready.then(() => {
|
|
608
596
|
return this.context.axios.put(`/api/v3/device/suppliers/${id}`, data);
|
|
609
597
|
});
|
|
@@ -628,7 +616,7 @@ export class DeviceGateway extends Object {
|
|
|
628
616
|
if (parentId == undefined) {
|
|
629
617
|
return this.context.axios.get(`/api/v3/device/purpose`);
|
|
630
618
|
} else {
|
|
631
|
-
return this.context.axios.get(`/api/v3/device/purpose/${parentId}`);
|
|
619
|
+
return this.context.axios.get(`/api/v3/device/purpose/${parentId}/children`);
|
|
632
620
|
}
|
|
633
621
|
});
|
|
634
622
|
},
|
|
@@ -652,22 +640,30 @@ export class DeviceGateway extends Object {
|
|
|
652
640
|
return this.context.ready.then(() => {
|
|
653
641
|
return this.context.axios.delete(`/api/v3/device/purpose/${id}`);
|
|
654
642
|
});
|
|
655
|
-
}
|
|
643
|
+
},
|
|
644
|
+
|
|
645
|
+
detail: (id: number): Promise<any> => {
|
|
646
|
+
return this.context.ready.then(() => {
|
|
647
|
+
return this.context.axios.get(`/api/v3/device/purpose/${id}`);
|
|
648
|
+
});
|
|
649
|
+
},
|
|
656
650
|
}
|
|
657
651
|
}
|
|
658
652
|
|
|
659
653
|
get trouble() {
|
|
660
654
|
return {
|
|
661
|
-
list: async (
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
655
|
+
list: async (args: {
|
|
656
|
+
sourceType: "device" | "comprehensive" | undefined,
|
|
657
|
+
pageNum: number,
|
|
658
|
+
pageSize: number,
|
|
659
|
+
} = {
|
|
660
|
+
sourceType: "device",
|
|
661
|
+
pageNum: 1,
|
|
662
|
+
pageSize: 10,
|
|
663
|
+
}): Promise<any> => {
|
|
665
664
|
const axios = await this.context.ready;
|
|
666
665
|
return axios.get('/api/v3/device/trouble/list', {
|
|
667
|
-
params:
|
|
668
|
-
pageNum,
|
|
669
|
-
pageSize
|
|
670
|
-
}
|
|
666
|
+
params: args
|
|
671
667
|
});
|
|
672
668
|
},
|
|
673
669
|
|
|
@@ -696,7 +692,29 @@ export class DeviceGateway extends Object {
|
|
|
696
692
|
}
|
|
697
693
|
return res.data;
|
|
698
694
|
});
|
|
699
|
-
}
|
|
695
|
+
},
|
|
696
|
+
|
|
697
|
+
history: async (troubleId: string): Promise<any> => {
|
|
698
|
+
const axios = await this.context.ready;
|
|
699
|
+
return axios.get(`/api/v3/device/trouble/${troubleId}/handle-records`)
|
|
700
|
+
.then((res) => {
|
|
701
|
+
if (res.data.code !== 200) {
|
|
702
|
+
throw new Error(res.data.message || '获取处理记录失败');
|
|
703
|
+
}
|
|
704
|
+
return res.data;
|
|
705
|
+
});
|
|
706
|
+
},
|
|
707
|
+
|
|
708
|
+
delete: async (troubleIds: number[]): Promise<any> => {
|
|
709
|
+
const axios = await this.context.ready;
|
|
710
|
+
return axios.delete('/api/v3/device/trouble/delete', troubleIds)
|
|
711
|
+
.then((res) => {
|
|
712
|
+
if (res.data.code !== 200) {
|
|
713
|
+
throw new Error(res.data.message || '删除故障失败');
|
|
714
|
+
}
|
|
715
|
+
return res.data;
|
|
716
|
+
});
|
|
717
|
+
},
|
|
700
718
|
};
|
|
701
719
|
}
|
|
702
720
|
|
|
@@ -719,6 +737,44 @@ export class DeviceGateway extends Object {
|
|
|
719
737
|
}
|
|
720
738
|
}
|
|
721
739
|
|
|
740
|
+
get troubleReason() {
|
|
741
|
+
return {
|
|
742
|
+
list: async (): Promise<any> => {
|
|
743
|
+
var axios = await this.context.ready;
|
|
744
|
+
return axios.get('/api/v3/device/trouble-reason');
|
|
745
|
+
},
|
|
746
|
+
|
|
747
|
+
create: async (data: {
|
|
748
|
+
name: string;
|
|
749
|
+
code?: string;
|
|
750
|
+
color?: string;
|
|
751
|
+
description?: string;
|
|
752
|
+
}): Promise<any> => {
|
|
753
|
+
var axios = await this.context.ready;
|
|
754
|
+
return axios.post('/api/v3/device/trouble-reason', data);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
get troubleEmergency() {
|
|
760
|
+
return {
|
|
761
|
+
list: async (): Promise<any> => {
|
|
762
|
+
var axios = await this.context.ready;
|
|
763
|
+
return axios.get('/api/v3/device/trouble-emergency');
|
|
764
|
+
},
|
|
765
|
+
|
|
766
|
+
create: async (data: {
|
|
767
|
+
name: string;
|
|
768
|
+
code?: string;
|
|
769
|
+
color?: string;
|
|
770
|
+
description?: string;
|
|
771
|
+
}): Promise<any> => {
|
|
772
|
+
var axios = await this.context.ready;
|
|
773
|
+
return axios.post('/api/v3/device/trouble-emergency', data);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
722
778
|
get troubleType() {
|
|
723
779
|
return {
|
|
724
780
|
// 获取根节点(原list方法)
|
|
@@ -799,6 +855,11 @@ export class DeviceGateway extends Object {
|
|
|
799
855
|
delete: async (id: number): Promise<any> => {
|
|
800
856
|
var axios = await this.context.ready;
|
|
801
857
|
return axios.delete(`/api/v3/device/model/${id}`);
|
|
858
|
+
},
|
|
859
|
+
|
|
860
|
+
detail: async (id: number): Promise<any> => {
|
|
861
|
+
var axios = await this.context.ready;
|
|
862
|
+
return axios.get(`/api/v3/device/model/${id}`);
|
|
802
863
|
}
|
|
803
864
|
}
|
|
804
865
|
}
|
|
@@ -821,9 +882,7 @@ export class DeviceGateway extends Object {
|
|
|
821
882
|
members?: number[];
|
|
822
883
|
}): Promise<any> => {
|
|
823
884
|
const axios = await this.context.ready;
|
|
824
|
-
return axios.post(
|
|
825
|
-
params: { factoryId }
|
|
826
|
-
});
|
|
885
|
+
return axios.post(`/api/v3/device/maintenance-groups?factoryId=${factoryId}`, group);
|
|
827
886
|
},
|
|
828
887
|
|
|
829
888
|
// 删除维护组
|
|
@@ -832,7 +891,165 @@ export class DeviceGateway extends Object {
|
|
|
832
891
|
return axios.delete(`/api/v3/device/maintenance-groups/${groupId}`, {
|
|
833
892
|
params: { factoryId }
|
|
834
893
|
});
|
|
894
|
+
},
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
get maintenanceLevels() {
|
|
899
|
+
return {
|
|
900
|
+
// 获取维护级别列表
|
|
901
|
+
list: async (factoryId: number): Promise<any> => {
|
|
902
|
+
const axios = await this.context.ready;
|
|
903
|
+
return axios.get('/api/v3/device/maintenance-levels', {
|
|
904
|
+
params: { factoryId }
|
|
905
|
+
});
|
|
906
|
+
},
|
|
907
|
+
create: async (data: {
|
|
908
|
+
name: string;
|
|
909
|
+
code?: string;
|
|
910
|
+
color?: string;
|
|
911
|
+
description?: string;
|
|
912
|
+
}): Promise<any> => {
|
|
913
|
+
var axios = await this.context.ready;
|
|
914
|
+
return axios.post('/api/v3/device/maintenance-levels', data);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
get maintenanceTypes() {
|
|
920
|
+
return {
|
|
921
|
+
// 获取维护类型列表
|
|
922
|
+
list: async (factoryId: number): Promise<any> => {
|
|
923
|
+
const axios = await this.context.ready;
|
|
924
|
+
return axios.get('/api/v3/device/maintenance-types', {
|
|
925
|
+
params: { factoryId }
|
|
926
|
+
});
|
|
927
|
+
},
|
|
928
|
+
create: async (data: {
|
|
929
|
+
name: string;
|
|
930
|
+
code?: string;
|
|
931
|
+
color?: string;
|
|
932
|
+
description?: string;
|
|
933
|
+
}): Promise<any> => {
|
|
934
|
+
var axios = await this.context.ready;
|
|
935
|
+
return axios.post('/api/v3/device/maintenance-levels', data);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
get maintenanceFeedbackTypes() {
|
|
941
|
+
return {
|
|
942
|
+
// 获取维护类型列表
|
|
943
|
+
list: async (factoryId: number): Promise<any> => {
|
|
944
|
+
const axios = await this.context.ready;
|
|
945
|
+
return axios.get('/api/v3/device/maintenance-feedback-types', {
|
|
946
|
+
params: { factoryId }
|
|
947
|
+
});
|
|
948
|
+
},
|
|
949
|
+
create: async (data: {
|
|
950
|
+
name: string;
|
|
951
|
+
code?: string;
|
|
952
|
+
color?: string;
|
|
953
|
+
description?: string;
|
|
954
|
+
}): Promise<any> => {
|
|
955
|
+
var axios = await this.context.ready;
|
|
956
|
+
return axios.post('/api/v3/device/maintenance-feedback-types', data);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
//维修中状态
|
|
962
|
+
get maintenanceStatus() {
|
|
963
|
+
return {
|
|
964
|
+
list: async (): Promise<any> => {
|
|
965
|
+
const axios = await this.context.ready;
|
|
966
|
+
return axios.get('/api/v3/device/maintenance-status');
|
|
967
|
+
},
|
|
968
|
+
create: async (data: {
|
|
969
|
+
name: string;
|
|
970
|
+
code?: string;
|
|
971
|
+
color?: string;
|
|
972
|
+
description?: string;
|
|
973
|
+
}): Promise<any> => {
|
|
974
|
+
var axios = await this.context.ready;
|
|
975
|
+
return axios.post('/api/v3/device/maintenance-status', data);
|
|
835
976
|
}
|
|
836
977
|
};
|
|
837
978
|
}
|
|
979
|
+
|
|
980
|
+
//外委中状态列表
|
|
981
|
+
get maintenanceOutsourceStatus() {
|
|
982
|
+
return {
|
|
983
|
+
list: async (): Promise<any> => {
|
|
984
|
+
const axios = await this.context.ready;
|
|
985
|
+
return axios.get('/api/v3/device/maintenance-outsource-status');
|
|
986
|
+
},
|
|
987
|
+
create: async (data: {
|
|
988
|
+
name: string;
|
|
989
|
+
code?: string;
|
|
990
|
+
color?: string;
|
|
991
|
+
description?: string;
|
|
992
|
+
}): Promise<any> => {
|
|
993
|
+
var axios = await this.context.ready;
|
|
994
|
+
return axios.post('/api/v3/device/maintenance-outsource-status', data);
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
//故障来源
|
|
1000
|
+
get troubleDetectSource() {
|
|
1001
|
+
return {
|
|
1002
|
+
list: async (): Promise<any> => {
|
|
1003
|
+
const axios = await this.context.ready;
|
|
1004
|
+
return axios.get('/api/v3/device/trouble-detect-source');
|
|
1005
|
+
},
|
|
1006
|
+
create: async (data: {
|
|
1007
|
+
name: string;
|
|
1008
|
+
code?: string;
|
|
1009
|
+
color?: string;
|
|
1010
|
+
description?: string;
|
|
1011
|
+
}): Promise<any> => {
|
|
1012
|
+
var axios = await this.context.ready;
|
|
1013
|
+
return axios.post('/api/v3/device/trouble-detect-source', data);
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
get usage() {
|
|
1019
|
+
return {
|
|
1020
|
+
/**
|
|
1021
|
+
* 获取设备使用情况
|
|
1022
|
+
* @param deviceId 设备ID
|
|
1023
|
+
* @returns Promise 包含设备使用情况的数据
|
|
1024
|
+
*/
|
|
1025
|
+
get: async (deviceId: number): Promise<any> => {
|
|
1026
|
+
const axios = await this.context.ready;
|
|
1027
|
+
return axios.get(`/api/v3/device/usage/${deviceId}`)
|
|
1028
|
+
.then((res) => {
|
|
1029
|
+
if (res.data.code !== 200) {
|
|
1030
|
+
throw new Error(res.data.message || '获取设备使用情况失败');
|
|
1031
|
+
}
|
|
1032
|
+
return res.data;
|
|
1033
|
+
});
|
|
1034
|
+
},
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* 更新设备使用情况
|
|
1038
|
+
* @param deviceId 设备ID
|
|
1039
|
+
* @param usageData 使用情况数据
|
|
1040
|
+
* @returns Promise 包含更新后的设备使用情况数据
|
|
1041
|
+
*/
|
|
1042
|
+
update: async (deviceId: number, usageData: any): Promise<any> => {
|
|
1043
|
+
const axios = await this.context.ready;
|
|
1044
|
+
return axios.put(`/api/v3/device/usage/${deviceId}`, usageData)
|
|
1045
|
+
.then((res) => {
|
|
1046
|
+
if (res.data.code !== 200) {
|
|
1047
|
+
throw new Error(res.data.message || '更新设备使用情况失败');
|
|
1048
|
+
}
|
|
1049
|
+
return res.data;
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
|
|
838
1055
|
}
|
package/dist/company_gateway.js
CHANGED
|
@@ -46,6 +46,14 @@ class CompanyGateway extends Object {
|
|
|
46
46
|
},
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
+
async attribute(key, companyId = undefined) {
|
|
50
|
+
let axios = await this.context.ready;
|
|
51
|
+
if (!companyId) {
|
|
52
|
+
var selectedFarm = await this.context.user.getSelectedFarm();
|
|
53
|
+
companyId = selectedFarm.id;
|
|
54
|
+
}
|
|
55
|
+
return axios.get(`/api/v2/company/${companyId}/attribute/${key}`);
|
|
56
|
+
}
|
|
49
57
|
get department() {
|
|
50
58
|
return {
|
|
51
59
|
list: async (pid) => {
|
|
@@ -59,6 +67,14 @@ class CompanyGateway extends Object {
|
|
|
59
67
|
create: async (data) => {
|
|
60
68
|
var axios = await this.context.ready;
|
|
61
69
|
return axios.post(`/api/v3/enterprise/department`, data);
|
|
70
|
+
},
|
|
71
|
+
mark: async (factoryId, departmentId, kind) => {
|
|
72
|
+
var axios = await this.context.ready;
|
|
73
|
+
return axios.post(`/api/v3/enterprise/department/${factoryId}/mark`, { departmentId, kind });
|
|
74
|
+
},
|
|
75
|
+
users: async (id) => {
|
|
76
|
+
var axios = await this.context.ready;
|
|
77
|
+
return axios.get("/api/v2/factory/" + id + "/users");
|
|
62
78
|
}
|
|
63
79
|
};
|
|
64
80
|
}
|
package/dist/device_gateway.js
CHANGED
|
@@ -490,7 +490,7 @@ class DeviceGateway extends Object {
|
|
|
490
490
|
return this.context.axios.get(`/api/v3/device/purpose`);
|
|
491
491
|
}
|
|
492
492
|
else {
|
|
493
|
-
return this.context.axios.get(`/api/v3/device/purpose/${parentId}`);
|
|
493
|
+
return this.context.axios.get(`/api/v3/device/purpose/${parentId}/children`);
|
|
494
494
|
}
|
|
495
495
|
});
|
|
496
496
|
},
|
|
@@ -503,18 +503,24 @@ class DeviceGateway extends Object {
|
|
|
503
503
|
return this.context.ready.then(() => {
|
|
504
504
|
return this.context.axios.delete(`/api/v3/device/purpose/${id}`);
|
|
505
505
|
});
|
|
506
|
-
}
|
|
506
|
+
},
|
|
507
|
+
detail: (id) => {
|
|
508
|
+
return this.context.ready.then(() => {
|
|
509
|
+
return this.context.axios.get(`/api/v3/device/purpose/${id}`);
|
|
510
|
+
});
|
|
511
|
+
},
|
|
507
512
|
};
|
|
508
513
|
}
|
|
509
514
|
get trouble() {
|
|
510
515
|
return {
|
|
511
|
-
list: async (
|
|
516
|
+
list: async (args = {
|
|
517
|
+
sourceType: "device",
|
|
518
|
+
pageNum: 1,
|
|
519
|
+
pageSize: 10,
|
|
520
|
+
}) => {
|
|
512
521
|
const axios = await this.context.ready;
|
|
513
522
|
return axios.get('/api/v3/device/trouble/list', {
|
|
514
|
-
params:
|
|
515
|
-
pageNum,
|
|
516
|
-
pageSize
|
|
517
|
-
}
|
|
523
|
+
params: args
|
|
518
524
|
});
|
|
519
525
|
},
|
|
520
526
|
create: async (data) => {
|
|
@@ -526,7 +532,27 @@ class DeviceGateway extends Object {
|
|
|
526
532
|
}
|
|
527
533
|
return res.data;
|
|
528
534
|
});
|
|
529
|
-
}
|
|
535
|
+
},
|
|
536
|
+
history: async (troubleId) => {
|
|
537
|
+
const axios = await this.context.ready;
|
|
538
|
+
return axios.get(`/api/v3/device/trouble/${troubleId}/handle-records`)
|
|
539
|
+
.then((res) => {
|
|
540
|
+
if (res.data.code !== 200) {
|
|
541
|
+
throw new Error(res.data.message || '获取处理记录失败');
|
|
542
|
+
}
|
|
543
|
+
return res.data;
|
|
544
|
+
});
|
|
545
|
+
},
|
|
546
|
+
delete: async (troubleIds) => {
|
|
547
|
+
const axios = await this.context.ready;
|
|
548
|
+
return axios.delete('/api/v3/device/trouble/delete', troubleIds)
|
|
549
|
+
.then((res) => {
|
|
550
|
+
if (res.data.code !== 200) {
|
|
551
|
+
throw new Error(res.data.message || '删除故障失败');
|
|
552
|
+
}
|
|
553
|
+
return res.data;
|
|
554
|
+
});
|
|
555
|
+
},
|
|
530
556
|
};
|
|
531
557
|
}
|
|
532
558
|
get troubleLevel() {
|
|
@@ -541,6 +567,30 @@ class DeviceGateway extends Object {
|
|
|
541
567
|
}
|
|
542
568
|
};
|
|
543
569
|
}
|
|
570
|
+
get troubleReason() {
|
|
571
|
+
return {
|
|
572
|
+
list: async () => {
|
|
573
|
+
var axios = await this.context.ready;
|
|
574
|
+
return axios.get('/api/v3/device/trouble-reason');
|
|
575
|
+
},
|
|
576
|
+
create: async (data) => {
|
|
577
|
+
var axios = await this.context.ready;
|
|
578
|
+
return axios.post('/api/v3/device/trouble-reason', data);
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
get troubleEmergency() {
|
|
583
|
+
return {
|
|
584
|
+
list: async () => {
|
|
585
|
+
var axios = await this.context.ready;
|
|
586
|
+
return axios.get('/api/v3/device/trouble-emergency');
|
|
587
|
+
},
|
|
588
|
+
create: async (data) => {
|
|
589
|
+
var axios = await this.context.ready;
|
|
590
|
+
return axios.post('/api/v3/device/trouble-emergency', data);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
}
|
|
544
594
|
get troubleType() {
|
|
545
595
|
return {
|
|
546
596
|
// 获取根节点(原list方法)
|
|
@@ -597,6 +647,10 @@ class DeviceGateway extends Object {
|
|
|
597
647
|
delete: async (id) => {
|
|
598
648
|
var axios = await this.context.ready;
|
|
599
649
|
return axios.delete(`/api/v3/device/model/${id}`);
|
|
650
|
+
},
|
|
651
|
+
detail: async (id) => {
|
|
652
|
+
var axios = await this.context.ready;
|
|
653
|
+
return axios.get(`/api/v3/device/model/${id}`);
|
|
600
654
|
}
|
|
601
655
|
};
|
|
602
656
|
}
|
|
@@ -612,9 +666,7 @@ class DeviceGateway extends Object {
|
|
|
612
666
|
// 创建维护组
|
|
613
667
|
create: async (factoryId, group) => {
|
|
614
668
|
const axios = await this.context.ready;
|
|
615
|
-
return axios.post(
|
|
616
|
-
params: { factoryId }
|
|
617
|
-
});
|
|
669
|
+
return axios.post(`/api/v3/device/maintenance-groups?factoryId=${factoryId}`, group);
|
|
618
670
|
},
|
|
619
671
|
// 删除维护组
|
|
620
672
|
delete: async (factoryId, groupId) => {
|
|
@@ -622,6 +674,125 @@ class DeviceGateway extends Object {
|
|
|
622
674
|
return axios.delete(`/api/v3/device/maintenance-groups/${groupId}`, {
|
|
623
675
|
params: { factoryId }
|
|
624
676
|
});
|
|
677
|
+
},
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
get maintenanceLevels() {
|
|
681
|
+
return {
|
|
682
|
+
// 获取维护级别列表
|
|
683
|
+
list: async (factoryId) => {
|
|
684
|
+
const axios = await this.context.ready;
|
|
685
|
+
return axios.get('/api/v3/device/maintenance-levels', {
|
|
686
|
+
params: { factoryId }
|
|
687
|
+
});
|
|
688
|
+
},
|
|
689
|
+
create: async (data) => {
|
|
690
|
+
var axios = await this.context.ready;
|
|
691
|
+
return axios.post('/api/v3/device/maintenance-levels', data);
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
get maintenanceTypes() {
|
|
696
|
+
return {
|
|
697
|
+
// 获取维护类型列表
|
|
698
|
+
list: async (factoryId) => {
|
|
699
|
+
const axios = await this.context.ready;
|
|
700
|
+
return axios.get('/api/v3/device/maintenance-types', {
|
|
701
|
+
params: { factoryId }
|
|
702
|
+
});
|
|
703
|
+
},
|
|
704
|
+
create: async (data) => {
|
|
705
|
+
var axios = await this.context.ready;
|
|
706
|
+
return axios.post('/api/v3/device/maintenance-levels', data);
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
get maintenanceFeedbackTypes() {
|
|
711
|
+
return {
|
|
712
|
+
// 获取维护类型列表
|
|
713
|
+
list: async (factoryId) => {
|
|
714
|
+
const axios = await this.context.ready;
|
|
715
|
+
return axios.get('/api/v3/device/maintenance-feedback-types', {
|
|
716
|
+
params: { factoryId }
|
|
717
|
+
});
|
|
718
|
+
},
|
|
719
|
+
create: async (data) => {
|
|
720
|
+
var axios = await this.context.ready;
|
|
721
|
+
return axios.post('/api/v3/device/maintenance-feedback-types', data);
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
//维修中状态
|
|
726
|
+
get maintenanceStatus() {
|
|
727
|
+
return {
|
|
728
|
+
list: async () => {
|
|
729
|
+
const axios = await this.context.ready;
|
|
730
|
+
return axios.get('/api/v3/device/maintenance-status');
|
|
731
|
+
},
|
|
732
|
+
create: async (data) => {
|
|
733
|
+
var axios = await this.context.ready;
|
|
734
|
+
return axios.post('/api/v3/device/maintenance-status', data);
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
//外委中状态列表
|
|
739
|
+
get maintenanceOutsourceStatus() {
|
|
740
|
+
return {
|
|
741
|
+
list: async () => {
|
|
742
|
+
const axios = await this.context.ready;
|
|
743
|
+
return axios.get('/api/v3/device/maintenance-outsource-status');
|
|
744
|
+
},
|
|
745
|
+
create: async (data) => {
|
|
746
|
+
var axios = await this.context.ready;
|
|
747
|
+
return axios.post('/api/v3/device/maintenance-outsource-status', data);
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
//故障来源
|
|
752
|
+
get troubleDetectSource() {
|
|
753
|
+
return {
|
|
754
|
+
list: async () => {
|
|
755
|
+
const axios = await this.context.ready;
|
|
756
|
+
return axios.get('/api/v3/device/trouble-detect-source');
|
|
757
|
+
},
|
|
758
|
+
create: async (data) => {
|
|
759
|
+
var axios = await this.context.ready;
|
|
760
|
+
return axios.post('/api/v3/device/trouble-detect-source', data);
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
get usage() {
|
|
765
|
+
return {
|
|
766
|
+
/**
|
|
767
|
+
* 获取设备使用情况
|
|
768
|
+
* @param deviceId 设备ID
|
|
769
|
+
* @returns Promise 包含设备使用情况的数据
|
|
770
|
+
*/
|
|
771
|
+
get: async (deviceId) => {
|
|
772
|
+
const axios = await this.context.ready;
|
|
773
|
+
return axios.get(`/api/v3/device/usage/${deviceId}`)
|
|
774
|
+
.then((res) => {
|
|
775
|
+
if (res.data.code !== 200) {
|
|
776
|
+
throw new Error(res.data.message || '获取设备使用情况失败');
|
|
777
|
+
}
|
|
778
|
+
return res.data;
|
|
779
|
+
});
|
|
780
|
+
},
|
|
781
|
+
/**
|
|
782
|
+
* 更新设备使用情况
|
|
783
|
+
* @param deviceId 设备ID
|
|
784
|
+
* @param usageData 使用情况数据
|
|
785
|
+
* @returns Promise 包含更新后的设备使用情况数据
|
|
786
|
+
*/
|
|
787
|
+
update: async (deviceId, usageData) => {
|
|
788
|
+
const axios = await this.context.ready;
|
|
789
|
+
return axios.put(`/api/v3/device/usage/${deviceId}`, usageData)
|
|
790
|
+
.then((res) => {
|
|
791
|
+
if (res.data.code !== 200) {
|
|
792
|
+
throw new Error(res.data.message || '更新设备使用情况失败');
|
|
793
|
+
}
|
|
794
|
+
return res.data;
|
|
795
|
+
});
|
|
625
796
|
}
|
|
626
797
|
};
|
|
627
798
|
}
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,8 @@ 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
55
|
const purchase_gateway_1 = require("./purchase_gateway");
|
|
56
|
+
const warehouse_gateway_1 = require("./warehouse_gateway");
|
|
57
|
+
const sparepart_gateway_1 = require("./sparepart_gateway");
|
|
56
58
|
class Cpzxrobot {
|
|
57
59
|
constructor(appCode, baseUrl, initSelectedFactory, initSelectedUnit) {
|
|
58
60
|
this.pigfarm = new pigfarm_gateway_1.PigfarmGateway(this);
|
|
@@ -91,6 +93,8 @@ class Cpzxrobot {
|
|
|
91
93
|
this.energy = new energy_gateway_1.EnergyGateway(this);
|
|
92
94
|
this.camera = new camera_gateway_1.CameraGateway(this);
|
|
93
95
|
this.purchase = new purchase_gateway_1.PurchaseGateway(this);
|
|
96
|
+
this.warehouse = new warehouse_gateway_1.WarehouseGateway(this);
|
|
97
|
+
this.sparepart = new sparepart_gateway_1.SparePartGateway(this);
|
|
94
98
|
}
|
|
95
99
|
exit() {
|
|
96
100
|
if (this.mode === "miniapp_in_app") {
|
package/dist/project_gateway.js
CHANGED
|
@@ -472,5 +472,73 @@ class ProjectGateway extends Object {
|
|
|
472
472
|
},
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
|
+
get principal() {
|
|
476
|
+
return {
|
|
477
|
+
// 分配负责人
|
|
478
|
+
assign: (args) => {
|
|
479
|
+
return this.context.ready.then((axios) => {
|
|
480
|
+
return axios.post(`/api/v2/coremde-sale/project/principal/assign`, args);
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
get stages() {
|
|
486
|
+
return {
|
|
487
|
+
// 根据项目类型获取配置的阶段
|
|
488
|
+
byType: (projectTypeId) => {
|
|
489
|
+
return this.context.ready.then((axios) => {
|
|
490
|
+
return axios.get(`/api/v2/coremde-sale/project/type/template/${projectTypeId}`);
|
|
491
|
+
});
|
|
492
|
+
},
|
|
493
|
+
// 批量新增阶段模板
|
|
494
|
+
addBatch: (args) => {
|
|
495
|
+
return this.context.ready.then((axios) => {
|
|
496
|
+
return axios.post(`/api/v2/coremde-sale/project/type/template/batchAdd`, args);
|
|
497
|
+
});
|
|
498
|
+
},
|
|
499
|
+
// 批量更新阶段模板
|
|
500
|
+
updateBatch: (args) => {
|
|
501
|
+
return this.context.ready.then((axios) => {
|
|
502
|
+
return axios.post(`/api/v2/coremde-sale/project/type/template/batchUpdate`, args);
|
|
503
|
+
});
|
|
504
|
+
},
|
|
505
|
+
// 删除项目类型下的所有阶段
|
|
506
|
+
deleteAll: (projectTypeId) => {
|
|
507
|
+
return this.context.ready.then((axios) => {
|
|
508
|
+
return axios.get(`/api/v2/coremde-sale/project/type/template/deleteAll/${projectTypeId}`);
|
|
509
|
+
});
|
|
510
|
+
},
|
|
511
|
+
// 获取模板列表
|
|
512
|
+
list: (args) => {
|
|
513
|
+
return this.context.ready.then((axios) => {
|
|
514
|
+
return axios.post(`/api/v2/coremde-sale/project/stage/template/list`, args);
|
|
515
|
+
});
|
|
516
|
+
},
|
|
517
|
+
// 获取模板详情
|
|
518
|
+
get: (id) => {
|
|
519
|
+
return this.context.ready.then((axios) => {
|
|
520
|
+
return axios.get(`/api/v2/coremde-sale/project/stage/template/get/${id}`);
|
|
521
|
+
});
|
|
522
|
+
},
|
|
523
|
+
// 添加模板
|
|
524
|
+
add: (args) => {
|
|
525
|
+
return this.context.ready.then((axios) => {
|
|
526
|
+
return axios.post(`/api/v2/coremde-sale/project/stage/template/add`, args);
|
|
527
|
+
});
|
|
528
|
+
},
|
|
529
|
+
// 修改模板
|
|
530
|
+
update: (args) => {
|
|
531
|
+
return this.context.ready.then((axios) => {
|
|
532
|
+
return axios.post(`/api/v2/coremde-sale/project/stage/template/update`, args);
|
|
533
|
+
});
|
|
534
|
+
},
|
|
535
|
+
// 删除模板
|
|
536
|
+
delete: (id) => {
|
|
537
|
+
return this.context.ready.then((axios) => {
|
|
538
|
+
return axios.get(`/api/v2/coremde-sale/project/stage/template/delete/${id}`);
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
}
|
|
475
543
|
}
|
|
476
544
|
exports.ProjectGateway = ProjectGateway;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SparePartGateway = void 0;
|
|
4
|
+
class SparePartGateway extends Object {
|
|
5
|
+
constructor(context) {
|
|
6
|
+
super();
|
|
7
|
+
this.context = context;
|
|
8
|
+
}
|
|
9
|
+
get inventory() {
|
|
10
|
+
return {
|
|
11
|
+
list: async (args) => {
|
|
12
|
+
var axios = await this.context.ready;
|
|
13
|
+
return axios.get('/api/v3/spare-part/inventories', {
|
|
14
|
+
params: args,
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
detail: async (id) => {
|
|
18
|
+
var axios = await this.context.ready;
|
|
19
|
+
return axios.get(`/api/v3/spare-part/inventories/${id}`);
|
|
20
|
+
},
|
|
21
|
+
create: async (data) => {
|
|
22
|
+
var axios = await this.context.ready;
|
|
23
|
+
return axios.post('/api/v3/spare-part/inventories', data);
|
|
24
|
+
},
|
|
25
|
+
update: async (id, data) => {
|
|
26
|
+
var axios = await this.context.ready;
|
|
27
|
+
return axios.put(`/api/v3/spare-part/inventories/${id}`, data);
|
|
28
|
+
},
|
|
29
|
+
delete: async (id) => {
|
|
30
|
+
var axios = await this.context.ready;
|
|
31
|
+
return axios.delete(`/api/v3/spare-part/inventories/${id}`);
|
|
32
|
+
},
|
|
33
|
+
adjust: async (id, quantity) => {
|
|
34
|
+
var axios = await this.context.ready;
|
|
35
|
+
return axios.post(`/api/v3/spare-part/inventories/${id}/adjust`, { quantity });
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.SparePartGateway = SparePartGateway;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StageTemplateService = void 0;
|
|
4
|
+
class StageTemplateService {
|
|
5
|
+
constructor(context) {
|
|
6
|
+
this.context = context;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.StageTemplateService = StageTemplateService;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WarehouseGateway = void 0;
|
|
4
|
+
class WarehouseGateway extends Object {
|
|
5
|
+
constructor(context) {
|
|
6
|
+
super();
|
|
7
|
+
this.context = context;
|
|
8
|
+
}
|
|
9
|
+
async list() {
|
|
10
|
+
var axios = await this.context.ready;
|
|
11
|
+
return axios.get('/api/v3/warehouses');
|
|
12
|
+
}
|
|
13
|
+
async detail(code) {
|
|
14
|
+
var axios = await this.context.ready;
|
|
15
|
+
return axios.get(`/api/v3/warehouses/${code}`);
|
|
16
|
+
}
|
|
17
|
+
async create(data) {
|
|
18
|
+
var axios = await this.context.ready;
|
|
19
|
+
return axios.post('/api/v3/warehouses', data);
|
|
20
|
+
}
|
|
21
|
+
async update(code, data) {
|
|
22
|
+
var axios = await this.context.ready;
|
|
23
|
+
return axios.put(`/api/v3/warehouses/${code}`, data);
|
|
24
|
+
}
|
|
25
|
+
async toggleStatus(code) {
|
|
26
|
+
var axios = await this.context.ready;
|
|
27
|
+
return axios.put(`/api/v3/warehouses/${code}/toggle-status`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.WarehouseGateway = WarehouseGateway;
|
package/dist/web_platform.js
CHANGED
|
@@ -129,7 +129,8 @@ class WebPlatform {
|
|
|
129
129
|
delete: async (url, data, config) => {
|
|
130
130
|
const response = await this.fetchWithAuth(url, {
|
|
131
131
|
method: 'DELETE',
|
|
132
|
-
headers: config === null || config === void 0 ? void 0 : config.headers
|
|
132
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, config === null || config === void 0 ? void 0 : config.headers),
|
|
133
|
+
body: JSON.stringify(data)
|
|
133
134
|
});
|
|
134
135
|
return { data: await response.json() };
|
|
135
136
|
},
|
package/index.ts
CHANGED
|
@@ -28,6 +28,8 @@ import { MobilePlatform } from "./mobile_platform";
|
|
|
28
28
|
import { WebPlatform } from "./web_platform";
|
|
29
29
|
import { ProductionGateway } from "./production_gateway";
|
|
30
30
|
import { PurchaseGateway } from "./purchase_gateway";
|
|
31
|
+
import { WarehouseGateway } from "./warehouse_gateway";
|
|
32
|
+
import { SparePartGateway } from "./sparepart_gateway";
|
|
31
33
|
|
|
32
34
|
export class Cpzxrobot {
|
|
33
35
|
private static factorySelectorLoaded = false;
|
|
@@ -70,6 +72,8 @@ export class Cpzxrobot {
|
|
|
70
72
|
system: SystemGateway = new SystemGateway(this);
|
|
71
73
|
production: ProductionGateway = new ProductionGateway(this);
|
|
72
74
|
purchase!: PurchaseGateway;
|
|
75
|
+
warehouse!: WarehouseGateway;
|
|
76
|
+
sparepart!: SparePartGateway;
|
|
73
77
|
sseCallbacks: {
|
|
74
78
|
[key: string]: (data: any) => void;
|
|
75
79
|
} = {};
|
|
@@ -92,6 +96,8 @@ export class Cpzxrobot {
|
|
|
92
96
|
this.energy = new EnergyGateway(this);
|
|
93
97
|
this.camera = new CameraGateway(this);
|
|
94
98
|
this.purchase = new PurchaseGateway(this);
|
|
99
|
+
this.warehouse = new WarehouseGateway(this);
|
|
100
|
+
this.sparepart = new SparePartGateway(this);
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
exit() {
|
package/package.json
CHANGED
package/project_gateway.ts
CHANGED
|
@@ -567,7 +567,7 @@ export class ProjectGateway extends Object {
|
|
|
567
567
|
)
|
|
568
568
|
})
|
|
569
569
|
},
|
|
570
|
-
|
|
570
|
+
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
|
|
@@ -707,4 +707,108 @@ export class ProjectGateway extends Object {
|
|
|
707
707
|
},
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
|
+
|
|
711
|
+
get principal() {
|
|
712
|
+
return {
|
|
713
|
+
// 分配负责人
|
|
714
|
+
assign: (args: {id: number, principalId: number, principalName: string}) => {
|
|
715
|
+
return this.context.ready.then((axios) => {
|
|
716
|
+
return axios.post(
|
|
717
|
+
`/api/v2/coremde-sale/project/principal/assign`,
|
|
718
|
+
args
|
|
719
|
+
)
|
|
720
|
+
})
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
get stages() {
|
|
726
|
+
return {
|
|
727
|
+
// 根据项目类型获取配置的阶段
|
|
728
|
+
byType: (projectTypeId: number) => {
|
|
729
|
+
return this.context.ready.then((axios) => {
|
|
730
|
+
return axios.get(
|
|
731
|
+
`/api/v2/coremde-sale/project/type/template/${projectTypeId}`
|
|
732
|
+
)
|
|
733
|
+
})
|
|
734
|
+
},
|
|
735
|
+
|
|
736
|
+
// 批量新增阶段模板
|
|
737
|
+
addBatch: (args: any) => {
|
|
738
|
+
return this.context.ready.then((axios) => {
|
|
739
|
+
return axios.post(
|
|
740
|
+
`/api/v2/coremde-sale/project/type/template/batchAdd`,
|
|
741
|
+
args
|
|
742
|
+
)
|
|
743
|
+
})
|
|
744
|
+
},
|
|
745
|
+
|
|
746
|
+
// 批量更新阶段模板
|
|
747
|
+
updateBatch: (args: any) => {
|
|
748
|
+
return this.context.ready.then((axios) => {
|
|
749
|
+
return axios.post(
|
|
750
|
+
`/api/v2/coremde-sale/project/type/template/batchUpdate`,
|
|
751
|
+
args
|
|
752
|
+
)
|
|
753
|
+
})
|
|
754
|
+
},
|
|
755
|
+
|
|
756
|
+
// 删除项目类型下的所有阶段
|
|
757
|
+
deleteAll: (projectTypeId: number) => {
|
|
758
|
+
return this.context.ready.then((axios) => {
|
|
759
|
+
return axios.get(
|
|
760
|
+
`/api/v2/coremde-sale/project/type/template/deleteAll/${projectTypeId}`
|
|
761
|
+
)
|
|
762
|
+
})
|
|
763
|
+
},
|
|
764
|
+
|
|
765
|
+
// 获取模板列表
|
|
766
|
+
list: (args: { pageNo: number, pageSize: number, companyId: number }) => {
|
|
767
|
+
return this.context.ready.then((axios) => {
|
|
768
|
+
return axios.post(
|
|
769
|
+
`/api/v2/coremde-sale/project/stage/template/list`,
|
|
770
|
+
args
|
|
771
|
+
)
|
|
772
|
+
})
|
|
773
|
+
},
|
|
774
|
+
|
|
775
|
+
// 获取模板详情
|
|
776
|
+
get: (id: number) => {
|
|
777
|
+
return this.context.ready.then((axios) => {
|
|
778
|
+
return axios.get(
|
|
779
|
+
`/api/v2/coremde-sale/project/stage/template/get/${id}`
|
|
780
|
+
)
|
|
781
|
+
})
|
|
782
|
+
},
|
|
783
|
+
|
|
784
|
+
// 添加模板
|
|
785
|
+
add: (args: { templateName: string, companyId: number, remark?: string }) => {
|
|
786
|
+
return this.context.ready.then((axios) => {
|
|
787
|
+
return axios.post(
|
|
788
|
+
`/api/v2/coremde-sale/project/stage/template/add`,
|
|
789
|
+
args
|
|
790
|
+
)
|
|
791
|
+
})
|
|
792
|
+
},
|
|
793
|
+
|
|
794
|
+
// 修改模板
|
|
795
|
+
update: (args: { id: number, templateName: string, companyId: number, remark?: string }) => {
|
|
796
|
+
return this.context.ready.then((axios) => {
|
|
797
|
+
return axios.post(
|
|
798
|
+
`/api/v2/coremde-sale/project/stage/template/update`,
|
|
799
|
+
args
|
|
800
|
+
)
|
|
801
|
+
})
|
|
802
|
+
},
|
|
803
|
+
|
|
804
|
+
// 删除模板
|
|
805
|
+
delete: (id: number) => {
|
|
806
|
+
return this.context.ready.then((axios) => {
|
|
807
|
+
return axios.get(
|
|
808
|
+
`/api/v2/coremde-sale/project/stage/template/delete/${id}`
|
|
809
|
+
)
|
|
810
|
+
})
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
710
814
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Cpzxrobot } from "./types";
|
|
2
|
+
|
|
3
|
+
export class SparePartGateway extends Object {
|
|
4
|
+
context: Cpzxrobot;
|
|
5
|
+
|
|
6
|
+
constructor(context: Cpzxrobot) {
|
|
7
|
+
super();
|
|
8
|
+
this.context = context;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get inventory() {
|
|
12
|
+
return {
|
|
13
|
+
list: async (args: {
|
|
14
|
+
warehouseId?: string;
|
|
15
|
+
partId?: string;
|
|
16
|
+
}) => {
|
|
17
|
+
var axios = await this.context.ready;
|
|
18
|
+
return axios.get('/api/v3/spare-part/inventories',{
|
|
19
|
+
params: args,
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
detail: async (id: string) => {
|
|
23
|
+
var axios = await this.context.ready;
|
|
24
|
+
return axios.get(`/api/v3/spare-part/inventories/${id}`);
|
|
25
|
+
},
|
|
26
|
+
create: async (data: any) => {
|
|
27
|
+
var axios = await this.context.ready;
|
|
28
|
+
return axios.post('/api/v3/spare-part/inventories', data);
|
|
29
|
+
},
|
|
30
|
+
update: async (id: string, data: any) => {
|
|
31
|
+
var axios = await this.context.ready;
|
|
32
|
+
return axios.put(`/api/v3/spare-part/inventories/${id}`, data);
|
|
33
|
+
},
|
|
34
|
+
delete: async (id: string) => {
|
|
35
|
+
var axios = await this.context.ready;
|
|
36
|
+
return axios.delete(`/api/v3/spare-part/inventories/${id}`);
|
|
37
|
+
},
|
|
38
|
+
adjust: async (id: string, quantity: number) => {
|
|
39
|
+
var axios = await this.context.ready;
|
|
40
|
+
return axios.post(`/api/v3/spare-part/inventories/${id}/adjust`, { quantity });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
package/types.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { type ElectricMeterRate } from "./energy_types/electric_meter_gateway";
|
|
|
22
22
|
import { ConstructionGateway } from "./construction_gateway";
|
|
23
23
|
import { SystemGateway } from "./system_gateway";
|
|
24
24
|
import { PlatformInterface } from "./platform_interface";
|
|
25
|
+
import { WarehouseGateway } from "./warehouse_gateway";
|
|
25
26
|
|
|
26
27
|
type Device = {
|
|
27
28
|
id: number;
|
|
@@ -311,6 +312,19 @@ interface MyAxiosInstance {
|
|
|
311
312
|
delete: (url: string, data?: any, config?: any) => Promise<any>;
|
|
312
313
|
}
|
|
313
314
|
|
|
315
|
+
interface Supplier {
|
|
316
|
+
id?: number;
|
|
317
|
+
type?: string; // supplier/customer/outsourcing
|
|
318
|
+
code?: string;
|
|
319
|
+
name: string;
|
|
320
|
+
contact?: string;
|
|
321
|
+
phone?: string;
|
|
322
|
+
address?: string;
|
|
323
|
+
remark?: string;
|
|
324
|
+
createdAt?: Date;
|
|
325
|
+
updatedAt?: Date;
|
|
326
|
+
}
|
|
327
|
+
|
|
314
328
|
interface Assistant {
|
|
315
329
|
info: String;
|
|
316
330
|
status: Number;
|
|
@@ -369,7 +383,7 @@ interface DataQueryArgs {
|
|
|
369
383
|
| "max"
|
|
370
384
|
| "raw"
|
|
371
385
|
| "difference";
|
|
372
|
-
period?: "1mo" | "1d" | "1h" | null; // 统计周期,默认为1d
|
|
386
|
+
period?: "1mo" | "1d" | "1h" | "30m" | "5m" | null; // 统计周期,默认为1d
|
|
373
387
|
offset?: string; // 可以设置统计偏移量,比如设置18h, 则统计从当天晚上6点开始
|
|
374
388
|
[key: string]: any;
|
|
375
389
|
aggerate?: string;
|
|
@@ -404,6 +418,8 @@ class Cpzxrobot {
|
|
|
404
418
|
platform: PlatformInterface;
|
|
405
419
|
production: ProductionGateway;
|
|
406
420
|
purchase: PurchaseGateway;
|
|
421
|
+
warehouse: WarehouseGateway;
|
|
422
|
+
sparepart: SparePartGateway;
|
|
407
423
|
// _getSelectedFarmFromMiniApp: () => Promise<Factory>;
|
|
408
424
|
// _getSelectedUnitFromMiniApp: () => Promise<Unit>;
|
|
409
425
|
openMiniApp: (url: string) => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Cpzxrobot } from "./types";
|
|
2
|
+
|
|
3
|
+
export class WarehouseGateway extends Object {
|
|
4
|
+
context: Cpzxrobot;
|
|
5
|
+
|
|
6
|
+
constructor(context: Cpzxrobot) {
|
|
7
|
+
super();
|
|
8
|
+
this.context = context;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async list() {
|
|
12
|
+
var axios = await this.context.ready;
|
|
13
|
+
return axios.get('/api/v3/warehouses');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async detail(code: string) {
|
|
17
|
+
var axios = await this.context.ready;
|
|
18
|
+
return axios.get(`/api/v3/warehouses/${code}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async create(data: any) {
|
|
22
|
+
var axios = await this.context.ready;
|
|
23
|
+
return axios.post('/api/v3/warehouses', data);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async update(code: string, data: any) {
|
|
27
|
+
var axios = await this.context.ready;
|
|
28
|
+
return axios.put(`/api/v3/warehouses/${code}`, data);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async toggleStatus(code: string) {
|
|
32
|
+
var axios = await this.context.ready;
|
|
33
|
+
return axios.put(`/api/v3/warehouses/${code}/toggle-status`);
|
|
34
|
+
}
|
|
35
|
+
}
|
package/web_platform.ts
CHANGED
|
@@ -135,7 +135,11 @@ export class WebPlatform implements PlatformInterface {
|
|
|
135
135
|
delete: async (url: string, data?: any, config?: any) => {
|
|
136
136
|
const response = await this.fetchWithAuth(url, {
|
|
137
137
|
method: 'DELETE',
|
|
138
|
-
headers:
|
|
138
|
+
headers: {
|
|
139
|
+
'Content-Type': 'application/json',
|
|
140
|
+
...config?.headers
|
|
141
|
+
},
|
|
142
|
+
body: JSON.stringify(data)
|
|
139
143
|
});
|
|
140
144
|
return { data: await response.json() };
|
|
141
145
|
},
|