UpdateAnaInfo.jsp 43.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
<%--
  Created by IntelliJ IDEA.
  User: molinyi
  Date: 2017/11/25 0025
  Time: 下午 2:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
13
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>全网监控智能分析平台</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">

    <script src="${ctx}/static/artDialog4.1.7/artDialog.source.js?skin=default"></script>
    <script src="${ctx}/static/artDialog4.1.7/plugins/iframeTools.source.js"></script>
    <style>
        .table-null .table {
            margin-bottom: 0px;
        }

        .table-null .table > tbody > tr > td, .table-null .table > thead > tr > th {
            text-align: center;
            width: 25%;
        }

        .table-null td:first-child {
            text-align: right;
            width: 36%;
        }

        .table-null tr td:last-child .form-control, .table-null tr td:last-child table {
            width: 400px;
        }

        .file-box {
            position: relative;
        }

        .file {
            position: absolute;
            top: 0;
            height: 30px;
            filter: alpha(opacity:0);
            opacity: 0;
            width: 470px;
            cursor: pointer;
        }


    </style>
</head>
<body>

<div class="container">
    <ol class="breadcrumb">
        <li><a href="${ctx}/index">首页</a></li>
        <li>监控运营</li>
        <li class="active">告警关联诊断</li>
    </ol>
</div>

<div id="main-container main-tab-container">
    <div id="content" class="container">
        <div class="section">
            <div class="tab-content">

                <div class="tab-pane fade in active" id="home">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="table-header">修改关联配置</div>

                            <form action="#" class="form-horizontal" id="modelMaintainForm" method="post"
                                  enctype="multipart/form-data">
                                <table id="modelMaintainTable" class="table-null">
莫林毅's avatar
莫林毅 committed
86
                                    <input type="hidden" id="associationId" value="${anaInfo.associationId}">
87 88 89 90
                                    <input type="hidden" id="dimKpiSelectedList" value="${dimKpiSelectedList}">
                                    <tr>
                                        <td>省份:</td>
                                        <td>
91
                                            <select class="form-control" name="proviceTd" id="proviceTd" disabled>
92
                                                <c:forEach var="provice" items="${proviceList}">
93 94 95 96 97 98 99 100 101 102 103
                                                    <c:if test="${provice.provinceId ==32}">
                                                        <c:choose>
                                                            <c:when test="${provice.provinceId == anaInfo.provinceId}">
                                                                <option value="${provice.provinceId}"
                                                                        selected disabled>${provice.provinceName}</option>
                                                            </c:when>
                                                            <c:otherwise>
                                                                <option value="${provice.provinceId}">${provice.provinceName}</option>
                                                            </c:otherwise>
                                                        </c:choose>
                                                    </c:if>
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
                                                </c:forEach>
                                            </select>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>维度:</td>
                                        <td><select class="form-control" name="dimensionTd" id="dimensionTd">
                                            <c:forEach var="modelType" items="${dimensionList}">

                                                <c:choose>
                                                    <c:when test="${modelType.value == anaInfo.associationType}">
                                                        <option value="${modelType.value}"
                                                                selected>${modelType.name}</option>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <option value="${modelType.value}">${modelType.name}</option>
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:forEach>
                                        </select></td>
                                    </tr>
                                    <tr>
                                        <td>描述(<font color="red">必填</font>):</td>
                                        <td><input type="text" class="form-control" name="descTd" id="descTd"
                                                   style="display: inline;" value="${anaInfo.assoicationDesc}"/>
                                            <span id="writeWarningInf"
                                                  style="color:red;display: inline;padding-left:10px;"></span></td>
                                    </tr>


                                    <tr>
                                        <td>添加指标:</td>
                                        <td><table class="table table-hover table-striped" id="displayParam">
                                            <thead>
                                                <tr>

                                                        <input type="hidden" class="btn btn-default" id="modelReset2"/>
142
                                                    <th>指标名称</th><th style="display: none">权重值</th><th><a href="javascript:deleteAllTr()">删除所有</a></th>
143 144 145 146 147 148
                                                </tr>

                                            </thead>
                                            <tbody id="addTr">
                                                <c:forEach items="${dimKpiSelectedList}" var="dimKpi">
                                                    <tr class="${dimKpi.kpiId}"  id='dimKpiCheck_${dimKpi.kpiId}'>
149
                                                        <td title="${dimKpi.code}">${dimKpi.name}</td>
150 151
                                                        <c:forEach items="${anaInfo.items}" var="ite">
                                                            <c:if test="${ite.kpiId == dimKpi.kpiId}">
152
                                                                <%--<td>${ite.kpiWeight}</td>--%>
153
                                                                <td style="display: none"><fmt:formatNumber type="number" value="${ite.kpiWeight}" pattern="0.00" maxFractionDigits="1"/></td>
154

155 156
                                                            </c:if>
                                                        </c:forEach>
157
                                                        <td><a href='javascript:void(0);' id="deleteRow" <%--title='${dimKpi.kpiId}'--%> onclick='deleteRow(this)'>删除</a>&nbsp;&nbsp;</td><%--  <a href='javascript:;' onclick='updateRow(this)'>修改</a> --%>
158 159 160 161 162 163 164 165 166 167 168 169
                                                    </tr>
                                                </c:forEach>

                                            </tbody>
                                        </table>
                                        </td>
                                    </tr>
                                    <tr>

                                    <tr id="dataSourceTr">
                                        <td>数据源:</td>
                                        <td>
170 171 172 173 174 175
                                            <label>
                                                <div class="checkbox-inline">
                                                    <input type="checkbox" name="dataSourceRadioAll" value="全选"
                                                           onclick="dataSourceRadioAllCheckedClick()"/><font color="#FF0000">全选</font>
                                                </div>
                                            </label>
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
                                            <c:forEach items="${dataSourceList}" var="dataSource">
                                                <div class="checkbox-inline">
                                                    <label>
                                                        <input type="checkbox" name="dataSourceRadio"
                                                               onclick="dataSourceRadioClick()" class="provinceDetail"
                                                               title="${dataSource.dataSourceName}"
                                                               value="${dataSource.dataSourceId}"/>${dataSource.dataSourceName}
                                                    </label>
                                                </div>
                                            </c:forEach>

                                        </td>
                                    </tr>
                                    <tr id="channelTr">
                                        <td>渠道:</td>
                                        <td>
192 193 194 195 196 197
                                            <label>
                                                <div class="checkbox-inline">
                                                    <input type="checkbox" name="channelRadioAll" value="全选"
                                                           onclick="channelRadioAllCheckedClick()"/><font color="#FF0000">全选</font>
                                                </div>
                                            </label>
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
                                            <c:forEach items="${channelList}" var="channel">
                                                <div class="checkbox-inline">
                                                    <label>
                                                        <input type="checkbox" name="channelRadio"
                                                               onclick="channelRadioClick()" class="provinceDetail"
                                                               title="${channel.channelId}"
                                                               value="${channel.channelId}"/>${channel.channelName}
                                                    </label>
                                                </div>
                                            </c:forEach>
                                        </td>
                                    </tr>

                                    <tr id="businessTr">
                                        <td>业务:</td>
                                        <td id="businessActivedListTd">

                                        </td>


                                    </tr>
                                    <tr id="tr_id_dimkpi">
                                        <td>指标:</td>
                                        <td id="dimKpiListTd">

                                        </td>
                                    </tr>
225
                                    <tr id="tr_id_weight" style="display: none">
226
                                        <td>权重(<font color="red">必填</font>):</td>
227
                                        <td><input type="number" step="0.01" class="form-control" name="descTd" id="kpiWeightTd" style="display: inline;" />
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
                                            <span id="writeWarningInfTd" style="color:red;display: inline;padding-left:10px;"></span></td>
                                    </tr>

                                    <tr>
                                        <td></td>
                                        <td>
                                        </td>
                                    </tr>




                                    <tr>
                                        <td></td>
                                        <td>
                                            <button type="button" id="addAnaInfo" class="btn btn-primary">添加勾选指标</button>
                                            <button type="button" id="updateAnaInf" class="btn btn-info btn-small">
                                                修改指标
                                            </button>
                                            <button type="button" id="updateAnaInfo" class="btn btn-primary">更新</button>
                                            <button type="reset" class="btn btn-default" id="modelReset">取消</button>
249
                                            <%--<button type="button" id="deleteAnaInfo" class="btn btn-danger">删除</button>--%>
250 251 252 253 254 255 256 257 258 259 260 261
                                            <button type="reset" class="btn btn-warning" id="modelBack">返回</button>
                                        </td>
                                    </tr>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
莫林毅's avatar
莫林毅 committed
262
<%--${anaInfo}--%>
263 264
<script type="text/javascript">

265
    sumkpiWeightTdVal=1.00;
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
    $(document).ready(function () {

        $("#tr_id_dimkpi").hide();
        $("#tr_id_weight").hide();
        $("#addAnaInfo").hide();
        $("#modelReset").hide();


        $("#modelReset2").hide();
        $("#channelTr").hide();
        $("#dataSourceTr").hide();
        $("#businessTr").hide();
        $("#selectAnaInfo").hide();

        $("#selectBusiness").hide();

        //权重 初始值
        kpiWeightTdInitValue = $("#kpiWeightTd").val();
        //描述 初始值
        descTdInitValue = $("#descTd").val();
286
        if($("#addTr").find("tr").length ==0){sumkpiWeightTdVal=0.00;}
287 288 289 290 291

    });

    $("#updateAnaInf").click(function () {//跟新指标按钮
        $(this).hide();
292
//        $("#kpiWeightTd").val(1-Number(sumkpiWeightTdVal));
293
        $("#kpiWeightTd").val(parseFloat((1-sumkpiWeightTdVal).toFixed(2)) === 0?'':parseFloat((1-sumkpiWeightTdVal).toFixed(2)));
294
        $("#tr_id_dimkpi").show();
295
        //$("#tr_id_weight").show();
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
        $("#addAnaInfo").show();
        $("#modelReset").show();

        $("#channelTr").show();
        $("#dataSourceTr").show();
        $("#businessTr").show();
        $("#selectAnaInfo").show();
        $("#selectBusiness").show();
    });

    $("#selectBusiness").click(function () {//查找业务按钮
        $("#businessActivedListTd").empty();
        //渠道选择值
        var channelArray = new Array();// 存放 所选 频道
        $("input[name='channelRadio']:checked").each(function (e) {
            if ($(this).attr("checked")) {
                channelArray.push($(this).context.value);
            }
        });
        //数据源选择值
        var dataSourceArray = new Array();
        $("input[name='dataSourceRadio']:checked").each(function (e) {
            if ($(this).attr("checked")) {
                dataSourceArray.push($(this).context.value);
            }
        });

        $.ajax({
            type: 'GET',
            async: true,
            contentType: 'application/json',
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/getBusinessByChannelIdListAndDataSourceIdList?dataSourceId=" + dataSourceArray + "&channelId=" + channelArray,
            dataType: 'text',
            success: function (data) {

                var jsonDa = eval('(' + data + ')');
                var strcheckBox = "";
                for (var i = 0; i < jsonDa.length; i++) {
334
                    var strInput = "<input type='checkbox' id=BusinessCheck_" + jsonDa[i].businessId + " name='BusinessCheck' onClick='BusinessCheckClick()' class='provinceDetail' title='" + jsonDa[i].businessName + "' value=" + jsonDa[i].businessId + "'/><font>" + jsonDa[i].businessName + "</font>" ;
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363

                    strcheckBox += strInput;
                }
                $("#businessActivedListTd").append(strcheckBox);
            }

        });


    });

    // 查找 指标
    $("#selectAnaInfo").click(function () {
        //$("#dimKpiListTd").empty();
        //获取选择的 业务
        var businessSelectedArr = [];
        $("input[name='BusinessCheck']").each(function (e) {

            if ($(this).attr("checked")) {
                businessSelectedArr.push($(this).context.id.split("_")[1]);
            }
        });


    });

    // 更新
    $("#updateAnaInfo").click(function () {

364
        $("#kpiWeightTd").val(parseFloat((1-sumkpiWeightTdVal).toFixed(2)) === 0?'':parseFloat((1-sumkpiWeightTdVal).toFixed(2)));
365

366
        var kk=parseFloat((sumkpiWeightTdVal).toFixed(2));
367
        /*if( kk <1.00){
368 369
            $.alert("权值总和必须为1");
            return;
370
        }*/
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
        var  kpiId_weight=getkpiIDAndWeightShallSave();

        var associationId = $("#associationId").val();

        var proviceTdSelected = $("#proviceTd option:selected").val();
        var dimensionTdSelected = $("#dimensionTd option:selected").val();//getArrDimensionTdSelected();

        var arrDimKpiChecked = getArrDimKpiChecked();
        var descTdV = $("#descTd").val();
        //var kpiWeightTdV = $("#kpiWeightTd").val();
        //var weightDimKpiChecked=getWeightDimKpiChecked(); // 指标  weight
        //var arrIdAndWeightDimKpiChecked=getArrIdAndWeightDimKpiChecked();// 指标  id_weight

       /* if(weightDimKpiChecked.length != arrIdAndWeightDimKpiChecked.length ){
            $.alert("权重不能为空");
            return;
        }*/
        if ($.trim(descTdV) == "") {
            $.alert("描述不能为空");
            return;
        }
        /*if ($.trim(kpiWeightTdV) == "") {
            $.alert("权重不能为空");
            return;
        }*/
        if(kpiId_weight.length <= 0){
            $.alert("指标不能为空");
            return;
        }

莫林毅's avatar
莫林毅 committed
401 402
        $("#updateAnaInfo").attr("disabled","disabled");

403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
        $.ajax({
            type: 'GET',
            async: true,
            contentType: 'application/json',
            data: {
                associationId: associationId,
                proviceTdSelected: proviceTdSelected,
                dimensionTdSelected: dimensionTdSelected,
                descTdV: descTdV,

            },
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/updateAssociDigConfig?kpiId_weight=" + kpiId_weight,
            dataType: 'text',
            success: function (data) {

                $.alert(data);
                setTimeout(function () {
                    location.href = "${ctx}/MonitorOperation/AssociateDiagosisConfiguration";
                }, 2000);
            }

        });


    });

    $("#deleteAnaInfo").click(function () {

        $.dialog({
            title: "提醒",
            content: "真的要删除该配置项目?",
            ok: function () {
                var associationId = $("#associationId").val();
                $.ajax({
                    type: 'GET',
                    async: true,
                    contentType: 'application/json',
                    data: {associationId: associationId},
                    url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/deleteAssociDigConfig",
                    dataType: 'text',
                    success: function (data) {

                        $.alert(data);
                        setTimeout(function () {
                            location.href = "${ctx}/MonitorOperation/AssociateDiagosisConfiguration";
                        }, 2000);

                    }

                });
            },
            okValue: "确定",
            cancel: function () {
            },
            cancelValue: "取消",
            lock: true
        });

    });
    $("#modelBack").click(function () {

        location.href = "${ctx}/MonitorOperation/AssociateDiagosisConfiguration";
    });

    function getArrDimKpiChecked() {
        var arrDimKpiChecked = [];
        $("input[name='dimKpiCheck']").each(function (e) {
            if ($(this).attr("checked")) {
                arrDimKpiChecked.push($(this).context.id.split("_")[1]);

            }
        });
        return arrDimKpiChecked;
    }

    function getWeightDimKpiChecked() {
        var weightDimKpiChecked = [];
        $("input[name='dimKpiCheck']").each(function (e) {
            if ($(this).attr("checked")) {
                var kpiWeight_="kpiWeight_"+$(this).context.id.split("_")[1];
                var nu=Number($("input[name="+kpiWeight_+"]").val());
                if(nu != 0){
                    weightDimKpiChecked.push(nu);
                }
//                weightDimKpiChecked.push(Number($("input[name="+kpiWeight_+"]").val()));
            }
        });
        return weightDimKpiChecked;
    }

    // 指标 id_weight
    function getArrIdAndWeightDimKpiChecked() {
        var arrIdAndWeightDimKpiChecked = [];
        $("input[name='dimKpiCheck']").each(function (e) {
            if ($(this).attr("checked")) {
                var kpiWeight_="kpiWeight_"+$(this).context.id.split("_")[1];
                arrIdAndWeightDimKpiChecked.push($(this).context.id.split("_")[1]+"_"+$("input[name="+kpiWeight_+"]").val());
            }
        });
        return arrIdAndWeightDimKpiChecked;
    }

    function getArrDimensionTdSelected() {

        var dimensionTdSelected = [];
        $("input[name='dimensionTd']").each(function (e) {
            if ($(this).attr("selected")) {
                dimensionTdSelected.push($(this).context.id.split("_")[1]);
            }
        });
        return dimensionTdSelected;

    }

517
    //业务 复选框点击
518
    function BusinessCheckClick() {
519 520
        // 清空  指标 一栏 所有 指标
        $("#dimKpiListTd").empty();
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543

        //$("#dimKpiListTd").empty();
        //获取选择的 业务
        var businessSelectedArr =new Array();
        $("input[name='BusinessCheck']").each(function (e) {

            if ($(this).attr("checked")) {
                businessSelectedArr.push($(this).context.id.split("_")[1]);
            }
        });
        if (businessSelectedArr.length < 1) {
            return;
        }


        var dimKpiHadSelectedArr = new Array();//原有的指标
        $("#addTr").find("tr").each(function(){
            var id=$(this).attr("id");
            id=Number(id.split("_")[1]);
            dimKpiHadSelectedArr.push(id);
        });

        // 重置  指标 一栏 筛选保留原有的 指标
544
        /*$("input[name='dimKpiCheck']").each(function (e) {
545 546 547 548 549
            if (!$(this).attr("checked")) {
                $(this).next().remove();
                $(this).remove();

            }
550 551
        });*/

552 553 554 555 556 557 558 559 560 561 562 563
        var arrdimKpiChecked=getValueOfNamedimKpiCheck();


        $.ajax({
            type: 'GET',
            async: true,
            contentType: 'application/json',
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/getDimKpiListByBusinessIdList?businessIdList=" + businessSelectedArr,
            dataType: 'text',
            success: function (data) {

                var jsonDa = eval('(' + data + ')');
564
                var colLength=0;
565 566 567 568 569 570 571 572 573
                for (var i = 0; i < jsonDa.length; i++) {


                    if (dimKpiHadSelectedArr.indexOf(jsonDa[i].kpiId) >= 0) {
                       continue;
                    }
                    if(arrdimKpiChecked.indexOf(jsonDa[i].kpiId) >= 0){
                        continue;
                    }
574 575 576 577
                    if(colLength == 0){
                        $("#dimKpiListTd").append(
                            "<input type='checkbox' value='全选' name='dimKpiAllChecked' onclick='dimKpiAllCheckedClick()'/><font color='#FF0000'>全选</font>")
                    }
578
                    var strInput = "<input type='checkbox' id=dimKpiCheck_" + jsonDa[i].kpiId + " name='dimKpiCheck' class='provinceDetail' title='"+jsonDa[i].code+ "' value=" + jsonDa[i].kpiId + "'/><font>" + jsonDa[i].name + "</font>";
579
                    if((colLength !=0)&&((colLength+1)%5 ===0)){strInput=strInput+'<br>'}
580
                    $("#dimKpiListTd").append(strInput);
581
                    colLength=colLength+1;
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
                }
            }
        });
    }

    function getValueOfNamedimKpiCheck(){
        var arr=new Array();
        $("input[name='dimKpiCheck']").each(function (e) {
            if ($(this).attr("checked")) {
                var dimKpiHadCheckId = Number($(this).attr("id").split("_")[1]);
                arr.push(dimKpiHadCheckId);
            }
        });
        return arr;
    }

    function getkpiid_NameOfNamedimKpiCheck(){
        var arr=new Array();
        $("input[name='dimKpiCheck']").each(function (e) {
            if ($(this).attr("checked")) {
                var dimKpiHadCheckId = Number($(this).attr("id").split("_")[1]);
603 604
                var dimKpiHadCheckCode = $(this).attr("title");
                var dimKpiHadCheckName = $(this).next().text();
605
                arr.push(dimKpiHadCheckId+"&"+dimKpiHadCheckName+"&"+dimKpiHadCheckCode);
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625
            }
        });
        return arr;
    }
    function doresetDimKpiArr() {

        var arrDimKpiChecked = [];
        $("input[name='dimKpiCheck']").each(function (e) {
            if (!$(this).attr("checked")) {
                arrDimKpiChecked.push($(this).context.id.split("_")[1]);
                $(this).remove();
                $(this).next().remove();
            }
        });
        return arrDimKpiChecked;


    }

    function channelRadioClick() {
626
        $("input[name='channelRadioAll']").removeAttr('checked');
627 628

        $("#businessActivedListTd").empty();
629 630 631 632 633 634 635 636 637 638
        $("#dimKpiListTd").empty();

        // 重置  指标 一栏 筛选保留原有的 和已选择的 指标
        /*$("input[name='dimKpiCheck']").each(function (e) {
            if (!$(this).attr("checked")) {
                $(this).next().remove();
                $(this).remove();

            }
        });*/
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
        //渠道选择值
        var channelArray = new Array();// 存放 所选 频道
        $("input[name='channelRadio']:checked").each(function (e) {
            if ($(this).attr("checked")) {
                channelArray.push($(this).context.value);
            }
        });
        //数据源选择值
        var dataSourceArray = new Array();
        $("input[name='dataSourceRadio']:checked").each(function (e) {
            if ($(this).attr("checked")) {
                dataSourceArray.push($(this).context.value);
            }
        });
        if (dataSourceArray.length < 1 || channelArray.length < 1) {
            return;
        }

        $.ajax({
            type: 'GET',
            async: true,
            contentType: 'application/json',
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/getBusinessByChannelIdListAndDataSourceIdList?dataSourceId=" + dataSourceArray + "&channelId=" + channelArray,
            dataType: 'text',
            success: function (data) {

                var jsonDa = eval('(' + data + ')');
666
                var strcheckBox = "<input type='checkbox' name='BusinessCheckALL' onclick='BusinessCheckALLCLICK()' value='全选'/><font color='#FF0000'>全选</font>";
667
                for (var i = 0; i < jsonDa.length; i++) {
668
                    var strInput = "<input type='checkbox' id=BusinessCheck_" + jsonDa[i].businessId + " name='BusinessCheck' onClick='BusinessCheckClick()' class='provinceDetail' title='" + jsonDa[i].businessName + "' value=" + jsonDa[i].businessId + "'/>" + jsonDa[i].businessName;
669
                    if((i !=0)&&((i+1)%6 ===0)){strInput=strInput+'<br>'}
670 671 672 673 674 675 676 677 678 679 680 681
                    strcheckBox += strInput;
                }
                $("#businessActivedListTd").append(strcheckBox);
            }

        });

    }

    function dataSourceRadioClick() {


682
        $("input[name='dataSourceRadioAll']").removeAttr('checked');
683
        $("#businessActivedListTd").empty();
684 685 686 687 688 689 690 691 692
        $("#dimKpiListTd").empty();
        // 重置  指标 一栏 筛选保留原有的 和已选择的 指标
        /*$("input[name='dimKpiCheck']").each(function (e) {
            if (!$(this).attr("checked")) {
                $(this).next().remove();
                $(this).remove();

            }
        });*/
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719
        //渠道选择值
        var channelArray = new Array();// 存放 所选 频道
        $("input[name='channelRadio']:checked").each(function (e) {
            if ($(this).attr("checked")) {
                channelArray.push($(this).context.value);
            }
        });
        //数据源选择值
        var dataSourceArray = new Array();
        $("input[name='dataSourceRadio']:checked").each(function (e) {
            if ($(this).attr("checked")) {
                dataSourceArray.push($(this).context.value);
            }
        });
        if (dataSourceArray.length < 1 || channelArray.length < 1) {
            return;
        }

        $.ajax({
            type: 'GET',
            async: true,
            contentType: 'application/json',
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/getBusinessByChannelIdListAndDataSourceIdList?dataSourceId=" + dataSourceArray + "&channelId=" + channelArray,
            dataType: 'text',
            success: function (data) {

                var jsonDa = eval('(' + data + ')');
720
                var strcheckBox = "<input type='checkbox' name='BusinessCheckALL' onclick='BusinessCheckALLCLICK()' value='全选'/><font color='#FF0000'>全选</font>";
721
                for (var i = 0; i < jsonDa.length; i++) {
722
                    var strInput = "<input type='checkbox' id=BusinessCheck_" + jsonDa[i].businessId + " name='BusinessCheck' onClick='BusinessCheckClick()' class='provinceDetail' title='" + jsonDa[i].businessName + "' value=" + jsonDa[i].businessId + "'/>" + jsonDa[i].businessName;
723
                    if((i !=0)&&((i+1)%6 ===0)){strInput=strInput+'<br>'}
724 725 726 727 728 729 730 731 732
                    strcheckBox += strInput;
                }
                $("#businessActivedListTd").append(strcheckBox);
            }
        });

    }

    function deleteRow(e) {
733

734
        var initK=Number($(e).parent().prev()[0].innerHTML).toFixed(2);
735 736 737 738 739 740

        sumkpiWeightTdVal-=parseFloat(Number(initK).toFixed(2));

        var parseF=parseFloat((1-sumkpiWeightTdVal).toFixed(2));
        $("#kpiWeightTd").val(parseFloat((1-sumkpiWeightTdVal).toFixed(2)) === 0?'':parseFloat((1-sumkpiWeightTdVal).toFixed(2)));
//        $("#kpiWeightTd").val(parseF === 0?'':parseF);
741 742 743
        $(e).parent().parent().remove();
    }
    function updateRow(e){
744
        var initK=Number($(e).parent().prev()[0].innerHTML).toFixed(2);
745
        var pro=prompt("请输入 ",$(e).parent().prev()[0].innerHTML);
746 747
        pro=$.trim(pro);
        if($.isNumeric(pro)){
748
            pro=Number(pro);
749
            if(pro >0){
750 751 752
                var k=sumkpiWeightTdVal-initK;
                k=k+pro;
                if(k <= 1.00){
753
                    $(e).parent().prev()[0].innerHTML=parseFloat(pro.toFixed(2));
754 755
                    sumkpiWeightTdVal-=initK;
                    sumkpiWeightTdVal+=pro;
756
                    $("#kpiWeightTd").val(parseFloat((1-sumkpiWeightTdVal).toFixed(2)) === 0?'':parseFloat((1-sumkpiWeightTdVal).toFixed(2)));
757 758
                }else{
                    $.alert("输入值过大,请输入0~"+initK);
759
                }
760 761
            }else{
                $.alert("请输入 大于 0 的值");
762 763 764 765 766 767 768 769 770 771 772 773 774
            }

        }
    }
    // '添加勾选指标' 按钮  点击事件
    $("#addAnaInfo").click(function () {
        var arrdimKpiChecked=getValueOfNamedimKpiCheck();

        if(arrdimKpiChecked.length <= 0){
            $.alert("指标不能为空");
            return;
        }
        id_kpiWeightTd_value=getValueBykpiWeightTd();
775

776
        /*if(parseFloat(id_kpiWeightTd_value.toFixed(2)) == 0||isNaN(id_kpiWeightTd_value)){
777 778
            $.alert("权值不能为空 或 0");
            $("#kpiWeightTd").val(parseFloat((1-sumkpiWeightTdVal).toFixed(2)) === 0?'':parseFloat((1-sumkpiWeightTdVal).toFixed(2)));
779 780
            return;
        }
781 782
        if(id_kpiWeightTd_value <0){
            $.alert("权值不能 小于 0");
莫林毅's avatar
莫林毅 committed
783
            $("#kpiWeightTd").val(parseFloat((1-sumkpiWeightTdVal).toFixed(2)) === 0?'':parseFloat((1-sumkpiWeightTdVal).toFixed(2)));
784 785 786
            return;
        }

787 788 789 790 791
        var curm01=0.00;
        for(var jj=0;jj<arrdimKpiChecked.length;jj++){
            curm01+=Number(id_kpiWeightTd_value);
        }
        if(curm01+Number(sumkpiWeightTdVal) > 1.00){
792 793
            $.alert("权值总和 不能大于 1");
            $("#kpiWeightTd").val(parseFloat((1-sumkpiWeightTdVal).toFixed(2)));
794
            return;
795
        }*/
796
        id_kpiWeightTd_value=parseFloat(id_kpiWeightTd_value.toFixed(2));
797
        id_kpiWeightTd_value=1;
798 799 800
        var kpiId_Name=getkpiid_NameOfNamedimKpiCheck();
        for(var i=0;i<kpiId_Name.length;i++){
            var id_name=kpiId_Name[i];
801
            //var addRow = $("<tr class='"+id_name.split("_")[0]+"' id='dimKpiCheck_"+id_name.split("_")[0]+"'><td title='"+id_name.split("_")[1].split(" ")[1]+"'>"+id_name.split("_")[1].split(" ")[0]+"</td><td style='display: none'>"+id_kpiWeightTd_value+"</td><td><a href='javascript:;' onclick='deleteRow(this)'>删除</a>&nbsp;&nbsp;</td></tr>");//<a href='javascript:;' onclick='updateRow(this)'>修改</a>
802
            var addRow = $("<tr class='"+id_name.split("&")[0]+"' id='dimKpiCheck_"+id_name.split("&")[0]+"'><td title='"+id_name.split("&")[2]+"'>"+id_name.split("&")[1]+"</td><td style='display: none'>"+id_kpiWeightTd_value+"</td><td><a href='javascript:;' onclick='deleteRow(this)'>删除</a>&nbsp;&nbsp;</td></tr>");//<a href='javascript:;' onclick='updateRow(this)'>修改</a>
803 804 805 806 807 808 809 810
            $("#addTr").append(addRow);
            $("input[name='dimKpiCheck']").each(function (e) {
                if ($(this).attr("checked")) {
                    $(this).next().remove();
                    $(this).remove();
                }
            });
        }
811 812 813 814 815 816 817 818
        //如果 指标栏 全选复选框 选中
        if($("input[name='dimKpiAllChecked']").attr('checked')){
            $("#dimKpiListTd").empty();
        }
        //如果 指标栏不存在 指标 条项
        if($("input[name='dimKpiCheck']").length ===0){
            $("#dimKpiListTd").empty();
        }
819 820
        /*sumkpiWeightTdVal=curm01+Number(sumkpiWeightTdVal);
        $("#kpiWeightTd").val(parseFloat((1-sumkpiWeightTdVal).toFixed(2))===0?'':parseFloat((1-sumkpiWeightTdVal).toFixed(2)));*/
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840

    });

    function getkpiIDAndWeightShallSave(){
        var arr=new Array();
        $("#addTr").find("tr").each(function(){
            var id=$(this).attr("id");
            id=Number(id.split("_")[1]);

            var weight=$(this).children('td').eq(1).text();
            weight=Number(weight);
            var id_weight=id+"_"+weight;
            arr.push(id_weight);
        });
        return arr;


    }
    function getValueBykpiWeightTd(){
        var val=$("#kpiWeightTd").val();
841
        return parseFloat(val);
842
    }
843

844 845 846 847 848 849
    $("#modelReset").click(function(){
        window.location.reload();

    });
    //删除所有参数
    function deleteAllTr(){
850 851
        sumkpiWeightTdVal=0.00;
        $("#kpiWeightTd").val(1.00);
852 853 854 855
        $("#addTr").empty();
    }


856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066
    //数据源 全选复选框 点击 事件   2018.1.23 bymoi
    function dataSourceRadioAllCheckedClick(){


        //判断 全选框是否选中 若选中  所有 数据源复选框 都选中
        if($("input[name='dataSourceRadioAll']").attr('checked')){

            $("input[name='dataSourceRadio']").attr('checked','true');
        }else{
            $("input[name='dataSourceRadio']").removeAttr('checked');

        }
        $("#businessActivedListTd").empty();
        $("#dimKpiListTd").empty();


        var channelId = $("input[name='channelRadio']:checked").val();
        var dataSourceId = $("input[name='dataSourceRadio']:checked").val();

        var channelArray = new Array();// 存放 所选 频道
        var i = 0;
        $("input[name='channelRadio']:checked").each(function () {
            channelArray[i] = $(this).val();
            i++;
        });
        var dataSourceArray = new Array();// 存放 所选数据源
        var j = 0;
        $("input[name='dataSourceRadio']:checked").each(function () {
            dataSourceArray[j] = $(this).val();
            j++;
        });

        if (channelArray.length < 0 || dataSourceArray.length < 0) {
            return;
        }


        $.ajax({
            type: 'GET',
            async: true,
            contentType: 'application/json',
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/getBusinessByChannelIdListAndDataSourceIdList?dataSourceId=" + dataSourceArray + "&channelId=" + channelArray,
            dataType: 'text',
            success: function (data) {

                var jsonDa = eval('(' + data + ')');
                var strcheckBox = "<input type='checkbox' name='BusinessCheckALL' onclick='BusinessCheckALLCLICK()' value='全选'/><font color='#FF0000'>全选</font>";
                for (var i = 0; i < jsonDa.length; i++) {
                    var strInput = "<input type='checkbox' onClick='BusinessCheckClick()' id=BusinessCheck_" + jsonDa[i].businessId + " name='BusinessCheck' class='provinceDetail' title='" + jsonDa[i].businessName + "' value='" + jsonDa[i].businessId + "'/>" + jsonDa[i].businessName;
                    if((i !=0)&&((i+1)%6 ===0)){strInput=strInput+'<br>'}
                    strcheckBox += strInput;
                }
                $("#businessActivedListTd").append(strcheckBox);

            }

        });
    }
    //--2018.1.23 bymoi

    //渠道 全选复选框 点击 事件   2018.1.23 bymoi
    function channelRadioAllCheckedClick(){

        //判断 全选框是否选中 若选中  所有 渠道复选框 都选中
        if($("input[name='channelRadioAll']").attr('checked')){

            $("input[name='channelRadio']").attr('checked','true');
        }else{
            $("input[name='channelRadio']").removeAttr('checked');

        }
        $("#businessActivedListTd").empty();
        $("#dimKpiListTd").empty();

        var channelId = $("input[name='channelRadio']:checked").val();
        var dataSourceId = $("input[name='dataSourceRadio']:checked").val();

        var channelArray = new Array();// 存放 所选 频道
        var i = 0;
        $("input[name='channelRadio']:checked").each(function () {
            channelArray[i] = $(this).val();
            i++;
        });
        var dataSourceArray = new Array();// 存放 所选数据源
        var j = 0;
        $("input[name='dataSourceRadio']:checked").each(function () {
            dataSourceArray[j] = $(this).val();
            j++;
        });

        if (channelArray.length < 0 || dataSourceArray.length < 0) {
            return;
        }


        $.ajax({
            type: 'GET',
            async: true,
            contentType: 'application/json',
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/getBusinessByChannelIdListAndDataSourceIdList?dataSourceId=" + dataSourceArray + "&channelId=" + channelArray,
            dataType: 'text',
            success: function (data) {

                var jsonDa = eval('(' + data + ')');

                var strcheckBox = "<input type='checkbox' name='BusinessCheckALL' onclick='BusinessCheckALLCLICK()' value='全选'/><font color='#FF0000'>全选</font>";
                for (var i = 0; i < jsonDa.length; i++) {
                    var strInput = "<input type='checkbox' onClick='BusinessCheckClick()' id=BusinessCheck_" + jsonDa[i].businessId + " name='BusinessCheck' class='provinceDetail' title='" + jsonDa[i].businessName + "' value='" + jsonDa[i].businessId + "'/>" + jsonDa[i].businessName;
                    if((i !=0)&&((i+1)%6 ===0)){strInput=strInput+'<br>'}
                    strcheckBox += strInput;
                }
                $("#businessActivedListTd").append(strcheckBox);

            }

        });

    }
    //   2018.1.23 bymoi

    //业务 全选复选框 点击 事件   2018.1.23 bymoi
    function BusinessCheckALLCLICK(){


        if($("input[name='BusinessCheckALL']").attr('checked')){

            $("input[name='BusinessCheck']").attr('checked','true');
        }else{

            $("input[name='BusinessCheck']").removeAttr('checked');
        }

        // 清空  指标 一栏 所有 指标
        $("#dimKpiListTd").empty();

        //$("#dimKpiListTd").empty();
        //获取选择的 业务
        var businessSelectedArr =new Array();
        $("input[name='BusinessCheck']").each(function (e) {

            if ($(this).attr("checked")) {
                businessSelectedArr.push($(this).context.id.split("_")[1]);
            }
        });
        if (businessSelectedArr.length < 1) {
            return;
        }


        var dimKpiHadSelectedArr = new Array();//原有的指标
        $("#addTr").find("tr").each(function(){
            var id=$(this).attr("id");
            id=Number(id.split("_")[1]);
            dimKpiHadSelectedArr.push(id);
        });

        // 重置  指标 一栏 筛选保留原有的 指标
        /*$("input[name='dimKpiCheck']").each(function (e) {
            if (!$(this).attr("checked")) {
                $(this).next().remove();
                $(this).remove();

            }
        });*/

        var arrdimKpiChecked=getValueOfNamedimKpiCheck();


        $.ajax({
            type: 'GET',
            async: true,
            contentType: 'application/json',
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/getDimKpiListByBusinessIdList?businessIdList=" + businessSelectedArr,
            dataType: 'text',
            success: function (data) {

                var jsonDa = eval('(' + data + ')');
                var colLength=0;
                for (var i = 0; i < jsonDa.length; i++) {


                    if (dimKpiHadSelectedArr.indexOf(jsonDa[i].kpiId) >= 0) {
                        continue;
                    }
                    if(arrdimKpiChecked.indexOf(jsonDa[i].kpiId) >= 0){
                        continue;
                    }
                    var strInput = "<input type='checkbox' id=dimKpiCheck_" + jsonDa[i].kpiId + " name='dimKpiCheck' class='provinceDetail' title='"+jsonDa[i].code+ "' value=" + jsonDa[i].kpiId + "'/><font>" + jsonDa[i].name + "</font>";
                    if((colLength !=0)&&((colLength+1)%5 ===0)){strInput=strInput+'<br>'}
                    if(colLength == 0){$("#dimKpiListTd").append("<input type='checkbox' value='全选' name='dimKpiAllChecked' onclick='dimKpiAllCheckedClick()'/><font color='#FF0000'>全选</font>")}
                    $("#dimKpiListTd").append(strInput);
                    colLength=colLength+1;
                }
            }
        });

    }
    // 2018.1.23 bymoi

    // 2018.1.23 bymoi
    //指标复选框 全选 2018.1.23 bymoi
    function dimKpiAllCheckedClick(){
        if($("input[name='dimKpiAllChecked']").attr('checked')){
            $("input[name='dimKpiCheck']").attr('checked','true');
        }else{
            $("input[name='dimKpiCheck']").removeAttr('checked');
        }
    }
    //2018.1.23 bymoi


1067 1068 1069
</script>
</body>
</html>