centaline-data-driven-v3 0.1.43 → 0.1.45
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/centaline-data-driven-v3.umd.js +114 -114
- package/package.json +1 -1
- package/src/assets/commonWeb.css +7 -1
- package/src/components/web/Label.vue +1 -0
- package/src/components/web/SearchList/SearchTable.vue +2 -2
- package/src/components/web/TextBox.vue +1 -1
- package/src/components/web/Tree/Tree.vue +499 -368
- package/src/loader/src/Tree.js +304 -33
- package/src/main.js +4 -4
- package/src/views/Form.vue +2 -2
package/src/loader/src/Tree.js
CHANGED
|
@@ -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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
|
|
98
|
-
|
|
97
|
+
let rtn = {
|
|
98
|
+
fields: []
|
|
99
99
|
};
|
|
100
100
|
rtn.fields.push({
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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,279 @@ function loadSearchTreeModel(source, searchModel) {
|
|
|
128
128
|
};
|
|
129
129
|
return rtn;
|
|
130
130
|
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
function buildDeptTreeByField(flatList, opt = {}) {
|
|
134
|
+
const {
|
|
135
|
+
pathKey = 'path',
|
|
136
|
+
separator = '.',
|
|
137
|
+
sortKey = 'sort'
|
|
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: true
|
|
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
|
+
const sortTree = (nodes) => {
|
|
180
|
+
nodes.sort((a, b) => {
|
|
181
|
+
const aVal = a[actualSortKey] || a[pathKey] || '';
|
|
182
|
+
const bVal = b[actualSortKey] || b[pathKey] || '';
|
|
183
|
+
return String(aVal).localeCompare(String(bVal));
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
nodes.forEach(node => {
|
|
187
|
+
if (node.children && node.children.length > 0) {
|
|
188
|
+
sortTree(node.children);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
sortTree(root);
|
|
194
|
+
|
|
195
|
+
const hasAnyLeaf = root.some(n => !n.isLeaf);
|
|
196
|
+
return { tree: root, hasAnyLeaf };
|
|
197
|
+
}
|
|
198
|
+
function getFirstNLevelKeys(nodes, targetLevel = 1) {
|
|
199
|
+
const result = [];
|
|
200
|
+
|
|
201
|
+
if (!nodes || nodes.length === 0 || targetLevel < 0) {
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const traverse = (nodes, currentLevel) => {
|
|
206
|
+
if (currentLevel > targetLevel || !nodes) return;
|
|
207
|
+
|
|
208
|
+
nodes.forEach(node => {
|
|
209
|
+
if (node.code) {
|
|
210
|
+
result.push(node.code);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// 如果还有下一层且没超过目标层级,继续遍历
|
|
214
|
+
if (currentLevel < targetLevel && node.children && node.children.length > 0) {
|
|
215
|
+
traverse(node.children, currentLevel + 1);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
traverse(nodes, 0);
|
|
221
|
+
return result;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// 递归获取所有节点的key(用于搜索时全展开)
|
|
225
|
+
function getAllNodeKeys(nodes, result = []) {
|
|
226
|
+
if (!nodes || nodes.length === 0) {
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
nodes.forEach(node => {
|
|
231
|
+
if (node.code) {
|
|
232
|
+
result.push(node.code);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (node.children && node.children.length > 0) {
|
|
236
|
+
getAllNodeKeys(node.children, result);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// 新增:构建节点Map,便于快速查找
|
|
244
|
+
function buildNodeCodeMap(nodes) {
|
|
245
|
+
const map = new Map();
|
|
246
|
+
|
|
247
|
+
function traverse(nodeList) {
|
|
248
|
+
nodeList.forEach(node => {
|
|
249
|
+
if (node.code) {
|
|
250
|
+
map.set(node.code, node);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (node.children && node.children.length > 0) {
|
|
254
|
+
traverse(node.children);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
traverse(nodes);
|
|
260
|
+
return map;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// 新增:复制节点(深拷贝)
|
|
264
|
+
function cloneNode(node) {
|
|
265
|
+
const cloned = { ...node };
|
|
266
|
+
cloned.children = [];
|
|
267
|
+
return cloned;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// 检查是否有有效的搜索条件
|
|
271
|
+
function checkHasValidSearchConditions(filter) {
|
|
272
|
+
if (!filter) return false;
|
|
273
|
+
|
|
274
|
+
let searchConditions = [];
|
|
275
|
+
|
|
276
|
+
if (filter?.searchData?.fields) {
|
|
277
|
+
searchConditions = filter.searchData.fields;
|
|
278
|
+
} else if (filter?.fields) {
|
|
279
|
+
searchConditions = filter.fields;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const validConditions = filterValidConditions(searchConditions);
|
|
283
|
+
return validConditions && validConditions.length > 0;
|
|
284
|
+
}
|
|
285
|
+
// 过滤掉 operation 为 1 的条件
|
|
286
|
+
function filterValidConditions(conditions) {
|
|
287
|
+
if (!conditions || !Array.isArray(conditions)) return [];
|
|
288
|
+
|
|
289
|
+
return conditions.filter(condition => {
|
|
290
|
+
return condition.operation !== 1;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// 判断节点是否匹配所有搜索条件
|
|
295
|
+
function nodeMatchesAllConditions(node, conditions) {
|
|
296
|
+
const validConditions = filterValidConditions(conditions);
|
|
297
|
+
|
|
298
|
+
if (!validConditions || validConditions.length === 0) return true;
|
|
299
|
+
|
|
300
|
+
return validConditions.every(condition => {
|
|
301
|
+
const { fieldName1, operation, searchValue1, searchValue2, searchDataType } = condition;
|
|
302
|
+
let nodeValue = node[fieldName1];
|
|
303
|
+
|
|
304
|
+
if (nodeValue === undefined) {
|
|
305
|
+
const mappedField = Object.keys(node).find(key =>
|
|
306
|
+
key.toLowerCase() === fieldName1.toLowerCase()
|
|
307
|
+
);
|
|
308
|
+
if (mappedField) {
|
|
309
|
+
nodeValue = node[mappedField];
|
|
310
|
+
} else {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const strNodeValue = String(nodeValue || '').toLowerCase();
|
|
316
|
+
const strSearchValue = String(searchValue1 || '').toLowerCase();
|
|
317
|
+
|
|
318
|
+
switch (operation) {
|
|
319
|
+
case 2:
|
|
320
|
+
return strNodeValue === strSearchValue;
|
|
321
|
+
case 3:
|
|
322
|
+
return strNodeValue !== strSearchValue;
|
|
323
|
+
case 4:
|
|
324
|
+
return Number(nodeValue) > Number(searchValue1);
|
|
325
|
+
case 5:
|
|
326
|
+
return Number(nodeValue) >= Number(searchValue1);
|
|
327
|
+
case 6:
|
|
328
|
+
return Number(nodeValue) < Number(searchValue1);
|
|
329
|
+
case 7:
|
|
330
|
+
return Number(nodeValue) <= Number(searchValue1);
|
|
331
|
+
case 8:
|
|
332
|
+
return strNodeValue.includes(strSearchValue);
|
|
333
|
+
case 9:
|
|
334
|
+
return strNodeValue.startsWith(strSearchValue);
|
|
335
|
+
case 10:
|
|
336
|
+
return strNodeValue.endsWith(strSearchValue);
|
|
337
|
+
case 11:
|
|
338
|
+
return !strNodeValue.includes(strSearchValue);
|
|
339
|
+
case 12:
|
|
340
|
+
try {
|
|
341
|
+
const regex = new RegExp(searchValue1, 'i');
|
|
342
|
+
return regex.test(nodeValue);
|
|
343
|
+
} catch (e) {
|
|
344
|
+
console.warn('正则表达式错误:', e);
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
case 13:
|
|
348
|
+
if (!searchValue1) return false;
|
|
349
|
+
try {
|
|
350
|
+
const values = searchValue1.split(',').map(v => v.trim().toLowerCase());
|
|
351
|
+
return values.includes(strNodeValue);
|
|
352
|
+
} catch (e) {
|
|
353
|
+
console.warn('解析IN条件错误:', e);
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
case 14:
|
|
357
|
+
if (!searchValue1) return true;
|
|
358
|
+
try {
|
|
359
|
+
const values = searchValue1.split(',').map(v => v.trim().toLowerCase());
|
|
360
|
+
return !values.includes(strNodeValue);
|
|
361
|
+
} catch (e) {
|
|
362
|
+
console.warn('解析NotIN条件错误:', e);
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
default:
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// 新增:检查节点是否在子树中
|
|
372
|
+
function isNodeInChildren(parentNode, targetCode) {
|
|
373
|
+
if (parentNode.code === targetCode) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (!parentNode.children || parentNode.children.length === 0) {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
for (const child of parentNode.children) {
|
|
382
|
+
if (child.code === targetCode) {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (isNodeInChildren(child, targetCode)) {
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
131
393
|
const SearchStats = {
|
|
132
394
|
loadSearchTreeApi,
|
|
133
|
-
loadSearchTreeModel
|
|
395
|
+
loadSearchTreeModel,
|
|
396
|
+
buildDeptTreeByField,
|
|
397
|
+
getFirstNLevelKeys,
|
|
398
|
+
getAllNodeKeys,
|
|
399
|
+
buildNodeCodeMap,
|
|
400
|
+
cloneNode,
|
|
401
|
+
checkHasValidSearchConditions,
|
|
402
|
+
filterValidConditions,
|
|
403
|
+
nodeMatchesAllConditions,
|
|
404
|
+
isNodeInChildren,
|
|
134
405
|
};
|
|
135
406
|
export default SearchStats;
|
package/src/main.js
CHANGED
|
@@ -21,8 +21,8 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
app.use(centaline, {
|
|
24
|
-
baseUrl: "
|
|
25
|
-
|
|
24
|
+
//baseUrl: "http://10.88.22.13:7080/ibs-api/",
|
|
25
|
+
baseUrl:"http://10.88.22.57:28251/service-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
|
-
|
|
70
|
-
authobject: '{token:"
|
|
69
|
+
AuthorizationCode:'Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyaWQiOiIyNTEyMTUxNzQyMTg5QzI4MTgwRDkxRTk0MDhEOTA0QSIsImxvZ2luX3VzZXJfa2V5IjoiN2MzYzNjNjAtNWVjMy00MzdkLWExMDYtOWYxZTMwYjU0Mjg2In0.daG9mS98Gg8KmHSUjYHktMcO2Jk7SVtCcqm2sRB0I8Y2N0TuonIrVUDcHdNdDiuD3v6qO_f010tQWlBsAQ1dqg',
|
|
70
|
+
authobject: '{"currentEstate":{},"platform":1,"osVersion":"","clientVersion":"","machineCode":"f43f90f1caf5e3960a12e17aebd80b67","token":"","random":"tBBZub","time":1767510778671,"sign":""}',
|
|
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"}',
|
package/src/views/Form.vue
CHANGED
|
@@ -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="'/
|
|
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={
|
|
9
|
+
const apiParam={actionType: 3,empId: "260104160031E4FF8D4434FD4400BAC9"}
|
|
10
10
|
</script>
|