From 46773828b8c46e450a67eb1fc5e6124d87d97ab6 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 23 九月 2023 19:51:11 +0800
Subject: [PATCH] 2023-09-23

---
 src/menu/datasource/verifycard/settingform/index.jsx |   76 ++++++++++++++++++++++++++++++++++----
 1 files changed, 68 insertions(+), 8 deletions(-)

diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx
index 612259d..805305e 100644
--- a/src/menu/datasource/verifycard/settingform/index.jsx
+++ b/src/menu/datasource/verifycard/settingform/index.jsx
@@ -1,8 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Form, Row, Col, Input, Radio, Tooltip, notification, Select, InputNumber, Cascader } from 'antd'
-import { QuestionCircleOutlined } from '@ant-design/icons'
+import { Form, Row, Col, Input, Radio, Tooltip, notification, Select, InputNumber, Cascader, Modal, Button } from 'antd'
+import { QuestionCircleOutlined, PlusOutlined } from '@ant-design/icons'
 
 import { formRule } from '@/utils/option.js'
 import Utils from '@/utils/utils.js'
@@ -16,6 +16,7 @@
 class SettingForm extends Component {
   static propTpyes = {
     updateStatus: PropTypes.func,
+    updateColumns: PropTypes.func,
     addProcess: PropTypes.func,
     config: PropTypes.object,     // 缁勪欢閰嶇疆
     setting: PropTypes.object,    // 鏁版嵁婧愰厤缃�
@@ -29,7 +30,8 @@
     innerRules: [],
     innertip: '',
     MenuType: sessionStorage.getItem('MenuType') || '',
-    ismain: false
+    ismain: false,
+    visible: false
   }
 
   UNSAFE_componentWillMount () {
@@ -182,21 +184,61 @@
   }
 
   addProcess = () => {
-    let _sql = this.props.form.getFieldValue('dataresource')
+    this.setState({visible: true})
+  }
 
-    _sql = _sql + `\n/* select a.*,w.remark as remark_w,w.statusname as statusname_w,w.status as status_w,w.works_flow_param from (鏁版嵁婧�) a inner join (select * from  s_my_works_flow  where works_flow_code=@works_flow_code@ and status=0 and deleted=0) w on a.id=w.works_flow_id */`
+  execAddProcess = (type) => {
+    let _sql = this.props.form.getFieldValue('dataresource')
+    let tableName = this.props.form.getFieldValue('tableName') || '琛ㄥ悕'
+
+    if (type === 'flowstart') {
+      _sql = _sql + `\n/* select a.*, w.remark as remark_w, w.statusname  as statusname_w,w.status as status_w,w.works_flow_param,w.modifydate as modifydate_w  from (select * from ${tableName} where status=0 and deleted=0 $@ and createuserid=@userid@ @$) a
+    inner join (select * from  s_my_works_flow  where works_flow_code=@works_flow_code@ and status=0 and deleted=0) w on a.id=w.works_flow_id */`
+    } else if (type === 'flowcheck') {
+      _sql = _sql + `\n/* select a.*, w.remark as remark_w, w.statusname  as statusname_w,w.status as status_w,w.works_flow_param,w.modifydate as modifydate_w  
+    from (select * from ${tableName} where status=0 and deleted=0 ) a
+    inner join (select * from  s_my_works_flow  where works_flow_code=@works_flow_code@ and status>0 and status<888 and deleted=0) w 
+    on a.id=w.works_flow_id 
+    $@ inner join (select works_flow_id  from s_my_works_flow_role where userid=@userid@ and  works_flow_code=@works_flow_code@ and deleted=0 ) r
+    on r.works_flow_id=w.works_flow_id @$ */`
+    }
 
     this.props.form.setFieldsValue({
       dataresource: _sql
     })
 
+    this.setState({visible: false})
+
     this.props.addProcess()
+  }
+
+  addSql = () => {
+    let tableName = this.props.form.getFieldValue('tableName')
+
+    if (!tableName) {
+      notification.warning({
+        top: 92,
+        message: '璇锋坊鍔犺〃鍚嶃��',
+        duration: 5
+      })
+      return
+    }
+
+    let _sql = this.props.form.getFieldValue('dataresource')
+
+    if (/^\s*$/.test(_sql)) {
+      this.props.form.setFieldsValue({
+        dataresource: `select * from ${tableName} where deleted=0`
+      })
+    }
+
+    this.props.updateColumns(tableName)
   }
 
   render() {
     const { columns, config } = this.props
     const { getFieldDecorator } = this.props.form
-    const { setting, modules, innerRules, innertip, MenuType } = this.state
+    const { setting, modules, innerRules, innertip, MenuType, visible } = this.state
 
     const formItemLayout = {
       labelCol: {
@@ -223,7 +265,7 @@
                       message: '璇疯緭鍏ユ暟鎹簮鍚嶇О!'
                     }
                   ]
-                })(<Input placeholder={''} autoComplete="off" />)}
+                })(<Input placeholder="" autoComplete="off" />)}
               </Form.Item>
             </Col> : null}
             <Col span={8}>
@@ -244,7 +286,11 @@
                       message: '琛ㄥ悕鍙彲浣跨敤瀛楁瘝銆佹暟瀛椾互鍙奯'
                     }
                   ]
-                })(<Input placeholder={''} autoComplete="off" />)}
+                })(
+                  setting.interType === 'system' && ((columns.length === 0 && config.subtype !== 'basetable') || !setting.dataresource) ?
+                  <Input placeholder="" autoComplete="off" addonAfter={<PlusOutlined onClick={this.addSql} />}/> :
+                  <Input placeholder="" autoComplete="off"/>
+                  )}
               </Form.Item>
             </Col>
             <Col span={8}>
@@ -672,6 +718,20 @@
             </Col> : null}
           </Row>
         </Form>
+        <Modal
+          wrapClassName="mk-flow-type"
+          visible={visible}
+          width={400}
+          maskClosable={false}
+          closable={false}
+          footer={[
+            <Button key="cancel" className="mk-green" onClick={() => this.execAddProcess('flowstart')}>鍙戣捣</Button>,
+            <Button key="confirm" className="mk-primary" onClick={() => this.execAddProcess('flowcheck')}>瀹℃壒</Button>
+          ]}
+          destroyOnClose
+        >
+          璇烽�夋嫨宸ヤ綔娴佺被鍨嬨��
+        </Modal>
       </div>
     )
   }

--
Gitblit v1.8.0