├── LICENSE ├── demo ├── demo.html ├── img │ ├── device.png │ ├── icon.png │ ├── setting.png │ └── title-bg.png ├── js │ ├── Guid.js │ ├── Smt_topology.js │ ├── createList.js │ ├── go-debug.js │ ├── go.js │ └── index.js └── scss │ ├── .sass-cache │ ├── d7f3ed3a3437288f346dda7527e5414673bf7ee9 │ │ └── index.scssc │ └── f8ca3efc0b08d7728b2da59b5eea8823b40971d9 │ │ └── index.scssc │ ├── css │ ├── index.css │ ├── index.css.map │ └── reset.css │ └── index.scss └── readme.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 taiaiwu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /demo/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |' + item.name + '
' + item.name + '
' + item.value + '
' + input_value + '
'); 79 | M.submitEdit(text, input_value, _this); 80 | } 81 | //让input获得焦点 82 | input_dom.focus(); 83 | input_dom.off('blur', emitSubmit); 84 | input_dom.on('blur', emitSubmit); 85 | 86 | 87 | } 88 | }); 89 | } 90 | window.onload = function() { 91 | var viewOptions = { 92 | domId: 'diagramDiv', 93 | //dom id 94 | // 设备数据 95 | nodeDataArray: [{ 96 | "key": "1", 97 | "name": "router", 98 | "to": [], 99 | "__gohashid": 1144, 100 | "loc": "0 0" 101 | }, { 102 | "key": "2", 103 | "name": "网关", 104 | //"to": ["router"], 105 | "__gohashid": 1145, 106 | "loc": "-130.0000000000001 102" 107 | }, { 108 | "key": "3", 109 | "name": "SRC001", 110 | type: 'SRC001', 111 | "to": ["网关"], 112 | "__gohashid": 1146, 113 | "loc": "-197.0000000000002 296" 114 | }, { 115 | "key": "4", 116 | "name": "tts", 117 | "to": ["网关", "LED"], 118 | "__gohashid": 1147, 119 | "loc": "-36 297.0000000000001" 120 | }, { 121 | "key": "5", 122 | "name": "LED", 123 | "to": ["router"], 124 | "__gohashid": 1148, 125 | "loc": "151.9999999999999 142.0000000000001" 126 | }, { 127 | "key": "8", 128 | "name": "SRC001", 129 | type: 'SRC001', 130 | "to": ["SRC001"], 131 | "loc": "-197.0000000000002 478.0000000000001" 132 | }, { 133 | "key": "9", 134 | "name": "SRC002", 135 | type: 'SRC002', 136 | "to": ["SRC001.DO2"], 137 | "loc": "-127.0000000000002 378.0000000000001" 138 | }], 139 | linkDataArray: [{ 140 | "__gohashid": 2582, 141 | "from": "2", 142 | "to": "1", 143 | 'label': 'sss', 144 | "fromPort": "output", 145 | "toPort": "input" 146 | }, { 147 | "__gohashid": 2917, 148 | "from": "3", 149 | "to": "2", 150 | "fromPort": "output", 151 | "toPort": "input" 152 | }, { 153 | "__gohashid": 3048, 154 | "from": "4", 155 | "to": "2", 156 | "fromPort": "output", 157 | "toPort": "input" 158 | }, { 159 | "__gohashid": 5333, 160 | "from": "5", 161 | "to": "1", 162 | "fromPort": "output", 163 | "toPort": "input" 164 | }] //线条数据 可填空数组 165 | }; 166 | var panelOptions = { 167 | domId: 'myPaletteDiv', 168 | //控制面板id 169 | model: [{ 170 | name: 'router', 171 | to: [] 172 | }, { 173 | name: 'gateway', 174 | to: ['router'] 175 | }, { 176 | type: 'SRC001', 177 | name: 'SRC001', 178 | to: ['网关'] 179 | }, { 180 | type: 'SRC002', 181 | name: 'SRC002', 182 | to: ['网关'] 183 | }, { 184 | name: '传感器', 185 | to: ['SRC002'] 186 | }] 187 | }; 188 | 189 | var portChange = function(toPortId, status) { 190 | switch (true) { 191 | case status === 'start': 192 | $('.port-hint').text(toPortId).show(0); 193 | return; 194 | case status === 'changing': 195 | $('.port-hint').text(toPortId); 196 | return; 197 | case status === 'end': 198 | $('.port-hint').text(toPortId).hide(0); 199 | return; 200 | } 201 | } 202 | 203 | var listParse = function() { 204 | var listData = []; 205 | $('.group-box').each(function(i, group) { 206 | group = $(group); 207 | var name = group.children('h2').text(); 208 | var data = []; 209 | group.find('.group-item-box').each(function(i, item) { 210 | item = $(item); 211 | if (item.find('.item-content').length) { 212 | data.push({ 213 | name: item.find('.item-title p').text(), 214 | value: item.find('.item-content p').text() 215 | }); 216 | } else { 217 | data.push({ 218 | name: item.find('.item-title p').text(), 219 | value: item.find('.options p').text() 220 | }); 221 | } 222 | 223 | }); 224 | listData.push({ 225 | name: name, 226 | data: data 227 | }); 228 | }); 229 | return listData; 230 | } 231 | 232 | var getDeiveDetail = function(a, b, c) { 233 | $('.device-info-wrapper').empty(); 234 | createList(data); 235 | bindListEnevt(); 236 | } 237 | 238 | 239 | Smt_topology.init(viewOptions, panelOptions, { 240 | getDeviceDetail: getDeiveDetail, 241 | portChange: portChange 242 | }); 243 | 244 | $('.save').on('click', function() { 245 | console.log(listParse()); 246 | console.log(Smt_topology.save()); 247 | setTimeout(function() { 248 | layer.msg('保存成功'); 249 | }, 500); 250 | }); 251 | 252 | $('.reset').on('click', function() { 253 | layer.msg('重置成功'); 254 | setTimeout(function() { 255 | location.reload(); 256 | }, 500); 257 | 258 | }); 259 | } -------------------------------------------------------------------------------- /demo/scss/.sass-cache/d7f3ed3a3437288f346dda7527e5414673bf7ee9/index.scssc: -------------------------------------------------------------------------------- 1 | 3.4.22 (Selective Steve) 2 | 8c60a9686efd3385efcc3cf4b2f91e034a7da17a 3 | o:Sass::Tree::RootNode:@children[o:Sass::Tree::ImportNode :@imported_filenameI"css/reset.css:ET;[ :@filename0: @options{ :@template0: 4 | @linei:@source_rangeo:Sass::Source::Range :@start_poso:Sass::Source::Position; i:@offseti: @end_poso;; i;i: 5 | @fileI"index.scss: encoding"GBK:@importero: Sass::Importers::Filesystem: 6 | @rootI"=C:/Users/Public/Nwt/cache/recv/张睿/workflow/demo/scss; T:@real_rootI"=C:/Users/Public/Nwt/cache/recv/张睿/workflow/demo/scss; T:@same_name_warningso:Set: 7 | @hash} F:@imported_file0; 8 | 0;@ 9 | ;I"@import 'css/reset.css'; T; i;o; ;o;; i;i;o;; i;i;@;@:@has_childrenT -------------------------------------------------------------------------------- /demo/scss/.sass-cache/f8ca3efc0b08d7728b2da59b5eea8823b40971d9/index.scssc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maskTAQ/topology/2558022db9bcf5bf0039cc9617885a9f98aa6d8b/demo/scss/.sass-cache/f8ca3efc0b08d7728b2da59b5eea8823b40971d9/index.scssc -------------------------------------------------------------------------------- /demo/scss/css/index.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | @import url(reset.css); 3 | html, body { 4 | width: 100%; 5 | height: 100%; } 6 | 7 | .container { 8 | min-width: 1200px; 9 | width: 100%; 10 | height: 100%; 11 | position: relative; 12 | font-family: '微软雅黑'; } 13 | .container > div { 14 | height: 100%; 15 | position: absolute; } 16 | .container .container-panel { 17 | width: 14%; 18 | height: 100%; 19 | box-shadow: 2px 0px 12px 0px rgba(0, 128, 255, 0.2); 20 | z-index: 9; } 21 | .container .container-panel .device-library { 22 | display: flex; 23 | align-items: center; 24 | width: 100%; 25 | height: 4%; 26 | font-size: 16px; 27 | color: #515151; 28 | text-indent: 40px; 29 | background-image: url("../../img/device.png"), url("../../img/title-bg.png"); 30 | background-repeat: no-repeat; 31 | background-position: 12px center,0px 0px; } 32 | .container .container-panel #myPaletteDiv { 33 | height: 96%; } 34 | .container .container-view { 35 | left: 14%; 36 | width: 60%; 37 | background: #f1f5f8; } 38 | .container .port-hint { 39 | display: none; 40 | left: 14%; 41 | bottom: 0; 42 | width: 100px; 43 | height: 100px; 44 | line-height: 100px; 45 | text-align: center; 46 | border: 1px solid #ccc; 47 | background: #fff; 48 | color: #82a8c0; 49 | font-size: 28px; } 50 | .container .container-device-info { 51 | display: block; 52 | left: 74%; 53 | width: 26%; 54 | height: 100%; 55 | overflow: auto; 56 | position: relative; 57 | border: 1px solid #e0e0e0; } 58 | .container .container-device-info .param-setting { 59 | display: flex; 60 | align-items: center; 61 | width: 100%; 62 | height: 4%; 63 | font-size: 16px; 64 | color: #515151; 65 | text-indent: 40px; 66 | background-image: url("../../img/setting.png"), url("../../img/title-bg.png"); 67 | background-repeat: no-repeat; 68 | background-position: 12px center,0px 0px; } 69 | .container .container-device-info .device-info-wrapper { 70 | height: auto; } 71 | .container .container-device-info .device-info-wrapper .has-nothing { 72 | height: 100px; 73 | line-height: 100px; 74 | text-align: center; 75 | font-size: 20px; 76 | color: #ccc; } 77 | .container .container-device-info .button-group { 78 | position: absolute; 79 | left: 0; 80 | bottom: 0; 81 | width: 100%; 82 | height: 80px; 83 | line-height: 80px; 84 | background: #f5f5f5; 85 | border-top: 1px solid #e0e0e0; 86 | text-align: center; 87 | font-size: 0; } 88 | .container .container-device-info .button-group button { 89 | border: 1px solid red; 90 | display: inline-block; 91 | width: 100px; 92 | height: 36px; 93 | font-size: 16px; 94 | background: #ebebeb; 95 | border: 1px solid #e0e0e0; 96 | border-radius: 4px; 97 | cursor: pointer; } 98 | .container .container-device-info .button-group .save { 99 | margin-right: 10%; 100 | color: #8f8f8f; } 101 | .container .container-device-info .button-group .save:hover { 102 | color: #0d79ce; 103 | border: 1px solid #0d79ce; } 104 | .container .container-device-info .button-group .reset { 105 | color: #f55655; } 106 | .container .container-device-info .button-group .reset:hover { 107 | border: 1px solid #f55655; } 108 | 109 | .group-wrapper { 110 | width: 100%; 111 | height: 100%; 112 | padding: 20px; } 113 | .group-wrapper .group-box { 114 | margin-bottom: 20px; } 115 | .group-wrapper .group-box .group-title { 116 | display: inline-block; 117 | height: 36px; 118 | line-height: 36px; 119 | color: #6496c1; 120 | text-indent: 10px; 121 | cursor: pointer; } 122 | .group-wrapper .group-box .group-title.active i { 123 | background: url("../../img/icon.png") no-repeat 0px 0px; } 124 | .group-wrapper .group-box .group-title i { 125 | box-sizing: border-box; 126 | margin-top: 6px; 127 | float: left; 128 | width: 24px; 129 | height: 24px; 130 | background: url("../../img/icon.png") no-repeat 0px -60px; 131 | cursor: pointer; } 132 | .group-wrapper .group-box .group-item-wrapper { 133 | margin-top: 10px; 134 | border: 1px solid #e0e0e0; 135 | border-right: none; 136 | border-bottom: none; } 137 | .group-wrapper .group-box .group-item-wrapper .group-item-box { 138 | height: 36px; 139 | line-height: 36px; 140 | background: #f5f5f5; } 141 | .group-wrapper .group-box .group-item-wrapper .group-item-box .item-title, .group-wrapper .group-box .group-item-wrapper .group-item-box .item-content, .group-wrapper .group-box .group-item-wrapper .group-item-box .options { 142 | float: left; 143 | height: 100%; 144 | border: 1px solid #e0e0e0; 145 | border-top: none; 146 | border-left: none; 147 | color: #717171; } 148 | .group-wrapper .group-box .group-item-wrapper .group-item-box .item-title p, .group-wrapper .group-box .group-item-wrapper .group-item-box .item-content p, .group-wrapper .group-box .group-item-wrapper .group-item-box .options p { 149 | text-overflow: ellipsis; 150 | white-space: nowrap; 151 | overflow: hidden; } 152 | .group-wrapper .group-box .group-item-wrapper .group-item-box .item-title { 153 | width: 30%; 154 | text-indent: 20px; } 155 | .group-wrapper .group-box .group-item-wrapper .group-item-box .item-content, .group-wrapper .group-box .group-item-wrapper .group-item-box .options { 156 | width: 70%; 157 | text-align: center; } 158 | .group-wrapper .group-box .group-item-wrapper .group-item-box .item-content.readonly p, .group-wrapper .group-box .group-item-wrapper .group-item-box .options.readonly p { 159 | color: #8f8f8f; } 160 | .group-wrapper .group-box .group-item-wrapper .group-item-box .item-content.editable p, .group-wrapper .group-box .group-item-wrapper .group-item-box .options.editable p { 161 | color: #3f7ba9; } 162 | .group-wrapper .group-box .group-item-wrapper .group-item-box .item-content.editable p:hover, .group-wrapper .group-box .group-item-wrapper .group-item-box .options.editable p:hover { 163 | border: 1px solid #2b2b2b; 164 | line-height: 34px; } 165 | .group-wrapper .group-box .group-item-wrapper .group-item-box .item-content input, .group-wrapper .group-box .group-item-wrapper .group-item-box .options input { 166 | width: 100%; 167 | height: 100%; 168 | border: none; 169 | text-align: center; } 170 | .group-wrapper .group-box .group-item-wrapper .group-item-box .options { 171 | width: 70%; 172 | position: relative; } 173 | .group-wrapper .group-box .group-item-wrapper .group-item-box .options.active ul { 174 | display: block; } 175 | .group-wrapper .group-box .group-item-wrapper .group-item-box .options p { 176 | height: 100%; 177 | text-align: center; } 178 | .group-wrapper .group-box .group-item-wrapper .group-item-box .options ul { 179 | display: none; 180 | position: absolute; 181 | top: 36px; 182 | left: 0; 183 | width: 100%; 184 | border: 1px solid #e0e0e0; 185 | border-top: none; 186 | border-bottom: none; 187 | background: #fff; } 188 | .group-wrapper .group-box .group-item-wrapper .group-item-box .options ul li { 189 | height: 30px; 190 | line-height: 30px; 191 | text-align: center; 192 | border-bottom: 1px solid #e0e0e0; 193 | cursor: pointer; } 194 | .group-wrapper .group-box .group-item-wrapper .group-item-box .options ul li:hover { 195 | color: #40a0ff; 196 | font-weight: bold; } 197 | 198 | /*# sourceMappingURL=index.css.map */ 199 | -------------------------------------------------------------------------------- /demo/scss/css/index.css.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "mappings": ";AAAQ,sBAAW;AAGnB,UAAS;EACR,KAAK,EAAC,IAAI;EACV,MAAM,EAAC,IAAI;;AAEZ,UAAU;EACT,SAAS,EAAC,MAAM;EAEhB,K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AO,EAAE,IAAI;YACb,QAAQ,EAAC,QAAQ;YACjB,GAAG,EAAC,IAAI;YACR,IAAI,EAAC,CAAC;YACN,KAAK,EAAE,IAAI;YACX,MAAM,EAAC,iBAAiB;YACxB,UAAU,EAAC,IAAI;YACf,aAAa,EAAC,IAAI;YAClB,UAAU,EAAC,IAAI;YACf,4EAAE;cACD,MAAM,EAAE,IAAI;cACZ,WAAW,EAAE,IAAI;cACjB,UAAU,EAAE,MAAM;cAClB,aAAa,EAAC,iBAAiB;cAC/B,MAAM,EAAE,OAAO;cACf,kFAAO;gBAEN,KAAK,EAAC,OAAO;gBACb,WAAW,EAAE,IAAI", 4 | "sources": ["../index.scss"], 5 | "names": [], 6 | "file": "index.css" 7 | } -------------------------------------------------------------------------------- /demo/scss/css/reset.css: -------------------------------------------------------------------------------- 1 | html{ 2 | color:#000; 3 | background:#FFF; 4 | } 5 | body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td { 6 | margin:0; 7 | padding:0; 8 | box-sizing:border-box; 9 | } 10 | button{ 11 | border:none; 12 | background:none; 13 | outline:none; 14 | } 15 | table { 16 | border-collapse:collapse; 17 | border-spacing:0; 18 | } 19 | fieldset, img { 20 | border:0; 21 | } 22 | address, caption, cite, code, dfn, em, th, var { 23 | font-style:normal; 24 | font-weight:normal; 25 | } 26 | li { 27 | list-style:none; 28 | } 29 | caption, th { 30 | text-align:left; 31 | } 32 | h1, h2, h3, h4, h5, h6 { 33 | font-size:100%; 34 | font-weight:normal; 35 | } 36 | q:before, q:after { 37 | content:''; 38 | } 39 | abbr, acronym { 40 | border:0; 41 | font-variant:normal; 42 | } 43 | sup { 44 | vertical-align:text-top; 45 | } 46 | sub { 47 | vertical-align:text-bottom; 48 | } 49 | input, textarea, select { 50 | font-family:inherit; 51 | font-size:inherit; 52 | font-weight:inherit; 53 | outline: none; 54 | } 55 | input, textarea, select { 56 | *font-size:100%; 57 | } 58 | legend { 59 | color:#000; 60 | } 61 | a{ 62 | text-decoration: none!important; 63 | } 64 | i{ 65 | font-style:normal; 66 | } 67 | 68 | 69 | 70 | .clearfix:after{ 71 | content: "."; /**//*内容为“.”就是一个英文的句号而已。也可以不写。*/ 72 | display: block; /**//*加入的这个元素转换为块级元素。*/ 73 | clear: both; /**//*清除左右两边浮动。*/ 74 | visibility: hidden; /**//*可见度设为隐藏。注意它和display:none;是有区别的。visibility:hidden;仍然占据空间,只是看不到而已;*/ 75 | line-height: 0; /**//*行高为0;*/ 76 | height: 0; /**//*高度为0;*/ 77 | font-size:0; /**//*字体大小为0;*/ 78 | } 79 | 80 | .clearfix{ *zoom:1;} /**//*这是针对于IE6的,因为IE6不支持:after伪类,这个神奇的zoom:1让IE6的元素可以清除浮动来包裹内部元素。*/ 81 | -------------------------------------------------------------------------------- /demo/scss/index.scss: -------------------------------------------------------------------------------- 1 | @import 'reset.css'; 2 | 3 | 4 | html,body{ 5 | width:100%; 6 | height:100%; 7 | } 8 | .container{ 9 | min-width:1200px; 10 | //max-height:800px; 11 | width:100%; 12 | height:100%; 13 | position:relative; 14 | font-family:'微软雅黑'; 15 | >div{ 16 | height: 100%; 17 | position:absolute; 18 | } 19 | // &.list-close{ 20 | // .container-view{ 21 | // width: 86%; 22 | // } 23 | // .container-device-info{ 24 | // display: none; 25 | // } 26 | // } 27 | .container-panel{ 28 | width: 14%; 29 | height: 100%; 30 | box-shadow: 2px 0px 12px 0px rgba(0, 128, 255, 0.2); 31 | z-index: 9; 32 | 33 | .device-library{ 34 | display: flex; 35 | align-items: center; 36 | width: 100%; 37 | height: 4%; 38 | font-size: 16px; 39 | color: #515151; 40 | text-indent: 40px; 41 | background-image:url('../../img/device.png'),url('../../img/title-bg.png'); 42 | background-repeat:no-repeat; 43 | background-position:12px center,0px 0px; 44 | } 45 | #myPaletteDiv{ 46 | height: 96%; 47 | } 48 | } 49 | .container-view{ 50 | left: 14%; 51 | width: 60%; 52 | background: #f1f5f8; 53 | 54 | } 55 | .port-hint{ 56 | display: none; 57 | left: 14%; 58 | bottom: 0; 59 | width: 100px; 60 | height: 100px; 61 | line-height: 100px; 62 | text-align: center; 63 | border:1px solid #ccc; 64 | background:#fff; 65 | color: #82a8c0; 66 | font-size: 28px; 67 | } 68 | .container-device-info{ 69 | display: block; 70 | left: 74%; 71 | width: 26%; 72 | height: 100%; 73 | overflow: auto; 74 | position:relative; 75 | border: 1px solid #e0e0e0; 76 | .param-setting{ 77 | display: flex; 78 | align-items: center; 79 | width: 100%; 80 | height: 4%; 81 | font-size: 16px; 82 | color: #515151; 83 | text-indent: 40px; 84 | background-image:url('../../img/setting.png'),url('../../img/title-bg.png'); 85 | background-repeat:no-repeat; 86 | background-position:12px center,0px 0px; 87 | } 88 | .device-info-wrapper{ 89 | height: auto; 90 | .has-nothing{ 91 | height: 100px; 92 | line-height: 100px; 93 | text-align:center; 94 | font-size: 20px; 95 | color: #ccc; 96 | } 97 | } 98 | .button-group{ 99 | position:absolute; 100 | left: 0; 101 | bottom:0; 102 | width: 100%; 103 | height: 80px; 104 | line-height: 80px; 105 | background:#f5f5f5; 106 | border-top:1px solid #e0e0e0; 107 | text-align: center; 108 | font-size: 0; 109 | button{ 110 | border:1px solid red; 111 | display: inline-block; 112 | width: 100px; 113 | height: 36px; 114 | font-size: 16px; 115 | background:#ebebeb; 116 | border:1px solid #e0e0e0; 117 | border-radius:4px; 118 | cursor: pointer; 119 | } 120 | .save{ 121 | margin-right: 10%; 122 | color: #8f8f8f; 123 | &:hover{ 124 | color: #0d79ce; 125 | border:1px solid #0d79ce; 126 | } 127 | } 128 | .reset{ 129 | color: #f55655; 130 | &:hover{ 131 | border:1px solid #f55655; 132 | } 133 | } 134 | } 135 | } 136 | } 137 | 138 | .group-wrapper{ 139 | width:100%; 140 | height:100%; 141 | padding:20px; 142 | .group-box{ 143 | margin-bottom: 20px; 144 | .group-title{ 145 | display: inline-block; 146 | height: 36px; 147 | line-height: 36px; 148 | color: #6496c1; 149 | text-indent: 10px; 150 | cursor: pointer; 151 | &.active{ 152 | i{ 153 | background:url('../../img/icon.png') no-repeat 0px 0px; 154 | } 155 | } 156 | i{ 157 | box-sizing:border-box; 158 | margin-top: 6px; 159 | float: left; 160 | width: 24px; 161 | height: 24px; 162 | background:url('../../img/icon.png') no-repeat 0px -60px; 163 | cursor: pointer; 164 | } 165 | } 166 | .group-item-wrapper{ 167 | margin-top: 10px; 168 | border:1px solid #e0e0e0; 169 | border-right:none; 170 | border-bottom:none; 171 | .group-item-box{ 172 | height: 36px; 173 | line-height: 36px; 174 | background:#f5f5f5; 175 | .item-title,.item-content,.options{ 176 | float: left; 177 | height: 100%; 178 | border:1px solid #e0e0e0; 179 | border-top:none; 180 | border-left:none; 181 | color: #717171; 182 | p{ 183 | text-overflow: ellipsis; 184 | white-space: nowrap; 185 | overflow: hidden; 186 | } 187 | } 188 | .item-title{ 189 | width: 30%; 190 | text-indent: 20px; 191 | } 192 | .item-content,.options{ 193 | width: 70%; 194 | text-align: center; 195 | &.readonly{ 196 | p{ 197 | color:#8f8f8f; 198 | } 199 | } 200 | &.editable{ 201 | p{ 202 | color:#3f7ba9; 203 | &:hover{ 204 | border:1px solid #2b2b2b; 205 | line-height: 34px; 206 | } 207 | } 208 | } 209 | input{ 210 | width: 100%; 211 | height: 100%; 212 | border:none; 213 | text-align: center; 214 | } 215 | } 216 | .options{ 217 | width: 70%; 218 | position:relative; 219 | &.active{ 220 | ul{ 221 | display: block; 222 | } 223 | } 224 | p{ 225 | height: 100%; 226 | text-align: center; 227 | } 228 | ul{ 229 | display: none; 230 | position:absolute; 231 | top:36px; 232 | left:0; 233 | width: 100%; 234 | border:1px solid #e0e0e0; 235 | border-top:none; 236 | border-bottom:none; 237 | background:#fff; 238 | li{ 239 | height: 30px; 240 | line-height: 30px; 241 | text-align: center; 242 | border-bottom:1px solid #e0e0e0; 243 | cursor: pointer; 244 | &:hover{ 245 | //background:#6b6b6b; 246 | color:#40a0ff; 247 | font-weight: bold; 248 | } 249 | } 250 | } 251 | } 252 | } 253 | } 254 | } 255 | 256 | } -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # 基于go.js 的动态绘制拓扑图插件 2 | 3 | ## 使用方法 4 | 1. 引入go.js 5 | 2. 引入Smt_topology.js 6 | 7 | ````javascript 8 | 初始化界面 9 | ```` 10 | 11 | ````javascript 12 | Smt_topology.init({ 13 | domId: 'domId', 14 | //dom id 15 | // 设备数据 16 | nodeDataArray: [{ 17 | //设备key 18 | key: '1', 19 | //设备名称 20 | name: 'co2', 21 | //设备可接入其他设备的名称集 必须是数组 可不填此选项 22 | to: ['co2', 'co3'] 23 | }, 24 | { 25 | key: '2', 26 | name: 'co3', 27 | to: ['co4', 'co3'] 28 | }], 29 | linkDataArray: [] //线条数据 可填空数组 30 | }, 31 | { 32 | domId: 'id',//控制面板id 33 | model: [{ 34 | name: 'router', 35 | to: [] 36 | }, 37 | { 38 | name: 'gateway', 39 | to: ['router'] 40 | }, 41 | { 42 | type: 'SRC001', 43 | name: 'SRC001', 44 | to: ['网关'] 45 | }, 46 | { 47 | type: 'SRC002', 48 | name: 'SRC002', 49 | to: ['网关'] 50 | }, 51 | { 52 | name: '传感器', 53 | to: ['SRC002'] 54 | }] 55 | }); 56 | ```` 57 | 58 | 添加设备 59 | ````javascript 60 | Smt_topology.createDevice({ 61 | name: 'deviceName',//设备名 62 | to: ['co2']//设备可接入其他设备的名称集 必须是数组 可不填此选项 63 | }); 64 | ```` 65 | 66 | 保存数据 67 | ````javascript 68 | Smt_topology.save();//返回包含设备信息和线条信息的对象 69 | ```` 70 | --------------------------------------------------------------------------------