centaline-data-driven-v3 0.1.42 → 0.1.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "centaline-data-driven-v3",
3
- "version": "0.1.42",
3
+ "version": "0.1.44",
4
4
  "private": false,
5
5
  "description": "centaline-data-driven-v3",
6
6
  "main": "dist/centaline-data-driven-v3.umd.js",
@@ -587,6 +587,11 @@ body {
587
587
  background-color: inherit;
588
588
  }
589
589
 
590
+ .ct-table .left-fixation .el-checkbox {
591
+ padding: 0px;
592
+ vertical-align: -2px;
593
+ }
594
+
590
595
  .ct-table .right-fixation {
591
596
  position: sticky;
592
597
  background-color: inherit;
@@ -780,7 +785,8 @@ body {
780
785
  user-select: none;
781
786
  /* 禁止文本选择 */
782
787
  }
783
- .ct-form .btnPadBom .el-checkbox{
788
+
789
+ .ct-form .btnPadBom .el-checkbox {
784
790
  height: 100% !important;
785
791
  padding: 0 !important;
786
792
  }
@@ -29,7 +29,7 @@
29
29
  :rowspan="model.multiRowSpan" class="ct-td left-fixation-th checkbox-td"
30
30
  :class="[model.tdClass]">
31
31
  <el-checkbox v-model="model.selectAll" :indeterminate="model.isIndeterminate"
32
- size="default" @change="selectAll"></el-checkbox>
32
+ size="small" @change="selectAll"></el-checkbox>
33
33
  </th>
34
34
  <template v-for="(column, colIndex) in columns" :key="colIndex">
35
35
  <th v-if="column.show" class="ct-td ct-searchtable-th" :rowspan="column.rowspan"
@@ -70,7 +70,7 @@
70
70
  align="center">
71
71
  <el-checkbox
72
72
  v-if="!model.rightCheckBoxColumn || common.getDataOfUpperLower(row, model.rightCheckBoxColumn) == 1"
73
- v-model="row.$select" @change="selectRow()" size="default" />
73
+ v-model="row.$select" @change="selectRow()" size="small" />
74
74
 
75
75
  </td>
76
76
  <template v-for="(column, colIndex) in model.dataFieldcolumns" :key="colIndex">
@@ -103,6 +103,7 @@ const fullTreeData = ref([])
103
103
  // 新增:缓存所有节点的Map,用于快速查找
104
104
  const nodeCodeMap = ref(new Map())
105
105
 
106
+ const isExpandAll = ref(false);
106
107
  /** 动态设置Input Ref */
107
108
  const handleSetInputMap = (el: refItem, item) => {
108
109
  if (el) {
@@ -118,22 +119,29 @@ onBeforeUnmount(() => {
118
119
  }
119
120
  })
120
121
 
121
- // 递归获取前两级节点的key
122
- function getFirstTwoLevelKeys(nodes, level = 0, result = []) {
123
- if (!nodes || nodes.length === 0 || level >= 1) {
122
+ function getFirstNLevelKeys(nodes, targetLevel = 1) {
123
+ const result = [];
124
+
125
+ if (!nodes || nodes.length === 0 || targetLevel < 0) {
124
126
  return result;
125
127
  }
126
128
 
127
- nodes.forEach(node => {
128
- if (node.code) {
129
- result.push(node.code);
130
- }
129
+ const traverse = (nodes, currentLevel) => {
130
+ if (currentLevel > targetLevel || !nodes) return;
131
131
 
132
- if (level < 1 && node.children && node.children.length > 0) {
133
- getFirstTwoLevelKeys(node.children, level + 1, result);
134
- }
135
- });
132
+ nodes.forEach(node => {
133
+ if (node.code) {
134
+ result.push(node.code);
135
+ }
136
+
137
+ // 如果还有下一层且没超过目标层级,继续遍历
138
+ if (currentLevel < targetLevel && node.children && node.children.length > 0) {
139
+ traverse(node.children, currentLevel + 1);
140
+ }
141
+ });
142
+ };
136
143
 
144
+ traverse(nodes, 0);
137
145
  return result;
138
146
  }
139
147
 
@@ -163,10 +171,36 @@ function setDefaultExpandedNodes() {
163
171
  }
164
172
 
165
173
  if (isSearching.value) {
174
+ isExpandAll.value = true;
166
175
  const allKeys = getAllNodeKeys(fullTreeData.value);
167
176
  defaultExpandedKeys.value = allKeys;
168
177
  } else {
169
- defaultExpandedKeys.value = getFirstTwoLevelKeys(fullTreeData.value);
178
+ isExpandAll.value = false;
179
+ // 检查是否有全展开搜索条件
180
+ const expandValue = findSearchFieldValue(screenPara.value, 'expanded', {
181
+ caseInsensitive: true, // 添加不区分大小写的选项
182
+ keyFields: ['fieldName1', 'groupName', 'fieldLabel'] // 扩展可能的key字段
183
+ });
184
+
185
+ // 如果找到expanded=all的搜索条件,设置全展开
186
+ if (expandValue && expandValue.toString().toLowerCase() === 'all') {
187
+ isExpandAll.value = true;
188
+ const allKeys = getAllNodeKeys(fullTreeData.value);
189
+ defaultExpandedKeys.value = allKeys;
190
+ } else {
191
+ // 处理非'all'的情况
192
+ let expandLevel = 1; // 默认展开级别为1
193
+
194
+ if (expandValue) {
195
+ const numericValue = Number(expandValue);
196
+ if (!isNaN(numericValue) && numericValue > 0) {
197
+ expandLevel = Math.max(0, numericValue - 1); // 减1但最小为1
198
+
199
+ }
200
+ }
201
+
202
+ defaultExpandedKeys.value = getFirstNLevelKeys(fullTreeData.value, expandLevel);
203
+ }
170
204
  }
171
205
 
172
206
  hasSetDefaultExpand.value = true;
@@ -626,8 +660,8 @@ function loadNode(node, resolve) {
626
660
  loading.value = false;
627
661
 
628
662
 
629
- const { tree, hasAnyLeaf } = buildDeptTreeByField(data.rows, data.source.content.columns || [], {
630
- pathKey: 'deptPath',
663
+ const { tree, hasAnyLeaf } = buildDeptTreeByField(data.rows, {
664
+ pathKey: 'path',
631
665
  separator: '.'
632
666
  });
633
667
 
@@ -665,7 +699,7 @@ function loadNode(node, resolve) {
665
699
  ...(screenPara.value?.searchData?.fields || [])
666
700
  ]
667
701
  }
668
- };
702
+ };
669
703
 
670
704
  return SearchTree(filter).then(data => {
671
705
  loading.value = false;
@@ -771,6 +805,7 @@ function clearSearch() {
771
805
 
772
806
  //节点点击事件
773
807
  function handleNodeClick(data, formType) {
808
+
774
809
  closeMenu();
775
810
  if (data && formType) {
776
811
  refTree.value.setCurrentKey(data.code)
@@ -784,6 +819,7 @@ function handleNodeClick(data, formType) {
784
819
  SearchData[v] = data[v];
785
820
  }
786
821
  })
822
+
787
823
  model.value.requestAction(rowRouter.action, SearchData, function (rowdata) {
788
824
  var newdata = common.deepClone(data);
789
825
  delete newdata.children;
@@ -859,8 +895,9 @@ function routerClickHandler(field) {
859
895
 
860
896
  //删除树节点
861
897
  function removeNode(newData) {
862
- getNextClickNode()
898
+ getNextClickNode(currentNode.value)
863
899
  refTree.value.remove(currentNode.value);
900
+
864
901
  }
865
902
 
866
903
  //新增树节点
@@ -882,13 +919,13 @@ function updateNode(newData) {
882
919
  }
883
920
 
884
921
  function getNextClickNode() {
885
- const node = refTree.value.getNode(currentData.value.code);
922
+ const node = refTree.value.getNode((currentData.value.code || currentNode.value.key));
886
923
  let data = {};
887
- if (node.nextSibling) {
924
+ if (node?.nextSibling) {
888
925
  data = node.nextSibling.data;
889
926
  } else if (node.previousSibling) {
890
927
  data = node.previousSibling.data;
891
- } else if (node.parent) {
928
+ } else if (node?.parent) {
892
929
  data = node.parent.data;
893
930
  }
894
931
  handleNodeClick(data, true)
@@ -900,94 +937,110 @@ function filterNode(value, data) {
900
937
  return data.name.toLowerCase().includes(value.toLowerCase())
901
938
  }
902
939
 
903
- function buildDeptTreeByField(flatList, fieldDefine, opt = {}) {
940
+ function buildDeptTreeByField(flatList, opt = {}) {
904
941
  const {
905
942
  pathKey = 'path',
906
943
  separator = '.',
907
- sortKey = 'path'
944
+ sortKey = 'sort'
908
945
  } = opt;
909
946
 
910
- const keepFields = fieldDefine
911
- .filter(f => f.visible && f.isDataField)
912
- .sort((a, b) => a.trOrder - b.trOrder)
913
- .map(f => f.fieldName);
914
-
915
- const createNode = (tplItem, path) => {
916
- const node = { children: [] };
917
-
918
- for (const key in tplItem) {
919
- if (key !== 'children') {
920
- node[key] = tplItem[key];
921
- }
922
- }
947
+ // 检查第一行是否有 sort 字段
948
+ const firstItem = flatList.length > 0 ? flatList[0] : null;
949
+ const actualSortKey = firstItem && firstItem.hasOwnProperty(sortKey) ? sortKey : pathKey;
923
950
 
924
- node[pathKey] = path;
925
- return node;
926
- };
951
+ // 按路径排序,确保父节点在前
952
+ const sortedList = [...flatList].sort((a, b) => {
953
+ const aPath = a[pathKey] || '';
954
+ const bPath = b[pathKey] || '';
955
+ return aPath.length - bPath.length || aPath.localeCompare(bPath);
956
+ });
927
957
 
958
+ const pathMap = new Map(); // path -> node
928
959
  const root = [];
929
- const nodeMap = new Map();
930
960
 
931
- for (const item of flatList) {
932
-
933
- if (!item[pathKey]) {
934
- break;
935
- }
961
+ for (const item of sortedList) {
936
962
  const path = item[pathKey];
937
- const levels = path.split(separator);
963
+ if (!path) continue;
938
964
 
939
- let curPath = '';
940
- let parentPath = '';
965
+ const node = {
966
+ ...item,
967
+ children: [],
968
+ isLeaf: true // 默认为叶子节点,后续会更新
969
+ };
941
970
 
942
- levels.forEach((lvl, idx) => {
943
- curPath = idx === 0 ? lvl : `${parentPath}${separator}${lvl}`;
944
- let curNode = nodeMap.get(curPath);
971
+ // 添加到路径映射
972
+ pathMap.set(path, node);
973
+
974
+ // 查找父节点
975
+ const lastDotIndex = path.lastIndexOf(separator);
976
+ if (lastDotIndex > -1) {
977
+ const parentPath = path.substring(0, lastDotIndex);
978
+ const parentNode = pathMap.get(parentPath);
979
+
980
+ if (parentNode) {
981
+ parentNode.children.push(node);
982
+ parentNode.isLeaf = false; // 有子节点,所以不是叶子
983
+ continue;
984
+ }
985
+ }
945
986
 
946
- if (!curNode) {
947
- curNode = createNode(item, curPath);
948
- nodeMap.set(curPath, curNode);
987
+ // 没有找到父节点,或者没有父路径,则作为根节点
988
+ root.push(node);
989
+ }
949
990
 
950
- if (idx === 0) {
951
- root.push(curNode);
952
- } else {
953
- const pNode = nodeMap.get(parentPath);
954
- if (pNode) {
955
- pNode.children.push(curNode);
956
- }
957
- }
958
- }
959
- parentPath = curPath;
991
+ // 排序:按 sortKey path 排序
992
+ const sortTree = (nodes) => {
993
+ nodes.sort((a, b) => {
994
+ const aVal = a[actualSortKey] || a[pathKey] || '';
995
+ const bVal = b[actualSortKey] || b[pathKey] || '';
996
+ return String(aVal).localeCompare(String(bVal));
960
997
  });
961
998
 
962
- const lastNode = nodeMap.get(path);
963
- for (const key in item) {
964
- if (key !== 'children') {
965
- lastNode[key] = item[key];
999
+ nodes.forEach(node => {
1000
+ if (node.children && node.children.length > 0) {
1001
+ sortTree(node.children);
966
1002
  }
967
- }
1003
+ });
1004
+ };
1005
+
1006
+ sortTree(root);
1007
+
1008
+ const hasAnyLeaf = root.some(n => !n.isLeaf);
1009
+ return { tree: root, hasAnyLeaf };
1010
+ }
1011
+
1012
+ function findSearchFieldValue(searchFields, targetKey, options = {}) {
1013
+ const {
1014
+ keyFields = ['fieldName1', 'groupName'], // 要查找的key字段列表
1015
+ valueField = 'searchValue1', // 要返回值的字段
1016
+ defaultValue = 2
1017
+ } = options;
1018
+
1019
+ // 检查数据结构
1020
+ if (!searchFields?.searchData?.fields?.length) {
1021
+ return defaultValue;
968
1022
  }
969
1023
 
970
- for (const node of nodeMap.values()) {
971
- if (node.children && node.children.length > 0) {
972
- node.children.sort((a, b) => {
973
- const aVal = a[sortKey] || '';
974
- const bVal = b[sortKey] || '';
975
- return String(aVal).localeCompare(String(bVal));
976
- });
1024
+ // 遍历fields数组
1025
+ for (const field of searchFields.searchData.fields) {
1026
+ // 检查所有可能的key字段
1027
+ for (const keyField of keyFields) {
1028
+ if (field[keyField] === targetKey) {
1029
+ // 找到了匹配的key,返回对应的值
1030
+ const value = field[valueField];
1031
+ // 如果值为undefined、null或空字符串,返回默认值
1032
+ return value !== undefined && value !== null && value !== ''
1033
+ ? value
1034
+ : defaultValue;
1035
+ }
977
1036
  }
978
- node.isLeaf = node.children.length === 0;
979
1037
  }
980
1038
 
981
- root.sort((a, b) => {
982
- const aVal = a[sortKey] || '';
983
- const bVal = b[sortKey] || '';
984
- return String(aVal).localeCompare(String(bVal));
985
- });
986
-
987
- const hasAnyLeaf = [...nodeMap.values()].some(n => n.isLeaf == false);
988
- return { tree: root, hasAnyLeaf };
1039
+ return defaultValue;
989
1040
  }
990
1041
 
1042
+
1043
+
991
1044
  // 暴露方法
992
1045
  defineExpose({
993
1046
  search,
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: "https://kq-api.centaline.com.cn/onecard-api/",
25
- //baseUrl:"http://10.88.22.66/IBS.Mvc/api/",
24
+ //baseUrl: "http://10.88.22.13:7080/ibs-api/",
25
+ baseUrl:"http://hkibswcfha01.centaline.com/mvc/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.eyJsb2dpbl91c2VyX2tleSI6ImIzMjNmYjZjLTU5MWEtNGU5Mi1iODNmLWUzZDBhNThmMDMzMSJ9.P32j9z5ujG9bg76InDMrs89NgLhjly6ESp9MIipYVmCoiYQD0kgscqdk_7E6NKsi_FKosZVliKEeZFlPwqsBZQ',
70
- authobject: '{token:"16-2005889170303787008",platform:"WEB"}',
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"}',
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"}',