king
2021-12-21 3cff8e1589fd8e319ee6a35facfa63cf02f92f6a
src/menu/components/form/formaction/index.jsx
@@ -1,12 +1,14 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Modal, Button, Popover, Icon } from 'antd'
import { Modal, Button, Popover } from 'antd'
import { FontColorsOutlined, EditOutlined, ProfileOutlined } from '@ant-design/icons'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import asyncComponent from '@/utils/asyncComponent'
import { getActionForm } from './formconfig'
import { resetStyle } from '@/utils/utils-custom.js'
import MKEmitter from '@/utils/events.js'
import MenuUtils from '@/utils/utils-custom.js'
@@ -23,6 +25,7 @@
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    appType: sessionStorage.getItem('appType'),
    card: null,          // 编辑中元素
    formlist: null,      // 表单信息
    visible: false,      // 模态框控制
@@ -51,7 +54,7 @@
    const { group } = this.props
    let _style = element.style ? fromJS(element.style).toJS() : {}
    let options = ['font', 'border', 'padding', 'margin', 'backgroundColor']
    let options = ['font', 'border', 'padding', 'margin', 'backgroundColor', 'width']
    this.setState({
      card: element
@@ -86,7 +89,7 @@
    if (usefulFields) {
      try {
        usefulFields = JSON.parse(usefulFields)
      } catch {
      } catch (e) {
        usefulFields = []
      }
    } else {
@@ -98,7 +101,7 @@
      <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p>
    </div>
    let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, config.uuid)
    let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, config.uuid) || []
    this.setState({
      visible: true,
@@ -172,36 +175,51 @@
    })
  }
  changeMenu = () => {
    const { appType } = this.state
    const { group } = this.props
    if (appType !== 'pc' && appType !== 'mob') return
    if (!group.subButton.linkmenu) return
    MKEmitter.emit('changeEditMenu', {
      MenuID: group.subButton.linkmenu,
      copyMenuId: '',
      MenuNo: '',
      MenuName: '',
    })
  }
  render() {
    const { group, config } = this.props
    const { visible, profVisible, card, dict } = this.state
    return (
      <div className="mk-form-action">
        {group.sort !== 1 ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
        {group.prevButton && group.prevButton.enable !== 'false' && group.sort !== 1 ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
          <div className="mk-popover-control">
            <Icon className="edit" title="编辑" type="edit" onClick={() => this.handleAction(group.prevButton)} />
            <Icon className="style" title="调整样式" onClick={() => this.handleStyle(group.prevButton)} type="font-colors" />
            <EditOutlined className="edit" title="编辑" onClick={() => this.handleAction(group.prevButton)} />
            <FontColorsOutlined className="style" title="调整样式" onClick={() => this.handleStyle(group.prevButton)}/>
          </div>
        } trigger="hover">
          <Button type="link" className="prev" style={group.prevButton.style}>{group.prevButton.label}</Button>
          <Button type="link" className="prev" style={resetStyle(group.prevButton.style)}>{group.prevButton.label}</Button>
        </Popover> : null}
        <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
          <div className="mk-popover-control">
            <Icon className="edit" title="编辑" type="edit" onClick={() => this.handleAction(group.subButton)} />
            <Icon className="style" title="调整样式" onClick={() => this.handleStyle(group.subButton)} type="font-colors" />
            <Icon className="profile" title="setting" type="profile" onClick={() => this.profileAction()} />
            <EditOutlined className="edit" title="编辑" onClick={() => this.handleAction(group.subButton)} />
            <FontColorsOutlined className="style" title="调整样式" onClick={() => this.handleStyle(group.subButton)}/>
            <ProfileOutlined className="profile" title="setting" onClick={() => this.profileAction()} />
          </div>
        } trigger="hover">
          <Button type="link" className="submit mk-primary" style={group.subButton.style}>{group.subButton.label}</Button>
          <Button type="link" className="submit mk-primary" onDoubleClick={this.changeMenu} style={resetStyle(group.subButton.style)}>{group.subButton.label}</Button>
        </Popover>
        {group.sort !== config.subcards.length ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
        {group.nextButton && group.nextButton.enable !== 'false' && group.sort !== config.subcards.length ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
          <div className="mk-popover-control">
            <Icon className="edit" title="编辑" type="edit" onClick={() => this.handleAction(group.nextButton)} />
            <Icon className="style" title="调整样式" onClick={() => this.handleStyle(group.nextButton)} type="font-colors" />
            <EditOutlined className="edit" title="编辑" onClick={() => this.handleAction(group.nextButton)} />
            <FontColorsOutlined className="style" title="调整样式" onClick={() => this.handleStyle(group.nextButton)}/>
          </div>
        } trigger="hover">
          <Button type="link" className={'skip ' + group.nextButton.enable} style={group.nextButton.style}>{group.nextButton.label}</Button>
          <Button type="link" className="skip" style={resetStyle(group.nextButton.style)}>{group.nextButton.label}</Button>
        </Popover> : null}
        {/* 编辑按钮:复制、编辑 */}
        <Modal
@@ -234,7 +252,15 @@
          maskClosable={false}
          okText={dict['model.submit']}
          onOk={this.verifySubmit}
          onCancel={() => { this.setState({ profVisible: false }) }}
          onCancel={() => {
            if (this.verifyRef.handleCancel) {
              this.verifyRef.handleCancel().then(() => {
                this.setState({ profVisible: false })
              })
            } else {
              this.setState({ profVisible: false })
            }
          }}
          destroyOnClose
        >
          <VerifyCard