Browse Source

数据源接口对接调整

zhuth 7 years ago
parent
commit
793edcd38a

+ 1 - 1
app/components/datasource/dataConnectBox.jsx

@@ -27,7 +27,7 @@ const DataConnectBox = ({operation, dispatch, dataConnect, visibleBox, hideBox,
 
     return (
         <Modal
-            className='newdataconnect-box'
+            className='dataconnect-box'
             title={`${operation=='create'?'新增':'修改'}数据库连接配置`}
             visible={visibleBox}
             onOk={() => {okHandler(dataConnect.newOne)}}

+ 3 - 13
app/components/datasource/dataSource.less

@@ -99,20 +99,13 @@
     }
 }
 
-.newdatasource-box {
-    top: 0px;
-    height: 90%;
-    width: 90% !important;
+.dataconnect-box {
+    width: 600px !important;
     .ant-modal-content {
-        height: 100%;
         .ant-modal-body {
             padding: 6px;
-            max-height: 382px;
+            max-height: 50vh;
             overflow-y: auto;
-            .textarea-target {
-                margin-top: 4px;
-                margin-bottom: 3px;
-            }
             .textarea-desc {
                 margin-top: 4px;
             }
@@ -125,9 +118,6 @@
                 }
             }
         }
-        .ant-modal-footer {
-            height: 32px;
-        }
     }
 }
 .ant-table-body::-webkit-scrollbar {/*滚动条整体样式*/

+ 1 - 2
app/components/datasource/datasource.jsx

@@ -230,8 +230,7 @@ class DataSource extends React.Component {
                     }}><Icon type="plus"/>创建数据源</div>
                     <div className='operation'><Divider type="vertical" /></div>
                     <div className='operation' onClick={() => {
-                        let selectedModel = dataConnect.list.find((i) => { return i.code == record.code });
-                        dispatch({ type: 'dataConnect/remoteDelete', model: selectedModel });
+                        dispatch({ type: 'dataConnect/remoteDelete', code: record.code });
                     }}><Icon type="delete"/>删除</div>
                 </div>
             ),

+ 17 - 5
app/models/dataConnect.js

@@ -170,17 +170,29 @@ export default {
             }
         },
         *remoteDelete(action, { select, call, put, takeEvery, takeLatest }) {
-            const model = action.model;
+            const dataConnect = yield select(state => state.present.dataConnect);
+            const code = action.code;
+            let list = dataConnect.list;
             try {
                 const res = yield call(service.fetch, {
                     url: URLS.DATACONNECT_DELETE,
-                    body: {
-                    }
+                    body: [code]
                 });
-                // yield put({ type: 'add' });
-                message.success('删除成功');
+                if(!res.err && res.data.code > 0) {
+                    for(let i = 0; i < list.length; i++) {
+                        if(list[i].code == code) {
+                            list.splice(i, 1);
+                            break;
+                        }
+                    }
+                    yield put({ type: 'list', data: list });
+                    message.success('删除成功');
+                }else {
+                    message.error('删除失败');
+                }
             }catch(e) {
                 message.error('删除失败');
+                console.log(e);
             }
         }
     },

+ 5 - 0
app/models/main.js

@@ -16,5 +16,10 @@ export default {
             yield put(routerRedux.push(path || '/'));
             yield put({ type: 'setPath', path });
         },
+    },
+    subscriptions: {
+        setup({ dispatch, history }) {
+            
+        }
     }
 };