美文网首页开发笔记
c# .net mvc排名展示html

c# .net mvc排名展示html

作者: 孤傲小狼 | 来源:发表于2019-12-13 17:19 被阅读0次
    页签1 页签2

    页签切换,echarts隐藏显示,宽高自适应。没啥要说的了,就是单纯的炫耀一下自己做的前端页

    源代码:

    @using dsgcWeb.Models;
    @{
        ViewBag.Title = "Index";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    <link href="~/Content/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="~/Content/bootstrap.css" rel="stylesheet" />
    <script src="~/Scripts/echarts.min.js"></script>
    <style>
        .body-content {
            width: 100%;
            background-color: #d7d5d5
        }
    
        .content {
            height: 100%;
            background-color: white;
            margin-bottom: 20px;
        }
    
        .toolbar {
            padding-top: 20px;
            height: 50px;
            width: 100%;
            display: flex;
        }
    
            .toolbar .tag_personal {
                border: 1px solid #eee;
                border-top-left-radius: 5px;
                border-top-right-radius: 5px;
                height: 30px;
                width: 130px;
                line-height: 30px;
                text-align: center;
                background-color: #eee;
            }
    
                .toolbar .tag_personal:hover {
                    background-color: white;
                    cursor: pointer;
                }
    
        .ranking {
            width: 100%;
            border: 1px solid #eee;
        }
    
        .topThree {
            height: 200px;
            width: 100%;
        }
    
            .topThree .topdiv {
                height: 200px;
                float: left;
                display: table-cell;
                vertical-align: middle;
                text-align: center;
            }
    
                .topThree .topdiv:hover {
                    background-color: #F5F5F5
                }
    
                .topThree .topdiv .topshow {
                    width: 100px;
                    height: 200px;
                    display: inline-block;
                }
    
        .topshowmain {
            width: 100px;
            height: 100px;
            position: relative;
        }
    
        .topshow .topsign {
            position: absolute;
            height: 40px;
            width: 80px;
            transform: rotate(45deg);
        }
    
        .topshow .topsign1 {
            top: 8px;
            right: -20px;
        }
    
        .topshow .topsign2 {
            top: 30px;
            right: -10px;
        }
    
        .topshow .topsign3 {
            top: 30px;
            right: -10px;
        }
    
        .topshow .topname {
            height: 20px;
            border-radius: 4px;
            width: 50px;
            text-align: center;
            color: white;
            position: absolute;
            bottom: -5px;
            left: 25px;
        }
    
        .topshow .topname1 {
            left: 20px;
            width: 60px;
            font-size: 16px;
            background-color: red;
            border: 1px solid red;
        }
    
        .topshow .topname2 {
            background-color: #CFCFCF;
            border: 1px solid #CFCFCF;
        }
    
        .topshow .topname3 {
            background-color: #FF9515;
            border: 1px solid #FF9515;
        }
    
        .topThree .topdiv .topshow .topshowfont {
            margin-top: 10px;
        }
    </style>
    
    <div class="container body-content">
        <div class="content container" id="content">
    
            <div class="toolbar">
                <div class="tag_personal" onclick="Tab(1)" id="tag1" style="background-color:white">
                    个人排名
                </div>
                <div class="tag_personal" onclick="Tab(2)" id="tag2">
                    图表
                </div>
            </div>
            <div class="ranking" id="d1">
                <div class="topThree">
    
                    <div title="我是第二,客户数: @ViewBag.toptwo.count" class="topdiv top2" style="width:33.3%;">
                        <div class="topshow">
                            <div class="topshowmain">
                                @{
                                    var twoss = "";
                                    if (ViewBag.toptwo.photo == "暂无")
                                    {
                                        twoss = "../imgs/empphoto.jpg";
                                    }
                                    else
                                    {
                                        twoss = "data:image/png;base64," + @ViewBag.toptwo.photo;
                                    }
                                    <img class="pimg" src="@twoss" style="width:60px;height :60px;margin-top:40px;border:2px solid #CFCFCF;border-radius:30px;" />
                                }
                                <div class="topname topname2">
                                    NO.2
                                </div>
                                <div class="topsign topsign2">
                                    <img src="~/imgs/top2.png" style="height:30px;width:60px;" />
                                </div>
                            </div>
                            <div></div>
                            <div style="width:100px;height:100px;">
                                <p class="topshowfont">@ViewBag.toptwo.employeeName  <br />@ViewBag.toptwo.Amount <br /> @ViewBag.toptwo.companydept </p>
                            </div>
                        </div>
                    </div>
                    <div title="我是第一,客户数: @ViewBag.topone.count" class="topdiv top1" style="width:33.4%;">
                        <div class="topshow">
                            <div class="topshowmain">
                                @{
                                    var oness = "";
                                    if (ViewBag.topone.photo == "暂无")
                                    {
                                        oness = "../imgs/empphoto.jpg";
                                    }
                                    else
                                    {
                                        oness = "data:image/png;base64," + @ViewBag.topone.photo;
                                    }
                                    <img src="@oness" style="width:80px;height :80px;margin-top:20px;border:2px solid red;border-radius:40px;" />
                                }
                                <div class="topname topname1">
                                    <strong>NO.1</strong>
                                </div>
                                <div class="topsign topsign1">
                                    <img src="~/imgs/top1.png" style="height:40px;width:80px;" />
                                </div>
                            </div>
                            <div style="width:100px;height:100px;">
                                <p class="topshowfont">@ViewBag.topone.employeeName  <br />@ViewBag.topone.Amount <br /> @ViewBag.topone.companydept </p>
                            </div>
                        </div>
                    </div>
                    <div title="我是第三,客户数: @ViewBag.topthree.count" class="topdiv top3" style="width:33.3%;">
                        <div class="topshow">
                            <div class="topshowmain">
                                @{
                                    var threess = "";
                                    if (ViewBag.topthree.photo == "暂无")
                                    {
                                        threess = "../imgs/empphoto.jpg";
                                    }
                                    else
                                    {
                                        threess = "data:image/png;base64," + @ViewBag.topthree.photo;
                                    }
                                    <img class="pimg" src="@threess" style="width:60px;height :60px;margin-top:40px;border:2px solid orange;border-radius:30px;" />
                                }
                                <div class="topname topname3">
                                    NO.3
                                </div>
                                <div class="topsign topsign3">
                                    <img src="~/imgs/top3.png" style="height:30px;width:60px;" />
                                </div>
                            </div>
                            <div style="width:100px;height:100px;">
                                <p class="topshowfont">@ViewBag.topthree.employeeName  <br /> @ViewBag.topthree.Amount <br /> @ViewBag.topthree.companydept </p>
                            </div>
                        </div>
                    </div>
                    <div style="clear:both"></div>
                </div>
                <div class="four2ten">
                    <table class="table table-hover">
                        <tbody>
                            @foreach (var v in ViewBag.four2tenlst as IList<PersonalRankingModel>)
                            {
                                var photo = "";
                                if (v.photo == "暂无")
                                {
                                    photo = "../imgs/empphoto.jpg";
                                }
                                else
                                {
                                    photo = "data:image/png;base64," + @v.photo;
                                }
                                <tr>
                                    <td width="20px">@v.rangking</td>
                                    <td style="display :flex;line-height:38px;padding:0">
                                        <img src="@photo" style="width:30px;height :30px;border:1px solid blue;margin-top:6px;" />
                                        @v.employeeName
                                    </td>
                                    <td>@v.companydept</td>
                                    <td>金额:@v.Amount</td>
                                    <td>客户数:@v.count</td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="ranking" id="d2" style="width:100%;display:none">
            </div>
        </div>
    </div>
    
    
    <script>
        document.title = '个人排名展示';
    
        var rank = document.getElementById('d1');
        rank.style.height = (document.documentElement.clientHeight-100) + "px";
        var chart = document.getElementById('d2');
        chart.style.height = (document.documentElement.clientHeight-100) + "px";
    
        //选项卡切换div
        function Tab(num) {
            var i;
            for (i = 1; i <= 2; i++) {
                if (i == num) {
                    document.getElementById("tag" + i).style.backgroundColor = "white";
                    document.getElementById("d" + i).style.display = "block";
                    if (i == 2)
                    {
                        loadChart();
                    }
                }
                else {
                    document.getElementById("tag" + i).style.backgroundColor = "#eee";
                    document.getElementById("d" + i).style.display = "none";
                }
            }
        }
    
        function loadChart() {
            var Xarr = new Array();
            var Yarr = new Array();
            @foreach (var v in ViewBag.showemplst as IList<PersonalRankingModel>)
            {
                <text>
            Xarr.push('@v.employeeName');
            if ( "@v.Amount"!= "暂无") {
                Yarr.push(@v.Amount);
            }
            else {
                Yarr.push(0);
            }
                    
                </text>
            }
    
            var echartBar = echarts.init(document.getElementById('d2'));
            echartBar.resize();
            var option = {
                color: ['#3398DB'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                        type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
                    }
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: Xarr,
                        axisTick: {
                            alignWithLabel: true
                        },
                        axisLabel: {
                            interval: 0,
                            rotate:0
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        name:'单位/元'
                    }
                ],
                series: [
                    {
                        name: '收款金额',
                        type: 'bar',
                        barWidth: '60%',
                        data: Yarr,
                        itemStyle: {
                            normal: {
                                label: {
                                    show: true,//开启显示数值
                                    position: 'top',
                                    textStyle: {
                                        color: 'black',
                                        fontSize: 16
                                    }
                                },
                                color: function (params) {
                                        var colorList = ['#c23531', '#2f4554', '#61a0a8', '#d48265', '#91c7ae', '#749f83', '#ca8622','#C6E579','#F4E001','#F0805A','#26C0C0','#FFB7DD'];
    
                                        return colorList[params.dataIndex]
                                }
                            }
                        },
                    }
                ]
            };
    
                echartBar.setOption(option);
                window.onresize = function () {
                    var winHeight = 0;
                    if (window.innerHeight)
                        winHeight = window.innerHeight;
                    else if ((document.body) && (document.body.clientHeight))
                        winHeight = document.body.clientHeight;
                    //通过深入Document内部对body进行检测,获取浏览器窗口高度
                    if (document.documentElement && document.documentElement.clientHeight)
                        winHeight = document.documentElement.clientHeight;
    
                    document.getElementById("d2").style.height = (winHeight - 100) + "px";
                    document.getElementById('d1').style.height = (winHeight - 100) + "px";
                    echartBar.resize();
            }
        }
    
    </script>
    
    

    相关文章

      网友评论

        本文标题:c# .net mvc排名展示html

        本文链接:https://www.haomeiwen.com/subject/ggtqnctx.html