CreateDiagosis.jsp 34.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<%--
  Created by IntelliJ IDEA.
  User: molinyi
  Date: 2017/11/23 0023
  Time: 上午 11:07
  To change this template use File | Settings | File Templates.
--%>

<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>模型维护</title>
    <style>
18
        .table-null .table {
19 20
            margin-bottom: 0px;
        }
21 22

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

        .table-null td:first-child {
28 29 30
            text-align: right;
            width: 36%;
        }
31 32

        .table-null tr td:last-child .form-control, .table-null tr td:last-child table {
33 34
            width: 400px;
        }
35 36 37 38 39 40 41 42 43 44 45 46 47 48

        .file-box {
            position: relative;
        }

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

        /* .file-box{ position:relative;width:340px}
        .txt{ height:22px; border:1px solid #cdcdcd; width:180px;}
        .btn{ background-color:#FFF; border:1px solid #CDCDCD;height:24px; width:70px;}
53
        .file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:260px }
54 55 56 57 58 59 60 61 62 63 64 65

    </style>
</head>

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

67 68 69 70 71 72 73 74 75
<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>
76 77
                            <form action="#" class="form-horizontal" id="modelMaintainForm" method="post"
                                  enctype="multipart/form-data">
78
                                <table id="modelMaintainTable" class="table-null">
79 80 81
                                    <tr>
                                        <td>省份:</td>
                                        <td>
82
                                            <%--<div class="checkbox-inline">
83
                                                <input type="checkbox" name="" id="provinceDetailAll" title="" value="" /><div style="color:red;">全选</div>
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
                                            </div>--%>

                                            <c:forEach var="provice" items="${proviceList}">
                                                <c:if test="${provice.provinceId ==32}">

                                                    <label>
                                                        <input type="checkbox" name="provinceDetail"
                                                               class="provinceDetail" title="${provice.provinceName}"
                                                               value="${provice.provinceId}" checked disabled/>
                                                        ${provice.provinceName}
                                                    </label>

                                                </c:if>

                                            </c:forEach>

100 101 102 103 104
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>维度:</td>
105
                                        <td><select class="form-control" name="dimensionTd" id="dimensionTd">
106 107 108 109 110 111 112 113 114 115 116 117 118
                                            <c:forEach var="modelType" items="${dimensionList}">

                                                <c:choose>
                                                    <c:when test="${modelType == 'c' }">
                                                        <option value="${modelType}">渠道</option>
                                                    </c:when>
                                                    <c:when test="${modelType == 'y'}">
                                                        <option value="${modelType}">业务</option>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <option value="ex">异常</option>
                                                    </c:otherwise>
                                                </c:choose>
119
                                            </c:forEach>
120 121 122 123
                                        </select></td>
                                    </tr>
                                    <tr>
                                        <td>描述(<font color="red">必填</font>):</td>
124 125 126 127
                                        <td><input type="text" class="form-control" name="descTd" id="descTd"
                                                   style="display: inline;"/>
                                            <span id="writeWarningInf"
                                                  style="color:red;display: inline;padding-left:10px;"></span></td>
128 129 130
                                    </tr>
                                    <tr>
                                        <td>已添加指标:</td>
131 132 133 134 135 136 137 138 139 140 141 142 143
                                        <td>
                                            <table class="table table-hover table-striped" id="displayParam">
                                                <thead>
                                                <tr>
                                                    <th>指标名称</th>
                                                    <th>权重值</th>
                                                    <th><a href="javascript:deleteAllTr()">删除所有</a></th>
                                                </tr>
                                                </thead>
                                                <tbody id="addTr"></tbody>
                                            </table>
                                        </td>
                                    </tr>
144 145 146 147 148 149 150 151
                                    <tr>
                                    <tr>
                                        <td>数据源:</td>
                                        <td>
                                            <%--<select class="form-control" name="dataSourceList" id="dataSourceListTd" >--%>
                                            <c:forEach items="${dataSourceList}" var="dataSource">
                                                <div class="checkbox-inline">
                                                    <label>
152 153 154 155
                                                        <input type="checkbox" onclick="dataSourceRadioClick()"
                                                               name="dataSourceRadio" class="provinceDetail"
                                                               title="${dataSource.dataSourceName}"
                                                               value="${dataSource.dataSourceId}"/>${dataSource.dataSourceName}
156 157
                                                    </label>
                                                </div>
158
                                            </c:forEach>
159 160 161 162 163 164 165 166 167 168 169

                                        </td>
                                    </tr>

                                    <tr>
                                        <td>渠道:</td>
                                        <td>
                                            <div id="">
                                                <c:forEach items="${channelList}" var="channel">
                                                    <div class="checkbox-inline">
                                                        <label>
170 171 172 173
                                                            <input type="checkbox" onclick="channelRadioClick()"
                                                                   name="channelRadio" class="provinceDetail"
                                                                   title="${channel.channelId}"
                                                                   value="${channel.channelId}"/>${channel.channelName}
174 175 176 177 178 179 180 181 182
                                                        </label>
                                                    </div>
                                                </c:forEach>
                                            </div>
                                        </td>
                                    </tr>


                                    <tr>
莫林毅's avatar
莫林毅 committed
183
                                        <td><%--<acronym title="ni caicai">--%>业务:<%--</acronym>--%></td>
184 185 186 187 188 189 190 191 192 193 194 195 196 197
                                        <td id="businessActivedListTd">

                                        </td>


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


                                    </tr>

198 199
                                    <tr>
                                        <td></td>
200 201 202 203
                                    </tr>

                                    <tr>
                                        <td>权重(<font color="red">必填</font>):</td>
204
                                        <td><input type="number" step="0.01" class="form-control" name="descTd"
205
                                                   id="kpiWeightTd" value="1" style="display: inline;"/>
206 207
                                            <span id="writeWarningInfTd"
                                                  style="color:red;display: inline;padding-left:10px;"></span></td>
208 209
                                    </tr>

210 211 212
                                    <tr>
                                        <td></td>
                                        <td>
213

214 215
                                            <button type="button" id="UPDATEAnaInfo" class="btn btn-primary">修改指标
                                            </button>
216

217 218
                                        </td>
                                    </tr>
219

220 221 222 223 224 225 226 227 228
                                    <tr>
                                        <td></td>
                                        <td>
                                            <button type="button" id="addAnaInfo" class="btn btn-info">添加勾选指标</button>
                                            <button type="button" id="modelSubmit" class="btn btn-primary">确定</button>
                                            <button type="reset" class="btn btn-default" id="modelReset">清空</button>
                                            <button type="reset" class="btn btn-warning" id="modelBack">返回</button>
                                        </td>
                                    </tr>
229 230 231 232 233 234 235 236
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
237

238 239 240
</div>

<script type="text/javascript">
241
    $(document).ready(function () {
242
        $("#UPDATEAnaInfo").hide();
243
        if ($("#paramDataType").val() == "字符") {
244 245
            var addDataValue = $("<input type='text' class='form-control name=paramValue' id='paramValue'/>");
            $("#addParamVal").append(addDataValue);
246
        } else if ($("#paramDataType").val() == "日期") {
247 248
            var addDataValue = $("<input type='text' class='form-control name=paramValue' id='paramValue' onFocus='WdatePicker({dateFmt:\" yyyy-MM-dd \"})'/>");
            $("#addParamVal").append(addDataValue);
249
        } else if ($("#paramDataType").val() == "时间") {
250 251
            var addDataValue = $("<input type='text' class='form-control name=paramValue' id='paramValue' onFocus='WdatePicker({})'/>");
            $("#addParamVal").append(addDataValue);
252
        } else {
253 254 255 256 257
            var addDataValue = $("<input type='text' class='form-control' name='paramValue' id='paramValue' onkeyup='(this.v=function(){this.value=this.value.replace(/[^0-9]+/,\"\");}).call(this)' onblur='this.v();'/>");
            $("#addParamVal").append(addDataValue);
        }
    });

莫林毅's avatar
莫林毅 committed
258 259 260
    //全选和不全选所有的省
    $("#provinceDetailAll").click(function () {

261 262 263 264
        if ($("#provinceDetailAll").attr("checked") == "checked") {//全选
            $("provinceDetail").attr("checked", "checked");
            $("input[name='provinceDetail']").attr("checked", "checked");
            $("input[name='provinceDetail'][value='32']").attr("checked", false);
莫林毅's avatar
莫林毅 committed
265

266 267 268
        } else {//不全选
            $("input[name='provinceDetail']").attr("checked", false);
            $("input[name='provinceDetail']").attr("disabled", false);
莫林毅's avatar
莫林毅 committed
269 270
        }
    });
271
    $("input[name='provinceDetail'][value='3000']").click(function () {
272 273
            /*alert($("input[name='provinceDetail'][value='32']").text());
            alert($("input[name='provinceDetail'][value='32']").html());*/
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298

            if ($("input[name='provinceDetail'][value='32']").attr("checked") == "checked") {
                /*$("#provinceDetailAll").next().hide();
                $("#provinceDetailAll").hide();

                $("input[name='provinceDetail'][value!='32']").next().hide();
                $("input[name='provinceDetail'][value!='32']").hide();

    */
                $("#provinceDetailAll").prop("disabled", "disabled");
                $("input[name='provinceDetail'][value!='32']").prop("disabled", "disabled");
            } else {
                /* $("#provinceDetailAll").next().show();
                 $("#provinceDetailAll").show();


                 $("input[name='provinceDetail'][value!='32']").next().show();
                 $("input[name='provinceDetail'][value!='32']").show();*/
                $("#provinceDetailAll").removeAttr("disabled");
                $("input[name='provinceDetail'][value!='32']").removeAttr("disabled");
            }


        }
    );
莫林毅's avatar
莫林毅 committed
299

300 301
    //模型名称是否重复判断
    var isDouble = true;
302 303
    $("#dataModelName").blur(function () {
        if ("" != $.trim($(this).val())) {
304 305 306
            var modelName = $(this).val();
            $.ajax({
                type: "GET",
307
                contentType: "application/json",
308
                dataType: "text",
309 310 311 312 313
                url: "${ctx}/ModelManage/ModelMaintain/select_modelName/" + encodeURIComponent(modelName),
                beforeSend: function (data) {
                    $("#modelSubmit").attr("disabled", true);
                },
                success: function (data) {
314
                    data = parseInt(data);
315
                    if (0 == data) {
316 317
                        $("#writeWarningInf").html("");
                        isDouble = false;
318 319
                        $("#modelSubmit").attr("disabled", false);
                    } else {
320 321
                        $("#writeWarningInf").html("<img src='${ctx}/static/images/x.png'/> 标题已存在");
                        isDouble = true;
322
                        $("#modelSubmit").attr("disabled", true);
323 324 325 326 327 328 329
                    }
                }
            });
        }
    });

    //参数类型变化  类型数据验证
330
    $("#paramDataType").change(function () {
331 332
        $("#addParamVal").empty();
        var paramDataType = $(this).find("option:selected").val();
333
        if (paramDataType == "字符") {
334 335
            var addDataValue = $("<input type='text' class='form-control name=paramValue' id='paramValue'/>");
            $("#addParamVal").append(addDataValue);
336
        } else if (paramDataType == "日期") {
337 338
            var addDataValue = $("<input type='text' class='form-control name=paramValue' id='paramValue' onFocus='WdatePicker({dateFmt:\" yyyy-MM-dd \"})'/>");
            $("#addParamVal").append(addDataValue);
339
        } else if (paramDataType == "时间") {
340 341
            var addDataValue = $("<input type='text' class='form-control name=paramValue' id='paramValue' onFocus='WdatePicker({})'/>");
            $("#addParamVal").append(addDataValue);
342
        } else {
343 344 345 346 347 348
            var addDataValue = $("<input type='text' class='form-control' name='paramValue' id='paramValue' onkeyup='(this.v=function(){this.value=this.value.replace(/[^0-9]+/,\"\");}).call(this)' onblur='this.v();'/>");
            $("#addParamVal").append(addDataValue);
        }
    });

    //删除所有参数
349
    function deleteAllTr() {
350
        $("#addTr").empty();
351
        dimKpiSelected.splice(0, dimKpiSelected.length);
352 353 354 355
    }


    //添加/修改参数
356
    $("#addParam").click(function () {
357 358 359
        var paramDataType = $("#paramDataType").val();
        var paramName = $.trim($("#paramName").val());
        var paramValue = $("#paramValue").val();
360
        if (paramName == "") {
361
            $.alert("参数名不能为空");
362 363 364
        } else {
            if ($("#addTr").find("tr.orange-tr").html() == null) {
                var addRow = $("<tr><td>" + paramName + "</td><td id='paramValue_'+paramValue>" + paramValue + "</td><td>" + paramDataType + "</td><td><a href='javascript:;' title='' onclick='deleteRow(this)'>删除</a>&nbsp;&nbsp;<a href='javascript:;' onclick='updateRow(this)'>修改</a></td></tr>");
365
                $("#addTr").append(addRow);
366 367 368
                $("#paramName").attr("value", "");
                $("#paramValue").attr("value", "");
            } else {
369 370 371 372 373 374 375 376 377 378
                var findTr = $("#addTr").find("tr.orange-tr");
                $(findTr).find("td").eq(0).html(paramName);
                $(findTr).find("td").eq(1).html(paramValue);
                $(findTr).find("td").eq(2).html(paramDataType);
                $("#addTr").find("tr").removeClass();
                $("#addParam").text("添加参数");
            }
        }
    });

379
    //修改一条参数
380
    function updateRow(e) {
381

382
        var initK = Number($(e).parent().prev()[0].innerHTML);
383
        var pro = prompt("请输入 ", $(e).parent().prev()[0].innerHTML);
384 385 386
        pro = $.trim(pro);
        if ($.isNumeric(pro)) {
            pro = parseFloat(pro);
387

388 389
            if (pro > 0) {
                if (initK >= pro) {
390
                    $(e).parent().prev()[0].innerHTML = parseFloat(pro.toFixed(2));
391 392
                    var clz=$(e).parent().parent().attr("class");
                    $(e).parent().parent()[0].setAttribute("class",clz.substring(0,clz.lastIndexOf('_')+1)+parseFloat(pro.toFixed(2)));
393 394
                    sumkpiWeightTdVal -= parseFloat(initK.toFixed(2));
                    sumkpiWeightTdVal += parseFloat(pro.toFixed(2));
395
                    var maxV = (1 - Number(sumkpiWeightTdVal)).toFixed(2);
396
                    $("#kpiWeightTd").val(maxV === '0.00'?'':parseFloat(maxV));
397 398
                }
                else {
399 400
                    var k = sumkpiWeightTdVal - initK + pro;
                    if (k <= 1.00) {
401
                        $(e).parent().prev()[0].innerHTML = parseFloat(pro.toFixed(2));//.toFixed(2);
402 403
                        var clz=$(e).parent().parent().attr("class");
                        $(e).parent().parent()[0].setAttribute("class",clz.substring(0,clz.lastIndexOf('_')+1)+parseFloat(pro.toFixed(2)));
404 405
                        sumkpiWeightTdVal -= parseFloat(initK.toFixed(2));
                        sumkpiWeightTdVal += parseFloat(pro.toFixed(2));
406
                        var maxV = (1 - Number(sumkpiWeightTdVal)).toFixed(2);
407
                        $("#kpiWeightTd").val(maxV === '0.00'?'':parseFloat(maxV));
408 409
                    }else{
                        $.alert("输入值过大,请输入0~"+initK);
410
                    }
411

412
                }
413 414
            }else{
                $.alert("请输入 大于 0 的值");
415 416 417
            }
        }
    }
418

419
    //删除一条参数
420 421
    function deleteRow(e) {
        var v = $(e).parent().prev().text();
422
        sumkpiWeightTdVal = parseFloat((sumkpiWeightTdVal - parseFloat(Number(v).toFixed(2))).toFixed(2));
423
        $("#kpiWeightTd").val((1.00 - sumkpiWeightTdVal) === 0?'':parseFloat((1.00 - sumkpiWeightTdVal).toFixed(2)));
424 425
        var id = Number(e.title);
        dimKpiSelected.splice($.inArray(id, dimKpiSelected), 1);
426
        $(e).parent().parent().remove();
427 428 429
    }

    //form表单重置
430
    $("#modelReset").click(function () {
431 432
        $("#businessActivedListTd").empty();
        $("#dimKpiListTd").empty();
433 434 435
        deleteAllTr();
    });

436 437

    //返回 选中的省份
438 439 440 441
    function getDetailProvinceCheckedValues() {
        var provinceArray = new Array();
        $("input[name='provinceDetail']").each(function () {
            if ($(this).attr("checked")) {
442 443 444 445 446 447
                provinceArray.push($(this).val());
            }
        });
        return provinceArray;
    }

448
    //form表单提交
449
    $("#modelSubmit").click(function () {
450

451
        if (sumkpiWeightTdVal < 1.00) {
452 453 454
            $.alert("权限总和需 为 1");
            return;
        }
455 456 457 458
        var anainfoShallSaveArr = getAnainfoShallSave();
        var arrDimKpiChecked = getArrDimKpiChecked();
        var provinceDetailChecked = getDetailProvinceCheckedValues();
        if (provinceDetailChecked.length < 1) {
459
            $.alert("省份需选");
460
            return;
461
        } else if ($.trim($("#descTd").val()) == "") {
462
            $.alert("描述不能为空");
463
            return;
464
        } else if (anainfoShallSaveArr.length < 1) {
465
            $.alert("指标需选");
466
            return;
467
        }
468
        else {
469

470 471
            var proviceTdSelected = $("#proviceTd option:selected").val();
            var dimensionTdSelected = $("#dimensionTd option:selected").val();
472

473 474
            var descTdV = $("#descTd").val();
            var kpiWeightTdV = $("#kpiWeightTd").val();
475 476


477
            $("#modelSubmit").attr("disabled", "disabled");
478
            $.ajax({
479 480 481 482 483 484 485 486 487 488 489
                type: 'GET',
                async: true,
                contentType: 'application/json',
                data: {
                    /*proviceTdSelected : proviceTdSelected,*/
                    dimensionTdSelected: dimensionTdSelected,
                    descTdV: descTdV/*,kpiWeightTdV:kpiWeightTdV*/
                },
                url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/createAssociDigConfig?anainfoShallSaveArr=" + anainfoShallSaveArr + "&proviceSelected=" + provinceDetailChecked,
                dataType: 'text',
                success: function (data) {
490 491

                    $.alert(data);
492
                    sumkpiWeightTdVal = 0.00;
493
                    setTimeout(function () {
494 495
                        location.href = "${ctx}/MonitorOperation/AssociateDiagosisConfiguration";
                    }, 2000);
496

497
                }
498 499 500

            });

501 502 503
        }
    });

504
    $("#modelBack").click(function () {
505

506
        location.href = "${ctx}/MonitorOperation/AssociateDiagosisConfiguration";
507
    });
508 509 510 511 512 513 514


    // 查找 指标
    $("#selectAnaInfo").click(function () {

        $("#dimKpiListTd").empty();
        //获取选择的 业务
515
        var businessSelectedArr = [];
516

517 518
        $("input[name='BusinessCheck']").each(function (e) {
            if ($(this).attr("checked")) {
519 520 521 522 523
                businessSelectedArr.push($(this).context.id.split("_")[1]);
            }
        });

        $.ajax({
524 525 526 527 528 529 530 531 532 533
            type: 'GET',
            async: true,
            contentType: 'application/json',
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/getDimKpiListByBusinessIdList?businessIdList=" + businessSelectedArr,
            dataType: 'text',
            success: function (data) {

                var jsonDa = eval('(' + data + ')');
                for (var i = 0; i < jsonDa.length; i++) {
                    var strInput = "<input type='checkbox' id=dimKpiCheck_" + jsonDa[i].kpiId + " name='dimKpiCheck' class='provinceDetail' title='" + jsonDa[i].name + " value='" + jsonDa[i].kpiId + "'>" + jsonDa[i].name + "</input>";
534 535 536 537 538 539 540
                    $("#dimKpiListTd").append(strInput);
                }
            }
        });
    });

    //渠道 复选框 点击 事件
541
    function channelRadioClick() {
542 543
        $("#businessActivedListTd").empty();

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

547 548 549 550
        var channelArray = new Array();// 存放 所选 频道
        var i = 0;
        $("input[name='channelRadio']:checked").each(function () {
            channelArray[i] = $(this).val();
551 552
            i++;
        });
553 554 555 556
        var dataSourceArray = new Array();// 存放 所选数据源
        var j = 0;
        $("input[name='dataSourceRadio']:checked").each(function () {
            dataSourceArray[j] = $(this).val();
557 558 559
            j++;
        });

560
        if (channelArray.length < 0 || dataSourceArray.length < 0) {
561 562 563 564 565
            return;
        }


        $.ajax({
566 567 568 569 570 571 572 573
            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 + ')');
574
//                var jsonDa=data;
575 576 577 578
                var strcheckBox = "";
                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;
                    strcheckBox += strInput;
579 580 581 582 583 584 585 586 587 588
                }
                $("#businessActivedListTd").append(strcheckBox);

            }

        });

    }

    //数据源 复选框 点击 事件
589
    function dataSourceRadioClick() {
590 591 592 593


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

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

597 598 599 600
        var channelArray = new Array();// 存放 所选 频道
        var i = 0;
        $("input[name='channelRadio']:checked").each(function () {
            channelArray[i] = $(this).val();
601 602
            i++;
        });
603 604 605 606
        var dataSourceArray = new Array();// 存放 所选数据源
        var j = 0;
        $("input[name='dataSourceRadio']:checked").each(function () {
            dataSourceArray[j] = $(this).val();
607 608 609
            j++;
        });

610
        if (channelArray.length < 0 || dataSourceArray.length < 0) {
611 612 613 614 615
            return;
        }


        $.ajax({
616 617 618 619 620 621 622 623 624 625 626 627
            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++) {
                    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;
                    strcheckBox += strInput;
628 629 630 631 632 633 634 635
                }
                $("#businessActivedListTd").append(strcheckBox);

            }

        });

    }
636

637 638 639
    // 业务 复选框 点击事件
    function BusinessCheckClick() {

640

641
        // 重置  指标 一栏 筛选保留原有的 和已选择的 指标
642 643 644 645
        $("input[name='dimKpiCheck']").each(function (e) {
            if (!$(this).attr("checked")) {
                $(this).next().remove();
                $(this).remove();
646 647 648 649 650 651

            }
        });


        //获取选择的 业务
652
        var businessSelectedArr = [];
653

654 655
        $("input[name='BusinessCheck']").each(function (e) {
            if ($(this).attr("checked")) {
656 657 658 659 660
                businessSelectedArr.push($(this).context.id.split("_")[1]);
            }
        });

        $.ajax({
661 662 663 664 665 666 667 668 669 670 671 672
            type: 'GET',
            async: true,
            contentType: 'application/json',
            url: "${ctx}/MonitorOperation/AssociateDiagosisConfiguration/getDimKpiListByBusinessIdList?businessIdList=" + businessSelectedArr,
            dataType: 'text',
            success: function (data) {

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

                    if ($.inArray(jsonDa[i].kpiId, dimKpiSelected) < 0) {
                        var strInput = "<input type='checkbox' id=dimKpiCheck_" + jsonDa[i].kpiId + " name='dimKpiCheck' class='provinceDetail'   title='" + jsonDa[i].name + "  " + jsonDa[i].code + "' value='" + jsonDa[i].kpiId + "'/><font>" + jsonDa[i].name + "</font>";
673 674 675 676 677 678 679 680 681 682
                        $("#dimKpiListTd").append(strInput);
                    }

                }
            }
        });
    }


    // 查找 业务
683
    $("#selectBusiness").click(function () {
684 685 686

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

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

690 691 692 693
        var channelArray = new Array();// 存放 所选 频道
        var i = 0;
        $("input[name='channelRadio']:checked").each(function () {
            channelArray[i] = $(this).val();
694 695
            i++;
        });
696 697 698 699
        var dataSourceArray = new Array();// 存放 所选数据源
        var j = 0;
        $("input[name='dataSourceRadio']:checked").each(function () {
            dataSourceArray[j] = $(this).val();
700 701 702 703 704
            j++;
        });


        $.ajax({
705 706 707 708 709 710 711 712 713 714 715 716
            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++) {
                    var strInput = "<input type='checkbox' id=BusinessCheck_" + jsonDa[i].businessId + " name='BusinessCheck' class='provinceDetail' title='" + jsonDa[i].businessName + " value='" + jsonDa[i].businessId + "'/>" + jsonDa[i].businessName;
                    strcheckBox += strInput;
717
                }
718
                $("#businessActivedListTd").append(strcheckBox);
719 720 721 722 723 724 725 726

            }

        });


    });

727 728 729 730 731
    sumkpiWeightTdVal = 0.00;
    //    添加 '勾选指标指标'按钮  点击事件
    $("#addAnaInfo").click(function () {
        var arrDimKpiChecked = getArrDimKpiChecked();
        if (arrDimKpiChecked.length < 1) {
732 733 734
            $.alert("需选指标");
            return;
        }
735
        var kpiWeightTdVal = $.trim($("#kpiWeightTd").val());
736
        if (kpiWeightTdVal == "" || parseFloat(Number(kpiWeightTdVal).toFixed(2)) == 0) {
737
            $.alert("权重不能为空");
738
            var mmm_1 = (1 - Number(sumkpiWeightTdVal)).toFixed(2);
739
            $("#kpiWeightTd").val(mmm_1 === '0.00'?'':parseFloat(mmm_1));
740 741
            return;
        }
742
        if (kpiWeightTdVal < 0) {
743
            $.alert("权重不能为负");
744
            var mmm = (1 - Number(sumkpiWeightTdVal)).toFixed(2);
745
            $("#kpiWeightTd").val(mmm === '0.00'?'':parseFloat(mmm));
746 747
            return;
        }
748
        if (kpiWeightTdVal > 1.00) {
749
            $.alert("权重超值 1");
750
            var mmmm = (1 - Number(sumkpiWeightTdVal)).toFixed(2);
751
            $("#kpiWeightTd").val(parseFloat(mmmm));
752
            return;
753
        }
754 755
        var tt = 0.00;
        for (var jj = 0; jj < arrDimKpiChecked.length; jj++) {
756
            tt += parseFloat(Number(kpiWeightTdVal).toFixed(2));
757
        }
758
        var k = sumkpiWeightTdVal + tt;
759
        //var k=sumkpiWeightTdVal+Number(kpiWeightTdVal);
760
        if (k > 1.00) {
761
            $.alert("权重和 超值 1");
762
            var mm = (1 - Number(sumkpiWeightTdVal)).toFixed(2);
763
            $("#kpiWeightTd").val(parseFloat(mm));
764 765
            return;
        }
766
        // 勾选指标 的 名称 和 value
767
        var arrDimKpiidAndNameChecked = getArrDimKpiidAndNameChecked();
768 769

        //向 已添加指标  添加
770
        kpiWeightTdVal=parseFloat(Number(kpiWeightTdVal).toFixed(2));
771 772 773
        for (var i = 0; i < arrDimKpiidAndNameChecked.length; i++) {
            var id_name = arrDimKpiidAndNameChecked[i];
            var addRow = $("<tr class='" + id_name.split("_")[0] + "_" + kpiWeightTdVal + "'><td>" + id_name.split("_")[1] + "</td><td>" + kpiWeightTdVal + "</td><td><a href='javascript:;' title='" + id_name.split("_")[0] + "' onclick='deleteRow(this)'>删除</a>&nbsp;&nbsp;<a href='javascript:;' onclick='updateRow(this)'>修改</a></td></tr>");
774 775 776 777
            $("#addTr").append(addRow);
            dimKpiSelected.push(Number(id_name.split("_")[0]));
        }
        // 指标项中 去除 已添加指标 已有的指标
778
        $("input[name='dimKpiCheck']").each(function (e) {
779

780
            var id = Number($(this).context.id.split("_")[1]);
781 782


783
            if ($.inArray(id, dimKpiSelected) >= 0) {
784 785 786 787 788
                $(this).next().remove();
                $(this).remove();
            }

        });
789
        sumkpiWeightTdVal += tt;
790 791
        var maxV = parseFloat((1 - Number(sumkpiWeightTdVal)).toFixed(2));
        $("#kpiWeightTd").val(maxV === 0?'':parseFloat(maxV));
792 793

    });
794
    dimKpiSelected = new Array();
795

796 797 798 799
    function getAnainfoShallSave() {
        var anainfoShallSaveArr = new Array();
        $("#addTr").find("tr").each(function () {
            var claz = $(this).attr("class");
800 801 802 803 804
            anainfoShallSaveArr.push(claz);
        });
        return anainfoShallSaveArr;
    }

805

806

807
    // 获取勾选指标的 数据    格式  id_名称
808 809 810 811 812
    function getArrDimKpiidAndNameChecked() {
        var arrDimKpiChecked = [];
        $("input[name='dimKpiCheck']").each(function (e) {
            if ($(this).attr("checked")) {
                var id_name = $(this).context.id.split("_")[1] + "_" + $(this).context.title.split("  ")[0];
813 814 815 816 817 818
                arrDimKpiChecked.push(id_name);
            }
        });
        return arrDimKpiChecked;
    }

819 820 821 822
    function getArrDimKpiChecked() {
        var arrDimKpiChecked = [];
        $("input[name='dimKpiCheck']").each(function (e) {
            if ($(this).attr("checked")) {
823 824 825 826 827
                arrDimKpiChecked.push($(this).context.id.split("_")[1]);
            }
        });
        return arrDimKpiChecked;
    }
828 829 830 831
</script>

</body>
</html>