centaline-data-driven-v3 0.1.44 → 0.1.46

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.
@@ -846,14 +846,13 @@ const Base = function (source, moreActionRouter, formLabelPlacement) {
846
846
  || this.controlType === Enum.ControlType.MultiLineLabel) {
847
847
  }
848
848
  else if (this.isList || this.isScreen) {
849
-
850
849
  if (this.controlType === Enum.ControlType.SearchListBox || this.controlType === Enum.ControlType.ComboBox || this.controlType === Enum.ControlType.MultiSelectWithSearch || this.controlType === Enum.ControlType.MultiSelectNoSearch
851
850
  || this.controlType === Enum.ControlType.PhoneNumberText) {
852
851
  if (this.multiple) {
853
852
  this.value.splice(0);
854
853
  this.labelValue.splice(0);
855
854
  if (this.defaultCode1) {
856
- var defaultCode1=JSON.parse(this.defaultCode1)
855
+ var defaultCode1 = JSON.parse(this.defaultCode1)
857
856
  defaultCode1.forEach((v) => {
858
857
  this.value.push(v.code);
859
858
  this.labelValue.push(v);
@@ -876,20 +875,23 @@ const Base = function (source, moreActionRouter, formLabelPlacement) {
876
875
  if (this.defaultValue) {
877
876
  this.value = this.defaultValue;
878
877
  }
879
-
880
878
  }
881
879
  else if (this.controlType === Enum.ControlType.CheckBox || this.controlType === Enum.ControlType.Switch) {
882
880
  if (this.defaultCode1 == '1') {
883
881
  this.value = true
884
882
  }
885
-
886
883
  }
887
884
  this.code1 = this.defaultCode1 || '';
888
885
  this.code2 = this.defaultCode2 || '';
889
886
  this.name1 = this.defaultName1 || '';
890
- if (this.controlType === Enum.ControlType.SearchListBox && this.defaultCode1 && this.defaultName1) {
887
+ if ((this.controlType === Enum.ControlType.SearchListBox || this.controlType === Enum.ControlType.ComboBox
888
+ ) && this.defaultCode1 && this.defaultName1) {
891
889
  this.options = [{ value: this.code1, label: this.name1 }]
892
890
  }
891
+ if ((this.controlType === Enum.ControlType.MultiSelectWithSearch || this.controlType === Enum.ControlType.MultiSelectNoSearch
892
+ ) && this.defaultCode1) {
893
+ this.options = [].concat(JSON.parse(this.code1))
894
+ }
893
895
  }
894
896
  else {
895
897
  if (this.controlType === Enum.ControlType.DateRange
@@ -4,37 +4,37 @@ import request from '../../utils/request';
4
4
  import Router from './Router';
5
5
 
6
6
  function loadSearchTreeApi(action, searchModel) {
7
- return new Promise((resolve, reject) => {
8
- var apiData = searchModel?.searchData ? searchModel.searchData : {};
9
- request.postHandler(common.globalUri(),
10
- {
11
- action: action,
12
- para:
7
+ return new Promise((resolve, reject) => {
8
+ var apiData = searchModel?.searchData ? searchModel.searchData : {};
9
+ request.postHandler(common.globalUri(),
13
10
  {
14
- searchFields: apiData,
15
- pageAttribute: { pageIndex: 1 },
16
- flagSearch: true
17
- }
18
- }).then(
19
- function (response) {
20
- if (response.rtnCode === Enum.ReturnCode.Successful) {
21
- let rtn = loadSearchTreeModel(response);
22
- resolve(rtn);
23
-
24
- // if (callBack) {
25
- // callBack(rtn, resolve1, firstLoad);
26
- // }
11
+ action: action,
12
+ para:
13
+ {
14
+ searchFields: apiData,
15
+ pageAttribute: { pageIndex: 1 },
16
+ flagSearch: true
27
17
  }
28
- else {
29
- reject(response);
18
+ }).then(
19
+ function (response) {
20
+ if (response.rtnCode === Enum.ReturnCode.Successful) {
21
+ let rtn = loadSearchTreeModel(response);
22
+ resolve(rtn);
23
+
24
+ // if (callBack) {
25
+ // callBack(rtn, resolve1, firstLoad);
26
+ // }
27
+ }
28
+ else {
29
+ reject(response);
30
30
 
31
+ }
31
32
  }
32
- }
33
- );
34
- });
33
+ );
34
+ });
35
35
  }
36
36
  function loadSearchTreeModel(source, searchModel) {
37
- let rtn = {
37
+ let rtn = {
38
38
  searchModel: searchModel,
39
39
  get source() {
40
40
  return source;
@@ -94,15 +94,15 @@ function loadSearchTreeModel(source, searchModel) {
94
94
  },
95
95
  //组装查询条件
96
96
  searchData(fieldName1, _parentID, operation, searchDataType) {
97
- let rtn = {
98
- fields: []
97
+ let rtn = {
98
+ fields: []
99
99
  };
100
100
  rtn.fields.push({
101
- "fieldName1": fieldName1,
102
- "groupName": fieldName1,
103
- "operation": operation || 0,
104
- "searchDataType": searchDataType || 3,
105
- "searchValue1": _parentID
101
+ "fieldName1": fieldName1,
102
+ "groupName": fieldName1,
103
+ "operation": operation || 0,
104
+ "searchDataType": searchDataType || 3,
105
+ "searchValue1": _parentID
106
106
  });
107
107
  return rtn;
108
108
  },
@@ -128,8 +128,294 @@ function loadSearchTreeModel(source, searchModel) {
128
128
  };
129
129
  return rtn;
130
130
  }
131
+
132
+ function buildDeptTreeByField(flatList, opt = {}) {
133
+ const {
134
+ pathKey = 'path',
135
+ separator = '.',
136
+ sortKey = 'sort',
137
+ lazyMode = false
138
+ } = opt;
139
+
140
+ const firstItem = flatList.length > 0 ? flatList[0] : null;
141
+ const actualSortKey = firstItem && firstItem.hasOwnProperty(sortKey) ? sortKey : pathKey;
142
+
143
+ const sortedList = [...flatList].sort((a, b) => {
144
+ const aPath = a[pathKey] || '';
145
+ const bPath = b[pathKey] || '';
146
+ return aPath.length - bPath.length || aPath.localeCompare(bPath);
147
+ });
148
+
149
+ const pathMap = new Map();
150
+ const root = [];
151
+
152
+ for (const item of sortedList) {
153
+ const path = item[pathKey];
154
+ if (!path) continue;
155
+
156
+ const node = {
157
+ ...item,
158
+ children: [],
159
+ isLeaf: !lazyMode, // 默认非懒加载模式下为叶子节点
160
+ };
161
+
162
+ pathMap.set(path, node);
163
+
164
+ const lastDotIndex = path.lastIndexOf(separator);
165
+ if (lastDotIndex > -1) {
166
+ const parentPath = path.substring(0, lastDotIndex);
167
+ const parentNode = pathMap.get(parentPath);
168
+
169
+ if (parentNode) {
170
+ parentNode.children.push(node);
171
+ parentNode.isLeaf = false;
172
+ continue;
173
+ }
174
+ }
175
+
176
+ root.push(node);
177
+ }
178
+ // 如果不是懒加载模式,需要递归判断所有节点是否为叶子节点
179
+ if (!lazyMode) {
180
+ const determineIsLeaf = (node) => {
181
+ if (node.children && node.children.length > 0) {
182
+ // 递归处理子节点
183
+ node.children.forEach(determineIsLeaf);
184
+ // 有子节点,不是叶子节点
185
+ node.isLeaf = false;
186
+ } else {
187
+ // 没有子节点,是叶子节点
188
+ node.isLeaf = true;
189
+ }
190
+ };
191
+
192
+ root.forEach(determineIsLeaf);
193
+ }
194
+ const sortTree = (nodes) => {
195
+ nodes.sort((a, b) => {
196
+ const aVal = a[actualSortKey] || a[pathKey] || '';
197
+ const bVal = b[actualSortKey] || b[pathKey] || '';
198
+ return String(aVal).localeCompare(String(bVal));
199
+ });
200
+
201
+ nodes.forEach(node => {
202
+ if (node.children && node.children.length > 0) {
203
+ sortTree(node.children);
204
+ }
205
+ });
206
+ };
207
+
208
+ sortTree(root);
209
+
210
+ const hasAnyLeaf = root.some(n => !n.isLeaf);
211
+ return { tree: root, hasAnyLeaf };
212
+ }
213
+
214
+
215
+ // 获取前N层节点的 key
216
+ function getFirstNLevelKeys(treeData, level = 0) {
217
+ const keys = [];
218
+
219
+ function traverse(nodes, currentLevel) {
220
+ if (!nodes || nodes.length === 0 || currentLevel > level) return;
221
+
222
+ nodes.forEach(node => {
223
+ if (node.code) {
224
+ keys.push(node.code);
225
+ }
226
+
227
+ if (currentLevel < level && node.children && node.children.length > 0) {
228
+ traverse(node.children, currentLevel + 1);
229
+ }
230
+ });
231
+ }
232
+
233
+ traverse(treeData, 0);
234
+ return keys;
235
+ }
236
+ // 获取树中所有节点的 key
237
+ function getAllNodeKeys(treeData) {
238
+ const keys = [];
239
+
240
+ function traverse(nodes) {
241
+ if (!nodes || nodes.length === 0) return;
242
+
243
+ nodes.forEach(node => {
244
+ if (node.code) {
245
+ keys.push(node.code);
246
+ }
247
+
248
+ if (node.children && node.children.length > 0) {
249
+ traverse(node.children);
250
+ }
251
+ });
252
+ }
253
+
254
+ traverse(treeData);
255
+ return keys;
256
+ }
257
+
258
+ // 新增:构建节点Map,便于快速查找
259
+ function buildNodeCodeMap(nodes) {
260
+ const map = new Map();
261
+
262
+ function traverse(nodeList) {
263
+ nodeList.forEach(node => {
264
+ if (node.code) {
265
+ map.set(node.code, node);
266
+ }
267
+
268
+ if (node.children && node.children.length > 0) {
269
+ traverse(node.children);
270
+ }
271
+ });
272
+ }
273
+
274
+ traverse(nodes);
275
+ return map;
276
+ }
277
+
278
+ // 新增:复制节点(深拷贝)
279
+ function cloneNode(node) {
280
+ const cloned = { ...node };
281
+ cloned.children = [];
282
+ return cloned;
283
+ }
284
+
285
+ // 检查是否有有效的搜索条件
286
+ function checkHasValidSearchConditions(filter) {
287
+ if (!filter) return false;
288
+
289
+ let searchConditions = [];
290
+
291
+ if (filter?.searchData?.fields) {
292
+ searchConditions = filter.searchData.fields;
293
+ } else if (filter?.fields) {
294
+ searchConditions = filter.fields;
295
+ }
296
+
297
+ const validConditions = filterValidConditions(searchConditions);
298
+ return validConditions && validConditions.length > 0;
299
+ }
300
+ // 过滤掉 operation 为 1 的条件
301
+ function filterValidConditions(conditions) {
302
+ if (!conditions || !Array.isArray(conditions)) return [];
303
+
304
+ return conditions.filter(condition => {
305
+ return condition.operation !== 1;
306
+ });
307
+ }
308
+
309
+ // 判断节点是否匹配所有搜索条件
310
+ function nodeMatchesAllConditions(node, conditions) {
311
+ const validConditions = filterValidConditions(conditions);
312
+
313
+ if (!validConditions || validConditions.length === 0) return true;
314
+
315
+ return validConditions.every(condition => {
316
+ const { fieldName1, operation, searchValue1, searchValue2, searchDataType } = condition;
317
+ let nodeValue = node[fieldName1];
318
+
319
+ if (nodeValue === undefined) {
320
+ const mappedField = Object.keys(node).find(key =>
321
+ key.toLowerCase() === fieldName1.toLowerCase()
322
+ );
323
+ if (mappedField) {
324
+ nodeValue = node[mappedField];
325
+ } else {
326
+ return false;
327
+ }
328
+ }
329
+
330
+ const strNodeValue = String(nodeValue || '').toLowerCase();
331
+ const strSearchValue = String(searchValue1 || '').toLowerCase();
332
+
333
+ switch (operation) {
334
+ case 2:
335
+ return strNodeValue === strSearchValue;
336
+ case 3:
337
+ return strNodeValue !== strSearchValue;
338
+ case 4:
339
+ return Number(nodeValue) > Number(searchValue1);
340
+ case 5:
341
+ return Number(nodeValue) >= Number(searchValue1);
342
+ case 6:
343
+ return Number(nodeValue) < Number(searchValue1);
344
+ case 7:
345
+ return Number(nodeValue) <= Number(searchValue1);
346
+ case 8:
347
+ return strNodeValue.includes(strSearchValue);
348
+ case 9:
349
+ return strNodeValue.startsWith(strSearchValue);
350
+ case 10:
351
+ return strNodeValue.endsWith(strSearchValue);
352
+ case 11:
353
+ return !strNodeValue.includes(strSearchValue);
354
+ case 12:
355
+ try {
356
+ const regex = new RegExp(searchValue1, 'i');
357
+ return regex.test(nodeValue);
358
+ } catch (e) {
359
+ console.warn('正则表达式错误:', e);
360
+ return false;
361
+ }
362
+ case 13:
363
+ if (!searchValue1) return false;
364
+ try {
365
+ const values = searchValue1.split(',').map(v => v.trim().toLowerCase());
366
+ return values.includes(strNodeValue);
367
+ } catch (e) {
368
+ console.warn('解析IN条件错误:', e);
369
+ return false;
370
+ }
371
+ case 14:
372
+ if (!searchValue1) return true;
373
+ try {
374
+ const values = searchValue1.split(',').map(v => v.trim().toLowerCase());
375
+ return !values.includes(strNodeValue);
376
+ } catch (e) {
377
+ console.warn('解析NotIN条件错误:', e);
378
+ return false;
379
+ }
380
+ default:
381
+ return false;
382
+ }
383
+ });
384
+ }
385
+
386
+ // 新增:检查节点是否在子树中
387
+ function isNodeInChildren(parentNode, targetCode) {
388
+ if (parentNode.code === targetCode) {
389
+ return false;
390
+ }
391
+
392
+ if (!parentNode.children || parentNode.children.length === 0) {
393
+ return false;
394
+ }
395
+
396
+ for (const child of parentNode.children) {
397
+ if (child.code === targetCode) {
398
+ return true;
399
+ }
400
+
401
+ if (isNodeInChildren(child, targetCode)) {
402
+ return true;
403
+ }
404
+ }
405
+
406
+ return false;
407
+ }
131
408
  const SearchStats = {
132
409
  loadSearchTreeApi,
133
- loadSearchTreeModel
410
+ loadSearchTreeModel,
411
+ buildDeptTreeByField,
412
+ getFirstNLevelKeys,
413
+ getAllNodeKeys,
414
+ buildNodeCodeMap,
415
+ cloneNode,
416
+ checkHasValidSearchConditions,
417
+ filterValidConditions,
418
+ nodeMatchesAllConditions,
419
+ isNodeInChildren,
134
420
  };
135
421
  export default SearchStats;
package/src/main.js CHANGED
@@ -22,7 +22,7 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
22
22
 
23
23
  app.use(centaline, {
24
24
  //baseUrl: "http://10.88.22.13:7080/ibs-api/",
25
- baseUrl:"http://hkibswcfha01.centaline.com/mvc/api/",
25
+ baseUrl:"http://10.88.22.13:7070/onecard-api/",
26
26
  //baseUrl: "https://kq-api.centaline.com.cn/onecard-api/",
27
27
  //baseUrl: "http://10.88.22.13:6060/onecard-api/",
28
28
  //baseUrl: "http://10.88.22.66/IBS.Mvc/api/",
@@ -66,8 +66,8 @@ app.use(centaline, {
66
66
  getRequestHeaders: function () {
67
67
  return {
68
68
 
69
- //AuthorizationCode:'Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQxZTM1MGE1LWFiMGMtNDY2Mi05MTQ5LTAwYTQ4NTljMDkyYSJ9.3ci0CpgcmIqm-ORf9efFnvB6sgAWVSGv6ptrWMe3ZSs3fQ8PvlZv3BizhcBJjk0l7csA2Ihw9oodq2N81ELUoQ',
70
- authobject: '{EmpID:"Token_fce238af-47db-4fd9-9b14-f3ffb4767b55",MachineCode:"503aad67-3233-4256-8907-3e7d520245dc",SSO_Token:"SSOToken_fce238af-47db-4fd9-9b14-f3ffb4767b55",Platform:"WEB"}',
69
+ //AuthorizationCode:'Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyaWQiOiIyNTEyMTUxNzQyMTg5QzI4MTgwRDkxRTk0MDhEOTA0QSIsImxvZ2luX3VzZXJfa2V5IjoiN2MzYzNjNjAtNWVjMy00MzdkLWExMDYtOWYxZTMwYjU0Mjg2In0.daG9mS98Gg8KmHSUjYHktMcO2Jk7SVtCcqm2sRB0I8Y2N0TuonIrVUDcHdNdDiuD3v6qO_f010tQWlBsAQ1dqg',
70
+ authobject: '{token:"wufw-2008030035520409600",platform:"WEB"}',
71
71
  //authobject: '{EmpID:"Token_946d56e1-7972-4382-9d10-4a72496aab39",MachineCode:"ae184643-f8e2-453c-a752-ba82612b592f",SSO_Token:"SSOToken_946d56e1-7972-4382-9d10-4a72496aab39",Platform:"WEB"}',
72
72
  //oldToken: 'd92d4a3b-2274-42e8-96f0-100ffb579b6e',
73
73
  //authObject: '{token:"jiangzf-1958445358178844672",platform:"WEB"}',
@@ -77,7 +77,7 @@ const request = {
77
77
  if (data.rtnCode === Enum.ReturnCode.Successful) {
78
78
  if (data.rtnMsg && common.getDataDrivenOpts().showRequestSuccessMessage) {
79
79
  if (data.msgAlertStyle && data.msgAlertStyle == Enum.MessageAlertStyle.Dialog) {
80
- common.message(data.rtnMsg, 'error', '', 0, true)
80
+ common.message(data.rtnMsg, 'success', '', 0, true)
81
81
  }
82
82
  else {
83
83
  common.message(data.rtnMsg, 'success')
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <div id="form-app" class="data-driven" style="width:100%;height:100%;overflow:auto">
3
- <ct-form :api="'/Employee/readDetail'" :apiParam="apiParam"></ct-form>
3
+ <ct-form :api="'/employee/getLayoutOfPwd'" :apiParam="apiParam"></ct-form>
4
4
  <!-- <ct-textbox :source="source"></ct-textbox> -->
5
5
  <ct-dialoglist ref="dialogList"></ct-dialoglist>
6
6
  </div>
7
7
  </template>
8
8
  <script lang="ts" setup>
9
- const apiParam={"rowGUID":"{84373596-5043-4d58-935c-bc3559c8654f}","actionType":3}
9
+ const apiParam={actionType: 3,empId: "260104160031E4FF8D4434FD4400BAC9"}
10
10
  </script>