ztxkui 4.2.23-574 → 4.2.23-575
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.
|
@@ -343,6 +343,25 @@ function useColumns(tableHandleRef) {
|
|
|
343
343
|
return React.createElement("div", null, "123123");
|
|
344
344
|
},
|
|
345
345
|
},
|
|
346
|
+
{
|
|
347
|
+
title: i18next.t('商品描述'),
|
|
348
|
+
width: 120,
|
|
349
|
+
dataIndex: 'productDesc',
|
|
350
|
+
key: 'productDesc',
|
|
351
|
+
// hideColumn: !isMaterialSupplementalInformation,
|
|
352
|
+
validate: {},
|
|
353
|
+
render: function (text, record, index) {
|
|
354
|
+
return (React.createElement(React.Fragment, null, true ? (React.createElement(React.Fragment, null,
|
|
355
|
+
React.createElement(Input, { maxLength: 30, value: text, onBlur: function (e) {
|
|
356
|
+
var _a, _b, _c;
|
|
357
|
+
var realyIndex = (_b = (_a = tableHandleRef.current) === null || _a === void 0 ? void 0 : _a.getRealyIndex) === null || _b === void 0 ? void 0 : _b.call(_a, index);
|
|
358
|
+
var newRecord = {
|
|
359
|
+
productDesc: e.target.value,
|
|
360
|
+
};
|
|
361
|
+
(_c = tableHandleRef.current) === null || _c === void 0 ? void 0 : _c.onEditableSaveHandle(newRecord, index);
|
|
362
|
+
}, suffix: React.createElement(React.Fragment, null, (record === null || record === void 0 ? void 0 : record.productDescIsRequired) === '1' && (React.createElement("span", { style: { color: 'red' } }, "*"))) }))) : null));
|
|
363
|
+
},
|
|
364
|
+
},
|
|
346
365
|
];
|
|
347
366
|
useEffect(function () {
|
|
348
367
|
setTimeout(function () {
|
|
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
12
23
|
import i18next from 'ztxkutils/dist/i18next';
|
|
13
24
|
import React, { useState, useEffect, isValidElement, useRef } from 'react';
|
|
14
25
|
import { Menu, Item } from 'react-contexify';
|
|
@@ -41,6 +52,7 @@ var TableMenu = function (_a) {
|
|
|
41
52
|
(originItem === null || originItem === void 0 ? void 0 : originItem.validate) ||
|
|
42
53
|
(item === null || item === void 0 ? void 0 : item.required) ||
|
|
43
54
|
(originItem === null || originItem === void 0 ? void 0 : originItem.required),
|
|
55
|
+
required: (item === null || item === void 0 ? void 0 : item.required) || (originItem === null || originItem === void 0 ? void 0 : originItem.required),
|
|
44
56
|
};
|
|
45
57
|
});
|
|
46
58
|
function onMenuItemClick(e) {
|
|
@@ -100,6 +112,23 @@ var TableMenu = function (_a) {
|
|
|
100
112
|
function onCancel() {
|
|
101
113
|
setVisible(false);
|
|
102
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* 递归代理renderItem的返回值,将表单组件的onBlur替换为onChange
|
|
117
|
+
*/
|
|
118
|
+
function proxyRenderElement(element) {
|
|
119
|
+
if (!isValidElement(element))
|
|
120
|
+
return element;
|
|
121
|
+
var _a = element.props, children = _a.children, onBlur = _a.onBlur, onChange = _a.onChange, restProps = __rest(_a, ["children", "onBlur", "onChange"]);
|
|
122
|
+
// 递归处理子元素
|
|
123
|
+
var newChildren = children != null
|
|
124
|
+
? React.Children.map(children, proxyRenderElement)
|
|
125
|
+
: children;
|
|
126
|
+
// 有onBlur且无onChange时,将onBlur替换为onChange
|
|
127
|
+
if (typeof onBlur === 'function' && typeof onChange !== 'function') {
|
|
128
|
+
return React.cloneElement(element, __assign(__assign({}, restProps), { onChange: onBlur }), newChildren);
|
|
129
|
+
}
|
|
130
|
+
return React.cloneElement(element, restProps, newChildren);
|
|
131
|
+
}
|
|
103
132
|
function renderItem(items) {
|
|
104
133
|
return items.map(function (item) {
|
|
105
134
|
var _a, _b;
|
|
@@ -119,8 +148,8 @@ var TableMenu = function (_a) {
|
|
|
119
148
|
// 如果item.render 返回的不是ReactElement,那么就使用span来包裹
|
|
120
149
|
// 做列合并时,render返回的是一个对象
|
|
121
150
|
return (React.createElement(Descriptions.Item, { key: item.key, label: React.createElement("span", { style: { display: 'flex', alignItems: 'center' } },
|
|
122
|
-
React.createElement("span", { style: { color: 'red' } }, item.
|
|
123
|
-
item.label) }, isValidElement(renderItem) ? (renderItem) : isValidElement(renderItem === null || renderItem === void 0 ? void 0 : renderItem.children) ? (renderItem === null || renderItem === void 0 ? void 0 : renderItem.children) : renderItem != null && typeof renderItem !== 'object' ? (
|
|
151
|
+
React.createElement("span", { style: { color: 'red' } }, item.required ? '*' : ''),
|
|
152
|
+
item.label) }, isValidElement(renderItem) ? (proxyRenderElement(renderItem)) : isValidElement(renderItem === null || renderItem === void 0 ? void 0 : renderItem.children) ? (proxyRenderElement(renderItem === null || renderItem === void 0 ? void 0 : renderItem.children)) : renderItem != null && typeof renderItem !== 'object' ? (
|
|
124
153
|
// render返回了string或number,直接渲染该值
|
|
125
154
|
renderItem) : (React.createElement("span", { title: currentRecord[item.key] }, currentRecord[item.key]))));
|
|
126
155
|
});
|