From 8d66ff34fae5b048a6b7923cc75d34f13a08be9d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 02 八月 2022 11:42:43 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/menu/components/group/normal-group/index.jsx |  113 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 72 insertions(+), 41 deletions(-)

diff --git a/src/menu/components/group/normal-group/index.jsx b/src/menu/components/group/normal-group/index.jsx
index 0d19e48..509829e 100644
--- a/src/menu/components/group/normal-group/index.jsx
+++ b/src/menu/components/group/normal-group/index.jsx
@@ -1,21 +1,20 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { connect } from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { Icon, Popover } 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 zhCN from '@/locales/zh-CN/model.js'
-import enUS from '@/locales/en-US/model.js'
+import { resetStyle } from '@/utils/utils-custom.js'
+import getSettingForm from './options'
 import './index.scss'
 
-const SettingComponent = asyncIconComponent(() => import('../tabsetting'))
+const NormalForm = asyncIconComponent(() => import('@/components/normalform'))
 const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
-const PasteController = asyncIconComponent(() => import('@/menu/pastecontroller'))
-const TabComponents = asyncComponent(() => import('../tabcomponents'))
+const PasteComponent = asyncIconComponent(() => import('../paste'))
+const GroupComponents = asyncComponent(() => import('../groupcomponents'))
 
 class NormalGroup extends Component {
   static propTpyes = {
@@ -25,19 +24,17 @@
   }
 
   state = {
-    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     group: null,
     editab: null,
   }
 
   UNSAFE_componentWillMount () {
     const { group } = this.props
-    console.log(group)
+
     if (group.isNew) {
       let _group = {
         uuid: group.uuid,
         type: group.type,
-        floor: group.floor,
         tabId: group.tabId || '',
         parentId: group.parentId || '',
         subtype: group.subtype,
@@ -63,8 +60,9 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('tabsChange', this.handleTabsChange)
     MKEmitter.addListener('submitStyle', this.getStyle)
+    MKEmitter.addListener('tabsChange', this.handleTabsChange)
+    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
   }
 
   /**
@@ -74,14 +72,34 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('submitStyle', this.getStyle)
     MKEmitter.removeListener('tabsChange', this.handleTabsChange)
-    MKEmitter.addListener('submitStyle', this.getStyle)
+    MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
+  }
+
+  updateComponentStyle = (parentId, keys, style) => {
+    const { group } = this.state
+
+    if (group.uuid !== parentId) return
+
+    let components = group.components.map(item => {
+      if (keys.includes(item.uuid)) {
+        item.style = {...item.style, ...style}
+      }
+      return item
+    })
+
+    this.setState({
+      group: {...group, components: []}
+    }, () => {
+      this.updateComponent({...group, components: components})
+    })
   }
 
   changeStyle = () => {
     const { group } = this.state
 
-    MKEmitter.emit('changeStyle', [group.uuid], ['background', 'border', 'padding', 'margin'], group.style)
+    MKEmitter.emit('changeStyle', [group.uuid], ['background', 'border', 'padding', 'margin', 'shadow'], group.style)
   }
 
   getStyle = (comIds, style) => {
@@ -109,8 +127,8 @@
   updateComponent = (component) => {
     const { group } = this.state
 
-    if (!is(fromJS(group.setting), fromJS(component.setting))) {
-      // 娉ㄥ唽浜嬩欢-鏍囩鍙樺寲锛岄�氱煡鏍囩鍐呭厓绱�
+    if (!is(fromJS(group.setting), fromJS(component.setting)) || !is(fromJS(group.style), fromJS(component.style))) {
+      // 娉ㄥ唽浜嬩欢-鏍囩鍙樺寲锛岄�氱煡缁勫唴鍏冪礌
       MKEmitter.emit('tabsChange', group.uuid)
     }
 
@@ -123,50 +141,63 @@
     this.props.updateConfig(component)
   }
 
-  insert = (item, cell) => {
+  insert = (item) => {
     let group = fromJS(this.state.group).toJS()
 
-    group.components.forEach(stab => {
-      if (stab.uuid === cell.uuid) {
-        stab.components.push(item)
-      }
-    })
+    item.parentId = group.parentId
+
+    group.components.push(item)
 
     this.setState({group})
     this.props.updateConfig(group)
   }
 
+  getWrapForms = () => {
+    const { setting } = this.state.group
+
+    return getSettingForm(setting)
+  }
+
+  updateWrap = (res) => {
+    this.updateComponent({...this.state.group, setting: res})
+  }
+
+  clickComponent = (e) => {
+    if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') {
+      e.stopPropagation()
+      MKEmitter.emit('clickComponent', this.state.group)
+    }
+  }
+
   render() {
     const { group } = this.state
+    let _style = resetStyle(group.style)
+
+    let paddingTop = true
+    if (group.style.paddingTop && parseInt(group.style.paddingTop) >= 28) {
+      paddingTop = false
+    }
 
     return (
-      <div className="menu-group-edit-box" style={group.style}>
+      <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">
-            <SettingComponent config={group} updateConfig={this.updateComponent} />
+            <NormalForm title="鍒嗙粍璁剧疆" width={700} update={this.updateWrap} getForms={this.getWrapForms}>
+              <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/>
+            </NormalForm>
             <CopyComponent type="tabs" card={group}/>
-            <PasteController type="tab" Tab={group} 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)} />
+            <PasteComponent insert={this.insert} />
+            <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>
-        <TabComponents config={group} handleList={this.updateComponent} deleteCard={this.deleteCard} />
-        
+        {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>
     )
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    menu: state.customMenu
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(NormalGroup)
\ No newline at end of file
+export default NormalGroup
\ No newline at end of file

--
Gitblit v1.8.0