Commit 062d3703 by zhaochengxiang

修改模型部分问题

parent 12351124
...@@ -5,7 +5,7 @@ import { DndProvider, useDrag, useDrop } from 'react-dnd'; ...@@ -5,7 +5,7 @@ import { DndProvider, useDrag, useDrop } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend'; import { HTML5Backend } from 'react-dnd-html5-backend';
import update from 'immutability-helper'; import update from 'immutability-helper';
import './ImportActionTable.less'; import './ImportActionIndex.less';
const { Option } = Select; const { Option } = Select;
...@@ -291,11 +291,11 @@ const ImportActionIndex = (props) => { ...@@ -291,11 +291,11 @@ const ImportActionIndex = (props) => {
const isEditing = (record) => record.name === editingKey; const isEditing = (record) => record.name === editingKey;
const onAddClick = () => { const onAddClick = () => {
const newData = [{name: ''}, ...data]; const newFilterData = [{name: ''}, ...filterData];
onChange && onChange(newData); setFilterData(newFilterData);
edit(newData[0]); edit(newFilterData[0]);
} }
const edit = (record) => { const edit = (record) => {
...@@ -319,14 +319,15 @@ const ImportActionIndex = (props) => { ...@@ -319,14 +319,15 @@ const ImportActionIndex = (props) => {
} }
const cancel = () => { const cancel = () => {
const newData = [...data];
const index = newData.findIndex((item) => editingKey === item.name); const newFilterData = [...filterData];
const item = newData[index]; const index = newFilterData.findIndex((item) => editingKey === item.name);
const item = newFilterData[index];
if (!item.name || item.name==='') { if (!item.name || item.name==='') {
newData.splice(index, 1); newFilterData.splice(index, 1);
onChange && onChange(newData); setFilterData(newFilterData);
} }
setEditingKey(null); setEditingKey(null);
...@@ -336,15 +337,20 @@ const ImportActionIndex = (props) => { ...@@ -336,15 +337,20 @@ const ImportActionIndex = (props) => {
try { try {
const row = await form.validateFields(); const row = await form.validateFields();
// console.log('row', row); // console.log('row', row);
const newData = [...data]; const newData = [...data];
const index = newData.findIndex((item) => editingKey === item.name); const index = newData.findIndex((item) => editingKey === item.name);
//判断索引名称是否唯一 //判断索引名称是否唯一
const newDataExcludeSelf = [...data]; let _index;
newDataExcludeSelf.splice(index, 1); if (index === -1) {
const _index = (newDataExcludeSelf||[]).findIndex(item => item.name === row.name); _index = (data||[]).findIndex(item => item.name === row.name);
} else {
const newDataExcludeSelf = [...data];
newDataExcludeSelf.splice(index, 1);
_index = (newDataExcludeSelf||[]).findIndex(item => item.name === row.name);
}
if (_index !== -1) { if (_index !== -1) {
form.setFields([{ name: 'name', errors: ['索引名称不能重复'] }]); form.setFields([{ name: 'name', errors: ['索引名称不能重复'] }]);
...@@ -369,12 +375,21 @@ const ImportActionIndex = (props) => { ...@@ -369,12 +375,21 @@ const ImportActionIndex = (props) => {
return; return;
} }
newData.splice(index, 1, {...{ if (index === -1) {
name: row.name, newData.splice(0, 0, {
unique: row.unique, name: row.name,
indexedEasyDataModelAttributes: _indexedEasyDataModelAttributes, unique: row.unique,
indexedAttributeOrders: _indexedAttributeOrders, indexedEasyDataModelAttributes: _indexedEasyDataModelAttributes,
}}); indexedAttributeOrders: _indexedAttributeOrders,
});
} else {
newData.splice(index, 1, {...{
name: row.name,
unique: row.unique,
indexedEasyDataModelAttributes: _indexedEasyDataModelAttributes,
indexedAttributeOrders: _indexedAttributeOrders,
}});
}
onChange && onChange(newData, true); onChange && onChange(newData, true);
......
.model-import-action-index {
.yy-table {
max-height: 200px !important;
overflow: auto !important;
}
}
\ No newline at end of file
...@@ -129,7 +129,7 @@ const EditableCell = ({ ...@@ -129,7 +129,7 @@ const EditableCell = ({
valuePropName={(inputType==='check')? 'checked': 'value'} valuePropName={(inputType==='check')? 'checked': 'value'}
rules={[ rules={[
{ {
required: (inputType === 'text' && dataIndex !== 'remark'), required: (inputType === 'text'),
message: `请输入${colTitle}!`, message: `请输入${colTitle}!`,
}, },
]} ]}
...@@ -248,11 +248,11 @@ const ImportActionTable = (props) => { ...@@ -248,11 +248,11 @@ const ImportActionTable = (props) => {
const isEditing = (record) => record.iid === editingKey; const isEditing = (record) => record.iid === editingKey;
const onAddClick = () => { const onAddClick = () => {
const newFilterData = [{iid: generateUUID()}, ...filterData];
const newData = [{iid: generateUUID()}, ...data]; setFilterData(newFilterData);
edit(newFilterData[0]);
onChange && onChange(newData);
edit(newData[0]);
} }
const edit = (record) => { const edit = (record) => {
...@@ -274,14 +274,14 @@ const ImportActionTable = (props) => { ...@@ -274,14 +274,14 @@ const ImportActionTable = (props) => {
} }
const cancel = () => { const cancel = () => {
const newData = [...data]; const newFilterData = [...filterData];
const index = newData.findIndex((item) => editingKey === item.iid); const index = newFilterData.findIndex((item) => editingKey === item.iid);
const item = newData[index]; const item = newFilterData[index];
if (!item.name || item.name==='') { if (!item.name || item.name==='') {
newData.splice(index, 1); newFilterData.splice(index, 1);
onChange && onChange(newData); setFilterData(newFilterData);
} }
setEditingKey(''); setEditingKey('');
...@@ -307,9 +307,15 @@ const ImportActionTable = (props) => { ...@@ -307,9 +307,15 @@ const ImportActionTable = (props) => {
const newData = [...data]; const newData = [...data];
const index = newData.findIndex((item) => editingKey === item.iid); const index = newData.findIndex((item) => editingKey === item.iid);
const item = newData[index]; if (index === -1) {
newData.splice(index, 1, { ...item, ...row });
newData.splice(0, 0, row);
} else {
const item = newData[index];
newData.splice(index, 1, { ...item, ...row });
}
onChange && onChange(newData, true); onChange && onChange(newData, true);
setEditingKey(''); setEditingKey('');
......
.model-import-action-table { .model-import-action-table {
.yy-table { .yy-table {
max-height: 500px !important; max-height: 400px !important;
overflow: auto !important; overflow: auto !important;
} }
......
...@@ -110,7 +110,7 @@ const ImportModal = (props) => { ...@@ -110,7 +110,7 @@ const ImportModal = (props) => {
const cancel = () => { const cancel = () => {
reset(); reset();
onCancel && onCancel(); onCancel && onCancel(false);
} }
const save = async () => { const save = async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment