From 54d01e6ef9ac31f10de4a0e92824eba50b77eda6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 27 九月 2021 18:40:51 +0800 Subject: [PATCH] 2021-09-27 --- src/tabviews/zshare/topSearch/index.jsx | 21 src/templates/formtabconfig/index.jsx | 12 src/templates/comtableconfig/index.jsx | 25 - src/menu/components/form/normal-form/index.jsx | 20 - src/templates/sharecomponent/fieldscomponent/editcard/index.jsx | 75 +++- src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx | 11 src/templates/sharecomponent/searchcomponent/index.jsx | 32 + src/templates/zshare/editcomponent/index.jsx | 87 ---- src/templates/sharecomponent/fieldscomponent/index.jsx | 320 +++++++------------ src/templates/modalconfig/index.jsx | 42 +- src/templates/sharecomponent/columncomponent/index.jsx | 37 + src/tabviews/zshare/topSearch/index.scss | 8 src/mob/modalconfig/index.jsx | 32 - src/menu/modulesource/option.jsx | 1 src/tabviews/zshare/topSearch/mkInput/index.scss | 0 src/templates/sharecomponent/fieldscomponent/editcard/index.scss | 7 src/templates/zshare/formconfig.jsx | 2 src/menu/components/form/tab-form/index.jsx | 20 - src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx | 16 + src/templates/calendarconfig/index.jsx | 8 src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx | 4 src/templates/subtableconfig/index.jsx | 26 - src/menu/components/search/main-search/index.jsx | 30 + src/templates/sharecomponent/actioncomponent/index.jsx | 34 +- src/menu/modalconfig/index.jsx | 36 +- src/tabviews/zshare/topSearch/advanceform/index.jsx | 7 src/tabviews/zshare/topSearch/mkInput/index.jsx | 18 + src/templates/sharecomponent/searchcomponent/index.scss | 7 src/templates/sharecomponent/searchcomponent/searchform/index.jsx | 2 29 files changed, 430 insertions(+), 510 deletions(-) diff --git a/src/menu/components/form/normal-form/index.jsx b/src/menu/components/form/normal-form/index.jsx index 4444f91..bedbe6c 100644 --- a/src/menu/components/form/normal-form/index.jsx +++ b/src/menu/components/form/normal-form/index.jsx @@ -504,13 +504,10 @@ this.formRef.handleConfirm().then(res => { let _config = fromJS(this.state.group).toJS() let fieldrepet = false // 瀛楁閲嶅 - let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 _config.fields = _config.fields.map(item => { if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { fieldrepet = true - } else if (res.label && item.uuid !== res.uuid && item.label === res.label) { - labelrepet = true } if (item.uuid === res.uuid) { @@ -524,13 +521,6 @@ notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', - duration: 10 - }) - return - } else if (labelrepet) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', duration: 10 }) return @@ -586,13 +576,10 @@ pasteForm = (res) => { let _config = fromJS(this.state.group).toJS() let fieldrepet = false // 瀛楁閲嶅 - let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 _config.fields.forEach(item => { if (res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { fieldrepet = true - } else if (res.label && item.label === res.label) { - labelrepet = true } }) @@ -600,13 +587,6 @@ notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', - duration: 10 - }) - return - } else if (labelrepet) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', duration: 10 }) return diff --git a/src/menu/components/form/tab-form/index.jsx b/src/menu/components/form/tab-form/index.jsx index f1fc543..e4fb94e 100644 --- a/src/menu/components/form/tab-form/index.jsx +++ b/src/menu/components/form/tab-form/index.jsx @@ -496,13 +496,10 @@ this.formRef.handleConfirm().then(res => { let _config = fromJS(this.state.group).toJS() let fieldrepet = false // 瀛楁閲嶅 - let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 _config.fields = _config.fields.map(item => { if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { fieldrepet = true - } else if (res.label && item.uuid !== res.uuid && item.label === res.label) { - labelrepet = true } if (item.uuid === res.uuid) { @@ -516,13 +513,6 @@ notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', - duration: 10 - }) - return - } else if (labelrepet) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', duration: 10 }) return @@ -578,13 +568,10 @@ pasteForm = (res) => { let _config = fromJS(this.state.group).toJS() let fieldrepet = false // 瀛楁閲嶅 - let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 _config.fields.forEach(item => { if (res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { fieldrepet = true - } else if (res.label && item.label === res.label) { - labelrepet = true } }) @@ -592,13 +579,6 @@ notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', - duration: 10 - }) - return - } else if (labelrepet) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', duration: 10 }) return diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx index 92fce35..79505bb 100644 --- a/src/menu/components/search/main-search/index.jsx +++ b/src/menu/components/search/main-search/index.jsx @@ -76,6 +76,7 @@ componentDidMount () { MKEmitter.addListener('submitStyle', this.getStyle) + MKEmitter.addListener('plusSearch', this.plusSearch) } /** @@ -86,6 +87,7 @@ return } MKEmitter.removeListener('submitStyle', this.getStyle) + MKEmitter.removeListener('plusSearch', this.plusSearch) } shouldComponentUpdate (nextProps, nextState) { @@ -365,10 +367,28 @@ }) } - updatefields = (config) => { - this.setState({card: config}, ()=> { - this.props.updateConfig(config) - }) + plusSearch = (MenuId, item, type) => { + const { card } = this.state + + if (MenuId !== card.uuid) return + + let _card = fromJS(card).toJS() + + if (type === 'simple') { + _card.search.push(item) + this.setState({ + card: _card, + }, () => { + this.props.updateConfig(_card) + }) + } else if (type === 'multil') { + _card.search.push(...item) + this.setState({ + card: _card, + }, () => { + this.props.updateConfig(_card) + }) + } } getWrapForms = () => { @@ -394,7 +414,7 @@ return ( <div className={`main-search-edit-list ${card.wrap.float} ${card.wrap.show || ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}> - <FieldsComponent config={card} type="search" updatefield={this.updatefields} /> + <FieldsComponent config={card} type="search" /> <Switch checkedChildren={dict['model.switch.open']} size="small" unCheckedChildren={dict['model.switch.close']} defaultChecked={showField} onChange={this.onFieldChange} /> <DragElement list={card.search} diff --git a/src/menu/modalconfig/index.jsx b/src/menu/modalconfig/index.jsx index fa87b7f..bead002 100644 --- a/src/menu/modalconfig/index.jsx +++ b/src/menu/modalconfig/index.jsx @@ -191,13 +191,10 @@ this.formRef.handleConfirm().then(res => { let _config = fromJS(this.state.config).toJS() let fieldrepet = false // 瀛楁閲嶅 - let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 _config.fields = _config.fields.map(item => { if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { fieldrepet = true - } else if (res.label && item.uuid !== res.uuid && item.label === res.label) { - labelrepet = true } if (item.uuid === res.uuid) { @@ -211,13 +208,6 @@ notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', - duration: 10 - }) - return - } else if (labelrepet) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', duration: 10 }) return @@ -422,6 +412,24 @@ }) } + plusFields = (items) => { + let _config = fromJS(this.state.config).toJS() + + if (_config.fields[0] && _config.fields[0].origin) { + _config.fields = _config.fields.filter(item => !item.origin) + } + + _config.fields.push(...items) + + this.setState({ + config: _config + }, () => { + if (items.length === 1 && items[0].focus) { + this.handleForm(items[0]) + } + }) + } + render () { const { config, dict, saving } = this.state @@ -436,11 +444,7 @@ return (<SourceElement key={index} content={item}/>) })} </div> - <FieldsComponent - config={config} - type="form" - updatefield={this.updateConfig} - /> + <FieldsComponent config={config} type="form" plusFields={this.plusFields}/> </Panel> </Collapse> </div> @@ -448,7 +452,7 @@ <Card title={dict['header.menu.form.configurable']} bordered={false} extra={ <div> <Button type="danger" onClick={this.clearConfig}>娓呯┖</Button> - <EditComponent dict={dict} options={['form']} config={this.state.config} refresh={(res) => this.updateConfig(res.config)}/> + <EditComponent dict={dict} options={['form']} config={this.state.config} plusFields={this.plusFields}/> <Button type="primary" loading={saving} onClick={this.submitConfig}>淇濆瓨</Button> <Button onClick={this.cancelConfig}>杩斿洖</Button> </div> diff --git a/src/menu/modulesource/option.jsx b/src/menu/modulesource/option.jsx index 3149553..dfdb100 100644 --- a/src/menu/modulesource/option.jsx +++ b/src/menu/modulesource/option.jsx @@ -36,6 +36,7 @@ { type: 'menu', url: Carousel, component: 'carousel', subtype: 'datacard', title: '杞挱-鍔ㄦ�佹暟鎹�', width: 24, forbid: ['billPrint'] }, { type: 'menu', url: Carousel1, component: 'carousel', subtype: 'propcard', title: '杞挱-闈欐�佹暟鎹�', width: 24, forbid: ['billPrint'] }, { type: 'menu', url: NormalTable, component: 'table', subtype: 'normaltable', title: '甯哥敤琛�', width: 24 }, + // { type: 'menu', url: NormalTable, component: 'table', subtype: 'normaltable', title: '甯哥敤琛�', width: 24 }, { type: 'menu', url: TableCard, component: 'table', subtype: 'tablecard', title: '琛ㄦ牸锛堝崱鐗囷級', width: 12 }, { type: 'menu', url: tree, component: 'tree', subtype: 'normaltree', title: '鏍戝舰鍒楄〃', width: 12 }, { type: 'menu', url: line, component: 'line', subtype: 'line', title: '鎶樼嚎鍥�', width: 24 }, diff --git a/src/mob/modalconfig/index.jsx b/src/mob/modalconfig/index.jsx index 29c8e42..23be59f 100644 --- a/src/mob/modalconfig/index.jsx +++ b/src/mob/modalconfig/index.jsx @@ -91,8 +91,6 @@ let _config = fromJS(this.state.config).toJS() if (list.length > _config.fields.length) { - _config.fields = list.filter(item => !item.origin) - this.setState({ config: _config }, () => { @@ -195,13 +193,10 @@ this.formRef.handleConfirm().then(res => { let _config = fromJS(this.state.config).toJS() let fieldrepet = false // 瀛楁閲嶅 - let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 _config.fields = _config.fields.map(item => { if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { fieldrepet = true - } else if (res.label && item.uuid !== res.uuid && item.label === res.label) { - labelrepet = true } if (item.uuid === res.uuid) { @@ -218,16 +213,7 @@ duration: 10 }) return - } else if (labelrepet) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', - duration: 10 - }) - return } - - _config.fields = _config.fields.filter(item => !item.origin) if (['select', 'multiselect', 'link', 'checkbox', 'radio', 'checkcard'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) { this.setState({ @@ -369,9 +355,17 @@ /** * @description 鏇存柊 */ - updateConfig = (config) => { + plusFields = (items) => { + let _config = fromJS(this.state.config).toJS() + + _config.fields.push(...items) + this.setState({ - config + config: _config + }, () => { + if (items.length === 1 && items[0].focus) { + this.handleForm(items[0]) + } }) } @@ -397,11 +391,7 @@ return (<SourceElement key={index} content={item}/>) })} </div> - <FieldsComponent - config={config} - type="form" - updatefield={this.updateConfig} - /> + <FieldsComponent config={config} type="form" plusFields={this.plusFields}/> </Panel> </Collapse> </div> diff --git a/src/tabviews/zshare/topSearch/advanceform/index.jsx b/src/tabviews/zshare/topSearch/advanceform/index.jsx index 9a9f6d9..d5c4c88 100644 --- a/src/tabviews/zshare/topSearch/advanceform/index.jsx +++ b/src/tabviews/zshare/topSearch/advanceform/index.jsx @@ -6,7 +6,6 @@ import asyncComponent from '@/utils/asyncComponent' import './index.scss' -const { Search } = Input const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/checkCard')) const MKSelect = asyncComponent(() => import('../mkSelect')) const MKDatePicker = asyncComponent(() => import('../mkDatePicker')) @@ -42,11 +41,7 @@ item.initval = record[item.field] || '' if (item.type === 'text') { - if (item.inputType === 'search') { - content = <Search allowClear placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onSearch={this.handleSubmit} enterButton/> - } else { - content = <Input allowClear placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onPressEnter={this.handleSubmit} /> - } + content = <Input allowClear placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onPressEnter={this.handleSubmit} /> } else if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') { content = (<MKSelect config={item}/>) } else if (item.type === 'date' || item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') { diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index defee38..c2a3416 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Button, notification, Modal, Icon } from 'antd' +import { is, fromJS } from 'immutable' +import { Form, Row, Col, Button, notification, Modal, Icon } from 'antd' import moment from 'moment' import Api from '@/api' @@ -11,9 +11,8 @@ import Utils from '@/utils/utils.js' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' +import MKInput from './mkInput' import './index.scss' - -const { Search } = Input const MutilForm = asyncSpinComponent(() => import('./advanceform')) const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/checkCard')) @@ -201,6 +200,10 @@ this.improveSearch(mainItems, localItems) } }) + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) } // 鏌ヨ涓嬫媺鑿滃崟 @@ -446,15 +449,12 @@ ] let content = null + let className = '' let field = item.field lastRadio = item.ratio || 6 if (item.type === 'text') { - if (item.inputType === 'search') { - content = <Search allowClear placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onSearch={this.handleSubmit} enterButton/> - } else { - content = <Input allowClear placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onPressEnter={this.handleSubmit} /> - } + content = (<MKInput config={item} onInputSubmit={this.handleSubmit} />) } else if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') { content = (<MKSelect config={item} onChange={(val, defer) => this.recordChange(val, defer, item)} />) } else if (item.type === 'date' || item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') { @@ -463,13 +463,14 @@ field = item.datefield content = <DateGroup position={index} config={item} onChange={(val, type) => this.dateGroupChange(val, type, item)} /> } else if (item.type === 'checkcard') { + className = 'checkcard' content = <MKCheckCard card={item} onChange={this.handleSubmit} /> } if (content) { fields.push( <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> + <Form.Item className={className} label={item.labelShow !== 'false' ? item.label : ''}> {getFieldDecorator(field, { initialValue: item.initval, rules: _rules diff --git a/src/tabviews/zshare/topSearch/index.scss b/src/tabviews/zshare/topSearch/index.scss index 5cfa7c7..18fe436 100644 --- a/src/tabviews/zshare/topSearch/index.scss +++ b/src/tabviews/zshare/topSearch/index.scss @@ -8,6 +8,11 @@ white-space: nowrap; } } + .ant-form-item.checkcard { + .ant-form-item-control { + line-height: 1; + } + } .ant-form-item-control-wrapper { flex: 1; width: calc(100% - 100px); @@ -86,6 +91,9 @@ opacity: 0; } } + .check-card-search-box { + margin-top: 3px; + } } .top-search.right { >.ant-row { diff --git a/src/tabviews/zshare/topSearch/mkInput/index.jsx b/src/tabviews/zshare/topSearch/mkInput/index.jsx new file mode 100644 index 0000000..4ccb57e --- /dev/null +++ b/src/tabviews/zshare/topSearch/mkInput/index.jsx @@ -0,0 +1,18 @@ +import React, {Component} from 'react' +import { Input } from 'antd' + +const { Search } = Input + +class MKSearchInput extends Component { + render() { + const { config, onChange, onInputSubmit } = this.props + + if (config.inputType === 'search') { + return <Search defaultValue={config.initval} allowClear placeholder={config.labelShow === 'false' ? config.label : ''} autoComplete="off" onChange={onChange} onSearch={onInputSubmit} enterButton/> + } else { + return <Input defaultValue={config.initval} allowClear placeholder={config.labelShow === 'false' ? config.label : ''} autoComplete="off" onChange={onChange} onPressEnter={onInputSubmit} /> + } + } +} + +export default MKSearchInput \ No newline at end of file diff --git a/src/tabviews/zshare/topSearch/mkInput/index.scss b/src/tabviews/zshare/topSearch/mkInput/index.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/tabviews/zshare/topSearch/mkInput/index.scss diff --git a/src/templates/calendarconfig/index.jsx b/src/templates/calendarconfig/index.jsx index 10dec96..498affe 100644 --- a/src/templates/calendarconfig/index.jsx +++ b/src/templates/calendarconfig/index.jsx @@ -755,11 +755,7 @@ return (<SourceElement key={index} content={item}/>) })} </div> - <FieldsComponent - config={config} - type="search" - updatefield={this.updateconfig} - /> + <FieldsComponent config={config} type="search" /> </Panel> </Collapse> </div> @@ -771,7 +767,7 @@ </div> } bordered={false} extra={ <div> - <EditComponent dict={this.state.dict} options={['search']} config={this.state.config} refresh={this.updateConfig}/> + <EditComponent dict={this.state.dict} options={['search']} config={this.state.config}/> <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button> <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index b3cc118..2056c7e 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -91,6 +91,7 @@ _config.MenuNo = menu.MenuNo || '' _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : '' _config.easyCode = _config.easyCode || '' + _config.uuid = menu.MenuID || '' // 鐗堟湰鍏煎 _config = updateCommonTable(_config) @@ -1034,14 +1035,10 @@ * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑 */ editConfig = (res) => { - if (res.type === 'thaw') { - this.setState({ - thawButtons: res.thawButtons, - config: res.config - }) - } else if (res.type === 'paste') { - this.setState({config: res.config}) - } + this.setState({ + thawButtons: res.thawButtons, + config: res.config + }) } /** @@ -1190,11 +1187,7 @@ <div className="search-element"> {Source.searchItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> - <FieldsComponent - config={config} - type="search" - updatefield={this.updateconfig} - /> + <FieldsComponent config={config} type="search" /> </Panel> {/* 鎸夐挳娣诲姞 */} <Panel header={this.state.dict['header.menu.action']} key="2"> @@ -1229,11 +1222,7 @@ <div className="search-element"> {Source.columnItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> - <FieldsComponent - config={config} - type="columns" - updatefield={this.updateconfig} - /> + <FieldsComponent config={config} type="columns"/> </Panel> {/* 娣诲姞鏍囩 */} <Panel header={this.state.dict['header.menu.tab']} key="4"> diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 8b38bc5..ae594a5 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -537,7 +537,6 @@ let _groups = null let fieldrepet = false // 瀛楁閲嶅 - let labelrepeat = false // 鎻愮ず鏂囧瓧閲嶅 if (card.iscopy) { _groups = _config.groups.map(group => { @@ -549,8 +548,6 @@ if (item.uuid !== res.uuid && item.field === res.field) { fieldrepet = true - } else if (item.uuid !== res.uuid && item.label === res.label) { - labelrepeat = true } }) @@ -568,8 +565,6 @@ group.sublist = group.sublist.map(item => { if (item.uuid !== res.uuid && item.field === res.field) { fieldrepet = true - } else if (item.uuid !== res.uuid && item.label === res.label) { - labelrepeat = true } if (item.uuid === res.uuid) { @@ -589,13 +584,6 @@ notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', - duration: 5 - }) - return - } else if (labelrepeat) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', duration: 5 }) return diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 8e0e44a..096eb2c 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -297,13 +297,10 @@ this.formRef.handleConfirm().then(res => { let _config = fromJS(this.state.config).toJS() let fieldrepet = false // 瀛楁閲嶅 - let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 _config.fields = _config.fields.map(item => { if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { fieldrepet = true - } else if (res.label && item.uuid !== res.uuid && item.label === res.label) { - labelrepet = true } if (item.uuid === res.uuid) { @@ -317,13 +314,6 @@ notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', - duration: 10 - }) - return - } else if (labelrepet) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', duration: 10 }) return @@ -547,18 +537,6 @@ } /** - * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑 - */ - updateEditConfig = (res) => { - if (res.type === 'paste') { - this.setState({ - config: res.config - }) - this.handleForm(res.newform) - } - } - - /** * @description 鏇存柊閰嶇疆淇℃伅 */ updateconfig = (config) => { @@ -652,6 +630,24 @@ }) } + plusFields = (items) => { + let _config = fromJS(this.state.config).toJS() + + if (_config.fields[0] && _config.fields[0].origin) { + _config.fields = _config.fields.filter(item => !item.origin) + } + + _config.fields.push(...items) + + this.setState({ + config: _config + }, () => { + if (items.length === 1 && items[0].focus) { + this.handleForm(items[0]) + } + }) + } + render () { const { editAction } = this.props const { config, dict, openEdition } = this.state @@ -694,7 +690,7 @@ <div> <Versions MenuId={editAction.uuid} open_edition={openEdition} updateConfig={this.refreshConfig}/> <ReplaceField type="form" config={config} updateConfig={this.updateconfig}/> - <EditComponent dict={dict} options={['form']} config={this.state.config} refresh={this.updateEditConfig}/> + <EditComponent dict={dict} options={['form']} config={this.state.config} plusFields={this.plusFields}/> <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{dict['model.save']}</Button> <Button onClick={this.cancelConfig}>{dict['model.back']}</Button> </div> diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx index 2a76df0..3d27967 100644 --- a/src/templates/sharecomponent/actioncomponent/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/index.jsx @@ -16,6 +16,7 @@ import CreateInterface from '@/templates/zshare/createinterface' import { updateForm } from '@/utils/utils-update.js' import DragElement from './dragaction' +import MKEmitter from '@/utils/events.js' import './index.scss' const { confirm } = Modal @@ -54,24 +55,22 @@ }) } - /** - * @description 鐩戝惉鍒版寜閽鍒舵椂锛岃Е鍙戞寜閽紪杈� - */ - UNSAFE_componentWillReceiveProps (nextProps) { - const { actionlist } = this.state - - if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) { - let len = nextProps.config.action.length - let item = nextProps.config.action[len - 1] - if (item && item.focus) { - this.handleAction(item) - } - this.setState({actionlist: fromJS(nextProps.config.action).toJS()}) - } - } - componentDidMount () { this.getBillPrintTemp() + MKEmitter.addListener('pasteButton', this.pasteButton) + } + + pasteButton = (MenuId, btn) => { + const { config } = this.props + const { actionlist } = this.state + + if (MenuId !== config.uuid) return + + this.setState({ + actionlist: [...actionlist, btn], + }, () => { + this.handleAction(btn) + }) } getBillPrintTemp = () => { @@ -835,7 +834,7 @@ } shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS(this.state), fromJS(nextState)) } /** @@ -845,6 +844,7 @@ this.setState = () => { return } + MKEmitter.removeListener('pasteButton', this.pasteButton) } render() { diff --git a/src/templates/sharecomponent/columncomponent/index.jsx b/src/templates/sharecomponent/columncomponent/index.jsx index 50d7df2..63a0a8d 100644 --- a/src/templates/sharecomponent/columncomponent/index.jsx +++ b/src/templates/sharecomponent/columncomponent/index.jsx @@ -12,6 +12,7 @@ import GridBtnForm from './gridbtnform' import DragElement from './dragcolumn' import MarkColumn from './markcolumn' +import MKEmitter from '@/utils/events.js' import './index.scss' const { confirm } = Modal @@ -38,18 +39,6 @@ this.setState({ columnlist: fromJS(this.props.config.columns).toJS() }) - } - - /** - * @description 鐩戝惉鍒版樉绀哄垪澶嶅埗鏃讹紝瑙﹀彂鏄剧ず鍒楃紪杈� - */ - UNSAFE_componentWillReceiveProps (nextProps) { - const { config } = this.props - const { columnlist } = this.state - - if (!is(fromJS(nextProps.config.columns), fromJS(config.columns)) && !is(fromJS(nextProps.config.columns), fromJS(columnlist))) { - this.setState({columnlist: fromJS(nextProps.config.columns).toJS()}) - } } /** @@ -460,8 +449,31 @@ }) } + plusColumns = (MenuId, items) => { + const { config } = this.props + const { columnlist } = this.state + + if (MenuId !== config.uuid) return + + let list = [...columnlist, ...items] + + if (list[0] && list[0].origin) { + list = list.filter(col => !col.origin) + } + + this.setState({ + columnlist: list + }, () => { + this.props.updatecolumn({...config, columns: list}) + }) + } + shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + MKEmitter.addListener('plusColumns', this.plusColumns) } /** @@ -471,6 +483,7 @@ this.setState = () => { return } + MKEmitter.removeListener('plusColumns', this.plusColumns) } render() { diff --git a/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx b/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx index 2d89188..8f97ec6 100644 --- a/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx +++ b/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx @@ -1,4 +1,5 @@ import React, {Component} from 'react' +import { is, fromJS } from 'immutable' import { Row, Col, Icon, Radio, Input, Button } from 'antd' import './index.scss' @@ -29,8 +30,21 @@ } } + UNSAFE_componentWillReceiveProps (nextProps) { + const { card } = this.state + + if (nextProps.card.origin !== card.origin) { + this.setState({ + card: {...card, origin: nextProps.card.origin} + }) + } + } + changeSelect = () => { const { card } = this.state + + if (card.origin) return + this.setState({ card: {...card, selected: !card.selected} }, () => { @@ -40,38 +54,41 @@ changeType = (e) => { const { card } = this.state + + if (card.origin) return + this.setState({ card: {...card, type: e.target.value} }, () => { - this.props.changeCard(this.state.card) + this.props.changeCard(this.state.card, 'update') }) } render() { const { card, type } = this.state return ( - <div className={'ant-card ant-card-bordered ' + (card.selected ? 'selected' : '')} > + <div className={'ant-card ant-card-bordered ' + (card.selected ? 'selected' : '') + (card.origin ? ' fixed' : '')} > <div className="base" onClick={this.changeSelect}> <Icon type="check" /> - <p title={card.field}>{this.props.dict['model.form.field']}锛� <span>{card.field}</span></p> - <p title={card.label}>{this.props.dict['model.name']}锛� <span>{card.label}</span></p> + <p title={card.field}>瀛楁锛� <span>{card.field}</span></p> + <p title={card.label}>鍚嶇О锛� <span>{card.label}</span></p> </div> {type === 'search' ? - <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected}> + <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected || card.origin}> <Radio value="text">text</Radio> <Radio value="select">select</Radio> <Radio value="daterange">dateRange</Radio> </Radio.Group> : null } {type === 'columns' ? - <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected}> + <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected || card.origin}> <Radio value="text">text</Radio> <Radio value="number">number</Radio> <Radio value="picture">picture</Radio> </Radio.Group> : null } {type === 'form' ? - <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected}> + <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected || card.origin}> <Radio value="text">text</Radio> <Radio value="number">number</Radio> <Radio value="select">select</Radio> @@ -88,18 +105,31 @@ super(props) this.state = { - dataSource: props.data, - selectCards: props.data.filter(item => item.selected), + selectCards: [], type: props.type, searchKey: '', - loading: false } } - changeCard = (item) => { + UNSAFE_componentWillReceiveProps (nextProps) { + const { data } = this.props + + if (!is(fromJS(nextProps.data), fromJS(data))) { + this.setState({selectCards: []}) + } + } + + changeCard = (item, m) => { let cards = JSON.parse(JSON.stringify(this.state.selectCards)) - if (!item.selected) { + if (m === 'update') { + cards = cards.map(card => { + if (card.field === item.field) { + return item + } + return card + }) + } else if (!item.selected) { cards = cards.filter(card => card.field !== item.field) } else { cards.push(item) @@ -107,42 +137,37 @@ this.setState({ selectCards: cards + }, () => { + this.props.onChange(cards) }) } reset = () => { this.setState({ searchKey: '', - loading: true - }, () => { - this.setState({ - loading: false - }) }) } render() { - const { dict } = this.props - const { dataSource, type, loading } = this.state + const { data } = this.props + const { type } = this.state return ( <div className="common-modal-edit-card"> <Row className="search-row"> <Col span={8}> - {!loading ? <Search placeholder={dict['form.required.input'] + dict['model.form.field']} onSearch={value => {this.setState({searchKey: value})}} enterButton /> : null} + <Search placeholder="璇疯緭鍏ュ瓧娈�" onSearch={value => {this.setState({searchKey: value})}} enterButton /> </Col> <Col span={8}> - <Button onClick={this.reset}> - {this.props.dict['header.reset']} - </Button> + <Button onClick={this.reset}>閲嶇疆</Button> </Col> </Row> <Row> - {dataSource.map((item, index) => { + {data.map((item, index) => { if (item.field.toLowerCase().indexOf(this.state.searchKey.toLowerCase()) >= 0 || item.label.indexOf(this.state.searchKey) >= 0) { return ( <Col key={index} span={8}> - <EditCardCell ref={'cellCard' + index} type={type} card={item} dict={this.props.dict} changeCard={this.changeCard} /> + <EditCardCell type={type} card={item} changeCard={this.changeCard} /> </Col> ) } else { diff --git a/src/templates/sharecomponent/fieldscomponent/editcard/index.scss b/src/templates/sharecomponent/fieldscomponent/editcard/index.scss index a504e4a..8cb4172 100644 --- a/src/templates/sharecomponent/fieldscomponent/editcard/index.scss +++ b/src/templates/sharecomponent/fieldscomponent/editcard/index.scss @@ -29,7 +29,7 @@ cursor: pointer; } } - .ant-card.selected { + .ant-card.selected, .ant-card.fixed { border-color: #1890ff; box-shadow: 0px 0px 4px #1890ff; .anticon { @@ -40,6 +40,11 @@ color: #1890ff; } } + .ant-card.fixed { + .base { + cursor: default; + } + } } .search-row { .ant-col { diff --git a/src/templates/sharecomponent/fieldscomponent/index.jsx b/src/templates/sharecomponent/fieldscomponent/index.jsx index 137071c..8ae766f 100644 --- a/src/templates/sharecomponent/fieldscomponent/index.jsx +++ b/src/templates/sharecomponent/fieldscomponent/index.jsx @@ -8,6 +8,7 @@ import enUS from '@/locales/en-US/model.js' import EditCard from './editcard' +import MKEmitter from '@/utils/events.js' import './index.scss' class FieldsComponent extends Component { @@ -20,8 +21,9 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, appType: sessionStorage.getItem('appType'), - fields: [], // 瀛楁闆� - tableVisible: false, // 妯℃�佹鎺у埗 + fields: [], // 瀛楁闆� + visible: false, // 妯℃�佹鎺у埗 + selectCards: [] } queryField = () => { @@ -49,7 +51,7 @@ config.search.forEach(item => { if (columns.has(item.field.toLowerCase())) { let _datatype = columns.get(item.field.toLowerCase()).datatype - columns.set(item.field.toLowerCase(), {...item, selected: true, datatype: _datatype}) + columns.set(item.field.toLowerCase(), {...item, origin: true, datatype: _datatype}) } }) } else if (type === 'columns') { @@ -57,248 +59,171 @@ config.columns.forEach(item => { if (item.field && columns.has(item.field.toLowerCase())) { let _datatype = columns.get(item.field.toLowerCase()).datatype - columns.set(item.field.toLowerCase(), {...item, selected: true, datatype: _datatype}) + columns.set(item.field.toLowerCase(), {...item, origin: true, datatype: _datatype}) } }) } else if (type === 'fields') { config.columns.forEach(item => { if (columns.has(item.field.toLowerCase())) { let _datatype = columns.get(item.field.toLowerCase()).datatype - columns.set(item.field.toLowerCase(), {...item, selected: true, datatype: _datatype}) + columns.set(item.field.toLowerCase(), {...item, origin: true, datatype: _datatype}) } }) } else if (type === 'form') { config.fields.forEach(item => { if (item.field && columns.has(item.field.toLowerCase())) { let _datatype = columns.get(item.field.toLowerCase()).datatype - columns.set(item.field.toLowerCase(), {...item, selected: true, datatype: _datatype}) + columns.set(item.field.toLowerCase(), {...item, origin: true, datatype: _datatype}) } }) } // 鏄剧ず瀛楁闆嗗脊绐� this.setState({ - tableVisible: true, + visible: true, + selectCards: [], fields: [...columns.values()] }) } addFieldSubmit = () => { const { type } = this.props + const { selectCards, fields } = this.state // 瀛楁闆嗕负绌猴紝鍏抽棴寮圭獥 - if (!this.state.fields || this.state.fields.length === 0) { - this.setState({ - tableVisible: false - }) + if (!fields || fields.length === 0) { + this.setState({ visible: false }) } let config = fromJS(this.props.config).toJS() // 鑾峰彇宸查�夊瓧娈甸泦鍚� - let cards = this.refs.searchcard.state.selectCards + let cards = selectCards let columnsMap = new Map() cards.forEach(card => { columnsMap.set(card.field.toLowerCase(), card) }) let items = [] + let keys = [] if (type === 'search') { - config.search.forEach(item => { - if (columnsMap.has(item.field.toLowerCase())) { - let cell = columnsMap.get(item.field.toLowerCase()) - - if (cell.selected && cell.type === item.type) { // 鏁版嵁鏈慨鏀� - items.push(item) - } else if (cell.selected) { // 鏁版嵁绫诲瀷淇敼 - item.initval = '' - if (cell.type === 'select') { - item.match = '=' - } else if (cell.type === 'daterange') { - item.initval = '[30, 0]' - item.match = 'between' - } else { - cell.type = 'text' - item.match = 'like' - } - - item.type = cell.type - items.push(item) - } - columnsMap.delete(item.field.toLowerCase()) - } else if (!item.origin) { - items.push(item) - } - }) - - let _columns = [...columnsMap.values()] - - _columns.forEach(item => { - if (item.selected) { - let _match = '' - if (item.type === 'select') { - _match = '=' - } else if (item.type === 'daterange') { - _match = 'between' - } else { - item.type = 'text' - _match = 'like' - } - - let newcard = { - uuid: Utils.getuuid(), - label: item.label, - field: item.field, - initval: '', - type: item.type, - resourceType: '0', - setAll: 'false', - options: [], - orderType: 'asc', - match: _match, - display: 'dropdown' - } - - items.push(newcard) - } - }) - config.search = items - } else if (type === 'columns') { - config.columns.forEach(item => { - if (item.field && columnsMap.has(item.field.toLowerCase())) { - let cell = columnsMap.get(item.field.toLowerCase()) - - if (cell.selected) { - items.push(item) - } - columnsMap.delete(item.field.toLowerCase()) - } else if (!item.origin) { - items.push(item) - } - }) - - let _columns = [...columnsMap.values()] - - _columns.forEach(item => { - if (item.selected) { - let newcard = { - uuid: Utils.getuuid(), - Align: 'left', - label: item.label, - field: item.field, - Hide: 'false', - IsSort: item.type === 'picture' ? 'false' : 'true', - type: item.type, - Width: 120 - } - - if (item.type === 'number') { - newcard.decimal = item.decimal - } else { - newcard.fieldlength = item.length || 50 - } - - items.push(newcard) - } - }) - config.columns = items - } else if (type === 'fields') { - config.columns.forEach(item => { - if (columnsMap.has(item.field.toLowerCase())) { - let cell = columnsMap.get(item.field.toLowerCase()) - - if (cell.selected) { - items.push(item) - } - columnsMap.delete(item.field.toLowerCase()) + selectCards.forEach(item => { + let _match = '' + let initval = '' + if (item.type === 'select') { + _match = '=' + } else if (item.type === 'daterange') { + initval = '[30, 0]' + _match = 'between' } else { - items.push(item) + item.type = 'text' + _match = 'like' } + + let newcard = { + uuid: Utils.getuuid(), + label: item.label, + field: item.field, + initval: initval, + type: item.type, + resourceType: '0', + setAll: 'false', + options: [], + orderType: 'asc', + match: _match, + display: 'dropdown' + } + + items.push(newcard) + keys.push(item.field.toLowerCase()) }) + MKEmitter.emit('plusSearch', config.uuid, items, 'multil') + } else if (type === 'columns') { + selectCards.forEach(item => { + let newcard = { + uuid: Utils.getuuid(), + Align: 'left', + label: item.label, + field: item.field, + Hide: 'false', + IsSort: item.type === 'picture' ? 'false' : 'true', + type: item.type, + Width: 120 + } - let _columns = [...columnsMap.values()] + if (item.type === 'number') { + newcard.decimal = item.decimal + } else { + newcard.fieldlength = item.length || 50 + } - _columns.forEach(item => { + items.push(newcard) + keys.push(item.field.toLowerCase()) + }) + MKEmitter.emit('plusColumns', config.uuid, items) + } else if (type === 'fields') { + items = [...config.columns] + + selectCards.forEach(item => { let _t = item.$datatype || (item.type === 'number' ? 'Decimal(18,0)' : 'Nvarchar(50)') - if (item.selected) { - let newcard = { - uuid: Utils.getuuid(), - label: item.label, - field: item.field, - datatype: _t - } + let newcard = { + uuid: Utils.getuuid(), + label: item.label, + field: item.field, + datatype: _t + } + items.push(newcard) + keys.push(item.field.toLowerCase()) + }) - items.push(newcard) - } - }) + this.props.updatefield(items) } else if (type === 'form') { - config.fields.forEach(item => { - if (item.field && columnsMap.has(item.field.toLowerCase())) { - let cell = columnsMap.get(item.field.toLowerCase()) - - if (cell.selected && cell.type === item.type) { // 鏁版嵁閫夋嫨鐘舵�佸強绫诲瀷鏈慨鏀规椂锛岀洿鎺ユ坊鍔� - items.push(item) - } else if (cell.selected) { // 鏁版嵁绫诲瀷淇敼鏃讹紝閲嶇疆绫诲瀷鍙婂垵濮嬪�� - item.type = cell.type - item.initval = '' - items.push(item) - } - columnsMap.delete(item.field.toLowerCase()) - } else if (!item.origin) { // 杩囨护绀轰緥椤� - items.push(item) - } - }) - - let _columns = [...columnsMap.values()] let lastItem = config.fields[config.fields.length - 1] let span = this.state.appType === 'mob' ? 24 : 12 if (lastItem && lastItem.span) { span = lastItem.span } - _columns.forEach(item => { // 寰幆娣诲姞鏂板瀛楁 - if (item.selected) { - let newcard = { - uuid: Utils.getuuid(), - label: item.label, - field: item.field, - initval: '', - type: item.type, - resourceType: '0', - setAll: 'false', - span: span, - labelwidth: 33.3, - options: [], - dataSource: '', - decimal: item.decimal, - orderType: 'asc', - readonly: 'false', - required: 'true' - } - - items.push(newcard) + selectCards.forEach(item => { // 寰幆娣诲姞鏂板瀛楁 + let newcard = { + uuid: Utils.getuuid(), + label: item.label, + field: item.field, + initval: '', + type: item.type, + resourceType: '0', + setAll: 'false', + span: span, + labelwidth: 33.3, + options: [], + dataSource: '', + decimal: item.decimal, + orderType: 'asc', + readonly: 'false', + required: 'true' } + + items.push(newcard) + keys.push(item.field.toLowerCase()) }) - - config.fields = items + + this.props.plusFields(items) } - if (type === 'search' || type === 'columns' || type === 'form') { - this.props.updatefield(config) - - notification.success({ - top: 92, - message: '鎿嶄綔鎴愬姛', - duration: 2 + this.setState({ + selectCards: [], + fields: fromJS(fields).toJS().map(cell => { + if (keys.includes(cell.field.toLowerCase())) { + cell.origin = true + } + return cell }) - } else if (type === 'fields') { - this.props.updatefield(items) + }) - notification.success({ - top: 92, - message: '鎿嶄綔鎴愬姛', - duration: 2 - }) - } + notification.success({ + top: 92, + message: '鎿嶄綔鎴愬姛', + duration: 2 + }) } shouldComponentUpdate (nextProps, nextState) { @@ -314,6 +239,10 @@ } } + onChange = (selectCards) => { + this.setState({selectCards}) + } + render() { const { type } = this.props const { dict, fields } = this.state @@ -325,24 +254,15 @@ <Modal wrapClassName="model-table-fieldmanage-modal" title={dict['model.edit']} - visible={this.state.tableVisible} + visible={this.state.visible} width={'65vw'} maskClosable={false} cancelText={dict['model.close']} onOk={this.addFieldSubmit} - onCancel={() => { // 鍙栨秷娣诲姞 - this.setState({ - tableVisible: false - }) - }} + onCancel={() => this.setState({ visible: false })} destroyOnClose > - {fields.length > 0 ? - <EditCard data={fields} ref="searchcard" type={type} dict={dict} /> : null - } - {(!fields || fields.length === 0) && - <Empty /> - } + {fields.length > 0 ? <EditCard data={fields} onChange={this.onChange} type={type} /> : <Empty />} </Modal> </div> ) diff --git a/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx b/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx index 416646d..e65b6ec 100644 --- a/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx +++ b/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx @@ -7,6 +7,7 @@ import asyncComponent from '@/utils/asyncComponent' import './index.scss' +const { Search } = Input const { MonthPicker, WeekPicker, RangePicker } = DatePicker const CheckCard = asyncComponent(() => import('@/templates/modalconfig/checkCard')) @@ -60,8 +61,13 @@ } let formItem = null + let type = '' if (card.type === 'text') { - formItem = (<Input style={{marginTop: '4px'}} placeholder={card.labelShow === 'false' ? card.label : ''} value={card.initval} />) + if (card.inputType === 'search') { + formItem = (<Search style={{marginTop: '4px'}} placeholder={card.labelShow === 'false' ? card.label : ''} value={card.initval} enterButton />) + } else { + formItem = (<Input style={{marginTop: '4px'}} placeholder={card.labelShow === 'false' ? card.label : ''} value={card.initval} />) + } } else if (card.type === 'multiselect' || card.type === 'select' || card.type === 'link') { formItem = (<Select value={_defaultValue}></Select>) } else if (card.type === 'date') { @@ -80,6 +86,7 @@ } else if (card.type === 'group') { formItem = (<DateGroup card={card} />) } else if (card.type === 'checkcard') { + type = 'checkcard' formItem = <CheckCard config={card} /> } @@ -91,7 +98,7 @@ <Icon className="close" title="delete" type="close" onClick={() => delCard(id)} /> </div> } trigger="hover"> - <div className={'page-card ' + (card.labelShow || '')} style={{ opacity: opacity}}> + <div className={'page-card ' + (card.labelShow || '') + ' ' + type} style={{ opacity: opacity}}> <div ref={node => drag(drop(node))} onDoubleClick={() => editCard(id)}> <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 8 }}} diff --git a/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx b/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx index 374c44e..06a1df7 100644 --- a/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx @@ -7,7 +7,7 @@ import Card from './card' import './index.scss' -const Container = ({list, placeholder, showField, handleList, handleMenu, deleteMenu }) => { +const Container = ({list, show, placeholder, showField, handleList, handleMenu, deleteMenu }) => { const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -144,7 +144,7 @@ /> </Col> ))} - {cards.length > 0 ? <Col key="action" className="action" span={radio < 6 ? 6 : radio}> + {cards.length > 0 && show !== 'false' ? <Col key="action" className="action" span={radio < 6 ? 6 : radio}> <div className="ant-row ant-form-item" style={{whiteSpace: 'nowrap', lineHeight: '40px', height: '55px', marginBottom: 0}}> <div className="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"> </div> diff --git a/src/templates/sharecomponent/searchcomponent/index.jsx b/src/templates/sharecomponent/searchcomponent/index.jsx index 44d9716..dc0dd9e 100644 --- a/src/templates/sharecomponent/searchcomponent/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/index.jsx @@ -10,6 +10,7 @@ import enUS from '@/locales/en-US/model.js' import { getSearchForm } from '@/templates/zshare/formconfig' +import MKEmitter from '@/utils/events.js' import SearchForm from './searchform' import DragElement from './dragsearch' import './index.scss' @@ -53,6 +54,32 @@ this.handleSearch(item) } this.setState({searchlist: fromJS(nextProps.config.search).toJS()}) + } + } + + componentDidMount () { + MKEmitter.addListener('plusSearch', this.plusSearch) + } + + plusSearch = (MenuId, item, type) => { + const { config } = this.props + const { searchlist } = this.state + + if (MenuId !== config.uuid) return + + if (type === 'simple') { + this.setState({ + searchlist: [...searchlist, item], + }, () => { + this.handleSearch(item) + }) + } else if (type === 'multil') { + let list = [...searchlist, ...item] + this.setState({ + searchlist: list + }, () => { + this.props.updatesearch({...config, search: list}) + }) } } @@ -280,13 +307,15 @@ this.setState = () => { return } + MKEmitter.removeListener('plusSearch', this.plusSearch) } shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS(this.state), fromJS(nextState)) || this.props.config.setting.show !== nextProps.config.setting.show } render() { + const { config } = this.props const { dict, searchlist, visible, sqlVerifing, card, showField } = this.state return ( @@ -297,6 +326,7 @@ <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={showField} onChange={this.onFieldChange} /> <DragElement list={searchlist} + show={config.setting.show} showField={showField} handleList={this.handleList} handleMenu={this.handleSearch} diff --git a/src/templates/sharecomponent/searchcomponent/index.scss b/src/templates/sharecomponent/searchcomponent/index.scss index 8c171b4..60babd1 100644 --- a/src/templates/sharecomponent/searchcomponent/index.scss +++ b/src/templates/sharecomponent/searchcomponent/index.scss @@ -71,6 +71,13 @@ width: 100%; } } + .page-card.checkcard { + .ant-form-item-control-wrapper { + .ant-form-item-control { + line-height: 1; + } + } + } .ant-calendar-picker { min-width: 100px!important; width: 100%; diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx index 377235b..e92077f 100644 --- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx @@ -654,6 +654,8 @@ } } else if (['multiselect', 'select', 'link', 'checkcard'].includes(values.type) && values.resourceType === '1') { values.options = [] + } else if (values.type === 'text' && values.advanced === 'true') { + values.inputType = 'input' } if (values.type === 'range') { diff --git a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx index 27bdb93..9919da3 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx @@ -679,6 +679,22 @@ </Col> <Col span={12}> <Form.Item label={ + <Tooltip placement="topLeft" title="鍦ㄦ悳绱㈡潯浠跺瓨鍦ㄦ椂锛屾槸鍚︽樉绀烘悳绱㈠拰閲嶇疆鎸夐挳銆�"> + <Icon type="question-circle" /> + 鎼滅储鎸夐挳 + </Tooltip> + }> + {getFieldDecorator('show', { + initialValue: setting.show || 'true' + })( + <Radio.Group> + <Radio value="true">鏄剧ず</Radio> + <Radio value="false">闅愯棌</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label={ <Tooltip placement="topLeft" title="楂樼骇鎼滅储寮圭獥鐨勫搴︼紝娉細褰撳搴﹀�煎皬浜�100鏃惰〃绀哄崰绐楀彛鐨勭櫨鍒嗘瘮锛屽ぇ浜�100鏃惰〃绀哄搴︾殑缁濆鍊笺��"> <Icon type="question-circle" /> 楂樼骇鎼滅储 diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 3beaec0..c1ea057 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -863,17 +863,13 @@ } /** - * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑 + * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽瓑 */ updateConfig = (res) => { - if (res.type === 'thaw') { - this.setState({ - thawButtons: res.thawButtons, - config: res.config - }) - } else if (res.type === 'paste') { - this.setState({config: res.config}) - } + this.setState({ + thawButtons: res.thawButtons, + config: res.config + }) } /** @@ -1008,11 +1004,7 @@ return (<SourceElement key={index} content={item}/>) })} </div> - <FieldsComponent - config={config} - type="search" - updatefield={this.updateconfig} - /> + <FieldsComponent config={config} type="search" /> </Panel> {/* 鎸夐挳娣诲姞 */} <Panel header={this.state.dict['header.menu.action']} key="2"> @@ -1051,11 +1043,7 @@ return (<SourceElement key={index} content={item}/>) })} </div> - <FieldsComponent - config={config} - type="columns" - updatefield={this.updateconfig} - /> + <FieldsComponent config={config} type="columns" /> </Panel> </Collapse> </div> diff --git a/src/templates/zshare/editcomponent/index.jsx b/src/templates/zshare/editcomponent/index.jsx index 6fd72b8..dd89e6d 100644 --- a/src/templates/zshare/editcomponent/index.jsx +++ b/src/templates/zshare/editcomponent/index.jsx @@ -9,6 +9,7 @@ import TransferForm from '@/templates/zshare/basetransferform' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' +import MKEmitter from '@/utils/events.js' import './index.scss' class editComponent extends Component { @@ -116,30 +117,16 @@ } pasteSubmit = () => { - const { options } = this.props + const { options, config } = this.props let _config = fromJS(this.props.config).toJS() this.pasteFormRef.handleConfirm().then(res => { if (res.copyType === 'action' && options.includes('action')) { res.uuid = Utils.getuuid() - - _config.action = _config.action.filter(item => !item.origin) - _config.action.push(res) - - this.setState({ - pasteVisible: false - }, () => { - this.props.refresh({ - type: 'paste', - config: _config - }) - }) + MKEmitter.emit('pasteButton', config.uuid, res) } else if (options.includes('search') && res.copyType === 'search') { res.uuid = Utils.getuuid() - _config.search = _config.search.filter(item => !item.origin) - let keys = _config.search.map(item => item.field.toLowerCase()) - - _config.search.push(res) + let keys = _config.search.map(item => item.field ? item.field.toLowerCase() : '') if (res.field && keys.includes(res.field.toLowerCase())) { notification.warning({ @@ -149,83 +136,37 @@ }) return } - - this.setState({ - pasteVisible: false - }, () => { - this.props.refresh({ - type: 'paste', - config: _config - }) - }) + MKEmitter.emit('plusSearch', config.uuid, res, 'simple') } else if (options.includes('columns') && res.copyType === 'columns') { - _config.columns = _config.columns.filter(col => !col.origin) let keys = _config.columns.map(item => item.field ? item.field.toLowerCase() : '') - - if (_config.columns.length === 0) { - _config.columns = res.columns - } else { - res.columns.forEach(col => { - if (!col.field) return - let _key = col.field.toLowerCase() - if (!keys.includes(_key)) { - keys.push(_key) - _config.columns.push(col) - } - }) - } + let items = res.columns.filter(col => col.field && !keys.includes(col.field.toLowerCase())) - this.setState({ - pasteVisible: false - }, () => { - this.props.refresh({ - type: 'paste', - config: _config - }) - }) + MKEmitter.emit('plusColumns', config.uuid, items) } else if (options.includes('form') && res.copyType === 'form') { - let fields = [] - let labels = [] + let keys = _config.fields.map(item => item.field ? item.field.toLowerCase() : '') res.uuid = Utils.getuuid() - _config.fields.forEach(item => { - item.field && fields.push(item.field.toLowerCase()) - labels.push(item.label) - }) - _config.fields.push(res) - - if (res.field && fields.includes(res.field.toLowerCase())) { + if (res.field && keys.includes(res.field.toLowerCase())) { notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', duration: 10 }) return - } else if (labels.includes(res.label)) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', - duration: 10 - }) - return } - this.setState({ - pasteVisible: false - }, () => { - this.props.refresh({ - type: 'paste', - config: _config, - newform: res - }) - }) + this.props.plusFields([res]) } else { notification.warning({ top: 92, message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�', duration: 5 }) + return } + this.setState({ + pasteVisible: false + }) }) } diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 6613e61..e143d8b 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -749,8 +749,8 @@ key: 'inputType', label: '杈撳叆鏍峰紡', initVal: card.inputType || 'input', + tooltip: '浣跨敤楂樼骇鎼滅储鏃舵棤鏁堛��', required: false, - forbid: appType === null, options: [{ value: 'input', text: '杈撳叆妗�' -- Gitblit v1.8.0