From 8d66ff34fae5b048a6b7923cc75d34f13a08be9d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 02 八月 2022 11:42:43 +0800 Subject: [PATCH] Merge branch 'develop' --- src/menu/components/form/simple-form/index.jsx | 399 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 199 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 67% copy from src/menu/components/form/normal-form/index.jsx copy to src/menu/components/form/simple-form/index.jsx index e10544c..866a334 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', 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'}} + 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'}}, }] } @@ -105,16 +102,11 @@ return scard }) } - this.setState({ - card: _card, - group: _card.subcards[0] || null - }) - this.props.updateConfig(_card) + this.updateComponent(_card) } else { let _card = fromJS(card).toJS() this.setState({ - card: _card, - group: _card.subcards[0] || null + card: _card }) } } @@ -159,15 +151,55 @@ /** * @description 鍗$墖琛屽灞備俊鎭洿鏂帮紙鏁版嵁婧愶紝鏍峰紡绛夛級 */ - updateComponent = (component) => { + updateComponent = (card) => { + card.width = card.wrap.width + card.name = card.wrap.name + card.errors = [] + + if (card.wrap.datatype !== 'static') { + if (card.setting.interType === 'system' && card.setting.execute !== 'false' && !card.setting.dataresource) { + card.errors.push({ level: 0, detail: '鏈缃暟鎹簮锛�'}) + } else if (card.setting.interType === 'system' && card.setting.execute === 'false' && card.scripts.filter(script => script.status !== 'false').length === 0) { + card.errors.push({ level: 0, detail: '鏁版嵁婧愪腑鏃犲彲鐢ㄨ剼鏈紒'}) + } else if (!card.setting.primaryKey) { + card.errors.push({ level: 0, detail: '鏈缃富閿紒'}) + } else if (!card.setting.supModule) { + card.errors.push({ level: 0, detail: '鏈缃笂绾х粍浠讹紒'}) + } + + let supModule = card.setting.supModule ? card.setting.supModule[card.setting.supModule.length - 1] || '' : '' + if (supModule === 'empty') { + supModule = '' + } + let columns = card.columns.map(c => c.field) + let lowcols = card.columns.map(c => c.field.toLowerCase()) + + card.subcards.forEach(item => { + item.fields.forEach(m => { + if (m.type === 'linkMain' && !supModule) { + 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: `琛ㄥ崟鈥�${m.label}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻}) + } + }) + }) + } else { + let supModule = card.wrap.supModule ? card.wrap.supModule[card.wrap.supModule.length - 1] : '' + + card.subcards.forEach(item => { + item.fields.forEach(m => { + if (m.type === 'linkMain' && !supModule) { + card.errors.push({ level: 1, detail: `鍏宠仈涓昏〃琛ㄥ崟鈥�${m.label}鈥濇棤鏁坄}) + } + }) + }) + } + this.setState({ - card: component + card: card }) - component.width = component.wrap.width - component.name = component.wrap.name - - this.props.updateConfig(component) + this.props.updateConfig(card) } /** @@ -181,9 +213,7 @@ return item }) - this.setState({card}) - - this.props.updateConfig(card) + this.updateComponent(card) } changeStyle = () => { @@ -193,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 } @@ -213,107 +243,32 @@ let _card = {...card, style} - this.setState({ - card: _card - }) - - this.props.updateConfig(_card) + 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', 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({ - card, - group: newcard - }) - this.props.updateConfig(card) - } - - changecards = (list) => { - let card = fromJS(this.state.card).toJS() - card.subcards = list.map((item, index) => { - item.sort = index + 1 - return item - }) - - this.setState({card}) - this.props.updateConfig(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({card, group: _group}) - _this.props.updateConfig(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({card, group}) - this.props.updateConfig(card) + 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)) { @@ -337,59 +292,35 @@ confirm({ content: `纭畾鍒囨崲涓�${type}鍒楀悧锛焋, onOk() { - card.subcards = card.subcards.map(item => { - if (item.uuid === config.uuid) { - return config - } - return item - }) - _this.setState({group: config, card}) - _this.props.updateConfig(card) + _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({card, group}, () => { + this.setState({}, () => { if (newcard) { this.handleForm(newcard) } }) - this.props.updateConfig(card) + this.updateComponent(card) } 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({card, group}) - _this.props.updateConfig(card) + _this.updateComponent(card) }, onCancel() {} }) @@ -397,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 @@ -422,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 = [] @@ -456,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 } @@ -473,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 @@ -495,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++ } }) @@ -510,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 } } @@ -554,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 } @@ -592,10 +522,10 @@ LText: res.dataSource } - param.LText = param.LText.replace(/@\$|\$@/ig, '') + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) if (window.GLOB.mainSystemApi && res.database === 'sso') { @@ -609,7 +539,7 @@ editform: null, visible: false }) - this.updateGroup(_config) + this.updateComponent(_config) } else { this.setState({sqlVerifing: false}) @@ -623,16 +553,48 @@ editform: null, visible: false }) - this.updateGroup(_config) + this.updateComponent(_config) } }) } pasteForm = (res) => { - let _config = fromJS(this.state.group).toJS() + let _config = fromJS(this.state.card).toJS() + + if (res.subButton) { + let _this = this + + _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 || '' + + _config.subcards[0].subButton = res.subButton + + _config.subcards[0].fields = res.fields.map(item => { + item.uuid = Utils.getuuid() + return item + }) + + confirm({ + content: `鏇挎崲琛ㄥ崟鍙婃寜閽厤缃紵`, + onOk() { + _this.updateComponent(_config) + }, + onCancel() {} + }) + return + } + 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 } @@ -646,9 +608,9 @@ }) return } - _config.fields.push(res) + _config.subcards[0].fields.push(res) - this.updateGroup(_config) + this.updateComponent(_config) this.handleForm(res) @@ -664,7 +626,38 @@ } updateWrap = (res) => { - this.updateComponent({...this.state.card, wrap: res}) + let _card = {...this.state.card, wrap: res} + + if (res.datatype === 'static') { + if (res.supModule && res.supModule.length > 0) { + _card.setting.supModule = res.supModule + } else { + _card.setting.supModule = '' + } + } + + _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) => { @@ -675,18 +668,18 @@ } 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}/> - <PasteComponent config={card} options={['form']} updateConfig={this.pasteForm} /> + <CopyComponent type="simpleform" card={card}/> + <PasteComponent config={card} options={['form', 'formgroup']} updateConfig={this.pasteForm} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> <UserComponent config={card}/> <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> @@ -696,17 +689,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} @@ -714,24 +700,37 @@ {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} - <div className="component-name"><div className="center">{card.name}</div></div> + <FormAction config={card} group={card.subcards[0]} updateconfig={this.updateGroup}/> + </div> + <div className="component-name"> + <div className="center"> + <div className="title">{card.name}</div> + <div className="content"> + {card.errors && card.errors.map((err, index) => { + if (err.level === 0) { + return <span key={index} className="error">{err.detail}</span> + } else { + return <span key={index} className="waring">{err.detail}锛�</span> + } + })} + </div> + </div> + </div> <Modal title={this.state.dict['model.edit']} visible={this.state.visible} @@ -756,4 +755,4 @@ } } -export default PropCardEditComponent \ No newline at end of file +export default SimpleFormComponent \ No newline at end of file -- Gitblit v1.8.0