From f267d04e0561a0a20d1f2a9f558a273558ece90d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 24 五月 2021 17:50:19 +0800 Subject: [PATCH] 2021-05-24 --- src/menu/components/form/normal-form/index.jsx | 81 +++++++++++++++++++++++++++------------- 1 files changed, 54 insertions(+), 27 deletions(-) diff --git a/src/menu/components/form/normal-form/index.jsx b/src/menu/components/form/normal-form/index.jsx index 590fe46..5c7f303 100644 --- a/src/menu/components/form/normal-form/index.jsx +++ b/src/menu/components/form/normal-form/index.jsx @@ -1,6 +1,5 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import {connect} from 'react-redux' import { is, fromJS } from 'immutable' import { Icon, Popover, Modal, Button, Switch, notification } from 'antd' import moment from 'moment' @@ -19,6 +18,7 @@ const SettingComponent = asyncIconComponent(() => import('@/menu/datasource')) const WrapComponent = asyncIconComponent(() => import('@/menu/components/form/wrapsetting')) const CardComponent = asyncComponent(() => import('@/templates/modalconfig/dragelement')) +const MobCardComponent = asyncComponent(() => import('@/mob/components/formdragelement')) const FormTitle = asyncComponent(() => import('../dragtitle')) const GroupForm = asyncComponent(() => import('./groupform')) const FormAction = asyncComponent(() => import('../formaction')) @@ -38,6 +38,7 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + appType: sessionStorage.getItem('appType'), card: null, back: false, group: null, @@ -45,7 +46,8 @@ visible: false, editform: null, formlist: null, - sqlVerifing: false + sqlVerifing: false, + standardform: null } UNSAFE_componentWillMount () { @@ -118,7 +120,7 @@ } shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) || (!this.props.menu && nextProps.menu) + return !is(fromJS(this.state), fromJS(nextState)) } /** @@ -404,9 +406,13 @@ } addForm = () => { + const { appType } = this.state let group = fromJS(this.state.group).toJS() let lastItem = group.fields[group.fields.length - 1] - let span = lastItem ? lastItem.span : 12 + let span = appType === 'mob' ? 24 : 12 + if (lastItem && lastItem.span) { + span = lastItem.span + } let newcard = { uuid: Utils.getuuid(), @@ -429,8 +435,9 @@ group.fields.push(newcard) - this.setState({group}) - this.handleForm(newcard) + this.setState({group}, () => { + this.handleForm(newcard) + }) } editModalCancel = () => { @@ -444,7 +451,7 @@ * @description 琛ㄥ崟缂栬緫 */ handleForm = (_item) => { - const { card, group } = this.state + const { card, group, appType } = this.state let _form = fromJS(_item).toJS() let _inputfields = [] let _tabfields = [] @@ -453,14 +460,23 @@ value: '', text: '绌�' }] + let standardform = null _inputfields = group.fields.filter(item => item.type === 'text' || item.type === 'number' || item.type === 'textarea' || item.type === 'color') - _tabfields = group.fields.filter(item => _form.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) + if (appType === 'mob') { + _tabfields = group.fields.filter(item => _form.field !== item.field && item.hidden !== 'true' && ['text', 'number'].includes(item.type)) + } else { + _tabfields = group.fields.filter(item => _form.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) + } _tabfields.unshift({field: '', text: '鍘熻〃鍗�'}) let uniq = new Map() uniq.set(_form.field, true) - group.fields.forEach(item => { + let index = null + group.fields.forEach((item, i) => { + if (_form.uuid === item.uuid) { + index = i + } if (item.type !== 'select' && item.type !== 'link' && item.type !== 'radio') return if (item.field && !uniq.has(item.field)) { uniq.set(item.field, true) @@ -475,6 +491,13 @@ }) } }) + if (index !== null) { + if (index === 0) { + standardform = group.fields[index + 1] || null + } else { + standardform = group.fields[index - 1] || null + } + } card.columns.forEach(col => { if (col.field && !uniq.has(col.field)) { @@ -492,7 +515,13 @@ _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item)) } + if (appType !== 'mob' && !_form.span && standardform && standardform.span) { + _form.span = standardform.span + _form.labelwidth = standardform.labelwidth + } + this.setState({ + standardform, visible: true, editform: _form, formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, false) @@ -596,7 +625,7 @@ } render() { - const { card, dict, group } = this.state + const { card, dict, group, appType } = this.state return ( <div className="menu-normal-form-edit-box" style={{...card.style}} onClick={this.clickComponent} id={card.uuid}> @@ -627,12 +656,12 @@ <Icon className="plus" title="娣诲姞琛ㄥ崟" onClick={this.addForm} type="plus" /> <FieldsComponent config={group} type="form" updatefield={this.updateGroup} /> <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> - <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button> - <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2鍒�</Button> - <Button className="mk-cols-change" onClick={() => this.changecols(3)}>3鍒�</Button> - <Button className="mk-cols-change" onClick={() => this.changecols(4)}>4鍒�</Button> + {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button> : null} + {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2鍒�</Button> : null} + {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(3)}>3鍒�</Button> : null} + {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(4)}>4鍒�</Button> : null} <div style={{clear: 'both'}}></div> - <CardComponent + {appType !== 'mob' ? <CardComponent list={group.fields} setting={group.setting} showField={this.state.showField} @@ -640,7 +669,14 @@ handleList={this.handleList} handleForm={this.handleForm} closeForm={this.closeForm} - /> + /> : <MobCardComponent + list={group.fields} + setting={group.setting} + showField={this.state.showField} + handleList={this.handleList} + handleForm={this.handleForm} + closeForm={this.closeForm} + />} <FormAction config={card} group={group} updateconfig={this.updateGroup}/> </div> : null} <Modal @@ -673,6 +709,7 @@ card={this.state.editform} formlist={this.state.formlist} inputSubmit={this.handleSubmit} + standardform={this.state.standardform} wrappedComponentRef={(inst) => this.formRef = inst} /> </Modal> @@ -681,14 +718,4 @@ } } -const mapStateToProps = (state) => { - return { - menu: state.customMenu - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(PropCardEditComponent) \ No newline at end of file +export default PropCardEditComponent \ No newline at end of file -- Gitblit v1.8.0