zmdms-webui 0.0.95 → 0.0.96

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.
@@ -62,14 +62,19 @@ var Form = function (props, ref) {
62
62
  var nameKeys = Object.keys(itemsShouldUpdate);
63
63
  nameKeys.forEach(function (nameKey) {
64
64
  var _a;
65
- var _b;
66
65
  var shouldUpdateClear = itemsShouldUpdate[nameKey]
67
66
  ? itemsShouldUpdate[nameKey]
68
67
  : [];
69
68
  if (keys_1.find(function (key) { return shouldUpdateClear.includes(key); })) {
70
- (_b = form === null || form === void 0 ? void 0 : form.setFieldsValue) === null || _b === void 0 ? void 0 : _b.call(form, (_a = {},
71
- _a[nameKey] = undefined,
72
- _a));
69
+ // 这里用undefined当清空值得话,会有点问题。
70
+ // https://github.com/react-component/select/commit/305b3dcfe627482686055a1ec9c34705623d807f
71
+ // 对于下拉框来说 会报这个警告 `label` of `value` is not same as `label` in Select options.
72
+ // 暂时不知道如何消除这个警告 yong null 和 "" 都可以
73
+ // TODO: 暂时改成null
74
+ (_a = form === null || form === void 0 ? void 0 : form.setFieldValue) === null || _a === void 0 ? void 0 : _a.call(form, nameKey, null);
75
+ // form?.setFieldsValue?.({
76
+ // [nameKey]: undefined,
77
+ // });
73
78
  }
74
79
  });
75
80
  }
@@ -40,7 +40,7 @@ function useRenderChildren(props) {
40
40
  return children;
41
41
  }
42
42
  if (Array.isArray(resultList)) {
43
- return (jsxs(Fragment, { children: [showAll && (jsx(MemoSelect.Option, __assign({ title: "\u5168\u90E8", value: "" }, { children: "\u5168\u90E8" }))), resultList === null || resultList === void 0 ? void 0 : resultList.map(function (item, index) {
43
+ return (jsxs(Fragment, { children: [showAll ? (jsx(MemoSelect.Option, __assign({ title: "\u5168\u90E8", value: "" }, { children: "\u5168\u90E8" }))) : null, resultList === null || resultList === void 0 ? void 0 : resultList.map(function (item, index) {
44
44
  if (!item) {
45
45
  console.error("\u9ED8\u8BA4\u6570\u636E\u4E2D\u6709\u7A7A\u503C \u4F4D\u7F6E\u518Dlist\u4E2D\u7B2C".concat(index + 1, "\u9879"));
46
46
  return null;
@@ -77,7 +77,9 @@ function useRenderChildren(props) {
77
77
  disabledValues.includes(value)) {
78
78
  disabled = true;
79
79
  }
80
- return (jsxs(MemoSelect.Option, __assign({ value: value, title: title, disabled: disabled }, { children: [Array.isArray(joinTitle) ? joinTitle === null || joinTitle === void 0 ? void 0 : joinTitle.join(joinStr) : "", Array.isArray(linefeedTitle) && linefeedTitle.length > 0 ? (jsx("div", __assign({ className: "ztxk-select--feed-item" }, { children: linefeedTitle === null || linefeedTitle === void 0 ? void 0 : linefeedTitle.join(lineFeedStr) }))) : ("")] }), "".concat(key).concat(index)));
80
+ return (jsxs(MemoSelect.Option
81
+ // key={`${key}${index}`}
82
+ , __assign({ value: value, title: title, disabled: disabled }, { children: [Array.isArray(joinTitle) ? joinTitle === null || joinTitle === void 0 ? void 0 : joinTitle.join(joinStr) : "", Array.isArray(linefeedTitle) && linefeedTitle.length > 0 ? (jsx("div", __assign({ className: "ztxk-select--feed-item" }, { children: linefeedTitle === null || linefeedTitle === void 0 ? void 0 : linefeedTitle.join(lineFeedStr) }))) : ("")] }), key));
81
83
  })] }));
82
84
  }
83
85
  return null;
@@ -8,18 +8,21 @@ import MemoInput from '../../input/input.js';
8
8
  import InputNumber from '../../inputnumber/inputNumber.js';
9
9
 
10
10
  var EnhanceCell = function (props) {
11
- var record = props.record, propsIndex = props.index, editable = props.editable, editableConfig = props.editableConfig, dataIndex = props.dataIndex; props.title; var onEditableSave = props.onEditableSave; props.onMouseEnter; props.onMouseLeave; var children = props.children, currentPage = props.currentPage, isValidate = props.isValidate, resetProps = __rest(props, ["record", "index", "editable", "editableConfig", "dataIndex", "title", "onEditableSave", "onMouseEnter", "onMouseLeave", "children", "currentPage", "isValidate"]);
11
+ var _a;
12
+ var record = props.record, propsIndex = props.index, editable = props.editable, editableConfig = props.editableConfig, dataIndex = props.dataIndex; props.title; var onEditableSave = props.onEditableSave, dataSourceRef = props.dataSourceRef; props.onMouseEnter; props.onMouseLeave; var children = props.children, currentPage = props.currentPage, isValidate = props.isValidate, resetProps = __rest(props, ["record", "index", "editable", "editableConfig", "dataIndex", "title", "onEditableSave", "dataSourceRef", "onMouseEnter", "onMouseLeave", "children", "currentPage", "isValidate"]);
12
13
  // 设置最新的index
13
14
  var index = getInnerIndex(currentPage, propsIndex);
15
+ // 最新的record
16
+ var newRecord = ((_a = dataSourceRef === null || dataSourceRef === void 0 ? void 0 : dataSourceRef.current) === null || _a === void 0 ? void 0 : _a[index]) || record;
14
17
  // 当前数据
15
- var _a = useState(record ? record[dataIndex] : undefined), val = _a[0], setVal = _a[1];
18
+ var _b = useState(newRecord ? newRecord[dataIndex] : undefined), val = _b[0], setVal = _b[1];
16
19
  // 当前是否是编辑状态 性能优化,显示纯字段比显示一个完整的组件 性能要高出许多
17
- var _b = useEditing(), editing = _b.editing, toggleEdit = _b.toggleEdit;
20
+ var _c = useEditing(), editing = _c.editing, toggleEdit = _c.toggleEdit;
18
21
  // 输入框ref对象
19
22
  var iptRef = useIptRef(editing);
20
23
  // 单元格Ref
21
- var _c = useTdRef(), tdRef = _c.tdRef, removeErrorClass = _c.removeErrorClass;
22
- var data = record === null || record === void 0 ? void 0 : record[dataIndex];
24
+ var _d = useTdRef(), tdRef = _d.tdRef, removeErrorClass = _d.removeErrorClass;
25
+ var data = newRecord === null || newRecord === void 0 ? void 0 : newRecord[dataIndex];
23
26
  // 外部更新值时,需要取这个值
24
27
  useEffect(function () {
25
28
  setVal(data);
@@ -31,17 +34,17 @@ var EnhanceCell = function (props) {
31
34
  throw Error("如果开启了editable, 那么必须传递 onEditableSave属性 来更改表格数据!");
32
35
  }
33
36
  toggleEdit();
34
- onEditableSave(__assign(__assign({}, record), (_a = {}, _a[dataIndex] = val, _a)), index, dataIndex);
37
+ onEditableSave(__assign(__assign({}, newRecord), (_a = {}, _a[dataIndex] = val, _a)), index, dataIndex);
35
38
  };
36
39
  // 如果开启编辑 那么内部直接代理
37
- if (typeof editable === "function" ? editable(record) : editable) {
38
- var _d = editableConfig || {
40
+ if (typeof editable === "function" ? editable(newRecord) : editable) {
41
+ var _e = editableConfig || {
39
42
  type: "input",
40
- }, type = _d.type, max = _d.max, min = _d.min, maxHandle = _d.maxHandle, minHandle = _d.minHandle, disabled = _d.disabled, disabledHandle = _d.disabledHandle, resetEditableConfigProps = __rest(_d, ["type", "max", "min", "maxHandle", "minHandle", "disabled", "disabledHandle"]);
43
+ }, type = _e.type, max = _e.max, min = _e.min, maxHandle = _e.maxHandle, minHandle = _e.minHandle, disabled = _e.disabled, disabledHandle = _e.disabledHandle, resetEditableConfigProps = __rest(_e, ["type", "max", "min", "maxHandle", "minHandle", "disabled", "disabledHandle"]);
41
44
  var CurrentReactNode = null;
42
45
  var newChildren = children;
43
46
  var resultDisabled = disabledHandle
44
- ? disabledHandle(record)
47
+ ? disabledHandle(newRecord)
45
48
  : disabled;
46
49
  // 输入框处理
47
50
  if (type === "input") {
@@ -54,8 +57,8 @@ var EnhanceCell = function (props) {
54
57
  }
55
58
  // 数字输入框处理
56
59
  if (type === "inputNumber") {
57
- var resultMax_1 = maxHandle ? maxHandle(record) : max;
58
- var resultmin_1 = minHandle ? minHandle(record) : min;
60
+ var resultMax_1 = maxHandle ? maxHandle(newRecord) : max;
61
+ var resultmin_1 = minHandle ? minHandle(newRecord) : min;
59
62
  CurrentReactNode = (jsx(InputNumber, __assign({ value: val, onChange: function (value) {
60
63
  if (typeof value === "number") {
61
64
  if (typeof resultMax_1 === "number" && value > resultMax_1) {
@@ -1,6 +1,6 @@
1
1
  import { __rest, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { memo, useRef, useEffect, useMemo, useCallback, useImperativeHandle } from 'react';
3
+ import { memo, useMemo, useCallback, useImperativeHandle } from 'react';
4
4
  import { Table as Table$1 } from 'antd';
5
5
  import { BasicBodyRow, MoveBodyRow } from './components/EnhanceBodyRow.js';
6
6
  import EnhanceCell from './components/EnhanceBodyCell.js';
@@ -19,6 +19,7 @@ import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index
19
19
  import { VList, scrollTo } from '../node_modules/virtuallist-antd/dist/index.es.js';
20
20
  import useTableValidate, { tableValidate } from './useTableValidate.js';
21
21
  import TitleDirectionColumn from './components/TitleDirectionColumn.js';
22
+ import { useLatest } from 'ahooks';
22
23
  import DynamicSetting from '../dynamicsetting/dynamicSetting.js';
23
24
  import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js';
24
25
 
@@ -37,10 +38,7 @@ var Table = function (props) {
37
38
  "ztxk-table--flex": isFlex,
38
39
  });
39
40
  // 将表格数据 在 Ref中 存储一份
40
- var dataSourceRef = useRef();
41
- useEffect(function () {
42
- dataSourceRef.current = dataSource;
43
- }, [dataSource]);
41
+ var dataSourceRef = useLatest(dataSource);
44
42
  // 得到动态列配置信息
45
43
  var _j = useDynamicListByColumns(columns, dynamicKey), defaultDynamicList = _j.defaultDynamicList, onCurrentListChange = _j.onCurrentListChange, currentDynamicList = _j.currentDynamicList, dynamicSettingRef = _j.dynamicSettingRef;
46
44
  // 针对SCU和增减行 做特殊处理
@@ -58,6 +58,7 @@ function useColumns(columns, options) {
58
58
  onEditableSave: onEditableSave,
59
59
  currentPage: currentPage,
60
60
  isValidate: validate ? true : false,
61
+ dataSourceRef: dataSourceRef,
61
62
  });
62
63
  };
63
64
  }