ronds-metadata 1.2.55 → 1.2.56
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,11 +6,11 @@ var _excluded = ["title", "isAddColumn", "editable", "record", "editableType", "
|
|
6
6
|
/*
|
7
7
|
* @Author: wangxian
|
8
8
|
* @Date: 2022-03-04 10:01:10
|
9
|
-
* @LastEditTime: 2023-
|
9
|
+
* @LastEditTime: 2023-05-23 10:17:15
|
10
10
|
*/
|
11
11
|
import React from 'react';
|
12
12
|
import { EditableContext } from '../interface';
|
13
|
-
import { getDataCell, isFreeEditCell, isFreeEditRow } from '../utils';
|
13
|
+
import { getDataCell, isCellDisabled, isFreeEditCell, isFreeEditRow } from '../utils';
|
14
14
|
import './index.less';
|
15
15
|
import Texty from './Texty';
|
16
16
|
import { tr } from '../../../framework/locale';
|
@@ -88,7 +88,7 @@ var EditableCell = function EditableCell(props) {
|
|
88
88
|
}
|
89
89
|
return /*#__PURE__*/React.createElement("td", _extends({}, restProps, {
|
90
90
|
className: "".concat(className, " ").concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
|
91
|
-
}), editable ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
|
91
|
+
}), editable && isCellDisabled(record, restProps === null || restProps === void 0 ? void 0 : restProps.cellDisabled) ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
|
92
92
|
tooltipStyle: {
|
93
93
|
wordWrap: 'break-word'
|
94
94
|
},
|
@@ -11,7 +11,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
11
11
|
/*
|
12
12
|
* @Author: wangxain
|
13
13
|
* @Date: 2022-03-04 08:53:04
|
14
|
-
* @LastEditTime: 2023-
|
14
|
+
* @LastEditTime: 2023-05-23 09:20:36
|
15
15
|
*/
|
16
16
|
import React from 'react';
|
17
17
|
import { pick, isArray } from 'lodash';
|
@@ -205,7 +205,7 @@ var Editable = function Editable(props) {
|
|
205
205
|
record: record,
|
206
206
|
editableType: type,
|
207
207
|
isAddColumn: isAddColumn
|
208
|
-
}, pick(column, ['editable', 'title', 'dataIndex', 'type', 'enum', 'mode', 'disabled'])), {}, {
|
208
|
+
}, pick(column, ['editable', 'title', 'dataIndex', 'type', 'enum', 'mode', 'disabled', 'cellDisabled'])), {}, {
|
209
209
|
rowIndex: rowIndex
|
210
210
|
});
|
211
211
|
};
|
@@ -2,4 +2,5 @@ import { EditableCellProps } from './interface';
|
|
2
2
|
export declare function getDataCell(item: EditableCellProps): JSX.Element;
|
3
3
|
export declare function isFreeEditRow(curRow: any, rowIndex: number): boolean;
|
4
4
|
export declare function isFreeEditCell(editCellKey: any, dataIndex: string, rowIndex: number): boolean;
|
5
|
+
export declare function isCellDisabled(record: any, cellDisabled?: string): boolean;
|
5
6
|
export declare function removeCurKeyFromEditRow(editRowKey: any, curKey: number): string;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: wangxian
|
3
3
|
* @Date: 2022-03-04 14:59:04
|
4
|
-
* @LastEditTime:
|
4
|
+
* @LastEditTime: 2023-05-23 10:33:54
|
5
5
|
*/
|
6
6
|
import React from 'react';
|
7
7
|
import Input from './DataCell/Input';
|
@@ -31,6 +31,30 @@ export function isFreeEditRow(curRow, rowIndex) {
|
|
31
31
|
export function isFreeEditCell(editCellKey, dataIndex, rowIndex) {
|
32
32
|
return (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.dataIndex) === dataIndex && (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.rowIndex) === rowIndex;
|
33
33
|
}
|
34
|
+
export function isCellDisabled(record, cellDisabled) {
|
35
|
+
if (cellDisabled) {
|
36
|
+
var regex = /\w+(\.\w+)?[=<>!]{1}|\w+(\.\w+)?(\.indexOf\('.+'\)[=<>!]{1})/g;
|
37
|
+
var keys = cellDisabled.trim().match(regex);
|
38
|
+
if (!keys) {
|
39
|
+
return true;
|
40
|
+
}
|
41
|
+
var expression = cellDisabled;
|
42
|
+
for (var i = 0; i < keys.length; i++) {
|
43
|
+
var key = keys[i].substring(0, keys[i].length - 1);
|
44
|
+
// 处理.length 之类的状况
|
45
|
+
var _key = key.split('.');
|
46
|
+
var _changeData = record[_key[0]];
|
47
|
+
if (_changeData || _changeData === 0) {
|
48
|
+
var r = key === _key[0] ? "'".concat(_changeData, "'") : eval("_changeData.".concat(_key[1]));
|
49
|
+
expression = expression.replace(key, r);
|
50
|
+
} else {
|
51
|
+
expression = expression.replace(key, undefined);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return !eval(expression);
|
55
|
+
}
|
56
|
+
return true;
|
57
|
+
}
|
34
58
|
export function removeCurKeyFromEditRow(editRowKey, curKey) {
|
35
59
|
var keys = editRowKey.toString().split(',');
|
36
60
|
var res = [];
|