king
2024-06-01 c62724a2cdbafa3c660538955acbedafa5a01871
src/templates/modalconfig/settingform/index.jsx
@@ -5,7 +5,11 @@
// import { formRule } from '@/utils/option.js'
import StyleInput from '@/menu/stylecontroller/styleInput'
import asyncComponent from '@/utils/asyncComponent'
import './index.scss'
const MkEditIcon = asyncComponent(() => import('@/components/mkIcon'))
const ColorSketch = asyncComponent(() => import('@/mob/colorsketch'))
class SettingForm extends Component {
  static propTpyes = {
@@ -18,38 +22,32 @@
    fields: null,
    display: this.props.config.setting.display || 'modal',
    placement: this.props.config.setting.placement || 'right',
    icon: this.props.config.setting.icon || '',
    appType: sessionStorage.getItem('appType'),
    dialogInput: false
    viewType: sessionStorage.getItem('editMenuType') || '',
  }
  UNSAFE_componentWillMount () {
    const { config } = this.props
    const { appType, display } = this.state
    let fields = []
    let dialogInput = null
    config.fields.forEach(f => {
      if (f.field && ['select', 'link', 'text', 'number', 'textarea'].includes(f.type) && f.hidden !== 'true' && f.readonly !== 'true') {
        fields.push(f)
      }
      if (f.field && f.hidden !== 'true' && f.readonly !== 'true') {
        if (dialogInput === null) {
          dialogInput = ['text', 'number'].includes(f.type)
        } else {
          dialogInput = false
        }
      }
    })
    let _display = display
    if (appType === 'mob' && display === 'modal') {
      _display = 'drawer'
    } else if (appType !== 'mob' && display === 'dialog') {
      _display = 'modal'
    }
    this.setState({
      fields: fields,
      display: _display,
      dialogInput
      display: _display
    })
  }
@@ -77,7 +75,7 @@
  render() {
    const { config } = this.props
    const { fields, appType, display, placement } = this.state
    const { fields, appType, display, placement, icon } = this.state
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
@@ -109,7 +107,7 @@
          </Col> */}
          <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="对话框在仅有一个可输入表单(非隐藏、非只读的文本或数字)时有效。">
              <Tooltip placement="topLeft" title="可选择表单的显示形式,注:标签打印按钮,暂不支持以抽屉显示表单。">
                <QuestionCircleOutlined className="mk-form-tip" />
                显示方式
              </Tooltip>
@@ -122,7 +120,7 @@
                  <Radio value="drawer">抽屉</Radio>
                  <Radio value="prompt">是否框</Radio>
                  <Radio value="exec">直接执行</Radio>
                  {/* <Radio value="dialog" disabled={dialogInput !== true}>对话框</Radio> */}
                  {appType !== 'mob' ? null : <Radio value="dialog">弹窗</Radio>}
                </Radio.Group>
              )}
            </Form.Item>
@@ -139,7 +137,19 @@
              })(<InputNumber min={10} max={2000} precision={0} onPressEnter={this.handleSubmit}/>)}
            </Form.Item>
          </Col> : null}
          {display === 'drawer' || display === 'modal' ? <Col span={12}>
          {display === 'dialog' && appType === 'mob' ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="小于100时为百分率,大于100时为绝对值。空值时宽度自适应。">
                <QuestionCircleOutlined className="mk-form-tip" />
                宽度
              </Tooltip>
            }>
              {getFieldDecorator('width', {
                initialValue: config.setting.width || ''
              })(<InputNumber min={10} max={2000} precision={0} onPressEnter={this.handleSubmit}/>)}
            </Form.Item>
          </Col> : null}
          {['dialog', 'drawer', 'modal'].includes(display) ? <Col span={12}>
            <Form.Item label="初始焦点">
              {getFieldDecorator('focus', {
                initialValue: config.setting.focus || ''
@@ -158,7 +168,7 @@
              )}
            </Form.Item>
          </Col> : null}
          {display === 'drawer' || display === 'modal' ? <Col span={12}>
          {['drawer', 'modal'].includes(display) ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="执行失败时需要聚焦的表单。">
                <QuestionCircleOutlined className="mk-form-tip" />
@@ -180,6 +190,32 @@
                  )}
                </Select>
              )}
            </Form.Item>
          </Col> : null}
          {appType !== 'mob' && display === 'modal' ? <Col span={12}>
            <Form.Item label="图标">
              {getFieldDecorator('icon', {
                initialValue: icon
              })(<MkEditIcon onChange={(value) => this.setState({icon: value})} allowClear={true}/>)}
            </Form.Item>
          </Col> : null}
          {appType !== 'mob' && display === 'modal' && icon ? <Col span={12}>
            <Form.Item label="图标样式">
              {getFieldDecorator('iconType', {
                initialValue: config.setting.iconType || 'def'
              })(
                <Radio.Group>
                  <Radio value="def">默认</Radio>
                  <Radio value="circle">圆形</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {appType !== 'mob' && display === 'modal' && icon ? <Col span={12}>
            <Form.Item label="图标颜色">
              {getFieldDecorator('iconColor', {
                initialValue: config.setting.iconColor || ''
              })(<ColorSketch allowClear={true}/>)}
            </Form.Item>
          </Col> : null}
          {appType === 'mob' && display === 'drawer' ? <Col span={12}>
@@ -228,7 +264,7 @@
                </Radio.Group>)}
            </Form.Item>
          </Col> : null}
          {display === 'drawer' || display === 'modal' ? <Col span={12}>
          {['drawer', 'modal'].includes(display) ? <Col span={12}>
            <Form.Item label="完成后">
              {getFieldDecorator('finish', {
                initialValue: config.setting.finish || 'close'
@@ -240,7 +276,7 @@
              )}
            </Form.Item>
          </Col> : null}
          {display === 'drawer' || display === 'modal' ? <Col span={12}>
          {['dialog', 'drawer', 'modal'].includes(display) ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="需要通过数据源查询的选项,是否使用缓存。">
                <QuestionCircleOutlined className="mk-form-tip" />
@@ -258,7 +294,7 @@
            </Form.Item>
          </Col> : null}
          {display === 'drawer' ? <Col span={12}>
            <Form.Item label="抽屉方向">
            <Form.Item label="弹出方向">
              {getFieldDecorator('placement', {
                initialValue: placement
              })(
@@ -283,8 +319,31 @@
              )}
            </Form.Item>
          </Col> : null}
          {display === 'drawer' && appType !== 'mob' ? <Col span={12}>
            <Form.Item label="表单类型">
          {appType !== 'mob' && (display === 'drawer' || display === 'modal') ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="正常间隙会预留出报错信息的位置,防止表单位置发生变化。">
                <QuestionCircleOutlined className="mk-form-tip" />
                竖向间隙
              </Tooltip>
            }>
              {getFieldDecorator('verticalSpace', {
                initialValue: config.setting.verticalSpace || 'normal'
              })(
                <Radio.Group>
                  <Radio value="normal">正常</Radio>
                  <Radio value="middle">中</Radio>
                  <Radio value="small">小</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {appType !== 'mob' && (display === 'drawer' || display === 'modal') ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="选择查看时表单均为只读,仅用于数据展示。">
                <QuestionCircleOutlined className="mk-form-tip" />
                表单类型
              </Tooltip>
            }>
              {getFieldDecorator('formType', {
                initialValue: config.setting.formType || 'edit'
              })(
@@ -295,7 +354,21 @@
              )}
            </Form.Item>
          </Col> : null}
          {!this.props.isSubTab && !appType && display === 'modal' ? <Col span={12}>
          {display === 'prompt' ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="提示框的确认提示信息。">
                <QuestionCircleOutlined className="mk-form-tip" />
                确认提示
              </Tooltip>
            }>
              {getFieldDecorator('tipTitle', {
                initialValue: config.setting.tipTitle || ''
              })(
                <Input autoComplete="off" onPressEnter={this.handleSubmit} />
              )}
            </Form.Item>
          </Col> : null}
          {!this.props.isSubTab && !appType && this.state.viewType !== 'popview' && display === 'modal' ? <Col span={12}>
            <Form.Item label="挂载对象">
              {getFieldDecorator('container', {
                initialValue: config.setting.container || 'tab'
@@ -307,7 +380,7 @@
              )}
            </Form.Item>
          </Col> : null}
          {display === 'drawer' || display === 'modal' ? <Col span={12}>
          {['dialog', 'drawer', 'modal'].includes(display) ? <Col span={12}>
            <Form.Item label="点击蒙层">
              {getFieldDecorator('clickouter', {
                initialValue: config.setting.clickouter || 'unclose'
@@ -319,6 +392,23 @@
              )}
            </Form.Item>
          </Col> : null}
          {!appType && display === 'modal' ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="是否可拖拽移动模态框。">
                <QuestionCircleOutlined className="mk-form-tip" />
                可移动
              </Tooltip>
            }>
              {getFieldDecorator('moveable', {
                initialValue: config.setting.moveable || 'false'
              })(
                <Radio.Group>
                  <Radio value="false">否</Radio>
                  <Radio value="true">是</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
        </Row>
      </Form>
    )