From 1da6506bf58270bacc2a4345002c6b082835580e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 21 十月 2021 23:17:08 +0800
Subject: [PATCH] 2021-10-21

---
 src/menu/components/card/cardcomponent/index.jsx |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 100 insertions(+), 15 deletions(-)

diff --git a/src/menu/components/card/cardcomponent/index.jsx b/src/menu/components/card/cardcomponent/index.jsx
index 0709e4f..4b43fef 100644
--- a/src/menu/components/card/cardcomponent/index.jsx
+++ b/src/menu/components/card/cardcomponent/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Popover, Icon, Switch, Col } from 'antd'
+import { Popover, Icon, Switch, Col, Modal, Button } from 'antd'
 
 import asyncComponent from '@/utils/asyncComponent'
 import asyncIconComponent from '@/utils/asyncIconComponent'
@@ -13,6 +13,7 @@
 
 const NormalForm = asyncIconComponent(() => import('@/components/normalform'))
 const CardCellComponent = asyncComponent(() => import('../cardcellcomponent'))
+const CardMenus = asyncComponent(() => import('./menus-wrap'))
 const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
 const PasteController = asyncIconComponent(() => import('@/components/paste'))
 
@@ -30,7 +31,9 @@
     card: null,            // 鍗$墖淇℃伅锛屽寘鎷鍙嶉潰
     formlist: null,        // 璁剧疆琛ㄥ崟淇℃伅
     elements: null,        // 缂栬緫缁�
-    side: 'front'
+    side: 'front',
+    appType: sessionStorage.getItem('appType'),
+    visible: false
   }
 
   /**
@@ -85,7 +88,7 @@
     this.props.updateElement(_card)
   }
 
-  updateCard = (elements) => {
+  updateCard = (elements, btn) => {
     const { card, side } = this.state
 
     let _card = {}
@@ -100,7 +103,7 @@
       card: _card
     })
 
-    this.props.updateElement(_card)
+    this.props.updateElement(_card, btn)
   }
 
   changeSide = () => {
@@ -170,13 +173,52 @@
 
   getSettingForms = () => {
     const { cards } = this.props
-    const { setting } = this.state.card
+    const { card, appType } = this.state
 
-    return getSettingForm(setting, cards.subtype === 'propcard')
+    let buttons = []
+    card.elements && card.elements.forEach(item => {
+      if (item.eleType === 'button') {
+        buttons.push({
+          value: item.uuid,
+          label: item.label
+        })
+      }
+    })
+    if (appType !== 'mob' && card.backElements) {
+      card.backElements.forEach(item => {
+        if (item.eleType === 'button') {
+          buttons.push({
+            value: item.uuid,
+            label: item.label
+          })
+        }
+      })
+    }
+    return getSettingForm(card.setting, cards.subtype, buttons, card.$cardType, cards.columns)
   }
 
   updateSetting = (res) => {
-    const { card, side } = this.state
+    const { card, side, appType } = this.state
+
+    if (appType === '' && res.menu) {
+      let list = null
+      try {
+        list = JSON.parse(sessionStorage.getItem('thdMenuList')) || []
+      } catch (e) {
+        list = []
+      }
+
+      let id = res.menu[res.menu.length - 1]
+
+      list.forEach(item => {
+        if (item.MenuID === id) {
+          res.MenuID = id
+          res.MenuName = item.MenuName
+          res.MenuNo = item.MenuNo
+          res.tabType = item.type
+        }
+      })
+    }
 
     this.setState({
       card: {...card, setting: res}
@@ -198,11 +240,14 @@
 
     let _uuid = Utils.getuuid()
     
-    if (element.copyType === 'action' && element.OpenType === 'popview') { // 寮圭獥鏍囩澶嶅埗
-      let _cell = fromJS(element).toJS()
-      _cell.$originUuid = element.uuid
-      _cell.uuid = _uuid
-      MKEmitter.emit('copyButtons', [_cell])
+    if (element.copyType === 'action') {
+      element.eleType = 'button'
+      if (element.OpenType === 'popview') { // 寮圭獥鏍囩澶嶅埗
+        let _cell = fromJS(element).toJS()
+        _cell.$originUuid = element.uuid
+        _cell.uuid = _uuid
+        MKEmitter.emit('copyButtons', [_cell])
+      }
     }
 
     element.uuid = _uuid
@@ -222,16 +267,29 @@
   }
 
   doubleClickCard = () => {
-    const { card } = this.state
+    const { cards } = this.props
+    const { card, appType } = this.state
 
     if (card.setting.click === 'menu' && card.setting.menu) {
       MKEmitter.emit('changeEditMenu', {MenuID: card.setting.menu})
+    } else if (card.setting.click === 'menus' && card.menus && card.menus.length > 0 && cards.subtype === 'datacard' && card.$cardType !== 'extendCard' && (appType === 'mob' || appType === 'pc')) {
+      this.setState({visible: true})
     }
+  }
+
+  updateMenus = (res) => {
+    const { card } = this.state
+
+    this.setState({
+      card: {...card, menus: res}
+    })
+
+    this.props.updateElement({...card, menus: res})
   }
 
   render() {
     const { cards, offset } = this.props
-    const { card, elements, side } = this.state
+    const { card, elements, side, visible } = this.state
 
     let _style = {...card.style}
 
@@ -249,7 +307,7 @@
 
     return (
       <Col span={card.setting.width || 6} offset={offset || 0}>
-        <div className="card-item" style={_style} onClick={this.clickComponent} onDoubleClick={(e) => {e.stopPropagation(); this.doubleClickCard()}} id={card.uuid}>
+        <div className={'card-item ' + (card.setting.btnControl || '')} style={_style} onClick={this.clickComponent} onDoubleClick={(e) => {e.stopPropagation(); this.doubleClickCard()}} id={card.uuid}>
           <CardCellComponent cards={cards} cardCell={card} side={side} elements={elements} updateElement={this.updateCard}/>
           <div className="card-control" onDoubleClick={(e) => e.stopPropagation()}>
             <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
@@ -259,6 +317,8 @@
                 <NormalForm title="鍗$墖璁剧疆" width={800} update={this.updateSetting} getForms={this.getSettingForms}>
                   <Icon type="edit" className="edit" title="缂栬緫"/>
                 </NormalForm>
+                {cards.subtype === 'datacard' && card.$cardType !== 'extendCard' && card.setting.click === 'menus' ?
+                  <CardMenus card={card} updateMenus={this.updateMenus}/> : null}
                 <CopyComponent type="cardcell" card={card}/>
                 <PasteController options={['action', 'customCardElement']} updateConfig={this.paste} />
                 <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" />
@@ -278,6 +338,31 @@
             </Popover>
           </div>
         </div>
+        <Modal
+          title="鑿滃崟缁�"
+          wrapClassName="menus-detail-modal"
+          visible={visible}
+          closable={false}
+          width={900}
+          maskClosable={false}
+          footer={[<Button key="close" onClick={() => { this.setState({ visible: false })}}>鍏抽棴</Button>]}
+          destroyOnClose
+        >
+          <div className="menu-line">
+            <div className="sort">搴忓彿</div>
+            <div className="sign">鏍囪瘑</div>
+            <div className="name">鑿滃崟</div>
+            <div className="action">鎿嶄綔</div>
+          </div>
+          {card.menus && card.menus.map((item, index) => {
+            return <div className="menu-line" key={index}>
+              <div className="sort">{index + 1}</div>
+              <div className="sign">{item.sign}</div>
+              <div className="name">{item.label}</div>
+              <div className="action"><span onClick={() => MKEmitter.emit('changeEditMenu', {MenuID: item.menu})}>璇︽儏</span></div>
+            </div>
+          })}
+        </Modal>
       </Col>
     )
   }

--
Gitblit v1.8.0