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
626d778a
Commit
626d778a
authored
Aug 14, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
仓位
parent
d3096785
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
21 deletions
+21
-21
useAsyncSelect.ts
src/formSchema/effects/useAsyncSelect.ts
+1
-1
useHttpRequest.ts
src/hooks/useHttpRequest.ts
+6
-3
adjustRepository.tsx
src/pages/repositories/adjustRepository.tsx
+14
-17
No files found.
src/formSchema/effects/useAsyncSelect.ts
View file @
626d778a
...
@@ -7,7 +7,7 @@ const { onFormInit$ } = FormEffectHooks
...
@@ -7,7 +7,7 @@ const { onFormInit$ } = FormEffectHooks
* @param name 待处理的表单路径
* @param name 待处理的表单路径
* @param service 触发的异步函数, 需返回一个{label: any, value: any}形式的数组
* @param service 触发的异步函数, 需返回一个{label: any, value: any}形式的数组
*/
*/
export
const
useAsyncSelect
=
(
name
,
service
:
()
=>
Promise
<
any
[]
>
)
=>
{
export
const
useAsyncSelect
=
async
(
name
,
service
:
()
=>
Promise
<
any
[]
>
)
=>
{
const
{
dispatch
,
setFieldState
}
=
createFormActions
()
const
{
dispatch
,
setFieldState
}
=
createFormActions
()
const
linkage
=
useLinkageUtils
()
const
linkage
=
useLinkageUtils
()
onFormInit$
().
subscribe
(()
=>
{
onFormInit$
().
subscribe
(()
=>
{
...
...
src/hooks/useHttpRequest.ts
View file @
626d778a
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
IApiRequest
}
from
'@/utils/request'
;
import
{
IApiRequest
}
from
'@/utils/request'
;
export
interface
IHttpRequestReturn
<
T
>
{
export
interface
IHttpRequestReturn
<
T
>
{
...
@@ -8,15 +8,18 @@ export interface IHttpRequestReturn<T> {
...
@@ -8,15 +8,18 @@ export interface IHttpRequestReturn<T> {
run
(
params
?:
any
)
run
(
params
?:
any
)
}
}
export
interface
useHttpRequestConfig
extends
IApiRequest
{
autoRun
?:
boolean
}
/**
/**
* 简易版本的useRequest hooks, 用于处理带有loading的业务场景
* 简易版本的useRequest hooks, 用于处理带有loading的业务场景
* @auth xjm
* @auth xjm
*/
*/
export
function
useHttpRequest
<
T
>
(
api
:
(
params
?,
config
?)
=>
Promise
<
T
>
,
config
?:
IApiRequest
):
IHttpRequestReturn
<
T
>
{
export
function
useHttpRequest
<
T
>
(
api
:
(
params
?,
config
?)
=>
Promise
<
T
>
,
selfConfig
?:
useHttpRequestConfig
):
IHttpRequestReturn
<
T
>
{
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
[
data
,
setData
]
=
useState
<
T
|
null
>
(
null
)
const
[
data
,
setData
]
=
useState
<
T
|
null
>
(
null
)
const
[
err
,
setErr
]
=
useState
()
const
[
err
,
setErr
]
=
useState
()
const
run
=
(
params
)
=>
{
const
run
=
(
params
)
=>
{
setLoading
(
true
)
setLoading
(
true
)
api
(
params
).
then
((
res
:
any
)
=>
{
api
(
params
).
then
((
res
:
any
)
=>
{
...
...
src/pages/repositories/adjustRepository.tsx
View file @
626d778a
...
@@ -26,6 +26,7 @@ import { useSyncValues } from '@/formSchema/effects/useSyncValues'
...
@@ -26,6 +26,7 @@ import { useSyncValues } from '@/formSchema/effects/useSyncValues'
import
{
useLinkageUtils
}
from
'@/utils/formEffectUtils'
import
{
useLinkageUtils
}
from
'@/utils/formEffectUtils'
import
{
createAddRepositoryEffect
,
useUnitPreview
}
from
'./effects'
import
{
createAddRepositoryEffect
,
useUnitPreview
}
from
'./effects'
import
ModalTable
from
'@/components/ModalTable'
import
ModalTable
from
'@/components/ModalTable'
import
{
useHttpRequest
}
from
'@/hooks/useHttpRequest'
const
fetchMemberList
=
async
(
params
)
=>
{
const
fetchMemberList
=
async
(
params
)
=>
{
const
res
=
await
PublicApi
.
getMemberMaintenancePage
(
params
)
const
res
=
await
PublicApi
.
getMemberMaintenancePage
(
params
)
...
@@ -60,21 +61,13 @@ const AddRepository:React.FC<{}> = (props) => {
...
@@ -60,21 +61,13 @@ const AddRepository:React.FC<{}> = (props) => {
// 获取到的所有仓库, 用于选中后获得仓库库存
// 获取到的所有仓库, 用于选中后获得仓库库存
const
[
reposits
,
setReposits
]
=
useState
<
any
>
(
null
)
const
[
reposits
,
setReposits
]
=
useState
<
any
>
(
null
)
const
fetchWarehouseAll
=
async
()
=>
{
const
{
data
}
=
await
PublicApi
.
getWarehouseWarehouseAll
()
setReposits
(
data
)
return
data
.
map
(
v
=>
({
value
:
v
.
id
,
label
:
v
.
name
}))
}
const
initValue
=
useInitValue
(
PublicApi
.
getWarehouseFreightSpaceDetails
)
const
initValue
=
useInitValue
(
PublicApi
.
getWarehouseFreightSpaceDetails
)
const
[
visibleChannelMember
,
setVisibleChannelMember
]
=
useState
(
false
)
const
[
visibleChannelMember
,
setVisibleChannelMember
]
=
useState
(
false
)
const
[
visibleChannelRroduct
,
setVisibleChannelRroduct
]
=
useState
(
false
)
const
[
visibleChannelRroduct
,
setVisibleChannelRroduct
]
=
useState
(
false
)
const
[
memberRowSelection
,
memberRowCtl
]
=
useRowSelectionTable
()
const
[
memberRowSelection
,
memberRowCtl
]
=
useRowSelectionTable
()
const
[
productRowSelection
,
productRowCtl
]
=
useRowSelectionTable
({
type
:
'radio'
})
const
[
productRowSelection
,
productRowCtl
]
=
useRowSelectionTable
({
type
:
'radio'
})
useUnitPreview
(
initValue
,
addSchemaAction
)
useUnitPreview
(
initValue
,
addSchemaAction
)
const
columnsSetMember
:
ColumnType
<
any
>
[]
=
[
const
columnsSetMember
:
ColumnType
<
any
>
[]
=
[
{
{
...
@@ -141,6 +134,12 @@ const AddRepository:React.FC<{}> = (props) => {
...
@@ -141,6 +134,12 @@ const AddRepository:React.FC<{}> = (props) => {
},
},
]
]
useEffect
(()
=>
{
PublicApi
.
getWarehouseWarehouseAll
().
then
(({
data
})
=>
{
setReposits
(
data
)
})
},
[])
// 弹出会员
// 弹出会员
const
handleAddMemberBtn
=
()
=>
{
const
handleAddMemberBtn
=
()
=>
{
const
checkBoxs
=
addSchemaAction
.
getFieldValue
(
'applyMember'
)
const
checkBoxs
=
addSchemaAction
.
getFieldValue
(
'applyMember'
)
...
@@ -329,28 +328,26 @@ const AddRepository:React.FC<{}> = (props) => {
...
@@ -329,28 +328,26 @@ const AddRepository:React.FC<{}> = (props) => {
schema=
{
repositInSchema
}
schema=
{
repositInSchema
}
actions=
{
repositSchemaAction
}
actions=
{
repositSchemaAction
}
onSubmit=
{
handleRespotIn
}
onSubmit=
{
handleRespotIn
}
effects=
{
(
$
,
{
setFieldState
})
=>
{
effects=
{
async
(
$
,
{
setFieldState
})
=>
{
const
utils
=
useLinkageUtils
()
const
utils
=
useLinkageUtils
()
FormEffectHooks
.
onFormMount$
().
subscribe
(()
=>
{
FormEffectHooks
.
onFormMount$
().
subscribe
(()
=>
{
const
name
=
spyForm
.
getFieldValue
(
'name'
)
const
name
=
spyForm
.
getFieldValue
(
'name'
)
console
.
log
(
reposits
)
PublicApi
.
getWarehouseFreightSpaceAll
().
then
(
res
=>
{
const
asyncEnums
=
reposits
.
map
(
v
=>
({
const
{
data
}
=
res
const
asyncEnums
=
data
.
map
(
v
=>
({
label
:
v
.
name
,
label
:
v
.
name
,
value
:
v
.
id
value
:
v
.
id
}))
}))
utils
.
enum
(
'freightSpaceId'
,
asyncEnums
)
utils
.
enum
(
'freightSpaceId'
,
asyncEnums
)
$
(
'onFieldInputChange'
,
'freightSpaceId'
).
subscribe
(
state
=>
{
$
(
'onFieldInputChange'
,
'freightSpaceId'
).
subscribe
(
state
=>
{
const
numberValue
=
data
.
find
(
v
=>
v
.
id
===
state
.
value
).
inventory
const
numberValue
=
reposits
.
find
(
v
=>
v
.
id
===
state
.
value
).
principal
||
0
utils
.
value
(
'NO_SUBMIT1'
,
numberValue
)
utils
.
value
(
'NO_SUBMIT1'
,
numberValue
)
})
})
})
// 调入仓位信息
utils
.
enum
(
'foldFreightSpaceId'
,
[
utils
.
enum
(
'foldFreightSpaceId'
,
[
{
label
:
name
,
value
:
id
}
{
label
:
name
,
value
:
id
}
])
])
utils
.
value
(
'foldFreightSpaceId'
,
id
)
utils
.
value
(
'foldFreightSpaceId'
,
id
)
utils
.
value
(
'NO_SUBMIT2'
,
spyForm
.
getFieldValue
(
'inventory'
))
})
})
}
}
}
}
expressionScope=
{
{
expressionScope=
{
{
...
...
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