@zat-design/sisyphus-react 3.3.1-beta.6 → 3.3.1-beta.7

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.
Files changed (40) hide show
  1. package/dist/index.esm.css +8 -2
  2. package/es/ProEditTable/components/RenderField/index.js +17 -9
  3. package/es/ProEditTable/index.js +21 -2
  4. package/es/ProEditTable/style/index.less +5 -0
  5. package/es/ProForm/style/index.less +5 -4
  6. package/es/ProForm/utils/contrastOriginal.d.ts +0 -1
  7. package/es/ProForm/utils/contrastOriginal.js +0 -1
  8. package/es/ProForm/utils/useChanged.d.ts +7 -14
  9. package/es/ProForm/utils/useChanged.js +13 -20
  10. package/es/ProForm/utils/useListChanged.d.ts +16 -0
  11. package/es/ProForm/utils/useListChanged.js +81 -0
  12. package/es/ProLayout/components/Layout/Menu/index.js +13 -10
  13. package/es/ProLayout/propTypes.d.ts +2 -0
  14. package/es/ProTreeModal/components/Trigger.d.ts +1 -0
  15. package/es/ProTreeModal/components/Trigger.js +12 -7
  16. package/es/ProTreeModal/index.js +13 -3
  17. package/es/locale/en_US.d.ts +2 -0
  18. package/es/locale/en_US.js +3 -1
  19. package/es/locale/zh_CN.d.ts +3 -0
  20. package/es/locale/zh_CN.js +4 -1
  21. package/lib/ProEditTable/components/RenderField/index.js +16 -8
  22. package/lib/ProEditTable/index.js +20 -1
  23. package/lib/ProEditTable/style/index.less +5 -0
  24. package/lib/ProForm/style/index.less +5 -4
  25. package/lib/ProForm/utils/contrastOriginal.d.ts +0 -1
  26. package/lib/ProForm/utils/contrastOriginal.js +0 -1
  27. package/lib/ProForm/utils/useChanged.d.ts +7 -14
  28. package/lib/ProForm/utils/useChanged.js +13 -20
  29. package/lib/ProForm/utils/useListChanged.d.ts +16 -0
  30. package/lib/ProForm/utils/useListChanged.js +86 -0
  31. package/lib/ProLayout/components/Layout/Menu/index.js +13 -10
  32. package/lib/ProLayout/propTypes.d.ts +2 -0
  33. package/lib/ProTreeModal/components/Trigger.d.ts +1 -0
  34. package/lib/ProTreeModal/components/Trigger.js +12 -7
  35. package/lib/ProTreeModal/index.js +13 -3
  36. package/lib/locale/en_US.d.ts +2 -0
  37. package/lib/locale/en_US.js +3 -1
  38. package/lib/locale/zh_CN.d.ts +3 -0
  39. package/lib/locale/zh_CN.js +4 -1
  40. package/package.json +1 -1
@@ -2569,9 +2569,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
2569
2569
  .pro-form .ant-form-item.pro-form-item-changed .ant-picker .ant-select-selection-placeholder {
2570
2570
  z-index: 9;
2571
2571
  }
2572
- .pro-form .ant-form-item.pro-form-item-changed .ant-form-item-control-input-content > span {
2573
- background: var(--zaui-contract-bg, #fffaa1);
2572
+ .pro-form .ant-form-item.pro-form-item-changed .ant-form-item-control-input-content > .pro-form-view-container {
2574
2573
  padding: 4px 8px;
2574
+ background: var(--zaui-contract-bg, #fffaa1);
2575
2575
  border-radius: 4px;
2576
2576
  }
2577
2577
  .pro-form .ant-form-item .ant-row {
@@ -4191,6 +4191,12 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
4191
4191
  .pro-edit-table .ant-table-pagination .ant-pagination-options .ant-select.ant-select-in-form-item {
4192
4192
  width: auto;
4193
4193
  }
4194
+ .pro-edit-table .is-new-row td,
4195
+ .pro-edit-table .is-new-row.ant-table-row:hover td,
4196
+ .pro-edit-table .is-new-row .ant-table-cell-row-hover,
4197
+ .pro-edit-table .is-new-row.ant-table-row:hover .ant-table-cell-row-hover {
4198
+ background: var(--ant-primary-2) !important;
4199
+ }
4194
4200
  .pro-edit-table-header {
4195
4201
  margin-bottom: calc(var(--zaui-space-size-md, 16px) * var(--zaui-size, 1));
4196
4202
  }
@@ -17,7 +17,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
17
17
  /* eslint-disable prefer-const */
18
18
  import React, { useCallback, useEffect } from 'react';
19
19
  import classNames from 'classnames';
20
- import { cloneDeep, isEqual, debounce, omit, isFunction, isString } from 'lodash';
20
+ import { cloneDeep, isEqual, debounce, omit, isFunction, isString, get } from 'lodash';
21
21
  import valueTypeMap from '../../../ProForm/utils/valueType';
22
22
  import transformMap from '../../utils/transform';
23
23
  import { getNamePath, difference } from '../../utils/tools';
@@ -25,7 +25,7 @@ import * as componentMap from '../../../ProForm/components';
25
25
  import Container from '../../../ProForm/components/Container';
26
26
  import transformNames from '../../../ProForm/utils/transformNames';
27
27
  import { FieldProvider } from '../../../ProForm/utils/useFieldProps';
28
- import { useChanged } from '../../../ProForm/utils/useChanged';
28
+ import { useListChanged } from '../../../ProForm/utils/useListChanged';
29
29
  import useRules from '../../../ProForm/utils/useRules';
30
30
  import { isSelect } from '../../../ProForm/utils';
31
31
  import locale from '../../../locale';
@@ -73,7 +73,8 @@ var RenderField = function RenderField(_ref) {
73
73
  virtualKey = config.virtualKey,
74
74
  viewEmpty = config.viewEmpty,
75
75
  originalValues = config.originalValues,
76
- originalTip = config.originalTip;
76
+ originalTip = config.originalTip,
77
+ IsNew = config.IsNew;
77
78
  var _fieldProps = fieldProps || formItemProps || {};
78
79
  var _rules = rules || [];
79
80
  var _required = required;
@@ -87,6 +88,8 @@ var RenderField = function RenderField(_ref) {
87
88
  // 单行正在编辑时,临时生成一套formItem用来存储中间值,点击取消时候重置回上一次状态
88
89
  var namePath = getNamePath(name, virtualKey);
89
90
  var rowData = form.getFieldValue([].concat(_toConsumableArray(namePath), [index])) || record || {};
91
+ var originalArr = get(originalValues, name);
92
+ var isAdd = IsNew(originalArr, rowData);
90
93
  var currentValue = dataIndex ? rowData === null || rowData === void 0 ? void 0 : rowData[dataIndex] : null;
91
94
  // 第三个参数
92
95
  var options = {
@@ -452,19 +455,24 @@ var RenderField = function RenderField(_ref) {
452
455
  };
453
456
  }();
454
457
  // 判断当前字段是否变更
455
- var _useChanged = useChanged({
458
+ var _useListChanged = useListChanged({
456
459
  name: cellName,
457
460
  names: names,
458
461
  namesStr: [].concat(_toConsumableArray(baseName), [index, dataIndex]),
462
+ rowKeyPath: [].concat(_toConsumableArray(baseName), [index, 'rowKey']),
459
463
  originalName: originalName,
460
464
  originalNames: originalNames,
461
465
  originalValues: originalValues,
462
- form: form,
463
- equalWith: equalWith
466
+ form: form
467
+ // equalWith: (originalValue, values) => {
468
+ // console.log('originalValue', originalValue);
469
+ // console.log('values', values);
470
+ // return false;
471
+ // },
464
472
  }),
465
- _useChanged2 = _slicedToArray(_useChanged, 2),
466
- changed = _useChanged2[0],
467
- originalValue = _useChanged2[1];
473
+ _useListChanged2 = _slicedToArray(_useListChanged, 2),
474
+ changed = _useListChanged2[0],
475
+ originalValue = _useListChanged2[1];
468
476
  var componentProps = _objectSpread(_objectSpread(_objectSpread({
469
477
  form: form,
470
478
  name: cellName,
@@ -13,7 +13,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
13
13
  var _excluded = ["value", "onChange", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "otherProps", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalTip", "rowKey"];
14
14
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from 'react';
16
- import { isArray } from 'lodash';
16
+ import { get, isArray } from 'lodash';
17
17
  import { useDebounceEffect, useSetState } from 'ahooks';
18
18
  import classnames from 'classnames';
19
19
  import { transformColumns } from './utils';
@@ -106,6 +106,15 @@ var ProEditTable = function ProEditTable(_ref, ref) {
106
106
  }
107
107
  return key;
108
108
  };
109
+ var IsNew = function IsNew(preArr, record) {
110
+ var _preArr$find;
111
+ if (!(preArr === null || preArr === void 0 ? void 0 : preArr.length)) {
112
+ return false;
113
+ }
114
+ return !(preArr === null || preArr === void 0 ? void 0 : (_preArr$find = preArr.find) === null || _preArr$find === void 0 ? void 0 : _preArr$find.call(preArr, function (item) {
115
+ return getRowKey(item) === getRowKey(record);
116
+ }));
117
+ };
109
118
  var config = {
110
119
  form: form,
111
120
  mode: mode,
@@ -136,12 +145,17 @@ var ProEditTable = function ProEditTable(_ref, ref) {
136
145
  page: page,
137
146
  originalValues: originalValues,
138
147
  originalTip: originalTip,
139
- prefixCls: prefixCls
148
+ prefixCls: prefixCls,
149
+ IsNew: IsNew
140
150
  };
141
151
  // 编辑行设置下样式
142
152
  var _rowClassName = function _rowClassName(record) {
143
153
  var isEdit = !virtualKey || editingKeys.includes(record.rowKey);
144
154
  var className = isEdit ? 'is-editing' : '';
155
+ var originalArr = get(originalValues, name);
156
+ if (!isEdit && IsNew(originalArr, record)) {
157
+ return "is-new-row ".concat(className);
158
+ }
145
159
  return className;
146
160
  };
147
161
  // 复选框
@@ -246,11 +260,16 @@ var ProEditTable = function ProEditTable(_ref, ref) {
246
260
  var _value$;
247
261
  // 初始化默认生成row-key
248
262
  if ((value === null || value === void 0 ? void 0 : value.length) && !(value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey)) {
263
+ var _originalArr$forEach;
249
264
  var nextValues = value === null || value === void 0 ? void 0 : value.map(function (item) {
250
265
  return _objectSpread(_objectSpread({}, item), {}, {
251
266
  rowKey: getRowKey(item)
252
267
  });
253
268
  });
269
+ var originalArr = get(originalValues, name);
270
+ originalArr === null || originalArr === void 0 ? void 0 : (_originalArr$forEach = originalArr.forEach) === null || _originalArr$forEach === void 0 ? void 0 : _originalArr$forEach.call(originalArr, function (item) {
271
+ item.rowKey = getRowKey(item);
272
+ });
254
273
  onChange(nextValues);
255
274
  if (virtualKey) {
256
275
  form.setFieldValue(virtualRowName, nextValues);
@@ -296,6 +296,11 @@
296
296
  }
297
297
  }
298
298
 
299
+ .is-new-row, .is-new-row.@{ant-prefix}-table-row:hover {
300
+ td, .@{ant-prefix}-table-cell-row-hover {
301
+ background: var(--ant-primary-2) !important;
302
+ }
303
+ }
299
304
  }
300
305
 
301
306
  .pro-edit-table-header {
@@ -56,7 +56,8 @@
56
56
  visibility: unset;
57
57
  }
58
58
 
59
- .@{ant-prefix}-input-affix-wrapper:hover span.@{ant-prefix}-input-clear-icon[class~='ant-input-clear-icon-hidden'] {
59
+ .@{ant-prefix}-input-affix-wrapper:hover
60
+ span.@{ant-prefix}-input-clear-icon[class~='ant-input-clear-icon-hidden'] {
60
61
  display: unset;
61
62
  visibility: hidden;
62
63
  }
@@ -140,9 +141,9 @@
140
141
  }
141
142
  }
142
143
 
143
- .@{ant-prefix}-form-item-control-input-content > span {
144
- background: @zaui-contract-bg;
144
+ .@{ant-prefix}-form-item-control-input-content > .pro-form-view-container {
145
145
  padding: 4px 8px;
146
+ background: @zaui-contract-bg;
146
147
  border-radius: 4px;
147
148
  }
148
149
  }
@@ -306,7 +307,7 @@
306
307
 
307
308
  div.pro-form-custom-footer {
308
309
  width: unset !important;
309
- height:32px;
310
+ height: 32px;
310
311
  margin-bottom: calc(var(--zaui-height-size-md, 16px) * var(--zaui-size, 1));
311
312
 
312
313
  &.pro-form-custom-footer-hidden {
@@ -1,6 +1,5 @@
1
1
  import { FormInstance } from 'antd';
2
2
  interface Params {
3
- originalValues: any;
4
3
  originalValue: any;
5
4
  value: any;
6
5
  form: FormInstance;
@@ -2,7 +2,6 @@ import { isEqual, isFunction } from 'lodash';
2
2
  var nullValue = [null, undefined, '']; // 输入框空值时可能存在的三种值 视为相等
3
3
  export var contrastOriginal = function contrastOriginal(params) {
4
4
  var originalValue = params.originalValue,
5
- originalValues = params.originalValues,
6
5
  value = params.value,
7
6
  equalWith = params.equalWith;
8
7
  // 支持传入自定义比较事件
@@ -1,15 +1,8 @@
1
- import { FormInstance } from 'antd';
2
- import { NamePath } from 'antd/lib/form/interface';
3
- interface Params {
4
- name?: NamePath;
5
- names?: NamePath[];
6
- namesStr?: NamePath;
7
- originalName?: NamePath;
8
- originalNames?: NamePath[];
9
- originalNameStr?: NamePath;
1
+ export declare const useChanged: ({ name, names, namesStr, originalValues, form, equalWith }: {
2
+ name: any;
3
+ names: any;
4
+ namesStr: any;
10
5
  originalValues: any;
11
- form: FormInstance;
12
- equalWith?: (originalValue: any, currentValue: any) => boolean;
13
- }
14
- export declare const useChanged: (params: Params) => any[];
15
- export {};
6
+ form: any;
7
+ equalWith: any;
8
+ }) => any[];
@@ -2,30 +2,23 @@ import "antd/es/form/style";
2
2
  import _Form from "antd/es/form";
3
3
  import { get } from 'lodash';
4
4
  import { contrastOriginal } from './contrastOriginal';
5
- export var useChanged = function useChanged(params) {
6
- var name = params.name,
7
- names = params.names,
8
- namesStr = params.namesStr,
9
- _params$originalName = params.originalName,
10
- originalName = _params$originalName === void 0 ? name : _params$originalName,
11
- _params$originalNames = params.originalNames,
12
- originalNames = _params$originalNames === void 0 ? names : _params$originalNames,
13
- originalValues = params.originalValues,
14
- form = params.form,
15
- equalWith = params.equalWith;
16
- var _form = form;
17
- var originalValue = (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
18
- return get(originalValues, originalName);
19
- }) : get(originalValues, originalName);
5
+ export var useChanged = function useChanged(_ref) {
6
+ var name = _ref.name,
7
+ names = _ref.names,
8
+ namesStr = _ref.namesStr,
9
+ originalValues = _ref.originalValues,
10
+ form = _ref.form,
11
+ equalWith = _ref.equalWith;
12
+ var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
13
+ return get(originalValues, name);
14
+ }) : get(originalValues, name);
20
15
  var notWatch = !originalValues || originalValue === undefined;
21
- // @ts-ignore
22
- if (notWatch) _form = [];
23
- var value = _Form.useWatch(namesStr || name, _form);
16
+ if (notWatch) form = [];
17
+ var value = _Form.useWatch(namesStr || name, form);
24
18
  if (notWatch) return [false];
25
19
  var changed = contrastOriginal({
26
- value: value,
27
20
  originalValue: originalValue,
28
- originalValues: originalValues,
21
+ value: value,
29
22
  form: form,
30
23
  equalWith: equalWith
31
24
  });
@@ -0,0 +1,16 @@
1
+ import { FormInstance } from 'antd';
2
+ import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
3
+ interface Params {
4
+ name?: NamePath;
5
+ names?: NamePath[];
6
+ namesStr?: NamePath;
7
+ originalName?: NamePath;
8
+ originalNames?: NamePath[];
9
+ originalNameStr?: NamePath;
10
+ originalValues: any;
11
+ form: FormInstance;
12
+ rowKeyPath?: InternalNamePath;
13
+ equalWith?: (originalValue: any, currentValue: any) => boolean;
14
+ }
15
+ export declare const useListChanged: (params: Params) => any[];
16
+ export {};
@@ -0,0 +1,81 @@
1
+ import "antd/es/form/style";
2
+ import _Form from "antd/es/form";
3
+ import { get } from 'lodash';
4
+ import { contrastOriginal } from './contrastOriginal';
5
+ var toNamePath = function toNamePath(name) {
6
+ if (Array.isArray(name)) {
7
+ return name;
8
+ }
9
+ return [name];
10
+ };
11
+ var toNamePaths = function toNamePaths(names) {
12
+ return names.map(function (name) {
13
+ return toNamePath(name);
14
+ });
15
+ };
16
+ var getOriginalValue = function getOriginalValue(_ref) {
17
+ var namePath = _ref.namePath,
18
+ originalName = _ref.originalName,
19
+ originalNames = _ref.originalNames,
20
+ originalValues = _ref.originalValues,
21
+ rowKeyPath = _ref.rowKeyPath,
22
+ form = _ref.form;
23
+ if (!originalValues) {
24
+ return undefined;
25
+ }
26
+ if (rowKeyPath) {
27
+ var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
28
+ var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
29
+ var rowValue = form.getFieldValue(rowValueNamePath);
30
+ var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
31
+ if (!keyValue) return undefined;
32
+ var originalValueList = get(originalValues, originalName.slice(0, rowKeyPath.length - 2));
33
+ var originalValueRow = originalValueList.find(function (item) {
34
+ return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
35
+ });
36
+ var originalValue = (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
37
+ return get(originalValueRow, originalName.slice(rowKeyPath.length - 1));
38
+ }) : get(originalValueRow, originalName.slice(rowKeyPath.length - 1));
39
+ return originalValue;
40
+ }
41
+ return (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
42
+ return get(originalValues, originalName);
43
+ }) : get(originalValues, originalName);
44
+ };
45
+ export var useListChanged = function useListChanged(params) {
46
+ var name = params.name,
47
+ names = params.names,
48
+ namesStr = params.namesStr,
49
+ _params$originalName = params.originalName,
50
+ originalName = _params$originalName === void 0 ? name : _params$originalName,
51
+ _params$originalNames = params.originalNames,
52
+ originalNames = _params$originalNames === void 0 ? names : _params$originalNames,
53
+ originalValues = params.originalValues,
54
+ form = params.form,
55
+ equalWith = params.equalWith,
56
+ rowKeyPath = params.rowKeyPath;
57
+ // let _form = form;
58
+ var namePath = toNamePath(namesStr || name);
59
+ var originalNamePath = toNamePath(originalName);
60
+ var originalNamePaths = originalNames && toNamePaths(originalNames);
61
+ var originalValue = getOriginalValue({
62
+ namePath: namePath,
63
+ originalName: originalNamePath,
64
+ originalNames: originalNamePaths,
65
+ originalValues: originalValues,
66
+ rowKeyPath: rowKeyPath,
67
+ form: form
68
+ });
69
+ var notWatch = !originalValues || originalValue === undefined;
70
+ // @ts-ignore
71
+ // if (notWatch) _form = [];
72
+ var value = _Form.useWatch(namePath, form);
73
+ if (notWatch) return [false];
74
+ var changed = contrastOriginal({
75
+ value: value,
76
+ originalValue: originalValue,
77
+ form: form,
78
+ equalWith: equalWith
79
+ });
80
+ return [changed, originalValue];
81
+ };
@@ -3,14 +3,17 @@ import classnames from 'classnames';
3
3
  import OpenMenu from './OpenMenu';
4
4
  import FoldMenu from './FoldMenu'; // 折叠后菜单
5
5
  var Menu = function Menu(props) {
6
- var headerHeight = props.headerHeight,
7
- dataSource = props.dataSource,
8
- iconfontUrl = props.iconfontUrl,
9
- collapsed = props.collapsed,
10
- notice = props.notice,
11
- onToggle = props.onToggle,
12
- pure = props.pure,
13
- theme = props.theme;
6
+ var _ref = props || {},
7
+ headerHeight = _ref.headerHeight,
8
+ dataSource = _ref.dataSource,
9
+ iconfontUrl = _ref.iconfontUrl,
10
+ collapsed = _ref.collapsed,
11
+ notice = _ref.notice,
12
+ onToggle = _ref.onToggle,
13
+ pure = _ref.pure,
14
+ theme = _ref.theme,
15
+ sideMenuFooterRender = _ref.sideMenuFooterRender,
16
+ sideMenuHeaderRender = _ref.sideMenuHeaderRender;
14
17
  var menus = [];
15
18
  var menuCls = classnames({
16
19
  'pro-layout-menu': true,
@@ -29,7 +32,7 @@ var Menu = function Menu(props) {
29
32
  style: {
30
33
  top: notice ? 80 + headerHeight - 48 : headerHeight
31
34
  },
32
- children: [_jsx(OpenMenu, {
35
+ children: [sideMenuHeaderRender, _jsx(OpenMenu, {
33
36
  dataSource: {
34
37
  menus: menus,
35
38
  iconfontUrl: iconfontUrl,
@@ -52,7 +55,7 @@ var Menu = function Menu(props) {
52
55
  display: collapsed ? 'none' : 'block',
53
56
  height: "calc(100vh - ".concat(headerHeight + (notice ? 32 : 0) + 48 || 0, "px)")
54
57
  }
55
- }), _jsx("div", {
58
+ }), sideMenuFooterRender || _jsx("div", {
56
59
  className: "pro-layout-menu-collapsed",
57
60
  onClick: onToggle,
58
61
  children: _jsx("div", {
@@ -36,6 +36,8 @@ export interface ProLayoutProps {
36
36
  rightContentRender?: ReactNode;
37
37
  headerContentRender?: ReactNode;
38
38
  headerTitleRender?: ReactNode;
39
+ sideMenuHeaderRender?: ReactNode;
40
+ sideMenuFooterRender?: ReactNode;
39
41
  headerNotice?: ReactNode | string;
40
42
  notice?: ReactNode | string;
41
43
  title?: string;
@@ -2,6 +2,7 @@ import { CSSProperties } from 'react';
2
2
  interface TriggerProps {
3
3
  checkedValues: any[];
4
4
  value: any;
5
+ label?: React.ReactNode;
5
6
  disabled?: boolean;
6
7
  isView?: boolean;
7
8
  checkAll?: boolean;
@@ -17,6 +17,7 @@ import viewSvg from '../../assets/view.svg';
17
17
  function Trigger(props) {
18
18
  var _locale$ProTreeModal2, _locale$ProTreeModal3;
19
19
  var value = props.value,
20
+ label = props.label,
20
21
  disabled = props.disabled,
21
22
  isView = props.isView,
22
23
  triggerStyle = props.triggerStyle,
@@ -34,7 +35,7 @@ function Trigger(props) {
34
35
  state = _useSetState2[0],
35
36
  setState = _useSetState2[1];
36
37
  useEffect(function () {
37
- if (checkAll && appoint) {
38
+ if (allValue === value && appoint) {
38
39
  setState({
39
40
  mode: 'all'
40
41
  });
@@ -51,7 +52,9 @@ function Trigger(props) {
51
52
  return _jsxs("div", {
52
53
  className: "pro-tree-modal-isView",
53
54
  children: [_jsx("div", {
54
- children: checkedValues.length === 0 ? '-' : checkAll ? locale === null || locale === void 0 ? void 0 : locale.ProTreeModal.checkAll : formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProTreeModal = locale.ProTreeModal) === null || _locale$ProTreeModal === void 0 ? void 0 : _locale$ProTreeModal.checkNumber, {
55
+ children: checkedValues.length === 0 ? '-' : state.mode === 'all' ? formatMessage(locale === null || locale === void 0 ? void 0 : locale.ProTreeModal.checkAll1, {
56
+ all: label
57
+ }) : formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProTreeModal = locale.ProTreeModal) === null || _locale$ProTreeModal === void 0 ? void 0 : _locale$ProTreeModal.checkNumber, {
55
58
  num: checkedValues.length
56
59
  })
57
60
  }), _jsx("div", {
@@ -90,10 +93,10 @@ function Trigger(props) {
90
93
  onChange: onAppointChange,
91
94
  children: [_jsx(_Select.Option, {
92
95
  value: "all",
93
- children: "\u5168\u90E8"
96
+ children: locale === null || locale === void 0 ? void 0 : locale.ProTreeModal.specifyMode[0]
94
97
  }), _jsx(_Select.Option, {
95
98
  value: "appoint",
96
- children: "\u6307\u5B9A"
99
+ children: locale === null || locale === void 0 ? void 0 : locale.ProTreeModal.specifyMode[1]
97
100
  })]
98
101
  }), props.children]
99
102
  });
@@ -104,10 +107,12 @@ function Trigger(props) {
104
107
  children: _jsx(_Input, {
105
108
  className: classNames(disabled ? 'trigger-no-hover' : '', appoint ? 'pro-tree-modal-input-appoint' : ''),
106
109
  onClick: handleClick,
107
- value: checkedValues.length === 0 ? null : checkAll ? locale === null || locale === void 0 ? void 0 : locale.ProTreeModal.checkAll : formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProTreeModal2 = locale.ProTreeModal) === null || _locale$ProTreeModal2 === void 0 ? void 0 : _locale$ProTreeModal2.checkNumber, {
110
+ value: checkedValues.length === 0 ? null : state.mode === 'all' ? formatMessage(locale === null || locale === void 0 ? void 0 : locale.ProTreeModal.checkAll1, {
111
+ all: label
112
+ }) : formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProTreeModal2 = locale.ProTreeModal) === null || _locale$ProTreeModal2 === void 0 ? void 0 : _locale$ProTreeModal2.checkNumber, {
108
113
  num: checkedValues.length
109
114
  }),
110
- addonAfter: _jsxs("div", {
115
+ addonAfter: state.mode === 'all' ? null : _jsxs("div", {
111
116
  className: "pro-enum-input-addonAfter",
112
117
  children: [checkedValues.length > 0 && !disabled && _jsx("span", {
113
118
  className: "close-icon",
@@ -121,7 +126,7 @@ function Trigger(props) {
121
126
  })]
122
127
  }),
123
128
  placeholder: locale === null || locale === void 0 ? void 0 : (_locale$ProTreeModal3 = locale.ProTreeModal) === null || _locale$ProTreeModal3 === void 0 ? void 0 : _locale$ProTreeModal3.select,
124
- disabled: disabled || appoint && value === allValue,
129
+ disabled: disabled || state.mode === 'all',
125
130
  style: _objectSpread({}, triggerStyle)
126
131
  })
127
132
  });
@@ -42,7 +42,6 @@ var ProTreeModal = function ProTreeModal(props) {
42
42
  _props$title = props.title,
43
43
  title = _props$title === void 0 ? locale === null || locale === void 0 ? void 0 : (_locale$ProTreeModal = locale.ProTreeModal) === null || _locale$ProTreeModal === void 0 ? void 0 : _locale$ProTreeModal.select : _props$title,
44
44
  useRequest = props.useRequest,
45
- allValue = props.allValue,
46
45
  _props$showCodeName = props.showCodeName,
47
46
  showCodeName = _props$showCodeName === void 0 ? false : _props$showCodeName,
48
47
  _props$checkStrictly = props.checkStrictly,
@@ -72,9 +71,14 @@ var ProTreeModal = function ProTreeModal(props) {
72
71
  optionRender = props.optionRender,
73
72
  openChange = props.openChange,
74
73
  maxMessage = props.maxMessage;
74
+ var allValue = props.allValue;
75
75
  var modeType = mode.toUpperCase();
76
76
  var fieldNameLabel = fieldNames.label;
77
77
  var fieldNameValue = fieldNames.value;
78
+ if (appoint && !allValue) {
79
+ console.error('allValue must be input');
80
+ allValue = 'all';
81
+ }
78
82
  var _useSetState = useSetState({
79
83
  open: false,
80
84
  checkedValues: [],
@@ -217,8 +221,11 @@ var ProTreeModal = function ProTreeModal(props) {
217
221
  */
218
222
  var handleFinish = function handleFinish() {
219
223
  // 全选的时候返回 allValue 标记即可
224
+ // 3.3.2 版本全选的时候返回所有值的合集 list
220
225
  if (allValue !== undefined && state.checkAll && !draggable) {
221
- onChange === null || onChange === void 0 ? void 0 : onChange(allValue);
226
+ onChange === null || onChange === void 0 ? void 0 : onChange(state.flatTreeData.map(function (item) {
227
+ return item[fieldNameValue];
228
+ }));
222
229
  } else if (draggable && span) {
223
230
  var _listRef$current;
224
231
  // 开启 draggable 使用拖拽后的顺序
@@ -269,6 +276,7 @@ var ProTreeModal = function ProTreeModal(props) {
269
276
  treeViewData: [],
270
277
  checkAll: false
271
278
  });
279
+ onChange === null || onChange === void 0 ? void 0 : onChange(_checkedValues);
272
280
  };
273
281
  /**
274
282
  * Drawer close
@@ -493,6 +501,7 @@ var ProTreeModal = function ProTreeModal(props) {
493
501
  * @returns
494
502
  */
495
503
  var TriggerComponent = useMemo(function () {
504
+ var _props$otherProps3;
496
505
  if (trigger && /*#__PURE__*/React.isValidElement(trigger)) {
497
506
  return _jsx("div", {
498
507
  onClick: handleClick,
@@ -508,6 +517,7 @@ var ProTreeModal = function ProTreeModal(props) {
508
517
  isView: isView,
509
518
  appoint: appoint,
510
519
  allValue: allValue,
520
+ label: props === null || props === void 0 ? void 0 : (_props$otherProps3 = props.otherProps) === null || _props$otherProps3 === void 0 ? void 0 : _props$otherProps3.label,
511
521
  handleClick: handleClick,
512
522
  handleClearAll: handleClearAll,
513
523
  appointChange: appointChange
@@ -698,7 +708,7 @@ var ProTreeModal = function ProTreeModal(props) {
698
708
  title: title,
699
709
  showType: "Modal",
700
710
  className: "pro-tree-modal-container",
701
- extraLeft: allValue !== undefined && !appoint ? _jsx(_Checkbox, {
711
+ extraLeft: allValue !== undefined ? _jsx(_Checkbox, {
702
712
  checked: state.checkAll,
703
713
  disabled: disabled,
704
714
  onChange: handleAllCheck,
@@ -127,10 +127,12 @@ declare const _default: {
127
127
  selectMax: string;
128
128
  noCheck: string;
129
129
  checkAll: string;
130
+ checkAll1: string;
130
131
  check: string;
131
132
  clearAll: string;
132
133
  checkNumber: string;
133
134
  noFinal: string;
135
+ specifyMode: string[];
134
136
  };
135
137
  ProTimeLimit: {
136
138
  foreverText: string;
@@ -127,10 +127,12 @@ export default {
127
127
  selectMax: 'Select at most {max} items',
128
128
  noCheck: 'None selected yet',
129
129
  checkAll: 'Select all',
130
+ checkAll1: 'Select all {all}',
130
131
  check: 'selected',
131
132
  clearAll: 'Clear all',
132
133
  checkNumber: '{num} items selected',
133
- noFinal: 'Oops, the content you are looking for is not found.'
134
+ noFinal: 'Oops, the content you are looking for is not found.',
135
+ specifyMode: ['all', 'specify']
134
136
  },
135
137
  ProTimeLimit: {
136
138
  foreverText: 'long term'
@@ -127,9 +127,12 @@ declare const _default: {
127
127
  selectMax: string;
128
128
  noCheck: string;
129
129
  checkAll: string;
130
+ checkAll1: string;
130
131
  check: string;
131
132
  clearAll: string;
132
133
  checkNumber: string;
134
+ noFinal: string;
135
+ specifyMode: string[];
133
136
  };
134
137
  ProTimeLimit: {
135
138
  foreverText: string;
@@ -127,9 +127,12 @@ export default {
127
127
  selectMax: '最多选择{max}个',
128
128
  noCheck: '暂无已选',
129
129
  checkAll: '全选',
130
+ checkAll1: '全部{all}',
130
131
  check: '已选',
131
132
  clearAll: '清空全部',
132
- checkNumber: '已选择{num}项'
133
+ checkNumber: '已选择{num}项',
134
+ noFinal: '哎呀,你要找的内容没有找到。',
135
+ specifyMode: ['全部', '指定']
133
136
  },
134
137
  ProTimeLimit: {
135
138
  foreverText: '长期'
@@ -25,7 +25,7 @@ var componentMap = _interopRequireWildcard(require("../../../ProForm/components"
25
25
  var _Container = _interopRequireDefault(require("../../../ProForm/components/Container"));
26
26
  var _transformNames = _interopRequireDefault(require("../../../ProForm/utils/transformNames"));
27
27
  var _useFieldProps = require("../../../ProForm/utils/useFieldProps");
28
- var _useChanged3 = require("../../../ProForm/utils/useChanged");
28
+ var _useListChanged3 = require("../../../ProForm/utils/useListChanged");
29
29
  var _useRules = _interopRequireDefault(require("../../../ProForm/utils/useRules"));
30
30
  var _utils = require("../../../ProForm/utils");
31
31
  var _locale = _interopRequireDefault(require("../../../locale"));
@@ -76,7 +76,8 @@ var RenderField = function RenderField(_ref) {
76
76
  virtualKey = config.virtualKey,
77
77
  viewEmpty = config.viewEmpty,
78
78
  originalValues = config.originalValues,
79
- originalTip = config.originalTip;
79
+ originalTip = config.originalTip,
80
+ IsNew = config.IsNew;
80
81
  var _fieldProps = fieldProps || formItemProps || {};
81
82
  var _rules = rules || [];
82
83
  var _required = required;
@@ -90,6 +91,8 @@ var RenderField = function RenderField(_ref) {
90
91
  // 单行正在编辑时,临时生成一套formItem用来存储中间值,点击取消时候重置回上一次状态
91
92
  var namePath = (0, _tools.getNamePath)(name, virtualKey);
92
93
  var rowData = form.getFieldValue([].concat((0, _toConsumableArray2.default)(namePath), [index])) || record || {};
94
+ var originalArr = (0, _lodash.get)(originalValues, name);
95
+ var isAdd = IsNew(originalArr, rowData);
93
96
  var currentValue = dataIndex ? rowData === null || rowData === void 0 ? void 0 : rowData[dataIndex] : null;
94
97
  // 第三个参数
95
98
  var options = {
@@ -455,19 +458,24 @@ var RenderField = function RenderField(_ref) {
455
458
  };
456
459
  }();
457
460
  // 判断当前字段是否变更
458
- var _useChanged = (0, _useChanged3.useChanged)({
461
+ var _useListChanged = (0, _useListChanged3.useListChanged)({
459
462
  name: cellName,
460
463
  names: names,
461
464
  namesStr: [].concat((0, _toConsumableArray2.default)(baseName), [index, dataIndex]),
465
+ rowKeyPath: [].concat((0, _toConsumableArray2.default)(baseName), [index, 'rowKey']),
462
466
  originalName: originalName,
463
467
  originalNames: originalNames,
464
468
  originalValues: originalValues,
465
- form: form,
466
- equalWith: equalWith
469
+ form: form
470
+ // equalWith: (originalValue, values) => {
471
+ // console.log('originalValue', originalValue);
472
+ // console.log('values', values);
473
+ // return false;
474
+ // },
467
475
  }),
468
- _useChanged2 = (0, _slicedToArray2.default)(_useChanged, 2),
469
- changed = _useChanged2[0],
470
- originalValue = _useChanged2[1];
476
+ _useListChanged2 = (0, _slicedToArray2.default)(_useListChanged, 2),
477
+ changed = _useListChanged2[0],
478
+ originalValue = _useListChanged2[1];
471
479
  var componentProps = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
472
480
  form: form,
473
481
  name: cellName,
@@ -109,6 +109,15 @@ var ProEditTable = function ProEditTable(_ref, ref) {
109
109
  }
110
110
  return key;
111
111
  };
112
+ var IsNew = function IsNew(preArr, record) {
113
+ var _preArr$find;
114
+ if (!(preArr === null || preArr === void 0 ? void 0 : preArr.length)) {
115
+ return false;
116
+ }
117
+ return !(preArr === null || preArr === void 0 ? void 0 : (_preArr$find = preArr.find) === null || _preArr$find === void 0 ? void 0 : _preArr$find.call(preArr, function (item) {
118
+ return getRowKey(item) === getRowKey(record);
119
+ }));
120
+ };
112
121
  var config = {
113
122
  form: form,
114
123
  mode: mode,
@@ -139,12 +148,17 @@ var ProEditTable = function ProEditTable(_ref, ref) {
139
148
  page: page,
140
149
  originalValues: originalValues,
141
150
  originalTip: originalTip,
142
- prefixCls: prefixCls
151
+ prefixCls: prefixCls,
152
+ IsNew: IsNew
143
153
  };
144
154
  // 编辑行设置下样式
145
155
  var _rowClassName = function _rowClassName(record) {
146
156
  var isEdit = !virtualKey || editingKeys.includes(record.rowKey);
147
157
  var className = isEdit ? 'is-editing' : '';
158
+ var originalArr = (0, _lodash.get)(originalValues, name);
159
+ if (!isEdit && IsNew(originalArr, record)) {
160
+ return "is-new-row ".concat(className);
161
+ }
148
162
  return className;
149
163
  };
150
164
  // 复选框
@@ -249,11 +263,16 @@ var ProEditTable = function ProEditTable(_ref, ref) {
249
263
  var _value$;
250
264
  // 初始化默认生成row-key
251
265
  if ((value === null || value === void 0 ? void 0 : value.length) && !(value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey)) {
266
+ var _originalArr$forEach;
252
267
  var nextValues = value === null || value === void 0 ? void 0 : value.map(function (item) {
253
268
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
254
269
  rowKey: getRowKey(item)
255
270
  });
256
271
  });
272
+ var originalArr = (0, _lodash.get)(originalValues, name);
273
+ originalArr === null || originalArr === void 0 ? void 0 : (_originalArr$forEach = originalArr.forEach) === null || _originalArr$forEach === void 0 ? void 0 : _originalArr$forEach.call(originalArr, function (item) {
274
+ item.rowKey = getRowKey(item);
275
+ });
257
276
  onChange(nextValues);
258
277
  if (virtualKey) {
259
278
  form.setFieldValue(virtualRowName, nextValues);
@@ -296,6 +296,11 @@
296
296
  }
297
297
  }
298
298
 
299
+ .is-new-row, .is-new-row.@{ant-prefix}-table-row:hover {
300
+ td, .@{ant-prefix}-table-cell-row-hover {
301
+ background: var(--ant-primary-2) !important;
302
+ }
303
+ }
299
304
  }
300
305
 
301
306
  .pro-edit-table-header {
@@ -56,7 +56,8 @@
56
56
  visibility: unset;
57
57
  }
58
58
 
59
- .@{ant-prefix}-input-affix-wrapper:hover span.@{ant-prefix}-input-clear-icon[class~='ant-input-clear-icon-hidden'] {
59
+ .@{ant-prefix}-input-affix-wrapper:hover
60
+ span.@{ant-prefix}-input-clear-icon[class~='ant-input-clear-icon-hidden'] {
60
61
  display: unset;
61
62
  visibility: hidden;
62
63
  }
@@ -140,9 +141,9 @@
140
141
  }
141
142
  }
142
143
 
143
- .@{ant-prefix}-form-item-control-input-content > span {
144
- background: @zaui-contract-bg;
144
+ .@{ant-prefix}-form-item-control-input-content > .pro-form-view-container {
145
145
  padding: 4px 8px;
146
+ background: @zaui-contract-bg;
146
147
  border-radius: 4px;
147
148
  }
148
149
  }
@@ -306,7 +307,7 @@
306
307
 
307
308
  div.pro-form-custom-footer {
308
309
  width: unset !important;
309
- height:32px;
310
+ height: 32px;
310
311
  margin-bottom: calc(var(--zaui-height-size-md, 16px) * var(--zaui-size, 1));
311
312
 
312
313
  &.pro-form-custom-footer-hidden {
@@ -1,6 +1,5 @@
1
1
  import { FormInstance } from 'antd';
2
2
  interface Params {
3
- originalValues: any;
4
3
  originalValue: any;
5
4
  value: any;
6
5
  form: FormInstance;
@@ -8,7 +8,6 @@ var _lodash = require("lodash");
8
8
  var nullValue = [null, undefined, '']; // 输入框空值时可能存在的三种值 视为相等
9
9
  var contrastOriginal = exports.contrastOriginal = function contrastOriginal(params) {
10
10
  var originalValue = params.originalValue,
11
- originalValues = params.originalValues,
12
11
  value = params.value,
13
12
  equalWith = params.equalWith;
14
13
  // 支持传入自定义比较事件
@@ -1,15 +1,8 @@
1
- import { FormInstance } from 'antd';
2
- import { NamePath } from 'antd/lib/form/interface';
3
- interface Params {
4
- name?: NamePath;
5
- names?: NamePath[];
6
- namesStr?: NamePath;
7
- originalName?: NamePath;
8
- originalNames?: NamePath[];
9
- originalNameStr?: NamePath;
1
+ export declare const useChanged: ({ name, names, namesStr, originalValues, form, equalWith }: {
2
+ name: any;
3
+ names: any;
4
+ namesStr: any;
10
5
  originalValues: any;
11
- form: FormInstance;
12
- equalWith?: (originalValue: any, currentValue: any) => boolean;
13
- }
14
- export declare const useChanged: (params: Params) => any[];
15
- export {};
6
+ form: any;
7
+ equalWith: any;
8
+ }) => any[];
@@ -7,30 +7,23 @@ exports.useChanged = void 0;
7
7
  var _antd = require("antd");
8
8
  var _lodash = require("lodash");
9
9
  var _contrastOriginal = require("./contrastOriginal");
10
- var useChanged = exports.useChanged = function useChanged(params) {
11
- var name = params.name,
12
- names = params.names,
13
- namesStr = params.namesStr,
14
- _params$originalName = params.originalName,
15
- originalName = _params$originalName === void 0 ? name : _params$originalName,
16
- _params$originalNames = params.originalNames,
17
- originalNames = _params$originalNames === void 0 ? names : _params$originalNames,
18
- originalValues = params.originalValues,
19
- form = params.form,
20
- equalWith = params.equalWith;
21
- var _form = form;
22
- var originalValue = (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
23
- return (0, _lodash.get)(originalValues, originalName);
24
- }) : (0, _lodash.get)(originalValues, originalName);
10
+ var useChanged = exports.useChanged = function useChanged(_ref) {
11
+ var name = _ref.name,
12
+ names = _ref.names,
13
+ namesStr = _ref.namesStr,
14
+ originalValues = _ref.originalValues,
15
+ form = _ref.form,
16
+ equalWith = _ref.equalWith;
17
+ var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
18
+ return (0, _lodash.get)(originalValues, name);
19
+ }) : (0, _lodash.get)(originalValues, name);
25
20
  var notWatch = !originalValues || originalValue === undefined;
26
- // @ts-ignore
27
- if (notWatch) _form = [];
28
- var value = _antd.Form.useWatch(namesStr || name, _form);
21
+ if (notWatch) form = [];
22
+ var value = _antd.Form.useWatch(namesStr || name, form);
29
23
  if (notWatch) return [false];
30
24
  var changed = (0, _contrastOriginal.contrastOriginal)({
31
- value: value,
32
25
  originalValue: originalValue,
33
- originalValues: originalValues,
26
+ value: value,
34
27
  form: form,
35
28
  equalWith: equalWith
36
29
  });
@@ -0,0 +1,16 @@
1
+ import { FormInstance } from 'antd';
2
+ import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
3
+ interface Params {
4
+ name?: NamePath;
5
+ names?: NamePath[];
6
+ namesStr?: NamePath;
7
+ originalName?: NamePath;
8
+ originalNames?: NamePath[];
9
+ originalNameStr?: NamePath;
10
+ originalValues: any;
11
+ form: FormInstance;
12
+ rowKeyPath?: InternalNamePath;
13
+ equalWith?: (originalValue: any, currentValue: any) => boolean;
14
+ }
15
+ export declare const useListChanged: (params: Params) => any[];
16
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useListChanged = void 0;
7
+ var _antd = require("antd");
8
+ var _lodash = require("lodash");
9
+ var _contrastOriginal = require("./contrastOriginal");
10
+ var toNamePath = function toNamePath(name) {
11
+ if (Array.isArray(name)) {
12
+ return name;
13
+ }
14
+ return [name];
15
+ };
16
+ var toNamePaths = function toNamePaths(names) {
17
+ return names.map(function (name) {
18
+ return toNamePath(name);
19
+ });
20
+ };
21
+ var getOriginalValue = function getOriginalValue(_ref) {
22
+ var namePath = _ref.namePath,
23
+ originalName = _ref.originalName,
24
+ originalNames = _ref.originalNames,
25
+ originalValues = _ref.originalValues,
26
+ rowKeyPath = _ref.rowKeyPath,
27
+ form = _ref.form;
28
+ if (!originalValues) {
29
+ return undefined;
30
+ }
31
+ if (rowKeyPath) {
32
+ var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
33
+ var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
34
+ var rowValue = form.getFieldValue(rowValueNamePath);
35
+ var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
36
+ if (!keyValue) return undefined;
37
+ var originalValueList = (0, _lodash.get)(originalValues, originalName.slice(0, rowKeyPath.length - 2));
38
+ var originalValueRow = originalValueList.find(function (item) {
39
+ return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
40
+ });
41
+ var originalValue = (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
42
+ return (0, _lodash.get)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
43
+ }) : (0, _lodash.get)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
44
+ return originalValue;
45
+ }
46
+ return (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
47
+ return (0, _lodash.get)(originalValues, originalName);
48
+ }) : (0, _lodash.get)(originalValues, originalName);
49
+ };
50
+ var useListChanged = exports.useListChanged = function useListChanged(params) {
51
+ var name = params.name,
52
+ names = params.names,
53
+ namesStr = params.namesStr,
54
+ _params$originalName = params.originalName,
55
+ originalName = _params$originalName === void 0 ? name : _params$originalName,
56
+ _params$originalNames = params.originalNames,
57
+ originalNames = _params$originalNames === void 0 ? names : _params$originalNames,
58
+ originalValues = params.originalValues,
59
+ form = params.form,
60
+ equalWith = params.equalWith,
61
+ rowKeyPath = params.rowKeyPath;
62
+ // let _form = form;
63
+ var namePath = toNamePath(namesStr || name);
64
+ var originalNamePath = toNamePath(originalName);
65
+ var originalNamePaths = originalNames && toNamePaths(originalNames);
66
+ var originalValue = getOriginalValue({
67
+ namePath: namePath,
68
+ originalName: originalNamePath,
69
+ originalNames: originalNamePaths,
70
+ originalValues: originalValues,
71
+ rowKeyPath: rowKeyPath,
72
+ form: form
73
+ });
74
+ var notWatch = !originalValues || originalValue === undefined;
75
+ // @ts-ignore
76
+ // if (notWatch) _form = [];
77
+ var value = _antd.Form.useWatch(namePath, form);
78
+ if (notWatch) return [false];
79
+ var changed = (0, _contrastOriginal.contrastOriginal)({
80
+ value: value,
81
+ originalValue: originalValue,
82
+ form: form,
83
+ equalWith: equalWith
84
+ });
85
+ return [changed, originalValue];
86
+ };
@@ -11,14 +11,17 @@ var _OpenMenu = _interopRequireDefault(require("./OpenMenu"));
11
11
  var _FoldMenu = _interopRequireDefault(require("./FoldMenu"));
12
12
  // 折叠后菜单
13
13
  var Menu = function Menu(props) {
14
- var headerHeight = props.headerHeight,
15
- dataSource = props.dataSource,
16
- iconfontUrl = props.iconfontUrl,
17
- collapsed = props.collapsed,
18
- notice = props.notice,
19
- onToggle = props.onToggle,
20
- pure = props.pure,
21
- theme = props.theme;
14
+ var _ref = props || {},
15
+ headerHeight = _ref.headerHeight,
16
+ dataSource = _ref.dataSource,
17
+ iconfontUrl = _ref.iconfontUrl,
18
+ collapsed = _ref.collapsed,
19
+ notice = _ref.notice,
20
+ onToggle = _ref.onToggle,
21
+ pure = _ref.pure,
22
+ theme = _ref.theme,
23
+ sideMenuFooterRender = _ref.sideMenuFooterRender,
24
+ sideMenuHeaderRender = _ref.sideMenuHeaderRender;
22
25
  var menus = [];
23
26
  var menuCls = (0, _classnames.default)({
24
27
  'pro-layout-menu': true,
@@ -37,7 +40,7 @@ var Menu = function Menu(props) {
37
40
  style: {
38
41
  top: notice ? 80 + headerHeight - 48 : headerHeight
39
42
  },
40
- children: [(0, _jsxRuntime.jsx)(_OpenMenu.default, {
43
+ children: [sideMenuHeaderRender, (0, _jsxRuntime.jsx)(_OpenMenu.default, {
41
44
  dataSource: {
42
45
  menus: menus,
43
46
  iconfontUrl: iconfontUrl,
@@ -60,7 +63,7 @@ var Menu = function Menu(props) {
60
63
  display: collapsed ? 'none' : 'block',
61
64
  height: "calc(100vh - ".concat(headerHeight + (notice ? 32 : 0) + 48 || 0, "px)")
62
65
  }
63
- }), (0, _jsxRuntime.jsx)("div", {
66
+ }), sideMenuFooterRender || (0, _jsxRuntime.jsx)("div", {
64
67
  className: "pro-layout-menu-collapsed",
65
68
  onClick: onToggle,
66
69
  children: (0, _jsxRuntime.jsx)("div", {
@@ -36,6 +36,8 @@ export interface ProLayoutProps {
36
36
  rightContentRender?: ReactNode;
37
37
  headerContentRender?: ReactNode;
38
38
  headerTitleRender?: ReactNode;
39
+ sideMenuHeaderRender?: ReactNode;
40
+ sideMenuFooterRender?: ReactNode;
39
41
  headerNotice?: ReactNode | string;
40
42
  notice?: ReactNode | string;
41
43
  title?: string;
@@ -2,6 +2,7 @@ import { CSSProperties } from 'react';
2
2
  interface TriggerProps {
3
3
  checkedValues: any[];
4
4
  value: any;
5
+ label?: React.ReactNode;
5
6
  disabled?: boolean;
6
7
  isView?: boolean;
7
8
  checkAll?: boolean;
@@ -20,6 +20,7 @@ var _view = _interopRequireDefault(require("../../assets/view.svg"));
20
20
  function Trigger(props) {
21
21
  var _locale$ProTreeModal2, _locale$ProTreeModal3;
22
22
  var value = props.value,
23
+ label = props.label,
23
24
  disabled = props.disabled,
24
25
  isView = props.isView,
25
26
  triggerStyle = props.triggerStyle,
@@ -37,7 +38,7 @@ function Trigger(props) {
37
38
  state = _useSetState2[0],
38
39
  setState = _useSetState2[1];
39
40
  (0, _react.useEffect)(function () {
40
- if (checkAll && appoint) {
41
+ if (allValue === value && appoint) {
41
42
  setState({
42
43
  mode: 'all'
43
44
  });
@@ -54,7 +55,9 @@ function Trigger(props) {
54
55
  return (0, _jsxRuntime.jsxs)("div", {
55
56
  className: "pro-tree-modal-isView",
56
57
  children: [(0, _jsxRuntime.jsx)("div", {
57
- children: checkedValues.length === 0 ? '-' : checkAll ? _locale.default === null || _locale.default === void 0 ? void 0 : _locale.default.ProTreeModal.checkAll : (0, _locale.formatMessage)(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProTreeModal = _locale.default.ProTreeModal) === null || _locale$ProTreeModal === void 0 ? void 0 : _locale$ProTreeModal.checkNumber, {
58
+ children: checkedValues.length === 0 ? '-' : state.mode === 'all' ? (0, _locale.formatMessage)(_locale.default === null || _locale.default === void 0 ? void 0 : _locale.default.ProTreeModal.checkAll1, {
59
+ all: label
60
+ }) : (0, _locale.formatMessage)(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProTreeModal = _locale.default.ProTreeModal) === null || _locale$ProTreeModal === void 0 ? void 0 : _locale$ProTreeModal.checkNumber, {
58
61
  num: checkedValues.length
59
62
  })
60
63
  }), (0, _jsxRuntime.jsx)("div", {
@@ -93,10 +96,10 @@ function Trigger(props) {
93
96
  onChange: onAppointChange,
94
97
  children: [(0, _jsxRuntime.jsx)(_antd.Select.Option, {
95
98
  value: "all",
96
- children: "\u5168\u90E8"
99
+ children: _locale.default === null || _locale.default === void 0 ? void 0 : _locale.default.ProTreeModal.specifyMode[0]
97
100
  }), (0, _jsxRuntime.jsx)(_antd.Select.Option, {
98
101
  value: "appoint",
99
- children: "\u6307\u5B9A"
102
+ children: _locale.default === null || _locale.default === void 0 ? void 0 : _locale.default.ProTreeModal.specifyMode[1]
100
103
  })]
101
104
  }), props.children]
102
105
  });
@@ -107,10 +110,12 @@ function Trigger(props) {
107
110
  children: (0, _jsxRuntime.jsx)(_antd.Input, {
108
111
  className: (0, _classnames.default)(disabled ? 'trigger-no-hover' : '', appoint ? 'pro-tree-modal-input-appoint' : ''),
109
112
  onClick: handleClick,
110
- value: checkedValues.length === 0 ? null : checkAll ? _locale.default === null || _locale.default === void 0 ? void 0 : _locale.default.ProTreeModal.checkAll : (0, _locale.formatMessage)(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProTreeModal2 = _locale.default.ProTreeModal) === null || _locale$ProTreeModal2 === void 0 ? void 0 : _locale$ProTreeModal2.checkNumber, {
113
+ value: checkedValues.length === 0 ? null : state.mode === 'all' ? (0, _locale.formatMessage)(_locale.default === null || _locale.default === void 0 ? void 0 : _locale.default.ProTreeModal.checkAll1, {
114
+ all: label
115
+ }) : (0, _locale.formatMessage)(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProTreeModal2 = _locale.default.ProTreeModal) === null || _locale$ProTreeModal2 === void 0 ? void 0 : _locale$ProTreeModal2.checkNumber, {
111
116
  num: checkedValues.length
112
117
  }),
113
- addonAfter: (0, _jsxRuntime.jsxs)("div", {
118
+ addonAfter: state.mode === 'all' ? null : (0, _jsxRuntime.jsxs)("div", {
114
119
  className: "pro-enum-input-addonAfter",
115
120
  children: [checkedValues.length > 0 && !disabled && (0, _jsxRuntime.jsx)("span", {
116
121
  className: "close-icon",
@@ -124,7 +129,7 @@ function Trigger(props) {
124
129
  })]
125
130
  }),
126
131
  placeholder: _locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProTreeModal3 = _locale.default.ProTreeModal) === null || _locale$ProTreeModal3 === void 0 ? void 0 : _locale$ProTreeModal3.select,
127
- disabled: disabled || appoint && value === allValue,
132
+ disabled: disabled || state.mode === 'all',
128
133
  style: (0, _objectSpread2.default)({}, triggerStyle)
129
134
  })
130
135
  });
@@ -43,7 +43,6 @@ var ProTreeModal = function ProTreeModal(props) {
43
43
  _props$title = props.title,
44
44
  title = _props$title === void 0 ? _locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProTreeModal = _locale.default.ProTreeModal) === null || _locale$ProTreeModal === void 0 ? void 0 : _locale$ProTreeModal.select : _props$title,
45
45
  useRequest = props.useRequest,
46
- allValue = props.allValue,
47
46
  _props$showCodeName = props.showCodeName,
48
47
  showCodeName = _props$showCodeName === void 0 ? false : _props$showCodeName,
49
48
  _props$checkStrictly = props.checkStrictly,
@@ -73,9 +72,14 @@ var ProTreeModal = function ProTreeModal(props) {
73
72
  optionRender = props.optionRender,
74
73
  openChange = props.openChange,
75
74
  maxMessage = props.maxMessage;
75
+ var allValue = props.allValue;
76
76
  var modeType = mode.toUpperCase();
77
77
  var fieldNameLabel = fieldNames.label;
78
78
  var fieldNameValue = fieldNames.value;
79
+ if (appoint && !allValue) {
80
+ console.error('allValue must be input');
81
+ allValue = 'all';
82
+ }
79
83
  var _useSetState = (0, _ahooks.useSetState)({
80
84
  open: false,
81
85
  checkedValues: [],
@@ -218,8 +222,11 @@ var ProTreeModal = function ProTreeModal(props) {
218
222
  */
219
223
  var handleFinish = function handleFinish() {
220
224
  // 全选的时候返回 allValue 标记即可
225
+ // 3.3.2 版本全选的时候返回所有值的合集 list
221
226
  if (allValue !== undefined && state.checkAll && !draggable) {
222
- onChange === null || onChange === void 0 ? void 0 : onChange(allValue);
227
+ onChange === null || onChange === void 0 ? void 0 : onChange(state.flatTreeData.map(function (item) {
228
+ return item[fieldNameValue];
229
+ }));
223
230
  } else if (draggable && span) {
224
231
  var _listRef$current;
225
232
  // 开启 draggable 使用拖拽后的顺序
@@ -270,6 +277,7 @@ var ProTreeModal = function ProTreeModal(props) {
270
277
  treeViewData: [],
271
278
  checkAll: false
272
279
  });
280
+ onChange === null || onChange === void 0 ? void 0 : onChange(_checkedValues);
273
281
  };
274
282
  /**
275
283
  * Drawer close
@@ -494,6 +502,7 @@ var ProTreeModal = function ProTreeModal(props) {
494
502
  * @returns
495
503
  */
496
504
  var TriggerComponent = (0, _react.useMemo)(function () {
505
+ var _props$otherProps3;
497
506
  if (trigger && /*#__PURE__*/_react.default.isValidElement(trigger)) {
498
507
  return (0, _jsxRuntime.jsx)("div", {
499
508
  onClick: handleClick,
@@ -509,6 +518,7 @@ var ProTreeModal = function ProTreeModal(props) {
509
518
  isView: isView,
510
519
  appoint: appoint,
511
520
  allValue: allValue,
521
+ label: props === null || props === void 0 ? void 0 : (_props$otherProps3 = props.otherProps) === null || _props$otherProps3 === void 0 ? void 0 : _props$otherProps3.label,
512
522
  handleClick: handleClick,
513
523
  handleClearAll: handleClearAll,
514
524
  appointChange: appointChange
@@ -699,7 +709,7 @@ var ProTreeModal = function ProTreeModal(props) {
699
709
  title: title,
700
710
  showType: "Modal",
701
711
  className: "pro-tree-modal-container",
702
- extraLeft: allValue !== undefined && !appoint ? (0, _jsxRuntime.jsx)(_antd.Checkbox, {
712
+ extraLeft: allValue !== undefined ? (0, _jsxRuntime.jsx)(_antd.Checkbox, {
703
713
  checked: state.checkAll,
704
714
  disabled: disabled,
705
715
  onChange: handleAllCheck,
@@ -127,10 +127,12 @@ declare const _default: {
127
127
  selectMax: string;
128
128
  noCheck: string;
129
129
  checkAll: string;
130
+ checkAll1: string;
130
131
  check: string;
131
132
  clearAll: string;
132
133
  checkNumber: string;
133
134
  noFinal: string;
135
+ specifyMode: string[];
134
136
  };
135
137
  ProTimeLimit: {
136
138
  foreverText: string;
@@ -133,10 +133,12 @@ var _default = exports.default = {
133
133
  selectMax: 'Select at most {max} items',
134
134
  noCheck: 'None selected yet',
135
135
  checkAll: 'Select all',
136
+ checkAll1: 'Select all {all}',
136
137
  check: 'selected',
137
138
  clearAll: 'Clear all',
138
139
  checkNumber: '{num} items selected',
139
- noFinal: 'Oops, the content you are looking for is not found.'
140
+ noFinal: 'Oops, the content you are looking for is not found.',
141
+ specifyMode: ['all', 'specify']
140
142
  },
141
143
  ProTimeLimit: {
142
144
  foreverText: 'long term'
@@ -127,9 +127,12 @@ declare const _default: {
127
127
  selectMax: string;
128
128
  noCheck: string;
129
129
  checkAll: string;
130
+ checkAll1: string;
130
131
  check: string;
131
132
  clearAll: string;
132
133
  checkNumber: string;
134
+ noFinal: string;
135
+ specifyMode: string[];
133
136
  };
134
137
  ProTimeLimit: {
135
138
  foreverText: string;
@@ -133,9 +133,12 @@ var _default = exports.default = {
133
133
  selectMax: '最多选择{max}个',
134
134
  noCheck: '暂无已选',
135
135
  checkAll: '全选',
136
+ checkAll1: '全部{all}',
136
137
  check: '已选',
137
138
  clearAll: '清空全部',
138
- checkNumber: '已选择{num}项'
139
+ checkNumber: '已选择{num}项',
140
+ noFinal: '哎呀,你要找的内容没有找到。',
141
+ specifyMode: ['全部', '指定']
139
142
  },
140
143
  ProTimeLimit: {
141
144
  foreverText: '长期'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.3.1-beta.6",
3
+ "version": "3.3.1-beta.7",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",