From 326aa6b3effaccc71cfe0775d47b0f29eb3695a6 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 25 八月 2024 00:36:40 +0800
Subject: [PATCH] 2024-08-25

---
 src/menu/components/group/normal-group/index.jsx |   56 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/src/menu/components/group/normal-group/index.jsx b/src/menu/components/group/normal-group/index.jsx
index 3d5ec2f..aa41f27 100644
--- a/src/menu/components/group/normal-group/index.jsx
+++ b/src/menu/components/group/normal-group/index.jsx
@@ -1,8 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Popover, Button } from 'antd'
-import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined, PrinterOutlined } from '@ant-design/icons'
+import { Popover, Modal } from 'antd'
+import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined, UngroupOutlined } from '@ant-design/icons'
 
 import MKEmitter from '@/utils/events.js'
 import asyncComponent from '@/utils/asyncComponent'
@@ -11,15 +11,18 @@
 import getSettingForm from './options'
 import './index.scss'
 
+const { confirm } = Modal
 const NormalForm = asyncIconComponent(() => import('@/components/normalform'))
 const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
-const PasteComponent = asyncIconComponent(() => import('../paste'))
+const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader'))
+const PasteController = asyncIconComponent(() => import('@/menu/pastecontroller'))
 const GroupComponents = asyncComponent(() => import('../groupcomponents'))
 
 class NormalGroup extends Component {
   static propTpyes = {
     group: PropTypes.object,
     deletecomponent: PropTypes.func,
+    unGroup: PropTypes.func,
     updateConfig: PropTypes.func,
   }
 
@@ -69,7 +72,7 @@
   changeStyle = () => {
     const { group } = this.state
 
-    MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow'], group.style, this.getStyle)
+    MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow', 'clear', 'minHeight'], group.style, this.getStyle)
   }
 
   getStyle = (style) => {
@@ -119,7 +122,43 @@
   }
 
   updateWrap = (res) => {
-    this.updateComponent({...this.state.group, setting: res})
+    let group = {...this.state.group, setting: res}
+
+    if (res.title && !group.headerStyle) {
+      group.headerStyle = { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }
+    }
+
+    this.updateComponent(group)
+  }
+
+  unGroup = () => {
+    const { group } = this.state
+
+    if (group.components.length === 0) return
+
+    const that = this
+    confirm({
+      title: '纭畾閲婃斁鍒嗙粍鍏冪礌鍚楋紵',
+      content: '',
+      onOk() {
+        that.props.unGroup(group.uuid)
+
+        setTimeout(() => {
+          that.updataGroup()
+        }, 10)
+      },
+      onCancel() {}
+    })
+  }
+
+  updataGroup = () => {
+    const { group } = this.props
+
+    if (group.components.length === 0) {
+      this.setState({
+        group: fromJS(group).toJS()
+      })
+    }
   }
 
   render() {
@@ -133,20 +172,21 @@
 
     return (
       <div className={'menu-group-edit-box ' + (paddingTop ? 'padding ' : '') + (group.setting.layout || '')} style={_style} id={group.uuid}>
+        <NormalHeader hideSearch="true" config={group} updateComponent={this.updateComponent}/>
         <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}>
               <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/>
             </NormalForm>
-            <CopyComponent type="tabs" card={group}/>
-            <PasteComponent insert={this.insert} />
+            <CopyComponent type="group" card={group}/>
+            <UngroupOutlined title="閲婃斁" style={group.components.length > 0 ? {color: '#32c5d2'} : {color: '#eeeeee', cursor: 'not-allowed'}} onClick={this.unGroup}/>
+            <PasteController type="group" tab={group} insert={this.insert} />
             <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/>
             <DeleteOutlined className="close" title="delete" onClick={() => this.props.deletecomponent(group.uuid)} />
           </div>
         } trigger="hover">
           <ToolOutlined />
         </Popover>
-        {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>
     )

--
Gitblit v1.8.0