From 76a4300654a18d228838c3f27455dc8e7a8cd616 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 15 一月 2021 17:04:42 +0800
Subject: [PATCH] Merge branch 'master' into bms

---
 src/menu/components/card/prop-card/index.jsx |  116 +++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 74 insertions(+), 42 deletions(-)

diff --git a/src/menu/components/card/prop-card/index.jsx b/src/menu/components/card/prop-card/index.jsx
index bcf9f79..9032026 100644
--- a/src/menu/components/card/prop-card/index.jsx
+++ b/src/menu/components/card/prop-card/index.jsx
@@ -19,6 +19,7 @@
 const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
 const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent'))
 const LogComponent = asyncIconComponent(() => import('@/menu/components/share/logcomponent'))
+const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent'))
 const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader'))
 
 const { confirm } = Modal
@@ -40,11 +41,49 @@
     const { card } = this.props
 
     if (card.isNew) {
-      let subcards = null
+      let _card = {
+        uuid: card.uuid,
+        type: card.type,
+        floor: card.floor,
+        tabId: card.tabId || '',
+        parentId: card.parentId || '',
+        format: 'object',   // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡
+        pageable: false,    // 缁勪欢灞炴�� - 鏄惁鍙垎椤�
+        switchable: true,  // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹�
+        dataName: card.dataName || '',
+        width: card.width || 24,
+        name: card.name,
+        subtype: card.subtype,
+        setting: { interType: 'system' },
+        wrap: { name: card.name, width: card.width || 24, title: '', addable: 'false', switch: 'false', datatype: 'static' },
+        style: { marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' },
+        headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' },
+        columns: [],
+        scripts: [],
+        subcards: [{
+          uuid: Utils.getuuid(),
+          setting: { width: 6, type: 'simple'},
+          style: {
+            borderWidth: '1px', borderColor: '#e8e8e8',
+            paddingTop: '15px', paddingBottom: '15px', paddingLeft: '15px', paddingRight: '15px',
+            marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px'
+          },
+          backStyle: {},
+          elements: [],
+          backElements: []
+        }],
+        btnlog: [],
+      }
 
       if (card.config) {
-        subcards = JSON.parse(card.config)
-        subcards = subcards.map(scard => {
+        let config = fromJS(card.config).toJS()
+
+        _card.wrap = config.wrap
+        _card.wrap.name = card.name
+        _card.style = config.style
+        _card.headerStyle = config.headerStyle
+
+        _card.subcards = config.subcards.map(scard => {
           scard.uuid = Utils.getuuid()
           scard.elements = scard.elements.map(elem => {
             elem.uuid = Utils.getuuid()
@@ -56,42 +95,6 @@
           })
           return scard
         })
-      } else {
-        subcards = [{
-          uuid: Utils.getuuid(),
-          setting: { width: 6, type: 'simple'},
-          style: {
-            borderWidth: '1px', borderColor: '#e8e8e8',
-            paddingTop: '15px', paddingBottom: '15px', paddingLeft: '15px', paddingRight: '15px',
-            marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px'
-          },
-          backStyle: {},
-          elements: [],
-          backElements: []
-        }]
-      }
-
-      let _card = {
-        uuid: card.uuid,
-        type: card.type,
-        floor: card.floor,
-        tabId: card.tabId || '',
-        parentId: card.parentId || '',
-        format: 'object',   // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡
-        pageable: false,    // 缁勪欢灞炴�� - 鏄惁鍙垎椤�
-        switchable: true,  // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹�
-        dataName: card.dataName || '',
-        width: 24,
-        name: card.name,
-        subtype: card.subtype,
-        setting: { interType: 'system' },
-        wrap: { name: card.name, width: 24, title: '', addable: 'false', switch: 'false', datatype: 'static' },
-        style: { marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' },
-        headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' },
-        columns: [],
-        scripts: [],
-        subcards: subcards,
-        btnlog: [],
       }
       this.setState({
         card: _card
@@ -107,6 +110,7 @@
   componentDidMount () {
     MKEmitter.addListener('submitStyle', this.getStyle)
     MKEmitter.addListener('logButton', this.logButton)
+    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -122,6 +126,24 @@
     }
     MKEmitter.removeListener('submitStyle', this.getStyle)
     MKEmitter.removeListener('logButton', this.logButton)
+    MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
+  }
+
+  updateComponentStyle = (parentId, keys, style) => {
+    const { card } = this.state
+
+    if (card.uuid !== parentId) return
+
+    let subcards = card.subcards.map(item => {
+      if (keys.includes(item.uuid)) {
+        item.style = {...item.style, ...style}
+      }
+      return item
+    })
+
+    this.setState({card: {...card, subcards: []}}, () => {
+      this.updateComponent({...card, subcards: subcards})
+    })
   }
 
   logButton = (id, item) => {
@@ -279,8 +301,10 @@
 
       card.btnlog = logs
 
-      this.setState({ card })
-      this.props.updateConfig(card)
+      this.setState({ card: {...card, subcards: []} }, () => {
+        this.setState({ card })
+        this.props.updateConfig(card)
+      })
       if (!done) {
         notification.warning({
           top: 92,
@@ -326,6 +350,13 @@
     this.props.updateConfig(card)
   }
 
+  clickComponent = (e) => {
+    if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') {
+      e.stopPropagation()
+      MKEmitter.emit('clickComponent', this.state.card)
+    }
+  }
+
   render() {
     const { card } = this.state
 
@@ -342,7 +373,7 @@
     }
 
     return (
-      <div className="menu-prop-card-edit-box" style={{...card.style}}>
+      <div className="menu-prop-card-edit-box" style={{...card.style}} onClick={this.clickComponent} id={card.uuid}>
         <NormalHeader defaultshow="hidden" config={card} updateComponent={this.updateComponent}/>
         <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
@@ -352,6 +383,7 @@
             <PasteComponent config={card} options={['cardcell']} updateConfig={this.updateComponent} />
             <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" />
             <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog} />
+            <UserComponent config={card}/>
             <Icon className="close" title="鍒犻櫎缁勪欢" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} />
             {card.wrap.datatype !== 'static' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : null}
             {card.wrap.datatype === 'static' ? <Icon style={{color: '#eeeeee', cursor: 'not-allowed'}} type="setting"/> : null}

--
Gitblit v1.8.0