@cpzxrobot/sdk 1.2.75 → 1.2.77

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 CHANGED
@@ -160,13 +160,21 @@ class Cpzxrobot {
160
160
  const button = document.createElement("input");
161
161
  button.type = "file";
162
162
  button.style.display = "none";
163
+ button.multiple = (option === null || option === void 0 ? void 0 : option.multiple) || false;
163
164
  document.body.appendChild(button);
164
- button.onclick = async (e) => {
165
- var _a;
166
- const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
167
- if (file) {
165
+ button.click(); // 手动触发点击
166
+ button.onchange = async (e) => {
167
+ const files = e.target.files;
168
+ if (files && files.length > 0) {
168
169
  const formData = new FormData();
169
- formData.append((option === null || option === void 0 ? void 0 : option["fileField"]) || "file", file);
170
+ if (option === null || option === void 0 ? void 0 : option.multiple) {
171
+ for (let i = 0; i < files.length; i++) {
172
+ formData.append("files[]", files[i]);
173
+ }
174
+ }
175
+ else {
176
+ formData.append((option === null || option === void 0 ? void 0 : option["fileField"]) || "file", files[0]);
177
+ }
170
178
  for (let key in option === null || option === void 0 ? void 0 : option["data"]) {
171
179
  formData.append(key, option["data"][key]);
172
180
  }
@@ -13,7 +13,7 @@ class QuotationGateway extends Object {
13
13
  }
14
14
  add(args) {
15
15
  return this.context.ready.then((axios) => {
16
- return axios.post(`/api/v2/coremde-sale/quotation/add`, args);
16
+ return axios.upload(`/api/v2/coremde-sale/quotation/add`, args);
17
17
  });
18
18
  }
19
19
  get(id) {
@@ -289,7 +289,7 @@ class UserGateway extends Object {
289
289
  return {
290
290
  list: async (params) => {
291
291
  var axios = await this.context.ready;
292
- return axios.post('/api/v2/task/list', params);
292
+ return axios.post('/api/v2/coremde-sale/task/list', params);
293
293
  }
294
294
  };
295
295
  }
package/index.ts CHANGED
@@ -182,12 +182,20 @@ export class Cpzxrobot {
182
182
  const button = document.createElement("input");
183
183
  button.type = "file";
184
184
  button.style.display = "none";
185
+ button.multiple = option?.multiple || false;
185
186
  document.body.appendChild(button);
186
- button.onclick = async (e: Event) => {
187
- const file = (e.target as HTMLInputElement).files?.[0];
188
- if (file) {
187
+ button.click(); // 手动触发点击
188
+ button.onchange = async (e: Event) => {
189
+ const files = (e.target as HTMLInputElement).files;
190
+ if (files && files.length > 0) {
189
191
  const formData = new FormData();
190
- formData.append(option?.["fileField"] || "file", file);
192
+ if (option?.multiple) {
193
+ for (let i = 0; i < files.length; i++) {
194
+ formData.append("files[]", files[i]);
195
+ }
196
+ } else {
197
+ formData.append(option?.["fileField"] || "file", files[0]);
198
+ }
191
199
  for (let key in option?.["data"]) {
192
200
  formData.append(key, option!["data"][key]);
193
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.75",
3
+ "version": "1.2.77",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@ export class QuotationGateway extends Object {
22
22
 
23
23
  add(args: any) {
24
24
  return this.context.ready.then((axios) => {
25
- return axios.post(`/api/v2/coremde-sale/quotation/add`, args);
25
+ return axios.upload(`/api/v2/coremde-sale/quotation/add`, args);
26
26
  });
27
27
  }
28
28
 
package/user_gateway.ts CHANGED
@@ -326,7 +326,7 @@ export class UserGateway extends Object {
326
326
  applyUserId: number
327
327
  }) => {
328
328
  var axios = await this.context.ready;
329
- return axios.post('/api/v2/task/list', params);
329
+ return axios.post('/api/v2/coremde-sale/task/list', params);
330
330
  }
331
331
  }
332
332
  }