From f3d4db769ba9b51b799d981511a710fd443d0e08 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 21 四月 2025 12:18:03 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/menu/sysinterface/index.jsx |   57 +++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/src/menu/sysinterface/index.jsx b/src/menu/sysinterface/index.jsx
index c24c4b0..5952f9c 100644
--- a/src/menu/sysinterface/index.jsx
+++ b/src/menu/sysinterface/index.jsx
@@ -52,7 +52,6 @@
         dataIndex: 'operation',
         render: (text, record) =>
           (<div style={{textAlign: 'center'}}>
-            <DataSource config={record} updateConfig={this.update}/>
             <span onClick={() => this.handleStatus(record)} style={{color: '#8E44AD', cursor: 'pointer', fontSize: '16px', marginRight: '15px'}}><SwapOutlined /></span>
             <span onClick={() => this.copy(record)} style={{color: '#26C281', cursor: 'pointer', fontSize: '16px', marginRight: '15px'}}><CopyOutlined /></span>
             <Popconfirm
@@ -60,8 +59,9 @@
               title="纭畾鍒犻櫎锛�"
               onConfirm={() => this.deleteScript(record)
             }>
-              <span style={{color: '#ff4d4f', cursor: 'pointer', fontSize: '16px'}}><DeleteOutlined /></span>
+              <span style={{color: '#ff4d4f', cursor: 'pointer', fontSize: '16px', marginRight: '15px'}}><DeleteOutlined /></span>
             </Popconfirm>
+            <DataSource config={record} updateConfig={this.update}/>
           </div>)
       }
     ]
@@ -73,11 +73,6 @@
 
   copy = (item) => {
     let msg = { key: 'interface', type: 'line', data: item }
-
-    let srcid = localStorage.getItem(window.location.href.split('#')[0] + 'srcId')
-    if (srcid) {
-      msg.$srcId = srcid
-    }
 
     try {
       msg = window.btoa(window.encodeURIComponent(JSON.stringify(msg)))
@@ -160,8 +155,44 @@
   changeScripts = (interfaces) => {
     const { config } = this.props
 
+    interfaces = interfaces.map(item => {
+      item.$tables = this.getTables(item)
+      return item
+    })
+
     this.setState({ interfaces })
     this.props.updateConfig({...config, interfaces})
+  }
+
+  getTables = (record) => {
+    let tables = []
+    let cuts = []
+    let cutreg = /(from|update|insert\s+into)\s+(@db@)?[a-z_]+/ig
+    let trimreg = /(from|update|insert\s+into)\s+(@db@)?/ig
+
+    if (record.setting.interType === 'system') {
+      if (record.setting.execute !== 'false' && record.setting.dataresource) {
+        let tbs = record.setting.dataresource.match(cutreg)
+        tbs && cuts.push(...tbs)
+      }
+      record.scripts && record.scripts.forEach(script => {
+        if (script.status === 'false') return
+        let tbs = script.sql.match(cutreg)
+        tbs && cuts.push(...tbs)
+      })
+    } else if (record.setting.tableName) {
+      let tb = record.setting.tableName.replace(/@db@|\s+/ig, '')
+      if (/[a-z_]+/ig.test(tb)) {
+        tables.push(tb)
+      }
+    }
+
+    cuts = cuts.map(item => item.replace(trimreg, ''))
+    tables.push(...cuts)
+    tables = tables.filter(Boolean)
+    tables = Array.from(new Set(tables))
+
+    return tables
   }
 
   update = (record) => {
@@ -173,6 +204,9 @@
       record.status = 'false'
     }
     record.name = record.setting.name
+    record.$tables = this.getTables(record)
+
+    delete record.subColumns
 
     let interfaces = this.state.interfaces.map(item => {
       if (item.uuid !== record.uuid) {
@@ -181,10 +215,10 @@
       return record
     })
 
-    
     this.setState({ interfaces })
     this.props.updateConfig({...config, interfaces})
 
+    MKEmitter.emit('editLineId', record.uuid)
     setTimeout(() => {
       MKEmitter.emit('mkUpdateInter', record, {delay: 0})
     }, 10)
@@ -216,8 +250,8 @@
     const { visible, columns, interfaces } = this.state
 
     return (
-      <div className="mk-sys-interface" style={{display: 'inline-block'}}>
-        <Button className="mk-border-green" onClick={this.trigger}><DatabaseOutlined /> 鍏叡鏁版嵁婧�</Button>
+      <>
+        <Button className="mk-border-danger" onClick={this.trigger}><DatabaseOutlined /> 鍏叡鏁版嵁婧�</Button>
         <Modal
           title="鍏叡鏁版嵁婧�"
           wrapClassName="interface-controller-modal"
@@ -233,10 +267,9 @@
           destroyOnClose
         > 
           <PlusOutlined key="add-interface" onClick={this.addInterface}/>
-          {/* <div style={{fontSize: '12px', position: 'relative', top: '20px'}}>娉細鎺ュ彛鎵ц瀹屾垚鍚庯紝浼氳Е鍙戦粯璁や笉鍔犺浇鐨勭粍浠跺埛鏂版暟鎹��</div> */}
           <EditTable key="manage-interface" actions={['copy']} type="interface" data={interfaces} columns={columns} onChange={this.changeScripts}/>
         </Modal>
-      </div>
+      </>
     )
   }
 }

--
Gitblit v1.8.0