<!DOCTYPE html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title>表单填写</title>
    <link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/easyui.css" />
	<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/menu.css" />
    <link rel="stylesheet" type="text/css" href="/assets/common/css/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="/assets/web/css/jitnry.css" />
	<link rel="stylesheet" type="text/css" href="/assets/web/css/common_car.css" />
    <script type="text/javascript" src="/assets/common/js/jquery.min.1.9.4.js"></script>
	<script type="text/javascript" src="/assets/common/js/jquery.easyui.min.1.9.4.js"></script>
    <script type="text/javascript" src="/assets/common/js/jquery.cookie.1.4.1.js"></script>
	<!-- 插件调用 --->
	<script type="text/javascript" src="/assets/common/js/datagrid-detailview.js"></script>
	<script type="text/javascript" src="/assets/common/locale/easyui-lang-zh_CN.js"></script>
	<!-- 基础 JS 调用 -->
	<script type="text/javascript" src="/assets/web/js/src/easyui.base.js"></script>
	<script type="text/javascript" src="/assets/web/js/src/allCity.js"></script>
</head>
<body style="margin-bottom: 54px;">
            <div id="win" class="easyui-dialog" title="提示"  style="width: 800px; padding: 10px 20px; height: auto" closed="false" buttons="#dlg-buttons">
                 <form id="fm" name="frm" method="post" style="margin-top: 20px; margin-left: 20px;">
                     <table style="padding: 10px 20px;" cellspacing="10">
<!--                         <tr style="">-->
<!--                             <td>名称:</td>-->
<!--                             <td><input class="easyui-textbox" type="text" name="name" id="old_name" /></td>-->
<!--                             <input class="easyui-textbox" id="prize_id" name="prize_id" type="hidden">-->
<!--                         </tr>-->


                         <tr>
                             <td>重置资格:</td>
                             <td> <a id="name_add_but" href="#" data-options="iconCls:'icon-edit'" class="my_but"  style="vertical-align: middle;">重置</a></td>
                         </tr>

                         <tr>
                             <td>抽奖次数:</td>
                             <td><input class="easyui-textbox" type="number" name="number" id="old_number" /></td>
                             <input class="easyui-textbox" id="rule_id" name="rule_id" type="hidden">
                         </tr>

                         <tr>
                             <td>是否开启:</td>
                             <td><input  id="statusId" name="open" class="easyui-switchbutton" style="height:30px"></td>
                         </tr>

                         <tr>
                             <td>抽奖规则:</td>
                             <td><input class="easyui-textbox" id="title" name="title" data-options="multiline:true" style="height:100px;width: 500px"></td>
                         </tr>



<!--                         <div id="html_table"></div>-->
                         <div id="dlg-buttons" style="display: block">
                             <a id="confirm" href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="submitForm()" style="width: 90px">修改</a>
<!--                             <a id="name_add_but111" href="#" data-options="iconCls:'icon-edit'" class="my_but"  style="vertical-align: middle;">重置</a>-->
                         </div>
                     </table>
                     </form>
            </div>


</body>
<tbody id="html_table"></tbody>
<script type="text/javascript" src="/assets/web/js/src/common_prize.js"></script>
<script>

    $(function(){
            addFile();
    })
         function addFile(){
             $('#win').dialog({
                 title: '规则设置',
                 width: 800,
                 height: "auto",
                 top:150,
                 closed: false,//显示对话框
                 cache: false,
                 modal: true,
                 closable:false
             });
             var result='';
             $.ajax({
                 type: "post",
                 data: result,
                 async: false,
                 url: "/products/prize/prize_rule",
                 success: function(arr) {
                     //var arr = JSON.parse(data);
                    // console.log(arr);
                      $('#rule_id').textbox('setValue',arr.id);
                     $('#old_number').textbox('setValue',arr.number);

                     if(arr.open == "1") {
                         $('#statusId').switchbutton('check');
                     }else {
                         $('#statusId').switchbutton('uncheck');
                     }

                      $('#title').textbox('setValue',arr.title);

                 },
                 error:function(data){
                     console.log(data)
                 }
             });

         }
//提交
         function submitForm(){
             $('#fm').form('submit', {
                 url:'/products/prize/prize_rule_edit',
                 onSubmit: function(){
                     console.log($(this))

                 },
                 success:function(data){
                     var arr = JSON.parse(data);
                     console.log(arr);
                     $.messager.alert("提示", arr.msg);
                 }
             });
         }

    //添加
    $('#name_add_but').linkbutton({

        onClick: function () {
            editFile();
        }
    });
    function editFile(){
        var id='';
        if(confirm("确实要重置抽奖资格?")){
            $.ajax({
                url:'/products/prize/prize_reset',
                type: "POST",
                data: id,
                contentType: false,
                processData: false,
                success: function (data) {
                    console.log(data);
                    $.messager.alert("提示", data.msg);
                },
                error:function(data){
                    console.log(data)
                }
            })
        }else {
            alert("已经取消了操作");
        }
    }




</script>
</html>