Commit 805a3f69 authored by 前端-许佳敏's avatar 前端-许佳敏

新增提示语工具函数

parent 8b667132
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.value)}/>
<InputNumber className='underline_input' min={0} max={max || 0} value={props.value} onChange={fieldValue => props.mutators.change(fieldValue)}/>
</div>
:
<Space>
......
......@@ -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;
......
......@@ -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'))
})
}}
......
......@@ -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)
})
}
})
......
......@@ -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 = {
}
}
}
}
})
......@@ -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,
......
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