king
2021-10-12 236fa30c934046d3b90d6345bb7749ab332eb2c9
2021-10-12
2个文件已修改
4个文件已添加
184 ■■■■■ 已修改文件
src/templates/comtableconfig/index.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/modalform/index.jsx 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/unattended/index.jsx 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/unattended/index.scss 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/unattended/settingform/index.jsx 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/unattended/settingform/index.scss 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/index.jsx
@@ -29,6 +29,7 @@
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'))
@@ -1260,6 +1261,7 @@
              </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}/>
src/templates/zshare/modalform/index.jsx
@@ -616,14 +616,12 @@
                ]
              })(
                <Radio.Group onChange={(e) => {this.onChange(e, item.key)}}>
                  {
                    item.options.map(option => {
                      return (
                        <Radio key={option.value} value={option.value}>{option.text}</Radio>
                      )
                    })
                  }
                </Radio.Group>,
                  {item.options.map(option => {
                    return (
                      <Radio key={option.value} value={option.value}>{option.text}</Radio>
                    )
                  })}
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
src/templates/zshare/unattended/index.jsx
New file
@@ -0,0 +1,74 @@
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
src/templates/zshare/unattended/index.scss
New file
@@ -0,0 +1,8 @@
.unattended-field-modal {
  .ant-modal {
    top: 70px;
  }
  .ant-modal-body {
    min-height: 150px;
  }
}
src/templates/zshare/unattended/settingform/index.jsx
New file
@@ -0,0 +1,86 @@
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)
src/templates/zshare/unattended/settingform/index.scss