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
805a3f69
Commit
805a3f69
authored
Sep 01, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增提示语工具函数
parent
8b667132
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
26 deletions
+76
-26
CustomSlider.tsx
src/components/NiceForm/components/CustomSlider.tsx
+2
-2
index.less
src/components/NiceForm/index.less
+5
-3
adjustRepository.tsx
src/pages/repositories/adjustRepository.tsx
+10
-2
PositionSetting.tsx
src/pages/repositories/components/PositionSetting.tsx
+4
-1
index.tsx
src/pages/repositories/schema/index.tsx
+31
-18
index.tsx
src/utils/index.tsx
+24
-0
No files found.
src/components/NiceForm/components/CustomSlider.tsx
View file @
805a3f69
import
React
from
'react'
import
{
Slider
,
Input
,
Space
}
from
'antd'
import
{
Slider
,
Input
,
Space
,
InputNumber
}
from
'antd'
const
CustomSlider
=
(
props
)
=>
{
const
value
=
props
.
value
||
0
...
...
@@ -16,7 +16,7 @@ const CustomSlider = (props) => {
{
isNumber
?
<
div
>
<
Input
type=
'number'
className=
'underline_input'
max=
{
max
}
value=
{
props
.
value
}
onChange=
{
e
=>
props
.
mutators
.
change
(
e
.
target
.
v
alue
)
}
/>
<
Input
Number
className=
'underline_input'
min=
{
0
}
max=
{
max
||
0
}
value=
{
props
.
value
}
onChange=
{
fieldValue
=>
props
.
mutators
.
change
(
fieldV
alue
)
}
/>
</
div
>
:
<
Space
>
...
...
src/components/NiceForm/index.less
View file @
805a3f69
...
...
@@ -10,15 +10,17 @@
}
.underline_input {
max-
width: 200px;
width: 200px;
background: none;
border: none;
outline: none;
font-size: 32px;
border-bottom: 1px solid #DFE1E6;
padding: 8px 19px;
text-align: center;
display: inline-block;
display: block;
input {
text-align: center;
}
&:focus{
box-shadow: none;
border-bottom: 1px solid #DFE1E6;
...
...
src/pages/repositories/adjustRepository.tsx
View file @
805a3f69
...
...
@@ -12,7 +12,7 @@ import './index.less'
import
NiceForm
from
'@/components/NiceForm'
import
{
repositInSchema
,
repositOutSchema
,
repositTabOneSchema
}
from
'./schema'
import
{
createFormActions
,
FormEffectHooks
,
FormProvider
,
FormSpy
,
createAsyncFormActions
}
from
'@formily/antd'
import
{
getStepNumber
}
from
'@/utils'
import
{
getStepNumber
,
padRequiredMessage
}
from
'@/utils'
import
{
PublicApi
}
from
'@/services/api'
import
{
usePageStatus
}
from
'@/hooks/usePageStatus'
import
{
useInitValue
}
from
'@/formSchema/effects/useInitValue'
...
...
@@ -202,8 +202,12 @@ const AddRepository:React.FC<{}> = (props) => {
}))
utils
.
enum
(
'freightSpaceId'
,
asyncEnums
)
$
(
'onFieldInputChange'
,
'freightSpaceId'
).
subscribe
(
state
=>
{
const
numberValue
=
reposits
.
find
(
v
=>
v
.
id
===
state
.
value
).
inventory
||
0
const
repositValue
=
reposits
.
find
(
v
=>
v
.
id
===
state
.
value
)
const
numberValue
=
repositValue
.
inventory
||
0
utils
.
value
(
'NO_SUBMIT1'
,
numberValue
)
setFieldState
(
'NO_SUBMIT1'
,
state
=>
{
state
.
props
.
title
=
`当前仓位库存(${repositValue.unit})`
})
setFieldState
(
'foldInventory'
,
state
=>
{
state
.
props
[
"x-component-props"
].
max
=
numberValue
state
.
props
[
"x-component-props"
].
marks
=
getStepNumber
(
numberValue
)
...
...
@@ -214,6 +218,10 @@ const AddRepository:React.FC<{}> = (props) => {
{
label
:
name
,
value
:
id
}
])
utils
.
value
(
'foldFreightSpaceId'
,
id
)
setFieldState
(
'NO_SUBMIT2'
,
state
=>
{
state
.
props
.
title
=
`当前仓位库存(${initValue.unit})`
})
utils
.
value
(
'NO_SUBMIT2'
,
spyForm
.
getFieldValue
(
'inventory'
))
})
}
}
...
...
src/pages/repositories/components/PositionSetting.tsx
View file @
805a3f69
...
...
@@ -305,7 +305,10 @@ const PositionSetting:React.FC<PositionSettingProps> = (props) => {
if
(
parentState
.
value
)
{
console
.
log
(
'review'
)
setFieldState
(
'shopIds'
,
state
=>
{
state
.
props
[
"x-component-props"
].
dataSource
=
GlobalConfig
.
web
.
shopInfo
.
filter
(
v
=>
v
.
type
===
parentState
.
value
)
state
.
props
[
"x-component-props"
].
dataSource
=
pageStatus
===
PageStatus
.
PREVIEW
?
GlobalConfig
.
web
.
shopInfo
.
filter
(
v
=>
v
.
type
===
parentState
.
value
&&
state
.
value
.
includes
(
v
.
id
))
:
GlobalConfig
.
web
.
shopInfo
.
filter
(
v
=>
v
.
type
===
parentState
.
value
)
})
}
})
...
...
src/pages/repositories/schema/index.tsx
View file @
805a3f69
...
...
@@ -4,6 +4,7 @@ import { FORM_FILTER_PATH } from '@/formSchema/const';
import
{
GlobalConfig
}
from
'@/global/config'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
{
SHOP_TYPES
}
from
'@/constants'
;
import
{
padRequiredMessage
}
from
'@/utils'
;
// 将获取的商城转化为可用类型
const
getShopTypeMap
=
(()
=>
{
...
...
@@ -19,7 +20,7 @@ const getShopTypeMap = (() => {
},
[])
})()
export
const
repositSchema
:
ISchema
=
{
export
const
repositSchema
:
ISchema
=
padRequiredMessage
(
{
type
:
'object'
,
properties
:
{
megaLayout
:
{
...
...
@@ -125,9 +126,9 @@ export const repositSchema: ISchema = {
}
}
}
}
}
)
export
const
repositMoreSchema
:
ISchema
=
{
export
const
repositMoreSchema
:
ISchema
=
padRequiredMessage
(
{
type
:
'object'
,
properties
:
{
REPOSIT_TABS
:
{
...
...
@@ -336,10 +337,10 @@ export const repositMoreSchema: ISchema = {
}
}
}
}
}
)
// 新增仓位
export
const
repositDetailSchema
:
ISchema
=
{
export
const
repositDetailSchema
:
ISchema
=
padRequiredMessage
(
{
type
:
'object'
,
properties
:
{
REPOSIT_TABS
:
{
...
...
@@ -371,7 +372,13 @@ export const repositDetailSchema: ISchema = {
title
:
'仓位名称'
,
"x-component-props"
:
{
placeholder
:
'建议名称:商品名称+商城名称+渠道描述'
}
},
"x-rules"
:
[
{
limitByte
:
true
,
maxByte
:
60
}
]
},
shopType
:
{
type
:
'string'
,
...
...
@@ -527,10 +534,10 @@ export const repositDetailSchema: ISchema = {
}
}
}
}
}
)
// 仓位设置
export
const
repositTabOneSchema
:
ISchema
=
{
export
const
repositTabOneSchema
:
ISchema
=
padRequiredMessage
(
{
type
:
'object'
,
properties
:
{
REPOSIT_TABS
:
{
...
...
@@ -563,7 +570,13 @@ export const repositTabOneSchema: ISchema = {
editable
:
false
,
"x-component-props"
:
{
placeholder
:
'建议名称:商品名称+商城名称+渠道描述'
}
},
"x-rules"
:
[
{
limitByte
:
true
,
maxByte
:
60
}
]
},
shopType
:
{
type
:
'string'
,
...
...
@@ -720,10 +733,10 @@ export const repositTabOneSchema: ISchema = {
}
}
}
}
}
)
// 库存调入
export
const
repositInSchema
:
ISchema
=
{
export
const
repositInSchema
:
ISchema
=
padRequiredMessage
(
{
type
:
'object'
,
properties
:
{
repos_layout
:
{
...
...
@@ -761,14 +774,14 @@ export const repositInSchema: ISchema = {
'NO_SUBMIT1'
:
{
type
:
'object'
,
readOnly
:
true
,
title
:
'当前仓位库存(尺)'
,
"x-component"
:
'CircleBox'
,
title
:
'当前仓位库存'
,
default
:
0
},
'NO_SUBMIT2'
:
{
type
:
'object'
,
title
:
'当前仓位库存(尺)'
,
"x-component"
:
'CircleBox'
,
title
:
'当前仓位库存'
,
default
:
0
},
"foldInventory"
:
{
...
...
@@ -801,10 +814,10 @@ export const repositInSchema: ISchema = {
}
}
}
}
}
)
// 库存调出
export
const
repositOutSchema
:
ISchema
=
{
export
const
repositOutSchema
:
ISchema
=
padRequiredMessage
(
{
type
:
'object'
,
properties
:
{
repos_layout
:
{
...
...
@@ -842,14 +855,14 @@ export const repositOutSchema: ISchema = {
'NO_SUBMIT1'
:
{
type
:
'object'
,
readOnly
:
true
,
title
:
'当前仓位库存(尺)'
,
"x-component"
:
'CircleBox'
,
title
:
'当前仓位库存'
,
default
:
0
},
'NO_SUBMIT2'
:
{
type
:
'object'
,
title
:
'当前仓位库存(尺)'
,
"x-component"
:
'CircleBox'
,
title
:
'当前仓位库存'
,
default
:
0
},
"foldInventory"
:
{
...
...
@@ -882,4 +895,4 @@ export const repositOutSchema: ISchema = {
}
}
}
}
}
)
src/utils/index.tsx
View file @
805a3f69
...
...
@@ -398,6 +398,30 @@ export const getQueryStringParams = (url?: string) => {
return
queryString
.
parse
(
searchParam
)
}
// 填充必填的schema message提示
export
const
padRequiredMessage
=
(
originSchema
:
ISchema
)
=>
{
const
messageSwich
=
(
type
)
=>
{
return
type
?
'请选择'
:
'请输入'
}
const
todoFn
=
(
targetSchema
)
=>
{
}
Object
.
entries
(
originSchema
.
properties
).
map
(([
key
,
value
])
=>
{
if
(
value
.
required
)
{
const
isSelect
=
value
.
enum
const
message
=
messageSwich
(
isSelect
)
+
(
value
.
title
||
''
)
value
[
'x-rules'
]
=
Array
.
isArray
(
value
[
'x-rules'
])
?
value
[
'x-rules'
].
concat
([{
message
,
required
:
true
}])
:
[{
message
,
required
:
true
}]
}
if
(
value
.
properties
)
{
padRequiredMessage
(
value
)
}
return
value
})
return
originSchema
}
export
default
{
isArray
,
isObject
,
...
...
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