From eb257a16632071469479fd13a93dceddc289d338 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 09 十月 2019 09:43:26 +0800
Subject: [PATCH] 2019-10-09update

---
 src/components/mainAction/index.jsx |  101 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 98 insertions(+), 3 deletions(-)

diff --git a/src/components/mainAction/index.jsx b/src/components/mainAction/index.jsx
index f99b8fb..49dc310 100644
--- a/src/components/mainAction/index.jsx
+++ b/src/components/mainAction/index.jsx
@@ -2,6 +2,7 @@
 import PropTypes from 'prop-types'
 // import { is, fromJS } from 'immutable'
 import { Button, Affix, Modal, notification } from 'antd'
+import MutilForm from '@/components/mutilform'
 import Api from '@/api'
 import './index.scss'
 
@@ -16,7 +17,11 @@
   }
 
   state = {
-
+    visible: false,
+    formdata: null,
+    tabledata: null,
+    confirmLoading: false,
+    execAction: null
   }
   
   refreshdata = () => {
@@ -24,14 +29,30 @@
   }
   actionTrigger = (item) => {
     let _this = this
-    let data = this.props.gettableselected()
-    if (item.Ot === 'required' && (!data || data.length === 0)) {
+    let data = this.props.gettableselected() || []
+    if (item.Ot === 'required' && data.length === 0) {
       // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹�
       notification.warning({
         top: 92,
         message: this.props.dict['main.action.confirm.selectline']
       })
       return
+    } else if (item.Ot === 'pop' && data.length !== 1) {
+      if (data.length === 0) {
+        // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹�
+        notification.warning({
+          top: 92,
+          message: this.props.dict['main.action.confirm.selectline']
+        })
+        return
+      } else {
+        // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁
+        notification.warning({
+          top: 92,
+          message: this.props.dict['main.action.confirm.selectSingleLine']
+        })
+        return
+      }
     }
 
     if (item.Action === 'Prompt' || item.Action === 'Delete') {
@@ -60,7 +81,80 @@
         },
         onCancel() {}
       })
+    } else if (item.Action === 'Update') {
+      Api.getModelFormData(item.MenuID).then(res => {
+        if (res.status) {
+          this.setState({
+            formdata: res.data.map(input => {
+              let validate = input.Validate && JSON.parse(input.Validate)
+              input.DynOptions = JSON.parse(input.DynOptions)
+              input.required = (validate && validate.required) || false
+              return input
+            }),
+            visible: true,
+            execAction: item,
+            tabledata: data[0]
+          })
+        }
+      })
     }
+  }
+
+  getModels = () => {
+    return (
+      <Modal
+        wrapClassName='action-modal'
+        title={(this.state.execAction && this.state.execAction.MenuName) || ''}
+        visible={this.state.visible}
+        width={(this.state.execAction && +this.state.execAction.PopWidth) || 520}
+        onOk={this.handleOk}
+        confirmLoading={this.state.confirmLoading}
+        onCancel={this.handleCancel}
+      >
+        {this.state.formdata &&
+          <MutilForm
+            dict={this.props.dict}
+            formlist={this.state.formdata}
+            data={this.state.tabledata}
+            wrappedComponentRef={(inst) => this.formRef = inst}
+          />}
+      </Modal>
+    )
+  }
+
+  handleOk = () => {
+    this.formRef.handleConfirm().then(res => {
+      this.setState({
+        confirmLoading: true
+      })
+      console.log(res)
+      Api.setActionSubmit({
+        func: 'SetActionSubmitSuccess'
+      }).then((res) => {
+        if (res.status) {
+          notification.success({
+            top: 92,
+            message: this.props.dict['main.action.confirm.success']
+          })
+          this.setState({
+            confirmLoading: false,
+            visible: false
+          })
+        } else {
+          notification.error({
+            top: 92,
+            message: res.message
+          })
+        }
+      })
+    }, () => {})
+  }
+
+  handleCancel = () => {
+    this.setState({
+      visible: false
+    })
+    this.formRef.handleReset()
   }
 
   UNSAFE_componentWillMount () {
@@ -87,6 +181,7 @@
                 >{item.MenuName}</Button>
               )
             })}
+            {this.getModels()}
           </div>
         </Affix>
       )

--
Gitblit v1.8.0