@lingxiteam/ebe-utils 0.3.26 → 0.3.28
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.
- package/lib/pcpublic/src/components/pcfactory/src/Description/index.tsx +6 -2
- package/lib/pcpublic/src/components/pcfactory/src/Table/EditComponent/index.tsx +20 -4
- package/lib/public/src/components/ImportBusiObjModal/index.tsx +5 -0
- package/package.json +2 -2
- package/es/renameComponents.d.ts +0 -1
- package/es/renameComponents.js +0 -70
|
@@ -195,11 +195,15 @@ const Description = React.forwardRef<any, MyDescriptionProps>((props, ref) => {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
|
|
199
198
|
// 如果配置了换行符则根据换行符进行切割
|
|
200
199
|
if (lineBreak && typeof text === 'string') {
|
|
201
|
-
|
|
200
|
+
let temlineBreak = lineBreak;
|
|
201
|
+
if (temlineBreak === '\\n') {
|
|
202
|
+
temlineBreak = lineBreak.replace(/\\n/g, '\n');
|
|
203
|
+
}
|
|
204
|
+
return content.split(temlineBreak).map((_c: any, _i: any) => <div key={_i}>{_c}</div>);
|
|
202
205
|
}
|
|
206
|
+
|
|
203
207
|
// 自定义渲染函数
|
|
204
208
|
if (c.jsx) {
|
|
205
209
|
content = (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DatePicker, Input, InputNumber, Select, Radio, Switch, Form } from 'antd';
|
|
2
2
|
import moment, { Moment } from 'moment';
|
|
3
|
-
import React, { useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import ComSelect from '../../SuperSelect/ComSelect';
|
|
5
5
|
import ModalSelect from '../../ModalSelect';
|
|
6
6
|
import { initMomentLocale, getRegExp } from '../../utils/common';
|
|
@@ -55,6 +55,7 @@ const EditComponent: React.FC<MyEditComponent> = (props) => {
|
|
|
55
55
|
engineApis,
|
|
56
56
|
onChange,
|
|
57
57
|
onBlur,
|
|
58
|
+
form,
|
|
58
59
|
} = props;
|
|
59
60
|
const { dataIndex } = c;
|
|
60
61
|
const {
|
|
@@ -75,6 +76,7 @@ const EditComponent: React.FC<MyEditComponent> = (props) => {
|
|
|
75
76
|
const [tempInputValue, updateTempInputValue] = useState<string | undefined>();
|
|
76
77
|
|
|
77
78
|
const { getLocale } = useLocale(engineApis || {});
|
|
79
|
+
const fieldName = getFormItemFieldName({ compId, currentRowKey, rowData, rowId, dataIndex });
|
|
78
80
|
|
|
79
81
|
const limitRangeTime: {
|
|
80
82
|
startTime: Moment;
|
|
@@ -212,6 +214,21 @@ const EditComponent: React.FC<MyEditComponent> = (props) => {
|
|
|
212
214
|
return res?.length > 0 ? res : null;
|
|
213
215
|
}, [initialValueType, isNaNValue, rules, validateDateCustomExpress]);
|
|
214
216
|
|
|
217
|
+
const needFormItem = useMemo(() => supportEditComponents.includes(edittype) && validateRules,
|
|
218
|
+
[supportEditComponents, edittype,
|
|
219
|
+
validateRules]);
|
|
220
|
+
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
if (needFormItem && fieldName) {
|
|
223
|
+
const currentValue = tempInputValue ?? initialValue;
|
|
224
|
+
const formValue = form.getFieldValue(fieldName);
|
|
225
|
+
if (formValue !== currentValue) {
|
|
226
|
+
// 值不一样时需要通过表单赋值更新成由外部传入的新值
|
|
227
|
+
form.setFieldValue(fieldName, currentValue);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, [needFormItem, fieldName, tempInputValue, initialValue]);
|
|
231
|
+
|
|
215
232
|
const getDisabledDate = useCallback((current: Moment) => {
|
|
216
233
|
// custom 自定义规则通过form表单进行校验
|
|
217
234
|
if (!limitRange || limitRange === 'no' || limitRange === 'custom') {
|
|
@@ -498,8 +515,7 @@ const EditComponent: React.FC<MyEditComponent> = (props) => {
|
|
|
498
515
|
}
|
|
499
516
|
};
|
|
500
517
|
|
|
501
|
-
if (
|
|
502
|
-
const fieldName = getFormItemFieldName({ compId, currentRowKey, rowData, rowId, dataIndex });
|
|
518
|
+
if (needFormItem) {
|
|
503
519
|
return (
|
|
504
520
|
<Form.Item
|
|
505
521
|
style={{ height: 'auto' }}
|
|
@@ -507,7 +523,7 @@ const EditComponent: React.FC<MyEditComponent> = (props) => {
|
|
|
507
523
|
// TODO: 设置的 filedName 目前实际没作用,只是为了防止formitem错误告警
|
|
508
524
|
name={fieldName}
|
|
509
525
|
initialValue={initialValue}
|
|
510
|
-
rules={validateRules}
|
|
526
|
+
rules={validateRules as any}
|
|
511
527
|
>
|
|
512
528
|
{renderComponent(true)}
|
|
513
529
|
</Form.Item>
|
|
@@ -590,6 +590,11 @@ const ImportBusiObjModal = forwardRef<ImportBusiObjModalHooks, ImportBusiObjModa
|
|
|
590
590
|
xhr.onload = async () => {
|
|
591
591
|
response = JSON.parse(xhr.responseText || xhr.response);
|
|
592
592
|
if (xhr.status === 200) {
|
|
593
|
+
if (Object.prototype.toString.call(response?.resultObject) === '[object Object]' && response?.resultObject.hasOwnProperty('resultCode') && response?.resultObject?.resultCode !== '0') {
|
|
594
|
+
response.resultCode = response?.resultObject?.resultCode;
|
|
595
|
+
response.resultMsg = response?.resultObject?.resultMsg;
|
|
596
|
+
response.resultObject = undefined;
|
|
597
|
+
}
|
|
593
598
|
let result = response?.resultObject;
|
|
594
599
|
let isAsyncImport = false;
|
|
595
600
|
if (hasUploadProcess) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxiteam/ebe-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.28",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@babel/types": "^7.12.12",
|
|
20
20
|
"cac": "^6.7.14",
|
|
21
21
|
"fs-extra": "9.x",
|
|
22
|
-
"@lingxiteam/ebe": "0.3.
|
|
22
|
+
"@lingxiteam/ebe": "0.3.28"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
package/es/renameComponents.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function renameComponents(data: any): string;
|
package/es/renameComponents.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
export function renameComponents(data) {
|
|
8
|
-
// 读取 JSON 文件
|
|
9
|
-
// const data: JsonData = JSON.parse(jsonContent);
|
|
10
|
-
|
|
11
|
-
// 用于存储已使用的名称计数
|
|
12
|
-
var nameCounters = {};
|
|
13
|
-
var renameObject = {};
|
|
14
|
-
|
|
15
|
-
// 递归处理组件
|
|
16
|
-
function processComponents(components) {
|
|
17
|
-
if (!Array.isArray(components)) return;
|
|
18
|
-
components.forEach(function (component) {
|
|
19
|
-
// 处理当前组件
|
|
20
|
-
if (component.id && /^[A-Za-z]+_\d+$/.test(component.id)) {
|
|
21
|
-
var baseName = component.id.split('_')[0];
|
|
22
|
-
// 生成新的有意义的名字
|
|
23
|
-
var newName = generateMeaningfulName(baseName, component.id, nameCounters);
|
|
24
|
-
component.id = newName;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// 递归处理子组件
|
|
28
|
-
if (component.components) {
|
|
29
|
-
processComponents(component.components);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 生成有意义的名称
|
|
35
|
-
function generateMeaningfulName(baseName, label, counters) {
|
|
36
|
-
if (!counters[baseName]) {
|
|
37
|
-
counters[baseName] = 1;
|
|
38
|
-
} else {
|
|
39
|
-
counters[baseName] += 1;
|
|
40
|
-
}
|
|
41
|
-
// 从 Form1 开始,防止变量名和组件名相同
|
|
42
|
-
var rename = "".concat(baseName).concat(counters[baseName]);
|
|
43
|
-
renameObject[label] = rename;
|
|
44
|
-
return rename;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// 处理所有组件
|
|
48
|
-
if (data.components) {
|
|
49
|
-
processComponents(data.components);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 将对象转换为字符串
|
|
53
|
-
var jsonString = JSON.stringify(data, null, 4);
|
|
54
|
-
|
|
55
|
-
// 全局替换所有引用
|
|
56
|
-
Object.entries(renameObject).forEach(function (_ref) {
|
|
57
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
58
|
-
oldName = _ref2[0],
|
|
59
|
-
newName = _ref2[1];
|
|
60
|
-
// 使用正则表达式确保只替换完整的匹配
|
|
61
|
-
var regex = oldName.trim();
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
jsonString = jsonString.replaceAll(regex, newName);
|
|
64
|
-
});
|
|
65
|
-
return JSON.parse(jsonString);
|
|
66
|
-
// 写回文件
|
|
67
|
-
// fs.writeFileSync('./Page_ceshi1.json', jsonString, 'utf8');
|
|
68
|
-
// console.log('组件重命名完成!');
|
|
69
|
-
// console.log('/重命名映射关系:', renameObject);
|
|
70
|
-
}
|