home_city_edit.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <include file="./Application/Admin/View/head.html" />
  5. <link rel="stylesheet" type="text/css" href="/Public/lib/bootstrap-Switch/bootstrapSwitch.css" />
  6. <link rel="stylesheet" type="text/css" href="/Public/plugins/uploadify/uploadify.css">
  7. <link rel="stylesheet" type="text/css" href="/Public/plugins/css/tinyselect.css">
  8. <style type="text/css">
  9. form .row input{width:250px;}
  10. * {
  11. margin: 0;
  12. padding: 0;
  13. }
  14. .citys{
  15. margin-bottom: 10px;
  16. }
  17. .citys p{
  18. line-height: 28px;
  19. }
  20. .warning{
  21. color: #c00;
  22. }
  23. table a{
  24. margin-right: 8px;
  25. color: #369;
  26. }
  27. .imgUpload {
  28. width: 60px;
  29. height: 25px;
  30. line-height: 25px;
  31. text-align: center;
  32. border-radius: 2px;
  33. background: #CC290E;
  34. color: #FFF;
  35. font-size: 12px;
  36. border: none;
  37. cursor: pointer;
  38. outline: none;
  39. }
  40. .c_img{
  41. width:240px;height:auto;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <article class="page-container">
  47. <form action="" method="post" class="form form-horizontal" id="edit">
  48. <div class="row cl">
  49. <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>名称:</label>
  50. <div class="formControls col-xs-10 col-sm-10">
  51. <input type="text" class="input-text" placeholder="请输入城市名称" id="name" name="name" value="{$data['name']}" />
  52. </div>
  53. </div>
  54. <div class="row cl">
  55. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
  56. <input type="hidden" class="input-text" value="{$data.id}" placeholder="" id="id" name="id" />
  57. <button type="submit" class="btn btn-success radius" id="save" name="save"><i class="icon-ok"></i> 确定</button>
  58. </div>
  59. </div>
  60. </form>
  61. </article>
  62. <!--_footer 作为公共模版分离出去-->
  63. <include file="./Application/Admin/View/foot.html" />
  64. <!--/_footer /作为公共模版分离出去-->
  65. <script>
  66. //下面js课用于多个图片异步上传,无需重复
  67. $(document).on('click','.imgUpload',function(){
  68. $(this).siblings('.imgFile').trigger('click');
  69. });
  70. $(document).on('change','.imgFile',function(e){
  71. var imgFile = $(this);
  72. var imgInput = $("#img");
  73. var reader = new FileReader();
  74. reader.onload = (function (file) {
  75. return function (e) {
  76. var imgBase64 = this.result;
  77. $(imgInput).val(imgBase64);
  78. var html = '<img class="c_img" src="' + imgBase64 + '" >';
  79. $(imgFile).siblings('.imgView').html(html);
  80. };
  81. })(e.target.files[0]);
  82. reader.readAsDataURL(e.target.files[0]);
  83. });
  84. </script>
  85. <script>
  86. $().ready(function() {
  87. $("#edit").validate({
  88. rules: {
  89. name: {required: true},
  90. city_id: {required: true}
  91. },
  92. success: "valid",
  93. submitHandler: function() {
  94. $("#save").attr('disabled', true);
  95. var data = {
  96. id: $('#id').val(),
  97. name: $('#name').val(),
  98. city_id: $('#city').val(),
  99. img: $('#img').val(),
  100. address: $('#address').val(),
  101. date: $('#date').val(),
  102. s_time: $('#s_time').val(),
  103. e_time: $('#e_time').val(),
  104. tel: $('#tel').val()
  105. };
  106. $.ajax({
  107. type: "post",
  108. url: "{:U(CONTROLLER_NAME . '/' . ACTION_NAME)}",
  109. data: {data:data},
  110. success: function(data) {
  111. if (data.status == '1') {
  112. //加载层-风格3
  113. parent.layer.load(2);
  114. parent.layer.msg(data.info, {icon: 1});
  115. parent.location.reload();
  116. var index = parent.layer.getFrameIndex(window.name);
  117. parent.layer.close(index);
  118. } else if(data.status == '0') {
  119. parent.layer.msg(data.info, {icon: 2});
  120. }
  121. $("#save").removeAttr('disabled');
  122. }
  123. });
  124. }
  125. });
  126. });
  127. </script>
  128. </body>
  129. </html>