@cpzxrobot/sdk 1.1.68 → 1.1.70

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.
@@ -41,13 +41,9 @@ export class ContractGateway extends Object {
41
41
  });
42
42
  }
43
43
 
44
- approval(contractId: number, agree: 1 | 0, audit_info: string) {
44
+ approval(args:any) {
45
45
  return this.context.ready.then((axios) => {
46
- return axios.post(`/api/v2/coremde-sale/contract/approve`, {
47
- contractId,
48
- agree,
49
- audit_info,
50
- });
46
+ return axios.post(`/api/v2/coremde-sale/contract/approve`, args);
51
47
  });
52
48
  }
53
49
 
@@ -30,13 +30,9 @@ class ContractGateway extends Object {
30
30
  }, filename);
31
31
  });
32
32
  }
33
- approval(contractId, agree, audit_info) {
33
+ approval(args) {
34
34
  return this.context.ready.then((axios) => {
35
- return axios.post(`/api/v2/coremde-sale/contract/approve`, {
36
- contractId,
37
- agree,
38
- audit_info,
39
- });
35
+ return axios.post(`/api/v2/coremde-sale/contract/approve`, args);
40
36
  });
41
37
  }
42
38
  }
@@ -136,5 +136,12 @@ class FactoryGateway extends Object {
136
136
  },
137
137
  };
138
138
  }
139
+ get batch() {
140
+ return {
141
+ list: (factory) => {
142
+ return this.context.axios.get(`/api/v2/batch/factory/${factory.id}`);
143
+ }
144
+ };
145
+ }
139
146
  }
140
147
  exports.FactoryGateway = FactoryGateway;
package/dist/index.js CHANGED
@@ -90,6 +90,31 @@ class Cpzxrobot {
90
90
  // @ts-ignore
91
91
  instance.getAndPreview = instance.getAndSave;
92
92
  // @ts-ignore
93
+ instance.upload = (url, option) => {
94
+ //add a file button to the body
95
+ var button = document.createElement("input");
96
+ button.type = "file";
97
+ button.style.display = "none";
98
+ document.body.appendChild(button);
99
+ button.onchange = (e) => {
100
+ var _a;
101
+ var file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
102
+ if (file) {
103
+ const formData = new FormData();
104
+ formData.append((option === null || option === void 0 ? void 0 : option["fileField"]) || "file", file);
105
+ for (let key in option === null || option === void 0 ? void 0 : option["data"]) {
106
+ formData.append(key, option["data"][key]);
107
+ }
108
+ instance.post(url, formData).then((res) => {
109
+ button.remove();
110
+ });
111
+ }
112
+ else {
113
+ button.remove();
114
+ }
115
+ };
116
+ };
117
+ // @ts-ignore
93
118
  this.axios = instance;
94
119
  }
95
120
  }
@@ -185,7 +210,10 @@ class Cpzxrobot {
185
210
  preview: true,
186
211
  fileName: fileName || "file",
187
212
  });
188
- }
213
+ },
214
+ upload: function (url, option) {
215
+ return platform.callHandler("axios_upload", url, option);
216
+ },
189
217
  };
190
218
  if (
191
219
  // @ts-ignore
@@ -58,6 +58,23 @@ class ProductGateway extends Object {
58
58
  return axios.post(`/api/v2/coremde-sale/product/price/add`, args);
59
59
  });
60
60
  },
61
+ delete: (id) => {
62
+ return this.context.ready.then((axios) => {
63
+ return axios.post(`/api/v2/coremde-sale/product/price/delete`, { id });
64
+ });
65
+ },
66
+ history: {
67
+ list: (args) => {
68
+ return this.context.ready.then((axios) => {
69
+ return axios.post(`/api/v2/coremde-sale/product/price/history/list`, args);
70
+ });
71
+ },
72
+ get: (id) => {
73
+ return this.context.ready.then((axios) => {
74
+ return axios.get(`/api/v2/coremde-sale/product/price/history/get?id=${id}`);
75
+ });
76
+ },
77
+ },
61
78
  };
62
79
  }
63
80
  }
@@ -36,6 +36,25 @@ class ProjectGateway extends Object {
36
36
  return this.context.ready.then((axios) => {
37
37
  return axios.post(`/api/v2/coremde-sale/project/feedback/reply`, args);
38
38
  });
39
+ },
40
+ media: {
41
+ add: () => {
42
+ return this.context.ready.then((axios) => {
43
+ return axios.upload(`/api/v2/coremde-sale/project/feedback/media/upload`, {
44
+ title: "请选择上传文件"
45
+ });
46
+ });
47
+ },
48
+ cancel: (id) => {
49
+ return this.context.ready.then((axios) => {
50
+ return axios.get(`/api/v2/coremde-sale/project/feedback/media/cancel?id=${id}`);
51
+ });
52
+ },
53
+ download: (id) => {
54
+ return this.context.ready.then((axios) => {
55
+ return axios.getAndPreview(`/api/v2/coremde-sale/project/feedback/media/download?id=${id}`);
56
+ });
57
+ }
39
58
  }
40
59
  };
41
60
  }
@@ -237,6 +237,16 @@ class UserGateway extends Object {
237
237
  return this.context.ready.then((axios) => {
238
238
  return axios.post(`/api/v2/coremde-sale/user/work-report/add`, report);
239
239
  });
240
+ },
241
+ update: (report) => {
242
+ return this.context.ready.then((axios) => {
243
+ return axios.post(`/api/v2/coremde-sale/user/work-report/update`, report);
244
+ });
245
+ },
246
+ delete: (id) => {
247
+ return this.context.ready.then((axios) => {
248
+ return axios.get(`/api/v2/coremde-sale/user/work-report/delete?id=${id}`);
249
+ });
240
250
  }
241
251
  };
242
252
  }
@@ -170,4 +170,12 @@ export class FactoryGateway extends Object {
170
170
  },
171
171
  };
172
172
  }
173
+
174
+ get batch(){
175
+ return {
176
+ list: (factory: Factory) => {
177
+ return this.context.axios.get(`/api/v2/batch/factory/${factory.id}`);
178
+ }
179
+ }
180
+ }
173
181
  }
package/index.ts CHANGED
@@ -124,6 +124,31 @@ export class Cpzxrobot {
124
124
  // @ts-ignore
125
125
  instance.getAndPreview = instance.getAndSave;
126
126
  // @ts-ignore
127
+ instance.upload = (url: string, option?: {
128
+ [key: string]: any;
129
+ }) => {
130
+ //add a file button to the body
131
+ var button = document.createElement("input");
132
+ button.type = "file";
133
+ button.style.display = "none";
134
+ document.body.appendChild(button);
135
+ button.onchange = (e: Event) => {
136
+ var file = (e.target as HTMLInputElement).files?.[0];
137
+ if (file) {
138
+ const formData = new FormData();
139
+ formData.append(option?.["fileField"] || "file", file);
140
+ for (let key in option?.["data"]) {
141
+ formData.append(key, option!["data"][key]);
142
+ }
143
+ instance.post(url, formData).then((res) => {
144
+ button.remove();
145
+ });
146
+ } else {
147
+ button.remove();
148
+ }
149
+ };
150
+ }
151
+ // @ts-ignore
127
152
  this.axios = instance;
128
153
  }
129
154
  }
@@ -224,7 +249,10 @@ export class Cpzxrobot {
224
249
  preview: true,
225
250
  fileName: fileName || "file",
226
251
  });
227
- }
252
+ },
253
+ upload: function (url, option) {
254
+ return platform.callHandler("axios_upload", url, option);
255
+ },
228
256
  };
229
257
  if (
230
258
  // @ts-ignore
package/news_gateway.ts CHANGED
@@ -47,7 +47,6 @@ export class NewsGateway extends Object {
47
47
  }) =>{
48
48
  return this.context.ready.then(axios => {
49
49
  return axios.get("/api/v2/coremde-sale/alarm/list", { params: args });
50
-
51
50
  });
52
51
  }
53
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.1.68",
3
+ "version": "1.1.70",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -95,6 +95,32 @@ export class ProductGateway extends Object {
95
95
  return axios.post(`/api/v2/coremde-sale/product/price/add`, args);
96
96
  });
97
97
  },
98
+ delete: (id: number) => {
99
+ return this.context.ready.then((axios) => {
100
+ return axios.post(`/api/v2/coremde-sale/product/price/delete`, { id });
101
+ });
102
+ },
103
+ history: {
104
+ list: (args: {
105
+ pageNo: number;
106
+ pageSize: number;
107
+ product_id: number;
108
+ }) => {
109
+ return this.context.ready.then((axios) => {
110
+ return axios.post(
111
+ `/api/v2/coremde-sale/product/price/history/list`,
112
+ args,
113
+ );
114
+ });
115
+ },
116
+ get: (id: number) => {
117
+ return this.context.ready.then((axios) => {
118
+ return axios.get(
119
+ `/api/v2/coremde-sale/product/price/history/get?id=${id}`,
120
+ );
121
+ });
122
+ },
123
+ },
98
124
  };
99
125
  }
100
126
  }
@@ -52,10 +52,31 @@ export class ProjectGateway extends Object {
52
52
  id: number;
53
53
  status: number;
54
54
  reply: string;
55
+ companyId: number;
56
+ medias: any[];
55
57
  }) => {
56
58
  return this.context.ready.then((axios) => {
57
59
  return axios.post(`/api/v2/coremde-sale/project/feedback/reply`, args);
58
60
  });
61
+ },
62
+ media: {
63
+ add: () => {
64
+ return this.context.ready.then((axios) => {
65
+ return axios.upload(`/api/v2/coremde-sale/project/feedback/media/upload`,{
66
+ title: "请选择上传文件"
67
+ });
68
+ });
69
+ },
70
+ cancel: (id: number) => {
71
+ return this.context.ready.then((axios) => {
72
+ return axios.get(`/api/v2/coremde-sale/project/feedback/media/cancel?id=${id}`);
73
+ });
74
+ },
75
+ download: (id: number) => {
76
+ return this.context.ready.then((axios) => {
77
+ return axios.getAndPreview(`/api/v2/coremde-sale/project/feedback/media/download?id=${id}`);
78
+ });
79
+ }
59
80
  }
60
81
  };
61
82
  }
package/readme.md CHANGED
@@ -99,6 +99,7 @@ baseURL: "/"
99
99
  | cpzxrobot().factory.workshop.get | 获得工厂的某个车间信息 |
100
100
  | cpzxrobot().factory.workshop.post | 添加车间信息 |
101
101
  | cpzxrobot().factory.workshop.types | 获得车间的类型列表 |
102
+ | cpzxrobot().factory.batch.list | 获得批次列表,传入factoryId参数 |
102
103
  | cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
103
104
  | cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
104
105
  | cpzxrobot().pigfarm.weightMeter.config.list | 获取称重计的配置信息 |
@@ -162,6 +163,8 @@ baseURL: "/"
162
163
  | cpzxrobot().user.workReport.list | 列出用户的日报记录 |
163
164
  | cpzxrobot().user.workReport.get | 获取用户的日报记录 |
164
165
  | cpzxrobot().user.workReport.add | 添加用户的日报记录 |
166
+ | cpzxrobot().user.workReport.delete | 删除用户的日报记录,传入id参数 |
167
+ | cpzxrobot().user.workReport.update | 更新用户的日报记录,传入id参数和更新的内容 |
165
168
  | cpzxrobot().user.position.leader | 获取当前用户的领导信息 |
166
169
  | cpzxrobot().user.position.team | 获取当前用户的下属团队信息, 可输入searchName进行模糊搜索 |
167
170
  | cpzxrobot().user.position.colleague | 获取当前用户的同组团队信息 |
@@ -171,6 +174,9 @@ baseURL: "/"
171
174
  | cpzxrobot().product.price.list | 获得产品报价列表 |
172
175
  | cpzxrobot().product.price.get | 获得产品报价信息,传入id参数 |
173
176
  | cpzxrobot().product.price.add | 添加产品报价信息 |
177
+ | cpzxrobot().product.price.delete | 删除产品报价信息,传入id参数 |
178
+ | cpzxrobot().product.price.history.list | 获得产品报价历史信息 |
179
+ | cpzxrobot().product.price.history.get | 获得产品报价历史信息,传入id参数 |
174
180
  | cpzxrobot().project.list | 获得项目列表,传入factory_id和必要的分页参数 |
175
181
  | cpzxrobot().project.feedback.list | 获得项目反馈列表,传入project_id参数 |
176
182
  | cpzxrobot().project.feedback.add | 添加项目反馈信息,传入project_id和反馈内容 |
package/types.d.ts CHANGED
@@ -270,6 +270,14 @@ interface MyAxiosInstance {
270
270
  post: (url: string, data?: any, config?: any) => Promise<any>;
271
271
  getAndSave: (url: string, data?: any, fileName?: string) => Promise<any>;
272
272
  getAndPreview: (url: string, data?: any, fileName?: string) => Promise<any>;
273
+ //调用系统文件选择器,上传文件
274
+ //url:上传的url
275
+ //option:上传的配置项,比如文件名等
276
+ //支持的配置项:
277
+ //option.title:上传文件选择框的标题
278
+ //option.fileField:上传的文件字段名,默认为file
279
+ //option.data:上传的数据,例如{id:123,name:"xxx"},文件会被附加到data中,作为文件字段上传
280
+ upload: (url: string,option?: {}) => Promise<any>;
273
281
  }
274
282
 
275
283
  interface Assistant {
package/user_gateway.ts CHANGED
@@ -262,6 +262,16 @@ export class UserGateway extends Object {
262
262
  return this.context.ready.then((axios) => {
263
263
  return axios.post(`/api/v2/coremde-sale/user/work-report/add`, report);
264
264
  });
265
+ },
266
+ update: (report: any) => {
267
+ return this.context.ready.then((axios) => {
268
+ return axios.post(`/api/v2/coremde-sale/user/work-report/update`, report);
269
+ });
270
+ },
271
+ delete: (id: number) => {
272
+ return this.context.ready.then((axios) => {
273
+ return axios.get(`/api/v2/coremde-sale/user/work-report/delete?id=${id}`);
274
+ });
265
275
  }
266
276
  };
267
277
  }