copy from src/menu/components/form/normal-form/index.jsx
copy to src/menu/components/form/simple-form/index.jsx
File was copied from src/menu/components/form/normal-form/index.jsx |
| | |
| | | import './index.scss' |
| | | |
| | | const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform')) |
| | | const NormalForm = asyncIconComponent(() => import('@/components/normalform')) |
| | | const SettingComponent = asyncIconComponent(() => import('@/menu/datasource')) |
| | | const NormalForm = asyncIconComponent(() => import('@/components/normalform')) |
| | | const CardComponent = asyncComponent(() => import('@/templates/modalconfig/dragelement')) |
| | | const MobCardComponent = asyncComponent(() => import('@/mob/components/formdragelement')) |
| | | const FormTitle = asyncComponent(() => import('../dragtitle')) |
| | | const FormAction = asyncComponent(() => import('../formaction')) |
| | | const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) |
| | | const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) |
| | | const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) |
| | | const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) |
| | |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | class PropCardEditComponent extends Component { |
| | | class SimpleFormComponent extends Component { |
| | | static propTpyes = { |
| | | card: PropTypes.object, |
| | | deletecomponent: PropTypes.func, |
| | |
| | | appType: sessionStorage.getItem('appType'), |
| | | card: null, |
| | | back: false, |
| | | group: null, |
| | | showField: false, |
| | | visible: false, |
| | | editform: null, |
| | |
| | | width: card.width || 24, |
| | | name: card.name, |
| | | subtype: card.subtype, |
| | | setting: { }, |
| | | wrap: { name: card.name, width: card.width || 24, datatype: 'static', groupLabel: 'show', color: '#1890ff' }, |
| | | setting: { interType: 'system' }, |
| | | wrap: { name: card.name, width: card.width || 24, datatype: 'static' }, |
| | | style: { marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' }, |
| | | headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, |
| | | columns: [], |
| | | scripts: [], |
| | | subcards: [{ |
| | | uuid: Utils.getuuid(), |
| | | setting: {title: '第一步', align: 'left_right'}, |
| | | sort: 1, |
| | | setting: {title: '空', align: 'left_right', enable: 'true'}, |
| | | style: {}, |
| | | fields: [], |
| | | prevButton: {label: '上一步', type: 'prev', enable: 'false', style: {marginRight: '15px', paddingTop: '5px', paddingBottom: '5px'}}, |
| | | subButton: {label: '提交', type: 'submit', intertype: 'system', reload: 'false', sqlType: 'update', sql: '', Ot: 'notRequired', execSuccess: 'never', enable: 'true', style: {backgroundColor: '#1890ff', color: '#ffffff', paddingLeft: '25px', paddingRight: '25px', paddingTop: '5px', paddingBottom: '5px'}}, |
| | | nextButton: {label: '跳过', type: 'next', enable: 'false', style: {paddingTop: '5px', paddingBottom: '5px'}} |
| | | }] |
| | | } |
| | | |
| | |
| | | return scard |
| | | }) |
| | | } |
| | | this.setState({ |
| | | group: _card.subcards[0] || null |
| | | }) |
| | | this.updateComponent(_card) |
| | | } else { |
| | | let _card = fromJS(card).toJS() |
| | | this.setState({ |
| | | card: _card, |
| | | group: _card.subcards[0] || null |
| | | card: _card |
| | | }) |
| | | } |
| | | } |
| | |
| | | card.subcards.forEach(item => { |
| | | item.fields.forEach(m => { |
| | | if (m.type === 'linkMain' && !supModule) { |
| | | card.errors.push({ level: 1, detail: `分组“${item.setting.title}”中关联主表表单“${m.label}”无效`}) |
| | | card.errors.push({ level: 1, detail: `关联主表表单“${m.label}”无效`}) |
| | | } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) { |
| | | card.errors.push({ level: 1, detail: `分组“${item.setting.title}”中表单“${m.label}”大小写与字段集不一致`}) |
| | | card.errors.push({ level: 1, detail: `表单“${m.label}”大小写与字段集不一致`}) |
| | | } |
| | | }) |
| | | }) |
| | |
| | | card.subcards.forEach(item => { |
| | | item.fields.forEach(m => { |
| | | if (m.type === 'linkMain' && !supModule) { |
| | | card.errors.push({ level: 1, detail: `分组“${item.setting.title}”中关联主表表单“${m.label}”无效`}) |
| | | card.errors.push({ level: 1, detail: `关联主表表单“${m.label}”无效`}) |
| | | } |
| | | }) |
| | | }) |
| | |
| | | } |
| | | |
| | | getStyle = (comIds, style) => { |
| | | const { card, group } = this.state |
| | | const { card } = this.state |
| | | |
| | | if (comIds[0] === 'form') { |
| | | let Index = group.fields.findIndex(n => n.uuid === comIds[1]) |
| | | let Index = card.subcards[0].fields.findIndex(n => n.uuid === comIds[1]) |
| | | |
| | | if (Index === -1) return |
| | | |
| | | let _group = fromJS(group).toJS() |
| | | let _card = fromJS(card).toJS() |
| | | |
| | | _group.fields[Index].style = style |
| | | _card.subcards[0].fields[Index].style = style |
| | | |
| | | this.updateGroup(_group) |
| | | this.updateComponent(_card) |
| | | |
| | | return |
| | | } |
| | |
| | | if (comIds.length !== 1 || comIds[0] !== card.uuid) return |
| | | |
| | | let _card = {...card, style} |
| | | |
| | | |
| | | this.updateComponent(_card) |
| | | } |
| | | |
| | | addCard = () => { |
| | | updateGroup = (res) => { |
| | | let card = fromJS(this.state.card).toJS() |
| | | |
| | | let newcard = { |
| | | uuid: Utils.getuuid(), |
| | | setting: { title: `第${card.subcards.length + 1}步`, align: 'left_right' }, |
| | | sort: card.subcards.length + 1, |
| | | style: {}, |
| | | fields: [], |
| | | prevButton: {label: '上一步', type: 'prev', enable: 'false', style: {marginRight: '15px', paddingTop: '5px', paddingBottom: '5px'}}, |
| | | subButton: {label: '提交', type: 'submit', intertype: 'system', reload: 'false', sqlType: 'update', sql: '', Ot: 'notRequired', enable: 'true', style: {backgroundColor: '#1890ff', color: '#ffffff', paddingLeft: '25px', paddingRight: '25px', paddingTop: '5px', paddingBottom: '5px'}}, |
| | | nextButton: {label: '跳过', type: 'next', enable: 'false', style: {paddingTop: '5px', paddingBottom: '5px'}} |
| | | } |
| | | card.subcards[0] = res |
| | | |
| | | card.subcards.push(newcard) |
| | | |
| | | this.setState({ |
| | | group: newcard |
| | | }) |
| | | this.updateComponent(card) |
| | | } |
| | | |
| | | changecards = (list) => { |
| | | let card = fromJS(this.state.card).toJS() |
| | | card.subcards = list.map((item, index) => { |
| | | item.sort = index + 1 |
| | | return item |
| | | }) |
| | | |
| | | this.updateComponent(card) |
| | | } |
| | | |
| | | selectGroup = (item) => { |
| | | this.setState({ |
| | | group: item |
| | | }) |
| | | } |
| | | |
| | | changeGroup = (item) => { |
| | | this.updateGroup(item) |
| | | } |
| | | |
| | | closeGroup = (cell) => { |
| | | const { group } = this.state |
| | | let card = fromJS(this.state.card).toJS() |
| | | const _this = this |
| | | |
| | | confirm({ |
| | | content: '确定删除分组吗?', |
| | | onOk() { |
| | | card.subcards = card.subcards.filter(item => item.uuid !== cell.uuid) |
| | | let _group = group |
| | | |
| | | if (group.uuid === cell.uuid) { |
| | | _group = card.subcards[0] || null |
| | | } |
| | | |
| | | _this.setState({group: _group}) |
| | | _this.updateComponent(card) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } |
| | | |
| | | updateGroup = (group) => { |
| | | let card = fromJS(this.state.card).toJS() |
| | | |
| | | card.subcards = card.subcards.map(item => { |
| | | if (item.uuid === group.uuid) { |
| | | return group |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({group}) |
| | | this.updateComponent(card) |
| | | } |
| | | |
| | | plusFields = (items) => { |
| | | let _group = fromJS(this.state.group).toJS() |
| | | const { card } = this.state |
| | | |
| | | _group.fields.push(...items) |
| | | let _card = fromJS(card).toJS() |
| | | |
| | | this.updateGroup(_group) |
| | | _card.subcards[0].fields.push(...items) |
| | | |
| | | this.updateComponent(_card) |
| | | } |
| | | |
| | | |
| | | changecols = (type) => { |
| | | let card = fromJS(this.state.card).toJS() |
| | | let config = fromJS(this.state.group).toJS() |
| | | let _this = this |
| | | |
| | | config.fields = config.fields.map(item => { |
| | | card.subcards[0].fields = card.subcards[0].fields.map(item => { |
| | | item.labelwidth = 33.3 |
| | | item.span = 24 |
| | | if (['textarea','split','hint','checkcard','brafteditor'].includes(item.type)) { |
| | |
| | | confirm({ |
| | | content: `确定切换为${type}列吗?`, |
| | | onOk() { |
| | | card.subcards = card.subcards.map(item => { |
| | | if (item.uuid === config.uuid) { |
| | | return config |
| | | } |
| | | return item |
| | | }) |
| | | _this.setState({group: config}) |
| | | _this.updateComponent(card) |
| | | }, |
| | | onCancel() {} |
| | |
| | | } |
| | | |
| | | handleList = (list, newcard) => { |
| | | let group = fromJS(this.state.group).toJS() |
| | | let card = fromJS(this.state.card).toJS() |
| | | |
| | | group.fields = list |
| | | card.subcards[0].fields = list |
| | | |
| | | card.subcards = card.subcards.map(item => { |
| | | if (item.uuid === group.uuid) { |
| | | return group |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({group}, () => { |
| | | this.setState({}, () => { |
| | | if (newcard) { |
| | | this.handleForm(newcard) |
| | | } |
| | |
| | | } |
| | | |
| | | closeForm = (cell) => { |
| | | let group = fromJS(this.state.group).toJS() |
| | | let card = fromJS(this.state.card).toJS() |
| | | let _this = this |
| | | |
| | | group.fields = group.fields.filter(item => item.uuid !== cell.uuid) |
| | | |
| | | card.subcards = card.subcards.map(item => { |
| | | if (item.uuid === group.uuid) { |
| | | return group |
| | | } |
| | | return item |
| | | }) |
| | | card.subcards[0].fields = card.subcards[0].fields.filter(item => item.uuid !== cell.uuid) |
| | | |
| | | confirm({ |
| | | content: `确定删除<<${cell.label}>>吗?`, |
| | | onOk() { |
| | | _this.setState({group}) |
| | | _this.updateComponent(card) |
| | | }, |
| | | onCancel() {} |
| | |
| | | |
| | | addForm = () => { |
| | | const { appType } = this.state |
| | | let group = fromJS(this.state.group).toJS() |
| | | let lastItem = group.fields[group.fields.length - 1] |
| | | let card = fromJS(this.state.card).toJS() |
| | | let lastItem = card.subcards[0].fields[card.subcards[0].fields.length - 1] |
| | | let span = appType === 'mob' ? 24 : 12 |
| | | if (lastItem && lastItem.span) { |
| | | span = lastItem.span |
| | |
| | | focus: true |
| | | } |
| | | |
| | | group.fields.push(newcard) |
| | | card.subcards[0].fields.push(newcard) |
| | | |
| | | this.setState({group}, () => { |
| | | this.setState({card}, () => { |
| | | this.handleForm(newcard) |
| | | }) |
| | | } |
| | | |
| | | editModalCancel = () => { |
| | | let group = fromJS(this.state.group).toJS() |
| | | group.fields = group.fields.filter(item => !item.focus) |
| | | let card = fromJS(this.state.card).toJS() |
| | | card.subcards[0].fields = card.subcards[0].fields.filter(item => !item.focus) |
| | | |
| | | this.setState({group, visible: false, editform: null}) |
| | | this.updateGroup(group) |
| | | this.setState({card, visible: false, editform: null}) |
| | | } |
| | | |
| | | /** |
| | | * @description 表单编辑 |
| | | */ |
| | | handleForm = (_item) => { |
| | | const { card, group, appType } = this.state |
| | | const { card, appType } = this.state |
| | | let _form = fromJS(_item).toJS() |
| | | let _inputfields = [] |
| | | let _tabfields = [] |
| | |
| | | let _inputIndex = 1 |
| | | let _tabIndex = 1 |
| | | let _linkIndex = 1 |
| | | group.fields.forEach((item, i) => { |
| | | card.subcards[0].fields.forEach((item, i) => { |
| | | if (_form.uuid === item.uuid) { |
| | | index = i |
| | | } |
| | |
| | | }) |
| | | _inputIndex++ |
| | | } |
| | | |
| | | if (_item.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { |
| | | if (_form.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { |
| | | _tabfields.push({ |
| | | field: item.field, |
| | | label: _tabIndex + '、' + label |
| | |
| | | uniq.set(item.field, true) |
| | | |
| | | _linkableFields.push({ |
| | | field: item.field, |
| | | label: _linkIndex + '、' + item.label + ' (表单)' |
| | | value: item.field, |
| | | text: _linkIndex + '、' + item.label + ' (表单)' |
| | | }) |
| | | _linksupFields.push({ |
| | | field: item.field, |
| | | label: _linkIndex + '、' + label |
| | | value: item.field, |
| | | text: _linkIndex + '、' + label |
| | | }) |
| | | |
| | | _linkIndex++ |
| | | } |
| | | }) |
| | |
| | | |
| | | if (index !== null) { |
| | | if (index === 0) { |
| | | standardform = group.fields[index + 1] || null |
| | | standardform = card.subcards[0].fields[index + 1] || null |
| | | } else { |
| | | standardform = group.fields[index - 1] || null |
| | | standardform = card.subcards[0].fields[index - 1] || null |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | handleSubmit = () => { |
| | | this.formRef.handleConfirm().then(res => { |
| | | let _config = fromJS(this.state.group).toJS() |
| | | let _config = fromJS(this.state.card).toJS() |
| | | let fieldrepet = false // 字段重复 |
| | | |
| | | _config.fields = _config.fields.map(item => { |
| | | _config.subcards[0].fields = _config.subcards[0].fields.map(item => { |
| | | if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { |
| | | fieldrepet = true |
| | | } |
| | |
| | | editform: null, |
| | | visible: false |
| | | }) |
| | | this.updateGroup(_config) |
| | | this.updateComponent(_config) |
| | | } else { |
| | | this.setState({sqlVerifing: false}) |
| | | |
| | |
| | | editform: null, |
| | | visible: false |
| | | }) |
| | | this.updateGroup(_config) |
| | | this.updateComponent(_config) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | pasteForm = (res) => { |
| | | let _config = fromJS(this.state.card).toJS() |
| | | |
| | | if (res.subButton) { |
| | | let card = fromJS(this.state.card).toJS() |
| | | let _this = this |
| | | |
| | | res.uuid = Utils.getuuid() |
| | | res.sort = card.subcards.length + 1 |
| | | _config.subcards[0].setting.focus = res.focus |
| | | _config.subcards[0].setting.cache = res.cache |
| | | _config.subcards[0].setting.align = res.align |
| | | _config.subcards[0].setting.enable = res.enable |
| | | _config.subcards[0].setting.verticalSpace = res.verticalSpace || '' |
| | | _config.wrap.focus = res.focus |
| | | _config.wrap.cache = res.cache |
| | | _config.wrap.align = res.align |
| | | _config.wrap.enable = res.enable |
| | | _config.wrap.verticalSpace = res.verticalSpace || '' |
| | | |
| | | res.fields.forEach(item => { |
| | | item.uuid = Utils.getuuid() |
| | | }) |
| | | _config.subcards[0].fields = res.fields |
| | | _config.subcards[0].subButton = res.subButton |
| | | |
| | | if (!res.prevButton) { |
| | | res.prevButton = {label: '上一步', type: 'prev', enable: 'false', style: {marginRight: '15px', paddingTop: '5px', paddingBottom: '5px'}} |
| | | } |
| | | if (!res.nextButton) { |
| | | res.nextButton = {label: '跳过', type: 'next', enable: 'false', style: {paddingTop: '5px', paddingBottom: '5px'}} |
| | | } |
| | | |
| | | card.subcards.push(res) |
| | | |
| | | this.setState({ |
| | | group: res |
| | | }) |
| | | this.updateComponent(card) |
| | | |
| | | notification.success({ |
| | | top: 92, |
| | | message: '粘贴成功!', |
| | | duration: 2 |
| | | confirm({ |
| | | content: `替换表单及按钮配置?`, |
| | | onOk() { |
| | | _this.updateComponent(_config) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _config = fromJS(this.state.group).toJS() |
| | | let fieldrepet = false // 字段重复 |
| | | |
| | | _config.fields.forEach(item => { |
| | | _config.subcards[0].fields.forEach(item => { |
| | | if (res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { |
| | | fieldrepet = true |
| | | } |
| | |
| | | }) |
| | | return |
| | | } |
| | | _config.fields.push(res) |
| | | _config.subcards[0].fields.push(res) |
| | | |
| | | this.updateGroup(_config) |
| | | this.updateComponent(_config) |
| | | |
| | | this.handleForm(res) |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | _card.subcards[0].setting.focus = _card.wrap.focus |
| | | _card.subcards[0].setting.cache = _card.wrap.cache |
| | | _card.subcards[0].setting.align = _card.wrap.align |
| | | _card.subcards[0].setting.enable = _card.wrap.enable |
| | | _card.subcards[0].setting.verticalSpace = _card.wrap.verticalSpace |
| | | |
| | | this.updateComponent(_card) |
| | | } |
| | | |
| | | clearGroup = () => { |
| | | let card = fromJS(this.state.card).toJS() |
| | | let _this = this |
| | | |
| | | card.subcards[0].fields = [] |
| | | |
| | | confirm({ |
| | | content: `确定清空表单吗?`, |
| | | onOk() { |
| | | _this.updateComponent(card) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { card, dict, group, appType } = this.state |
| | | const { card, dict, appType } = this.state |
| | | |
| | | return ( |
| | | <div className="menu-normal-form-edit-box" style={resetStyle(card.style)} onClick={this.clickComponent} id={card.uuid}> |
| | | <div className="menu-simple-form-edit-box" style={resetStyle(card.style)} onClick={this.clickComponent} id={card.uuid}> |
| | | <NormalHeader config={card} updateComponent={this.updateComponent}/> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <PlusOutlined className="plus" title="添加分组" onClick={this.addCard}/> |
| | | <NormalForm title="表单设置" width={800} update={this.updateWrap} getForms={this.getWrapForms}> |
| | | <EditOutlined style={{color: '#1890ff'}} title="编辑"/> |
| | | </NormalForm> |
| | | <CopyComponent type="stepform" card={card}/> |
| | | <CopyComponent type="simpleform" card={card}/> |
| | | <PasteComponent config={card} options={['form', 'formgroup']} updateConfig={this.pasteForm} /> |
| | | <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle}/> |
| | | <UserComponent config={card}/> |
| | |
| | | } trigger="hover"> |
| | | <ToolOutlined /> |
| | | </Popover> |
| | | <FormTitle |
| | | list={card.subcards} |
| | | selectId={group ? group.uuid : ''} |
| | | handleList={this.changecards} |
| | | handleGroup={this.changeGroup} |
| | | closeGroup={this.closeGroup} |
| | | selectGroup={this.selectGroup} |
| | | /> |
| | | {group ? <div className="form-area"> |
| | | <div className="form-area"> |
| | | <PlusOutlined className="plus" title="添加表单" onClick={this.addForm}/> |
| | | <FieldsComponent config={group} type="form" plusFields={this.plusFields} /> |
| | | <FieldsComponent config={card.subcards[0]} type="form" plusFields={this.plusFields} /> |
| | | <span style={{color: 'red', marginLeft: '30px', cursor: 'pointer'}} onClick={this.clearGroup}>清空</span> |
| | | <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> |
| | | {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(4)}>4列</Button> : null} |
| | | <div style={{clear: 'both'}}></div> |
| | | {appType !== 'mob' ? <CardComponent |
| | | list={group.fields} |
| | | setting={group.setting} |
| | | list={card.subcards[0].fields} |
| | | setting={card.subcards[0].setting} |
| | | showField={this.state.showField} |
| | | placeholder={dict['header.form.modal.placeholder']} |
| | | handleList={this.handleList} |
| | | handleForm={this.handleForm} |
| | | closeForm={this.closeForm} |
| | | /> : <MobCardComponent |
| | | list={group.fields} |
| | | setting={group.setting} |
| | | list={card.subcards[0].fields} |
| | | setting={card.subcards[0].setting} |
| | | showField={this.state.showField} |
| | | handleList={this.handleList} |
| | | handleForm={this.handleForm} |
| | | closeForm={this.closeForm} |
| | | />} |
| | | <FormAction config={card} group={group} updateconfig={this.updateGroup}/> |
| | | </div> : null} |
| | | <FormAction config={card} group={card.subcards[0]} updateconfig={this.updateGroup}/> |
| | | </div> |
| | | <div className="component-name"> |
| | | <div className="center"> |
| | | <div className="title">{card.name}</div> |
| | |
| | | } |
| | | } |
| | | |
| | | export default PropCardEditComponent |
| | | export default SimpleFormComponent |