提交 aa5aec36 authored 作者: 钟是志's avatar 钟是志

demo页面修改

上级 df8f8787
import React, { Fragment, Component } from 'react'; import React, { Fragment, Component } from 'react';
import { DatePicker, Picker, TextareaItem, InputItem, List } from 'antd-mobile'; import { DatePicker, Picker, TextareaItem, InputItem, List, Switch } from 'antd-mobile';
import moment from 'moment'; import moment from 'moment';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import FieldList from '@/H5Public/baseComponents/FieldList'; import FieldList from '@/H5Public/baseComponents/FieldList';
...@@ -81,16 +81,41 @@ const DiyPicker = (props) => { ...@@ -81,16 +81,41 @@ const DiyPicker = (props) => {
}} }}
{...config.otherProps} {...config.otherProps}
> >
<List.Item arrow={config.readOnly ? '' : 'horizontal' }> <List.Item arrow={config.readOnly ? '' : 'horizontal'}>
{giveRequiredName(config)} {giveRequiredName(config)}
</List.Item> </List.Item>
</Picker> </Picker>
); );
};
const DiySwitch = (props) => {
let { config, formValue, changeValue } = props;
if (config.readOnly) {
config.placeholder = ' ';
} else {
config.placeholder = config.placeholder || '点击输入';
}
return (
<List.Item
key={config.key}
extra={
<Switch
checked={formValue[config.key]}
disabled={config.readOnly}
onChange={(val) => {
changeValue(val, config.key);
}}
{...config.otherProps}
/>
}
>
{giveRequiredName(config)}
</List.Item>
);
}; };
const DiyDatePicker = (props) => { const DiyDatePicker = (props) => {
let { config, formValue, changeValue, } = props; let { config, formValue, changeValue } = props;
let value = formValue[config.key] ? new Date(formValue[config.key].replace(/-/g, '/')) : null; let value = formValue[config.key] ? new Date(formValue[config.key].replace(/-/g, '/')) : null;
const change = (date) => { const change = (date) => {
let v = moment(date.valueOf()).format('YYYY-MM-DD'); let v = moment(date.valueOf()).format('YYYY-MM-DD');
...@@ -189,6 +214,15 @@ class FormArray extends Component { ...@@ -189,6 +214,15 @@ class FormArray extends Component {
changeValue={this.changeValue} changeValue={this.changeValue}
/> />
); );
case 'Switch':
return (
<DiySwitch
key={x.key}
config={x}
formValue={formValues}
changeValue={this.changeValue}
/>
);
default: default:
return null; return null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论