Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
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
黄庭坚
jinfa-platform
Commits
6976caae
Commit
6976caae
authored
Apr 07, 2022
by
Bill
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-material-links' into 'v2-220418'
修改物料审核流程选择物料组逻辑 See merge request linkseeks-design/pro-platform!143
parents
57e4b125
5b76c8ce
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
142 additions
and
22 deletions
+142
-22
add.tsx
...ges/commodity/material/materialAuditProcessConfig/add.tsx
+24
-5
index.tsx
...alAuditProcessConfig/components/formilyTransfer/index.tsx
+111
-8
index.tsx
...s/commodity/material/materialAuditProcessConfig/index.tsx
+3
-3
add.tsx
src/pages/commodity/material/materialPendingAdd/add.tsx
+4
-6
No files found.
src/pages/commodity/material/materialAuditProcessConfig/add.tsx
View file @
6976caae
...
@@ -68,6 +68,7 @@ const Add = () => {
...
@@ -68,6 +68,7 @@ const Add = () => {
const
isEdit
=
lastTypeParams
===
'/edit'
&&
id
const
isEdit
=
lastTypeParams
===
'/edit'
&&
id
const
isEditable
=
isAdd
||
isEdit
;
const
isEditable
=
isAdd
||
isEdit
;
const
[
initialValue
,
setInitialValue
]
=
useState
(
null
);
const
[
initialValue
,
setInitialValue
]
=
useState
(
null
);
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
isAdd
)
{
if
(
isAdd
)
{
...
@@ -90,14 +91,13 @@ const Add = () => {
...
@@ -90,14 +91,13 @@ const Add = () => {
if
(
data
.
suitableMaterialType
===
GROUP
)
{
if
(
data
.
suitableMaterialType
===
GROUP
)
{
const
res
=
await
getProductMaterialProcessTreeRelMaterialGroup
({
processId
:
id
});
const
res
=
await
getProductMaterialProcessTreeRelMaterialGroup
({
processId
:
id
});
console
.
log
(
res
);
materialGroups
=
res
.
data
.
map
((
_item
)
=>
_item
.
materialGroupId
.
toString
())
materialGroups
=
res
.
data
.
map
((
_item
)
=>
_item
.
materialGroupId
)
}
}
setInitialValue
({
setInitialValue
({
...
data
,
...
data
,
materials
:
materials
,
materials
:
materials
,
materialGroups
:
[
'2'
,
'15'
]
materialGroups
:
materialGroups
});
});
}
}
}
}
...
@@ -113,6 +113,7 @@ const Add = () => {
...
@@ -113,6 +113,7 @@ const Add = () => {
}
}
const
handleSubmit
=
async
(
values
:
SubmitDataType
)
=>
{
const
handleSubmit
=
async
(
values
:
SubmitDataType
)
=>
{
setLoading
(
true
);
let
tempData
=
{}
let
tempData
=
{}
if
(
values
.
suitableMaterialType
===
2
)
{
if
(
values
.
suitableMaterialType
===
2
)
{
tempData
=
{
tempData
=
{
...
@@ -149,17 +150,35 @@ const Add = () => {
...
@@ -149,17 +150,35 @@ const Add = () => {
:
postProductMaterialProcessUpdate
:
postProductMaterialProcessUpdate
const
{
data
,
code
}
=
await
service
(
postData
);
const
{
data
,
code
}
=
await
service
(
postData
);
setLoading
(
false
)
if
(
code
===
1000
)
{
if
(
code
===
1000
)
{
history
.
back
();
history
.
back
();
}
}
}
}
const
renderTitle
=
()
=>
{
if
(
isAdd
)
{
return
'新增物料审核流程配置'
}
if
(
isEdit
)
{
return
'编辑物料审核流程配置'
}
return
'查看物料审核流程配置'
}
return
(
return
(
<
AnchorPage
<
AnchorPage
title=
{
"新增物料"
}
title=
{
renderTitle
()
}
anchors=
{
anchorHeader
}
anchors=
{
anchorHeader
}
extra=
{
extra=
{
<
Button
onClick=
{
()
=>
formActions
.
submit
()
}
>
保存
</
Button
>
(
isAdd
||
isEdit
)
&&
(
<
Button
onClick=
{
()
=>
formActions
.
submit
()
}
loading=
{
loading
}
>
保存
</
Button
>
)
}
}
>
>
<
NiceForm
<
NiceForm
...
...
src/pages/commodity/material/materialAuditProcessConfig/components/formilyTransfer/index.tsx
View file @
6976caae
import
{
Transfer
,
Tree
}
from
'antd'
;
import
{
Transfer
,
Tree
}
from
'antd'
;
import
React
,
{
useRef
,
useState
}
from
'react'
;
import
React
,
{
use
Memo
,
use
Ref
,
useState
}
from
'react'
;
interface
Iprops
{
interface
Iprops
{
dataSource
:
any
[],
dataSource
:
any
[],
...
@@ -15,9 +15,57 @@ interface Iprops {
...
@@ -15,9 +15,57 @@ interface Iprops {
/** 如果有其中一个未选,那么都选中 */
/** 如果有其中一个未选,那么都选中 */
// const isChecked = (selectedKeys, eventKey) => selectedKeys.some((_item) => !eventKey.includes(_item))
// const isChecked = (selectedKeys, eventKey) => selectedKeys.some((_item) => !eventKey.includes(_item))
/**
* 将tree 转为双向链表
*/
// let treeMap = {};
const
traverseToDataNode
=
(
treeData
,
depth
,
result
)
=>
{
for
(
let
i
=
0
;
i
<
treeData
.
length
;
i
++
)
{
const
current
=
treeData
[
i
];
const
children
=
current
.
children
||
[];
result
[
current
.
id
]
=
{
...
current
,
depth
:
depth
,
parent
:
result
[
current
.
parentId
]
||
null
}
if
(
children
.
length
>
0
)
{
traverseToDataNode
(
children
,
depth
+
1
,
result
)
}
}
}
const
FormilyTransfer
:
React
.
FC
<
Iprops
>
&
{
isFieldComponent
:
boolean
}
=
(
props
:
Iprops
)
=>
{
const
FormilyTransfer
:
React
.
FC
<
Iprops
>
&
{
isFieldComponent
:
boolean
}
=
(
props
:
Iprops
)
=>
{
const
{
value
,
mutators
,
...
restProps
}
=
props
;
const
{
value
,
mutators
,
...
restProps
}
=
props
;
const
dataSource
=
props
.
props
?.
enum
||
[];
const
dataSource
=
props
.
props
?.
enum
||
[];
console
.
log
(
value
,
"value"
);
const
treeNodes
=
useMemo
(()
=>
{
let
treeMap
=
{};
traverseToDataNode
(
dataSource
,
0
,
treeMap
);
return
treeMap
},
[
dataSource
])
/** 分层 */
const
levelSet
=
useMemo
(()
=>
{
const
map
=
new
Map
();
let
maxLevel
=
0
;
const
keys
=
Object
.
keys
(
treeNodes
);
keys
.
forEach
((
_item
)
=>
{
const
{
depth
,
children
}
=
treeNodes
[
_item
];
const
currentLevel
=
map
.
get
(
depth
)
||
[]
maxLevel
=
Math
.
max
(
maxLevel
,
depth
);
map
.
set
(
depth
,
currentLevel
.
concat
(
treeNodes
[
_item
]))
})
return
{
maxLevel
,
levelMap
:
map
};
},
[
treeNodes
])
console
.
log
(
"levelSet"
,
levelSet
)
console
.
log
(
treeNodes
,
"treeNodes"
);
console
.
log
(
dataSource
,
"dataSource"
);
// let depth = 0;
const
transferDataSource
=
[];
const
transferDataSource
=
[];
function
flatten
(
list
=
[])
{
function
flatten
(
list
=
[])
{
list
.
forEach
(
item
=>
{
list
.
forEach
(
item
=>
{
...
@@ -27,17 +75,18 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
...
@@ -27,17 +75,18 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
}
}
flatten
(
dataSource
);
flatten
(
dataSource
);
const
generateTree
=
(
treeNodes
=
[],
checkedKeys
=
[],
parentKey
=
''
)
=>
{
const
generateTree
=
(
treeNodes
=
[],
checkedKeys
=
[],
parentKey
=
''
,
depth
=
0
)
=>
{
return
treeNodes
.
map
(({
children
,
...
props
})
=>
{
return
treeNodes
.
map
(({
children
,
...
props
})
=>
{
const
{
checked
,
...
rest
}
=
props
const
{
checked
,
...
rest
}
=
props
;
return
{
const
result
=
{
...
rest
,
...
rest
,
key
:
`
${
props
.
id
}
`
,
key
:
`
${
props
.
id
}
`
,
title
:
props
.
title
,
title
:
props
.
title
,
fullKey
:
`
${
parentKey
}${
props
.
id
}
`
,
fullKey
:
`
${
parentKey
}${
props
.
id
}
`
,
disabled
:
checkedKeys
.
includes
(
props
.
id
),
disabled
:
checkedKeys
.
includes
(
props
.
id
),
children
:
generateTree
(
children
,
checkedKeys
,
`
${
parentKey
}${
props
.
id
}
-`
),
children
:
generateTree
(
children
,
checkedKeys
,
`
${
parentKey
}${
props
.
id
}
-`
,
depth
++
),
}
}
return
result
});
});
}
}
...
@@ -45,6 +94,61 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
...
@@ -45,6 +94,61 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
mutators
.
change
(
datas
)
mutators
.
change
(
datas
)
}
}
const
onChecked
=
(
checkedKeys
,
info
)
=>
{
const
{
checked
,
node
}
=
info
;
const
newCheckedKeys
=
[...
checkedKeys
,
node
.
id
];
// 从上到下, 联动勾选
for
(
let
i
=
0
;
i
<
levelSet
.
maxLevel
;
i
++
)
{
const
entities
=
levelSet
.
levelMap
.
get
(
i
);
entities
.
forEach
(
entity
=>
{
const
{
id
,
node
,
children
=
[]
}
=
entity
;
if
(
newCheckedKeys
.
includes
(
id
))
{
children
.
forEach
(
childEntity
=>
{
newCheckedKeys
.
push
(
childEntity
.
id
);
});
}
})
}
// 从下而上,联动勾选
const
visitedKeys
=
new
Set
();
for
(
let
level
=
levelSet
.
maxLevel
;
level
>=
0
;
level
-=
1
)
{
const
entities
=
levelSet
.
levelMap
.
get
(
level
)
||
new
Set
();
entities
.
forEach
(
entity
=>
{
const
{
parent
,
node
}
=
entity
;
if
(
!
entity
.
parent
||
visitedKeys
.
has
(
entity
.
parent
.
id
))
{
return
;
}
let
allChecked
=
true
;
(
parent
.
children
||
[])
.
forEach
(({
id
})
=>
{
const
checked
=
newCheckedKeys
.
includes
(
id
);
if
(
allChecked
&&
!
checked
)
{
allChecked
=
false
;
}
});
if
(
allChecked
)
{
newCheckedKeys
.
push
(
parent
.
id
);
}
visitedKeys
.
add
(
parent
.
key
);
});
}
console
.
log
(
"newCheckedKeys"
,
newCheckedKeys
);
return
newCheckedKeys
}
return
(
return
(
<
Transfer
<
Transfer
{
...
restProps
}
{
...
restProps
}
...
@@ -69,9 +173,8 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
...
@@ -69,9 +173,8 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
treeData=
{
treeData
}
treeData=
{
treeData
}
onCheck=
{
(
checkedKeysValue
,
e
)
=>
{
onCheck=
{
(
checkedKeysValue
,
e
)
=>
{
const
isChecked
=
e
.
checked
;
const
isChecked
=
e
.
checked
;
const
halfChecked
=
e
.
halfCheckedKeys
;
const
newData
=
onChecked
(
checkedKeys
,
e
)
const
newCheckedKeys
=
checkedKeysValue
.
filter
((
_item
)
=>
!
halfChecked
.
includes
(
_item
));
onItemSelectAll
(
newData
,
isChecked
);
onItemSelectAll
(
newCheckedKeys
,
isChecked
);
}
}
}
}
/>
/>
);
);
...
...
src/pages/commodity/material/materialAuditProcessConfig/index.tsx
View file @
6976caae
...
@@ -19,7 +19,7 @@ import { Link } from 'umi';
...
@@ -19,7 +19,7 @@ import { Link } from 'umi';
* 物料审核流程规则配置
* 物料审核流程规则配置
*/
*/
const
formActions
=
createFormActions
();
const
formActions
=
createFormActions
();
const
CREATE_URL
=
'/memberCenter/material/materialAuditProcessConfig/add'
const
CREATE_URL
=
'/memberCenter/
commodityAbility/
material/materialAuditProcessConfig/add'
const
MaterialAuditProcessConfig
=
()
=>
{
const
MaterialAuditProcessConfig
=
()
=>
{
const
ref
=
useRef
<
any
>
({});
const
ref
=
useRef
<
any
>
({});
...
@@ -50,7 +50,7 @@ const MaterialAuditProcessConfig = () => {
...
@@ -50,7 +50,7 @@ const MaterialAuditProcessConfig = () => {
dataIndex
:
'processId'
,
dataIndex
:
'processId'
,
render
:
(
text
,
record
)
=>
{
render
:
(
text
,
record
)
=>
{
return
(
return
(
<
Link
to=
{
`/memberCenter/material/materialAuditProcessConfig/detail?id=${record.processId}`
}
>
<
Link
to=
{
`/memberCenter/
commodityAbility/
material/materialAuditProcessConfig/detail?id=${record.processId}`
}
>
{
record
.
processId
}
{
record
.
processId
}
</
Link
>
</
Link
>
)
)
...
@@ -82,7 +82,7 @@ const MaterialAuditProcessConfig = () => {
...
@@ -82,7 +82,7 @@ const MaterialAuditProcessConfig = () => {
}
}
return
(
return
(
<
Space
>
<
Space
>
<
Link
to=
{
`/memberCenter/material/materialAuditProcessConfig/edit?id=${record.processId}`
}
>
<
Link
to=
{
`/memberCenter/
commodityAbility/
material/materialAuditProcessConfig/edit?id=${record.processId}`
}
>
修改
修改
</
Link
>
</
Link
>
{
{
...
...
src/pages/commodity/material/materialPendingAdd/add.tsx
View file @
6976caae
...
@@ -71,7 +71,7 @@ const MaterialAdd = (props) => {
...
@@ -71,7 +71,7 @@ const MaterialAdd = (props) => {
if
(
!
formatInitialValue
)
{
if
(
!
formatInitialValue
)
{
return
return
}
}
if
(
formatInitialValue
.
interiorState
===
FROZEN
)
{
if
(
formatInitialValue
?
.
interiorState
===
FROZEN
)
{
formActions
.
setFieldState
(
'changeCard'
,
(
state
)
=>
{
formActions
.
setFieldState
(
'changeCard'
,
(
state
)
=>
{
FormPath
.
setIn
(
state
,
'visible'
,
true
);
FormPath
.
setIn
(
state
,
'visible'
,
true
);
})
})
...
@@ -184,14 +184,12 @@ const MaterialAdd = (props) => {
...
@@ -184,14 +184,12 @@ const MaterialAdd = (props) => {
:
{}
:
{}
/** 物料是否变更 */
/** 物料是否变更 */
const
withChangeData
=
formatInitialValue
.
interiorState
===
FROZEN
const
withChangeData
=
formatInitialValue
?
.
interiorState
===
FROZEN
?
{
?
{
changeRemark
:
rest
.
changeRemark
,
changeRemark
:
rest
.
changeRemark
||
''
,
change
:
1
,
change
:
1
,
}
}
:
{
:
{}
change
:
1
,
}
/** 物料组 */
/** 物料组 */
const
withMaterialGroup
=
materialGroup
const
withMaterialGroup
=
materialGroup
...
...
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