| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Modal } from 'antd' |
| | | import { Modal, Button } from 'antd' |
| | | import { SettingOutlined } from '@ant-design/icons' |
| | | |
| | | import VerifyCard from './verifycard' |
| | | import CreateFunc from '@/templates/zshare/createfunc' |
| | | import './index.scss' |
| | | |
| | | class DataSource extends Component { |
| | |
| | | mainSearch: [], |
| | | visible: false, |
| | | loading: false, |
| | | setting: null |
| | | setting: null, |
| | | record: {} |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | }) |
| | | } |
| | | } else { |
| | | let _search = null |
| | | let filterComponent = (box) => { |
| | | let filterComponent = (box, mainSearch) => { |
| | | box.components.forEach(item => { |
| | | if (_search) return |
| | | |
| | | if (item.type === 'search') { |
| | | box.slist = [...box.slist, item.search] |
| | | } else if (item.uuid === config.uuid) { |
| | | _search = box.slist.pop() |
| | | if (item.type !== 'search') return |
| | | mainSearch = item.search |
| | | }) |
| | | let has = false |
| | | box.components.forEach(item => { |
| | | if (item.uuid === config.uuid) { |
| | | has = true |
| | | } else if (item.type === 'group') { |
| | | item.components.forEach(m => { |
| | | if (m.uuid !== config.uuid) return |
| | | _search = box.slist.pop() |
| | | }) |
| | | } else if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.slist = [...box.slist] |
| | | filterComponent(tab) |
| | | has = true |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | menu.slist = [] |
| | | filterComponent(menu) |
| | | |
| | | if (_search) { |
| | | search = _search |
| | | } else { |
| | | menu.components.forEach(item => { |
| | | if (item.type !== 'search') return |
| | | search = item.search |
| | | }) |
| | | if (has) { |
| | | search = mainSearch || [] |
| | | } else { |
| | | box.components.forEach(item => { |
| | | if (item.type !== 'tabs') return |
| | | |
| | | item.subtabs.forEach(tab => { |
| | | filterComponent(tab, mainSearch) |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | filterComponent(menu, null) |
| | | } |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | mainSearch: search |
| | | mainSearch: search, |
| | | record: {...config.setting} |
| | | }) |
| | | } |
| | | |
| | |
| | | delete res.setting.debugId |
| | | } |
| | | |
| | | if (res.setting.interType === 'system' && res.setting.sync === 'true') { |
| | | res.scripts && res.scripts.forEach(script => { |
| | | if (script.status === 'false' || script.position !== 'back') return |
| | | |
| | | res.setting.sync = 'false' |
| | | }) |
| | | } |
| | | |
| | | this.setState({loading: false, visible: false}) |
| | | this.props.updateConfig({...config, ...res}) |
| | | }, () => { |
| | |
| | | }) |
| | | } |
| | | |
| | | creatFunc = () => { |
| | | const { config } = this.props |
| | | const { mainSearch } = this.state |
| | | const menu = window.GLOB.customMenu |
| | | |
| | | return new Promise((resolve) => { |
| | | this.verifyRef.submitDataSource().then(res => { |
| | | let _config = fromJS(config).toJS() |
| | | _config.MenuName = menu.MenuName + '-' + _config.name |
| | | _config.menuNo = menu.MenuNo |
| | | _config.MenuID = menu.MenuID |
| | | _config.setting = res.setting |
| | | _config.columns = res.columns |
| | | _config.func = res.setting.innerFunc |
| | | _config.$type = 'table' |
| | | |
| | | if (res.setting.useMSearch === 'true') { // 使用主搜索条件 |
| | | _config.search = [..._config.search, ...mainSearch] |
| | | } |
| | | |
| | | resolve(_config) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | render () { |
| | | const { config } = this.props |
| | | const { visible, loading, mainSearch } = this.state |
| | | const { visible, loading, mainSearch, record } = this.state |
| | | |
| | | return ( |
| | | <div className="model-datasource"> |
| | |
| | | width={'75vw'} |
| | | maskClosable={false} |
| | | okText="提交" |
| | | onOk={this.verifySubmit} |
| | | confirmLoading={loading} |
| | | onCancel={() => {this.setState({ visible: false }) }} |
| | | onCancel={() => {this.setState({ visible: false, loading: false }) }} |
| | | footer={[ |
| | | config.subtype !== 'dualdatacard' && record.interType === 'inner' ? <CreateFunc key="create" getMsg={this.creatFunc}/> : null, |
| | | <Button key="cancel" onClick={() => { this.setState({ visible: false, loading: false }) }}>取消</Button>, |
| | | <Button key="confirm" type="primary" loading={loading} onClick={this.verifySubmit}>确定</Button> |
| | | ]} |
| | | destroyOnClose |
| | | > |
| | | <VerifyCard |
| | | mainSearch={mainSearch} |
| | | config={config} |
| | | updRecord={(record) => this.setState({record: record})} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> |
| | | </Modal> |