From b987be8dd8b6bc1fa01810daa1e1a60e58a3c921 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 04 九月 2020 17:24:36 +0800
Subject: [PATCH] 2020-09-04

---
 src/menu/datasource/verifycard/settingform/index.jsx |  116 +++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 79 insertions(+), 37 deletions(-)

diff --git a/src/menu/datasourcecomponent/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx
similarity index 83%
rename from src/menu/datasourcecomponent/verifycard/settingform/index.jsx
rename to src/menu/datasource/verifycard/settingform/index.jsx
index 9cdeb01..7a5eccd 100644
--- a/src/menu/datasourcecomponent/verifycard/settingform/index.jsx
+++ b/src/menu/datasource/verifycard/settingform/index.jsx
@@ -1,9 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, InputNumber, Select } from 'antd'
-import moment from 'moment'
 
-import Api from '@/api'
 import { formRule } from '@/utils/option.js'
 import Utils from '@/utils/utils.js'
 import CodeMirror from '@/templates/zshare/codemirror'
@@ -12,8 +10,7 @@
 class SettingForm extends Component {
   static propTpyes = {
     dict: PropTypes.object,       // 瀛楀吀椤�
-    menuId: PropTypes.string,     // 鑿滃崟Id
-    permFuncField: PropTypes.any, // 鑿滃崟Id
+    menu: PropTypes.any,          // 鑿滃崟閰嶇疆淇℃伅
     config: PropTypes.object,     // 缁勪欢閰嶇疆
     setting: PropTypes.object,    // 鏁版嵁婧愰厤缃�
     columns: PropTypes.array,     // 鍒楄缃�
@@ -22,10 +19,34 @@
 
   state = {
     interType: this.props.setting.interType || 'system',
+    supModule: '',
+    modules: []
+  }
+
+  UNSAFE_componentWillMount () {
+    const { menu, setting } = this.props
+    let supModule = setting.supModule || ''
+    let modules = []
+
+    menu.components.forEach(item => {
+      if (!item.switchable || !item.setting || !item.setting.name) return
+
+      modules.push({
+        value: item.uuid,
+        text: item.setting.name
+      })
+    })
+
+    if (supModule && supModule !== 'empty') {
+      if (modules.filter(item => item.value === supModule).length === 0) {
+        supModule = ''
+      }
+    }
+
+    this.setState({supModule, modules})
   }
 
   handleConfirm = () => {
-    const { setting } = this.props
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {
@@ -87,24 +108,6 @@
             }
           }
 
-          // 鏁版嵁婧愪繚瀛�
-          if (
-            values.interType === 'system' && values.execute !== 'false' &&
-            /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && setting.dataresource !== values.dataresource
-          ) {
-            let param = {
-              func: 's_DataSrc_Save',
-              LText: values.dataresource,
-              MenuID: this.props.menuId
-            }
-    
-            param.LText = Utils.formatOptions(param.LText)
-            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
-    
-            Api.getLocalConfig(param)
-          }
-
           resolve(values)
         } else {
           reject(err)
@@ -124,9 +127,9 @@
   }
 
   render() {
-    const { setting, permFuncField, columns, config } = this.props
+    const { setting, menu, columns, config } = this.props
     const { getFieldDecorator } = this.props.form
-    const { interType } = this.state
+    const { interType, supModule, modules } = this.state
 
     const formItemLayout = {
       labelCol: {
@@ -142,9 +145,9 @@
     let tooltip = null
     let rules = []
 
-    if (permFuncField && permFuncField.length > 0) {
-      tooltip = '寮�澶村彲鐢ㄥ瓧绗︼細' + permFuncField.join(', ')
-      let str = '^(' + permFuncField.join('|') + ')'
+    if (menu.permFuncField && menu.permFuncField.length > 0) {
+      tooltip = '寮�澶村彲鐢ㄥ瓧绗︼細' + menu.permFuncField.join(', ')
+      let str = '^(' + menu.permFuncField.join('|') + ')'
       let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g')
 
       rules.push({
@@ -354,26 +357,53 @@
               </Form.Item>
             </Col> : null}
             <Col span={8}>
-              <Form.Item label="鍒濆鍖�">
-                {getFieldDecorator('onload', {
-                  initialValue: setting.onload || 'true'
+              <Form.Item label={
+                <Tooltip placement="topLeft" title={'璇ョ粍浠跺鏋滃彈鍏朵粬缁勪欢鎺у埗锛岃閫夐」鐩稿簲鐨勭粍浠讹紝娌℃湁鏃堕�夆�滄棤鈥濄��'}>
+                  <Icon type="question-circle" />
+                  涓婄骇妯″潡
+                </Tooltip>
+              }>
+                {getFieldDecorator('supModule', {
+                  initialValue: supModule,
+                  rules: [
+                    {
+                      required: true,
+                      message: this.props.dict['form.required.select'] + '涓婄骇妯″潡!'
+                    }
+                  ]
                 })(
-                  <Radio.Group>
-                    <Radio value="true">鍔犺浇鏁版嵁</Radio>
-                    <Radio value="false">涓嶅姞杞芥暟鎹�</Radio>
-                  </Radio.Group>
+                  <Select>
+                    <Select.Option key="empty" value="empty"> 鏃� </Select.Option>
+                    {modules.map((option, i) =>
+                      <Select.Option key={i} value={option.value}>
+                        {option.text}
+                      </Select.Option>
+                    )}
+                  </Select>
                 )}
               </Form.Item>
             </Col>
-            {!config.laypage ? <Col span={8}>
+            {!config.pageable ? <Col span={8}>
               <Form.Item label={
-                <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細浠呭湪浣跨敤绯荤粺鍑芥暟锛屼笖鍒濆鍖栧姞杞芥暟鎹椂鏈夋晥銆�'}>
+                <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細浠呭湪浣跨敤绯荤粺鍑芥暟锛屼笖鍒濆鍖栧姞杞芥暟鎹椂鏈夋晥锛屽垎椤佃姹傛椂鏃犳晥銆�'}>
                   <Icon type="question-circle" />
                   鍚屾鏌ヨ
                 </Tooltip>
               }>
                 {getFieldDecorator('sync', {
                   initialValue: setting.sync || 'true'
+                })(
+                  <Radio.Group>
+                    <Radio value="true">鏄�</Radio>
+                    <Radio value="false">鍚�</Radio>
+                  </Radio.Group>
+                )}
+              </Form.Item>
+            </Col> : null}
+            {config.pageable ? <Col span={8}>
+              <Form.Item label="鍒嗛〉">
+                {getFieldDecorator('laypage', {
+                  initialValue: setting.laypage || 'false'
                 })(
                   <Radio.Group>
                     <Radio value="true">鏄�</Radio>
@@ -399,6 +429,18 @@
                 )}
               </Form.Item>
             </Col>
+            <Col span={8}>
+              <Form.Item label="鍒濆鍖栨暟鎹�">
+                {getFieldDecorator('onload', {
+                  initialValue: setting.onload || 'true'
+                })(
+                  <Radio.Group>
+                    <Radio value="true">鍔犺浇</Radio>
+                    <Radio value="false">涓嶅姞杞�</Radio>
+                  </Radio.Group>
+                )}
+              </Form.Item>
+            </Col>
           </Row>
         </Form>
       </div>

--
Gitblit v1.8.0