| | |
| | | const Versions = asyncComponent(() => import('@/menu/versions')) |
| | | const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) |
| | | const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) |
| | | const Unattended = asyncComponent(() => import('@/templates/zshare/unattended')) |
| | | const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent')) |
| | | const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent')) |
| | | const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) |
| | |
| | | </div> |
| | | } bordered={false} extra={ |
| | | <div> |
| | | <Unattended config={config} updateConfig={this.updateconfig}/> |
| | | <Versions MenuId={menu.MenuID} open_edition={openEdition} updateConfig={this.refreshConfig}/> |
| | | <ReplaceField type="table" config={config} updateConfig={this.updateconfig}/> |
| | | <EditComponent dict={this.state.dict} type="table" options={['search', 'form', 'action', 'columns']} config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> |
| | |
| | | ] |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.onChange(e, item.key)}}> |
| | | { |
| | | item.options.map(option => { |
| | | {item.options.map(option => { |
| | | return ( |
| | | <Radio key={option.value} value={option.value}>{option.text}</Radio> |
| | | ) |
| | | }) |
| | | } |
| | | </Radio.Group>, |
| | | })} |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Modal, Button } from 'antd' |
| | | |
| | | import SettingForm from './settingform' |
| | | import './index.scss' |
| | | |
| | | class Unattended extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, |
| | | updateConfig: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | visible: false, |
| | | actions: [], |
| | | autoMatic: null |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | trigger = () => { |
| | | const { config } = this.props |
| | | let actions = [] |
| | | |
| | | config.action.forEach(item => { |
| | | if (item.position !== 'toolbar') return |
| | | if (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print')) { |
| | | actions.push(item) |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | actions, |
| | | autoMatic: config.autoMatic || {enable: 'false'}, |
| | | visible: true |
| | | }) |
| | | } |
| | | |
| | | submit = () => { |
| | | // let config = fromJS(this.props.config).toJS() |
| | | |
| | | this.settingRef.handleConfirm().then(res => { |
| | | |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { visible, actions, autoMatic } = this.state |
| | | |
| | | return ( |
| | | <div style={{display: 'inline-block'}}> |
| | | <Button className="mk-border-purple" icon="user" onClick={this.trigger}>无人值守</Button> |
| | | <Modal |
| | | title="无人值守" |
| | | wrapClassName="unattended-field-modal" |
| | | visible={visible} |
| | | width={600} |
| | | maskClosable={false} |
| | | onOk={this.submit} |
| | | onCancel={() => { this.setState({ visible: false })}} |
| | | destroyOnClose |
| | | > |
| | | <SettingForm actions={actions} autoMatic={autoMatic} wrappedComponentRef={(inst) => this.settingRef = inst}/> |
| | | </Modal> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default Unattended |
New file |
| | |
| | | .unattended-field-modal { |
| | | .ant-modal { |
| | | top: 70px; |
| | | } |
| | | .ant-modal-body { |
| | | min-height: 150px; |
| | | } |
| | | } |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Tooltip, Icon, Select, Radio } from 'antd' |
| | | |
| | | // import './index.scss' |
| | | |
| | | class SettingForm extends Component { |
| | | static propTpyes = { |
| | | autoMatic: PropTypes.object, |
| | | actions: PropTypes.array |
| | | } |
| | | |
| | | state = {} |
| | | |
| | | handleConfirm = () => { |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | resolve(values) |
| | | } else { |
| | | reject(err) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { actions, autoMatic } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 8 } |
| | | }, |
| | | wrapperCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 16 } |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col span={20}> |
| | | <Form.Item label="是否启用"> |
| | | {getFieldDecorator('enable', { |
| | | initialValue: autoMatic.enable, |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value="true">是</Radio> |
| | | <Radio value="false">否</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={20}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="用于自动执行的按钮。"> |
| | | <Icon type="question-circle" style={{color: '#c49f47', marginRight: '3px'}} /> |
| | | 按钮 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('action', { |
| | | initialValue: autoMatic.action || '', |
| | | rules: [{ |
| | | required: true, |
| | | message: '请选择执行按钮!' |
| | | }] |
| | | })( |
| | | <Select> |
| | | {actions.map((option, i) => |
| | | <Select.Option key={i} value={option.uuid}>{option.label}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(SettingForm) |