@extends('admin/layout')
@section('header')
    <link rel="stylesheet" href="{{asset('js/plugins/jquery-pretty-radio-checkbox/css/jquery-labelauty.css')}}"
          rel="stylesheet">
    {{--<link href="{{asset('js/plugins/jquery-pretty-radio-checkbox/js/jquery-labelauty.js')}}" rel="stylesheet">--}}

@endsection
<style type="text/css">
    ul {
        list-style-type: none;
    }

    li {
        display: inline-block;
    }

    input.labelauty + label {
        font: 12px "Microsoft Yahei";
        display: inline-block !important;
    }

    table.tftable {
        font-size: 12px;
        color: #333333;
        width: 100%;
        border-width: 1px;
        border-color: #9dcc7a;
        border-collapse: collapse;
    }

    table.tftable th {
        font-size: 12px;
        background-color: #abd28e;
        border-width: 1px;
        padding: 8px;
        border-style: solid;
        border-color: #9dcc7a;
        text-align: left;
    }

    table.tftable tr {
        background-color: #ffffff;
    }

    table.tftable td {
        font-size: 12px;
        border-width: 1px;
        padding: 8px;
        border-style: solid;
        border-color: #9dcc7a;
    }

    .fenish {
        background: #1D976C;
        color: #fff;
    }

    .blue {
        background: #6DD5FA;
        color: #fff;
    }

    #tfhover tbody tr td:nth-child(2) {
        position: relative;
        padding-left: 35px;
    }

    .fa {
        position: absolute;
        left: 10px;
        top: 0;
        color: #ddd;
        transform: translateY(-50%);
        top: 50%;
        font-size: 18px !important;
        cursor: pointer;
    }

    .first-numb {
        color: palevioletred;
    }
</style>
<div style="margin-left: 10px">
    <form action="{{url('/admin/flow/notOnlineReason')}}" method="post" id="form1">
        <div style="display: flex;padding: 10px 0;">
            <input type="text" placeholder="请输入域名或项目名称" class="input-md form-control" name="keyword" id="keyword"
                   style="width: 260px;" value="{{$result['keyword']??''}}">
            <select name="manageHelperId" id="manageHelperId" title="" class="form-control"
                    style="width: 150px;float: right"
                    onchange="units.selectPage();">
                <option value="">请选择项目经理</option>
                @foreach($userList as $item)
                    @if($item->role_id==25)
                        <option
                            value="{{$item->id}}"
                            @if(!empty($result['manageHelperId']) && $result['manageHelperId']==$item->id) selected @endif>{{$item->nickname}}</option>
                    @endif
                @endforeach
            </select>
            <select name="editorId" id="editorId" title="" class="form-control"
                    style="width: 150px;float: right" onchange="units.selectPage();">
                <option value="">请选择采编</option>
                @foreach($userList as $item)
                    @if($item->role_id==2)
                        <option
                            value="{{$item->id}}" @if(!empty($result['editorId']) && $result['editorId']==$item->id) selected @endif>{{$item->nickname}}</option>
                    @endif
                @endforeach
            </select>
            <select name="webId" id="webId" title="" class="form-control"
                    style="width: 150px;float: right" onchange="units.selectPage();">
                <option value="">请选择前端</option>
                @foreach($userList as $item)
                    @if($item->role_id==14)
                        <option value="{{$item->id}}"
                                @if(!empty($result['webId']) && $result['webId']==$item->id) selected @endif>{{$item->nickname}}</option>
                    @endif
                @endforeach
            </select>
            <select name="plannerId" id="plannerId" title="" class="form-control"
                    style="width: 150px;float: right" onchange="units.selectPage();">
                <option value="">请选择策划师</option>
                @foreach($userList as $item)
                    @if($item->role_id==29)
                        <option value="{{$item->id}}"
                                @if(!empty($result['plannerId']) && $result['plannerId']==$item->id) selected @endif>{{$item->nickname}}</option>
                    @endif
                @endforeach
            </select>
            <select name="schedule" id="schedule" title="" class="form-control"
                    style="width: 150px;float: right" onchange="units.selectPage();">
                <option value="">请选择进度</option>
                <option value="1" @if(!empty($result['schedule']) && $result['schedule']==1) selected @endif>网站修改-前端配合</option>
                <option value="2" @if(!empty($result['schedule']) && $result['schedule']==2) selected @endif>资料情况-客服部协调</option>
                <option value="3" @if(!empty($result['schedule']) && $result['schedule']==3) selected @endif>关键词地图-策划师</option>
                <option value="4" @if(!empty($result['schedule']) && $result['schedule']==4) selected @endif>TDK布局-策划师</option>
                <option value="5" @if(!empty($result['schedule']) && $result['schedule']==5) selected @endif>网站上线前质检-HINA&质检部</option>
                <option value="6" @if(!empty($result['schedule']) && $result['schedule']==6) selected @endif>网站客户体验-设计配合</option>
            </select>

            <input style="margin-left: 10px" type="submit" class="btn btn-primary" value="搜索">
            <button style="margin-left: 10px" type="button" class="btn btn-primary reset"> 重置</button>
            <button style="margin-left: 10px" type="button" class=" btn btn-primary button"> 保存</button>
        </div>
    </form>
</div>

<table id="tfhover" class="tftable" border="1">
    <thead>
    <tr>
        <th colspan="11" style="text-align: center">
            未上线原因统计
        </th>
    </tr>
    <tr>
        <th style="width: 3%;text-align: center">序号</th>
        <th style="width: 10%;text-align: center">项目名称</th>
        <th style="width: 5%;text-align: center">测试站网址</th>
        <th style="width: 5%;text-align: center">项目经理</th>
        <th style="width: 10%;text-align: center">当月截止时间</th>
        <th style="width: 40%;text-align: center">项目进度</th>
        <th style="width: 10%;text-align: center">备注</th>
    </tr>
    </thead>
    <tbody>
    @foreach($siteList as $key=>$value)
        <tr>
            <td>
                {{$key+1}}
            </td>
            <td data-a="{{$value['id']}}" data-rank="{{$value['rank']??''}}">
                <i @if($value['rank']==1)class="fa fa-heart first-numb" @else class="fa fa-heart" @endif></i>
                <a onclick="units.openDetail('{{$value['id']}}','{{$value['cn_title']}}')">{{$value['cn_title']}}</a>
            </td>
            <td>{{$value['domain']??''}}</td>
            <td>{{$value['manage_helper_title']??''}}</td>
            <td>{{$value['current_month_online_date']??''}}</td>
            <td>
                <ul class="dowebok">
                    <li><input type="checkbox" name="checkbox" value="1" @if(in_array(1,$value['type']))  checked
                               @endif data-labelauty="网站修改-前端配合"></li>
                    <li><input type="checkbox" name="checkbox" value="2" @if(in_array(2,$value['type']))  checked
                               @endif data-labelauty="资料情况-客服部协调"></li>
                    <li><input type="checkbox" name="checkbox" value="3" @if(in_array(3,$value['type']))  checked
                               @endif data-labelauty="关键词地图-策划师"></li>
                    <li><input type="checkbox" name="checkbox" value="4" @if(in_array(4,$value['type']))  checked
                               @endif data-labelauty="TDK布局-策划师"></li>
                    <li><input type="checkbox" name="checkbox" value="5" @if(in_array(5,$value['type']))  checked
                               @endif data-labelauty="网站上线前质检-HINA&质检部"></li>
                    <li><input type="checkbox" name="checkbox" value="6" @if(in_array(6,$value['type']))  checked
                               @endif data-labelauty="网站客户体验-设计配合"></li>
                    <li><input type="checkbox" name="checkbox" value="7" @if(in_array(7,$value['type']))  checked
                               @endif data-labelauty="客户自建站"></li>
                    <li><input type="checkbox" name="checkbox" value="8" @if(in_array(8,$value['type']))  checked
                               @endif data-labelauty="重庆资料问题"></li>
                </ul>
            </td>
            <td><textarea style="border: none;width: 100%;height: 100px">{{$value['memo']??''}}</textarea></td>
        </tr>
    @endforeach
    </tbody>
</table>

@section('footer')

    <script src="{{asset('js/plugins/jquery-pretty-radio-checkbox/js/jquery-labelauty.js')}}"></script>
    <script>

        $(function () {
            $(':input').labelauty();
        });
        window.onload = function () {
            var tfrow = document.getElementById('tfhover').rows.length;
            var tbRow = [];
            for (var i = 1; i < tfrow; i++) {
                tbRow[i] = document.getElementById('tfhover').rows[i];
                tbRow[i].onmouseover = function () {
                    this.style.backgroundColor = '#f3f8aa';
                };
                tbRow[i].onmouseout = function () {
                    this.style.backgroundColor = '#ffffff';
                };
            }
        };

        $('#tfhover tbody tr td:nth-child(2) i').click(function () {
            var rank = 0;
            if ($(this).hasClass('first-numb')) {
                $(this).removeClass('first-numb');
            } else {
                rank = 1;
                $(this).addClass('first-numb');
            }

            var siteId = $(this).parent().attr('data-a');
            var ajaxConfig = {
                url: '/admin/flow/setSiteIdByRankId',
                type: 'post',
                data: {siteId: siteId, type: 7, rank: rank},
                success: function (result) {
                    layer.msg(result.message, {icon: 6, time: 1000}, function () {
                        window.location.reload();
                    });
                }
            };
            tips.ajax(ajaxConfig);
        });


        var units = {
            openDetail: function (id, title) {
                tips.page('/admin/sites/' + id + '/overview', title);
            },
        };
        //重置
        $(function () {
            $('.reset').click(function () {
                $('#keyword').val('');
                $('#manageHelperId').val('');
                $('#editorId').val('');
                $('#webId').val('');
                $('#plannerId').val('');
                $('#schedule').val('');
                $('#form1').submit();
            });
        });

        $('#tfhover tbody tr td').click(function () {
            $(this).toggleClass("fenish");
            if ($(this).hasClass("fenish")) {
                $(this).attr("data-a", "1");
            } else {
                $(this).attr("data-a", "0");
            }
        });

        $('#tfhover tbody tr td:first-child').unbind('click');
        $('#tfhover tbody tr td:nth-child(2)').unbind('click');
        $('#tfhover tbody tr td:nth-child(3)').unbind('click');
        $('#tfhover tbody tr td:nth-child(4)').unbind('click');
        $('#tfhover tbody tr td:nth-child(5)').unbind('click');
        $('#tfhover tbody tr td:nth-child(6)').unbind('click');
        $('#tfhover tbody tr td:nth-child(7)').unbind('click');

        $(".button").click(function () {
            var list = [];

            $("#tfhover tbody").find("tr").each(function () {
                var tdArr = $(this).children();

                var site_id = tdArr.eq(1).attr('data-a');
                var rank = tdArr.eq(1).attr('data-rank');
                var memo = tdArr.eq(6).find('textarea').val();
                var checkbox = tdArr.eq(5).find("input[type='checkbox']");
                var arr = [];
                checkbox.each(function () {
                    if ($(this).is(":checked")) {
                        arr.push($(this).val())
                    }
                });
                var array = {};
                array.site_id = site_id;
                array.rank = rank;
                array.memo = memo;
                array.type = arr;
                list.push(array);
            });

            var ajaxConfig = {
                url: '/admin/flow/notOnlineReason',
                type: 'post',
                data: {list: JSON.stringify(list)},
                success: function (result) {
                    layer.msg(result.message, {icon: 6, time: 1000}, function () {
                        window.location.reload();
                    });
                }
            };
            tips.ajax(ajaxConfig);
        });
    </script>
@endsection