@cpzxrobot/sdk 1.2.83 → 1.2.84

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.
@@ -32,23 +32,24 @@ export class ContractGateway extends Object {
32
32
  });
33
33
  }
34
34
 
35
- export(contractId: number, filename: string = "合同.pdf") {
35
+ export(contractId: number, fileName: string = "合同.pdf") {
36
36
  return this.context.ready.then((axios) => {
37
37
  return axios.getAndSave(`/api/v2/coremde-sale/contract/export`, {
38
38
  params: {
39
39
  contractId: contractId,
40
40
  },
41
- }, filename);
41
+ fileName,
42
+ });
42
43
  });
43
44
  }
44
45
 
45
- approval(args:any) {
46
+ approval(args: any) {
46
47
  return this.context.ready.then((axios) => {
47
48
  return axios.post(`/api/v2/coremde-sale/contract/approve`, args);
48
49
  });
49
50
  }
50
51
 
51
- restart(args:any) {
52
+ restart(args: any) {
52
53
  return this.context.ready.then((axios) => {
53
54
  return axios.post(`/api/v2/coremde-sale/contract/restart`, args);
54
55
  });
@@ -21,13 +21,14 @@ class ContractGateway extends Object {
21
21
  return axios.post(`/api/v2/coremde-sale/contract/add`, args);
22
22
  });
23
23
  }
24
- export(contractId, filename = "合同.pdf") {
24
+ export(contractId, fileName = "合同.pdf") {
25
25
  return this.context.ready.then((axios) => {
26
26
  return axios.getAndSave(`/api/v2/coremde-sale/contract/export`, {
27
27
  params: {
28
28
  contractId: contractId,
29
29
  },
30
- }, filename);
30
+ fileName,
31
+ });
31
32
  });
32
33
  }
33
34
  approval(args) {
package/dist/index.js CHANGED
@@ -147,19 +147,20 @@ class Cpzxrobot {
147
147
  });
148
148
  return { data: await response.json() };
149
149
  },
150
- getAndSave: async (url, config, fileName) => {
150
+ getAndSave: async (url, config) => {
151
+ var _a;
151
152
  url = processQueryParams(url, config);
152
153
  const response = await fetchWithAuth(url, {
153
154
  method: 'GET',
154
155
  headers: config === null || config === void 0 ? void 0 : config.headers
155
156
  });
156
157
  const blob = await response.blob();
157
- await this.saveBlob(blob, fileName || "file");
158
+ await this.saveBlob(blob, (_a = config === null || config === void 0 ? void 0 : config.fileName) !== null && _a !== void 0 ? _a : "file");
158
159
  return { data: blob };
159
160
  },
160
- getAndPreview: async (url, config, fileName) => {
161
+ getAndPreview: async (url, config) => {
161
162
  url = processQueryParams(url, config);
162
- return instance.getAndSave(url, config, fileName);
163
+ return instance.getAndSave(url, config);
163
164
  },
164
165
  upload: async (url, option) => {
165
166
  return new Promise((resolve, reject) => {
@@ -322,16 +323,17 @@ class Cpzxrobot {
322
323
  post: function (url, data) {
323
324
  return platform.callHandler("axios_post", url, data);
324
325
  },
325
- getAndSave: function (url, data, fileName) {
326
- return platform.callHandler("axios_getAndSave", url, data, {
327
- fileName: fileName || "file",
328
- });
326
+ getAndSave: function (url, config) {
327
+ return platform.callHandler("axios_getAndSave", url, config);
329
328
  },
330
- getAndPreview: function (url, data, fileName) {
331
- return platform.callHandler("axios_getAndSave", url, data, {
332
- preview: true,
333
- fileName: fileName || "file",
334
- });
329
+ getAndPreview: function (url, config) {
330
+ if (config == undefined) {
331
+ config = {};
332
+ }
333
+ if (config.preview == undefined) {
334
+ config.preview = true;
335
+ }
336
+ return platform.callHandler("axios_getAndSave", url, config);
335
337
  },
336
338
  upload: function (url, option) {
337
339
  return platform.callHandler("axios_upload", url, option);
@@ -44,13 +44,13 @@ class ProductGateway extends Object {
44
44
  // },
45
45
  //下载报价单
46
46
  export: (args) => {
47
- if (!args.fileName) {
48
- args.fileName = "报价单.xlsx";
49
- }
47
+ var _a;
48
+ const fileName = (_a = args.fileName) !== null && _a !== void 0 ? _a : "报价单.xlsx";
50
49
  return this.context.ready.then((axios) => {
51
50
  return axios.getAndSave(`/api/v2/coremde-sale/product/price/export`, {
52
51
  params: args,
53
- }, args.fileName);
52
+ fileName: fileName,
53
+ });
54
54
  });
55
55
  },
56
56
  add: (args) => {
@@ -75,13 +75,13 @@ class ProductGateway extends Object {
75
75
  });
76
76
  },
77
77
  export: (args) => {
78
- if (!args.fileName) {
79
- args.fileName = "报价单历史记录.xlsx";
80
- }
78
+ var _a;
79
+ var fileName = (_a = args.fileName) !== null && _a !== void 0 ? _a : "报价单历史记录.xlsx";
81
80
  return this.context.ready.then((axios) => {
82
81
  return axios.getAndSave(`/api/v2/coremde-sale/product/price/history/export`, {
83
82
  params: args,
84
- }, args.fileName);
83
+ fileName: fileName
84
+ });
85
85
  });
86
86
  },
87
87
  },
@@ -50,9 +50,9 @@ class ProjectGateway extends Object {
50
50
  return axios.get(`/api/v2/coremde-sale/project/feedback/media/cancel?id=${id}`);
51
51
  });
52
52
  },
53
- download: (id) => {
53
+ download: (id, config) => {
54
54
  return this.context.ready.then((axios) => {
55
- return axios.getAndPreview(`/api/v2/coremde-sale/project/feedback/media/download?id=${id}`);
55
+ return axios.getAndPreview(`/api/v2/coremde-sale/project/feedback/media/download?id=${id}`, config);
56
56
  });
57
57
  }
58
58
  }
@@ -99,8 +99,9 @@ class ProjectGateway extends Object {
99
99
  return axios.getAndSave(`/api/v2/coremde-sale/project/document/export`, {
100
100
  params: {
101
101
  id,
102
- }
103
- }, fileName);
102
+ },
103
+ fileName
104
+ });
104
105
  });
105
106
  },
106
107
  // 上传项目文档
@@ -201,8 +202,9 @@ class ProjectGateway extends Object {
201
202
  params: {
202
203
  id,
203
204
  fileName
204
- }
205
- }, fileName);
205
+ },
206
+ fileName
207
+ });
206
208
  });
207
209
  },
208
210
  approval: (args) => {
package/index.ts CHANGED
@@ -170,19 +170,23 @@ export class Cpzxrobot {
170
170
  });
171
171
  return { data: await response.json() };
172
172
  },
173
- getAndSave: async (url: string, config?: any, fileName?: string) => {
173
+ getAndSave: async (url: string, config?: any) => {
174
174
  url = processQueryParams(url, config);
175
175
  const response = await fetchWithAuth(url, {
176
176
  method: 'GET',
177
177
  headers: config?.headers
178
178
  });
179
179
  const blob = await response.blob();
180
- await this.saveBlob(blob, fileName || "file");
180
+ await this.saveBlob(blob, config?.fileName ?? "file");
181
181
  return { data: blob };
182
182
  },
183
- getAndPreview: async (url: string, config?: any, fileName?: string) => {
183
+ getAndPreview: async (url: string, config?: {
184
+ fileName?: string;
185
+ params?: any;
186
+ preview?: boolean;
187
+ }) => {
184
188
  url = processQueryParams(url, config);
185
- return instance.getAndSave(url, config, fileName);
189
+ return instance.getAndSave(url, config);
186
190
  },
187
191
  upload: async (url: string, option?: any) => {
188
192
  return new Promise<any>((resolve, reject) => {
@@ -348,16 +352,17 @@ export class Cpzxrobot {
348
352
  post: function (url, data) {
349
353
  return platform.callHandler("axios_post", url, data);
350
354
  },
351
- getAndSave: function (url, data, fileName) {
352
- return platform.callHandler("axios_getAndSave", url, data, {
353
- fileName: fileName || "file",
354
- });
355
+ getAndSave: function (url, config) {
356
+ return platform.callHandler("axios_getAndSave", url, config);
355
357
  },
356
- getAndPreview: function (url, data, fileName) {
357
- return platform.callHandler("axios_getAndSave", url, data, {
358
- preview: true,
359
- fileName: fileName || "file",
360
- });
358
+ getAndPreview: function (url, config) {
359
+ if (config== undefined){
360
+ config = {};
361
+ }
362
+ if (config.preview == undefined){
363
+ config.preview = true;
364
+ }
365
+ return platform.callHandler("axios_getAndSave", url, config);
361
366
  },
362
367
  upload: function (url, option) {
363
368
  return platform.callHandler("axios_upload", url, option);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.83",
3
+ "version": "1.2.84",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -73,13 +73,12 @@ export class ProductGateway extends Object {
73
73
  companyId: number;
74
74
  fileName?: string;
75
75
  }) => {
76
- if (!args.fileName) {
77
- args.fileName = "报价单.xlsx";
78
- }
76
+ const fileName = args.fileName ?? "报价单.xlsx";
79
77
  return this.context.ready.then((axios) => {
80
78
  return axios.getAndSave(`/api/v2/coremde-sale/product/price/export`, {
81
79
  params: args,
82
- }, args.fileName);
80
+ fileName: fileName,
81
+ });
83
82
  });
84
83
  },
85
84
  add: (args: {
@@ -125,13 +124,12 @@ export class ProductGateway extends Object {
125
124
  id: number;
126
125
  fileName?: string;
127
126
  }) => {
128
- if (!args.fileName) {
129
- args.fileName = "报价单历史记录.xlsx";
130
- }
127
+ var fileName = args.fileName ?? "报价单历史记录.xlsx";
131
128
  return this.context.ready.then((axios) => {
132
129
  return axios.getAndSave(`/api/v2/coremde-sale/product/price/history/export`, {
133
130
  params: args,
134
- }, args.fileName);
131
+ fileName: fileName
132
+ });
135
133
  });
136
134
  },
137
135
  },
@@ -75,9 +75,13 @@ export class ProjectGateway extends Object {
75
75
  return axios.get(`/api/v2/coremde-sale/project/feedback/media/cancel?id=${id}`);
76
76
  });
77
77
  },
78
- download: (id: number) => {
78
+ download: (id: number, config: {
79
+ fileName?: string;
80
+ preview?: boolean;
81
+ params?: any;
82
+ }) => {
79
83
  return this.context.ready.then((axios) => {
80
- return axios.getAndPreview(`/api/v2/coremde-sale/project/feedback/media/download?id=${id}`);
84
+ return axios.getAndPreview(`/api/v2/coremde-sale/project/feedback/media/download?id=${id}`, config);
81
85
  });
82
86
  }
83
87
  }
@@ -134,8 +138,9 @@ export class ProjectGateway extends Object {
134
138
  return axios.getAndSave(`/api/v2/coremde-sale/project/document/export`, {
135
139
  params: {
136
140
  id,
137
- }
138
- }, fileName);
141
+ },
142
+ fileName
143
+ });
139
144
  });
140
145
  },
141
146
  // 上传项目文档
@@ -158,7 +163,7 @@ export class ProjectGateway extends Object {
158
163
  });
159
164
  },
160
165
  // 下载项目文档
161
- download: (args: { documentId: number }) => {
166
+ download: (args: { documentId: number, fileName?: string, preview?: boolean }) => {
162
167
  return this.context.ready.then((axios) => {
163
168
  return axios.getAndPreview(`/api/v2/coremde-sale/project/document/download`, {
164
169
  params: args
@@ -253,8 +258,9 @@ export class ProjectGateway extends Object {
253
258
  params: {
254
259
  id,
255
260
  fileName
256
- }
257
- }, fileName);
261
+ },
262
+ fileName
263
+ });
258
264
  });
259
265
  },
260
266
  approval: (args: any) => {
package/types.d.ts CHANGED
@@ -283,8 +283,15 @@ type FeedTower = {
283
283
  interface MyAxiosInstance {
284
284
  get: (url: string, config?: any) => Promise<any>;
285
285
  post: (url: string, data?: any, config?: any) => Promise<any>;
286
- getAndSave: (url: string, data?: any, fileName?: string) => Promise<any>;
287
- getAndPreview: (url: string, data?: any, fileName?: string) => Promise<any>;
286
+ getAndSave: (url: string, data?: {
287
+ fileName?: string;
288
+ params?: any;
289
+ }) => Promise<any>;
290
+ getAndPreview: (url: string, config?: {
291
+ fileName?: string;
292
+ preview?: boolean;
293
+ params?: any;
294
+ }) => Promise<any>;
288
295
  //调用系统文件选择器,上传文件
289
296
  //url:上传的url
290
297
  //option:上传的配置项,比如文件名等