Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
2dbbe0ca
Commit
2dbbe0ca
authored
Aug 04, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
主数据定义
parent
704f99db
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
4 deletions
+20
-4
UpdateField.jsx
src/view/Manage/DataMaster/Define/Component/UpdateField.jsx
+20
-4
No files found.
src/view/Manage/DataMaster/Define/Component/UpdateField.jsx
View file @
2dbbe0ca
...
...
@@ -120,6 +120,8 @@ const UpdateField = (props) => {
const [loading, setLoading] = useState(false);
const [form] = Form.useForm();
const tableRef = useRef(null);
const dataRef = useRef([]);
const editingKeyRef = useRef(null);
const { attrIsEditingFunction } = useContext(EditTemplateContext);
const cols = [
...
...
@@ -235,8 +237,10 @@ const UpdateField = (props) => {
useEffect(() => {
if (visible) {
setEditingKey(null);
editingKeyRef.current = null;
if (!template) {
setData([]);
dataRef.current = [];
} else {
getFileds();
}
...
...
@@ -301,6 +305,7 @@ const UpdateField = (props) => {
(data||[]).sort(compare);
setData(data||[]);
dataRef.current = data||[];
onChange && onChange(data||[]);
},
error: () => {
...
...
@@ -316,9 +321,10 @@ const UpdateField = (props) => {
if (result) {
setKeyword('');
const newData = [...data, {name: ''}];
const newData = [...data
Ref.current
, {name: ''}];
setData(newData);
dataRef.current = newData;
setInsertIndex(newData.length-1);
editItem(newData[newData.length-1]);
...
...
@@ -335,7 +341,7 @@ const UpdateField = (props) => {
if (result) {
setKeyword('');
let newData = [...data];
let newData = [...data
Ref.current
];
const index = newData.findIndex((item) => record.name === item.name);
if (index === 0) {
...
...
@@ -349,6 +355,7 @@ const UpdateField = (props) => {
}
setData(newData);
dataRef.current = newData;
setTimeout(() => {
document.getElementById(`
field
-
`)?.scrollIntoView();
...
...
@@ -366,6 +373,7 @@ const UpdateField = (props) => {
}
setData(newData);
dataRef.current = newData;
onChange && onChange(newData);
}
...
...
@@ -374,6 +382,7 @@ const UpdateField = (props) => {
removeItemLogic(record);
} else {
setEditingKey(null);
editingKeyRef.current = null;
removeItemLogic(record);
}
}
...
...
@@ -394,9 +403,11 @@ const UpdateField = (props) => {
form.setFieldsValue({...record, dataType: dataTypeJson});
setEditingKey(record?.name);
editingKeyRef.current = record?.name;
} catch {
form.setFieldsValue({...record, dataType: {}});
setEditingKey(record?.name);
editingKeyRef.current = record?.name;
}
}
...
...
@@ -410,7 +421,7 @@ const UpdateField = (props) => {
const save = async() => {
try {
if (editingKey !== null) {
if (editingKey
Ref.current
!== null) {
const row = await form.validateFields();
if ((row.dataType.name||'')==='') {
...
...
@@ -425,7 +436,7 @@ const UpdateField = (props) => {
})
const newData = [...data];
const index = newData.findIndex((item) => editingKey === item.name);
const index = newData.findIndex((item) => editingKey
Ref.current
=== item.name);
//判断字段名称是否唯一
let _index;
...
...
@@ -455,7 +466,11 @@ const UpdateField = (props) => {
}
setEditingKey(null);
editingKeyRef.current = null;
setData(newData);
dataRef.current = newData;
onChange && onChange(newData);
}
...
...
@@ -477,6 +492,7 @@ const UpdateField = (props) => {
});
setData(newData);
dataRef.current = newData;
onChange && onChange(newData);
},
[data],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment