From 89fb1308d92e10a27cf8f91f4dd766eb38976e12 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 26 十一月 2020 21:56:42 +0800
Subject: [PATCH] 2020-11-26

---
 src/menu/components/card/cardcellcomponent/index.jsx |  264 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 160 insertions(+), 104 deletions(-)

diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx
index e408ef6..9d8b224 100644
--- a/src/menu/components/card/cardcellcomponent/index.jsx
+++ b/src/menu/components/card/cardcellcomponent/index.jsx
@@ -2,27 +2,27 @@
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
 import {connect} from 'react-redux'
-import { Modal, Button, notification } from 'antd'
+import { Modal, Button } from 'antd'
 
-import Api from '@/api'
-import options from '@/store/options.js'
 import zhCN from '@/locales/zh-CN/model.js'
 import enUS from '@/locales/en-US/model.js'
+import asyncComponent from '@/utils/asyncComponent'
 import { getCardCellForm } from './formconfig'
 import { getActionForm } from '@/menu/actioncomponent/formconfig'
 
 import MKEmitter from '@/utils/events.js'
 import ElementForm from './elementform'
 import DragElement from './dragaction'
-import ActionForm from '@/menu/actioncomponent/actionform'
-import CreateFunc from '@/templates/zshare/createfunc'
-import VerifyCard from '@/templates/zshare/verifycard'
-import VerifyPrint from '@/menu/actioncomponent/verifyprint'
-import VerifyExcelIn from '@/menu/actioncomponent/verifyexcelin'
-import VerifyExcelOut from '@/menu/actioncomponent/verifyexcelout'
 import './index.scss'
 
 const { confirm } = Modal
+
+const ActionForm = asyncComponent(() => import('@/menu/actioncomponent/actionform'))
+const CreateFunc = asyncComponent(() => import('@/templates/zshare/createfunc'))
+const VerifyCard = asyncComponent(() => import('@/templates/zshare/verifycard'))
+const VerifyPrint = asyncComponent(() => import('@/menu/actioncomponent/verifyprint'))
+const VerifyExcelIn = asyncComponent(() => import('@/menu/actioncomponent/verifyexcelin'))
+const VerifyExcelOut = asyncComponent(() => import('@/menu/actioncomponent/verifyexcelout'))
 
 class CardCellComponent extends Component {
   static propTpyes = {
@@ -40,7 +40,7 @@
     elements: null,      // 鎸夐挳缁�
     visible: false,      // 妯℃�佹鎺у埗
     actvisible: false,   // 鎸夐挳缂栬緫妯℃�佹
-    profVisible: false
+    profVisible: false,  // 楠岃瘉淇℃伅缂栬緫
   }
 
   /**
@@ -57,6 +57,7 @@
   componentDidMount () {
     MKEmitter.addListener('cardAddElement', this.cardAddElement)
     MKEmitter.addListener('submitStyle', this.getStyle)
+    MKEmitter.addListener('submitModal', this.handleSave)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -79,6 +80,8 @@
       return
     }
     MKEmitter.removeListener('cardAddElement', this.cardAddElement)
+    MKEmitter.removeListener('submitStyle', this.getStyle)
+    MKEmitter.removeListener('submitModal', this.handleSave)
   }
 
   cardAddElement = (ids, element) => {
@@ -97,10 +100,9 @@
     const { cards, cardCell } = this.props
 
     let _style = element.style ? fromJS(element.style).toJS() : {}
-    let options = ['font', 'border', 'padding', 'margin']
+    let options = ['font', 'border', 'padding', 'margin', 'backgroundColor']
 
     if (element.eleType === 'button') {
-      options.push('background')
       if (element.btnstyle) {
         _style = {..._style, ...element.btnstyle}
       }
@@ -127,7 +129,32 @@
 
     let _card = fromJS(card).toJS()
     
-    if (card.eleType === 'button') { // 鎷嗗垎style
+    if (_card.eleType === 'text' || _card.eleType === 'number' || _card.eleType === 'link') {
+      _card.style = style
+
+      let fontSize = 14
+      let lineHeight = 1.5
+      let line = _card.height || 1
+
+      if (_card.style.fontSize) {
+        fontSize = parseInt(_card.style.fontSize)
+      }
+      if (_card.style.lineHeight) {
+        lineHeight = parseFloat(_card.style.lineHeight)
+      }
+
+      _card.innerHeight = fontSize * lineHeight * line
+    } else if (_card.eleType === 'barcode') {
+      _card.style = style
+
+      let fontSize = 14
+
+      if (_card.style.fontSize) {
+        fontSize = parseInt(_card.style.fontSize)
+      }
+
+      _card.innerHeight = _card.barHeight + (_card.displayValue === 'true' ? fontSize + 2 : 0)
+    } else if (_card.eleType === 'button') { // 鎷嗗垎style
       let _style = fromJS(style).toJS()
       _card.style = {}
 
@@ -198,13 +225,15 @@
    * @description 鍏冪礌缂栬緫锛岃幏鍙栧厓绱犺〃鍗曚俊鎭�
    */
   handleElement = (card) => {
+    const { cards } = this.props
+
     if (card.eleType === 'button') {
       this.handleAction(card)
     } else {
       this.setState({
         visible: true,
         card: card,
-        formlist: getCardCellForm(card)
+        formlist: getCardCellForm(card, cards.type)
       })
     }
   }
@@ -215,82 +244,41 @@
   handleAction = (card) => {
     const { menu, cards } = this.props
 
-    let ableField = menu.permFuncField ? menu.permFuncField.join(', ') : ''
+    let usefulFields = sessionStorage.getItem('permFuncField')
+    if (usefulFields) {
+      try {
+        usefulFields = JSON.parse(usefulFields)
+      } catch {
+        usefulFields = []
+      }
+    } else {
+      usefulFields = []
+    }
+
+    let ableField = usefulFields.join(', ')
     let functip = <div>
       <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p>
       <p>{this.state.dict['model.tooltip.func.outface']}</p>
     </div>
 
-    let menulist = []
-    if (menu.fstMenuList) {
-      menulist = menu.fstMenuList.map(item => {
-        return {
-          value: item.MenuID,
-          label: item.text,
-          isLeaf: false
-        }
-      })
+    let menulist = sessionStorage.getItem('fstMenuList')
+    if (menulist) {
+      try {
+        menulist = JSON.parse(menulist)
+      } catch {
+        menulist = []
+      }
+    } else {
+      menulist = []
     }
 
     let modules = this.getModules(menu.components, cards.uuid)
 
-    if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) {
-      let _param = {
-        func: 'sPC_Get_FunMenu',
-        ParentID: card.linkmenu[0],
-        systemType: options.sysType,
-        debug: 'Y'
-      }
-  
-      Api.getSystemConfig(_param).then(result => {
-        if (result.status) {
-          menulist = menulist.map(item => {
-            if (item.value === card.linkmenu[0]) {
-              item.children = result.data.map(item => {
-                let submenu = {
-                  value: item.ParentID,
-                  label: item.MenuNameP,
-                  children: item.FunMenu.map(cell => {
-                    return {
-                      value: cell.MenuID,
-                      label: cell.MenuName,
-                      MenuID: cell.MenuID,
-                      MenuName: cell.MenuName,
-                      MenuNo: cell.MenuNo,
-                      Ot: cell.Ot,
-                      PageParam: cell.PageParam,
-                      LinkUrl: cell.LinkUrl,
-                      disabled: cell.MenuID === menu.MenuID
-                    }
-                  })
-                }
-
-                return submenu
-              })
-            }
-            return item
-          })
-        } else {
-          notification.warning({
-            top: 92,
-            message: result.message,
-            duration: 5
-          })
-        }
-
-        this.setState({
-          actvisible: true,
-          card: card,
-          formlist: getActionForm(card, functip, cards.setting, menu.permFuncField, 'card', menulist, modules)
-        })
-      })
-    } else {
-      this.setState({
-        actvisible: true,
-        card: card,
-        formlist: getActionForm(card, functip, cards.setting, menu.permFuncField, 'card', menulist, modules)
-      })
-    }
+    this.setState({
+      actvisible: true,
+      card: card,
+      formlist: getActionForm(card, functip, cards.setting, usefulFields, 'card', menulist, modules)
+    })
   }
 
   getModules = (components, selfId) => {
@@ -371,16 +359,40 @@
   handleSubmit = () => {
     const { elements } = this.state
 
-    this.elementFormRef.handleConfirm().then(ele => {
+    this.elementFormRef.handleConfirm().then(res => {
       let _elements = elements.map(cell => {
-        if (cell.uuid === ele.uuid) {
-          ele.style = cell.style || {}
-          if (ele.eleType === 'splitline' && cell.eleType !== 'splitline') {
-            ele.style.paddingTop = '5px'
-            ele.style.paddingBottom = '5px'
+        if (cell.uuid === res.uuid) {
+          res.style = cell.style || {}
+          if (res.eleType === 'splitline' && cell.eleType !== 'splitline') {
+            res.style.paddingTop = '5px'
+            res.style.paddingBottom = '5px'
+          } else if (res.eleType === 'text' || res.eleType === 'number' || res.eleType === 'link') {
+            let fontSize = 14
+            let lineHeight = 1.5
+            let line = res.height || 1
+      
+            if (res.style && res.style.fontSize) {
+              fontSize = parseInt(res.style.fontSize)
+            }
+            if (res.style && res.style.lineHeight) {
+              lineHeight = parseFloat(res.style.lineHeight)
+            }
+            res.innerHeight = fontSize * lineHeight * line
+
+            if (res.eleType === 'link' && !res.style.color) {
+              res.style.color = 'rgba(24, 144, 255, 1)'
+            }
+          } else if (res.eleType === 'barcode') {
+            let fontSize = 14
+      
+            if (res.style && res.style.fontSize) {
+              fontSize = parseInt(res.style.fontSize)
+            }
+      
+            res.innerHeight = res.barHeight + (res.displayValue === 'true' ? fontSize + 2 : 0)
           }
           
-          return ele
+          return res
         }
         return cell
       })
@@ -400,15 +412,13 @@
   handleActionSubmit = () => {
     const { elements } = this.state
 
-    this.actionFormRef.handleConfirm().then(ele => {
+    this.actionFormRef.handleConfirm().then(res => {
       let _elements = elements.map(cell => {
-        if (cell.uuid === ele.uuid) {
-          ele.eleType = 'button'
-          ele.style = cell.style || {}
-          ele.btnstyle = cell.btnstyle || {}
-          return ele
+        if (cell.uuid === res.uuid) {
+          res = {...cell, ...res}
+          delete res.focus
+          return res
         }
-
         return cell
       })
 
@@ -457,15 +467,12 @@
    * @description 楠岃瘉淇℃伅淇濆瓨
    */
   verifySubmit = () => {
-    const { elements } = this.state
-    
+    const { elements, card } = this.state
+
     this.verifyRef.handleConfirm().then(res => {
-      console.log(res)
       let _elements = elements.map(cell => {
-        if (cell.uuid === res.uuid) {
-          res.eleType = 'button'
-          res.style = cell.style || {}
-          return res
+        if (cell.uuid === card.uuid) {
+          cell.verify = res
         }
 
         return cell
@@ -473,10 +480,59 @@
 
       this.setState({
         elements: _elements,
-        actvisible: false
+        profVisible: false
       }, () => {
         this.props.updateElement(_elements)
       })
+    })
+  }
+
+  handleSubConfig = (item) => {
+    const { cards } = this.props
+
+    if (item.eleType !== 'button') return
+    if (item.OpenType === 'pop') {
+      let btn = fromJS(item).toJS()
+      if (!btn.modal) {
+        btn.modal = {
+          setting: {
+            title: btn.label,
+            width: 60,
+            cols: '2',
+            container: 'tab',
+            focus: '',
+            finish: 'close',
+            clickouter: 'unclose',
+            display: 'modal'
+          },
+          tables: [],
+          groups: [],
+          fields: []
+        }
+      }
+
+      MKEmitter.emit('changeModal', cards, btn)
+    }
+  }
+
+  handleSave = (_cards, btn, modal) => {
+    const { cards } = this.props
+    const { elements } = this.state
+
+    if (cards.uuid !== _cards.uuid) return
+
+    let _elements = elements.map(cell => {
+      if (cell.uuid === btn.uuid) {
+        cell.modal = modal
+      }
+
+      return cell
+    })
+
+    this.setState({
+      elements: _elements
+    }, () => {
+      this.props.updateElement(_elements)
     })
   }
 
@@ -492,6 +548,7 @@
           handleMenu={this.handleElement}
           handleStyle={this.handleStyle}
           profileAction={this.profileAction}
+          handleSubConfig={this.handleSubConfig}
           deleteMenu={this.deleteElement}
         />
         {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */}
@@ -552,7 +609,6 @@
         >
           {card && !card.execMode && card.OpenType !== 'excelIn' && card.OpenType !== 'excelOut' ?
             <VerifyCard
-              // floor={this.props.type}
               card={card}
               dict={dict}
               config={cards}

--
Gitblit v1.8.0