Commit 03fe67658d877d4af340d556dc4d0781dea5ca8e

Authored by 潘钊
1 parent 40d61184

update...

src/main/resources/static/pages/control/lineallot_v2/iframe_wrap.html 0 → 100644
  1 +<!-- 线路选择 -->
  2 +<iframe src="/pages/control/lineallot_v2/main.html?origin=real_control_iframe" frameborder="0" style="height: 100%;width: 100%;"></iframe>
0 3 \ No newline at end of file
... ...
src/main/resources/static/pages/control/lineallot_v2/main.html 0 → 100644
  1 +<!DOCTYPE html>
  2 +<html lang="zh-cn">
  3 +
  4 +<head>
  5 + <meta charset="UTF-8">
  6 + <link rel="stylesheet" href="/assets/plugins/uk3.0/uikit.min.css"/>
  7 + <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css"/>
  8 + <!-- flatpickr -->
  9 + <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.css">
  10 + <style>
  11 + html, body {
  12 + height: 100%;
  13 + }
  14 +
  15 + .ct_page {
  16 + padding: 25px 15px;
  17 + height: 100%;
  18 + height: calc(100% - 65px);
  19 + }
  20 +
  21 + .ct_cont {
  22 + height: calc(100% - 41px);
  23 + }
  24 +
  25 + .ct_cont > div > div.uk-card {
  26 + height: 99%;
  27 + }
  28 +
  29 + .loading {
  30 + height: 100%;
  31 + text-align: center;
  32 + }
  33 +
  34 + .loading .uk-spinner {
  35 + margin-top: 200px;
  36 + }
  37 +
  38 + .loading circle {
  39 + stroke: red;
  40 + }
  41 +
  42 + .ps-container > .ps-scrollbar-x-rail, .ps-container > .ps-scrollbar-y-rail {
  43 + opacity: 0.6 !important;
  44 + padding: 0 !important;
  45 + }
  46 +
  47 + .line_list_all_wrap {
  48 + height: 200px;
  49 + overflow: auto;
  50 + position: relative;
  51 + -webkit-user-select:none;
  52 + -moz-user-select:none;
  53 + -ms-user-select:none;
  54 + user-select:none;
  55 + }
  56 +
  57 + .line_list_all_wrap > .item {
  58 + background: #fff;
  59 + color: #666;
  60 + box-shadow: 0px 3px 12px rgba(0, 0, 0, 0.08);
  61 + padding: 7px 12px;
  62 + border: 1px solid #ececec;
  63 + display: inline-block;
  64 + margin: 5px;
  65 + min-width: 70px;
  66 + text-align: center;
  67 + cursor: default;
  68 + }
  69 +
  70 + .line_list_all_wrap > .item.active{
  71 + background: #ffe9a5;
  72 + }
  73 +
  74 + .checked_list {
  75 + padding-left: 4px;
  76 + -webkit-user-select:none;
  77 + -moz-user-select:none;
  78 + -ms-user-select:none;
  79 + user-select:none;
  80 + }
  81 +
  82 + .checked_list > .item {
  83 + color: #fbfbfb;
  84 + box-shadow: 0px 3px 12px rgba(50, 197, 210, 0.3);
  85 + padding: 7px 12px;
  86 + border: 1px solid #ececec;
  87 + display: inline-block;
  88 + margin: 5px 2px;
  89 + min-width: 70px;
  90 + text-align: center;
  91 + background: #32C5D2;
  92 + cursor: move;
  93 + }
  94 +
  95 + .company_search_wrap {
  96 + width: 610px;
  97 + margin-left: 6px;
  98 + }
  99 +
  100 + .company_search_wrap select {
  101 + display: inline-block;
  102 + width: 128px;
  103 + margin-right: 12px;
  104 + }
  105 +
  106 + .uk-card {
  107 + border: 1px solid #eeeeee;
  108 + }
  109 +
  110 + .footer_tools_card {
  111 + margin-top: 20px;
  112 + padding: 20px 40px;
  113 + }
  114 +
  115 + .footer_tools_card label {
  116 + vertical-align: bottom;
  117 + display: inline-block;
  118 + font-size: 13px;
  119 + margin-left: 13px;
  120 + margin-bottom: 3px !important;
  121 + }
  122 +
  123 + .uk-button-default{
  124 + background: #e0e0e0 !important;
  125 + }
  126 + </style>
  127 +</head>
  128 +
  129 +<body>
  130 +<div class="loading">
  131 + <div uk-spinner></div>
  132 +</div>
  133 +<div class="ct_page" style="display: none;">
  134 + <h2 class="uk-heading-line uk-heading-bullet"><span>线调 <h5 style="display: inline-block;">-选择线路</h5></span></h2>
  135 + <div class="ct_cont">
  136 + <div class="allot_wrap uk-flex-center" uk-grid>
  137 + <div class="uk-card uk-card-hover uk-card-body uk-width-2-3@m"
  138 + style="padding-top: 20px;padding-bottom: 20px;">
  139 + <div class="company_search_wrap">
  140 + <select class="uk-select company_search_select"></select>
  141 + <select class="uk-select fgs_search_select" disabled>
  142 + <option value="">分公司搜索</option>
  143 + </select>
  144 + <div class="uk-inline">
  145 + <span class="uk-form-icon uk-form-icon-flip" uk-icon="icon: search"></span>
  146 + <input class="uk-input line_search_input" style="width: 310px;" placeholder="搜索线路">
  147 + </div>
  148 + </div>
  149 + <hr>
  150 + <div class="line_list_all_wrap"></div>
  151 + <hr>
  152 + <div class="checked_list" uk-sortable> </div>
  153 + </div>
  154 +
  155 + <div class="uk-card uk-card-hover uk-card-body uk-width-2-3@m footer_tools_card">
  156 + <button class="uk-button uk-button-default uk-button-large" style="font-size: 16px" id="go_to_real_system_btn"><i
  157 + uk-icon=" icon: sign-in" style="margin-right: 5px;" ></i>进入线路调度
  158 + </button>
  159 + <label class="pattern_type_label"><input class="uk-checkbox" type="checkbox" > 主调模式登录</label>
  160 + <label class="new_window_open_label" title="可能会被浏览器阻止新建窗口" uk-tooltip><input class="uk-checkbox" type="checkbox"> 新窗口打开</label>
  161 + </div>
  162 +
  163 + <div class="uk-alert-warning uk-width-2-3@m " uk-alert>
  164 + <p>注意!!! 相关“设备调试人员”和“测试人员”不要以主调模式进入线调。</p>
  165 + </div>
  166 + </div>
  167 + </div>
  168 +</div>
  169 +
  170 +<script id="line_list_items_temp" type="text/html">
  171 + {{each list as obj i}}
  172 + <span class="item" data-id="{{obj.lineCode}}" data-gsbm="{{obj.company}}_{{obj.brancheCompany}}">{{obj.name}}</span>
  173 + {{/each}}
  174 +</script>
  175 +
  176 +<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script>
  177 +<script src="/assets/plugins/uk3.0/uikit.min.js"></script>
  178 +<script src="/assets/plugins/uk3.0/uikit-icons.min.js"></script>
  179 +<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js"></script>
  180 +<!-- EventProxy -->
  181 +<script src="/assets/js/eventproxy.js"></script>
  182 +<!-- art-template 模版引擎 -->
  183 +<script src="/assets/plugins/template.js"></script>
  184 +<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script>
  185 +<script src="/assets/plugins/pinyin.js"></script>
  186 +<script>
  187 + var allMapps = {};//线路搜索映射
  188 + var companyData = {};
  189 + var codeMapps={}; //线路编码映射
  190 + //滚动条
  191 + $('.line_list_all_wrap').perfectScrollbar();
  192 +
  193 + var ep = EventProxy.create('all_lines', 'user_author', 'company_data', function (allLines, userAuthor, company_data) {
  194 + //按用户权限过滤线路
  195 + var authArray = userAuthor.lineCodeStr.split(','),
  196 + newArray = [];
  197 + $.each(allLines, function () {
  198 + if (this.lineCode && authArray.indexOf(this.lineCode) != -1) {
  199 + newArray.push(this);
  200 + codeMapps[this.lineCode] = this;
  201 + }
  202 + });
  203 + //排序
  204 + newArray.sort(function (a, b) {
  205 + return a.name.localeCompare(b.name);
  206 + });
  207 + //创建线路搜索映射
  208 + createLineSearchMapps(newArray);
  209 +
  210 + var htmlStr = template('line_list_items_temp', {list: newArray});
  211 + $('.line_list_all_wrap').html(htmlStr);
  212 +
  213 + //过滤公司编码数据
  214 + filter_company_data.filter(newArray, convert_buss_data(company_data));
  215 + initCompanySelect();
  216 + //更新滚动条高度
  217 + setTimeout(function () {
  218 + $('.line_list_all_wrap').perfectScrollbar('update');
  219 + }, 1000);
  220 +
  221 + //登录模式
  222 + changePattern(userAuthor.pattern);
  223 + if(!userAuthor.pattern)
  224 + $('.pattern_type_label').hide().find('input')[0].checked=false;
  225 + else
  226 + $('input','.pattern_type_label')[0].checked=true;
  227 +
  228 + $('.loading').remove();
  229 + $('.ct_page').show();
  230 +
  231 + //默认选中上次记录
  232 + var lineControlItems = window.localStorage.getItem('lineControlItems');
  233 + if (lineControlItems) {
  234 + var array = JSON.parse(lineControlItems);
  235 + $.each(array, function (i, line) {
  236 + $('.item[data-id='+line.lineCode+']','.line_list_all_wrap').trigger('click');
  237 + });
  238 + }
  239 + });
  240 +
  241 + $('.pattern_type_label').on('click', function () {
  242 + var checked = $('input',this)[0].checked;
  243 + changePattern(checked);
  244 + });
  245 +
  246 + function changePattern(status) {
  247 + var btn = $('#go_to_real_system_btn'),
  248 + def='uk-button-default',
  249 + prim='uk-button-primary';
  250 + if(status){
  251 + btn.removeClass(def).addClass(prim);
  252 + }
  253 + else{
  254 + btn.removeClass(prim).addClass(def);
  255 + }
  256 + }
  257 +
  258 + /**
  259 + * 查询所有线路
  260 + */
  261 + $.get('/line/all', {destroy_eq: 0}, function (list) {
  262 + ep.emit('all_lines', list);
  263 + });
  264 +
  265 + /**用户分配的线路*/
  266 + $.get('/realControAuthority/findByCurrentUser', function (t) {
  267 + ep.emit('user_author', t);
  268 + });
  269 +
  270 + /** 查询公司编码 */
  271 + $.get('/business/all', function (rs) {
  272 + ep.emit('company_data', rs);
  273 + });
  274 +
  275 + //点击选择线路
  276 + $('.line_list_all_wrap').on('click', 'span.item', function () {
  277 + var lineCode = $(this).data('id'),
  278 + name = $(this).text();
  279 + if ($(this).hasClass('active')) {
  280 + $(this).removeClass('active');
  281 +
  282 + $('.item[data-id='+lineCode+']','.checked_list').remove();
  283 + }
  284 + else {
  285 + $(this).addClass('active');
  286 + $('.checked_list').append('<span data-id="'+lineCode+'" class="item uk-card uk-card-default">'+name+'</span>');
  287 + }
  288 + });
  289 +
  290 + $('.checked_list').on('click', '.item', function () {
  291 + var lineCode = $(this).data('id');
  292 + $('.item[data-id='+lineCode+']','.line_list_all_wrap').removeClass('active');
  293 + $(this).remove();
  294 + });
  295 +
  296 + /**
  297 + * 搜索线路
  298 + */
  299 + function search_line_list() {
  300 + var comp = $('select.company_search_select').val(),
  301 + fgs = $('select.fgs_search_select').val(),
  302 + gsbm = comp + '_' + fgs;
  303 +
  304 + if(gsbm=='_')
  305 + gsbm=null;
  306 + var allDoms = $('.line_list_all_wrap span.item');
  307 + //线路
  308 + var lineCodeArray = [];
  309 + var t = $('.line_search_input').val();
  310 + if(t){
  311 + t = t.toUpperCase();
  312 + for(var m in allMapps){
  313 + if(m.indexOf(t)!=-1)
  314 + lineCodeArray.push(allMapps[m]);
  315 + }
  316 + }
  317 +
  318 + //搜索
  319 + var show_elems = [];
  320 + for (var i=0, dom; dom = allDoms[i++];) {
  321 + if(gsbm && $(dom).data('gsbm').indexOf(gsbm)==-1)
  322 + continue;
  323 +
  324 + if(t && lineCodeArray.indexOf($(dom).data('id')+'') == -1)
  325 + continue;
  326 +
  327 + show_elems.push($(dom));
  328 + }
  329 +
  330 + //show
  331 + allDoms.hide();
  332 + for(var j=0,$dom;$dom=show_elems[j++];)
  333 + $dom.show();
  334 + }
  335 +
  336 + function createLineSearchMapps(list) {
  337 + allMapps = {};
  338 + var name, code;
  339 + for (var i = 0, line; line = list[i++];) {
  340 + name = line.name;
  341 + code = line.lineCode;
  342 + //拼音映射
  343 + allMapps[pinyin.getCamelChars(name)] = code;
  344 + allMapps[pinyin.getFullChars(name).toUpperCase()] = code;
  345 + //中文映射
  346 + allMapps[name] = code;
  347 + }
  348 + }
  349 +
  350 +
  351 + //构建公司级联下拉框
  352 + function initCompanySelect() {
  353 + var opts = '<option value="">公司搜索</option>';
  354 + for (var k in companyData) {
  355 + opts += '<option value="' + k + '">' + companyData[k].name + '</option>';
  356 + }
  357 + $('select.company_search_select').html(opts);
  358 + }
  359 +
  360 + //公司切换
  361 + $('select.company_search_select').on('change', function () {
  362 + var opts = '<option value="">分公司搜索</option>',
  363 + t = $(this).val(),
  364 + fgsSelect = $('select.fgs_search_select');
  365 + if (!t) {
  366 + fgsSelect.html(opts).attr('disabled', 'disabled');
  367 + }
  368 + else{
  369 + var array = companyData[t].childs;
  370 + for (var i = 0, fgs; fgs = array[i++];) {
  371 + opts += '<option value="' + fgs.businessCode + '">' + fgs.businessName + '</option>';
  372 + }
  373 +
  374 + fgsSelect.html(opts).removeAttr('disabled');
  375 + }
  376 + search_line_list();
  377 + });
  378 +
  379 + //分公司切换
  380 + $('select.fgs_search_select').on('change', search_line_list);
  381 +
  382 + //线路文本框输入
  383 + var flag;
  384 + $('.line_search_input').on('input', function () {
  385 + if(flag)
  386 + return;
  387 + flag = true;
  388 + setTimeout(function () {
  389 + //延迟
  390 + search_line_list();
  391 + flag = false;
  392 + }, 200);
  393 + });
  394 +
  395 + function convert_buss_data(rs) {
  396 + var baseCode;
  397 + //找到跟节点
  398 + $.each(rs, function () {
  399 + if (this.upCode == 0) {
  400 + baseCode = this.businessCode;
  401 + return false;
  402 + }
  403 + });
  404 + if (!baseCode)return;
  405 + //提取二级节点
  406 + var secondMap = {};
  407 + $.each(rs, function () {
  408 + if (this.upCode == baseCode)
  409 + secondMap[this.businessCode] = {name: this.businessName, childs: []};
  410 + });
  411 + //分公司节点
  412 + $.each(rs, function () {
  413 + if (secondMap[this.upCode])
  414 + secondMap[this.upCode].childs.push(this);
  415 + });
  416 + //排序
  417 + for (var sid in secondMap)
  418 + secondMap[sid].childs.sort(naturalSort);
  419 + return secondMap;
  420 + }
  421 +
  422 + var naturalSort = function (a, b) {
  423 + return a.businessName.localeCompare(b.businessName);
  424 + };
  425 +
  426 + /**
  427 + * 根据用户线路权限过滤公司编码数据
  428 + */
  429 + var filter_company_data = (function () {
  430 + var filter = function (lineArray, data) {
  431 + companyData = {};
  432 + var com, fCom;
  433 + $.each(lineArray, function () {
  434 + com = this.company;
  435 + fCom = this.brancheCompany;
  436 + if (!companyData[com]) {
  437 + companyData[com] = {name: data[com].name, childs: []};
  438 + }
  439 +
  440 + if (!get(fCom, companyData[com].childs)) {
  441 + companyData[com].childs.push(get(fCom, data[com].childs));
  442 + }
  443 + });
  444 + };
  445 +
  446 + function get(fgsCode, fgsArray) {
  447 + for (var i = 0, fgs; fgs = fgsArray[i++];) {
  448 + if (fgs.businessCode == fgsCode)
  449 + return fgs;
  450 + }
  451 + return null;
  452 + }
  453 +
  454 + return {
  455 + filter: filter
  456 + }
  457 + })();
  458 + var storage = window.localStorage;
  459 + $('#go_to_real_system_btn').on('click', go_to_xd_sys);
  460 + /**
  461 + * 进入线调
  462 + */
  463 + function go_to_xd_sys() {
  464 + var items = $('.checked_list .item');
  465 + if(items.length==0)
  466 + return UIkit.notification({message: '你还没有选择线路!', pos: 'bottom-center', status: 'danger'});
  467 + $(this).attr('disabled', 'disabled');
  468 +
  469 + show_btn_load(this, '更新缓存数据...');
  470 + (function () {
  471 + var ls_line_data = [];
  472 + $.each(items, function () {
  473 + ls_line_data.push(codeMapps[$(this).data('id')]);
  474 + });
  475 + //将线路基础信息写入localStorage
  476 + storage.setItem('lineControlItems', JSON.stringify(ls_line_data));
  477 + //监控模式还是主调模式
  478 + storage.setItem('operationMode', $('.pattern_type_label>input')[0].checked?1:0);
  479 +
  480 + //进入线调
  481 + var eq = EventProxy.create('cache_route', 'check_line_config', function () {
  482 + var newWinOpen = $('input','.new_window_open_label')[0].checked;
  483 + if(!newWinOpen)
  484 + top.window.location.href = "/real_control/v2";
  485 + else{
  486 + window.open("/real_control/v2");
  487 + $('#go_to_real_system_btn').html('已经尝试打开新窗口,如看不到,可能被浏览器阻止了');
  488 + }
  489 + });
  490 +
  491 + //拼接线路编码
  492 + var idx='';
  493 + $.each(ls_line_data, function () {
  494 + idx+=(this.lineCode + ',');
  495 + });
  496 + //缓存路由
  497 + idx=idx.substr(0, idx.length - 1);
  498 + $.get('/realMap/findRouteByLine', {idx: idx}, function (rs) {
  499 + if (rs) {
  500 + for(var lineCode in rs)
  501 + storage.setItem(lineCode + '_route', JSON.stringify(rs[lineCode]));
  502 +
  503 + eq.emit('cache_route');
  504 + }
  505 + });
  506 +
  507 + //检查线路配置
  508 + checkLineConfig(ls_line_data, function (rs) {
  509 + if (rs.status == 0)
  510 + eq.emit('check_line_config');
  511 + else if (rs.status == 1){
  512 + initLineConfig(rs.not, function () {
  513 + eq.emit('check_line_config');
  514 + });
  515 + }
  516 + })
  517 + })();
  518 + }
  519 +
  520 + function checkLineConfig(lsData, cb) {
  521 + var lineCodeArray = [];
  522 + $.each(lsData, function () {
  523 + lineCodeArray.push(this.lineCode);
  524 + });
  525 +
  526 + $.ajax({
  527 + url: '/lineConfig/check',
  528 + traditional: true,
  529 + data: {codeArray: lineCodeArray},
  530 + method: 'POST',
  531 + success: cb
  532 + });
  533 + }
  534 +
  535 + function initLineConfig(arr, cb) {
  536 + var i = 0;
  537 + (function () {
  538 + if (i >= arr.length) {
  539 + cb && cb();
  540 + return;
  541 + }
  542 + var f = arguments.callee
  543 + , lineCode = arr[i];
  544 +
  545 + //showLoad('初始化' + lineIds[lineCode] + '配置信息...');
  546 + $.post('/lineConfig/init/' + lineCode, function (rs) {
  547 + if (rs == 1) {
  548 + i++;
  549 + f();
  550 + }
  551 + });
  552 + })();
  553 + }
  554 +
  555 + /**
  556 + * 按钮转菊花
  557 + */
  558 + function show_btn_load(btn, msg) {
  559 + $(btn).html('<div uk-spinner></div> ' + msg);
  560 + }
  561 +</script>
  562 +</body>
  563 +</html>
0 564 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/js/north/toolbar.js
... ... @@ -48,7 +48,7 @@ var gb_northToolbar = (function () {
48 48 $('.north .north-toolbar .exit-system').on('click', function () {
49 49 //关闭websocket 连接
50 50 gb_sch_websocket.sock().close(1000, '退出线调');
51   - window.location.href = '/pages/control/lineallot/allot.html';
  51 + window.location.href = '/pages/control/lineallot_v2/iframe_wrap.html';
52 52 });
53 53  
54 54 //console.log('xd_auth', xd_auth, 'data', data);
... ...