zmdms-webui 1.2.7 → 1.2.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.
@@ -73,8 +73,12 @@ function tableValidate(dataSource, columns, restParams) {
73
73
  columns.forEach(function (column, index) {
74
74
  var _a, _b;
75
75
  if (!isMerge) {
76
+ // 这里判断需要改动,只需要有rowSpan属性或者colSpan属性就有合并
76
77
  var mergeColumn = (_a = column === null || column === void 0 ? void 0 : column.onCell) === null || _a === void 0 ? void 0 : _a.call(column, {}, 1);
77
- if (mergeColumn && (mergeColumn.rowSpan || mergeColumn.colSpan)) {
78
+ // if (mergeColumn && (mergeColumn?.rowSpan || mergeColumn?.colSpan)) {
79
+ if (mergeColumn &&
80
+ (Reflect.has(mergeColumn, "rowSpan") ||
81
+ Reflect.has(mergeColumn, "colSpan"))) {
78
82
  isMerge = true;
79
83
  }
80
84
  }
@@ -96,6 +100,7 @@ function tableValidate(dataSource, columns, restParams) {
96
100
  column.__title ||
97
101
  column.title,
98
102
  validate: column.validate,
103
+ // 错误发生的列
99
104
  index: childrenLen + (rowSelection ? 1 : 0) + (expandable ? 1 : 0),
100
105
  });
101
106
  }
@@ -17,6 +17,10 @@ interface ITreeSelectProps extends Omit<TreeSelectProps, "onChange"> {
17
17
  */
18
18
  searchType?: "all" | "lazy";
19
19
  lazySearchHandle?: (v: string, setExpandKeys?: any) => void;
20
+ /**
21
+ * 禁用的选项列表 一个dataKey列表
22
+ */
23
+ disabledValues?: string[];
20
24
  }
21
25
  interface TreeSelectComponent extends React__default.ForwardRefExoticComponent<ITreeSelectProps & React__default.RefAttributes<unknown>> {
22
26
  SHOW_ALL: typeof TreeSelect.SHOW_ALL;
@@ -1,6 +1,6 @@
1
1
  import { __rest, __assign } from '../_virtual/_tslib.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { memo, forwardRef } from 'react';
3
+ import { memo, forwardRef, useMemo } from 'react';
4
4
  import { TreeSelect as TreeSelect$1 } from 'antd';
5
5
  import { useBasicInfo, useAllDataHandle, useChange, useSearchHandle } from './hooks.js';
6
6
 
@@ -15,8 +15,8 @@ var DEFAULT_MAX_TAG_COUNT = 3;
15
15
  * treeDataSimpleMode treeData是否为简单格式 即树数据为平级 通过pId关联父子节点
16
16
  */
17
17
  var TreeSelect = function (props, ref) {
18
- var onChange = props.onChange, isAllData = props.isAllData, dataHandle = props.dataHandle, searchType = props.searchType, lazySearchHandle = props.lazySearchHandle, resetProps = __rest(props, ["onChange", "isAllData", "dataHandle", "searchType", "lazySearchHandle"]);
19
- var fieldNames = resetProps.fieldNames, treeNodeLabelProp = resetProps.treeNodeLabelProp, value = resetProps.value, treeData = resetProps.treeData, treeDataSimpleMode = resetProps.treeDataSimpleMode;
18
+ var onChange = props.onChange, isAllData = props.isAllData, dataHandle = props.dataHandle, searchType = props.searchType, lazySearchHandle = props.lazySearchHandle, disabledValues = props.disabledValues, treeData = props.treeData, resetProps = __rest(props, ["onChange", "isAllData", "dataHandle", "searchType", "lazySearchHandle", "disabledValues", "treeData"]);
19
+ var fieldNames = resetProps.fieldNames, treeNodeLabelProp = resetProps.treeNodeLabelProp, value = resetProps.value, treeDataSimpleMode = resetProps.treeDataSimpleMode;
20
20
  // 基础数据
21
21
  var _a = useBasicInfo({
22
22
  fieldNames: fieldNames,
@@ -47,11 +47,52 @@ var TreeSelect = function (props, ref) {
47
47
  childrenKey: childrenKey,
48
48
  titleKey: titleKey,
49
49
  }), searchValue = _b.searchValue, onLazySearchHandle = _b.onLazySearchHandle, filterTreeNode = _b.filterTreeNode, treeExpandedKeys = _b.treeExpandedKeys, onTreeExpand = _b.onTreeExpand;
50
+ var newTreeData = useMemo(function () {
51
+ if (!disabledValues) {
52
+ return treeData;
53
+ }
54
+ if (disabledValues.length === 0) {
55
+ return treeData;
56
+ }
57
+ // 如果数据是扁平模式
58
+ if (treeDataSimpleMode) {
59
+ return treeData === null || treeData === void 0 ? void 0 : treeData.map(function (item) {
60
+ if (valueKey && disabledValues.includes(item[valueKey])) {
61
+ return __assign(__assign({}, item), { disabled: true, disableCheckbox: true });
62
+ }
63
+ return item;
64
+ });
65
+ }
66
+ function cloneAndDisableTree(tree, disabledIds) {
67
+ var _a;
68
+ // 递归函数,用于克隆树结构并添加禁用属性
69
+ function cloneNode(node) {
70
+ // 创建一个新节点作为克隆
71
+ var newNode = __assign({}, node);
72
+ // 如果有子节点,则递归克隆子节点
73
+ if (node === null || node === void 0 ? void 0 : node[childrenKey]) {
74
+ newNode[childrenKey] = node[childrenKey].map(function (child) {
75
+ return cloneNode(child);
76
+ });
77
+ }
78
+ // 检查当前节点的ID是否在禁用列表中
79
+ if (disabledIds.includes(node[valueKey])) {
80
+ // 如果在,则添加禁用属性
81
+ newNode.disabled = true;
82
+ newNode.disableCheckbox = true;
83
+ }
84
+ return newNode;
85
+ }
86
+ // 遍历原始树结构,对每个节点调用cloneNode进行克隆和修改
87
+ return (_a = tree === null || tree === void 0 ? void 0 : tree.map) === null || _a === void 0 ? void 0 : _a.call(tree, function (rootNode) { return cloneNode(rootNode); });
88
+ }
89
+ return cloneAndDisableTree(treeData, disabledValues);
90
+ }, [treeData, valueKey, childrenKey, treeDataSimpleMode, disabledValues]);
50
91
  return (jsx(TreeSelect$1, __assign({ onChange: onChangeHandle,
51
92
  // 当多选模式或treeCheckable 定义回填的模式
52
93
  showCheckedStrategy: TreeSelect$1.SHOW_ALL, maxTagCount: DEFAULT_MAX_TAG_COUNT, searchValue: searchValue, onSearch: onLazySearchHandle, filterTreeNode: filterTreeNode,
53
94
  // 节点展开逻辑
54
- treeExpandedKeys: treeExpandedKeys, onTreeExpand: onTreeExpand, ref: ref }, resetProps)));
95
+ treeExpandedKeys: treeExpandedKeys, onTreeExpand: onTreeExpand, ref: ref, treeData: newTreeData }, resetProps)));
55
96
  };
56
97
  var MemoTreeSelect = memo(forwardRef(TreeSelect));
57
98
  MemoTreeSelect.displayName = "ZTXK_WEBUI_TreeSelect";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",