ronds-metadata 1.0.98 → 1.1.1
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.
@@ -32,7 +32,6 @@ var Editable = function Editable(props) {
|
|
32
32
|
addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition,
|
33
33
|
_props$isAddColumn = props.isAddColumn,
|
34
34
|
isAddColumn = _props$isAddColumn === void 0 ? false : _props$isAddColumn,
|
35
|
-
whiteColumn = props.whiteColumn,
|
36
35
|
tableProps = props.tableProps,
|
37
36
|
onRowConfirm = props.onRowConfirm,
|
38
37
|
onRowDelete = props.onRowDelete,
|
@@ -67,16 +66,9 @@ var Editable = function Editable(props) {
|
|
67
66
|
var _React$useState9 = React.useState(),
|
68
67
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
69
68
|
editHeardCellKey = _React$useState10[0],
|
70
|
-
setEditHeardCellkey = _React$useState10[1]; //
|
69
|
+
setEditHeardCellkey = _React$useState10[1]; // 记录上一次发生改变的行值
|
71
70
|
|
72
71
|
|
73
|
-
var _React$useState11 = React.useState([]),
|
74
|
-
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
75
|
-
addColumns = _React$useState12[0],
|
76
|
-
setAddColumns = _React$useState12[1];
|
77
|
-
|
78
|
-
var addColumnsRef = React.useRef([]); // 记录上一次发生改变的行值
|
79
|
-
|
80
72
|
var lastValueRef = React.useRef(); // 记录上一次的datasource
|
81
73
|
|
82
74
|
var lastDataSourceRef = React.useRef();
|
@@ -128,14 +120,6 @@ var Editable = function Editable(props) {
|
|
128
120
|
setEditHeardCellkey(data.payload);
|
129
121
|
break;
|
130
122
|
|
131
|
-
case 'onAddColumn':
|
132
|
-
processAddColumnsData(data.payload);
|
133
|
-
break;
|
134
|
-
|
135
|
-
case 'onDeleteColumn':
|
136
|
-
processDeleteColumnsData(data.payload);
|
137
|
-
break;
|
138
|
-
|
139
123
|
case 'onSingleSave':
|
140
124
|
if (lastValueRef.current && lastValueRef.current.rowIdx === data.payload._rowKey_) {
|
141
125
|
onRowConfirm && onRowConfirm({
|
@@ -202,52 +186,7 @@ var Editable = function Editable(props) {
|
|
202
186
|
}
|
203
187
|
}, [type]); // 集中处理数据流
|
204
188
|
|
205
|
-
useObservable(processStreamFactory, [editableStream]);
|
206
|
-
|
207
|
-
var processAddColumnsData = function processAddColumnsData(data) {
|
208
|
-
var _columns = addColumnsRef.current.length > 0 ? addColumnsRef.current : columns; // 判断key是否重复
|
209
|
-
|
210
|
-
|
211
|
-
if (_columns.findIndex(function (v) {
|
212
|
-
return v.key === data.key;
|
213
|
-
}) > -1) {
|
214
|
-
// message.warning('表格的key不可以重复');
|
215
|
-
return;
|
216
|
-
}
|
217
|
-
|
218
|
-
var idx = _columns.findIndex(function (v) {
|
219
|
-
return v.dataIndex === data.dataIndex;
|
220
|
-
});
|
221
|
-
|
222
|
-
var obj = {
|
223
|
-
title: data.title,
|
224
|
-
key: data.key,
|
225
|
-
dataIndex: data.key
|
226
|
-
};
|
227
|
-
|
228
|
-
_columns.splice(idx + 1, 0, _objectSpread(_objectSpread({}, _columns[0]), obj));
|
229
|
-
|
230
|
-
setAddColumns(_toConsumableArray(_columns));
|
231
|
-
addColumnsRef.current = _columns; // editableStream.next({ type: 'editHeardCellKey', payload: undefined });
|
232
|
-
};
|
233
|
-
|
234
|
-
var processDeleteColumnsData = function processDeleteColumnsData(data) {
|
235
|
-
var _columns = addColumnsRef.current.length > 0 ? addColumnsRef.current : columns;
|
236
|
-
|
237
|
-
if (whiteColumn.findIndex(function (v) {
|
238
|
-
return v === data.dataIndex;
|
239
|
-
}) > -1) {
|
240
|
-
// message.warning(`${data.dataIndex}无法删除`);
|
241
|
-
return;
|
242
|
-
}
|
243
|
-
|
244
|
-
_columns = _columns.filter(function (v) {
|
245
|
-
return v.dataIndex != data.dataIndex;
|
246
|
-
});
|
247
|
-
setAddColumns(_toConsumableArray(_columns));
|
248
|
-
addColumnsRef.current = _columns; // editableStream.next({ type: 'editHeardCellKey', payload: undefined });
|
249
|
-
}; // 返回stream的实例
|
250
|
-
|
189
|
+
useObservable(processStreamFactory, [editableStream]); // 返回stream的实例
|
251
190
|
|
252
191
|
React.useEffect(function () {
|
253
192
|
if (firstLoadRef && editableStream) {
|
@@ -290,7 +229,7 @@ var Editable = function Editable(props) {
|
|
290
229
|
}, [readonly, type]); // 处理一下编辑表格的数据
|
291
230
|
|
292
231
|
var _columns = React.useMemo(function () {
|
293
|
-
var __columns__ =
|
232
|
+
var __columns__ = columns;
|
294
233
|
|
295
234
|
var res = __columns__.map(getEditColumn);
|
296
235
|
|
@@ -317,7 +256,7 @@ var Editable = function Editable(props) {
|
|
317
256
|
}
|
318
257
|
|
319
258
|
return res;
|
320
|
-
}, [columns, readonly, type
|
259
|
+
}, [columns, readonly, type]); // 主要是自己加一层rowkey
|
321
260
|
|
322
261
|
|
323
262
|
var _dataSource = React.useMemo(function () {
|
@@ -380,6 +319,7 @@ var Editable = function Editable(props) {
|
|
380
319
|
}
|
381
320
|
}
|
382
321
|
}, /*#__PURE__*/React.createElement(_Table, _extends({
|
322
|
+
key: _columns.length,
|
383
323
|
className: "ronds-edit-table",
|
384
324
|
bordered: true,
|
385
325
|
scroll: {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { FormInstance } from 'antd';
|
1
2
|
import './index.less';
|
2
3
|
interface IMetadataEditProps {
|
3
4
|
/**
|
@@ -20,6 +21,10 @@ interface IMetadataEditProps {
|
|
20
21
|
* 添加新的引用类型点击事件
|
21
22
|
*/
|
22
23
|
onNewRefClick?: () => void;
|
24
|
+
/**
|
25
|
+
* 获取表单的实例
|
26
|
+
*/
|
27
|
+
getFormInstance?: (form: FormInstance) => void;
|
23
28
|
}
|
24
29
|
declare const MetadataEdit: (props: IMetadataEditProps) => JSX.Element;
|
25
30
|
export default MetadataEdit;
|
@@ -23,7 +23,8 @@ var MetadataEdit = function MetadataEdit(props) {
|
|
23
23
|
isNameDisabled = props.isNameDisabled,
|
24
24
|
metadataTag = props.metadataTag,
|
25
25
|
onFinish = props.onFinish,
|
26
|
-
onNewRefClick = props.onNewRefClick
|
26
|
+
onNewRefClick = props.onNewRefClick,
|
27
|
+
getFormInstance = props.getFormInstance;
|
27
28
|
|
28
29
|
var _Form$useForm = _Form.useForm(),
|
29
30
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
@@ -62,7 +63,16 @@ var MetadataEdit = function MetadataEdit(props) {
|
|
62
63
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
63
64
|
curFields = _React$useState10[0],
|
64
65
|
setCurFields = _React$useState10[1];
|
66
|
+
/**
|
67
|
+
* 获取form的实例
|
68
|
+
*/
|
65
69
|
|
70
|
+
|
71
|
+
React.useEffect(function () {
|
72
|
+
if (form) {
|
73
|
+
getFormInstance && getFormInstance(form);
|
74
|
+
}
|
75
|
+
}, [form]);
|
66
76
|
React.useEffect(function () {
|
67
77
|
form.setFieldsValue({
|
68
78
|
id: 'Test'
|