Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
merchant-manage-ui
Commits
57d51709
Commit
57d51709
authored
Jul 29, 2022
by
beisir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 删除ts
parent
e95e3d78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
44 deletions
+30
-44
index.jsx
src/pages/GoodsManage/createModal/index.jsx
+1
-1
EditFormTable.jsx
src/pages/ServiceGoods/components/EditFormTable.jsx
+29
-43
No files found.
src/pages/GoodsManage/createModal/index.jsx
View file @
57d51709
...
@@ -710,7 +710,7 @@ class goodsManage extends Component {
...
@@ -710,7 +710,7 @@ class goodsManage extends Component {
</
Col
>
</
Col
>
{
specListData
.
length
{
specListData
.
length
?
specListData
.
map
((
item
,
index
)
=>
(
?
specListData
.
map
((
item
,
index
)
=>
(
<
Col
span=
{
24
}
>
<
Col
key=
{
item
.
specId
}
span=
{
24
}
>
<
FormItem
label=
{
item
.
specName
}
labelCol=
{
{
span
:
2
}
}
>
<
FormItem
label=
{
item
.
specName
}
labelCol=
{
{
span
:
2
}
}
>
{
getFieldDecorator
(
`${item.specId}`
,
{
{
getFieldDecorator
(
`${item.specId}`
,
{
initialValue
:
initData
[
item
.
specId
],
initialValue
:
initData
[
item
.
specId
],
...
...
src/pages/ServiceGoods/components/EditFormTable.jsx
View file @
57d51709
import
{
InputNumber
,
Button
,
Form
,
Table
}
from
'
antd
'
;
import
{
InputNumber
,
Button
,
Form
,
Table
}
from
'
antd
'
;
import
React
,
{
useContext
,
createContext
,
useEffect
,
useState
,
forwardRef
,
useImperativeHandle
}
from
'
react
'
;
import
React
,
{
useContext
,
createContext
,
useEffect
,
useState
,
forwardRef
,
useImperativeHandle
,
}
from
'
react
'
;
import
{
ServiceContext
}
from
'
../context
'
;
import
{
ServiceContext
}
from
'
../context
'
;
const
EditableContext
=
createContext
(
null
);
const
EditableContext
=
createContext
(
null
);
const
EditableRow
=
({
index
,
...
props
})
=>
{
const
EditableRow
=
({
index
,
...
props
})
=>
<
tr
{
...
props
}
/>;
// console.log('==========> index', props);
const
EditableCell
=
props
=>
{
// const [form] = Form.useForm();
// console.log('==========>props', props)
return
(
// <Form form={form} component={false}>
// <EditableContext.Provider value={form}>
<
tr
{
...
props
}
/>
// </EditableContext.Provider>
// </Form>
);
};
const
EditableCell
=
(
props
)
=>
{
const
{
const
{
rowIndex
,
rowIndex
,
title
,
title
,
...
@@ -30,7 +24,7 @@ const EditableCell = (props) => {
...
@@ -30,7 +24,7 @@ const EditableCell = (props) => {
...
restProps
...
restProps
}
=
props
;
}
=
props
;
const
form
=
useContext
(
EditableContext
)
!
;
const
form
=
useContext
(
EditableContext
);
const
save
=
async
()
=>
{
const
save
=
async
()
=>
{
try
{
try
{
const
tableList
=
form
.
getFieldValue
(
'
tableList
'
);
const
tableList
=
form
.
getFieldValue
(
'
tableList
'
);
...
@@ -40,22 +34,19 @@ const EditableCell = (props) => {
...
@@ -40,22 +34,19 @@ const EditableCell = (props) => {
}
}
};
};
let
childNode
=
children
;
const
childNode
=
(
childNode
=
<
Form
.
Item
<
Form
.
Item
style=
{
{
margin
:
0
}
}
style=
{
{
margin
:
0
}
}
name=
{
[
'
tableList
'
,
rowIndex
,
dataIndex
]
}
name=
{
[
'
tableList
'
,
rowIndex
,
dataIndex
]
}
rules=
{
[{
required
:
true
,
message
:
`${title} is required.`
}]
}
>
rules=
{
[{
required
:
true
,
message
:
`${title} is required.`
}]
}
>
{
editable
?
<
InputNumber
onBlur=
{
save
}
/>
:
children
[
1
]
}
{
editable
?
<
InputNumber
onBlur=
{
save
}
/>
:
children
[
1
]
}
</
Form
.
Item
>
</
Form
.
Item
>
);
return
<
td
{
...
restProps
}
>
{
childNode
}
</
td
>;
return
<
td
{
...
restProps
}
>
{
childNode
}
</
td
>;
};
};
const
EditFormTable
=
forwardRef
((
props
,
ref
)
=>
{
const
EditFormTable
=
forwardRef
((
props
,
ref
)
=>
{
const
{
initData
,
defaultColumns
,
setTableData
,
mergeTable
}
=
props
;
const
{
initData
,
defaultColumns
,
setTableData
,
mergeTable
}
=
props
;
const
customer
=
useContext
(
ServiceContext
);
const
customer
=
useContext
(
ServiceContext
);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
...
@@ -66,7 +57,7 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -66,7 +57,7 @@ const EditFormTable = forwardRef((props, ref) => {
tableList
:
initData
,
tableList
:
initData
,
});
});
setDataSource
(
initData
);
setDataSource
(
initData
);
},
[
initData
])
},
[
initData
])
;
const
handleAdd
=
async
()
=>
{
const
handleAdd
=
async
()
=>
{
try
{
try
{
...
@@ -77,11 +68,10 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -77,11 +68,10 @@ const EditFormTable = forwardRef((props, ref) => {
}
}
};
};
const
handleSave
=
(
row
)
=>
{
const
handleSave
=
row
=>
{
setTableData
([...
row
]);
setTableData
([...
row
]);
};
};
const
onCheck
=
async
()
=>
{
const
onCheck
=
async
()
=>
{
try
{
try
{
const
values
=
await
form
.
validateFields
();
const
values
=
await
form
.
validateFields
();
...
@@ -96,15 +86,10 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -96,15 +86,10 @@ const EditFormTable = forwardRef((props, ref) => {
form
,
form
,
}));
}));
// 根据这里做判断渲染表格
// 根据这里做判断渲染表格
const
columns
=
defaultColumns
const
columns
=
defaultColumns
.
filter
(
item
=>
{
.
filter
(
item
=>
!
item
.
role
||
item
.
role
.
includes
(
customer
.
productType
))
// console.log('===============>column', item);
.
map
((
col
,
colIndex
)
=>
({
return
!
item
.
role
||
item
.
role
.
includes
(
customer
.
productType
);
})
.
map
((
col
,
colIndex
)
=>
{
return
{
...
col
,
...
col
,
onCell
:
(
record
,
rowIndex
)
=>
{
onCell
:
(
record
,
rowIndex
)
=>
{
let
rowSpan
=
null
;
let
rowSpan
=
null
;
...
@@ -112,7 +97,7 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -112,7 +97,7 @@ const EditFormTable = forwardRef((props, ref) => {
rowSpan
=
record
.
rowSpanCount
||
0
;
rowSpan
=
record
.
rowSpanCount
||
0
;
}
}
return
(
{
return
{
rowSpan
,
rowSpan
,
record
,
record
,
rowIndex
,
rowIndex
,
...
@@ -120,11 +105,10 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -120,11 +105,10 @@ const EditFormTable = forwardRef((props, ref) => {
dataIndex
:
col
.
dataIndex
,
dataIndex
:
col
.
dataIndex
,
title
:
col
.
title
,
title
:
col
.
title
,
handleSave
,
handleSave
,
});
};
}
},
};
}));
});
return
(
return
(
<
div
>
<
div
>
<
Form
form=
{
form
}
scrollToFirstError
component=
{
false
}
>
<
Form
form=
{
form
}
scrollToFirstError
component=
{
false
}
>
...
@@ -144,10 +128,12 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -144,10 +128,12 @@ const EditFormTable = forwardRef((props, ref) => {
columns=
{
columns
}
columns=
{
columns
}
/>
/>
</
EditableContext
.
Provider
>
</
EditableContext
.
Provider
>
<
Button
onClick=
{
handleAdd
}
type=
"primary"
style=
{
{
marginBottom
:
16
}
}
>
Add a row
</
Button
>
<
Button
onClick=
{
handleAdd
}
type=
"primary"
style=
{
{
marginBottom
:
16
}
}
>
Add a row
</
Button
>
</
Form
>
</
Form
>
</
div
>
</
div
>
);
);
});
});
export
default
EditFormTable
;
export
default
EditFormTable
;
\ No newline at end of file
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