From 5891206952e2ff63e87aed2f47df5324b019d32e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 25 十月 2022 00:39:38 +0800
Subject: [PATCH] 2022-10-25

---
 src/menu/components/form/formaction/index.jsx |  139 ++++++++++++++++++++++++----------------------
 1 files changed, 72 insertions(+), 67 deletions(-)

diff --git a/src/menu/components/form/formaction/index.jsx b/src/menu/components/form/formaction/index.jsx
index ba84729..c76bdcc 100644
--- a/src/menu/components/form/formaction/index.jsx
+++ b/src/menu/components/form/formaction/index.jsx
@@ -1,13 +1,12 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { connect } from 'react-redux'
-import { Modal, Button, Popover, Icon } from 'antd'
+import { Modal, Button, Popover } from 'antd'
+import { FontColorsOutlined, EditOutlined, ProfileOutlined } from '@ant-design/icons'
 
-import zhCN from '@/locales/zh-CN/model.js'
-import enUS from '@/locales/en-US/model.js'
 import asyncComponent from '@/utils/asyncComponent'
 import { getActionForm } from './formconfig'
+import { resetStyle } from '@/utils/utils-custom.js'
 
 import MKEmitter from '@/utils/events.js'
 import MenuUtils from '@/utils/utils-custom.js'
@@ -23,22 +22,11 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
+    appType: sessionStorage.getItem('appType'),
     card: null,          // 缂栬緫涓厓绱�
     formlist: null,      // 琛ㄥ崟淇℃伅
     visible: false,      // 妯℃�佹鎺у埗
     profVisible: false,  // 楠岃瘉淇℃伅缂栬緫
-  }
-
-  /**
-   * @description 鎼滅储鏉′欢鍒濆鍖�
-   */
-  UNSAFE_componentWillMount () {
-
-  }
-
-  componentDidMount () {
-    MKEmitter.addListener('submitStyle', this.getStyle)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -52,32 +40,28 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('submitStyle', this.getStyle)
   }
 
   handleStyle = (element) => {
-    const { group } = this.props
-
     let _style = element.style ? fromJS(element.style).toJS() : {}
-    let options = ['font', 'border', 'padding', 'margin', 'backgroundColor']
+    let options = ['font', 'border', 'padding', 'margin', 'backgroundColor', 'width']
 
     this.setState({
       card: element
     })
 
-    MKEmitter.emit('changeStyle', [group.uuid, element.type], options, _style)
+    MKEmitter.emit('changeStyle', options, _style, this.getStyle)
   }
 
-  getStyle = (comIds, style) => {
+  getStyle = (style) => {
+    const { card } = this.state
     let group = fromJS(this.props.group).toJS()
 
-    if (comIds.length !== 2 || comIds[0] !== group.uuid) return
-
-    if (comIds[1] === 'prev') {
+    if (card.type === 'prev') {
       group.prevButton.style = style
-    } else if (comIds[1] === 'submit') {
+    } else if (card.type === 'submit') {
       group.subButton.style = style
-    } else if (comIds[1] === 'next') {
+    } else if (card.type === 'next') {
       group.nextButton.style = style
     }
 
@@ -88,13 +72,13 @@
    * @description 鎸夐挳缂栬緫锛岃幏鍙栨寜閽〃鍗曚俊鎭�
    */
   handleAction = (card) => {
-    const { menu, config } = this.props
+    const { config } = this.props
 
     let usefulFields = sessionStorage.getItem('permFuncField')
     if (usefulFields) {
       try {
         usefulFields = JSON.parse(usefulFields)
-      } catch {
+      } catch (e) {
         usefulFields = []
       }
     } else {
@@ -102,16 +86,27 @@
     }
 
     let ableField = usefulFields.join(', ')
+    let msg = `鍑芥暟鍚嶇О闇�浠�${ableField}绛夊瓧绗﹀紑濮�;`
     let functip = <div>
-      <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p>
+      <p style={{marginBottom: '5px'}}>{msg}</p>
     </div>
 
-    let modules = MenuUtils.getSubModules(menu.components, config.uuid)
+    let supId = ''
+    if (config.wrap.linkType === 'sup') {
+      supId = config.wrap.supModule[config.wrap.supModule.length - 1]
+    }
+
+    let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, config.uuid, supId)
+    let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, config.uuid) || []
+
+    if (card.type === 'submit' && !card.Ot) {
+      card.Ot = config.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl'
+    }
 
     this.setState({
       visible: true,
       card: card,
-      formlist: getActionForm(card, functip, config.setting.tableName, usefulFields, modules)
+      formlist: getActionForm(card, functip, config.setting.tableName, usefulFields, modules, anchors)
     })
   }
 
@@ -180,52 +175,66 @@
     })
   }
 
+  changeMenu = () => {
+    const { appType } = this.state
+    const { group } = this.props
+
+    if (appType !== 'pc' && appType !== 'mob') return
+    if (!group.subButton.linkmenu) return
+
+    MKEmitter.emit('changeEditMenu', {
+      MenuID: group.subButton.linkmenu,
+      copyMenuId: '',
+      MenuNo: '',
+      MenuName: '',
+    })
+  }
+
   render() {
     const { group, config } = this.props
-    const { visible, profVisible, card, dict } = this.state
+    const { visible, profVisible, card } = this.state
 
     return (
       <div className="mk-form-action">
-        {group.sort !== 1 ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
+        {group.prevButton && group.prevButton.enable !== 'false' && group.sort !== 1 ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
-            <Icon className="edit" title="缂栬緫" type="edit" onClick={() => this.handleAction(group.prevButton)} />
-            <Icon className="style" title="璋冩暣鏍峰紡" onClick={() => this.handleStyle(group.prevButton)} type="font-colors" />
+            <EditOutlined className="edit" title="缂栬緫" onClick={() => this.handleAction(group.prevButton)} />
+            <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={() => this.handleStyle(group.prevButton)}/>
           </div>
         } trigger="hover">
-          <Button type="link" className="prev" style={group.prevButton.style}>{group.prevButton.label}</Button>
+          <Button type="link" className="prev" style={resetStyle(group.prevButton.style)}>{group.prevButton.label}</Button>
         </Popover> : null}
         <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
-            <Icon className="edit" title="缂栬緫" type="edit" onClick={() => this.handleAction(group.subButton)} />
-            <Icon className="style" title="璋冩暣鏍峰紡" onClick={() => this.handleStyle(group.subButton)} type="font-colors" />
-            <Icon className="profile" title="setting" type="profile" onClick={() => this.profileAction()} />
+            <EditOutlined className="edit" title="缂栬緫" onClick={() => this.handleAction(group.subButton)} />
+            <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={() => this.handleStyle(group.subButton)}/>
+            <ProfileOutlined className="profile" title="setting" onClick={() => this.profileAction()} />
           </div>
         } trigger="hover">
-          <Button type="link" className="submit mk-primary" style={group.subButton.style}>{group.subButton.label}</Button>
+          <Button type="link" className="submit mk-primary" onDoubleClick={this.changeMenu} style={resetStyle(group.subButton.style)}>{group.subButton.label}</Button>
         </Popover>
-        {group.sort !== config.subcards.length ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
+        {group.nextButton && group.nextButton.enable !== 'false' && group.sort !== config.subcards.length ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
-            <Icon className="edit" title="缂栬緫" type="edit" onClick={() => this.handleAction(group.nextButton)} />
-            <Icon className="style" title="璋冩暣鏍峰紡" onClick={() => this.handleStyle(group.nextButton)} type="font-colors" />
+            <EditOutlined className="edit" title="缂栬緫" onClick={() => this.handleAction(group.nextButton)} />
+            <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={() => this.handleStyle(group.nextButton)}/>
           </div>
         } trigger="hover">
-          <Button type="link" className={'skip ' + group.nextButton.enable} style={group.nextButton.style}>{group.nextButton.label}</Button>
+          <Button type="link" className="skip" style={resetStyle(group.nextButton.style)}>{group.nextButton.label}</Button>
         </Popover> : null}
         {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */}
         <Modal
-          title={dict['model.edit']}
+          title="缂栬緫"
           visible={visible}
-          width={800}
+          width={920}
           maskClosable={false}
           onCancel={this.editModalCancel}
           footer={[
-            <Button key="cancel" onClick={this.editModalCancel}>{dict['model.cancel']}</Button>,
-            <Button key="confirm" type="primary" onClick={this.handleActionSubmit}>{dict['model.confirm']}</Button>
+            <Button key="cancel" onClick={this.editModalCancel}>鍙栨秷</Button>,
+            <Button key="confirm" type="primary" onClick={this.handleActionSubmit}>纭畾</Button>
           ]}
           destroyOnClose
         >
           <ActionForm
-            dict={dict}
             card={card}
             setting={config.setting}
             formlist={this.state.formlist}
@@ -235,19 +244,25 @@
         </Modal>
         {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */}
         <Modal
-          wrapClassName="model-table-action-verify-modal"
-          title={'楠岃瘉淇℃伅'}
+          wrapClassName="mk-pop-modal"
           visible={profVisible}
-          width={'75vw'}
+          width={'90vw'}
           maskClosable={false}
-          okText={dict['model.submit']}
+          okText="鎻愪氦"
           onOk={this.verifySubmit}
-          onCancel={() => { this.setState({ profVisible: false }) }}
+          onCancel={() => {
+            if (this.verifyRef.handleCancel) {
+              this.verifyRef.handleCancel().then(() => {
+                this.setState({ profVisible: false })
+              })
+            } else {
+              this.setState({ profVisible: false })
+            }
+          }}
           destroyOnClose
         >
           <VerifyCard
             card={{...group.subButton, modal: {fields: group.fields}}}
-            dict={dict}
             config={config}
             columns={config.columns}
             wrappedComponentRef={(inst) => this.verifyRef = inst}
@@ -258,14 +273,4 @@
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    menu: state.customMenu
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(CardCellComponent)
\ No newline at end of file
+export default CardCellComponent
\ No newline at end of file

--
Gitblit v1.8.0