@cpzxrobot/sdk 1.3.24 → 1.3.25

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/user_gateway.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { Cpzxrobot, type Factory, type Unit } from "./types";
1
+ import { Cpzxrobot, type Factory, type Unit } from './types'
2
2
 
3
3
  export class UserGateway extends Object {
4
- context: Cpzxrobot;
4
+ context: Cpzxrobot
5
5
 
6
6
  constructor(context: Cpzxrobot) {
7
- super();
8
- this.context = context;
7
+ super()
8
+ this.context = context
9
9
  }
10
10
 
11
11
  //获得当前用户选择的工厂
@@ -14,129 +14,136 @@ export class UserGateway extends Object {
14
14
  }
15
15
 
16
16
  public async selectUnit(unit: Unit | String | Number) {
17
- if ((typeof unit === "string") || (typeof unit === "number")) {
18
- var resp = await this.context.unit.get(unit);
19
- this.context.platform.setSelectedUnit(resp.data);
17
+ if (typeof unit === 'string' || typeof unit === 'number') {
18
+ var resp = await this.context.unit.get(unit)
19
+ this.context.platform.setSelectedUnit(resp.data)
20
20
  } else {
21
- this.context.platform.setSelectedUnit(unit);
21
+ this.context.platform.setSelectedUnit(unit)
22
22
  }
23
23
  }
24
24
 
25
25
  //获得当前用户选择的单元
26
26
  getSelectedUnit() {
27
- return this.context.platform.getSelectedUnitFromMiniApp();
27
+ return this.context.platform.getSelectedUnitFromMiniApp()
28
28
  }
29
29
 
30
30
  set selectedFarm(farm: Factory) {
31
- this.context.platform.setSelectedFarm(farm);
31
+ this.context.platform.setSelectedFarm(farm)
32
32
  }
33
33
 
34
34
  set selectedUnit(unit: Unit) {
35
- this.context.platform.setSelectedUnit(unit);
35
+ this.context.platform.setSelectedUnit(unit)
36
36
  }
37
37
 
38
38
  async add(user: any) {
39
- var axios = await this.context.ready;
40
- return axios.post("/api/v2/user", user);
39
+ var axios = await this.context.ready
40
+ return axios.post('/api/v2/user', user)
41
41
  }
42
42
 
43
43
  async update(user: any) {
44
- var axios = await this.context.ready;
45
- return axios.post("/api/v2/user", user);
44
+ var axios = await this.context.ready
45
+ return axios.post('/api/v2/user', user)
46
46
  }
47
47
 
48
48
  async list(factory: Factory) {
49
- var axios = await this.context.ready;
50
- return axios.get("/api/v2/" + factory.id + "/users");
49
+ var axios = await this.context.ready
50
+ return axios.get('/api/v2/' + factory.id + '/users')
51
51
  }
52
52
 
53
-
54
53
  listByProvince(area_code: string) {
55
54
  return this.context.ready.then((axios) => {
56
- return axios.get(`/api/v2/coremde-sale/user/province/get?area_code=${area_code}`);
57
- });
55
+ return axios.get(
56
+ `/api/v2/coremde-sale/user/province/get?area_code=${area_code}`
57
+ )
58
+ })
58
59
  }
59
60
 
60
61
  listByCity(area_code: string) {
61
62
  return this.context.ready.then((axios) => {
62
- return axios.get(`/api/v2/coremde-sale/user/city/get?area_code=${area_code}`);
63
- });
63
+ return axios.get(
64
+ `/api/v2/coremde-sale/user/city/get?area_code=${area_code}`
65
+ )
66
+ })
64
67
  }
65
68
 
66
- async listByRole(role: string | {
67
- deptName: string;
68
- roleCode: string;
69
- }) {
70
- var args = {};
71
- if (typeof role === "string") {
69
+ async listByRole(
70
+ role:
71
+ | string
72
+ | {
73
+ deptName: string
74
+ roleCode: string
75
+ }
76
+ ) {
77
+ var args = {}
78
+ if (typeof role === 'string') {
72
79
  args = {
73
- roleCode: role
80
+ roleCode: role,
74
81
  }
75
82
  } else {
76
83
  args = {
77
84
  ...role,
78
85
  }
79
86
  }
80
- var axios = await this.context.ready;
81
- var factory = await this.context.user.getSelectedFarm();
87
+ var axios = await this.context.ready
88
+ var factory = await this.context.user.getSelectedFarm()
82
89
  //当前如果打开的是公司,则说明该应用支持在公司级别打开,则要求该应用应该有对应的公司级别的角色配置,所以并不需要查找公司下属工厂或工厂的对应公司,再去查找用户
83
90
  return axios.get(`/api/v2/company/${factory.id}/users`, {
84
- params: args
85
- });
91
+ params: args,
92
+ })
86
93
  }
87
94
 
88
95
  async mypermission(params: any = undefined) {
89
- var axios = await this.context.ready;
90
- var factory = await this.context.user.getSelectedFarm();
96
+ var axios = await this.context.ready
97
+ var factory = await this.context.user.getSelectedFarm()
91
98
  var args: {
92
- factoryId: number;
93
- [key: string]: any;
99
+ factoryId: number
100
+ [key: string]: any
94
101
  }
95
102
  if (params) {
96
103
  args = {
97
104
  ...params,
98
- factoryId: factory.id
105
+ factoryId: factory.id,
99
106
  }
100
107
  } else {
101
108
  args = {
102
- factoryId: factory.id ?? 0
103
- };
109
+ factoryId: factory.id ?? 0,
110
+ }
104
111
  }
105
- return axios.get("/api/v2/user/role/mypermission", {
106
- args
107
- });
112
+ return axios.get('/api/v2/user/role/mypermission', {
113
+ args,
114
+ })
108
115
  }
109
116
 
110
117
  async delete(id: number) {
111
- var axios = await this.context.ready;
112
- return axios.post("/api/v2/user/delete?id=" + id);
118
+ var axios = await this.context.ready
119
+ return axios.post('/api/v2/user/delete?id=' + id)
113
120
  }
114
121
 
115
122
  get avatar() {
116
123
  return {
117
124
  add: async (id: number) => {
118
- var axios = await this.context.ready;
125
+ var axios = await this.context.ready
119
126
  return axios.upload(`/api/v2/user/${id}/avatar/add`, {
120
- title: "请选择上传头像文件"
121
- });
127
+ title: '请选择上传头像文件',
128
+ })
122
129
  },
123
130
  get: async (id: number) => {
124
- var axios = await this.context.ready;
125
- return axios.get(`/api/v2/user/${id}/avatar`);
126
- }
131
+ var axios = await this.context.ready
132
+ return axios.get(`/api/v2/user/${id}/avatar`)
133
+ },
127
134
  }
128
135
  }
129
136
 
130
137
  get sign() {
131
138
  return {
132
139
  add: async (id: number) => {
133
- var axios = await this.context.ready;
134
- return axios.upload(`/api/v2/user/${id}/sign/add`);
140
+ var axios = await this.context.ready
141
+ return axios.upload(`/api/v2/user/${id}/sign/add`)
135
142
  },
136
143
  get: async (id: number) => {
137
- var axios = await this.context.ready;
138
- return axios.get(`/api/v2/user/${id}/sign`);
139
- }
144
+ var axios = await this.context.ready
145
+ return axios.get(`/api/v2/user/${id}/sign`)
146
+ },
140
147
  }
141
148
  }
142
149
 
@@ -146,71 +153,80 @@ export class UserGateway extends Object {
146
153
  return this.context.ready.then((axios) => {
147
154
  return axios.post(`/api/v2/coremde-sale/approval/count`, {
148
155
  status,
149
- userId: id
150
- });
151
- });
156
+ userId: id,
157
+ })
158
+ })
152
159
  },
153
- list: (id: number, status: any, pageNo: number | undefined = undefined, pageSize: number | undefined = undefined) => {
160
+ list: (
161
+ id: number,
162
+ status: any,
163
+ pageNo: number | undefined = undefined,
164
+ pageSize: number | undefined = undefined
165
+ ) => {
154
166
  return this.context.ready.then((axios) => {
155
167
  return axios.post(`/api/v2/coremde-sale/approval/list`, {
156
168
  status,
157
169
  userId: id,
158
170
  pageNo,
159
- pageSize
160
- });
161
- });
171
+ pageSize,
172
+ })
173
+ })
162
174
  },
163
- submits: (id: number, pageNo: number | undefined = undefined, pageSize: number | undefined = undefined) => {
175
+ submits: (
176
+ id: number,
177
+ pageNo: number | undefined = undefined,
178
+ pageSize: number | undefined = undefined
179
+ ) => {
164
180
  return this.context.ready.then((axios) => {
165
181
  return axios.get(`/api/v2/coremde-sale/approval/submit/list`, {
166
182
  params: {
167
183
  userId: id,
168
184
  pageNo,
169
- pageSize
170
- }
171
- });
172
- });
173
- }
185
+ pageSize,
186
+ },
187
+ })
188
+ })
189
+ },
174
190
  }
175
191
  }
176
192
 
177
193
  get checkin() {
178
194
  return {
179
195
  add: (args: {
180
- userId: number,
181
- address: string,
182
- areaCode: string,
183
- lat: number,
196
+ userId: number
197
+ address: string
198
+ areaCode: string
199
+ lat: number
184
200
  lng: number
185
201
  }) => {
186
202
  return this.context.ready.then((axios) => {
187
- return axios.post(`/api/v2/coremde-sale/checkin/add`, args);
188
- });
203
+ return axios.post(`/api/v2/coremde-sale/checkin/add`, args)
204
+ })
189
205
  },
190
206
  //date 传入格式为2019-8或者Date类型对象
191
207
  list: (userId: number, date: any) => {
192
208
  //if date is string
193
- var yearMonth: string;
209
+ var yearMonth: string
194
210
  if (typeof date === 'string') {
195
- yearMonth = date;
211
+ yearMonth = date
196
212
  } else if (typeof date === 'object') {
197
- yearMonth = date.getFullYear() + '-' + (date.getMonth() + 1);
213
+ yearMonth = date.getFullYear() + '-' + (date.getMonth() + 1)
198
214
  }
199
215
 
200
216
  return this.context.ready.then((axios) => {
201
217
  return axios.post(`/api/v2/coremde-sale/checkin/list`, {
202
218
  userId,
203
- yearMonth
204
- });
205
- });
219
+ yearMonth,
220
+ })
221
+ })
206
222
  },
207
223
  //获取打卡详情
208
224
  get: (id: number) => {
209
225
  return this.context.ready.then((axios) => {
210
- return axios.get(`/api/v2/coremde-sale/checkin/get?id=${id}`);
211
- });
212
- }
213
- };
226
+ return axios.get(`/api/v2/coremde-sale/checkin/get?id=${id}`)
227
+ })
228
+ },
229
+ }
214
230
  }
215
231
 
216
232
  get searchHistory() {
@@ -218,26 +234,26 @@ export class UserGateway extends Object {
218
234
  list: (type: number) => {
219
235
  return this.context.ready.then((axios) => {
220
236
  return axios.post(`/api/v2/coremde-sale/search/list`, {
221
- type
222
- });
223
- });
237
+ type,
238
+ })
239
+ })
224
240
  },
225
241
  //添加搜索历史,type 1:合同,2:项目
226
242
  add: (keyword: string, type: number) => {
227
243
  return this.context.ready.then((axios) => {
228
244
  return axios.post(`/api/v2/coremde-sale/search/add`, {
229
245
  name: keyword,
230
- type
231
- });
232
- });
246
+ type,
247
+ })
248
+ })
233
249
  },
234
250
  delete: (ids: number[]) => {
235
251
  return this.context.ready.then((axios) => {
236
252
  return axios.post(`/api/v2/coremde-sale/search/delete`, {
237
- ids
238
- });
239
- });
240
- }
253
+ ids,
254
+ })
255
+ })
256
+ },
241
257
  }
242
258
  }
243
259
 
@@ -246,71 +262,75 @@ export class UserGateway extends Object {
246
262
  return {
247
263
  list: (args: any) => {
248
264
  return this.context.ready.then((axios) => {
249
- return axios.post(`/api/v2/coremde-sale/user/work-report/list`, args);
250
- });
265
+ return axios.post(`/api/v2/coremde-sale/user/work-report/list`, args)
266
+ })
251
267
  },
252
268
  get: (id: number) => {
253
269
  return this.context.ready.then((axios) => {
254
- return axios.get(`/api/v2/coremde-sale/user/work-report/get?id=${id}`);
255
- });
270
+ return axios.get(`/api/v2/coremde-sale/user/work-report/get?id=${id}`)
271
+ })
256
272
  },
257
273
  add: (report: any) => {
258
274
  return this.context.ready.then((axios) => {
259
- return axios.post(`/api/v2/coremde-sale/user/work-report/add`, report);
260
- });
275
+ return axios.post(`/api/v2/coremde-sale/user/work-report/add`, report)
276
+ })
261
277
  },
262
278
  update: (report: any) => {
263
279
  return this.context.ready.then((axios) => {
264
- return axios.post(`/api/v2/coremde-sale/user/work-report/update`, report);
265
- });
280
+ return axios.post(
281
+ `/api/v2/coremde-sale/user/work-report/update`,
282
+ report
283
+ )
284
+ })
266
285
  },
267
286
  delete: (id: number) => {
268
287
  return this.context.ready.then((axios) => {
269
- return axios.get(`/api/v2/coremde-sale/user/work-report/delete?id=${id}`);
270
- });
271
- }
272
- };
288
+ return axios.get(
289
+ `/api/v2/coremde-sale/user/work-report/delete?id=${id}`
290
+ )
291
+ })
292
+ },
293
+ }
273
294
  }
274
295
 
275
296
  get stat() {
276
297
  return {
277
298
  china: () => {
278
299
  return this.context.ready.then((axios) => {
279
- return axios.get(`/api/v2/coremde-sale/user/stat/china`);
280
- });
300
+ return axios.get(`/api/v2/coremde-sale/user/stat/china`)
301
+ })
281
302
  },
282
303
  }
283
304
  }
284
305
 
285
306
  async info() {
286
- var axios = await this.context.ready;
287
- var factory = await this.context.user.getSelectedFarm();
307
+ var axios = await this.context.ready
308
+ var factory = await this.context.user.getSelectedFarm()
288
309
  return axios.get(`/api/v1/user/info`, {
289
310
  params: {
290
- selected_factory: factory
291
- }
292
- });
311
+ selected_factory: factory,
312
+ },
313
+ })
293
314
  }
294
315
 
295
-
296
316
  async detail(userId: number) {
297
- var axios = await this.context.ready;
298
- return axios.get(`/api/v2/user/info/${userId}`);
317
+ var axios = await this.context.ready
318
+ return axios.get(`/api/v2/user/info/${userId}`)
299
319
  }
300
320
 
301
321
  // 待处理任务列表
302
322
  get task() {
303
323
  return {
304
324
  list: async (params: {
305
- pageNo: number,
306
- pageSize: number,
307
- taskTypeId: number,
308
- demandTimeStart: string,
309
- demandTimeEnd: string,
325
+ pageNo: number
326
+ pageSize: number
327
+ taskTypeId: number
328
+ demandTimeStart: string
329
+ demandTimeEnd: string
310
330
  applyUserId: number
311
331
  }) => {
312
- var axios = await this.context.ready;
313
- return axios.post('/api/v2/coremde-sale/task/list', params);
332
+ var axios = await this.context.ready
333
+ return axios.post('/api/v2/coremde-sale/task/list', params)
314
334
  },
315
335
  // 任务指派功能
316
336
  assign: (taskId: number, deptId: number, handleUserId: number = 0) => {
@@ -318,81 +338,89 @@ export class UserGateway extends Object {
318
338
  return axios.post('/api/v2/coremde-sale/task/assign', {
319
339
  taskId,
320
340
  deptId,
321
- handleUserId
322
- });
323
- });
341
+ handleUserId,
342
+ })
343
+ })
324
344
  },
325
345
  // 任务催单功能
326
- remind: (taskId: number, handleUserId: number = 0, remindNotes: string = "") => {
346
+ remind: (
347
+ taskId: number,
348
+ handleUserId: number = 0,
349
+ remindNotes: string = ''
350
+ ) => {
327
351
  return this.context.ready.then((axios) => {
328
352
  return axios.post('/api/v2/coremde-sale/task/remind', {
329
353
  taskId,
330
354
  handleUserId,
331
- remindNotes
332
- });
333
- });
355
+ remindNotes,
356
+ })
357
+ })
334
358
  },
335
359
  // 任务接单功能
336
360
  accept: (taskId: number) => {
337
361
  return this.context.ready.then((axios) => {
338
362
  return axios.get('/api/v2/coremde-sale/task/accept', {
339
363
  params: {
340
- taskId
341
- }
342
- });
343
- });
364
+ taskId,
365
+ },
366
+ })
367
+ })
344
368
  },
345
369
  // 任务审核功能
346
370
  approve: (params: {
347
- taskId: number,
348
- taskType: string,
349
- approveResult: number,
371
+ taskId: number
372
+ taskType: string
373
+ approveResult: number
350
374
  approveNotes?: string
351
375
  }) => {
352
376
  return this.context.ready.then((axios) => {
353
- return axios.post('/api/v2/coremde-sale/task/approve', params);
354
- });
355
- }
377
+ return axios.post('/api/v2/coremde-sale/task/approve', params)
378
+ })
379
+ },
380
+ // 创建任务-ljk
381
+ create: (params: any) => {
382
+ return this.context.ready.then((axios) => {
383
+ return axios.post('/api/v2/coremde-sale/task/create', params)
384
+ })
385
+ },
356
386
  }
357
387
  }
358
388
 
359
389
  //根据组织机构id获得该组织机构下所有人员
360
390
  listByGroup(groupId: number) {
361
391
  return this.context.ready.then((axios) => {
362
- return axios.get(`/api/v2/user/list/${groupId}`);
363
- });
392
+ return axios.get(`/api/v2/user/list/${groupId}`)
393
+ })
364
394
  }
365
395
 
366
396
  get position() {
367
397
  return {
368
398
  leader: () => {
369
399
  return this.context.ready.then((axios) => {
370
- return axios.get(`/api/v2/user/info/leader`);
371
- });
400
+ return axios.get(`/api/v2/user/info/leader`)
401
+ })
372
402
  },
373
403
  team: (searchName: string | undefined) => {
374
404
  return this.context.ready.then((axios) => {
375
405
  return axios.get(`/api/v2/user/info/team`, {
376
406
  params: {
377
- name: searchName
378
- }
379
- });
380
- });
407
+ name: searchName,
408
+ },
409
+ })
410
+ })
381
411
  },
382
412
  //同事
383
413
  colleague: () => {
384
414
  return this.context.ready.then((axios) => {
385
- return axios.get(`/api/v2/user/info/colleague`);
386
- });
415
+ return axios.get(`/api/v2/user/info/colleague`)
416
+ })
387
417
  },
388
418
  //根据部门获取同事
389
419
  byDept: (deptName: string) => {
390
420
  return this.context.ready.then((axios) => {
391
- return axios.get(`/api/v2/user/info/dept/${deptName}`);
392
- });
393
- }
394
- };
421
+ return axios.get(`/api/v2/user/info/dept/${deptName}`)
422
+ })
423
+ },
424
+ }
395
425
  }
396
-
397
-
398
426
  }