tp6框架的销售统计系统

save.html 3.5KB

    {layout name="layout" /} <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog" style="width: 800px;"> <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" id="myModalLabel"> 新增销售单位 </h4> </div> <div class="modal-body"> <form role="form" id="company-form"> <input type="hidden" name="id" id="id" value="0"> <div class="row"> <div class="col-md-2"> <div class="form-group" style="text-align:right;line-height:40px;"> <label form-label for="name">公司名称:</label> </div> </div> <div class="col-md-4"> <div class="form-group"> <input type="text" class="form-control" name="name" id="name" value="" placeholder="公司名称"> </div> </div> <span style='color:red;' id="error_msg"></span> </div> <div class="row"> <div class="col-md-2"> <div class="form-group" style="text-align:right;line-height:40px;"> <label form-label for="department">初期余额:</label> </div> </div> <div class="col-md-4"> <div class="form-group"> <input type="number" class="form-control" name="initial_balance" id="initial_balance" value="" placeholder="初期余额"> </div> </div> </div> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" onclick="closeModel()">关闭</button> <button type="button" class="btn btn-primary" onclick="save()">保存</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal --> </div> <script> function closeModel() { $("#error_msg").html(''); $("#company-form")[0].reset(); $('#myModal').modal('hide'); } function modify(id, name, initial_balance) { $("#id").val(id); $("#name").val(name); $("#initial_balance").val(initial_balance); $('#myModal').modal('show'); } function save(params) { var id = $("#id").val(); var name = $("#name").val(); var initial_balance = Number($("#initial_balance").val()); $.post('/index/company/save', { 'id': id, 'name': name, 'initial_balance': initial_balance }, function(res) { if (res.code == 0) { alert('保存成功'); $('#myModal').modal('hide'); $("#company-form")[0].reset(); window.location.reload(); } else { // $("#company-form").children('div:first').append("<span style='color:red;'>" + res.msg + "</span>"); $("#error_msg").html(res.msg); } return false; }, 'json'); return false; } </script>