<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>赔案基本案例</title>
    <script src="../js/lib/jquery-1.11.1.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../compass/app/js/jquery-ui/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="../cssGraph/detail.css">
</head>
<body>
<div class="container detailTop">
    <div class="row">
        <div class="col-md-5 topLeft">
            <div class="title">赔案基本信息</div>
            <div class="container-fluid topLeftMain commonBorder">
                <div class="col-md-3 imgWrapper">
                    <img src="../images/userAvatar.png" alt="">
                </div>
                <div class="container-fluid col-md-9">
                    <div class="userDetail">
                        <div class="userDetailItem col-md-6">姓名：<span id="name"></span></div>
                        <div class="userDetailItem col-md-6">性别：<span id="sex"></span></div>
                        <div class="userDetailItem col-md-6">年龄：<span id="age"></span>岁</div>
                        <div class="userDetailItem col-md-6">赔偿事故：<span id="claimnAcc"></span></div>
                        <div class="userDetailItem col-md-6">事故日期：<span id="accdate"></span></div>
                        <div class="userDetailItem col-md-6">立案日期：<span id="recdate"></span></div>
                        <div class="userDetailItem col-md-12">案件号：<span id="current"></span></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-7">
            <div class="title">风险提示</div>
            <div class="tableWrapper commonBorder">
                <table class="table_right" border="0" cellspacing="0">
                    <tr class="table_title">
                        <td>决策结果</td>
                        <td>详细说明</td>
                    </tr>
                    <tr>
                        <td id="decisionResult"></td>
                        <td id="detailedDescription"></td>
                    </tr>
                </table>
                <div class="container-fluid scoreOutWrapper">
                    <div class="col-md-2">
                        快赔评分
                    </div>
                    <div class="col-md-10">
                        <div class="flexCenter">
                            <div class="scoreWrapper">
                                <div class="score" id="score">
                                    <span class="scorePencent"></span>
                                </div>
                            </div>
                            <span class="scoreNumber" id="fastCompensateScore"></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row sameMsg">
        <div class="title">同类案件信息</div>
        <div id="sameMsg">
        </div>
    </div>
</div>
<script>
    $(function () {
        // 初始化页面数据
        var claimno = 'CHD1830000303355';
        $('#current').html(claimno);
        initData()

        function initData() {
            $.ajax({
                url: "/dgt/graph/getDetailByClaimno",
                async: false,
                dataType: "json",
                type: "get",
                data: {
                    claimno: claimno
                },
                success: function (res) {
                    // console.log(res)
                    if (res.resultCode === '0000') {
                        renderMsg(res)
                    }
                }
            });
        }

        function renderMsg(res) {
            // 循环基本信息和风险提示
            var basicClaimno = res.data.basicClaimno;
            var riskTip = res.data.riskTip;
            var similarTypeClaimnos = res.data.similarTypeClaimnos;
            var similarHtml = '';
            for (var i in basicClaimno) {
                if ($('#' + i)) {
                    if (i == 'accdate' || i == 'recdate') {
                        basicClaimno[i] = formate(basicClaimno[i])
                    }
                    $('#' + i).html(basicClaimno[i])
                }
            }
            for (var i in riskTip) {
                if ($('#' + i)) {
                    $('#' + i).html(riskTip[i])
                }
            }
            initScoreNumber()

            for (var i = 0, len = similarTypeClaimnos.length; i < len; i++) {
                var jumpParam = '';
                similarHtml += '<div class="commonBorder sameMsgItem">';
                similarHtml += '<div class="flexCenter">';
                similarHtml += '<div class="number">' + (i + 1) + '</div>';
                similarHtml += '<div class="litter-title-wrapper">';
                similarHtml += '<div class="litter-title row">';
                similarHtml += '<div class="col-md-4 container-fluid">';
                similarHtml += '<div class="col-md-6 left-title">赔案号</div>';
                similarHtml += '<div class="col-md-6  right-title">' + similarTypeClaimnos[i].historyClaimno + '</div>';
                similarHtml += '</div>';
                similarHtml += '<div class="col-md-4 container-fluid">';
                similarHtml += '<div class="col-md-6 left-title">案件结论</div>';
                similarHtml += '<div class="col-md-6 right-title">' + similarTypeClaimnos[i].claimnoConclusion + '</div>';
                similarHtml += '</div>';
                similarHtml += '<div class="col-md-4 container-fluid">';
                similarHtml += '<div class="col-md-6 left-title">相似因子个数</div>';
                similarHtml += '<div class="col-md-6 right-title">' + similarTypeClaimnos[i].similarFactorNum + '</div>';
                similarHtml += '</div>';
                similarHtml += '</div>';
                similarHtml += '<div class="flexCenter picShowWrapper commonBorder">';
                similarHtml += '<div class="picDetail">';
                similarHtml += '<div class="row picDetailTitle">';
                similarHtml += '<div class="col-md-4">相似因子类别</div>';
                similarHtml += '<div class="col-md-4">相似因子明细</div>';
                similarHtml += '</div>';
                for (var j = 0; j < similarTypeClaimnos[i].similarFactorList.length; j++) {
                    var factorListItem = similarTypeClaimnos[i].similarFactorList[j];
                    similarHtml += '<div class="row commonBorderBottom">';
                    similarHtml += '<div class="col-md-4">' + factorListItem.similarityFactorType + '：</div>';
                    similarHtml += '<div class="col-md-4">' + factorListItem.similarityFactorDetail + '</div>';
                    if (factorListItem.remark) {
                        similarHtml += '<div class="col-md-4">' + factorListItem.remark + '</div>';
                    }
                    similarHtml += '</div>';
                }
                similarHtml += '<div class="row">';
                similarHtml += '<div class="col-md-4">';
                similarHtml += '<a href="#">案件详细信息</a>';
                similarHtml += '</div>';
                similarHtml += '</div>';
                similarHtml += '</div>';
                jumpParam = 'caseNow=' + similarTypeClaimnos[i].claimno + '&caseSame=' + similarTypeClaimnos[i].historyClaimno;
                similarHtml += '<a href="/graph/index.do?' + jumpParam + '" class="picShow">';
                similarHtml += '<div class="picShowImg">';
                similarHtml += '<img src="../images/pic.png" alt="">';
                similarHtml += '</div>';
                similarHtml += '<p class="pic-text">图谱展示</p>';
                similarHtml += '</a>';
                similarHtml += '</div>';
                similarHtml += '</div>';
                similarHtml += '<div class="samePencent">';
                similarHtml += '<div class="pencent">' + similarTypeClaimnos[i].similarityFactor * 100 + '%</div>';
                similarHtml += '<div class="text">相似度</div>';
                similarHtml += '</div>';
                similarHtml += '</div>';
                similarHtml += '</div>';
            }
            $('#sameMsg').html(similarHtml)
        }

        function initScoreNumber() {
            // 显示对应的进度条进度
            var $score = $('#score');
            var scoreNumber = $('.scoreNumber').text();
            $score.width($score.parent().width() * scoreNumber + 'px')
            $('.scorePencent').html(scoreNumber * 100 + '%')
        }


        function formate(dateTime) {
            var time = new Date(dateTime);
            var y = time.getFullYear(),
                m = time.getMonth() + 1,
                d = time.getDay();
            return y + '-' + m + '-' + d
        }
    })
</script>
</body>
</html>