From 99c0ccd473e30f029b81feb65975d654528bc3e5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 20 四月 2023 17:58:02 +0800
Subject: [PATCH] 2023-04-20

---
 src/menu/components/carousel/prop-card/index.jsx |  107 +++++++++++++++++++++++++++--------------------------
 1 files changed, 54 insertions(+), 53 deletions(-)

diff --git a/src/menu/components/carousel/prop-card/index.jsx b/src/menu/components/carousel/prop-card/index.jsx
index bb43d43..3b1a1cd 100644
--- a/src/menu/components/carousel/prop-card/index.jsx
+++ b/src/menu/components/carousel/prop-card/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Popover, Modal, Carousel } from 'antd'
+import { Popover, Modal, Carousel, message } from 'antd'
 import { PlusOutlined, SettingOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined, ClockCircleOutlined } from '@ant-design/icons'
 
 import asyncComponent from '@/utils/asyncComponent'
@@ -14,6 +14,7 @@
 
 const SettingComponent = asyncIconComponent(() => import('@/menu/datasource'))
 const NormalForm = asyncIconComponent(() => import('@/components/normalform'))
+const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader'))
 const CardSimpleComponent = asyncComponent(() => import('@/menu/components/card/cardsimplecomponent'))
 const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
 const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent'))
@@ -30,7 +31,6 @@
   }
 
   state = {
-    appType: sessionStorage.getItem('appType'),
     card: null,
     back: false
   }
@@ -42,8 +42,6 @@
       let _card = {
         uuid: card.uuid,
         type: card.type,
-        tabId: card.tabId || '',
-        parentId: card.parentId || '',
         format: 'object',   // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡
         pageable: false,    // 缁勪欢灞炴�� - 鏄惁鍙垎椤�
         switchable: false,  // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹�
@@ -51,8 +49,8 @@
         name: card.name,
         subtype: card.subtype,
         setting: { },
-        wrap: { name: card.name, width: card.width || 24, datatype: 'static', autoplay: 'false', dots: 'true' },
-        style: { borderWidth: '1px', borderColor: '#e8e8e8', marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px', height: '300px' },
+        wrap: { name: card.name, width: card.width || 24, datatype: 'static', autoplay: 'false', dots: 'true', height: '300px' },
+        style: { borderWidth: '1px', borderColor: '#e8e8e8', marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' },
         columns: [],
         scripts: [],
         subcards: [{
@@ -86,14 +84,17 @@
  
       this.updateComponent(_card)
     } else {
+      let _card = fromJS(card).toJS()
+
+      if (!_card.wrap.height && _card.style.height) { // 鍏煎
+        _card.wrap.height = _card.style.height
+      }
+      delete _card.style.height
+
       this.setState({
-        card: fromJS(card).toJS()
+        card: _card
       })
     }
-  }
-
-  componentDidMount () {
-    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -107,24 +108,6 @@
     this.setState = () => {
       return
     }
-    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})
-    })
   }
 
   /**
@@ -154,10 +137,15 @@
       card.subcards.forEach(item => {
         item.elements.forEach(cell => {
           if (cell.eleType === 'button') {
+            if (cell.hidden === 'true') return
             if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
               if (!cell.modal || cell.modal.fields.length === 0) {
-                card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
+                card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
               }
+            } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) {
+              card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎叆鍒楁湭璁剧疆锛乣})
+            } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) {
+              card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎嚭鍒楁湭璁剧疆锛乣})
             }
           } else if (cell.datatype === 'dynamic' && cell.field) {
             card.errors.push({ level: 1, detail: `鍗$墖涓姩鎬佸瓧娈碘��${cell.field}鈥濇棤鏁坄})
@@ -186,10 +174,15 @@
       card.subcards.forEach((item, i) => {
         item.elements.forEach(cell => {
           if (cell.eleType === 'button') {
+            if (cell.hidden === 'true') return
             if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
               if (!cell.modal || cell.modal.fields.length === 0) {
-                card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
+                card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
               }
+            } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) {
+              card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎叆鍒楁湭璁剧疆锛乣})
+            } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) {
+              card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎嚭鍒楁湭璁剧疆锛乣})
             }
           } else if (cell.datatype === 'dynamic' && cell.field && !columns.includes(cell.field)) {
             card.errors.push({ level: 1, detail: `鍗$墖涓姩鎬佸瓧娈碘��${cell.field}鈥濇棤鏁坄})
@@ -223,7 +216,6 @@
    * @description 鍗曚釜鍗$墖淇℃伅鏇存柊
    */
   deleteCard = (cell) => {
-    const { appType } = this.state
     let card = fromJS(this.state.card).toJS()
     let _this = this
 
@@ -233,20 +225,6 @@
         card.subcards = card.subcards.filter(item => item.uuid !== cell.uuid)
 
         _this.updateComponent(card)
-
-        if (appType === 'mob') return
-
-        let uuids = []
-
-        cell.elements && cell.elements.forEach(c => {
-          if (c.eleType !== 'button' || (appType === 'pc' && c.OpenType !== 'popview')) return
-
-          uuids.push(c.uuid)
-        })
-
-        if (uuids.length === 0) return
-        
-        MKEmitter.emit('delButtons', uuids)
       },
       onCancel() {}
     })
@@ -255,7 +233,7 @@
   changeStyle = () => {
     const { card } = this.state
 
-    MKEmitter.emit('changeStyle', ['height', 'background', 'border', 'padding', 'margin', 'shadow'], card.style, this.getStyle)
+    MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow', 'clear'], card.style, this.getStyle)
   }
 
   getStyle = (style) => {
@@ -316,13 +294,25 @@
   }
 
   updateWrap = (res) => {
-    this.updateComponent({...this.state.card, wrap: res})
+    let _card = {...this.state.card, wrap: res}
+
+    if (res.title && !_card.headerStyle) {
+      _card.headerStyle = { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }
+    }
+
+    this.updateComponent(_card)
   }
 
   clickComponent = (e) => {
     if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') {
       e.stopPropagation()
-      MKEmitter.emit('clickComponent', this.state.card)
+      MKEmitter.emit('clickComponent', this.state.card.uuid, null, (style) => {
+        let _card = {...this.state.card}
+        _card.style = {..._card.style, ...style}
+
+        this.setState({ card: _card })
+        this.props.updateConfig(_card)
+      })
     }
   }
 
@@ -332,6 +322,7 @@
 
     return (
       <div className="menu-prop-carousel-edit-box" style={_style} onClick={this.clickComponent} id={card.uuid}>
+        <NormalHeader hideSearch="true" config={card} updateComponent={this.updateComponent}/>
         <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
             <PlusOutlined className="plus" title="娣诲姞鍗$墖" onClick={this.addCard}/>
@@ -350,12 +341,22 @@
         } trigger="hover">
           <ToolOutlined/>
         </Popover>
-        {card.subcards.length > 0 ? <Carousel dotPosition={card.wrap.dotPosition || 'bottom'} effect={card.wrap.effect || 'scrollx'}>
-          {card.subcards.map((subcard) => (<CardSimpleComponent key={subcard.uuid} cards={card} card={subcard} move={this.move} updateElement={this.updateCard} deleteElement={this.deleteCard}/>))}
-        </Carousel> : null}
+        <div style={{height: card.wrap.height}}>
+          {card.subcards.length > 0 ? <Carousel dotPosition={card.wrap.dotPosition || 'bottom'} effect={card.wrap.effect || 'scrollx'}>
+            {card.subcards.map((subcard) => (<CardSimpleComponent key={subcard.uuid} cards={card} card={subcard} move={this.move} updateElement={this.updateCard} deleteElement={this.deleteCard}/>))}
+          </Carousel> : null}
+        </div>
         <div className="component-name">
           <div className="center">
-            <div className="title">{card.name}</div>
+            <div className="title" onDoubleClick={() => {
+              let oInput = document.createElement('input')
+              oInput.value = 'anchor' + card.uuid
+              document.body.appendChild(oInput)
+              oInput.select()
+              document.execCommand('Copy')
+              document.body.removeChild(oInput)
+              message.success('澶嶅埗鎴愬姛銆�')
+            }}>{card.name}</div>
             <div className="content">
               {card.errors && card.errors.map((err, index) => {
                 if (err.level === 0) {

--
Gitblit v1.8.0