@cpzxrobot/sdk 1.2.77 → 1.2.78
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 +25 -19
- package/dist/project_gateway.js +1 -1
- package/dist/quotation_gateway.js +1 -1
- package/dist/user_gateway.js +10 -0
- package/index.ts +29 -22
- package/package.json +1 -1
- package/project_gateway.ts +1 -1
- package/quotation_gateway.ts +1 -1
- package/user_gateway.ts +15 -0
package/dist/index.js
CHANGED
|
@@ -108,27 +108,31 @@ class Cpzxrobot {
|
|
|
108
108
|
}
|
|
109
109
|
return response;
|
|
110
110
|
};
|
|
111
|
+
const processQueryParams = (url, config) => {
|
|
112
|
+
if (config && config.params) {
|
|
113
|
+
const flattenParams = (params, prefix = '') => {
|
|
114
|
+
const result = {};
|
|
115
|
+
Object.keys(params).forEach(key => {
|
|
116
|
+
const value = params[key];
|
|
117
|
+
const fullKey = prefix ? `${prefix}[${key}]` : key;
|
|
118
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
119
|
+
Object.assign(result, flattenParams(value, fullKey));
|
|
120
|
+
}
|
|
121
|
+
else if (value) {
|
|
122
|
+
result[fullKey] = value.toString();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return result;
|
|
126
|
+
};
|
|
127
|
+
const flattened = flattenParams(config.params);
|
|
128
|
+
url += "?" + new URLSearchParams(flattened).toString();
|
|
129
|
+
delete config.params;
|
|
130
|
+
}
|
|
131
|
+
return url;
|
|
132
|
+
};
|
|
111
133
|
const instance = {
|
|
112
134
|
get: async (url, config) => {
|
|
113
|
-
|
|
114
|
-
const flattenParams = (params, prefix = '') => {
|
|
115
|
-
const result = {};
|
|
116
|
-
Object.keys(params).forEach(key => {
|
|
117
|
-
const value = params[key];
|
|
118
|
-
const fullKey = prefix ? `${prefix}[${key}]` : key;
|
|
119
|
-
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
120
|
-
Object.assign(result, flattenParams(value, fullKey));
|
|
121
|
-
}
|
|
122
|
-
else if (value) {
|
|
123
|
-
result[fullKey] = value.toString();
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return result;
|
|
127
|
-
};
|
|
128
|
-
const flattened = flattenParams(config.params);
|
|
129
|
-
url += "?" + new URLSearchParams(flattened).toString();
|
|
130
|
-
delete config.params;
|
|
131
|
-
}
|
|
135
|
+
url = processQueryParams(url, config);
|
|
132
136
|
const response = await fetchWithAuth(url, {
|
|
133
137
|
method: 'GET',
|
|
134
138
|
headers: config === null || config === void 0 ? void 0 : config.headers
|
|
@@ -144,6 +148,7 @@ class Cpzxrobot {
|
|
|
144
148
|
return { data: await response.json() };
|
|
145
149
|
},
|
|
146
150
|
getAndSave: async (url, config, fileName) => {
|
|
151
|
+
url = processQueryParams(url, config);
|
|
147
152
|
const response = await fetchWithAuth(url, {
|
|
148
153
|
method: 'GET',
|
|
149
154
|
headers: config === null || config === void 0 ? void 0 : config.headers
|
|
@@ -153,6 +158,7 @@ class Cpzxrobot {
|
|
|
153
158
|
return { data: blob };
|
|
154
159
|
},
|
|
155
160
|
getAndPreview: async (url, config, fileName) => {
|
|
161
|
+
url = processQueryParams(url, config);
|
|
156
162
|
return instance.getAndSave(url, config, fileName);
|
|
157
163
|
},
|
|
158
164
|
upload: async (url, option) => {
|
package/dist/project_gateway.js
CHANGED
|
@@ -106,7 +106,7 @@ class ProjectGateway extends Object {
|
|
|
106
106
|
// 上传项目文档
|
|
107
107
|
upload: (args) => {
|
|
108
108
|
return this.context.ready.then((axios) => {
|
|
109
|
-
return axios.
|
|
109
|
+
return axios.upload(`/api/v2/coremde-sale/project/document/upload`, args);
|
|
110
110
|
});
|
|
111
111
|
},
|
|
112
112
|
// 预览项目文档
|
|
@@ -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.
|
|
16
|
+
return axios.post(`/api/v2/coremde-sale/quotation/add`, args);
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
get(id) {
|
package/dist/user_gateway.js
CHANGED
|
@@ -126,6 +126,16 @@ class UserGateway extends Object {
|
|
|
126
126
|
}
|
|
127
127
|
async mypermission(params = undefined) {
|
|
128
128
|
var axios = await this.context.ready;
|
|
129
|
+
var factory = await this.context.user.getSelectedFarm();
|
|
130
|
+
var args;
|
|
131
|
+
if (params) {
|
|
132
|
+
args = Object.assign(Object.assign({}, params), { factoryId: factory.id });
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
args = {
|
|
136
|
+
factoryId: factory.id
|
|
137
|
+
};
|
|
138
|
+
}
|
|
129
139
|
return axios.get("/api/v2/user/role/mypermission", {
|
|
130
140
|
params
|
|
131
141
|
});
|
package/index.ts
CHANGED
|
@@ -127,27 +127,32 @@ export class Cpzxrobot {
|
|
|
127
127
|
return response;
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
+
const processQueryParams = (url: string, config?: any) => {
|
|
131
|
+
if (config && config.params) {
|
|
132
|
+
const flattenParams = (params: any, prefix = '') => {
|
|
133
|
+
const result: Record<string, string> = {};
|
|
134
|
+
Object.keys(params).forEach(key => {
|
|
135
|
+
const value = params[key];
|
|
136
|
+
const fullKey = prefix ? `${prefix}[${key}]` : key;
|
|
137
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
138
|
+
Object.assign(result, flattenParams(value, fullKey));
|
|
139
|
+
} else if (value) {
|
|
140
|
+
result[fullKey] = value.toString();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return result;
|
|
144
|
+
};
|
|
145
|
+
const flattened = flattenParams(config.params);
|
|
146
|
+
url += "?" + new URLSearchParams(flattened).toString();
|
|
147
|
+
delete config.params;
|
|
148
|
+
}
|
|
149
|
+
return url;
|
|
150
|
+
}
|
|
151
|
+
|
|
130
152
|
const instance = {
|
|
131
|
-
get: async (url: string, config?: any) => {
|
|
132
|
-
if (config && config.params) {
|
|
133
|
-
const flattenParams = (params: any, prefix = '') => {
|
|
134
|
-
const result: Record<string, string> = {};
|
|
135
|
-
Object.keys(params).forEach(key => {
|
|
136
|
-
const value = params[key];
|
|
137
|
-
const fullKey = prefix ? `${prefix}[${key}]` : key;
|
|
138
|
-
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
139
|
-
Object.assign(result, flattenParams(value, fullKey));
|
|
140
|
-
} else if(value){
|
|
141
|
-
result[fullKey] = value.toString();
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
return result;
|
|
145
|
-
};
|
|
146
153
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
delete config.params;
|
|
150
|
-
}
|
|
154
|
+
get: async (url: string, config?: any) => {
|
|
155
|
+
url = processQueryParams(url, config);
|
|
151
156
|
const response = await fetchWithAuth(url, {
|
|
152
157
|
method: 'GET',
|
|
153
158
|
headers: config?.headers
|
|
@@ -166,6 +171,7 @@ export class Cpzxrobot {
|
|
|
166
171
|
return { data: await response.json() };
|
|
167
172
|
},
|
|
168
173
|
getAndSave: async (url: string, config?: any, fileName?: string) => {
|
|
174
|
+
url = processQueryParams(url, config);
|
|
169
175
|
const response = await fetchWithAuth(url, {
|
|
170
176
|
method: 'GET',
|
|
171
177
|
headers: config?.headers
|
|
@@ -175,6 +181,7 @@ export class Cpzxrobot {
|
|
|
175
181
|
return { data: blob };
|
|
176
182
|
},
|
|
177
183
|
getAndPreview: async (url: string, config?: any, fileName?: string) => {
|
|
184
|
+
url = processQueryParams(url, config);
|
|
178
185
|
return instance.getAndSave(url, config, fileName);
|
|
179
186
|
},
|
|
180
187
|
upload: async (url: string, option?: any) => {
|
|
@@ -316,8 +323,8 @@ export class Cpzxrobot {
|
|
|
316
323
|
this.vibrate = function (time?: number) {
|
|
317
324
|
return platform.callHandler("app.vibrate", time);
|
|
318
325
|
};
|
|
319
|
-
this.showInDeviceManager = function (deviceId: number,type:string) {
|
|
320
|
-
return platform.callHandler("app.showInDeviceManager", deviceId,type);
|
|
326
|
+
this.showInDeviceManager = function (deviceId: number, type: string) {
|
|
327
|
+
return platform.callHandler("app.showInDeviceManager", deviceId, type);
|
|
321
328
|
};
|
|
322
329
|
this.reloadGroup = function (group: string) {
|
|
323
330
|
return platform.callHandler("app.reloadGroup", group);
|
|
@@ -445,7 +452,7 @@ export class Cpzxrobot {
|
|
|
445
452
|
}
|
|
446
453
|
});
|
|
447
454
|
};
|
|
448
|
-
this.showInDeviceManager = function (deviceId: number,type: string) {
|
|
455
|
+
this.showInDeviceManager = function (deviceId: number, type: string) {
|
|
449
456
|
return this.axios.get(`/api/v1/${type}/share/` + deviceId);
|
|
450
457
|
};
|
|
451
458
|
}
|
package/package.json
CHANGED
package/project_gateway.ts
CHANGED
|
@@ -146,7 +146,7 @@ export class ProjectGateway extends Object {
|
|
|
146
146
|
fileType: "base-info" | "inquiry" | "contract";
|
|
147
147
|
}) => {
|
|
148
148
|
return this.context.ready.then((axios) => {
|
|
149
|
-
return axios.
|
|
149
|
+
return axios.upload(`/api/v2/coremde-sale/project/document/upload`, args);
|
|
150
150
|
});
|
|
151
151
|
},
|
|
152
152
|
// 预览项目文档
|
package/quotation_gateway.ts
CHANGED
|
@@ -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.
|
|
25
|
+
return axios.post(`/api/v2/coremde-sale/quotation/add`, args);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
package/user_gateway.ts
CHANGED
|
@@ -139,6 +139,21 @@ export class UserGateway extends Object {
|
|
|
139
139
|
|
|
140
140
|
async mypermission(params: any = undefined) {
|
|
141
141
|
var axios = await this.context.ready;
|
|
142
|
+
var factory = await this.context.user.getSelectedFarm();
|
|
143
|
+
var args: {
|
|
144
|
+
factoryId: number;
|
|
145
|
+
[key: string]: any;
|
|
146
|
+
}
|
|
147
|
+
if (params) {
|
|
148
|
+
args = {
|
|
149
|
+
...params,
|
|
150
|
+
factoryId: factory.id
|
|
151
|
+
}
|
|
152
|
+
}else{
|
|
153
|
+
args = {
|
|
154
|
+
factoryId: factory.id
|
|
155
|
+
};
|
|
156
|
+
}
|
|
142
157
|
return axios.get("/api/v2/user/role/mypermission", {
|
|
143
158
|
params
|
|
144
159
|
});
|