@cpzxrobot/sdk 1.3.35 → 1.3.37

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 CHANGED
@@ -370,8 +370,9 @@ export abstract class DeviceFilter<T extends { id: number }> {
370
370
  return p
371
371
  .then((farm) => {
372
372
  console.log("type", type);
373
- return this.context.axios.get("/api/v1/device/list?rand=" + rand, {
373
+ return this.context.axios.get("/api/v1/device/list", {
374
374
  params: {
375
+ rand: rand,
375
376
  location: farm,
376
377
  type: options?.type || this.deviceType,
377
378
  unit: options?.unit,
@@ -314,8 +314,9 @@ class DeviceFilter {
314
314
  return p
315
315
  .then((farm) => {
316
316
  console.log("type", type);
317
- return this.context.axios.get("/api/v1/device/list?rand=" + rand, {
317
+ return this.context.axios.get("/api/v1/device/list", {
318
318
  params: {
319
+ rand: rand,
319
320
  location: farm,
320
321
  type: (options === null || options === void 0 ? void 0 : options.type) || this.deviceType,
321
322
  unit: options === null || options === void 0 ? void 0 : options.unit,
@@ -98,5 +98,14 @@ class PurchaseGateway {
98
98
  params: { id }
99
99
  });
100
100
  }
101
+ /**
102
+ * 获取项目采购汇总清单
103
+ * @param id 项目ID
104
+ */
105
+ async getBomConfigSummary(id) {
106
+ return this.axios.get("/api/v2/coremde-sale/purchase/bom-config/summary", {
107
+ params: { id }
108
+ });
109
+ }
101
110
  }
102
111
  exports.PurchaseGateway = PurchaseGateway;
@@ -88,6 +88,8 @@ class WebPlatform {
88
88
  ;
89
89
  processQueryParams(url, config) {
90
90
  if (config && config.params) {
91
+ // 检查URL是否已包含查询参数
92
+ const hasExistingParams = url.includes('?');
91
93
  const flattenParams = (params, prefix = '') => {
92
94
  const result = {};
93
95
  Object.keys(params).forEach(key => {
@@ -103,7 +105,9 @@ class WebPlatform {
103
105
  return result;
104
106
  };
105
107
  const flattened = flattenParams(config.params);
106
- url += "?" + new URLSearchParams(flattened).toString();
108
+ const newParams = new URLSearchParams(flattened).toString();
109
+ // 根据是否已有参数决定使用?还是&连接
110
+ url += (hasExistingParams ? '&' : '?') + newParams;
107
111
  delete config.params;
108
112
  }
109
113
  return url;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.35",
3
+ "version": "1.3.37",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -187,4 +187,14 @@ export class PurchaseGateway {
187
187
  params: { id }
188
188
  });
189
189
  }
190
+
191
+ /**
192
+ * 获取项目采购汇总清单
193
+ * @param id 项目ID
194
+ */
195
+ async getBomConfigSummary(id: number) {
196
+ return this.axios.get("/api/v2/coremde-sale/purchase/bom-config/summary", {
197
+ params: { id }
198
+ });
199
+ }
190
200
  }
package/web_platform.ts CHANGED
@@ -96,6 +96,9 @@ export class WebPlatform implements PlatformInterface {
96
96
 
97
97
  processQueryParams(url: string, config?: any) {
98
98
  if (config && config.params) {
99
+ // 检查URL是否已包含查询参数
100
+ const hasExistingParams = url.includes('?');
101
+
99
102
  const flattenParams = (params: any, prefix = '') => {
100
103
  const result: Record<string, string> = {};
101
104
  Object.keys(params).forEach(key => {
@@ -109,8 +112,12 @@ export class WebPlatform implements PlatformInterface {
109
112
  });
110
113
  return result;
111
114
  };
115
+
112
116
  const flattened = flattenParams(config.params);
113
- url += "?" + new URLSearchParams(flattened).toString();
117
+ const newParams = new URLSearchParams(flattened).toString();
118
+
119
+ // 根据是否已有参数决定使用?还是&连接
120
+ url += (hasExistingParams ? '&' : '?') + newParams;
114
121
  delete config.params;
115
122
  }
116
123
  return url;