| | |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | formlist: PropTypes.any, |
| | | card: PropTypes.object |
| | | card: PropTypes.object, |
| | | billCodes: PropTypes.array |
| | | } |
| | | |
| | | state = { |
| | |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | let formlist = JSON.parse(JSON.stringify(this.props.formlist)) |
| | | |
| | | console.log(formlist) |
| | | let type = formlist.filter(cell => cell.key === 'type')[0].initVal |
| | | let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal |
| | | let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required'] // 默认显示项 |
| | |
| | | |
| | | if (type === 'link') { // 关联类型、增加关联字段 |
| | | _options = [..._options, 'linkField'] |
| | | } |
| | | console.log(type) |
| | | if (type === 'funcvar') { |
| | | _options = ['label', 'field', 'linkfield'] |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | if (value === 'link') { |
| | | _options = [..._options, 'linkField'] |
| | | } |
| | | |
| | | if (value === 'funcvar') { |
| | | _options = ['label', 'field', 'linkfield'] |
| | | } |
| | | |
| | | this.setState({ |
| | | openType: value, |
| | |
| | | }, () => { |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(form => { |
| | | if (form.key === 'initval' && value !== 'fileupload') { |
| | | if (form.key === 'initval' && value !== 'fileupload' && value !== 'funcvar') { |
| | | form.hidden = false |
| | | } |
| | | return form |
| | |
| | | if (item.hidden) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | let rules = [] |
| | | if (item.key === 'field') { |
| | | rules = [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | }, { |
| | | max: 50, |
| | | message: '字段名最多50个字符!' |
| | | }] |
| | | } |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | }, |
| | | ...rules |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)} |
| | | </Form.Item> |
| | |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | let isvalid = true |
| | | values.id = this.props.card.id |
| | | values.uuid = this.props.card.uuid |
| | | // 下拉菜单或关联菜单 |
| | | if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '0') { |
| | |
| | | values.options = [] |
| | | } |
| | | |
| | | if (!values.type) { |
| | | values.type = 'funcvar' |
| | | values.readonly = 'true' |
| | | } |
| | | if (isvalid) { |
| | | resolve(values) |
| | | } else { |