From 88756147643a1d4ffb840797b96ea44462b0551d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 12 七月 2022 17:19:26 +0800
Subject: [PATCH] 2022-07-12
---
src/menu/components/form/simple-form/index.jsx | 309 ++++++++++++++++++---------------------------------
1 files changed, 109 insertions(+), 200 deletions(-)
diff --git a/src/menu/components/form/normal-form/index.jsx b/src/menu/components/form/simple-form/index.jsx
similarity index 73%
copy from src/menu/components/form/normal-form/index.jsx
copy to src/menu/components/form/simple-form/index.jsx
index 43f38bd..d5c0926 100644
--- a/src/menu/components/form/normal-form/index.jsx
+++ b/src/menu/components/form/simple-form/index.jsx
@@ -18,12 +18,12 @@
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'))
@@ -31,7 +31,7 @@
const { confirm } = Modal
-class PropCardEditComponent extends Component {
+class SimpleFormComponent extends Component {
static propTpyes = {
card: PropTypes.object,
deletecomponent: PropTypes.func,
@@ -43,7 +43,6 @@
appType: sessionStorage.getItem('appType'),
card: null,
back: false,
- group: null,
showField: false,
visible: false,
editform: null,
@@ -68,20 +67,18 @@
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'}}
}]
}
@@ -105,15 +102,11 @@
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
})
}
}
@@ -184,9 +177,9 @@
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}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻})
}
})
})
@@ -196,7 +189,7 @@
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}鈥濇棤鏁坄})
}
})
})
@@ -230,18 +223,18 @@
}
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
}
@@ -249,102 +242,33 @@
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)) {
@@ -368,13 +292,6 @@
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() {}
@@ -382,19 +299,11 @@
}
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)
}
@@ -403,23 +312,14 @@
}
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() {}
@@ -428,8 +328,8 @@
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
@@ -453,26 +353,25 @@
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 = []
@@ -487,7 +386,7 @@
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
}
@@ -504,8 +403,7 @@
})
_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
@@ -526,13 +424,14 @@
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++
}
})
@@ -541,9 +440,9 @@
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
}
}
@@ -585,10 +484,10 @@
*/
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
}
@@ -640,7 +539,7 @@
editform: null,
visible: false
})
- this.updateGroup(_config)
+ this.updateComponent(_config)
} else {
this.setState({sqlVerifing: false})
@@ -654,48 +553,44 @@
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
}
@@ -709,9 +604,9 @@
})
return
}
- _config.fields.push(res)
+ _config.subcards[0].fields.push(res)
- this.updateGroup(_config)
+ this.updateComponent(_config)
this.handleForm(res)
@@ -737,7 +632,28 @@
}
}
+ _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) => {
@@ -748,17 +664,17 @@
}
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}/>
@@ -769,17 +685,10 @@
} 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}
@@ -787,23 +696,23 @@
{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>
@@ -842,4 +751,4 @@
}
}
-export default PropCardEditComponent
\ No newline at end of file
+export default SimpleFormComponent
\ No newline at end of file
--
Gitblit v1.8.0