@cpzxrobot/sdk 1.1.63 → 1.1.64
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/dist/index.js +11 -4
- package/dist/unit_gateway.js +21 -0
- package/index.ts +31 -24
- package/package.json +1 -1
- package/project_gateway.ts +0 -1
- package/readme.md +2 -0
- package/types.d.ts +1 -0
- package/unit_gateway.ts +26 -0
package/dist/index.js
CHANGED
|
@@ -88,6 +88,8 @@ class Cpzxrobot {
|
|
|
88
88
|
});
|
|
89
89
|
};
|
|
90
90
|
// @ts-ignore
|
|
91
|
+
instance.getAndPreview = instance.getAndSave;
|
|
92
|
+
// @ts-ignore
|
|
91
93
|
this.axios = instance;
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -168,16 +170,21 @@ class Cpzxrobot {
|
|
|
168
170
|
};
|
|
169
171
|
this.axios = {
|
|
170
172
|
get: function (url, data) {
|
|
171
|
-
console.log(url, data);
|
|
172
173
|
return platform.callHandler("axios_get", url, data);
|
|
173
174
|
},
|
|
174
175
|
post: function (url, data) {
|
|
175
|
-
console.log(url, data);
|
|
176
176
|
return platform.callHandler("axios_post", url, data);
|
|
177
177
|
},
|
|
178
178
|
getAndSave: function (url, data, fileName) {
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
return platform.callHandler("axios_getAndSave", url, data, {
|
|
180
|
+
fileName: fileName || "file",
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
getAndPreview: function (url, data, fileName) {
|
|
184
|
+
return platform.callHandler("axios_getAndSave", url, data, {
|
|
185
|
+
preview: true,
|
|
186
|
+
fileName: fileName || "file",
|
|
187
|
+
});
|
|
181
188
|
}
|
|
182
189
|
};
|
|
183
190
|
if (
|
package/dist/unit_gateway.js
CHANGED
|
@@ -82,6 +82,27 @@ class UnitGateway extends Object {
|
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
+
//批次管理
|
|
86
|
+
get batch() {
|
|
87
|
+
return {
|
|
88
|
+
bind: (unitDayage, batchNo, type) => {
|
|
89
|
+
return this.context.ready.then((axios) => {
|
|
90
|
+
return axios.post(`/api/v2/batch/unit/bind`, {
|
|
91
|
+
batchNo,
|
|
92
|
+
unitDayage,
|
|
93
|
+
type,
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
clear: (unitIds) => {
|
|
98
|
+
return this.context.ready.then((axios) => {
|
|
99
|
+
return axios.post(`/api/v2/batch/unit/empty`, {
|
|
100
|
+
unitIds
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
85
106
|
v2() {
|
|
86
107
|
return {
|
|
87
108
|
//新增时必传factoryId, 当上层是workshop时,需要传workshopId
|
package/index.ts
CHANGED
|
@@ -122,6 +122,8 @@ export class Cpzxrobot {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
// @ts-ignore
|
|
125
|
+
instance.getAndPreview = instance.getAndSave;
|
|
126
|
+
// @ts-ignore
|
|
125
127
|
this.axios = instance;
|
|
126
128
|
}
|
|
127
129
|
}
|
|
@@ -207,16 +209,21 @@ export class Cpzxrobot {
|
|
|
207
209
|
};
|
|
208
210
|
this.axios = {
|
|
209
211
|
get: function (url, data) {
|
|
210
|
-
console.log(url, data);
|
|
211
212
|
return platform.callHandler("axios_get", url, data);
|
|
212
213
|
},
|
|
213
214
|
post: function (url, data) {
|
|
214
|
-
console.log(url, data);
|
|
215
215
|
return platform.callHandler("axios_post", url, data);
|
|
216
216
|
},
|
|
217
217
|
getAndSave: function (url, data, fileName) {
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
return platform.callHandler("axios_getAndSave", url, data, {
|
|
219
|
+
fileName: fileName || "file",
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
getAndPreview: function (url, data, fileName) {
|
|
223
|
+
return platform.callHandler("axios_getAndSave", url, data, {
|
|
224
|
+
preview: true,
|
|
225
|
+
fileName: fileName || "file",
|
|
226
|
+
});
|
|
220
227
|
}
|
|
221
228
|
};
|
|
222
229
|
if (
|
|
@@ -277,27 +284,27 @@ export class Cpzxrobot {
|
|
|
277
284
|
};
|
|
278
285
|
this.getGeo = async function () {
|
|
279
286
|
return new Promise((resolve, reject) => {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
287
|
+
if (navigator.geolocation) {
|
|
288
|
+
navigator.geolocation.getCurrentPosition(
|
|
289
|
+
(position) => {
|
|
290
|
+
const lat = position.coords.latitude; // 获取纬度
|
|
291
|
+
const lng = position.coords.longitude; // 获取经度
|
|
292
|
+
// 完成位置获取,解析 Promise
|
|
293
|
+
resolve({ lat, lng });
|
|
294
|
+
},
|
|
295
|
+
(error) => {
|
|
296
|
+
console.log("获取位置信息失败:" + error.message);
|
|
297
|
+
// 位置获取失败,拒绝 Promise
|
|
298
|
+
reject(error);
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
} else {
|
|
302
|
+
console.log("浏览器不支持获取位置信息");
|
|
303
|
+
// 浏览器不支持位置服务,拒绝 Promise
|
|
304
|
+
reject(new Error("浏览器不支持获取位置信息"));
|
|
305
|
+
}
|
|
299
306
|
});
|
|
300
|
-
|
|
307
|
+
};
|
|
301
308
|
}
|
|
302
309
|
}
|
|
303
310
|
isIosMiniApp(location: Location): boolean {
|
package/package.json
CHANGED
package/project_gateway.ts
CHANGED
package/readme.md
CHANGED
|
@@ -140,6 +140,8 @@ baseURL: "/"
|
|
|
140
140
|
| cpzxrobot().unit.thresholdConfig.get | 获取单元的阈值配置信息 |
|
|
141
141
|
| cpzxrobot().unit.thresholdConfig.bind | 设置单元的阈值配置信息 |
|
|
142
142
|
| cpzxrobot().unit.thresholdConfig.delete | 删除单元的阈值配置信息,传入get获取的条目的具体id或对象本身 |
|
|
143
|
+
| cpzxrobot().unit.batch.bind | 绑定单元和生产批次关系 |
|
|
144
|
+
| cpzxrobot().unit.batch.clear | 清除单元绑定的生产批次 |
|
|
143
145
|
| cpzxrobot().user.add | 添加用户 |
|
|
144
146
|
| cpzxrobot().user.update | 更新用户 |
|
|
145
147
|
| cpzxrobot().user.list | 列出用户(传入工厂) |
|
package/types.d.ts
CHANGED
|
@@ -269,6 +269,7 @@ interface MyAxiosInstance {
|
|
|
269
269
|
get: (url: string, config?: any) => Promise<any>;
|
|
270
270
|
post: (url: string, data?: any, config?: any) => Promise<any>;
|
|
271
271
|
getAndSave: (url: string, data?: any, fileName?: string) => Promise<any>;
|
|
272
|
+
getAndPreview: (url: string, data?: any, fileName?: string) => Promise<any>;
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
interface Assistant {
|
package/unit_gateway.ts
CHANGED
|
@@ -99,6 +99,32 @@ export class UnitGateway extends Object {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
//批次管理
|
|
103
|
+
get batch() {
|
|
104
|
+
return {
|
|
105
|
+
bind: (unitDayage: {
|
|
106
|
+
unitId: Number;
|
|
107
|
+
dayage: Number;
|
|
108
|
+
}[], batchNo: string, type: "pigfarm") => {
|
|
109
|
+
return this.context.ready.then((axios) => {
|
|
110
|
+
return axios.post(`/api/v2/batch/unit/bind`, {
|
|
111
|
+
batchNo,
|
|
112
|
+
unitDayage,
|
|
113
|
+
type,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
clear: (unitIds: Number[]) => {
|
|
118
|
+
return this.context.ready.then((axios) => {
|
|
119
|
+
return axios.post(
|
|
120
|
+
`/api/v2/batch/unit/empty`,{
|
|
121
|
+
unitIds
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
102
128
|
v2() {
|
|
103
129
|
return {
|
|
104
130
|
//新增时必传factoryId, 当上层是workshop时,需要传workshopId
|