Commit c857db9d authored by tjy's avatar tjy
parents 7595641a c8dbdc23
import React from 'react'
import styled from 'styled-components'
const CircleBox = (props) => {
return (
<div className='form-circle-box'>
{props.value}
</div>
)
}
CircleBox.defaultProps = {}
CircleBox.isFieldComponent = true;
export default CircleBox
\ No newline at end of file
......@@ -3,18 +3,27 @@ import { Slider, Input, Space } from 'antd'
const CustomSlider = (props) => {
const value = props.value || 0
const max = props.props['x-component-props']?.max || 0
const componentProps = props.props['x-component-props'] || {}
const { max = 0, width = '100%', layout = {}, isNumber = false } = componentProps
return (
<div style={{width: '100%'}}>
<div style={{width: '100%', ...layout}}>
<Slider
style={{width}}
disabled={!props.editable}
value={value}
onChange={e => props.mutators.change(e)}
{...props.props['x-component-props']}></Slider>
<Space>
<Input type='number' disabled max={max} value={props.value} onChange={e => props.mutators.change(e.target.value)} addonAfter='尺'/>
{ max && <span>还剩:{max - value}</span> }
</Space>
{...props.props['x-component-props']}/>
{
isNumber ?
<div>
<Input type='number' className='underline_input' max={max} value={props.value} onChange={e => props.mutators.change(e.target.value)}/>
</div>
:
<Space>
<Input type='number' disabled max={max} value={props.value} onChange={e => props.mutators.change(e.target.value)} addonAfter='尺'/>
{ max && <span>还剩:{max - value}</span> }
</Space>
}
</div>
)
}
......
.form-circle-box {
width: 160px;
height: 160px;
border: 3px solid #efefef;
background: #fff;
text-align: center;
line-height: 160px;
font-size: 20px;
border-radius: 50%;
}
.underline_input {
max-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;
&:focus{
box-shadow: none;
border-bottom: 1px solid #DFE1E6;
}
}
\ No newline at end of file
......@@ -16,6 +16,8 @@ import MultTable from './components/MultTable';
import CustomRegistryPhone from './components/CustomRegistryPhone';
import CustomRelevance from './components/CustomRelevance';
import Children from './components/Children';
import CircleBox from './components/CircleBox';
import './index.less'
export interface NiceFormProps extends IAntdSchemaFormProps {}
......@@ -54,7 +56,8 @@ const NiceForm: React.FC<NiceFormProps> = props => {
MultTable,
CustomRegistryPhone,
CustomRelevance,
Children
Children,
CircleBox
};
const defineComponents = Object.assign(customComponents, components);
......
import { FormEffectHooks } from '@formily/antd'
import { useLinkageUtils } from '@/utils/formEffectUtils'
const { onFieldValueChange$ } = FormEffectHooks
/**
* @description 用于同步表单的值
* @param target 同步的目标路径
* @param syncArr 被同步的表单字段
*/
export const useSyncValues = (target: string, syncArr: string[]) => {
const linkage = useLinkageUtils()
onFieldValueChange$(target).subscribe(state => {
syncArr.forEach(v => {
linkage.value(v, state.value)
})
})
}
\ No newline at end of file
@import './mixins/layout.less';
#root {
// 去除数字输入框的箭头
input[type=number] {
-moz-appearance:textfield;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.identityRadio{
display: flex;
flex-direction: column;
......
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