From 5d1e5dc9b248f91b33105dc838200af07947cdb2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 04 一月 2022 18:07:40 +0800
Subject: [PATCH] 2022-01-04

---
 src/tabviews/zshare/actionList/normalbutton/index.jsx |   50 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index af768ee..2adf417 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, Drawer } from 'antd'
+import { Button, Modal, notification, message, Drawer, Switch, Checkbox } from 'antd'
 
 import Api from '@/api'
 import Utils, { getSysDefaultSql } from '@/utils/utils.js'
@@ -47,7 +47,8 @@
     disabled: false,
     hidden: false,
     checkParam: null,
-    autoMatic: false
+    autoMatic: false,
+    check: false
   }
 
   moduleParams = null
@@ -78,6 +79,11 @@
     }
     if (this.props.disabled || disabled) {
       this.setState({disabled: true})
+    }
+    
+    if (btn.OpenType === 'form') {
+      let data = selectedData && selectedData[0] ? selectedData[0] : null
+      this.setState({check: data && data[btn.field] === btn.openVal})
     }
   }
 
@@ -130,6 +136,11 @@
       this.setState({disabled: true})
     } else {
       this.setState({disabled: false})
+    }
+
+    if (btn.OpenType === 'form') {
+      let data = nextProps.selectedData && nextProps.selectedData[0] ? nextProps.selectedData[0] : null
+      this.setState({check: data && data[btn.field] === btn.openVal})
     }
   }
 
@@ -312,6 +323,22 @@
       }, () => {
         this.improveAction()
       })
+    } else if (btn.OpenType === 'form') {
+      this.setState({
+        loading: true,
+        check: !this.state.check
+      }, () => {
+        let item = {
+          type: 'text',
+          readonly: false,
+          readin: true,
+          writein: true,
+          fieldlen: 50,
+          key: btn.field,
+          value: this.state.check ? btn.openVal : btn.closeVal
+        }
+        this.execSubmit(data, () => { this.setState({loading: false})}, [item])
+      })
     }
 
     if (window.GLOB.systemType === 'production') {
@@ -381,7 +408,7 @@
         }
 
         param.LText = Utils.formatOptions(param.LText)
-      } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 琛ㄥ崟
+      } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') { // 琛ㄥ崟
         if (btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid
           primaryId = ''
 
@@ -629,7 +656,7 @@
         param[setting.primaryKey] = primaryId // 璁剧疆涓婚敭鍙傛暟
       }
 
-      if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 琛ㄥ崟
+      if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') { // 琛ㄥ崟
         formdata.forEach(_data => {
           param[_data.key] = _data.value
         })
@@ -804,7 +831,7 @@
           param.BID = this.props.BID
         }
 
-        if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') && formdata) { // 琛ㄥ崟
+        if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') && formdata) { // 琛ㄥ崟
           formdata.forEach(_data => {
             param[_data.key] = _data.value
           })
@@ -1683,6 +1710,9 @@
       MKEmitter.emit('popclose')
     } else if (btn.execError !== 'never') {
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
+    } else if (btn.OpenType === 'form') {
+      let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null
+      this.setState({check: data && data[btn.field] === btn.openVal})
     }
   }
 
@@ -1989,11 +2019,17 @@
 
   render() {
     const { btn, show, style } = this.props
-    const { loadingNumber, loading, disabled, hidden } = this.state
+    const { loadingNumber, loading, disabled, hidden, check } = this.state
 
     if (hidden) return null
 
-    if (show === 'actionList') {
+    if (btn.OpenType === 'form') {
+      if (btn.formType === 'switch') {
+        return <Switch loading={loading} checked={check} disabled={disabled || loading} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={style} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/>
+      } else {
+        return <Checkbox disabled={disabled || loading} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={style}></Checkbox>
+      }
+    } else if (show === 'actionList') {
       return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
         <Button
           style={style}

--
Gitblit v1.8.0