| | |
| | | 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) { |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (labelrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '名称已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | |
| | | 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 |
| | | } |
| | | }) |
| | | |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (labelrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '名称已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | |
| | | 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) { |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (labelrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '名称已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | |
| | | 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 |
| | | } |
| | | }) |
| | | |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (labelrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '名称已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('submitStyle', this.getStyle) |
| | | MKEmitter.addListener('plusSearch', this.plusSearch) |
| | | } |
| | | |
| | | /** |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('submitStyle', this.getStyle) |
| | | MKEmitter.removeListener('plusSearch', this.plusSearch) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | }) |
| | | } |
| | | |
| | | 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 = () => { |
| | |
| | | |
| | | 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} |
| | |
| | | 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) { |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (labelrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '名称已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | |
| | | }) |
| | | } |
| | | |
| | | 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 |
| | | |
| | |
| | | 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> |
| | |
| | | <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> |
| | |
| | | { 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 }, |
| | |
| | | let _config = fromJS(this.state.config).toJS() |
| | | |
| | | if (list.length > _config.fields.length) { |
| | | _config.fields = list.filter(item => !item.origin) |
| | | |
| | | this.setState({ |
| | | config: _config |
| | | }, () => { |
| | |
| | | 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) { |
| | |
| | | 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({ |
| | |
| | | /** |
| | | * @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]) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | 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> |
| | |
| | | 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')) |
| | |
| | | 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') { |
| | |
| | | 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' |
| | |
| | | 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')) |
| | |
| | | this.improveSearch(mainItems, localItems) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | // 查询下拉菜单 |
| | |
| | | ] |
| | | |
| | | 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') { |
| | |
| | | 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 |
| | |
| | | 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); |
| | |
| | | opacity: 0; |
| | | } |
| | | } |
| | | .check-card-search-box { |
| | | margin-top: 3px; |
| | | } |
| | | } |
| | | .top-search.right { |
| | | >.ant-row { |
New file |
| | |
| | | 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 |
| | |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </div> |
| | | <FieldsComponent |
| | | config={config} |
| | | type="search" |
| | | updatefield={this.updateconfig} |
| | | /> |
| | | <FieldsComponent config={config} type="search" /> |
| | | </Panel> |
| | | </Collapse> |
| | | </div> |
| | |
| | | </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> |
| | |
| | | _config.MenuNo = menu.MenuNo || '' |
| | | _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : '' |
| | | _config.easyCode = _config.easyCode || '' |
| | | _config.uuid = menu.MenuID || '' |
| | | |
| | | // 版本兼容 |
| | | _config = updateCommonTable(_config) |
| | |
| | | * @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 |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | <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"> |
| | |
| | | <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"> |
| | |
| | | |
| | | let _groups = null |
| | | let fieldrepet = false // 字段重复 |
| | | let labelrepeat = false // 提示文字重复 |
| | | |
| | | if (card.iscopy) { |
| | | _groups = _config.groups.map(group => { |
| | |
| | | |
| | | if (item.uuid !== res.uuid && item.field === res.field) { |
| | | fieldrepet = true |
| | | } else if (item.uuid !== res.uuid && item.label === res.label) { |
| | | labelrepeat = true |
| | | } |
| | | }) |
| | | |
| | |
| | | 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) { |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (labelrepeat) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '名称已存在!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | 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) { |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (labelrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '名称已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 编辑功能完成更新,包括解冻按钮、粘贴、替换等 |
| | | */ |
| | | updateEditConfig = (res) => { |
| | | if (res.type === 'paste') { |
| | | this.setState({ |
| | | config: res.config |
| | | }) |
| | | this.handleForm(res.newform) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 更新配置信息 |
| | | */ |
| | | updateconfig = (config) => { |
| | |
| | | }) |
| | | } |
| | | |
| | | 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 |
| | |
| | | <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> |
| | |
| | | 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 |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @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 = () => { |
| | |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('pasteButton', this.pasteButton) |
| | | } |
| | | |
| | | render() { |
| | |
| | | import GridBtnForm from './gridbtnform' |
| | | import DragElement from './dragcolumn' |
| | | import MarkColumn from './markcolumn' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | |
| | | 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()}) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | } |
| | | |
| | | 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) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('plusColumns', this.plusColumns) |
| | | } |
| | | |
| | | render() { |
| | |
| | | import React, {Component} from 'react' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Row, Col, Icon, Radio, Input, Button } from 'antd' |
| | | import './index.scss' |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | 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} |
| | | }, () => { |
| | |
| | | |
| | | 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> |
| | |
| | | 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) |
| | |
| | | |
| | | 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 { |
| | |
| | | cursor: pointer; |
| | | } |
| | | } |
| | | .ant-card.selected { |
| | | .ant-card.selected, .ant-card.fixed { |
| | | border-color: #1890ff; |
| | | box-shadow: 0px 0px 4px #1890ff; |
| | | .anticon { |
| | |
| | | color: #1890ff; |
| | | } |
| | | } |
| | | .ant-card.fixed { |
| | | .base { |
| | | cursor: default; |
| | | } |
| | | } |
| | | } |
| | | .search-row { |
| | | .ant-col { |
| | |
| | | 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 { |
| | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | appType: sessionStorage.getItem('appType'), |
| | | fields: [], // 字段集 |
| | | tableVisible: false, // 模态框控制 |
| | | fields: [], // 字段集 |
| | | visible: false, // 模态框控制 |
| | | selectCards: [] |
| | | } |
| | | |
| | | queryField = () => { |
| | |
| | | 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') { |
| | |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | |
| | | onChange = (selectCards) => { |
| | | this.setState({selectCards}) |
| | | } |
| | | |
| | | render() { |
| | | const { type } = this.props |
| | | const { dict, fields } = this.state |
| | |
| | | <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> |
| | | ) |
| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | | const { Search } = Input |
| | | const { MonthPicker, WeekPicker, RangePicker } = DatePicker |
| | | const CheckCard = asyncComponent(() => import('@/templates/modalconfig/checkCard')) |
| | | |
| | |
| | | } |
| | | |
| | | 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') { |
| | |
| | | } else if (card.type === 'group') { |
| | | formItem = (<DateGroup card={card} />) |
| | | } else if (card.type === 'checkcard') { |
| | | type = 'checkcard' |
| | | formItem = <CheckCard config={card} /> |
| | | } |
| | | |
| | |
| | | <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 }}} |
| | |
| | | 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) |
| | |
| | | /> |
| | | </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> |
| | |
| | | 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' |
| | |
| | | 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}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | 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 ( |
| | |
| | | <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} |
| | |
| | | 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%; |
| | |
| | | } |
| | | } 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') { |
| | |
| | | </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" /> |
| | | 高级搜索 |
| | |
| | | } |
| | | |
| | | /** |
| | | * @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 |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | 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"> |
| | |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </div> |
| | | <FieldsComponent |
| | | config={config} |
| | | type="columns" |
| | | updatefield={this.updateconfig} |
| | | /> |
| | | <FieldsComponent config={config} type="columns" /> |
| | | </Panel> |
| | | </Collapse> |
| | | </div> |
| | |
| | | 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 { |
| | |
| | | } |
| | | |
| | | 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({ |
| | |
| | | }) |
| | | 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 |
| | | }) |
| | | }) |
| | | } |
| | | |
| | |
| | | key: 'inputType', |
| | | label: '输入样式', |
| | | initVal: card.inputType || 'input', |
| | | tooltip: '使用高级搜索时无效。', |
| | | required: false, |
| | | forbid: appType === null, |
| | | options: [{ |
| | | value: 'input', |
| | | text: '输入框' |