create.blade.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. @extends('admin.layout')
  2. @section('content')
  3. <?php
  4. if(!isset($data)) $data = array();
  5. if(!$data && session("data")){
  6. $data = session("data");
  7. }
  8. if(!$data && session('_old_input')){
  9. $data = session("_old_input");
  10. }
  11. if(!isset($data['target'])) {
  12. $data['target'] = '_blank';
  13. }
  14. ?>
  15. <div class="wrapper wrapper-content animated fadeInRight">
  16. <div class="row">
  17. <div class="col-sm-12">
  18. <div class="ibox float-e-margins">
  19. <div class="ibox-title">
  20. <h5>CURD</h5>
  21. <div class="ibox-tools">
  22. <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
  23. </a>
  24. </div>
  25. </div>
  26. <div class="ibox-content">
  27. <div class="row">
  28. <div class="col-lg-10">
  29. <form name="form_product" id="form-validation" action="" class="form-horizontal form-validation" accept-charset="UTF-8" method="post">
  30. <div class="form-group">
  31. <label class="control-label col-sm-3">选择表</label>
  32. <div class="col-sm-9">
  33. <select id="c_table" name="table" class="form-control">
  34. <option value="">选择表</option>
  35. @foreach($tables as $key => $val)
  36. <option value="{{ $val->TABLE_NAME}}" des="{{ $val->TABLE_COMMENT}}">{{ $val->TABLE_NAME}}-{{ $val->TABLE_COMMENT}}</option>
  37. @endforeach
  38. </select>
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. <label class="control-label col-sm-3">所属菜单</label>
  43. <div class="col-sm-9">
  44. <select class="form-control" required="" aria-required="true" name="menu_pid">
  45. <option value="">请选择所属菜单</option>
  46. @foreach($MenusTrees AS $val)
  47. <option value={{ $val['id'] }} @if((isset($data['pid']) && $data['pid']==$val['id']) || Request::get('pid')==$val['id']) selected @endif>{{ $val['spacer'] }}{{ $val['name'] }}</option>
  48. @endforeach
  49. </select>
  50. </div>
  51. </div>
  52. <div class="form-group">
  53. <label class="control-label col-sm-3">Description</label>
  54. <div class="col-sm-9">
  55. <input id="c_desc" name="desc" class="form-control" value="" required="" aria-required="true" placeholder="Model不能为空">
  56. </div>
  57. </div>
  58. <div class="form-group">
  59. <label class="control-label col-sm-3">Path</label>
  60. <div class="col-sm-9">
  61. <input id="c_path" name="path" class="form-control" value="" required="" aria-required="true" placeholder="Path不能为空">
  62. <div id="alert_path" class="alert-danger"></div>
  63. </div>
  64. </div>
  65. <div class="form-group">
  66. <label class="control-label col-sm-3">Model</label>
  67. <div class="col-sm-9">
  68. <input id="c_model" name="model" class="form-control" value="" required="" aria-required="true" placeholder="Model不能为空">
  69. <div id="alert_model" class="alert-danger"></div>
  70. </div>
  71. </div>
  72. <div class="form-group">
  73. <label class="control-label col-sm-3">Repository</label>
  74. <div class="col-sm-9">
  75. <input id="c_repositories" name="repositories" class="form-control" required="" aria-required="true" value="{{ $data['link'] or ''}}" placeholder="Service不能为空">
  76. <div id="alert_repositories" class="alert-danger"></div>
  77. </div>
  78. </div>
  79. <div class="form-group">
  80. <label class="control-label col-sm-3">Control</label>
  81. <div class="col-sm-9">
  82. <input id="c_control" name="control" class="form-control" value="" required="" aria-required="true" placeholder="控制器不能为空">
  83. <div id="alert_control" class="alert-danger"></div>
  84. </div>
  85. </div>
  86. <div class="form-group">
  87. <label class="control-label col-sm-3">&nbsp;</label>
  88. <div class="col-sm-9">
  89. <input type="hidden" name="_referer" value="<?php echo urlencode($_SERVER['HTTP_REFERER']);?>"/>
  90. <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
  91. <input type="submit" class="btn btn-success" style="margin-right:20px;">
  92. <input type="reset" class="btn btn-default" >
  93. </div>
  94. </div>
  95. </form>
  96. </div>
  97. <!-- /.col-lg-10 -->
  98. </div>
  99. <!-- /.row -->
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. @endsection
  106. @section('footer')
  107. <script type="text/javascript">
  108. String.prototype.transform = function(){
  109. var re=/_(w)/g;
  110. return this.replace(re,function(){
  111. var args=arguments;
  112. return args[1].toUpperCase();
  113. })
  114. }
  115. $(function() {
  116. $("#c_table").change(function(){
  117. var table=$(this).val();
  118. var des = ($(this).find("option[value='"+table+"']").attr("des"));
  119. $("#c_desc").val(des);
  120. table = table.replace(/(\w)/,function(v){return v.toUpperCase()})
  121. PathtableTo = table.replace(/\_(\w)/g, function(all, letter){
  122. console.log(all);
  123. console.log(letter);
  124. return "/" + letter.toUpperCase();
  125. });
  126. Model = table.replace(/\_(\w)/g, function(all, letter){
  127. console.log(all);
  128. console.log(letter);
  129. return letter.toUpperCase();
  130. });
  131. $("#c_model").val(Model + 'Model').trigger("change");
  132. $("#c_repositories").val(PathtableTo + "Repository").trigger("change");
  133. $("#c_control").val(PathtableTo + "Controller").trigger("change");
  134. $("#c_path").val(PathtableTo).trigger("change");
  135. });
  136. $("#c_model").change(function() {
  137. $.getJSON('/Foundation/Crud/checkModelPath?path=' + $(this).val(),function(data) {
  138. $("#alert_model").html(data.msg);
  139. });
  140. });
  141. $("#c_repositories").change(function() {
  142. $.getJSON('/Foundation/Crud/checkServicePath?path=' + $(this).val(),function(data) {
  143. if(data.status != 200) {
  144. $("#alert_repositories").html(data.msg);
  145. }
  146. });
  147. });
  148. $("#c_control").change(function() {
  149. $.getJSON('/Foundation/Crud/checkControllerPath?path=' + $(this).val(),function(data) {
  150. if(data.status != 200) {
  151. $("#alert_control").html(data.msg);
  152. }
  153. });
  154. });
  155. $("#c_path").change(function() {
  156. $.getJSON('/Foundation/Crud/checkPath?path=' + $(this).val(),function(data) {
  157. if(data.status != 200) {
  158. $("#alert_path").html(data.msg);
  159. }
  160. });
  161. });
  162. });
  163. </script>
  164. @endsection