From 6c66c9c2a6d0f7e7ccc65d4d9e478f1acb74d87e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 20 八月 2021 12:12:48 +0800
Subject: [PATCH] 2021-08-20

---
 src/tabviews/zshare/actionList/normalbutton/index.jsx |  152 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 103 insertions(+), 49 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 2fc84a8..8aac0c2 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -3,7 +3,7 @@
 import moment from 'moment'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { Button, Modal, notification, message } from 'antd'
+import { Button, Modal, notification, message, Drawer, Icon } from 'antd'
 
 import Api from '@/api'
 import Utils, { getSysDefaultSql } from '@/utils/utils.js'
@@ -70,9 +70,8 @@
   componentDidMount () {
     const { position } = this.props
 
-    if (position === 'toolbar') {
-      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
-    } else if (position === 'form') {
+    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
+    if (position === 'form') {
       MKEmitter.addListener('triggerFormSubmit', this.actionSubmit)
     }
     MKEmitter.addListener('returnModuleParam', this.resetModuleParam)
@@ -866,7 +865,7 @@
     })
 
     Api.directRequest(url, btn.method, param, btn.cross).then(res => {
-      if (typeof(res) !== 'object' || Array.isArray(res)) {
+      if (typeof(res) !== 'object') {
         let error = '鏈煡鐨勮繑鍥炵粨鏋滐紒'
 
         if (typeof(res) === 'string') {
@@ -881,6 +880,9 @@
 
         this.customCallbackRequest(params, result, record, _resolve)
       } else {
+        if (Array.isArray(res)) {
+          res = { data: res }
+        }
         res.mk_api_key = mkey
         this.customCallbackRequest(params, res, record, _resolve)
       }
@@ -1691,51 +1693,87 @@
 
     let title = btnconfig.setting.title
     let width = btnconfig.setting.width + 'vw'
-    let clickouter = false
-    let container = document.body
+    let clickouter = btnconfig.setting.clickouter === 'close'
 
-    if (
-      (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) ||
-      (btnconfig.setting.container === 'tab' && btn.ContainerId)
-    ) {
-      width = btnconfig.setting.width + '%'
-      container = () => document.getElementById(this.props.ContainerId || btn.ContainerId)
+    if (btnconfig.setting.display === 'drawer') {
+      let height = '100vh'
+      if (btnconfig.setting.placement === 'top' || btnconfig.setting.placement === 'bottom') {
+        width = '100vw'
+        height = btnconfig.setting.width + 'vh'
+      }
+      return (
+        <Drawer
+          title={title}
+          width={width}
+          height={height}
+          maskClosable={clickouter}
+          onClose={this.handleCancel}
+          visible={visible}
+          placement={btnconfig.setting.placement || 'right'}
+          bodyStyle={{ paddingBottom: 80 }}
+          destroyOnClose
+        >
+          <MutilForm
+            BID={BID}
+            dict={this.state.dict}
+            menuType={this.props.menuType}
+            action={btnconfig}
+            inputSubmit={this.handleOk}
+            data={this.state.tabledata[0]}
+            BData={this.props.BData}
+            wrappedComponentRef={(inst) => this.formRef = inst}
+          />
+          <div style={{ position: 'absolute', zIndex: 1, right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right'}}>
+            <Button onClick={this.handleCancel} style={{ marginRight: 8 }}>
+              鍙栨秷
+            </Button>
+            <Button onClick={this.handleOk} loading={this.state.confirmLoading} type="primary">
+              纭畾
+            </Button>
+          </div>
+        </Drawer>
+      )
+    } else {
+      let container = document.body
+
+      if (
+        (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) ||
+        (btnconfig.setting.container === 'tab' && btn.ContainerId)
+      ) {
+        width = btnconfig.setting.width + '%'
+        container = () => document.getElementById(this.props.ContainerId || btn.ContainerId)
+      }
+      return (
+        <Modal
+          title={title}
+          maskClosable={clickouter}
+          getContainer={container}
+          wrapClassName='action-modal'
+          visible={visible}
+          width={width}
+          onOk={this.handleOk}
+          confirmLoading={this.state.confirmLoading}
+          onCancel={this.handleCancel}
+          destroyOnClose
+        >
+          <MutilForm
+            BID={BID}
+            dict={this.state.dict}
+            menuType={this.props.menuType}
+            action={btnconfig}
+            inputSubmit={this.handleOk}
+            data={this.state.tabledata[0]}
+            BData={this.props.BData}
+            wrappedComponentRef={(inst) => this.formRef = inst}
+          />
+        </Modal>
+      )
     }
-
-    if (btnconfig.setting.clickouter === 'close') {
-      clickouter = true
-    }
-
-    return (
-      <Modal
-        title={title}
-        maskClosable={clickouter}
-        getContainer={container}
-        wrapClassName='action-modal'
-        visible={visible}
-        width={width}
-        onOk={this.handleOk}
-        confirmLoading={this.state.confirmLoading}
-        onCancel={this.handleCancel}
-        destroyOnClose
-      >
-        <MutilForm
-          BID={BID}
-          dict={this.state.dict}
-          menuType={this.props.menuType}
-          action={btnconfig}
-          inputSubmit={this.handleOk}
-          data={this.state.tabledata[0]}
-          BData={this.props.BData}
-          wrappedComponentRef={(inst) => this.formRef = inst}
-        />
-      </Modal>
-    )
   }
 
   render() {
     const { btn, show, style } = this.props
-    const { loadingNumber, loading, visible, disabled } = this.state
+    const { loadingNumber, loading, disabled } = this.state
 
     if (show === 'actionList') {
       return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
@@ -1747,7 +1785,7 @@
           className={'mk-btn mk-' + btn.class}
           onClick={() => {this.actionTrigger()}}
         >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button>
-        {visible ? this.getModels() : null}
+        {this.getModels()}
       </div>
     } else if (show && show.indexOf('plus') > -1) {
       return <div className="mk-btn-wrap">
@@ -1758,9 +1796,25 @@
           style={{fontSize: show.substring(4) + 'px'}}
           onClick={() => {this.actionTrigger()}}
         ></Button>
-        {visible ? this.getModels() : null}
+        {this.getModels()}
       </div>
     } else { // icon銆乼ext銆� all 鍗$墖
+      let label = ''
+      let icon = ''
+
+      if (show === 'button') {
+        label = btn.label
+        icon = btn.icon || ''
+      } else if (show === 'link') {
+        label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
+        icon = ''
+      } else if (show === 'icon') {
+        icon = btn.icon || ''
+      // } else if (show === 'text') {
+      } else {
+        label = btn.label
+      }
+
       return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
         <Button
           type="link"
@@ -1768,10 +1822,10 @@
           loading={loading}
           disabled={disabled}
           style={btn.style || style}
-          icon={show === 'text' ? '' : (btn.icon || '')}
+          icon={icon}
           onClick={() => {this.actionTrigger()}}
-        >{show === 'icon' && btn.icon ? '' : btn.label}</Button>
-        {visible ? this.getModels() : null}
+        >{label}</Button>
+        {this.getModels()}
       </div>
     }
   }

--
Gitblit v1.8.0