@cpzxrobot/sdk 1.1.69 → 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.
@@ -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
  }
@@ -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
@@ -123,7 +123,7 @@ export class Cpzxrobot {
123
123
  }
124
124
  // @ts-ignore
125
125
  instance.getAndPreview = instance.getAndSave;
126
-
126
+ // @ts-ignore
127
127
  instance.upload = (url: string, option?: {
128
128
  [key: string]: any;
129
129
  }) => {
@@ -132,7 +132,7 @@ export class Cpzxrobot {
132
132
  button.type = "file";
133
133
  button.style.display = "none";
134
134
  document.body.appendChild(button);
135
- button.onchange = (e:Event) => {
135
+ button.onchange = (e: Event) => {
136
136
  var file = (e.target as HTMLInputElement).files?.[0];
137
137
  if (file) {
138
138
  const formData = new FormData();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.1.69",
3
+ "version": "1.1.70",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
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 | 获取称重计的配置信息 |