king
2022-08-19 3b103caa6bfc9ed410e67156c3ca1785bf1cecc9
src/menu/components/group/normal-group/index.jsx
@@ -1,15 +1,14 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Icon, Popover, Button } from 'antd'
import { Popover, Button } from 'antd'
import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined, PrinterOutlined } from '@ant-design/icons'
import MKEmitter from '@/utils/events.js'
import asyncComponent from '@/utils/asyncComponent'
import asyncIconComponent from '@/utils/asyncIconComponent'
import { resetStyle } from '@/utils/utils-custom.js'
import getSettingForm from './options'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import './index.scss'
const NormalForm = asyncIconComponent(() => import('@/components/normalform'))
@@ -25,7 +24,6 @@
  }
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    group: null,
    editab: null,
  }
@@ -37,7 +35,6 @@
      let _group = {
        uuid: group.uuid,
        type: group.type,
        floor: group.floor,
        tabId: group.tabId || '',
        parentId: group.parentId || '',
        subtype: group.subtype,
@@ -63,7 +60,6 @@
  }
  componentDidMount () {
    MKEmitter.addListener('submitStyle', this.getStyle)
    MKEmitter.addListener('tabsChange', this.handleTabsChange)
    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
  }
@@ -75,7 +71,6 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('submitStyle', this.getStyle)
    MKEmitter.removeListener('tabsChange', this.handleTabsChange)
    MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
  }
@@ -102,15 +97,11 @@
  changeStyle = () => {
    const { group } = this.state
    MKEmitter.emit('changeStyle', [group.uuid], ['background', 'border', 'padding', 'margin', 'shadow'], group.style)
    MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow'], group.style, this.getStyle)
  }
  getStyle = (comIds, style) => {
    const { group } = this.state
    if (comIds.length !== 1 || comIds[0] !== group.uuid) return
    let _card = {...group, style}
  getStyle = (style) => {
    let _card = {...this.state.group, style}
    this.setState({
      group: _card
@@ -147,7 +138,6 @@
  insert = (item) => {
    let group = fromJS(this.state.group).toJS()
    item.floor = group.floor || 1
    item.parentId = group.parentId
    group.components.push(item)
@@ -183,21 +173,21 @@
    }
    return (
      <div className={'menu-group-edit-box' + (paddingTop ? ' padding' : '')} style={_style} onClick={this.clickComponent} id={group.uuid}>
      <div className={'menu-group-edit-box ' + (paddingTop ? 'padding ' : '') + (group.setting.layout || '')} style={_style} onClick={this.clickComponent} id={group.uuid}>
        <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
          <div className="mk-popover-control">
            <NormalForm title="分组设置" width={700} update={this.updateWrap} getForms={this.getWrapForms}>
              <Icon type="edit" style={{color: '#1890ff'}} title="编辑"/>
              <EditOutlined style={{color: '#1890ff'}} title="编辑"/>
            </NormalForm>
            <CopyComponent type="tabs" card={group}/>
            <PasteComponent insert={this.insert} />
            <Icon className="style" title="调整样式" onClick={this.changeStyle} type="font-colors" />
            <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(group.uuid)} />
            <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle}/>
            <DeleteOutlined className="close" title="delete" onClick={() => this.props.deletecomponent(group.uuid)} />
          </div>
        } trigger="hover">
          <Icon type="tool" />
          <ToolOutlined />
        </Popover>
        {group.setting && group.setting.print === 'true' ? <Button className="print-button" icon="printer" onClick={this.print}></Button> : null}
        {group.setting && group.setting.print === 'true' ? <Button className="print-button" onClick={this.print}><PrinterOutlined /></Button> : null}
        <GroupComponents config={group} handleList={this.updateComponent} deleteCard={this.deleteCard} />
      </div>
    )