From 58826d6f4eab9f8c9acf9fa8696f60039c645cfe Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 20 八月 2024 18:18:00 +0800
Subject: [PATCH] 2024-08-20

---
 src/templates/sharecomponent/settingcomponent/index.jsx |  143 ++++++++++++++++++++++++++++-------------------
 1 files changed, 84 insertions(+), 59 deletions(-)

diff --git a/src/templates/sharecomponent/settingcomponent/index.jsx b/src/templates/sharecomponent/settingcomponent/index.jsx
index c96f5c3..8657cbe 100644
--- a/src/templates/sharecomponent/settingcomponent/index.jsx
+++ b/src/templates/sharecomponent/settingcomponent/index.jsx
@@ -1,18 +1,12 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Icon, Modal, Button } from 'antd'
-
-import Utils from '@/utils/utils.js'
-import DevUtils from '@/utils/devutils.js'
-import zhCN from '@/locales/zh-CN/model.js'
-import enUS from '@/locales/en-US/model.js'
+import { Modal, Button } from 'antd'
+import { SettingOutlined } from '@ant-design/icons'
 
 import SettingForm from './settingform'
-import CreateFunc from '@/templates/zshare/createfunc'
-import CreateInterface from '@/templates/zshare/createinterface'
 
-import './index.scss'
+// import './index.scss'
 
 class SettingComponent extends Component {
   static propTpyes = {
@@ -23,12 +17,13 @@
   }
 
   state = {
-    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     menu: null,          // 鑿滃崟淇℃伅
     search: null,        // 鎼滅储鏉′欢锛屽寘鎷富琛ㄦ悳绱�
     formlist: null,      // 琛ㄥ崟淇℃伅
     visible: false,      // 妯℃�佹鎺у埗
-    loading: false       // 璁剧疆淇℃伅楠岃瘉淇濆瓨涓�
+    loading: false,      // 璁剧疆淇℃伅楠岃瘉淇濆瓨涓�
+    record: null
+    
   }
 
   /**
@@ -60,13 +55,12 @@
     this.setState({
       loading: true
     })
-    this.settingRef.handleConfirm().then(res => {
+    this.settingRef.handleConfirm().then(setting => {
+      let res = this.resetSetting(setting, config.setting)
       this.setState({
         visible: false,
         loading: false
       })
-      res.actionfixed = res.actionfixed === 'true'
-      res.columnfixed = res.columnfixed === 'true'
 
       this.props.updatesetting({...config, setting: res})
     }, () => {
@@ -76,44 +70,78 @@
     })
   }
 
-  /**
-   * @description 鍒涘缓琛ㄦ牸瀛樺偍杩囩▼
-   */
-  tableCreatFunc = () => {
-    const { config } = this.props
-    const { menu } = this.state
+  // /**
+  //  * @description 鍒涘缓琛ㄦ牸鎺ュ彛锛堣鍑猴級
+  //  */
+  // tableCreatInterface = () => {
+  //   const { config } = this.props
+  //   const { menu } = this.state
 
-    this.settingRef.handleConfirm('func').then(setting => {
-      let _config = {...config, setting: setting}
-      let newLText = Utils.formatOptions(DevUtils.getTableFunc(setting, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql
-      let DelText = Utils.formatOptions(DevUtils.dropfunc(setting.innerFunc))          // 鍒犻櫎瀛樺偍杩囩▼sql
+  //   this.settingRef.handleConfirm('loading').then(setting => {
+  //     let res = this.resetSetting(setting, config.setting)
+  //     let _config = {...config, setting: res}
+  //     let _menu = {
+  //       type: config.Template === 'CommonTable' ? 'main' : 'subtable',
+  //       MenuID: menu.MenuID,
+  //       menuName: menu.MenuName,
+  //       menuNo: menu.MenuNo
+  //     }
 
-      this.refs.funcCreatComponent.exec(setting.innerFunc, newLText, DelText).then(result => {
-        if (result === 'success') {
-          this.props.updatesetting(_config)
-        }
-      })
-    })
-  }
+  //     this.refs.tableCreatInterface.triggerOutInterface(_menu, _config)
+  //   })
+  // }
 
-  /**
-   * @description 鍒涘缓琛ㄦ牸鎺ュ彛锛堣鍑猴級
-   */
-  tableCreatInterface = () => {
-    const { config } = this.props
-    const { menu } = this.state
+  resetSetting = (s, ori) => {
+    let setting = fromJS(s).toJS()
+    // let maxScript = 0
 
-    this.settingRef.handleConfirm('interface').then(setting => {
-      let _config = {...config, setting: setting}
-      let _menu = {
-        type: config.Template === 'CommonTable' ? 'main' : 'subtable',
-        MenuID: menu.MenuID,
-        menuName: menu.MenuName,
-        menuNo: menu.MenuNo
-      }
+    setting.show = ori.show || 'true'
+    setting.advanceType = ori.advanceType || 'modal'
+    setting.advanceWidth = ori.advanceWidth || 1000
+    setting.drawerPlacement = ori.drawerPlacement || 'right'
+    setting.searchRatio = ori.searchRatio || 6
+    setting.searchLwidth = ori.searchLwidth !== undefined ? ori.searchLwidth : 33.3
+    setting.resetContrl = ori.resetContrl || 'init'
 
-      this.refs.tableCreatInterface.triggerOutInterface(_menu, _config)
-    })
+    // if (window.GLOB.funcs && window.GLOB.funcs.length > 0) {
+    //   window.GLOB.funcs.forEach(m => {
+    //     let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig')
+    //     setting.scripts.forEach(item => {
+    //       item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`)
+
+    //       if (item.status === 'false') return
+
+    //       if (/exec\s/ig.test(item.sql)) {
+    //         maxScript = 1000
+    //       } else if (item.sql.length > maxScript) {
+    //         maxScript = item.sql.length
+    //       }
+    //     })
+    //     setting.preScripts.forEach(item => {
+    //       item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`)
+    //     })
+    //     setting.cbScripts.forEach(item => {
+    //       item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`)
+    //     })
+    //     if (setting.dataresource) {
+    //       setting.dataresource = setting.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`)
+    //     }
+    //   })
+    // } else {
+    //   setting.scripts.forEach(item => {
+    //     if (item.status === 'false') return
+
+    //     if (/exec\s/ig.test(item.sql)) {
+    //       maxScript = 1000
+    //     } else if (item.sql.length > maxScript) {
+    //       maxScript = item.sql.length
+    //     }
+    //   })
+    // }
+
+    // setting.maxScript = maxScript
+
+    return setting
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -131,36 +159,33 @@
 
   render() {
     const { config } = this.props
-    const { dict, visible, search, menu } = this.state
+    const { visible, search, menu } = this.state
 
     return (
-      <div className="model-menu-setting">
-        <Icon type="setting" onClick={this.changeSetting} />
+      <>
+        <SettingOutlined style={{position: 'absolute', fontSize: '18px', right: '7px', top: '5px', padding: '10px', zIndex: 1}} onClick={this.changeSetting} />
         {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */}
         <Modal
-          wrapClassName="model-table-setting-verify-modal"
-          title={dict['model.edit']}
+          wrapClassName="mk-pop-modal"
           visible={visible}
-          width={900}
+          width={'75vw'}
           maskClosable={false}
           onCancel={() => { this.setState({ visible: false, loading: false })}}
           footer={[
-            <CreateInterface key="interface" loading={this.state.interloading} dict={dict} ref="tableCreatInterface" trigger={this.tableCreatInterface}/>,
-            <CreateFunc key="create" dict={dict} ref="funcCreatComponent" trigger={this.tableCreatFunc}/>,
-            <Button key="cancel" onClick={() => { this.setState({ visible: false, loading: false }) }}>{this.state.dict['model.cancel']}</Button>,
-            <Button key="confirm" type="primary" loading={this.state.loading} onClick={this.settingSave}>{this.state.dict['model.confirm']}</Button>
+            <Button key="cancel" onClick={() => { this.setState({ visible: false, loading: false }) }}>鍙栨秷</Button>,
+            <Button key="confirm" type="primary" loading={this.state.loading} onClick={this.settingSave}>纭畾</Button>
           ]}
           destroyOnClose
         >
           <SettingForm
-            dict={dict}
             menu={menu}
             config={config}
             search={search}
+            updRecord={() => {}}
             wrappedComponentRef={(inst) => this.settingRef = inst}
           />
         </Modal>
-      </div>
+      </>
     )
   }
 }

--
Gitblit v1.8.0