From 5e1d4d5155c57c43739d61914e2d29a64f9bb683 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 27 八月 2023 17:40:38 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/menu/datasource/index.jsx |   91 ++++++++++++++++++++++++++++++---------------
 1 files changed, 60 insertions(+), 31 deletions(-)

diff --git a/src/menu/datasource/index.jsx b/src/menu/datasource/index.jsx
index 75faaeb..4076942 100644
--- a/src/menu/datasource/index.jsx
+++ b/src/menu/datasource/index.jsx
@@ -1,10 +1,11 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Modal } from 'antd'
+import { Modal, Button } from 'antd'
 import { SettingOutlined } from '@ant-design/icons'
 
 import VerifyCard from './verifycard'
+import CreateFunc from '@/templates/zshare/createfunc'
 import './index.scss'
 
 class DataSource extends Component {
@@ -19,7 +20,8 @@
     mainSearch: [],
     visible: false,
     loading: false,
-    setting: null
+    setting: null,
+    record: {}
   }
 
   UNSAFE_componentWillMount () {
@@ -100,44 +102,42 @@
         })
       }
     } else {
-      let _search = null
-      let filterComponent = (box) => {
+      let filterComponent = (box, mainSearch) => {
         box.components.forEach(item => {
-          if (_search) return
-
-          if (item.type === 'search') {
-            box.slist = [...box.slist, item.search]
-          } else if (item.uuid === config.uuid) {
-            _search = box.slist.pop()
+          if (item.type !== 'search') return
+          mainSearch = item.search
+        })
+        let has = false
+        box.components.forEach(item => {
+          if (item.uuid === config.uuid) {
+            has = true
           } else if (item.type === 'group') {
             item.components.forEach(m => {
               if (m.uuid !== config.uuid) return
-              _search = box.slist.pop()
-            })
-          } else if (item.type === 'tabs') {
-            item.subtabs.forEach(tab => {
-              tab.slist = [...box.slist]
-              filterComponent(tab)
+              has = true
             })
           }
         })
-      }
-      menu.slist = []
-      filterComponent(menu)
 
-      if (_search) {
-        search = _search
-      } else {
-        menu.components.forEach(item => {
-          if (item.type !== 'search') return
-          search = item.search
-        })
+        if (has) {
+          search = mainSearch || []
+        } else {
+          box.components.forEach(item => {
+            if (item.type !== 'tabs') return
+
+            item.subtabs.forEach(tab => {
+              filterComponent(tab, mainSearch)
+            })
+          })
+        }
       }
+      filterComponent(menu, null)
     }
 
     this.setState({
       visible: true,
-      mainSearch: search
+      mainSearch: search,
+      record: {...config.setting}
     })
   }
 
@@ -227,9 +227,34 @@
     })
   }
 
+  creatFunc = () => {
+    const { config } = this.props
+    const { mainSearch } = this.state
+    const menu = window.GLOB.customMenu
+
+    return new Promise((resolve) => {
+      this.verifyRef.submitDataSource().then(res => {
+        let _config = fromJS(config).toJS()
+        _config.MenuName = menu.MenuName + '-' + _config.name
+        _config.menuNo = menu.MenuNo
+        _config.MenuID = menu.MenuID
+        _config.setting = res.setting
+        _config.columns = res.columns
+        _config.func = res.setting.innerFunc
+        _config.$type = 'table'
+  
+        if (res.setting.useMSearch === 'true') { // 浣跨敤涓绘悳绱㈡潯浠�
+          _config.search = [..._config.search, ...mainSearch]
+        }
+  
+        resolve(_config)
+      })
+    })
+  }
+
   render () {
     const { config } = this.props
-    const { visible, loading, mainSearch } = this.state
+    const { visible, loading, mainSearch, record } = this.state
 
     return (
       <div className="model-datasource">
@@ -241,14 +266,18 @@
           width={'75vw'}
           maskClosable={false}
           okText="鎻愪氦"
-          onOk={this.verifySubmit}
-          confirmLoading={loading}
-          onCancel={() => {this.setState({ visible: false }) }}
+          onCancel={() => {this.setState({ visible: false, loading: false }) }}
+          footer={[
+            config.subtype !== 'dualdatacard' && record.interType === 'inner' ? <CreateFunc key="create" getMsg={this.creatFunc}/> : null,
+            <Button key="cancel" onClick={() => { this.setState({ visible: false, loading: false }) }}>鍙栨秷</Button>,
+            <Button key="confirm" type="primary" loading={loading} onClick={this.verifySubmit}>纭畾</Button>
+          ]}
           destroyOnClose
         >
           <VerifyCard
             mainSearch={mainSearch}
             config={config}
+            updRecord={(record) => this.setState({record: record})}
             wrappedComponentRef={(inst) => this.verifyRef = inst}
           />
         </Modal>

--
Gitblit v1.8.0