cnhis-design-vue 3.1.23-beta.8 → 3.1.23-beta.9

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.
@@ -5,7 +5,7 @@ export declare const getMapVal: (row: any, item: any) => any;
5
5
  export declare const getageShowType: (row: any, item: any) => any;
6
6
  export declare const reScrollFilterWrap: () => void;
7
7
  export declare const showFilter: (field: any, columnName: any, event: any, props: any, state: any) => false | undefined;
8
- export declare const handleGroupColums: (columns: any, props: any) => any;
8
+ export declare const handleGroupColums: (columns: any, props: any) => any[];
9
9
  export declare const handlerInitSearchItem: (arr: any) => void;
10
10
  export declare const generateEditRender: (fieldItem: any) => {
11
11
  name: string;
@@ -1,7 +1,8 @@
1
- import { nextTick } from 'vue';
1
+ import img from '../../../shared/assets/img/xb_small.js';
2
2
  import XEUtils from 'xe-utils';
3
3
  import 'moment';
4
- import img from '../../../shared/assets/img/xb_small.js';
4
+ import { nextTick } from 'vue';
5
+ import { groupTraverser, createRowGroupList } from '../../iho-table/src/plugins/rowGroupSettingPlugin/row-group-utils2.js';
5
6
 
6
7
  const isJSON = (str) => {
7
8
  if (typeof str == "string") {
@@ -166,43 +167,16 @@ const showFilter = (field, columnName, event, props, state) => {
166
167
  field.indeterminate = !!len && len !== field.setting.showSetting.length;
167
168
  field.searchFilterText = "";
168
169
  };
169
- const handleRowColumns = (rowColumns, columns, key) => {
170
- rowColumns.map((item) => {
171
- var _a;
172
- const children = [];
173
- let spliceIndex = -1;
174
- const indexArr = [];
175
- ((_a = item.list) == null ? void 0 : _a.length) && item.list.forEach((v) => {
176
- const matchItem = columns == null ? void 0 : columns.find((column) => column[key] === v);
177
- if (matchItem) {
178
- const matchIndex = columns.findIndex((column) => column[key] === v);
179
- indexArr.push(matchIndex);
180
- delete matchItem.fixed;
181
- children.push(matchItem);
182
- columns.splice(matchIndex, 1);
183
- }
184
- });
185
- const obj = {
186
- title: item.title,
187
- align: "center",
188
- children
189
- };
190
- spliceIndex = Math.min(...indexArr);
191
- spliceIndex > -1 && columns.splice(spliceIndex, 0, obj);
192
- });
193
- };
194
170
  const handleGroupColums = (columns, props) => {
195
171
  const { rowGroupSetting } = props;
196
- if (!rowGroupSetting || !Object.keys(rowGroupSetting).length)
197
- return columns;
198
- const { firstRowGroup, secondRowGroup } = rowGroupSetting;
199
- if (!firstRowGroup || !firstRowGroup.length)
200
- return columns;
201
- handleRowColumns(firstRowGroup, columns, "columnName");
202
- if (!secondRowGroup || !secondRowGroup.length)
203
- return columns;
204
- handleRowColumns(secondRowGroup, columns, "title");
205
- return columns;
172
+ return groupTraverser(createRowGroupList(rowGroupSetting, columns, (field) => field.columnName || field.type), (fieldName, isBlock) => {
173
+ if (isBlock)
174
+ return { field: fieldName, title: fieldName, align: "center" };
175
+ return fieldSearcher(fieldName, columns);
176
+ });
177
+ function fieldSearcher(fieldName, fieldList) {
178
+ return fieldList.find((field) => (field.columnName || field.type) === fieldName);
179
+ }
206
180
  };
207
181
  const handlerInitSearchItem = (arr) => {
208
182
  if (!Array.isArray(arr))
@@ -1,7 +1,6 @@
1
1
  import { isObject } from '@vue/shared';
2
- import { isArray, isString } from 'lodash-es';
3
2
  import '../../../index2.js';
4
- import { IhoTableRowGroupSequence } from '../../constants/index2.js';
3
+ import { groupTraverser, createRowGroupList } from './row-group-utils2.js';
5
4
  import { defineTablePlugin } from '../../hooks/useTablePlugin2.js';
6
5
 
7
6
  function rowGroupSettingPlugin() {
@@ -24,49 +23,5 @@ function rowGroupSettingPlugin() {
24
23
  function fieldSearcher(fieldName, fieldList) {
25
24
  return fieldList.find((field) => field.field === fieldName);
26
25
  }
27
- function createRowGroupList(rowGroupSetting, fieldList) {
28
- const result = fieldList.map((field) => field.field);
29
- IhoTableRowGroupSequence.some((sequence) => {
30
- const currentLevelGroup = rowGroupSetting[sequence];
31
- if (!isArray(currentLevelGroup))
32
- return true;
33
- currentLevelGroup.forEach((groupSetting) => {
34
- if (!isArray(groupSetting.list) || !groupSetting.list.length)
35
- return;
36
- const children = [];
37
- groupSetting.list.forEach((fieldName, idx) => {
38
- const groupIdx = groupIndexSearcher(fieldName, result);
39
- if (!~groupIdx)
40
- return;
41
- children.push(result[groupIdx]);
42
- if (idx === 0) {
43
- result.splice(groupIdx, 1, { fieldName: groupSetting.title, children });
44
- } else {
45
- result.splice(groupIdx, 1);
46
- }
47
- });
48
- });
49
- });
50
- return result;
51
- function groupIndexSearcher(fieldName, groupList) {
52
- return groupList.findIndex((group) => (isObject(group) ? group.fieldName : group) === fieldName);
53
- }
54
- }
55
- function groupTraverser(groupList, replacer) {
56
- return groupList.reduce((result, group) => {
57
- if (isString(group)) {
58
- const item = replacer(group);
59
- item && result.push(item);
60
- }
61
- if (isObject(group) && group.children) {
62
- const item = replacer(group.fieldName, true);
63
- if (item) {
64
- item.children = groupTraverser(group.children, replacer);
65
- result.push(item);
66
- }
67
- }
68
- return result;
69
- }, []);
70
- }
71
26
 
72
27
  export { rowGroupSettingPlugin };
@@ -0,0 +1,11 @@
1
+ import { NotNull, Nullable } from '../../../../../../es/shared/types';
2
+ import { IhoTableConfig, IhoTableFieldItem } from '../../../../../../es/components/iho-table';
3
+ declare type GroupItem = string | {
4
+ fieldName: string;
5
+ children?: GroupItem[];
6
+ };
7
+ export declare function createRowGroupList(rowGroupSetting: NotNull<IhoTableConfig['rowGroupSetting']>, fieldList: IhoTableFieldItem[], getKey?: (field: IhoTableFieldItem) => string): GroupItem[];
8
+ export declare function groupTraverser<T extends Nullable<{
9
+ children?: T[];
10
+ }>>(groupList: GroupItem[], replacer: (fieldName: string, isBlock?: boolean) => T): NotNull<T>[];
11
+ export {};
@@ -0,0 +1 @@
1
+ export { createRowGroupList, groupTraverser } from './row-group-utils2.js';
@@ -0,0 +1,50 @@
1
+ import { isObject } from '@vue/shared';
2
+ import { isArray, isString } from 'lodash-es';
3
+ import { IhoTableRowGroupSequence } from '../../constants/index2.js';
4
+
5
+ function createRowGroupList(rowGroupSetting, fieldList, getKey = (field) => field.field) {
6
+ const result = fieldList.map((field) => getKey(field));
7
+ IhoTableRowGroupSequence.some((sequence) => {
8
+ const currentLevelGroup = rowGroupSetting[sequence];
9
+ if (!isArray(currentLevelGroup))
10
+ return true;
11
+ currentLevelGroup.forEach((groupSetting) => {
12
+ if (!isArray(groupSetting.list) || !groupSetting.list.length)
13
+ return;
14
+ const children = [];
15
+ groupSetting.list.forEach((fieldName, idx) => {
16
+ const groupIdx = groupIndexSearcher(fieldName, result);
17
+ if (!~groupIdx)
18
+ return;
19
+ children.push(result[groupIdx]);
20
+ if (idx === 0) {
21
+ result.splice(groupIdx, 1, { fieldName: groupSetting.title, children });
22
+ } else {
23
+ result.splice(groupIdx, 1);
24
+ }
25
+ });
26
+ });
27
+ });
28
+ return result;
29
+ function groupIndexSearcher(fieldName, groupList) {
30
+ return groupList.findIndex((group) => (isObject(group) ? group.fieldName : group) === fieldName);
31
+ }
32
+ }
33
+ function groupTraverser(groupList, replacer) {
34
+ return groupList.reduce((result, group) => {
35
+ if (isString(group)) {
36
+ const item = replacer(group);
37
+ item && result.push(item);
38
+ }
39
+ if (isObject(group) && group.children) {
40
+ const item = replacer(group.fieldName, true);
41
+ if (item) {
42
+ item.children = groupTraverser(group.children, replacer);
43
+ result.push(item);
44
+ }
45
+ }
46
+ return result;
47
+ }, []);
48
+ }
49
+
50
+ export { createRowGroupList, groupTraverser };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
- "version": "3.1.23-beta.8",
3
+ "version": "3.1.23-beta.9",
4
4
  "license": "ISC",
5
5
  "module": "./es/components/index.js",
6
6
  "main": "./es/components/index.js",
@@ -66,5 +66,5 @@
66
66
  "iOS 7",
67
67
  "last 3 iOS versions"
68
68
  ],
69
- "gitHead": "a54b390e037e36aa1dbf7793ef68a4cbd9a089e0"
69
+ "gitHead": "ba7a3a8d47692bcd6d27d53c1fa3e5b5db491b1c"
70
70
  }