From 27eb6c35533be910488869c393e2c89e3c0a5b20 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 07 九月 2020 23:33:23 +0800
Subject: [PATCH] 2020-09-07

---
 src/templates/sharecomponent/settingcomponent/index.jsx |   70 ++++++++++++----------------------
 1 files changed, 25 insertions(+), 45 deletions(-)

diff --git a/src/templates/sharecomponent/settingcomponent/index.jsx b/src/templates/sharecomponent/settingcomponent/index.jsx
index 1a04540..2550016 100644
--- a/src/templates/sharecomponent/settingcomponent/index.jsx
+++ b/src/templates/sharecomponent/settingcomponent/index.jsx
@@ -7,7 +7,6 @@
 import DevUtils from '@/utils/devutils.js'
 import zhCN from '@/locales/zh-CN/model.js'
 import enUS from '@/locales/en-US/model.js'
-import { getSettingForm } from '@/templates/zshare/formconfig'
 
 import SettingForm from './settingform'
 import CreateFunc from '@/templates/zshare/createfunc'
@@ -17,7 +16,6 @@
 
 class SettingComponent extends Component {
   static propTpyes = {
-    type: PropTypes.string,          // 鑿滃崟绫诲瀷
     mainsearch: PropTypes.any,       // 涓昏〃鐨勬悳绱㈡潯浠讹紝褰撳瓙琛ㄨ缃帴鏀朵富琛ㄦ潯浠舵椂鏈夋晥
     MenuID: PropTypes.string,        // 鑿滃崟ID
     config: PropTypes.object,        // 鑿滃崟閰嶇疆淇℃伅
@@ -28,6 +26,7 @@
   state = {
     dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     menu: null,          // 鑿滃崟淇℃伅
+    search: null,        // 鎼滅储鏉′欢锛屽寘鎷富琛ㄦ悳绱�
     formlist: null,      // 琛ㄥ崟淇℃伅
     visible: false,      // 妯℃�佹鎺у埗
     loading: false       // 璁剧疆淇℃伅楠岃瘉淇濆瓨涓�
@@ -37,39 +36,19 @@
    * @description 鍏ㄥ眬璁剧疆瑙﹀彂
    */
   changeSetting = () => {
-    const { MenuID, config, type, permFuncField, mainsearch } = this.props
-    let menu = {MenuID: MenuID, MenuName: config.MenuName, MenuNo: config.MenuNo}
-    let _columns = fromJS(config.columns).toJS()
-    let primaryKey = config.setting.primaryKey || ''
+    const { MenuID, config, mainsearch } = this.props
+    let menu = { MenuID: MenuID, MenuName: config.MenuName, MenuNo: config.MenuNo }
 
-    if (!primaryKey || _columns.filter(column => column.field === primaryKey).length === 0) {
-      _columns.forEach(col => {
-        if (col.field.toLowerCase() === 'id') {
-          primaryKey = col.field
-        }
-      })
-    }
-    _columns = _columns.filter(item => item.field && item.type !== 'colspan')
-    _columns = _columns.map(item => {
-      return {
-        value: item.field,
-        text: item.label
-      }
-    })
-
-    // _columns.unshift({value: '', text: '鏈缃�'})
-
-    let _config = fromJS(config).toJS()
+    let _search = fromJS(config.search).toJS()
 
     if (mainsearch) { // 缁煎悎涓婚〉鎼滅储鍙婂瓙琛ㄦ悳绱㈡潯浠�
-      _config.search = [..._config.search, ...mainsearch]
+      _search = [...mainsearch, ..._search]
     }
 
     this.setState({
       visible: true,
-      formlist: getSettingForm(config.setting, permFuncField, MenuID, primaryKey, _columns, type),
-      menu: menu,
-      config: _config
+      search: _search,
+      menu: menu
     })
   }
 
@@ -87,8 +66,8 @@
         visible: false,
         loading: false
       })
-
-      delete res.customScript // 娓呴櫎鏁寸悊鍚庣殑鑷畾涔夎剼鏈�
+      res.actionfixed = res.actionfixed === 'true'
+      res.columnfixed = res.columnfixed === 'true'
 
       this.props.updatesetting({...config, setting: res})
     }, () => {
@@ -105,18 +84,18 @@
     const { config } = this.props
     const { menu } = this.state
 
-    this.settingRef.handleConfirm().then(setting => {
-
-      if (!(setting.interType === 'inner') || !setting.innerFunc) {
+    this.settingRef.handleConfirm(true).then(setting => {
+      if (setting.interType !== 'inner' || !setting.innerFunc) {
         notification.warning({
           top: 92,
-          message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒',
+          message: '浣跨敤鍐呴儴鎺ュ彛锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒',
           duration: 5
         })
         return
       }
 
       let _config = {...config, setting: setting}
+
       let newLText = Utils.formatOptions(DevUtils.getTableFunc(setting, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql
       let DelText = Utils.formatOptions(DevUtils.dropfunc(setting.innerFunc))          // 鍒犻櫎瀛樺偍杩囩▼sql
 
@@ -132,14 +111,14 @@
    * @description 鍒涘缓琛ㄦ牸鎺ュ彛锛堣鍑猴級
    */
   tableCreatInterface = () => {
-    const { config, type } = this.props
+    const { config } = this.props
     const { menu } = this.state
 
-    this.settingRef.handleConfirm().then(setting => {
-      if (setting.interType !== 'inner' || setting.innerFunc) {
+    this.settingRef.handleConfirm(true).then(setting => {
+      if (setting.interType !== 'system') {
         notification.warning({
           top: 92,
-          message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖涓嶅瓨鍦ㄥ唴閮ㄥ嚱鏁版椂锛屾墠鍙互鍒涘缓鎺ュ彛锛�',
+          message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ュ垱寤烘帴鍙o紒',
           duration: 5
         })
         return
@@ -147,7 +126,7 @@
 
       let _config = {...config, setting: setting}
       let _menu = {
-        type: type,
+        type: config.Template === 'CommonTable' ? 'main' : 'subtable',
         MenuID: menu.MenuID,
         menuName: menu.MenuName,
         menuNo: menu.MenuNo
@@ -171,8 +150,8 @@
   }
 
   render() {
-    const { type } = this.props
-    const { dict, visible, config } = this.state
+    const { config, permFuncField } = this.props
+    const { dict, visible, search, menu } = this.state
 
     return (
       <div className="model-menu-setting">
@@ -186,7 +165,7 @@
           maskClosable={false}
           onCancel={() => { this.setState({ visible: false, loading: false })}}
           footer={[
-            <CreateInterface key="interface" dict={dict} ref="tableCreatInterface" trigger={this.tableCreatInterface}/>,
+            <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>
@@ -194,12 +173,13 @@
           destroyOnClose
         >
           <SettingForm
-            type={type}
+            type={config.Template === 'CommonTable' ? 'main' : 'subtable'}
             dict={dict}
+            menu={menu}
             config={config}
-            menu={this.state.menu}
+            search={search}
+            permFuncField={permFuncField}
             inputSubmit={this.settingSave}
-            formlist={this.state.formlist}
             wrappedComponentRef={(inst) => this.settingRef = inst}
           />
         </Modal>

--
Gitblit v1.8.0