From 46f79b491173d284a4900d19e7aecf7509481438 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 一月 2022 17:21:25 +0800
Subject: [PATCH] 2022-01-21

---
 src/templates/modalconfig/index.jsx |   73 +++++++++++++++++++++++++++++++-----
 1 files changed, 62 insertions(+), 11 deletions(-)

diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx
index 8c690fb..6b01727 100644
--- a/src/templates/modalconfig/index.jsx
+++ b/src/templates/modalconfig/index.jsx
@@ -5,7 +5,8 @@
 import { DndProvider } from 'react-dnd'
 import HTML5Backend from 'react-dnd-html5-backend'
 import moment from 'moment'
-import { Button, Card, Modal, Collapse, notification, Icon, Switch } from 'antd'
+import { Button, Card, Modal, Collapse, notification, Switch } from 'antd'
+import { SettingOutlined } from '@ant-design/icons'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -127,6 +128,35 @@
     })
   }
 
+  componentDidMount() {
+    document.onkeydown = (event) => {
+      let e = event || window.event
+      let keyCode = e.keyCode || e.which || e.charCode
+      let preKey = ''
+
+      if (e.ctrlKey) {
+        preKey = 'ctrl'
+      }
+      if (e.shiftKey) {
+        preKey = 'shift'
+      } else if (e.altKey) {
+        preKey = 'alt'
+      }
+      
+      if (!preKey || !keyCode) return
+      
+      let _shortcut = `${preKey}+${keyCode}`
+
+      if (_shortcut === 'ctrl+83') {
+        let node = document.getElementById('save-config')
+        if (node && node.click) {
+          node.click()
+        }
+        return false
+      }
+    }
+  }
+
   /**
    * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊
    */
@@ -134,6 +164,7 @@
     this.setState = () => {
       return
     }
+    document.onkeydown = () => {}
   }
 
   // 椤甸潰杩斿洖
@@ -194,10 +225,7 @@
     let _inputfields = []
     let _tabfields = []
     let _linkableFields = []
-    let _linksupFields = [{
-      field: '',
-      label: '绌�'
-    }]
+    let _linksupFields = []
     let standardform = null
 
     let uniq = new Map()
@@ -227,7 +255,15 @@
         _tabIndex++
       }
 
-      if (!['select', 'link', 'radio', ''].includes(item.type)) return
+      if (item.type === 'switch') {
+        _linksupFields.push({
+          field: item.field,
+          label: _linkIndex + '銆�' + item.label
+        })
+      }
+
+      if (!['select', 'link', 'radio', 'checkcard'].includes(item.type)) return
+      if (item.type === 'checkcard' && item.multiple === 'true') return // 閫夐」鍗″閫�
       if (item.field && !uniq.has(item.field)) {
         uniq.set(item.field, true)
 
@@ -670,6 +706,20 @@
     })
   }
 
+  clearConfig = () => {
+    const _this = this
+    let _config = {...this.state.config, fields: []}
+
+    confirm({
+      content: '纭畾娓呯┖琛ㄥ崟鍚楋紵',
+      onOk() {
+        _this.setState({ config: _config })
+      },
+      onCancel() {}
+    })
+  }
+
+
   render () {
     const { editAction } = this.props
     const { config, dict, openEdition } = this.state
@@ -704,17 +754,18 @@
             </Collapse>
           </div>
           <div className="setting">
-            <Card title={dict['header.menu.form.configurable']} bordered={false} extra={
+            <Card title="琛ㄥ崟閰嶇疆" bordered={false} extra={
               <div>
+                <Button type="danger" onClick={this.clearConfig}>娓呯┖</Button>
                 <Versions MenuId={editAction.uuid} open_edition={openEdition} updateConfig={this.refreshConfig}/>
                 <ReplaceField type="form" config={config} updateConfig={this.updateconfig}/>
                 <EditComponent dict={dict} options={['form']} config={this.state.config} plusFields={this.plusFields}/>
-                <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{dict['model.save']}</Button>
+                <Button type="primary" id="save-config" onClick={this.submitConfig} loading={this.state.menuloading}>{dict['model.save']}</Button>
                 <Button onClick={this.cancelConfig}>{dict['model.back']}</Button>
               </div>
             } style={{ width: '100%' }}>
-              <Icon type="setting" onClick={this.changeSetting} />
-              <div className="ant-modal-content" style={{width: config.setting.width + '%'}}>
+              <SettingOutlined onClick={this.changeSetting} />
+              <div className="ant-modal-content" style={{width: config.setting.width > 100 ? config.setting.width : config.setting.width + '%'}}>
                 <div className="ant-modal-header">
                   <div className="ant-modal-title">{config.setting.title}</div>
                   <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button>
@@ -773,7 +824,7 @@
         <Modal
           title={dict['model.edit']}
           visible={this.state.settingVisible}
-          width={850}
+          width={900}
           maskClosable={false}
           onOk={this.settingSave}
           onCancel={() => { this.setState({ settingVisible: false }) }}

--
Gitblit v1.8.0