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/custom/components/card/cardcellList/asyncButtonComponent.jsx |    7 -
 src/tabviews/custom/components/card/cardcellList/index.jsx                |    2 
 src/menu/components/share/actioncomponent/actionform/index.jsx            |   78 +++++++++++++--
 src/menu/components/card/cardcellcomponent/index.jsx                      |   16 ++
 src/tabviews/custom/components/card/cardcellList/index.scss               |    5 
 src/templates/zshare/formconfig.jsx                                       |    6 
 src/menu/components/share/actioncomponent/formconfig.jsx                  |   76 +++++++++++++++
 src/menu/components/card/cardcellcomponent/index.scss                     |    5 
 src/tabviews/zshare/actionList/normalbutton/index.jsx                     |   50 ++++++++-
 src/templates/zshare/verifycard/index.jsx                                 |    9 +
 src/menu/components/card/cardcellcomponent/dragaction/action.jsx          |   12 +
 11 files changed, 225 insertions(+), 41 deletions(-)

diff --git a/src/menu/components/card/cardcellcomponent/dragaction/action.jsx b/src/menu/components/card/cardcellcomponent/dragaction/action.jsx
index 7b28f71..346ad40 100644
--- a/src/menu/components/card/cardcellcomponent/dragaction/action.jsx
+++ b/src/menu/components/card/cardcellcomponent/dragaction/action.jsx
@@ -1,6 +1,6 @@
 import React from 'react'
 import { useDrag, useDrop } from 'react-dnd'
-import { Popover, Button } from 'antd'
+import { Popover, Button, Switch, Checkbox } from 'antd'
 import { EditOutlined, CopyOutlined, CloseOutlined, FontColorsOutlined, ProfileOutlined } from '@ant-design/icons'
 
 import { resetStyle } from '@/utils/utils-custom.js'
@@ -30,7 +30,7 @@
   })
 
   let hasProfile = false
-  if (['pop', 'prompt', 'exec'].includes(card.OpenType)) {
+  if (['pop', 'prompt', 'exec', 'form'].includes(card.OpenType)) {
     hasProfile = true
   } else if (card.OpenType === 'excelIn' || card.OpenType === 'excelOut') {
     hasProfile = true
@@ -40,7 +40,13 @@
 
   let btnElement = null
   let _style = resetStyle(card.style)
-  if (card.show === 'icon') {
+  if (card.OpenType === 'form') {
+    if (card.formType === 'switch') {
+      btnElement = (<Switch style={_style} size={card.size} checkedChildren={card.openText || ''} unCheckedChildren={card.closeText || ''}/>)
+    } else {
+      btnElement = (<Checkbox style={_style}></Checkbox>)
+    }
+  } else if (card.show === 'icon') {
     btnElement = (<Button style={_style} type="link"><MkIcon type={card.icon}/></Button>)
   } else if (card.show === 'link') {
     btnElement = (<Button style={_style} type="link">{card.label}{card.icon ? <MkIcon type={card.icon}/> : null}</Button>)
diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx
index ddfe3a1..8239471 100644
--- a/src/menu/components/card/cardcellcomponent/index.jsx
+++ b/src/menu/components/card/cardcellcomponent/index.jsx
@@ -145,7 +145,11 @@
     let options = ['font', 'border', 'padding', 'margin', 'background']
 
     if (element.eleType === 'button') {
-      options.push('width', 'float')
+      if (element.OpenType === 'form') {
+        options = ['margin', 'float']
+      } else {
+        options.push('width', 'float')
+      }
     } else if (element.eleType === 'picture') {
       options = ['border', 'margin']
     } else if (element.eleType === 'slider') {
@@ -406,9 +410,13 @@
           }
           
           delete res.focus
-          let style = {}
 
-          if (res.class !== cell.class || res.show !== cell.show || !res.style) {
+          if (res.OpenType === 'form') {
+            if (cell.OpenType !== 'form') {
+              res.style = {}
+            }
+          } else if (res.class !== cell.class || res.show !== cell.show || !res.style) {
+            let style = {}
             if (res.show === 'link' || res.show === 'icon') {
               style.color = color[res.class]
               style.backgroundColor = 'transparent'
@@ -416,8 +424,8 @@
               style.color = '#ffffff'
               style.backgroundColor = color[res.class]
             }
+            res.style = {...res.style, ...style}
           }
-          res.style = {...res.style, ...style}
 
           return res
         }
diff --git a/src/menu/components/card/cardcellcomponent/index.scss b/src/menu/components/card/cardcellcomponent/index.scss
index 855eaae..5478f4a 100644
--- a/src/menu/components/card/cardcellcomponent/index.scss
+++ b/src/menu/components/card/cardcellcomponent/index.scss
@@ -6,7 +6,7 @@
 
   .card-button-cell {
     float: left;
-    button {
+    button:not(.ant-switch) {
       width: 100%;
       background-size: cover;
       background-position: center center;
@@ -20,6 +20,9 @@
         font-weight: inherit;
       }
     }
+    .ant-checkbox .ant-checkbox-inner {
+      border-radius: 15px;
+    }
   }
   .card-cell:hover, .card-button-cell:hover {
     box-shadow: 0px 0px 1px #1890ff;
diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx
index dce21d6..e9500ee 100644
--- a/src/menu/components/share/actioncomponent/actionform/index.jsx
+++ b/src/menu/components/share/actioncomponent/actionform/index.jsx
@@ -19,7 +19,8 @@
   popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'color', 'popClose', 'resetPageIndex', 'width', 'display', 'ratio', 'syncComponent', 'clickouter'],
   tab: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'color', 'linkmenu', 'width'],
   innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'show', 'swipe', 'icon', 'class', 'color', 'width', 'open'],
-  funcbutton: ['label', 'OpenType', 'funcType', 'show', 'swipe', 'icon', 'class', 'color', 'width']
+  funcbutton: ['label', 'OpenType', 'funcType', 'show', 'swipe', 'icon', 'class', 'color', 'width'],
+  form: ['label', 'OpenType', 'formType', 'intertype', 'Ot', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'open', 'refreshTab', 'reload', 'title']
 }
 
 class ActionForm extends Component {
@@ -38,13 +39,13 @@
     requireOptions: [],
     insertUpdateOptions: [{
       value: 'insert',
-      text: this.props.dict['header.form.action.insert']
+      text: '娣诲姞'
     }, {
       value: 'update',
-      text: this.props.dict['header.form.action.update']
+      text: '淇敼'
     }, {
       value: 'audit',
-      text: this.props.dict['header.form.action.audit']
+      text: '瀹℃牳'
     }],
     deleteOptions: [{
       value: 'LogicDelete',
@@ -54,7 +55,7 @@
       text: '鐗╃悊鍒犻櫎'
     }, {
       value: 'custom',
-      text: this.props.dict['header.form.custom']
+      text: '鑷畾涔�'
     }],
     interTypeOptions: [{
       value: 'system',
@@ -197,6 +198,43 @@
       } else {
         reOptions.sqlType = this.state.insertUpdateOptions
       }
+    } else if (openType === 'form') {
+      let intertype = this.record.intertype
+
+      if (this.record.formType === 'switch') {
+        shows.push('field', 'size', 'openVal', 'closeVal', 'openText', 'closeText')
+      } else {
+        shows.push('field', 'openVal', 'closeVal')
+      }
+
+      reOptions.intertype = this.state.interTypeOptions.filter(item => item.value !== 'custom')
+
+      if (intertype === 'outer') {
+        shows.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackFunc')
+        reRequired.innerFunc = false
+
+        if (this.record.sysInterface === 'false') {
+          reReadonly.interface = false
+          reRequired.interface = true
+        } else {
+          reReadonly.interface = true
+          reRequired.interface = false
+        }
+      } else if (intertype === 'inner') {
+        shows.push('innerFunc')
+        reRequired.innerFunc = true
+      } else {
+        shows.push('sql', 'sqlType')
+      }
+
+      reOptions.Ot = requireOptions
+      reOptions.sqlType = [{
+        value: 'update',
+        text: '淇敼'
+      }, {
+        value: 'custom',
+        text: '鑷畾涔�'
+      }]
     } else if (openType === 'excelIn') {
       reOptions.intertype = this.state.interTypeOptions.filter(op => op.value !== 'custom')
       reOptions.Ot = requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value))
@@ -375,6 +413,10 @@
         _fieldval.intertype = 'system'
         _fieldval.sqlType = ''
   
+      } else if (value === 'form') {
+        _fieldval.Ot = 'requiredSgl'
+
+        this.record.Ot = 'requiredSgl'
       } else if (value === 'excelIn') {
         _fieldval.intertype = 'system'
         _fieldval.Ot = 'notRequired'
@@ -446,10 +488,12 @@
       } else if (value === 'update') {
         _fieldval.label = '淇敼'
         _fieldval.Ot = 'requiredSgl'
-        if (hasclass) {
-          _fieldval.class = 'purple'
-        } else {
-          _fieldval.color = 'primary'
+        if (this.record.OpenType !== 'form') {
+          if (hasclass) {
+            _fieldval.class = 'purple'
+          } else {
+            _fieldval.color = 'primary'
+          }
         }
       } else if (value === 'audit') {
         _fieldval.label = '瀹℃牳'
@@ -469,10 +513,10 @@
         }
       }
 
-      this.record.label = _fieldval.label
-      this.record.Ot = _fieldval.Ot
-      this.record.class = _fieldval.class || ''
-      this.record.color = _fieldval.color || ''
+      this.record.label = _fieldval.label || this.record.label || ''
+      this.record.Ot = _fieldval.Ot || this.record.Ot || ''
+      this.record.class = _fieldval.class || this.record.class || ''
+      this.record.color = _fieldval.color || this.record.color || ''
 
       if (appType !== 'mob' && _fieldval.Ot === 'notRequired') {
         this.record.control = ''
@@ -549,6 +593,14 @@
       let content = null
       let initVal = item.initVal || ''
 
+      if (item.type === 'splitLine') {
+        fields.push(
+          <Col span={24} key={index}>
+            <p style={{borderBottom: '1px solid #e9e9e9', color: '#1890ff', textAlign: 'center'}}>{item.label}</p>
+          </Col>
+        )
+        return
+      }
       if (item.type === 'text') {
         rules = [
           { required: item.required, message: dict['form.required.input'] + item.label + '!' }
diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx
index 248d1f0..76624c4 100644
--- a/src/menu/components/share/actioncomponent/formconfig.jsx
+++ b/src/menu/components/share/actioncomponent/formconfig.jsx
@@ -146,6 +146,13 @@
     })
   }
 
+  if (type === 'card') {
+    opentypes.push({
+      value: 'form',
+      text: '琛ㄥ崟'
+    })
+  }
+
   if (!card.control && card.controlField) {
     card.control = 'disabled'
   }
@@ -169,6 +176,20 @@
       initVal: card.funcType || '',
       required: true,
       options: funTypes
+    },
+    {
+      type: 'radio',
+      key: 'formType',
+      label: '琛ㄥ崟绫诲瀷',
+      initVal: card.formType || 'switch',
+      required: true,
+      options: [{
+        value: 'switch',
+        text: '寮�鍏�'
+      }, {
+        value: 'radio',
+        text: '鍕鹃�夋'
+      }]
     },
     {
       type: 'select',
@@ -766,6 +787,61 @@
       initVal: card.controlVal || '',
       required: false
     },
+    {
+      type: 'splitLine',
+      key: 'title',
+      label: '琛ㄥ崟',
+      initVal: ''
+    },
+    {
+      type: 'text',
+      key: 'field',
+      label: Formdict['model.form.field'],
+      initVal: card.field || '',
+      required: true,
+      readonly: false
+    },
+    {
+      type: 'radio',
+      key: 'size',
+      label: '寮�鍏冲昂瀵�',
+      initVal: card.size || 'default',
+      options: [{
+        value: 'default',
+        text: '澶�'
+      }, {
+        value: 'small',
+        text: '灏�'
+      }]
+    },
+    {
+      type: 'text',
+      key: 'openVal',
+      label: '寮�鍚��',
+      initVal: card.openVal || '',
+      required: false
+    },
+    {
+      type: 'text',
+      key: 'closeVal',
+      label: '鍏抽棴鍊�',
+      initVal: card.closeVal || '',
+      required: false
+    },
+    {
+      type: 'text',
+      key: 'openText',
+      label: '寮�鍚彁绀�',
+      initVal: card.openText || '',
+      required: false,
+    },
+    {
+      type: 'text',
+      key: 'closeText',
+      label: '鍏抽棴鎻愮ず',
+      initVal: card.closeText || '',
+      required: false,
+    },
   ]
 
   return forms
diff --git a/src/tabviews/custom/components/card/cardcellList/asyncButtonComponent.jsx b/src/tabviews/custom/components/card/cardcellList/asyncButtonComponent.jsx
index 9c160c8..b4313e8 100644
--- a/src/tabviews/custom/components/card/cardcellList/asyncButtonComponent.jsx
+++ b/src/tabviews/custom/components/card/cardcellList/asyncButtonComponent.jsx
@@ -1,6 +1,4 @@
 import React, {Component} from 'react'
-import { Button } from 'antd'
-
 /**
  * @description 寮傛鍔犺浇妯″潡
  * @param {*} importComponent
@@ -24,11 +22,8 @@
     // <Button className="loading-skeleton" disabled={true}></Button> // 楠ㄦ灦鎸夐挳
     render() {
       const C = this.state.component
-      const btn = this.props.btn || {}
 
-      return C ?
-        <C {...this.props} /> :
-        <Button className={'mk-btn mk-' + btn.class} type={btn.show !== 'button' ? 'link' : ''} icon={btn.icon} disabled={true} >{btn.label}</Button>
+      return C ? <C {...this.props} /> : null
     }
   }
 }
\ No newline at end of file
diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx
index 3798bd6..e3da235 100644
--- a/src/tabviews/custom/components/card/cardcellList/index.jsx
+++ b/src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -665,7 +665,7 @@
         _data = this.props.syncData
       }
 
-      if (['exec', 'prompt', 'pop'].includes(card.OpenType)) {
+      if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) {
         return (
           <Col key={card.uuid} className="mk-cell-btn" span={card.width}>
             <NormalButton
diff --git a/src/tabviews/custom/components/card/cardcellList/index.scss b/src/tabviews/custom/components/card/cardcellList/index.scss
index 0a10c7a..5ca1d4a 100644
--- a/src/tabviews/custom/components/card/cardcellList/index.scss
+++ b/src/tabviews/custom/components/card/cardcellList/index.scss
@@ -59,12 +59,15 @@
   }
   .mk-cell-btn {
     > div {width: 100%;max-width: 100%;}
-    button {
+    button:not(.ant-switch) {
       width: 100%;
       max-width: 100%;
       height: auto;
       min-height: 28px;
     }
+    .ant-checkbox-inner, .ant-checkbox-checked::after {
+      border-radius: 15px;
+    }
   }
   .ant-mk-slider {
     box-sizing: border-box;
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}
diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx
index 1d50873..b8f5a45 100644
--- a/src/templates/zshare/formconfig.jsx
+++ b/src/templates/zshare/formconfig.jsx
@@ -2428,16 +2428,14 @@
       key: 'openText',
       label: '寮�鍚彁绀�',
       initVal: card.openText || '',
-      required: false,
-      forbid: appType === 'mob'
+      required: false
     },
     {
       type: 'text',
       key: 'closeText',
       label: '鍏抽棴鎻愮ず',
       initVal: card.closeText || '',
-      required: false,
-      forbid: appType === 'mob'
+      required: false
     },
     {
       type: 'radio',
diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx
index 9641563..6a3ecb5 100644
--- a/src/templates/zshare/verifycard/index.jsx
+++ b/src/templates/zshare/verifycard/index.jsx
@@ -595,7 +595,14 @@
 
     new Promise(resolve => {
       let _fields = []
-      if (config.Template === 'FormTab') {
+      if (card.OpenType === 'form') {
+        _fields.push({
+          field: card.field,
+          label: card.label,
+          type: 'text'
+        })
+        resolve(_fields)
+      } else if (config.Template === 'FormTab') {
         config.groups.forEach(group => {
           _fields.push(...group.sublist)
         })

--
Gitblit v1.8.0