@cpzxrobot/sdk 1.1.37 → 1.1.39
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/device_filter.ts +6 -0
- package/dist/device_filter.js +5 -0
- package/dist/index.js +15 -1
- package/dist/product_gateway.js +1 -1
- package/index.ts +33 -19
- package/package.json +1 -1
- package/product_gateway.ts +1 -1
- package/readme.md +6 -3
- package/types.d.ts +1 -0
package/device_filter.ts
CHANGED
|
@@ -31,6 +31,12 @@ export abstract class DeviceFilter<T extends { id: number }> {
|
|
|
31
31
|
return Promise.resolve(list);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
add(device: any) {
|
|
35
|
+
this.context.ready.then(axios=>{
|
|
36
|
+
return axios.post("/api/v2/device/add", device)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
getInfo(id: number): Promise<T> {
|
|
35
41
|
if (this.devices) {
|
|
36
42
|
const one = this.devices.find((device) => device.id == id);
|
package/dist/device_filter.js
CHANGED
|
@@ -22,6 +22,11 @@ class DeviceFilter {
|
|
|
22
22
|
wrapList(list) {
|
|
23
23
|
return Promise.resolve(list);
|
|
24
24
|
}
|
|
25
|
+
add(device) {
|
|
26
|
+
this.context.ready.then(axios => {
|
|
27
|
+
return axios.post("/api/v2/device/add", device);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
25
30
|
getInfo(id) {
|
|
26
31
|
if (this.devices) {
|
|
27
32
|
const one = this.devices.find((device) => device.id == id);
|
package/dist/index.js
CHANGED
|
@@ -68,7 +68,7 @@ class Cpzxrobot {
|
|
|
68
68
|
}
|
|
69
69
|
initAxios(baseURL) {
|
|
70
70
|
if (this.mode !== "miniapp_in_app") {
|
|
71
|
-
|
|
71
|
+
var instance = axios_1.default.create({
|
|
72
72
|
baseURL,
|
|
73
73
|
});
|
|
74
74
|
instance.interceptors.request.use((config) => {
|
|
@@ -80,6 +80,16 @@ class Cpzxrobot {
|
|
|
80
80
|
// 对请求错误做些什么
|
|
81
81
|
return Promise.reject(error);
|
|
82
82
|
});
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
instance.getAndSave = (url, data, fileName) => {
|
|
85
|
+
return instance.get(url, {
|
|
86
|
+
responseType: "blob",
|
|
87
|
+
params: data,
|
|
88
|
+
}).then((res) => {
|
|
89
|
+
this.saveBlob(res.data, fileName || "file");
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
// @ts-ignore
|
|
83
93
|
this.axios = instance;
|
|
84
94
|
}
|
|
85
95
|
}
|
|
@@ -155,6 +165,10 @@ class Cpzxrobot {
|
|
|
155
165
|
console.log(url, data);
|
|
156
166
|
return platform.callHandler("axios_post", url, data);
|
|
157
167
|
},
|
|
168
|
+
getAndSave: function (url, data, fileName) {
|
|
169
|
+
console.log(url, data);
|
|
170
|
+
return platform.callHandler("axios_getAndSave", url, data);
|
|
171
|
+
}
|
|
158
172
|
};
|
|
159
173
|
if (
|
|
160
174
|
// @ts-ignore
|
package/dist/product_gateway.js
CHANGED
|
@@ -31,7 +31,7 @@ class ProductGateway extends Object {
|
|
|
31
31
|
//下载报价单
|
|
32
32
|
export: (args) => {
|
|
33
33
|
return this.context.ready.then((axios) => {
|
|
34
|
-
return axios.
|
|
34
|
+
return axios.getAndSave(`/api/v2/coremde-sale/product/price/export`, args, "报价单.xlsx");
|
|
35
35
|
});
|
|
36
36
|
},
|
|
37
37
|
add: (args) => {
|
package/index.ts
CHANGED
|
@@ -44,7 +44,7 @@ export class Cpzxrobot {
|
|
|
44
44
|
setTitle!: (title: string) => void;
|
|
45
45
|
saveBase64!: (base64: string, filename: string) => void;
|
|
46
46
|
saveBlob!: (blob: Blob, filename: string) => void;
|
|
47
|
-
scanQrcode!:() => Promise<string>;
|
|
47
|
+
scanQrcode!: () => Promise<string>;
|
|
48
48
|
vibrate!: (time?: number) => void;
|
|
49
49
|
assistant: AssistantGateway;
|
|
50
50
|
energy: EnergyGateway;
|
|
@@ -91,9 +91,9 @@ export class Cpzxrobot {
|
|
|
91
91
|
|
|
92
92
|
initAxios(baseURL: string) {
|
|
93
93
|
if (this.mode !== "miniapp_in_app") {
|
|
94
|
-
|
|
94
|
+
var instance = axios.create({
|
|
95
95
|
baseURL,
|
|
96
|
-
})
|
|
96
|
+
})
|
|
97
97
|
instance.interceptors.request.use(
|
|
98
98
|
(config) => {
|
|
99
99
|
// 在发送请求之前在头部添加token
|
|
@@ -107,6 +107,16 @@ export class Cpzxrobot {
|
|
|
107
107
|
return Promise.reject(error);
|
|
108
108
|
}
|
|
109
109
|
);
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
instance.getAndSave = (url: string, data?: any, fileName?: string) => {
|
|
112
|
+
return instance.get(url, {
|
|
113
|
+
responseType: "blob",
|
|
114
|
+
params: data,
|
|
115
|
+
}).then((res) => {
|
|
116
|
+
this.saveBlob(res.data, fileName || "file");
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
// @ts-ignore
|
|
110
120
|
this.axios = instance;
|
|
111
121
|
}
|
|
112
122
|
}
|
|
@@ -165,7 +175,7 @@ export class Cpzxrobot {
|
|
|
165
175
|
this._jumpToMiniApp = function (url: string) {
|
|
166
176
|
return platform.callHandler("app.openMiniapp", url);
|
|
167
177
|
};
|
|
168
|
-
this.scanQrcode = function(){
|
|
178
|
+
this.scanQrcode = function () {
|
|
169
179
|
return platform.callHandler("app.scanQrcode");
|
|
170
180
|
}
|
|
171
181
|
this.setTitle = function (title: string) {
|
|
@@ -187,6 +197,10 @@ export class Cpzxrobot {
|
|
|
187
197
|
console.log(url, data);
|
|
188
198
|
return platform.callHandler("axios_post", url, data);
|
|
189
199
|
},
|
|
200
|
+
getAndSave: function (url, data, fileName) {
|
|
201
|
+
console.log(url, data);
|
|
202
|
+
return platform.callHandler("axios_getAndSave", url, data);
|
|
203
|
+
}
|
|
190
204
|
};
|
|
191
205
|
if (
|
|
192
206
|
// @ts-ignore
|
|
@@ -334,7 +348,7 @@ export class Cpzxrobot {
|
|
|
334
348
|
this.resolveReady(this.axios);
|
|
335
349
|
});
|
|
336
350
|
return;
|
|
337
|
-
}else{
|
|
351
|
+
} else {
|
|
338
352
|
//jump to miniapp login page
|
|
339
353
|
window.location.href = "/login.html";
|
|
340
354
|
}
|
|
@@ -382,20 +396,20 @@ export default function (
|
|
|
382
396
|
selectedFarm: Factory;
|
|
383
397
|
selectedUnit: Unit;
|
|
384
398
|
} = {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
+
devAuth: "",
|
|
400
|
+
appCode: "",
|
|
401
|
+
baseURL: "https://www.cpzxrobot.com/",
|
|
402
|
+
selectedFarm: {
|
|
403
|
+
id: 0,
|
|
404
|
+
code: "",
|
|
405
|
+
name: "",
|
|
406
|
+
company_code: "",
|
|
407
|
+
},
|
|
408
|
+
selectedUnit: {
|
|
409
|
+
id: 0,
|
|
410
|
+
name: "",
|
|
411
|
+
},
|
|
412
|
+
}
|
|
399
413
|
): Cpzxrobot {
|
|
400
414
|
if (!_instance) {
|
|
401
415
|
_instance = new Cpzxrobot(args.appCode);
|
package/package.json
CHANGED
package/product_gateway.ts
CHANGED
|
@@ -50,7 +50,7 @@ export class ProductGateway extends Object {
|
|
|
50
50
|
pageSize: number;
|
|
51
51
|
}) => {
|
|
52
52
|
return this.context.ready.then((axios) => {
|
|
53
|
-
return axios.
|
|
53
|
+
return axios.getAndSave(`/api/v2/coremde-sale/product/price/export`, args, "报价单.xlsx");
|
|
54
54
|
});
|
|
55
55
|
},
|
|
56
56
|
add: (args: {
|
package/readme.md
CHANGED
|
@@ -152,6 +152,9 @@ baseURL: "/"
|
|
|
152
152
|
| cpzxrobot().user.stat.china | 获得员工在全国的统计信息 |
|
|
153
153
|
| cpzxrobot().user.listByProvince | 获得员工在某个省的统计信息,传入province参数 |
|
|
154
154
|
| cpzxrobot().user.listByCity | 获得员工在某个市的统计信息,传入city参数 |
|
|
155
|
+
| cpzxrobot().user.workReport.list | 列出用户的日报记录 |
|
|
156
|
+
| cpzxrobot().user.workReport.get | 获取用户的日报记录 |
|
|
157
|
+
| cpzxrobot().user.workReport.add | 添加用户的日报记录 |
|
|
155
158
|
| cpzxrobot().product.list | 获得产品列表,传入factory_id和必要的分页参数 |
|
|
156
159
|
| cpzxrobot().product.get | 获得产品信息,传入id参数 |
|
|
157
160
|
| cpzxrobot().product.price.list | 获得产品报价列表 |
|
|
@@ -190,9 +193,9 @@ baseURL: "/"
|
|
|
190
193
|
| cpzxrobot().company.cost.byYear | 按公司按年成本 |
|
|
191
194
|
| cpzxrobot().company.revenue.groupSummary.byMonth | 按公司按类别按月营收统计 |
|
|
192
195
|
| cpzxrobot().company.revenue.groupSummary.byYear | 按公司按类别按年营收统计 |
|
|
193
|
-
| cpzxrobot().company.revenue.
|
|
194
|
-
| cpzxrobot().company.revenue.
|
|
195
|
-
| cpzxrobot().company.revenue.
|
|
196
|
+
| cpzxrobot().company.revenue.recentSummary.byMonth | 按公司当月营收统计 |
|
|
197
|
+
| cpzxrobot().company.revenue.recentSummary.byDay | 按公司当日营收统计 |
|
|
198
|
+
| cpzxrobot().company.revenue.recentSummary.byDecade | 按公司按旬营收统计 |
|
|
196
199
|
| cpzxrobot().company.revenue.list | 获得公司营收列表,传入必要的分页参数 |
|
|
197
200
|
| cpzxrobot().company.revenue.enterprise | 获得集团整体营收统计 |
|
|
198
201
|
| cpzxrobot().car.stat.china | 获得车辆在全国的统计信息 |
|
package/types.d.ts
CHANGED
|
@@ -268,6 +268,7 @@ type FeedTower = {
|
|
|
268
268
|
interface MyAxiosInstance {
|
|
269
269
|
get: (url: string, config?: any) => Promise<any>;
|
|
270
270
|
post: (url: string, data?: any, config?: any) => Promise<any>;
|
|
271
|
+
getAndSave: (url: string, data?: any, fileName?: string) => Promise<any>;
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
interface Assistant {
|