<!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">
    <!-- Date Picker -->
    <link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <!--validate css-->
    <link rel="stylesheet" href="plugins/jquery-validation/css/validate.css">
    <!--fileinput css-->
    <link rel="stylesheet" href="plugins/bootstrap-fileinput/fileinput.min.css">
    <link rel="stylesheet" href="common/css/uePicPicker.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]-->
</head>
<style>
    #prizes th {
        border: 1px #ccc solid;
        background: #FFFAF0;
    }

    #prizes td {
        border: 1px #ccc solid;
    }

    .previewImg {
        max-width: 100%;
        max-height: 100%;
        border: 0px;
        display: none;
        z-index: 999;
    }
</style>
<!-- END HEAD -->
<body class="hold-transition skin-blue sidebar-mini">

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

        <section class="content-header">
            <h1>
                大转盘活动管理
                <small>大转盘活动</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>首页</a></li>
                <li><a class="active">大转盘活动</a></li>
            </ol>
        </section>


        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <!-- general form elements disabled -->
                    <div class="box box-primary">
                        <form role="form" id="myForm">
                            <input name="id" value="$!{data.id}" hidden="true"/>
                            <div class="box-body">
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>活动标题(CN)</label>
                                    <input type="text"
                                           class="form-control htmlescape" name="title"
                                           id="title"
                                           maxlength="100" placeholder="活动标题(CN)"
                                           value="$!{data.title}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>活动标题(EN)</label>
                                    <input type="text"
                                           class="form-control" name="titleEn"
                                           id="title_en"
                                           placeholder="活动标题(EN)"
                                           value="$!{data.titleEn}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12" style="display: none;">
                                    <label>关键字</label>
                                    <input type="text"
                                           class="form-control htmlescape" name="keywords"
                                           id="keywords"
                                           maxlength="30" placeholder="关键字"
                                           value="$!{data.keywords}"
                                           required="required"
                                    >

                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>活动说明(CN)</label>
                                    <input type="text"
                                           class="form-control htmlescape" name="explain"
                                           id="explain"
                                           maxlength="200" placeholder="活动说明(CN)"
                                           value="$!{data.explain}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>活动说明(EN)</label>
                                    <input type="text"
                                           class="form-control" name="explainEn"
                                           id="explainEn"
                                            placeholder="活动说明(EN)"
                                           value="$!{data.explainEn}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>中奖提示(CN)</label>
                                    <input type="text"
                                           class="form-control htmlescape" name="wintips"
                                           id="wintips"
                                           maxlength="200" placeholder="中奖提示(CN)"
                                           value="$!{data.wintips}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>中奖提示(EN)</label>
                                    <input type="text"
                                           class="form-control" name="wintipsEn"
                                           id="wintipsEn"
                                           placeholder="中奖提示(EN)"
                                           value="$!{data.wintipsEn}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>开始时间</label>
                                    <input type="text" class="form-control pull-right datepicker"
                                           value="$!{startTimeStr}"
                                           name="startTimeStr" placeholder="开始时间"
                                           readonly="readonly">
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>结束时间</label>
                                    <input type="text" class="form-control pull-right datepicker"
                                           value="$!{endTimeStr}"
                                           name="endTimeStr" placeholder="结束时间"
                                           readonly="readonly">
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>总抽奖次数上限提示(CN)</label>
                                    <input type="text"
                                           class="form-control htmlescape" name="drawAgainReply"
                                           id="drawAgainReply"
                                           maxlength="100" placeholder="重复抽奖回复"
                                           value="$!{data.drawAgainReply}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>总抽奖次数上限提示(EN)</label>
                                    <input type="text"
                                           class="form-control" name="drawAgainReplyEn"
                                           id="drawAgainReplyEn"
                                            placeholder="重复抽奖回复"
                                           value="$!{data.drawAgainReplyEn}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>每天抽奖次数上限提示(CN)</label>
                                    <input type="text"
                                           class="form-control htmlescape" name="drawAgainDayReply"
                                           id="drawAgainDayReply"
                                           maxlength="100" placeholder="重复抽奖回复"
                                           value="$!{data.drawAgainDayReply}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>每天抽奖次数上限提示(EN)</label>
                                    <input type="text"
                                           class="form-control" name="drawAgainDayReplyEn"
                                           id="drawAgainDayReplyEn"
                                            placeholder="重复抽奖回复"
                                           value="$!{data.drawAgainDayReplyEn}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12" id="actStartPic">
                                </div>
                               <!-- <div class="form-group form-md-line-input">
                                    <label>活动开始图片</label>
                                    <div class="input-group" id="actStartPicGroup">
                                        <input type="text" style="display: none"
                                               class="form-control" name="actStartPic"
                                               id="actStartPic"
                                               maxlength="500" placeholder="栏目图片"
                                               value="$!{data.actStartPic}"
                                        >

                                        &lt;!&ndash;<span class="input-group-btn">&ndash;&gt;
                                        &lt;!&ndash;<button type="button" id="smallImgSelect"&ndash;&gt;
                                        &lt;!&ndash;class="btn btn-info btn-flat">选择</button>&ndash;&gt;
                                        &lt;!&ndash;</span>&ndash;&gt;
                                    </div>
                                    <div id="ImgSelect"
                                         style="text-align: center;line-height: 200px;width: 200px;height: 200px;border: 1px #ccc solid;position: relative;">
                                        <i class="fa fa-plus" style="font-size:50px;color:#ccc"></i>
                                        <img src="" style="" class="previewImg" id="previewImg"/>
                                    </div>
                                </div>-->


                                <div class="form-group form-md-line-input col-md-12">
                                    <label>活动结束title(CN)</label>
                                    <input type="text"
                                           class="form-control htmlescape" name="endTitle"
                                           id="endTitle"
                                           maxlength="100" placeholder="活动结束title(CN)"
                                           value="$!{data.endTitle}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>活动结束title(EN)</label>
                                    <input type="text"
                                           class="form-control" name="endTitleEn"
                                           id="endTitleEn"
                                           maxlength="100" placeholder="活动结束title(EN)"
                                           value="$!{data.endTitleEn}"
                                           required="required"
                                    >
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>活动结束说明(CN)</label>
                                    <textarea required class="form-control" placeholder="活动结束说明(CN)" name="endExplain"
                                              id="endExplain" value="$!{data.endExplain}">$!{data.endExplain}</textarea>
                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>活动结束说明(EN)</label>
                                    <textarea required class="form-control" placeholder="活动结束说明(EN)" name="endExplainEn"
                                              id="endExplainEn" value="$!{data.endExplainEn}">$!{data.endExplainEn}</textarea>
                                </div>

                                <div class="form-group form-md-line-input col-md-12" id="actEndPic">
                                </div>

                               <!-- <div class="form-group form-md-line-input">
                                    <label>活动结束图片</label>
                                    <div class="input-group" id="actEndPicGroup">
                                        <input type="text" style="display: none"
                                               class="form-control" name="actEndPic"
                                               id="actEndPic"
                                               maxlength="500" placeholder=""
                                               value="$!{data.actEndPic}"
                                        >

                                        &lt;!&ndash;<span class="input-group-btn">&ndash;&gt;
                                        &lt;!&ndash;<button type="button" id="smallImgSelect"&ndash;&gt;
                                        &lt;!&ndash;class="btn btn-info btn-flat">选择</button>&ndash;&gt;
                                        &lt;!&ndash;</span>&ndash;&gt;
                                    </div>
                                    <div id="actEndPicSelect"
                                         style="text-align: center;line-height: 200px;width: 200px;height: 200px;border: 1px #ccc solid;position: relative;">
                                        <i class="fa fa-plus" style="font-size:50px;color:#ccc"></i>
                                        <img src="" class="previewImg" id="previewActEndPicImg"/>
                                    </div>
                                </div>
                            </div>-->
                            <div class="form-group form-md-line-input col-md-12">
                                <label>奖项奖品</label>
                                <table id="prizes" class="table table-bordered table-striped dataTable no-footer">
                                    <th>code</th>
                                    <th>奖品名称</th>
                                    <th>奖品内容</th>
                                    <th>奖品类型</th>
                                    <th>奖品数量</th>
                                    <th>奖品金额</th>
                                    <th>概率(仅一般算法需要填写,例:0.4)</th>
                                    <th>操作</th>
                                </table>
                                <p id="addPrizes" style="width:100%;text-align:center"><a
                                        href="javascript:void(0)">添加奖品</a></p>
                            </div>
                            <div class="form-group form-md-line-input col-md-12">
                                <label>活动概率算法</label>
                                <select name="probabilityMethod" class="form-control">
                                    #if($data.probabilityMethod=='NORMAL')
                                    <option value="PERSONNUM">按人数算概率</option>
                                    <option value="NORMAL" selected>一般概率算法</option>
                                    #else
                                    <option value="PERSONNUM" selected>按人数算概率</option>
                                    <option value="NORMAL">一般概率算法</option>
                                    #end
                                </select>
                            </div>
                            <div class="form-group form-md-line-input col-md-12">
                                <label>参与人数预估</label>
                                <input type="text"
                                       class="form-control number" name="attendPersonNum"
                                       id="attendPersonNum"
                                       placeholder="参与人数预估"
                                       value="$!{data.attendPersonNum}"
                                       required="required"
                                >
                            </div>
                            <div class="form-group form-md-line-input col-md-12">
                                <label>每人抽奖次数</label>
                                <input type="text"
                                       class="form-control number" name="perPersonDrawNum"
                                       id="perPersonDrawNum"
                                       placeholder="每人抽奖次数"
                                       value="$!{data.perPersonDrawNum}"
                                       required="required"
                                >
                            </div>
                            <div class="form-group form-md-line-input col-md-12">
                                <label>每人中奖次数</label>
                                <input type="text"
                                       class="form-control number" name="perPersonCanPrize"
                                       id="perPersonCanPrize"
                                       placeholder="每人中奖次数"
                                       value="$!{data.perPersonCanPrize}"
                                       required="required"
                                >
                            </div>
                            <div class="form-group form-md-line-input col-md-12">
                                <label>每天可抽奖次数</label>
                                <input type="text"
                                       class="form-control number" name="perDayDrawNum"
                                       id="perDayDrawNum"
                                       placeholder="每天可抽奖次数"
                                       value="$!{data.perDayDrawNum}"
                                       required="required"
                                >
                            </div>


                            <div class="form-group form-md-line-input col-md-12" style="display: none">
                                <label>是否显示奖品数量</label>
                                #if($data.showPrizesNum)
                                <input type="radio" name="showPrizesNum" checked value="1"> 是
                                <input type="radio" name="showPrizesNum" value="0"> 否
                                #else
                                <input type="radio" name="showPrizesNum" value="1"> 是
                                <input type="radio" name="showPrizesNum" checked value="0"> 否
                                #end

                            </div>

                            <div class="form-group form-md-line-input col-md-12">
                                <label>注册后才能参与</label>
                                #if($data.needRegister)
                                <input type="radio" name="needRegister" checked value="1"> 是
                                <input type="radio" name="needRegister" value="0"> 否
                                #else
                                <input type="radio" name="needRegister" value="1"> 是
                                <input type="radio" name="needRegister" checked value="0"> 否
                                #end
                            </div>
                                <input type="text" style="display: none" name="_csrf" value="${_csrf.token}"/>
                                <input  type="text" style="display: none" name="_csrf_header" value="${_csrf.headerName}"/>
                            <div class="box-footer">
                                #if($shiro.hasPermission("qy:wheel:edit"))
                                <input class="btn btn-primary" #if($data.status == 1 || $data.status==2)style="display: none;"#end id="save" value="保存" type="submit">
                                #end
                                <a href="#springUrl('/a/wheel/list')" class="btn btn-default">取消</a>
                            </div>
                                </div>
                        </form>
                        <!-- /.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 -->

<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>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<script src="plugins\bootstrap-fileinput\fileinput.js"></script>
<script src="plugins/bootstrap-fileinput/zh.js"></script>
<!--fileinput js-->
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script>
<script src="plugins/security/sha256.js" type="text/javascript"></script>
<script src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<script src="plugins/jquery-validation/js/localization/messages_zh.js"></script>
<script src="js/jquery.form.min.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/lang/zh-cn/zh-cn.js"></script>
<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script src="common/js/cfapp.js"></script>
<script src="common/component/uePicPicker.js"></script>
<script src="plugins/Sortable/Sortable.min.js"></script>
<script src="js/jquery.serializejson.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<script>
    var actStartPP = null;
    var actEndPP = null;
    $().ready(function () {
        Cfapp.init();
        recdTypeAdd.init();
        initPicsSel();
        $('.datepicker').datepicker({
            show: true,
            format: 'yyyy-mm-dd',
            autoclose: true,
            language: 'zh-CN',
            todayBtn: 'linked',
            clearBtn: 'linked'

        });

//        var actStartPicImg = $("#actStartPic").val();
//        var protocol = window.location.protocol;
//        var host = window.location.host;
//        if (actStartPicImg && actStartPicImg != null) {
//            if (actStartPicImg.substring(0, 7) == "http://") {
//                $("#previewImg").attr("src", actStartPicImg).show();
//            } else {
//                $("#previewImg").attr("src", protocol + '//' + host + actStartPicImg).show();
//            }
//            $("#previewImg").siblings("i").remove();
//        }
//
//        var actEndPicImg = $("#actEndPic").val();
//        if (actEndPicImg && actEndPicImg != null) {
//            if (actEndPicImg.substring(0, 7) == "http://") {
//                $("#previewActEndPicImg").attr("src", actEndPicImg).show();
//            } else {
//                $("#previewActEndPicImg").attr("src", protocol + '//' + host + actEndPicImg).show();
//            }
//            $("#previewActEndPicImg").siblings("i").remove();
//        }
//
//        /**
//         * 小图选择
//         */
//        $("#ImgSelect").click(function () {
//            obj = $(this);
//            Cfapp.sm({
//                title: "活动开始图选择",
//                success: function (data) {
//                    obj.find("i").remove();
//                    $("#actStartPic").val(data[0]);
//                    $("#previewImg").attr("src", data[0]).show();
//                }
//            })
//        })
//
//        /**
//         * 小图选择
//         */
//        $("#actEndPicSelect").click(function () {
//            obj = $(this);
//            Cfapp.sm({
//                title: "活动结束图选择",
//                success: function (data) {
//                    obj.find("i").remove();
//                    $("#actEndPic").val(data[0]);
//                    $("#previewActEndPicImg").attr("src", data[0]).show();
//                }
//            })
//        })

        $("#prizes").on("click", ".del", function () {
            $(this).parent("td").parent("tr").remove();
        })


        Cfapp.initFileInput({
            uploadUrl: '#springUrl("/a/fileinput/upload")',
            deleteUrl: '#springUrl("/a/fileinput/delete")',
            imgs: "$!{data.actStartPic}",
            ctrName: '#uploadBtn',
            maxFileCount: 1,
            valName: '#imgs',
            uploadExtraData: {
                className: 'wheel',
            }

        });

        Cfapp.initFileInput({
            uploadUrl: '#springUrl("/a/fileinput/upload")',
            deleteUrl: '#springUrl("/a/fileinput/delete")',
            imgs: "$!{data.actEndPic}",
            ctrName: '#actEndPicUploadBtn',
            maxFileCount: 1,
            valName: '#actEndPicImgs',
            uploadExtraData: {
                className: 'wheel',
            }

        });


        $("#addPrizes").click(function () {
            var HTML = "<tr>";
            HTML += "<td><p  class='form-control'  style='border:0 transparent'>" + new Date().getTime() + "</td>";
            HTML += "<td><input placeholder='奖品名称' class='form-control'></td>";
            HTML += "<td><input placeholder='奖品内容' class='form-control'></td>";
            HTML += "<td><input placeholder='奖品类型' class='form-control'></td>";
            HTML += "<td><input placeholder='奖品数量' class='form-control'></td>";
            HTML += "<td><input placeholder='奖品金额' class='form-control'></td>";
            HTML += "<td><input placeholder='奖品权重' class='form-control'></td>";
            HTML += "<td><a href='javascript:void(0)' class='del btn btn-default btn-sm'>删除</a></td>";
            $("#prizes").append(HTML);
        })


        if ("$!{data.id}" != null && "$!{data.id}" != "") {
            var prizes = eval('$!{data.prizes}');
            for (var i = 0; i < prizes.length; i++) {
                var HTML = "<tr>";
                HTML += "<td><p  class='form-control' style='border:0 transparent' >" + prizes[i].code + "</p></td>";
                HTML += "<td><input class='form-control' placeholder='奖品名称' value='" + prizes[i].name + "'></td>";
                HTML += "<td><input class='form-control' placeholder='奖品内容' value='" + prizes[i].desc + "'></td>";
                HTML += "<td><input class='form-control' placeholder='奖品类型' value='" + prizes[i].type + "'></td>";
                HTML += "<td><input class='form-control' placeholder='奖品数量' value='" + prizes[i].qty + "'></td>";
                HTML += "<td><input class='form-control' placeholder='奖品金额' value='" + prizes[i].amount + "'></td>";
                HTML += "<td><input class='form-control' placeholder='奖品权重' value='" + prizes[i].probability + "'></td>";
                HTML += "<td><a href='javascript:void(0)' class='del btn btn-default btn-sm'>删除</a></td>";
                $("#prizes").append(HTML);
            }
        }


    });


    var initPicsSel = function () {

        var actStartPicImg = '$!{data.actStartPic}';
        var actEndPicImg = '$!{data.actEndPic}';

        actStartPP = new uePicPicker({
            tarId: 'actStartPic',
            title: '活动开始图片',
            sizeDes: '750*360',
            max: 1,
            datas: actStartPicImg=='' ? null : actStartPicImg.split(","),
            success: null
        });
        actStartPP.init();

        /*actEndPP = new uePicPicker({
            tarId: 'actEndPic',
            title: '图片',
            sizeDes: '',
            max: 1,
            datas: actEndPicImg=='' ? null : actEndPicImg.split(","),
            success: null
        });
        actEndPP.init();*/
    };

    var recdTypeAdd = function () {
        var initForm = function () {
            var initFormCtrl = function () {
                bindEvent();
            };
            var bindEvent = function () {
                $("#myForm").validate({
                    rules: {},
                    messages: {},
                    submitHandler: function (form) {
                        //$("#save").attr("disabled", true);


                       /* if ($("#actStartPic").val() == null || $("#actStartPic").val() == "") {
                            $("#actStartPicGroup").append("<font color='red'>请上传活动开始图片</font>");
                            return false;
                        }

                        if ($("#actEndPic").val() == null || $("#actEndPic").val() == "") {
                            $("#actEndPicGroup").append("<font color='red'>请上传活动结束图片</font>");
                            return false;
                        }*/


                        var formJson = $("#myForm").serializeJSON();

                        var actStartPic = actStartPP.getStringValues();
//                        var actEndPic = actEndPP.getStringValues();
                        formJson.actStartPic = actStartPic.substring(0, actStartPic.lastIndexOf(','));
//                        formJson.actEndPic = actEndPic.substring(0, actEndPic.lastIndexOf(','));

                        var array = [];

                        var tb = document.getElementById("prizes");  //根据id找到这个表格
                        var reg = /^\d+$/;

                        var isFlag = true;

                        $("#prizes").find("tr").each(function (index, item) {
                            if (index > 0) {
                                var json = {};
                                var tdArr = $(this).children();
                                var code = tdArr.eq(0).text();//奖项code
                                var name = tdArr.eq(1).find('input').val();//奖项名称
                                var desc = tdArr.eq(2).find('input').val();//    奖项内容
                                var type = tdArr.eq(3).find('input').val();//    奖品类型
                                var qty = tdArr.eq(4).find('input').val();//    数量
                                var amount = tdArr.eq(5).find('input').val();//    金额
                                var probability = tdArr.eq(6).find('input').val();//    权重
                                if (qty && reg.test(qty) == false) {
                                    tdArr.eq(4).append("<font color='red'>奖品数量不合法</font>");
                                    isFlag = false;
                                }

                                if (amount && reg.test(amount) == false) {
                                    tdArr.eq(5).append("<font color='red'>奖品金额不合法</font>");
                                    isFlag = false;
                                }

                                json.code = code;
                                json.name = name;
                                json.desc = desc;
                                json.type = type;
                                json.qty = qty;
                                json.amount = amount;
                                json.probability = probability;
                                array.push(json);
                            }
                        });

                        if (!isFlag) {
                            return false;
                        }


                        var arrayStr = JSON.stringify(array);
                        formJson.prizes = arrayStr;


                        $.post("#springUrl('/a/wheel/formData')", formJson, function (returnobj, status) {
                            $("#save").attr("disabled", false);
                            if (returnobj.errorNo == 2) {  //保存成功
                                Cfapp.confirm({
                                    message: "添加成功",
                                    btnoktext: "继续添加",
                                    btncanceltext: "关闭",
                                    success: function () {
                                        location.href = "#springUrl('/a/wheel/form')";
                                    },
                                    cancel: function () {
                                        location.href = "#springUrl('/a/wheel/list')";
                                    }
                                });
                            } else if (returnobj.errorNo == 0) {  //修改成功
                                Cfapp.alert({
                                    message: "更新成功",
                                    btntext: "确定",
                                    success: function () {
                                        location.href = "#springUrl('/a/wheel/list')";
                                    }
                                });
                            } else {
                                Cfapp.alert({
                                    message: "创建失败",
                                    btntext: "确定",
                                    success: function () {
                                        location.href = "#springUrl('/a/wheel/list')";
                                    }
                                });
                            }
                        });
                    }
                })
            }
            initFormCtrl();
        }
        return {

            //main function to initiate the module
            init: function () {
                initForm();
            }

        };
    }();
</script>
</body>
<!-- END BODY -->
</html>