From 6def3330d1d1cf4036916ed04c8bbc4128e1e5d0 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 03 五月 2020 19:42:17 +0800
Subject: [PATCH] 2020-05-03

---
 src/templates/subtableconfig/index.jsx |  244 ++++--------------------------------------------
 1 files changed, 20 insertions(+), 224 deletions(-)

diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx
index a485945..5ee3d8c 100644
--- a/src/templates/subtableconfig/index.jsx
+++ b/src/templates/subtableconfig/index.jsx
@@ -11,7 +11,9 @@
 import zhCN from '@/locales/zh-CN/model.js'
 import enUS from '@/locales/en-US/model.js'
 import Utils from '@/utils/utils.js'
+import { getSubMenuForm } from '@/templates/zshare/formconfig'
 
+import asyncComponent from '@/utils/asyncComponent'
 import TableComponent from '@/templates/sharecomponent/tablecomponent'
 import FieldsComponent from '@/templates/sharecomponent/fieldscomponent'
 import ChartGroupComponent from '@/templates/sharecomponent/chartgroupcomponent'
@@ -19,12 +21,9 @@
 import ActionComponent from '@/templates/sharecomponent/actioncomponent'
 import ColumnComponent from '@/templates/sharecomponent/columncomponent'
 
-import SettingForm from './settingform'
 import MenuForm from '@/templates/zshare/menuform'
 import EditComponent from '@/templates/zshare/editcomponent'
 import SourceElement from '@/templates/zshare/dragsource'
-import CreateFunc from '@/templates/zshare/createfunc'
-import CreateInterface from '@/templates/zshare/createinterface'
 import ChartComponent from '@/templates/zshare/chartcomponent'
 import Source from './source'
 import './index.scss'
@@ -32,6 +31,7 @@
 const { Panel } = Collapse
 const { confirm } = Modal
 const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS
+const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent'))
 
 class SubTableConfig extends Component {
   static propTpyes = {
@@ -57,7 +57,6 @@
     menuloading: false,      // 鑿滃崟淇濆瓨涓�
     menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨
     loading: false,          // 鍔犺浇涓紝椤甸潰spin
-    settingVisible: false,   // 鍏ㄥ眬閰嶇疆妯℃�佹
     closeVisible: false,     // 鍏抽棴妯℃�佹
     originConfig: null,      // 鍘熼厤缃�
     originActions: null,     // 鍘熷鎸夐挳淇℃伅锛屼娇鐢ㄥ凡鏈夌敤鎴锋ā鏉�
@@ -67,7 +66,6 @@
     optionLibs: null,        // 鑷畾涔変笅鎷夐�夐」搴�
     thawButtons: [],         // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳
     activeKey: '0',          // 榛樿灞曞紑鍩烘湰淇℃伅
-    sqlVerifing: false,      // sql楠岃瘉
     chartview: null,         // 褰撳墠瑙嗗浘
     pasteContent: null       // 绮樿创鍐呭
   }
@@ -148,32 +146,7 @@
       config: _config,
       activeKey: _activeKey || '0',
       originConfig: _config,
-      menuformlist: [
-        {
-          type: 'text',
-          key: 'tabName',
-          label: this.state.dict['header.menu.viewName'],
-          initVal: _config.tabName,
-          required: true,
-          readonly: false
-        },
-        {
-          type: 'text',
-          key: 'tabNo',
-          label: this.state.dict['header.menu.menuNo'],
-          initVal: _config.tabNo,
-          required: true,
-          readonly: false
-        },
-        {
-          type: 'text',
-          key: 'Remark',
-          label: this.state.dict['header.menu.Remark'],
-          initVal: _config.Remark,
-          required: false,
-          readonly: false
-        }
-      ]
+      menuformlist: getSubMenuForm(_config)
     })
   }
 
@@ -289,37 +262,6 @@
   }
 
   /**
-   * @description 鍒涘缓琛ㄦ牸瀛樺偍杩囩▼
-   */
-  tableCreatFunc = () => {
-    const { config } = this.state
-
-    this.settingRef.handleConfirm().then(setting => {
-
-      if (!(setting.interType === 'inner') || !setting.innerFunc) {
-        notification.warning({
-          top: 92,
-          message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒',
-          duration: 5
-        })
-        return
-      }
-
-      let _config = {...config, setting: setting}
-      let newLText = Utils.formatOptions(Utils.getTableFunc(setting, {MenuID: _config.uuid, MenuName: _config.tabName, MenuNo: _config.tabNo}, _config)) // 鍒涘缓瀛樺偍杩囩▼sql
-      let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc))          // 鍒犻櫎瀛樺偍杩囩▼sql
-      
-      this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => {
-        if (result === 'success') {
-          this.setState({
-            config: _config
-          })
-        }
-      })
-    })
-  }
-
-  /**
    * @description 鏍囩椤典繚瀛�
    */
   submitConfig = () => {
@@ -341,7 +283,7 @@
       }
 
       let _LongParam = ''
-      let _config = {...config, ...res}
+      let _config = {...config, tabName: res.MenuName, tabNo: res.MenuNo, Remark: res.Remark}
 
       // 鏈缃暟鎹簮鎴栦富閿椂锛屽惎鐢ㄧ姸鎬佷负false
       if (_config.setting.interType === 'inner' && !_config.setting.innerFunc && !_config.setting.dataresource) {
@@ -471,7 +413,7 @@
           func: 'sPC_Button_AddUpt',
           Type: 40,
           ParentID: _config.uuid,
-          MenuNo: res.tabNo,
+          MenuNo: res.MenuNo,
           Template: 'SubTable',
           PageParam: '',
           LongParam: '',
@@ -505,9 +447,9 @@
         let param = {
           func: 'sPC_Tab_AddUpt',
           MenuID: _config.uuid,
-          MenuNo: res.tabNo,
+          MenuNo: res.MenuNo,
           Template: 'SubTable',
-          MenuName: res.tabName,
+          MenuName: res.MenuName,
           Remark: res.Remark,
           Sort: 0,
           PageParam: JSON.stringify({Template: 'SubTable'}),
@@ -814,101 +756,6 @@
     }
   }
 
-  changeSetting = () => {
-    this.setState({
-      settingVisible: true
-    })
-  }
-
-  settingSave = () => {
-    const { config } = this.state
-
-    this.settingRef.handleConfirm().then(res => {
-      if (
-        res.interType === 'inner' &&
-        !res.innerFunc &&
-        /[^\s]+\s+[^\s]+/ig.test(res.dataresource) &&
-        config.setting.dataresource !== res.dataresource
-      ) {
-        let param = {
-          func: 's_DataSrc_Save',
-          LText: res.dataresource,
-          MenuID: config.uuid
-        }
-
-        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)
-      }
-
-      if (res.interType === 'inner' && !res.innerFunc && res.dataresource && /\s/.test(res.dataresource)) {
-        this.setState({
-          sqlVerifing: true
-        })
-
-        let _dataresource = res.dataresource
-
-        if (res.queryType === 'statistics') {
-          let fieldmap = new Map()
-          let options = config.search.map(item => {
-            let _field = item.key
-            let _val = ''
-
-            if (fieldmap.has(_field)) {
-              _field = _field + '1'
-            }
-
-            fieldmap.set(item.key, true)
-
-            if (/date/.test(item.type)) {
-              _val = '1900-01-01'
-            }
-
-            return {
-              reg: new RegExp('@' + _field + '@', 'ig'),
-              value: _val
-            }
-          })
-
-          options.forEach(item => {
-            _dataresource = _dataresource.replace(item.reg, `'${item.value}'`)
-          })
-        }
-
-        let param = {
-          func: 's_debug_sql',
-          LText: _dataresource
-        }
-        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).then(result => {
-          if (result.status) {
-            this.setState({
-              sqlVerifing: false,
-              config: {...config, setting: res},
-              settingVisible: false
-            })
-          } else {
-            this.setState({sqlVerifing: false})
-            
-            Modal.error({
-              title: result.message
-            })
-          }
-        })
-      } else {
-        this.setState({
-          config: {...config, setting: res},
-          settingVisible: false
-        })
-      }
-    })
-  }
-
   /**
    * @description 璁剧疆鍙厤缃寜閽�
    */
@@ -1041,36 +888,6 @@
   }
 
   /**
-   * @description 鍒涘缓琛ㄦ牸鎺ュ彛
-   */
-  tableCreatInterface = () => {
-    const { config } = this.state
-
-    this.menuformRef.handleConfirm().then(res => {
-      this.settingRef.handleConfirm().then(setting => {
-        if (setting.interType !== 'inner' || setting.innerFunc) {
-          notification.warning({
-            top: 92,
-            message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖涓嶅瓨鍦ㄥ唴閮ㄥ嚱鏁版椂锛屾墠鍙互鍒涘缓鎺ュ彛锛�',
-            duration: 5
-          })
-          return
-        }
-  
-        let _config = {...config, setting: setting}
-        let _menu = {
-          type: 'subtable',
-          MenuID: config.uuid,
-          menuName: res.tabName,
-          menuNo: res.tabNo
-        }
-  
-        this.refs.tableCreatInterface.triggerOutInterface(_menu, _config)
-      })
-    })
-  }
-
-  /**
    * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑
    */
   updateConfig = (res) => {
@@ -1143,7 +960,7 @@
   /**
    * @description 鏇存柊鏄剧ず鍒楅厤缃俊鎭�
    */
-  updatecolumn = (config) => {
+  updateconfig = (config) => {
     this.setState({
       config: config
     })
@@ -1281,9 +1098,16 @@
                 <Button onClick={this.cancelConfig}>{this.state.dict['header.return']}</Button>
               </div>
             } style={{ width: '100%' }}>
-              <Icon type="setting" onClick={this.changeSetting} />
+              <SettingComponent
+                type="subtable"
+                config={config}
+                MenuID={config.uuid}
+                menuformRef={this.menuformRef}
+                permFuncField={this.props.permFuncField}
+                updatesetting={this.updateconfig}
+              />
               <SearchComponent
-                menu={{MenuID: this.state.config.uuid, MenuName: this.state.config.tabName}}
+                menu={{MenuID: config.uuid, MenuName: config.tabName}}
                 config={config}
                 pasteContent={this.state.pasteContent}
                 sysRoles={this.props.sysRoles}
@@ -1309,6 +1133,7 @@
                           menu={{MenuID: config.uuid, MenuName: config.tabName, MenuNo: config.tabNo}}
                           config={config}
                           tabs={this.state.tabviews}
+                          menuformRef={this.menuformRef}
                           pasteContent={this.state.pasteContent}
                           usefulFields={this.props.permFuncField}
                           setSubConfig={this.setSubConfig}
@@ -1319,7 +1144,7 @@
                           menu={this.props.menu}
                           sysRoles={this.props.sysRoles}
                           pasteContent={this.state.pasteContent}
-                          updatecolumn={this.updatecolumn}
+                          updatecolumn={this.updateconfig}
                         />
                       </Col>
                     )
@@ -1341,35 +1166,6 @@
             </Card>
           </div>
         </DndProvider>
-        {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */}
-        <Modal
-          title={this.state.dict['model.edit']}
-          visible={this.state.settingVisible}
-          width={750}
-          maskClosable={false}
-          onCancel={() => { // 鍙栨秷淇敼
-            this.setState({
-              settingVisible: false
-            })
-          }}
-          footer={[
-            <CreateInterface key="interface" dict={this.state.dict} ref="tableCreatInterface" trigger={this.tableCreatInterface}/>,
-            <CreateFunc key="create" dict={this.state.dict} ref="tableCreatFunc" trigger={this.tableCreatFunc}/>,
-            <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>,
-            <Button key="confirm" type="primary" loading={this.state.sqlVerifing} onClick={this.settingSave}>{this.state.dict['model.confirm']}</Button>
-          ]}
-          destroyOnClose
-        >
-          <SettingForm
-            dict={this.state.dict}
-            tabId={this.state.config.uuid}
-            inputSubmit={this.settingSave}
-            data={this.state.config.setting}
-            columns={this.state.config.columns}
-            usefulFields={this.props.permFuncField}
-            wrappedComponentRef={(inst) => this.settingRef = inst}
-          />
-        </Modal>
         <Modal
           bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}}
           closable={false}

--
Gitblit v1.8.0