bookCpList.blade.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. @extends('cp.web.layouts.admin')
  2. @section('content')
  3. <div class="row">
  4. <div class="col-lg-12">
  5. <h1 class="page-header">修改图书cp名</h1>
  6. </div>
  7. <!-- /.col-lg-12 -->
  8. </div>
  9. <div class="panel">
  10. @if (session('message'))
  11. <div class="alert alert-success" role="alert">{{session('message')}}</div>
  12. @endif
  13. @if(($errors->has('message')))
  14. <div class="alert alert-danger" role="alert">{{$errors->first('message')}}</div>
  15. @endif
  16. <form action='{{url("book/bookCpList")}}' method="get">
  17. <div class="form-group">
  18. <label>乐阅书名</label>
  19. <input class="form-control" name="old_name" value="{{ @$param['old_name'] }}">
  20. </div>
  21. <div class="form-group">
  22. <label>追书书名</label>
  23. <input class="form-control" name="new_name" value="{{ @$param['new_name'] }}">
  24. </div>
  25. <button type="submit" class="btn btn-success">查询</button>
  26. {{--<a type="button" class="btn btn-success createCp" data-title="添加cp">添加cp</a>--}}
  27. </form>
  28. </div>
  29. <div class="panel panel-default">
  30. <div class="panel-heading">
  31. 列表
  32. </div>
  33. <!-- /.panel-heading -->
  34. <div class="panel-body">
  35. <div class="dataTable_wrapper">
  36. <table class="table table-striped table-bordered table-hover" id="dataTables-example" style="text-align: center">
  37. <tr>
  38. <th>乐阅id</th>
  39. <th>乐阅书名</th>
  40. <th>追书id</th>
  41. <th>追书书名</th>
  42. <th>上架状态</th>
  43. <th>cp</th>
  44. <th>操作</th>
  45. </tr>
  46. @foreach ($data as $record)
  47. <tr >
  48. <td>{{ $record->ly_bid }}</td>
  49. <td>{{ $record->oldname }}</td>
  50. <td>{{ $record->id }}</td>
  51. <td>{{ $record->newname }}</td>
  52. <td><p class="{{ $on_shelf_status[$record->is_on_shelf][1] }}">{{ $on_shelf_status[$record->is_on_shelf][0] }}</p></td>
  53. <td>{{ $record->cp_source }}</td>
  54. <td> <a type="button" class="btn btn-success editcp" data-id="{{$record->id}}" data-title="修改cp--{{$record->newname}}">修改cp</a></td>
  55. </tr>
  56. @endforeach
  57. </table>
  58. </div>
  59. <div class="paging">
  60. 总计:{{ $data->total() }}
  61. {{ $data->appends($param)->links() }}
  62. </div>
  63. </div>
  64. </div>
  65. <div class="modal fade " id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  66. <div class="modal-dialog" role="document">
  67. <div class="modal-content">
  68. <div class="modal-header">
  69. <button type="button" class="close js-modal-close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  70. <h4 class="modal-title" id="myModalLabel">文章内容</h4>
  71. </div>
  72. <div class="modal-body">
  73. <form class="form js-ajax-from">
  74. </form>
  75. </div>
  76. <div class="modal-footer">
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. @endsection
  82. @push('script')
  83. <script >
  84. $(function () {
  85. var b = new AlertWindow({
  86. "startEle":".editcp",
  87. "startAjax":{"url":"/manage/cplistJson"},
  88. "closeEle":".js-modal-close",
  89. "saveEle":".js-ajax-add",
  90. "endAjax":{
  91. "requiredata":["cpid"],
  92. "url":"/book/editCp",
  93. "type":"post"
  94. },
  95. "formHtml":'',
  96. "saveHtml":'<button type="button" class="btn btn-default js-modal-close" data-dismiss="modal">关闭</button><button type="button" class="btn btn-primary js-ajax-add">提交</button>',
  97. });
  98. });
  99. function AlertWindow(obj) {
  100. $.ajaxSetup({
  101. headers: {
  102. 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
  103. }
  104. });
  105. this.startEle = obj.startEle || '.js-alert-start';
  106. this.startAjax = obj.startAjax || false;
  107. this.endAjax = obj.endAjax || false;
  108. this.closeEle = obj.closeEle || ".js-modal-close";
  109. this.saveEle = obj.saveEle || ".js-modal-save";
  110. this.errorEle = obj.errorEle || ".js-error-msg";
  111. this.oStartEle = $(this.startEle);
  112. this.formHtml = obj.formHtml;
  113. this.saveHtml =obj.saveHtml;
  114. this.__init__();
  115. }
  116. AlertWindow.prototype.__init__ = function () {
  117. fromOldHtml = '';
  118. //打开
  119. var that = this;
  120. var editid = '';
  121. if(that.startAjax){
  122. that.oStartEle.on('click',function (e) {
  123. var _this = this;
  124. e.preventDefault();
  125. var data = {};
  126. if(that.startAjax.data){
  127. data[that.startAjax.data.key] = $(this).data(that.startAjax.data.key);
  128. }
  129. $.ajax({
  130. url:that.startAjax.url,
  131. type:that.startAjax.type || 'get',
  132. data:data,
  133. dataType:'json',
  134. success:function (res) {
  135. if(res.code == 1){
  136. //$(that.startAjax.target).html(res.data)
  137. that.formHtml = res.data;
  138. var title = $(_this).data('title') || '编辑';
  139. editid = $(_this).data('id');
  140. that.show(title);
  141. }
  142. },
  143. });
  144. })
  145. }else{
  146. that.oStartEle.on('click',function (e) {
  147. e.preventDefault();
  148. var title = $(this).data('title') || '编辑';
  149. editid = $(this).data('id');
  150. that.show(title);
  151. })
  152. }
  153. //提交
  154. $("#myModal .modal-footer").on('click',that.saveEle,function () {
  155. var data = $('.js-ajax-from').serializeArray();
  156. console.log('--------------------------------------------');
  157. console.log(data);
  158. var res = that.formcheck(data,that.endAjax.requiredata) ;
  159. if(!( res === true )){
  160. $('.'+res).addClass('has-error');
  161. $(that.errorEle).html("不能为空").css({"display":"inline"});
  162. return false;
  163. }
  164. //console.log(that.endAjax);
  165. //console.log(data);
  166. var newdata = {};
  167. for(var k in data){
  168. newdata[data[k]['name']] = data[k]['value'];
  169. }
  170. console.log(editid);
  171. if(editid){
  172. newdata['id'] = editid;
  173. }
  174. console.log(newdata);
  175. //return ;
  176. $.ajax({
  177. url:that.endAjax.url,
  178. type:"post",
  179. data:newdata,
  180. dataType:'json',
  181. success:function (response) {
  182. //console.log(response)
  183. if(response.code){
  184. that.hide();
  185. setTimeout(function () {
  186. var html = '<div class="alert alert-success" role="alert">'+response.msg+'</div>';
  187. $('.js-prepend').prepend(html);
  188. setTimeout(function () {
  189. window.location.reload();
  190. },300)
  191. },10)
  192. }else {
  193. $('.'+res).addClass('has-error');
  194. $(that.errorEle).html(response.msg).css({"display":"inline"});
  195. return false;
  196. }
  197. },
  198. fail:function () {
  199. $(that.errorEle).html("error").css({"display":"inline"});
  200. return false;
  201. }
  202. })
  203. });
  204. //关闭
  205. $(that.closeEle).on('click',function () {
  206. that.hide(that.saveClass);
  207. /*setTimeout(function () {
  208. window.location.reload();
  209. },100)*/
  210. })
  211. };
  212. AlertWindow.prototype.show = function (title) {
  213. $("#myModal .modal-footer").html(this.saveHtml);
  214. $('#myModal .js-ajax-from').html(this.formHtml);
  215. $('body').addClass('modal-open');
  216. $('#myModal').addClass('in').css({"display":"block"});
  217. if(title){
  218. $('#myModalLabel').html(title);
  219. }
  220. //$(".form_datetime").datetimepicker({format: 'yyyy-mm-dd hh:ii'});
  221. };
  222. AlertWindow.prototype.hide = function () {
  223. $("#myModal .modal-footer").html("");
  224. $('body').removeClass('modal-open');
  225. $('#myModal').removeClass('in').css({"display":"none"});
  226. };
  227. AlertWindow.prototype.ajax = function (obj) {
  228. //console.log(obj)
  229. $.ajax({
  230. obj
  231. });
  232. };
  233. AlertWindow.prototype.formcheck = function (form,require) {
  234. //console.log(require);
  235. if(!require.length)
  236. return true;
  237. for(var i = 0;i<require.length;i++){
  238. if( form[i].name == require[i] && form[i].value == '')
  239. return require[i];
  240. }
  241. return true;
  242. }
  243. </script>
  244. @endpush