<!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>
        #appitems tr td {
            padding: 5px;
        }
        .hiddenCol{
            display: none;
        }
        .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="myModal" class="modal fade" data-backdrop="static">
            <div class="modal-dialog" style="width: 80%;">
                <div class="modal-content">
                    <!-- dialog body -->
                    <div class="modal-body">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <input name="form-id" style="display: none;">
                        <input name="typeform" style="display: none;" value="$!{id}">
                        <table id="form-table" style="width: 100%;">
                            <tr>
                                <td>所属单据</td>
                                <td><input type="text" class="form-control"
                                           name="typeformName" readonly></td>
                                <td>申请人</td>
                                <td><input type="text" class="form-control"
                                           name="form-name" readonly></td>
                                <td>职能部门</td>
                                <td><input type="text" class="form-control"
                                           name="form-departmentName" readonly></td>
                            </tr>
                            <tr>
                                <td>申请时间</td>
                                <td><input type="text" class="form-control"
                                           name="form-appTime" readonly></td>
                                <td>审批状态</td>
                                <td><input type="text" class="form-control"
                                           name="form-status" readonly></td>
                                <td>发放状态</td>
                                <td><input type="text" class="form-control"
                                           name="form-issuingStateName" readonly></td>
                            </tr>
                        </table>
                        <p style="font-weight: bold;">申请列表</p>
                        <table id="appitems" style="border: #d2d6de 1px solid;width: 100%;">.

                            <thead style="    background: #F0F0F0;border-bottom: #d2d6de solid 1px;font-weight: bold;">
                            <td>物品名称</td>
                            <td>物品规格</td>
                            <td>申请数量</td>
                            <td>单价</td>
                            <td>剩余库存</td>
                            <td>发放数量</td>
                            </thead>
                            <tbody>

                            </tbody>
                        </table>
                        <textarea placeholder="请输入内容" id="desc" style="width: 50%;margin-top: 15px;"></textarea>
                    </div>
                    <!-- dialog buttons -->
                </div>
            </div>
        </div>

        <div id="exportDetail" 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="exportDetailExcelTime" placeholder="筛选时间">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <a id="exportDetailLink" href="javascript:exportDetailLink()" 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>

        <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.整体服务Overall service:</label>
                            <input id="allEvaluate"  class="rating" >
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>2.促销品质量Promotional item:</label>
                            <input id="promotionalItemEvaluate"  class="rating" >
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>3.物流服务 Logistics service:</label>
                            <input id="logisticsServiceEvaluate"  class="rating" >
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>您的建议或反馈Your suggestions or comments:</label>
                            <textarea style="width: 100%;" id="managerEvaluateRemarks"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <a id="submitEvaluate" href="javascript:submitEvaluate()" 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="#" method="get">
                                <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="dname" placeholder="职能部门">
                                </div>
                                <div class="col-xs-2">
                                    <input type="text" class="form-control required"
                                           name="number" placeholder="申请单号">
                                </div>
                                <div class="col-xs-5">
                                    <a href="javascript:void(0)" class="btn btn-primary search">搜索</a>
                                    #if($shiro.hasPermission("download:promotion:qrcode"))
                                    <a href="#springUrl('/a/typeAppForm/downloadcode?id=1')" data-action="view" class="btn btn-primary">促销品申请二维码</a>
                                    #end
                                    #if($shiro.hasPermission("qy:typeappform:exportDetail"))
                                    <a href="javascript:exportDetails()" class="btn btn-primary">导出申请单明细</a>
                                    #end
                                    #if($shiro.hasPermission("manager:statistical:report"))
                                    <a href="javascript:exportStatistical()" class="btn btn-primary">导出申请单汇总报表</a>
                                    #end
                                </div>
                            </form>
                        </div><!-- /.box-header -->
                        <div class="box-body">
                            <table id="table" class="table table-bordered table-striped">
                                <thead>

                                </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>
<!-- 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 type="text/javascript"
        src="plugins/bootstrap-star-rating/js/star-rating.min.js"></script>
<script>
    var csrfheader = {name: '_csrf_header', value: '${_csrf.headerName}'};
    var csrftoken = {name: '_csrf', value: '${_csrf.token}'};
</script>
<script>

    var evaliuateText = {1: '不好 poor', 2: '不是很好 below average', 3: '一般 average', 4: '很好above average', 5: '非常好exceptional'};

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

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

    });
    $('#promotionalItemEvaluate').rating({
        step: 1,
        size: 'sm',//星星大小可选lg,sm,xl,xs
        stars:5,
        showClear: false,
        starCaptions: evaliuateText,
        starCaptionClasses:starCaptionClasses
    });
    $('#logisticsServiceEvaluate').rating({
        step: 1,
        size: 'sm',//星星大小可选lg,sm,xl,xs
        stars:5,
        showClear: false,
        starCaptions: evaliuateText,
        starCaptionClasses:starCaptionClasses
    });
    jQuery(document).ready(function () {


        $("#exportDetailExcelTime").daterangepicker({
            format: "YYYY-MM-DD HH:mm",
            timePicker: true,
            timePickerIncrement: 1,
            timePicker24Hour : true,
            timePicker12Hour:false,
            locale: {
                applyLabel: '确定',
                cancelLabel: '清除',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '手动选择',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                    '七月', '八月', '九月', '十月', '十一月', '十二月'
                ],
                firstDay: 1
            }
        });

        $("#exportStatisticalExcelTime").daterangepicker({
            format: "YYYY-MM-DD HH:mm",
            timePicker: true,
            timePickerIncrement: 1,
            timePicker24Hour : true,
            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();

        });


    });
    var evaliuateId = "";
    function submitEvaluate(){
        if(evaliuateId==""){
            Cfapp.alert({
                message: "请重新选择申请单",
                btntext: "确定",
                success: function () {
                   $("#evaluateModal").modal("hide");
                }
            });
        }else{
           var allevaluate = $("#allEvaluate").val();
           var promotionEvaluate = $("#promotionalItemEvaluate").val();
           var logisticsEvaluate = $("#logisticsServiceEvaluate").val();
           var managerEvaluateRemarks = $("#managerEvaluateRemarks").val();
            if(!allevaluate ||!promotionEvaluate || !logisticsEvaluate
            || allevaluate==null || promotionEvaluate==null || logisticsEvaluate==null
            || allevaluate=="" || promotionEvaluate=="" || promotionEvaluate==""
            ){
                Cfapp.alert({
                    message: "请打分后在进行提交",
                    btntext: "确定",
                    success: function () {
                    }
                });
                return false;
            }
            var data = {
                id: evaliuateId,
                _csrf_header:csrfheader.value,
                _csrf:csrftoken.value,
                managerAllEvaluate:allevaluate,
                managerQualityEvaluate:promotionEvaluate,
                managerLogisticsEvaluate:logisticsEvaluate,
                managerEvaluateRemarks:managerEvaluateRemarks
            }
            console.log(data);
            Cfapp.confirm({
                message: "确定要提交吗？",
                btnoktext: "确定",
                btncanceltext: "取消",
                success: function () {
                    $.ajax({
                        type: "post",
                        url: "#springUrl('/a/typeAppForm/evaluate')",
                        data: data,
                        dataType: "json",
                        success: function (data) {
                            if (data.errorNo == 0) {
                                Cfapp.alert({
                                    message: "评分成功",
                                    btntext: "确定",
                                    success: function () {
                                        location.href = "#springUrl('/a/typeAppForm/list')";
                                    }
                                });
                            }
                        },
                        error: function () {
                        }
                    })
                },
                cancel: function () {
                    $(".modal-backdrop").fadeOut();
                }
            });
        }
    }



    function confirm(id){
        Cfapp.confirm({
            message: "确定要确认收货吗？",
            btnoktext: "确定",
            btncanceltext: "取消",
            success: function () {
                $.ajax({
                    type: "get",
                    url: "#springUrl('/a/typeAppForm/confirm')",
                    data: {id: id,_csrf_header:csrfheader.value,_csrf:csrftoken.value},
                    dataType: "json",
                    success: function (data) {
                        if (data.errorNo == 0) {
                            Cfapp.alert({
                                message: "确认收货成功",
                                btntext: "确定",
                                success: function () {
                                    location.href = "#springUrl('/a/typeAppForm/list')";
                                }
                            });
                        }
                    },
                    error: function () {
                    }
                })
            },
            cancel: function () {
                $(".modal-backdrop").fadeOut();
            }
        });
    }

    function evaliuate(id){
        evaliuateId=id;
        $("#evaluateModal").modal("show");
    }

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

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

                }
            });
        }
    }

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

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

                }
            });
        }
    }



    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/typeAppForm/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",
            "initComplete":function(){
                if("$!{isManager}" == '0'){
                    $("#table").dataTable().fnSetColumnVis( 9, false);
                }

            },
            "columns":[
                {
                    "data": "id",
                    "title":"ID",
                },{
                    "data": "number",
                    "title":"申请单号",
                },
                {
                    "data": "name"
                    ,
                    "title":"申请人姓名",
                },
                {
                    "data": "org"
                    ,
                    "title":"申请人ORG",
                },
                {
                    "data": "dname"
                    ,
                    "title":"部门名称",
                },
                {
                    "data": "costCenter"
                    ,
                    "title":"成本中心",
                },
                {
                    "data": "address"
                    ,
                    "title":"收货信息",
                }, {
                    "data": "statusName"
                    ,
                    "title":"审批状态",
                }, {
                    "data": "issuingStateName"
                    ,
                    "title":"发放状态",
                },{
                    "data": "isCancel"
                    ,
                    "title":"是否有退库",
                },
                {
                    "data": "createTime"
                    ,
                    "title":"申请时间",
                },
                {
                    "data": "id"
                    ,
                    "title":"操作",
                }
            ],


            "aoColumnDefs": [
                { // set default column settings
                    'aTargets': [0],
                    'visible': false
                },
                {
                    "aTargets": [1],
                    "mData": "number",
                    "mRender": function (a, b, c, d) {
                        var html="";
                        html += '<a data-id="' + a + '" href="#springUrl("/a/typeAppForm/formId?id=' + c.id + '&type=3")"  data-action="view" class="btn green">'+a+'</a><br/>';
                        return html;
                    }

                },
                {
                    "targets": [9],
                    "mData": "isCancel",
                    "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象

                        if(a=='0'){
                            return "否";
                        }else{
                            return "是";
                        }
                    }
                },

                {
                    "aTargets": [10],
                    "mData": "createTime",
                    "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
                        return formatDates(a, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                {
                    "aTargets": [11],
                    "mData": "id",
                    "mRender": function (a, b, c, d) {//a表示id对应的值，c表示当前记录行对象
                        var issuingState = c.issuingState;//发货状态
                        var status = c.status;//审核状态
                        var grantSource = c.grantSource; //发货方
                        var html = '#if($shiro.hasPermission("qy:typeAppForm:managerSubmit"))';
                        /*发放状态为待录入数量，并且审核状态为部门领导审批通过/市场部领导审批通过/市场部领导审批拒绝*/
                        if((status == 1 || status ==5 || status == 4) && issuingState == -1){
                            html += '<a data-id="' + a + '" href="#springUrl("/a/typeAppForm/formId?id=' + a + '&type=0")"  data-action="view" class="btn green">录入发货量</a><br/>';
                        }
                        html+='#end';
                        html+='#if($shiro.hasPermission("qy:typeAppForm:managerGrant"))';
                        //管理员发货按钮
                        /**
                         * 如果发货渠道为仅管理员，并且发放状态为已录入，未发货的状态，则显示管理员发货按钮。（有权限的前提下）
                         * or
                         * 如果发货渠道为管理员+供应商，并且发放状态为已录入未发货的状态或者发放状态为供应商已发货，则显示管理员发货按钮
                         */
                        if((grantSource==1 && issuingState==0) || (grantSource==2 && (issuingState==0 || issuingState==1))){
                            html += '<a data-id="' + a + '" href="#springUrl("/a/typeAppForm/formId?id=' + a + '&type=1")"  data-action="view" class="btn green">管理员发货</a><br/>';
                        }
                        html+='#end';
                        html+= '#if($shiro.hasPermission("qy:typeAppForm:distriGrant"))';
                        //供应商发货按钮
                        /**
                         * 如果发货渠道为仅供应商，并且发放状态为已录入，未发货的状态，则显示供应商发货按钮。（有权限的前提下）
                         * or
                         * 如果发货渠道为管理员+供应商，并且发放状态为已录入未发货的状态或者发放状态为管理员已发货，则显示供应商发货按钮
                         */
                        if((grantSource==0 && issuingState==0) || (grantSource==2 && (issuingState==0 || issuingState==2))){
                            html += '<a data-id="' + a + '" href="#springUrl("/a/typeAppForm/formId?id=' + a + '&type=2")"  data-action="view" class="btn green">供应商发货</a><br/>';
                        }
                        html+='#end';
                        if(issuingState == 3){
                            if(c.managerConfirmTime==null){//没有确认收货过，则显示确认收货按钮
                                html+='#if($shiro.hasPermission("qy:typeappform:confirm"))<a class="btn green" onclick="confirm('+a+')">确认收货</a><br/>#end';
                            }
                            if(c.managerConfirmTime!=null && c.managerQualityTime==null){
                                html+='#if($shiro.hasPermission("qy:typeappform:evaliuate"))<a class="btn green" onclick="evaliuate('+a+')">评分</a><br/>#end';
                            }else if(c.managerConfirmTime!=null && c.managerQualityTime!=null){
                                html+="<a class=\"btn green\" style='color:#cccccc'>评分</a>";
                            }
                            html+= '#if($shiro.hasPermission("qy:grantitems:view"))';
                            html += '<a data-id="' + a + '" href="#springUrl("/a/grantitems/list?formId='+a+'")"  data-action="view" class="btn green">查看发放列表</a><br/>';
                            html+='#end';
                            html+= '#if($shiro.hasPermission("qy:typeAppForm:cancelItem"))';
                            html += '<a data-id="' + a + '" href="#springUrl("/a/typeAppForm/cancelForm?id=' + a + '")"  data-action="view" class="btn green">退库</a><br/>';
                            html+='#end';
                            html+= '#if($shiro.hasPermission("qy:cancelitems:view"))';
                            html += '<a data-id="' + a + '" href="#springUrl("/a/cancelitems/list?formId=' + a + '")"  data-action="view" class="btn green">查看退库列表</a><br/>';
                            html+='#end';
                        }
                        // var html = '#if($shiro.hasPermission("qy:typeAppForm:viewCancelList"))';//
                        // if((c.status == 1 || c.status ==5 || c.status == 4) && c.issuingState == 0){
                        //     html += '<a data-id="' + a + '" href="#springUrl("/a/typeAppForm/formId?id=' + a + '&type=0")"  data-action="view" class="btn green">发放</a><br/>';
                        // } else if(c.issuingState==1){
                        //     html += '<a data-id="' + a + '" href="#springUrl("/a/grantitems/list?formId='+a+'")"  data-action="view" class="btn green">查看发放列表</a><br/>';
                        //     html += '<a data-id="' + a + '" href="#springUrl("/a/typeAppForm/cancelForm?id=' + a + '")"  data-action="view" class="btn green">退库</a><br/>';
                        //     html += '<a data-id="' + a + '" href="#springUrl("/a/cancelitems/list?formId=' + a + '")"  data-action="view" class="btn green">查看退库列表</a><br/>';
                        // }
                        // html += '#end';
                        return html;
                    }
                }

            ]
        });
    }





    Cfapp.init();

    function removeData(data) {
        Cfapp.confirm({
            message: "确定要删除吗",
            btnoktext: "确定",
            btncanceltext: "取消",
            success: function () {
                $.ajax({
                    type: "POST",
                    url: "#springUrl('/a/typeAppForm/delete')",
                    data: {id: data},
                    dataType: "json",
                    success: function (data) {
                        if (data.errorNo == 0) {
                            Cfapp.alert({
                                message: "删除成功",
                                btntext: "确定",
                                success: function () {
                                    location.href = "#springUrl('/a/typeAppForm/list')";
                                }
                            });
                        }
                    },
                    error: function () {
                    }
                })
            },
            cancel: function () {
                $(".modal-backdrop").fadeOut();
            }
        });
    }

    function importExcel() {
        var templateExcelUrl = "#springUrl('/a/typeAppForm/templateExcel')";
        var importExcelUrl = "#springUrl('/a/typeAppForm/importExcel')";
        Cfapp.importExcel({
            title: '类型申请单导入',
            importurl: importExcelUrl,
            templateurl: templateExcelUrl,
            cancel: function () {

            },
            success: function () {

            }
        });
    }


</script>

</body>
</html>
