<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <base href="#springUrl('/assets/adminlte/')"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>工作台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">

    <!-- DataTables -->
    <link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">

    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
    <!-- Morris chart -->
    <link rel="stylesheet" href="plugins/morris/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet" href="plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
    <link rel="stylesheet"
          href="plugins\bootstrap-fileinput\fileinput.min.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <link rel="stylesheet" href="plugins/bootstrap-star-rating/css/star-rating.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .rating-container .filled-stars {
            color: green;
            border: 0px;
            -webkit-text-stroke: 0px;
        }
    </style>
</head>
<body class="hold-transition skin-blue sidebar-mini">

<div class="wrapper">
    <div class="content-wrapper" style="margin-left:0;">
        <div id="importExcelDiv"></div>

        <section class="content-header">
            <h1>
                品牌申请管理
                <small>品牌申请</small>
            </h1>
            <ol class="breadcrumb">
                <li><a><i class="fa fa-dashboard"></i>首页</a></li>
                <li><a class="active">品牌申请管理列表</a></li>
            </ol>
        </section>

        <div id="remarksModal" class="modal fade" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">修改管理员备注</h4>
                    </div>
                    <div class="modal-body">
                        <textarea id="orderRemarks" style="width: 100%"></textarea>
                        <input id="orderId" style="display: none;">
                    </div>
                    <div class="modal-footer">
                        <a href="javascript:void(0)" data-dismiss="modal" aria-hidden="true"
                           class="btn btn-primary">取消</a>
                        <a href="javascript:void(0)" id="submitRemarks" class="btn btn-primary">确定</a>
                    </div>
                    <!-- dialog buttons -->
                </div>
            </div>
        </div>
        <div id="reasonModal" class="modal fade" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">关闭订单理由</h4>
                    </div>
                    <div class="modal-body">
                        <textarea id="reasonRemarks" style="width: 100%"></textarea>
                    </div>
                    <div class="modal-footer">
                        <a href="javascript:void(0)" data-dismiss="modal" aria-hidden="true"
                           class="btn btn-primary">取消</a>
                        <a href="javascript:void(0)" id="submitReason" class="btn btn-primary">确定</a>
                    </div>
                    <!-- dialog buttons -->
                </div>
            </div>
        </div>
        <div id="completeModal" class="modal fade" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <font color="red">请录入实际费用</font>
                    </div>
                    <div class="modal-body">
                        <div class="col-xs-12" style="float: none;">
                            <label>实际内部工时</label>
                            <input class="form-control select2" style="width: 100%" id="actInnerCost"
                                   value="" placeholder='实际内部工时'>
                            </input>
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>实际外部费用</label>
                            <input class="form-control select2" style="width: 100%" id="actOuterCost"
                                   placeholder='实际外部费用'>
                            </input>
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>是否邀请申请人评分:</label>
                            <input type="radio" name="isScore"
                                   maxlength="2"
                                   value="1"
                                   required="required"
                                   checked
                            >是
                            <input type="radio" name="isScore"
                                   maxlength="2"
                                   value="0"
                                   required="required"
                            >否
                        </div>

                    </div>
                    <div class="modal-footer">
                        <a href="javascript:submitComplete()" class="btn btn-primary">提交</a>
                    </div>
                    <!-- dialog buttons -->
                </div>
            </div>
        </div>

        <div id="evaluateModal" class="modal fade" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <font color="red">请从如下维度为此次服务评价。Please rate the following statements.</font>
                    </div>
                    <div class="modal-body">
                        <div class="col-xs-12" style="float: none;">
                            <label>1.设计质量评价:</label>
                            <input id="designQuanlityScore" class="rating">
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>2.制作质量评价:</label>
                            <input id="makeQuanlityScore" class="rating">
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>您的建议或反馈Your suggestions or comments:</label>
                            <textarea style="width: 100%;" id="managerFeedback"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <a id="submitEvaluate" href="javascript:submitEvaluate()" class="btn btn-primary">提交</a>
                    </div>
                    <!-- dialog buttons -->
                </div>
            </div>
        </div>

        <div id="exportStatistical" class="modal fade" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <font style="color: red;">汇总报表-则根据申请单提交时间进行筛选</font>
                    </div>
                    <div class="modal-body">
                        <div class="col-xs-12" style="float: none;">
                            <input type="text" class="form-control required" readonly
                                   id="exportStatisticalExcelTime" placeholder="筛选时间">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <a id="exportStatisticalLink" href="javascript:exportStatisticalLink()" class="btn btn-primary">导出</a>
                    </div>
                    <!-- dialog buttons -->
                </div>
            </div>
        </div>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <form id="seachTableForm" action="#springUrl('/a/brandApply/list')" method="get">

                                <div class="col-xs-2">
                                    <input type="text" class="form-control required"
                                           name="number" placeholder="申请单号">
                                </div>
                                <div class="col-xs-2">
                                    <input type="text" class="form-control required"
                                           name="name" placeholder="提交人">
                                </div>

                                <div class="col-xs-2">
                                    <input type="text" class="form-control required"
                                           name="departmentName" placeholder="部门">
                                </div>
                                <div class="col-xs-3">
                                    <input type="text" class="form-control required" readonly
                                           name="createTimeStr" placeholder="申请时间">
                                </div>
                                <div class="col-xs-2">
                                    <select class="form-control select2 select2-hidden-accessible" name="status">
                                        <option value="">全部</option>
                                        <option value="0">待接单</option>
                                        <option value="1">待确认</option>
                                        <option value="2">待审批</option>
                                        <option value="3">审批通过</option>
                                        <option value="4">关闭</option>
                                        <option value="5">完成</option>
                                        <option value="6">已取消</option>
                                    </select>
                                </div>
                                <div class="col-xs-3">
                                    <input type="text" class="form-control required"
                                           name="productName" placeholder="成品名称">
                                </div>
                                <div class="col-xs-3">
                                    <select class="form-control select2 select2-hidden-accessible" name="productFormat" placeholder="成品类型">
                                        <option value="">全部</option>
                                        <option value="mp4">mp4</option>
                                        <option value="mov">mov</option>
                                        <option value="wmv">wmv</option>
                                        <option value="avi">avi</option>
                                        <option value="3gp">3gp</option>
                                        <option value="mp3">mp3</option>
                                        <option value="jpg">jpg</option>
                                        <option value="jpeg">jpeg</option>
                                        <option value="tif">tif</option>
                                        <option value="gif">gif</option>
                                        <option value="png">png</option>
                                        <option value="pdf">pdf</option>
                                        <option value="ppt">ppt</option>
                                        <option value="pptx">pptx</option>
                                        <option value="txt">txt</option>
                                        <option value="doc">doc</option>
                                        <option value="xls">xls</option>
                                        <option value="docx">docx</option>
                                        <option value="xlsx">xlsx</option>
                                        <option value="zip">zip</option>
                                    </select>
                                </div>
                                <div class="col-xs-3">
                                    <input type="text" class="form-control required"
                                           name="productLabel" placeholder="成品标签">
                                </div>
                                <div class="col-xs-5">
                                    <a href="javascript:void (0)" class="btn btn-primary search">搜索</a>
                                    <a href="#springUrl('/a/brandApply/downloadcode')"
                                       class="btn btn-primary">品牌申请二维码</a>
                                    <a href="#springUrl('/a/brandApply/exportExcel')"
                                       class="btn btn-primary">导出申请单明细</a>
                                    <a onclick="javascript:exportStatistical()" class="btn btn-primary">导出统计报表</a>
                                </div>
                            </form>
                        </div><!-- /.box-header -->
                        <div class="box-body">
                            <table id="table" class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <td hidden="true">Id</td>
                                    <th>单号</th>
                                    <th>申请状态</th>
                                    <th>姓名</th>
                                    <th>部门</th>
                                    <th>邮箱</th>
                                    <th>成本中心</th>
                                    <th>直属领导</th>
                                    <th>直属领导邮箱</th>
                                    <th>需求类别</th>
                                    <th>需求说明/用途</th>
                                    <th>是否需要制作</th>
                                    <th>期望交付日期</th>
                                    <th>拟交付日期</th>
                                    <th>申请时间</th>
                                    <th>备注</th>
                                    <th>标签</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="tablebody">
                                </tbody>

                            </table>
                        </div><!-- /.box-body -->
                    </div><!-- /.box -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->


    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->
<!-- jQuery 2.1.4 -->
<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins\bootstrap-fileinput\fileinput.js"></script>
<script src="plugins/bootstrap-fileinput/zh.js"></script>
<script src="plugins/bootstrap-fileinput/zh2.js"></script>

<script type="text/javascript"
        src="plugins/bootstrap-star-rating/js/star-rating.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script type="text/javascript"
        src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="common/js/cfapp.js"></script>
<script type="text/javascript"
        src="plugins/daterangepicker/moment.js"></script>
<script type="text/javascript"
        src="plugins/daterangepicker/daterangepicker.js"></script>
<script>
    var csrfheader = {name: '_csrf_header', value: '${_csrf.headerName}'};
    var csrftoken = {name: '_csrf', value: '${_csrf.token}'};
</script>
<script>
    var evaliuateText = {
        1: '非常不赞同 completely disagree',
        2: '不赞同 disagree',
        3: '一般 partly agree',
        4: '赞同agree',
        5: '非常赞同completely agree'
    };

    var starCaptionClasses = {
        1: 'text-success',
        2: 'text-success',
        3: 'text-success',
        4: 'text-success',
        5: 'text-success'
    };

    $('#designQuanlityScore').rating({
        step: 1,
        size: 'sm',//星星大小可选lg,sm,xl,xs
        stars: 5,
        showClear: false,
        starCaptions: evaliuateText,
        starCaptionClasses: starCaptionClasses

    });
    $('#makeQuanlityScore').rating({
        step: 1,
        size: 'sm',//星星大小可选lg,sm,xl,xs
        stars: 5,
        showClear: false,
        starCaptions: evaliuateText,
        starCaptionClasses: starCaptionClasses
    });
    var dateFormat = function (date, fmt) {
        if (!date) {
            return "";
        }
        date = new Date(date);
        const o = {
            "M+": date.getMonth() + 1, //月份
            "d+": date.getDate(), //日
            "h+": date.getHours(), //小时
            "m+": date.getMinutes(), //分
            "s+": date.getSeconds(), //秒
            "q+": Math.floor((date.getMonth() + 3) / 3), //季度
            "S": date.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    };


    function formatDates(now) {
        var now = new Date(now);
        var year = now.getFullYear();
        var month = now.getMonth() + 1;
        var date = now.getDate();
        var hour = now.getHours();
        var minute = now.getMinutes();
        var second = now.getSeconds();
        return year + "-" + month + "-" + date + "   " + hour + ":"
            + minute + ":" + second;
    }

    function seachTable() {
        var sSource = "#springUrl('/a/brandApply/listData')";
        var aoData = {
            iDisplayStart: 1,
            iDosplayLength: 10
        }
        var retrieveData = function (sSource, aoData, fnCallback) {

            $("#seachTableForm input,select").each(function () {
                var params = {
                    name: $(this).attr("name"),
                    value: $(this).val()
                };
                aoData.push(params);
            })

            $.ajax({
                "type": "GET",
                "url": sSource,
                "dataType": "json",
                "data": aoData, //以json格式传递
                "success": fnCallback
            });
        };

        $('#table').DataTable({
            "lengthChange": false,
            "searching": false,
            "ordering": false,
            "bFiltered": false,
            "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": sSource,
            "fnServerData": retrieveData,
            "pagingType": "full_numbers",
            "aoColumns": [
                {
                    "mData": "id"
                },
                {
                    "mData": "number"
                },
                {
                    "mData": "status"
                },
                {
                    "mData": "name"
                },
                {
                    "mData": "departmentName"
                },
                {
                    "mData": "email"
                },
                {
                    "mData": "costCenter"
                },
                {
                    "mData": "lineManager"
                },
                {
                    "mData": "lineManagerEmail"
                },
                {
                    "mData": "categoryName"
                },
                {
                    "mData": "requireSpecify"
                },
                {
                    "mData": "isMaterialObject"
                },
                {
                    "mData": "deliveryDate"
                },
                {
                    "mData": "intendedDeliveryDate"
                },
                {
                    "mData": "createTime"
                },
                {
                    "mData": "description"
                },
                {
                    "mData": "productLabel"
                },
                {
                    "mData": "id"
                },
            ],
            "aoColumnDefs": [
                { // set default column settings
                    'visible': false,
                    'targets': [0]
                },

                {
                    "aTargets": [1],
                    "mData": "number",
                    "mRender": function (a, b, c, d) {
                        return '<a href="#springUrl("/a/brandApply/form?id=' + c.id + '")" data-id="' + c.id + '" data-action="view">' + a + '</a>';

                    }
                },
                {
                    "aTargets": [2],
                    "mData": "status",
                    "mRender": function (a, b, c, d) {
                        if (a == '0') {
                            return "<font style='color: red;font-weight: bold'>待接单</font>";
                        } else if (a == '1') {
                            return "<font style='color: red;font-weight: bold'>待确认</font>"
                        } else if (a == '2') {
                            return "<font style='color: red;font-weight: bold'>待审批</font>"
                        } else if (a == '3') {
                            let productStatus = "";
                            if (c.productName && c.productName != null && c.productName != '') {
                                productStatus = "--已上传"
                            }
                            return "<font style='color: red;font-weight: bold'>审批通过" + productStatus + "</font>"
                        } else if (a == '4') {
                            return "关闭</strong>"
                        } else if (a == '5') {
                            let productStatus = "";
                            // if (c.productName && c.productName != null && c.productName != '') {
                            //     productStatus = "--已上传"
                            // }
                            return "已完成" + productStatus + "</font>"
                        } else if (a == '6') {
                            return "已取消";
                        }
                    }
                },
                {
                    "aTargets": [11],
                    "mData": "isMaterialObject",
                    "mRender": function (a, b, c, d) {
                        if (a == '0') {
                            return "否";
                        } else {
                            return "是"
                        }
                    }
                },

                {
                    "aTargets": [12],
                    "mData": "deliveryDate",
                    "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
                        return dateFormat(a, "yyyy-MM-dd");
                    }
                },
                {
                    "aTargets": [13],
                    "mData": "intendedDeliveryDate",
                    "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
                        return dateFormat(a, "yyyy-MM-dd");
                    }
                },
                {
                    "aTargets": [14],
                    "mData": "createTime",
                    "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
                        return formatDates(a, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                {
                    "aTargets": [17],
                    "mData": "id",
                    "mRender": function (a, b, c, d) {//a表示id对应的值，c表示当前记录行对象
                        var html = '#if($shiro.hasPermission("qy:brandApply:edit"))';//
                        if (c.status == '3') {
                            html += '<a onclick="complete(' + a + ')" class="btn green">完成</a>';
                            if (c.productName && c.productName != null && c.productName != '') {
                                // html += '<a href="#springUrl("/a/brandApplyProduct/form?applyId=' + a + '")" data-id="' + c.id + '" data-action="view"  class="btn red">成品上传<font color="green">(已上传)</font></a>'
                                // html += '<a class="btn green" style="color:#ababab">成品上传<font color="green">(已上传)</font></a>'
                            } else {
                                html += '<a href="#springUrl("/a/brandApplyProduct/form?applyId=' + a + '")" data-id="' + c.id + '" data-action="view"  class="btn red">成品上传<font style="color:#cccccc">(未上传)</font></a>'
                            }
                        }
                        if (c.status == '5' && c.designQuanlityScore == null && c.makeQuanlityScore == null) {
                            html += '<a onclick="evaluateModal(' + a + ')" class="btn green">评价</a>';
                        }

                        if (c.status == '4') {
                            html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="submitCloseReason(' + a + ',\'' + c.closeReason + '\')" class="btn red">关闭订单理由</a>';
                        }

                        if (c.managerRemark && c.managerRemark != null && c.managerRemark != '') {
                            html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="submitRemarks(' + a + ',\'' + c.managerRemark + '\')" class="btn red">管理员备注<font color="green">(已设置)</font></a>';
                        } else {
                            html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="submitRemarks(' + a + ',\'' + c.managerRemark + '\')" class="btn red">管理员备注<font style="color:#cccccc">(未设置)</font></a>';
                        }
                        html += '#end';
                        return html;
                    }
                }

            ]
        });
    }

    jQuery(document).ready(function () {
        $("input[name='createTimeStr']").daterangepicker({
            format: "YYYY-MM-DD HH:mm",
            timePicker: true,
            timePickerIncrement: 5,
            timePicker12Hour: false,
            locale: {
                applyLabel: '确定',
                cancelLabel: '清除',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '手动选择',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                    '七月', '八月', '九月', '十月', '十一月', '十二月'
                ],
                firstDay: 1
            }
        });
        $("input[name='createTimeStr']").on('cancel.daterangepicker', function (ev, picker) {
            $("input[name='createTimeStr']").val('');
        });
        $("#submitRemarks").click(function () {
            var text = $("#orderRemarks").val();
            var id = $("#orderId").val();
            $.ajax({
                type: "POST",
                url: "#springUrl('/a/brandApply/submitRemarks')",
                data: {text: text, _csrf_header: csrfheader.value, _csrf: csrftoken.value, id: id},
                dataType: "json",
                success: function (data) {
                    if (data.errorNo == 0) {
                        Cfapp.alert({
                            message: "更新成功",
                            btntext: "确定",
                            success: function () {
                                location.href = "#springUrl('/a/brandApply/list')";
                            }
                        });
                    }
                },
                error: function () {
                }
            })
        })
        $("#submitReason").click(function () {
            var text = $("#reasonRemarks").val();
            var id = $("#orderId").val();
            $.ajax({
                type: "POST",
                url: "#springUrl('/a/brandApply/closeReason')",
                data: {text: text, _csrf_header: csrfheader.value, _csrf: csrftoken.value, id: id},
                dataType: "json",
                success: function (data) {
                    if (data.errorNo == 0) {
                        Cfapp.alert({
                            message: "更新成功",
                            btntext: "确定",
                            success: function () {
                                location.href = "#springUrl('/a/brandApply/list')";
                            }
                        });
                    }
                },
                error: function () {
                }
            })
        })
        $("#exportStatisticalExcelTime").daterangepicker({
            format: "YYYY-MM-DD HH:mm",
            timePicker: true,
            timePickerIncrement: 5,
            timePicker12Hour: false,
            locale: {
                applyLabel: '确定',
                cancelLabel: '清除',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '手动选择',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                    '七月', '八月', '九月', '十月', '十一月', '十二月'
                ],
                firstDay: 1
            }
        });
        seachTable();
        $('.datepicker').datepicker({
            show: true,
            format: 'yyyy-mm-dd',
            autoclose: true,
            language: 'zh-CN',
            todayBtn: 'linked',
            clearBtn: 'linked'

        });
        $('.search').click(function () {
            $("#table").dataTable().fnClearTable();
        });
    });

    Cfapp.init();

    function submitRemarks(id, text) {
        if (text == null || text == 'null') {
            text = '';
        }
        $("#orderId").val(id);
        $("#orderRemarks").val(text);
        $("#remarksModal").modal("show");
    }


    function submitCloseReason(id, text) {
        if (text == null || text == 'null') {
            text = '';
        }
        $("#orderId").val(id);
        $("#orderReason").val(text);
        $("#reasonModal").modal("show");
    }

    //要操作的数据id
    var operateId = '';

    //弹出完成框
    var complete = function (id) {
        operateId = id;
        $("#completeModal").modal("show");
    }

    //弹出评价框
    var evaluateModal = function (id) {
        operateId = id;
        $("#evaluateModal").modal("show");
    }

    //提交评价操作
    function submitEvaluate() {
        if (operateId == "") {
            Cfapp.alert({
                message: "请重新选择申请单",
                btntext: "确定",
                success: function () {
                    $("#completeModal").modal("hide");
                }
            });
        } else {
            var designQuanlityScore = $("#designQuanlityScore").val();
            var makeQuanlityScore = $("#makeQuanlityScore").val();
            var managerFeedback = $("#managerFeedback").val();
            if (!designQuanlityScore && !makeQuanlityScore
                && designQuanlityScore == null && makeQuanlityScore == null
                && designQuanlityScore == "" && makeQuanlityScore == ""
            ) {
                Cfapp.alert({
                    message: "请打分后在进行提交",
                    btntext: "确定",
                    success: function () {
                    }
                });
                return false;
            }
            var data = {
                id: operateId,
                _csrf_header: csrfheader.value,
                _csrf: csrftoken.value,
                designQuanlityScore: designQuanlityScore,
                makeQuanlityScore: makeQuanlityScore,
                managerFeedback: managerFeedback
            }
            console.log(data);
            Cfapp.confirm({
                message: "确定要提交吗？",
                btnoktext: "确定",
                btncanceltext: "取消",
                success: function () {
                    var warningMsg = Cfapp.warning({
                        content: '请稍后。。。',  //
                        title: "提示"
                    });
                    $.ajax({
                        type: "post",
                        url: "#springUrl('/a/brandApply/evaluate')",
                        data: data,
                        dataType: "json",
                        success: function (data) {
                            warningMsg.destory();
                            if (data.errorNo == 0) {
                                Cfapp.alert({
                                    message: "操作成功",
                                    btntext: "确定",
                                    success: function () {
                                        location.href = "#springUrl('/a/brandApply/list')";
                                    }
                                });
                            }
                        },
                        error: function () {
                        }
                    })
                },
                cancel: function () {
                    $(".modal-backdrop").fadeOut();
                }
            });
        }
    }


    //提交完成操作
    function submitComplete() {
        if (operateId == "") {
            Cfapp.alert({
                message: "请重新选择申请单",
                btntext: "确定",
                success: function () {
                    $("#completeModal").modal("hide");
                }
            });
        } else {
            var isScore = $("input[name='isScore']:checked").val();
            var actInnerCost = $("#actInnerCost").val();
            var actOuterCost = $("#actOuterCost").val();
            if (!actInnerCost && !actOuterCost) {
                Cfapp.alert({
                    message: "请输入实际费用",
                    btntext: "确定",
                    success: function () {
                    }
                });
                return false;
            }
            var data = {
                id: operateId,
                _csrf_header: csrfheader.value,
                _csrf: csrftoken.value,
                actInnerCost: actInnerCost,
                actOuterCost: actOuterCost,
                isScore: isScore
            }
            console.log(data);
            Cfapp.confirm({
                message: "确定要提交吗？",
                btnoktext: "确定",
                btncanceltext: "取消",
                success: function () {
                    var warningMsg = Cfapp.warning({
                        content: '请稍后。。。',  //
                        title: "提示"
                    });
                    $.ajax({
                        type: "post",
                        url: "#springUrl('/a/brandApply/complete')",
                        data: data,
                        dataType: "json",
                        success: function (data) {
                            warningMsg.destory();
                            if (data.errorNo == 0) {
                                Cfapp.alert({
                                    message: "操作成功",
                                    btntext: "确定",
                                    success: function () {

                                        location.href = "#springUrl('/a/brandApply/list')";
                                    }
                                });
                            }
                        },
                        error: function () {
                        }
                    })
                },
                cancel: function () {
                    $(".modal-backdrop").fadeOut();
                }
            });
        }
    }

    function exportStatistical() {
        $("#exportStatistical").modal("show");
    }

    function exportStatisticalLink() {
        var time = $("#exportStatisticalExcelTime").val()
        if (time && time != null && time != '') {
            location.href = "#springUrl('/a/brandApply/exportStatistical')" + "?time=" + time;
            $("#exportStatistical").modal("hide");
        } else {
            Cfapp.alert({
                message: "请选择时间",
                btntext: "确定",
                success: function () {

                }
            });
        }
    }
</script>

</body>
</html>
