@ibiz-template/runtime 0.5.3 → 0.5.4

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.
Files changed (34) hide show
  1. package/dist/index.esm.js +87 -44
  2. package/dist/index.system.min.js +1 -1
  3. package/out/application.d.ts.map +1 -1
  4. package/out/application.js +4 -1
  5. package/out/controller/control/form/edit-form/edit-form.controller.js +1 -1
  6. package/out/controller/control/search-bar/search-bar.controller.d.ts +8 -1
  7. package/out/controller/control/search-bar/search-bar.controller.d.ts.map +1 -1
  8. package/out/controller/control/search-bar/search-bar.controller.js +41 -9
  9. package/out/controller/control/search-bar/search-bar.service.d.ts +4 -4
  10. package/out/controller/control/search-bar/search-bar.service.d.ts.map +1 -1
  11. package/out/controller/control/search-bar/search-bar.service.js +38 -19
  12. package/out/engine/md-view.engine.d.ts.map +1 -1
  13. package/out/engine/md-view.engine.js +3 -1
  14. package/out/interface/controller/controller/control/i-search-bar.controller.d.ts +8 -0
  15. package/out/interface/controller/controller/control/i-search-bar.controller.d.ts.map +1 -1
  16. package/out/interface/controller/state/control/i-search-bar.state.d.ts +36 -1
  17. package/out/interface/controller/state/control/i-search-bar.state.d.ts.map +1 -1
  18. package/out/plugin/remote-plugin-item/remote-plugin-item.d.ts +10 -0
  19. package/out/plugin/remote-plugin-item/remote-plugin-item.d.ts.map +1 -1
  20. package/out/service/mqtt/mqtt.service.d.ts.map +1 -1
  21. package/out/service/mqtt/mqtt.service.js +1 -4
  22. package/out/service/utils/dynamic-code-list/dynamic-code-list.d.ts.map +1 -1
  23. package/out/service/utils/dynamic-code-list/dynamic-code-list.js +6 -2
  24. package/package.json +2 -2
  25. package/src/application.ts +6 -1
  26. package/src/controller/control/form/edit-form/edit-form.controller.ts +1 -1
  27. package/src/controller/control/search-bar/search-bar.controller.ts +40 -9
  28. package/src/controller/control/search-bar/search-bar.service.ts +42 -20
  29. package/src/engine/md-view.engine.ts +5 -1
  30. package/src/interface/controller/controller/control/i-search-bar.controller.ts +9 -0
  31. package/src/interface/controller/state/control/i-search-bar.state.ts +41 -1
  32. package/src/plugin/remote-plugin-item/remote-plugin-item.ts +8 -0
  33. package/src/service/mqtt/mqtt.service.ts +1 -4
  34. package/src/service/utils/dynamic-code-list/dynamic-code-list.ts +7 -2
@@ -73,6 +73,14 @@ export class SearchBarController
73
73
  */
74
74
  isBackendSearchGroup = this.model.searchBarStyle === 'SEARCHBAR2';
75
75
 
76
+ /**
77
+ * 是否有默认选中
78
+ * @return {*}
79
+ * @author: zhujiamin
80
+ * @Date: 2023-12-21 10:17:43
81
+ */
82
+ hasDefaultSelect = false;
83
+
76
84
  /**
77
85
  * 启用自定义过滤项
78
86
  * @author lxm
@@ -148,12 +156,15 @@ export class SearchBarController
148
156
 
149
157
  // 实例部件服务
150
158
  if (this.isBackendSearchGroup && this.view.model.codeName) {
151
- this.service = new SearchBarService(this.model, this.view.model.codeName);
159
+ this.service = new SearchBarService(
160
+ this.model,
161
+ this.view.model.codeName.toLowerCase(),
162
+ );
152
163
  await this.service.init(this.context);
153
164
  }
154
165
 
155
166
  await this.initSearchBarFilters();
156
- await this.initSearBarGroups();
167
+ await this.initSearBarGroups(true);
157
168
  }
158
169
 
159
170
  /**
@@ -418,18 +429,21 @@ export class SearchBarController
418
429
  * @author: zhujiamin
419
430
  * @Date: 2023-12-19 14:43:46
420
431
  */
421
- async initSearBarGroups(): Promise<void> {
432
+ async initSearBarGroups(firstInit: boolean = false): Promise<void> {
422
433
  this.state.searchBarGroups = [];
423
434
  if (this.isBackendSearchGroup) {
424
435
  if (this.model.searchBarGroups && this.model.searchBarGroups.length > 0) {
425
436
  this.state.searchBarGroups = this.model.searchBarGroups.map(
426
437
  (item, index) => {
427
438
  const tempGroup = {
428
- ...item,
439
+ name: item.id!,
440
+ caption: item.caption,
429
441
  saved: false,
430
442
  show: true,
431
443
  searchGroupData: {} as IData,
432
444
  order: (index + 1) * 100,
445
+ defaultSelect: false,
446
+ noEdit: true,
433
447
  };
434
448
  if (item.data) {
435
449
  try {
@@ -455,6 +469,9 @@ export class SearchBarController
455
469
  ibiz.log.error(`${item.data}非标准JSON格式:`, error);
456
470
  }
457
471
  }
472
+ if (item.defaultGroup) {
473
+ tempGroup.defaultSelect = true;
474
+ }
458
475
  return tempGroup;
459
476
  },
460
477
  );
@@ -465,13 +482,13 @@ export class SearchBarController
465
482
  res.data.forEach((group: IData) => {
466
483
  // 已经存在的覆盖,否则新增
467
484
  const existGroup = this.state.searchBarGroups.find(
468
- item => item.id === group.id,
485
+ item => item.name === group.name,
469
486
  );
470
487
  if (existGroup) {
471
488
  mergeInLeft(existGroup, group);
472
489
  existGroup.saved = true;
473
490
  } else {
474
- // 找出最大的order项的下标index,然后+2新增
491
+ // 找出最大的order项的下标index,然后+2新增(第n项order为(n+1)*100)
475
492
  const tempMaxOrderIndex = this.state.searchBarGroups.reduce(
476
493
  (maxIndex, item, currentIndex) =>
477
494
  item.order > this.state.searchBarGroups[maxIndex].order
@@ -480,7 +497,6 @@ export class SearchBarController
480
497
  0,
481
498
  );
482
499
  this.state.searchBarGroups.push({
483
- appId: this.context.srfappid,
484
500
  saved: true,
485
501
  show: true,
486
502
  searchGroupData: {},
@@ -497,6 +513,20 @@ export class SearchBarController
497
513
  this.state.searchBarGroups.forEach((item, index) => {
498
514
  item.order = (index + 1) * 100;
499
515
  });
516
+ // 设置默认选中
517
+ if (
518
+ firstInit &&
519
+ this.state.searchBarGroups &&
520
+ this.state.searchBarGroups.length > 0
521
+ ) {
522
+ const defaultSelectedGroup = this.state.searchBarGroups.find(group => {
523
+ return group.defaultSelect;
524
+ });
525
+ if (defaultSelectedGroup) {
526
+ this.hasDefaultSelect = true;
527
+ this.handleGroupClick(defaultSelectedGroup);
528
+ }
529
+ }
500
530
  }
501
531
  }
502
532
 
@@ -524,14 +554,15 @@ export class SearchBarController
524
554
  ibiz.message.success('保存成功');
525
555
  } else {
526
556
  const res = await this.service.createWithParams(
527
- this.state.selectedSearchGroupItem.id!,
557
+ this.state.selectedSearchGroupItem,
528
558
  saveParams,
529
559
  );
530
560
  if (res.ok) {
531
561
  const savedGroup = this.state.searchBarGroups.find(
532
- group => group.id === res.data.id,
562
+ group => group.name === res.data.name,
533
563
  );
534
564
  if (savedGroup) {
565
+ mergeInLeft(savedGroup, res.data);
535
566
  savedGroup.saved = true;
536
567
  }
537
568
  ibiz.message.success('保存成功');
@@ -1,6 +1,6 @@
1
1
  import { IHttpResponse } from '@ibiz-template/core';
2
2
  import { ISearchBar } from '@ibiz/model-core';
3
- import { IAppService } from '../../../interface';
3
+ import { IAppService, IBackendSearchBarGroup } from '../../../interface';
4
4
 
5
5
  /**
6
6
  * 搜索栏服务
@@ -53,8 +53,16 @@ export class SearchBarService {
53
53
  *
54
54
  */
55
55
  async fetch(): Promise<IHttpResponse> {
56
- const res = await this.app.net.post(`${this.themeUrl}/fetch_default`, {
57
- app_view_tag: this.viewTag,
56
+ const searchconds = [
57
+ {
58
+ condop: 'EQ',
59
+ condtype: 'DEFIELD',
60
+ fieldname: 'app_view_tag',
61
+ value: this.viewTag,
62
+ },
63
+ ];
64
+ const res = await this.app.net.post(`${this.themeUrl}/fetch_cur_user_all`, {
65
+ searchconds,
58
66
  sort: 'create_time,asc',
59
67
  });
60
68
  if (res.ok) {
@@ -68,9 +76,7 @@ export class SearchBarService {
68
76
  *
69
77
  */
70
78
  async get(id: string): Promise<IHttpResponse> {
71
- const res = await this.app.net.get(`${this.themeUrl}/${id}`, {
72
- app_view_tag: this.viewTag,
73
- });
79
+ const res = await this.app.net.get(`${this.themeUrl}/${id}`);
74
80
  if (res.ok) {
75
81
  [res.data] = this.convertBackDataToFront([res.data] as IData[]);
76
82
  }
@@ -82,34 +88,39 @@ export class SearchBarService {
82
88
  *
83
89
  */
84
90
  async remove(id: string): Promise<IHttpResponse> {
85
- const res = await this.app.net.delete(`${this.themeUrl}/${id}`, {
86
- app_view_tag: this.viewTag,
87
- });
91
+ const res = await this.app.net.delete(`${this.themeUrl}/${id}`);
88
92
  return res;
89
93
  }
90
94
 
91
95
  /**
92
- * 新建数据
96
+ * 新建数据(只有一个标题)
93
97
  *
94
98
  */
95
99
  async create(caption: string): Promise<IHttpResponse> {
96
100
  const res = await this.app.net.post(`${this.themeUrl}`, {
97
- name: caption,
101
+ name: `${this.viewTag}___${caption}`,
102
+ caption,
103
+ app_tag: this.model.appId,
98
104
  app_view_tag: this.viewTag,
99
105
  });
100
106
  return res;
101
107
  }
102
108
 
103
109
  /**
104
- * 新建数据(带参数,给平台配置建立的分组用)
110
+ * 新建数据(带参数,给平台配置建立的分组用,分组项名称就是id)
105
111
  *
106
112
  */
107
- async createWithParams(id: string, data: IData): Promise<IHttpResponse> {
113
+ async createWithParams(
114
+ group: IBackendSearchBarGroup,
115
+ data: IData,
116
+ ): Promise<IHttpResponse> {
108
117
  const res = await this.app.net.post(`${this.themeUrl}`, {
109
- id,
110
- theme_model: JSON.stringify(data),
118
+ name: group.name,
119
+ caption: group.caption,
120
+ app_tag: this.model.appId,
111
121
  app_view_tag: this.viewTag,
112
- show: data.show,
122
+ theme_model: JSON.stringify(data),
123
+ valid_flag: group.show ? 1 : 0,
113
124
  });
114
125
  return res;
115
126
  }
@@ -164,8 +175,14 @@ export class SearchBarService {
164
175
  convertBackDataToFront(data: IData[]): IData[] {
165
176
  return data.map(item => {
166
177
  const tempItem = { ...item };
178
+ if (item.id) {
179
+ tempItem.id = item.id;
180
+ }
167
181
  if (item.name) {
168
- tempItem.caption = item.name;
182
+ tempItem.name = item.name;
183
+ }
184
+ if (item.caption) {
185
+ tempItem.caption = item.caption;
169
186
  }
170
187
  if (item.theme_model) {
171
188
  tempItem.searchGroupData = JSON.parse(item.theme_model);
@@ -190,12 +207,17 @@ export class SearchBarService {
190
207
  convertFrontDataToBack(data: IData[]): IData[] {
191
208
  return data.map(item => {
192
209
  const tempItem: IData = {
193
- appId: item.appId,
210
+ app_tag: this.model.appId,
194
211
  app_view_tag: this.viewTag,
195
- id: item.id,
196
212
  };
213
+ if (item.id) {
214
+ tempItem.id = item.id;
215
+ }
216
+ if (item.name) {
217
+ tempItem.name = item.name;
218
+ }
197
219
  if (item.caption) {
198
- tempItem.name = item.caption;
220
+ tempItem.caption = item.caption;
199
221
  }
200
222
  if (
201
223
  item.searchGroupData &&
@@ -139,7 +139,11 @@ export class MDViewEngine extends ViewEngineBase {
139
139
  }
140
140
 
141
141
  // 默认加载
142
- if (!this.view.state.noLoadDefault && model.loadDefault) {
142
+ if (
143
+ !this.view.state.noLoadDefault &&
144
+ model.loadDefault &&
145
+ !this.searchBar.hasDefaultSelect
146
+ ) {
143
147
  this.load();
144
148
  }
145
149
  }
@@ -21,4 +21,13 @@ export interface ISearchBarController
21
21
  * @returns {*} {IParams}
22
22
  */
23
23
  getFilterParams(): IParams;
24
+
25
+ /**
26
+ * 有默认选中分组
27
+ *
28
+ * @author lxm
29
+ * @date 2022-09-22 17:09:21
30
+ * @returns {*} {IParams}
31
+ */
32
+ hasDefaultSelect: boolean;
24
33
  }
@@ -155,7 +155,31 @@ export interface ISearchGroupData {
155
155
  * 后台分组接口
156
156
  *
157
157
  */
158
- export interface IBackendSearchBarGroup extends ISearchBarGroup {
158
+ export interface IBackendSearchBarGroup {
159
+ /**
160
+ * 唯一标识
161
+ * @return {*}
162
+ * @author: zhujiamin
163
+ * @Date: 2024-01-17 18:28:45
164
+ */
165
+ id?: string;
166
+
167
+ /**
168
+ * 标题
169
+ * @return {*}
170
+ * @author: zhujiamin
171
+ * @Date: 2023-12-22 14:25:09
172
+ */
173
+ caption?: string;
174
+
175
+ /**
176
+ * 分组项名称(模型的id, 新建的为viewtag___caption)
177
+ * @return {*}
178
+ * @author: zhujiamin
179
+ * @Date: 2023-12-22 14:25:09
180
+ */
181
+ name: string;
182
+
159
183
  /**
160
184
  * 是否保存过
161
185
  * @return {*}
@@ -187,4 +211,20 @@ export interface IBackendSearchBarGroup extends ISearchBarGroup {
187
211
  * @Date: 2023-12-21 11:24:21
188
212
  */
189
213
  searchGroupData: ISearchGroupData;
214
+
215
+ /**
216
+ * 是否默认选中
217
+ * @return {*}
218
+ * @author: zhujiamin
219
+ * @Date: 2023-12-21 11:24:21
220
+ */
221
+ defaultSelect?: boolean;
222
+
223
+ /**
224
+ * 是否不可编辑
225
+ * @return {*}
226
+ * @author: zhujiamin
227
+ * @Date: 2024-01-17 17:24:28
228
+ */
229
+ noEdit?: boolean;
190
230
  }
@@ -15,6 +15,14 @@ export interface ISystemImportMap {
15
15
  * @type {string}
16
16
  */
17
17
  baseUrl?: string;
18
+ /**
19
+ * package.json 清单
20
+ *
21
+ * @author chitanda
22
+ * @date 2024-01-11 20:01:57
23
+ * @type {{ [key: string]: string }}
24
+ */
25
+ packages: { [key: string]: string };
18
26
  /**
19
27
  * 脚本
20
28
  *
@@ -1,6 +1,6 @@
1
1
  import { IPortalMessage } from '@ibiz-template/core';
2
2
  import { MqttClient, IClientOptions } from 'mqtt';
3
- import { QXEvent, createUUID, isNilOrEmpty } from 'qx-util';
3
+ import { QXEvent, createUUID } from 'qx-util';
4
4
 
5
5
  /**
6
6
  * mqtt 连接服务
@@ -63,9 +63,6 @@ export class MqttService {
63
63
  protected token: string,
64
64
  protected appId: string,
65
65
  ) {
66
- if (isNilOrEmpty(mqttTopic) || isNilOrEmpty(token)) {
67
- throw new Error('mqttTopic or token is empty');
68
- }
69
66
  this.options.username = mqttTopic;
70
67
  this.options.password = token;
71
68
  }
@@ -248,9 +248,14 @@ export class DynamicCodeListCache {
248
248
  }
249
249
 
250
250
  // *预定义加载
251
- if (this.isPredefined) {
251
+ if (this.isPredefined && this.codeList.codeName) {
252
+ const index = this.codeList.codeName.indexOf('__');
253
+ const tag =
254
+ index !== -1
255
+ ? this.codeList.codeName.substring(index + 2)
256
+ : this.codeList.codeName;
252
257
  const res = await app.net.get(
253
- `/dictionaries/codelist/${this.codeList.codeName}`,
258
+ `/dictionaries/codelist/${tag}`,
254
259
  tempParams,
255
260
  );
256
261
  return Object.freeze(res.data.items);