link_count_for_site.blade.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. @extends('admin/site/side_layout')
  2. @section('header_extend')
  3. @endsection
  4. @section('right')
  5. @php $hasEdit=0; @endphp
  6. @hasAuth('sites-links-edit')
  7. @php $hasEdit=1; @endphp
  8. @endHasAuth
  9. <form class="row" id="searchForm">
  10. @if($hasEdit)
  11. <div class="col-md-2">
  12. <div class="input-group">
  13. <span class="input-group-btn">
  14. <button type="button" class="btn btn-md btn-info" onclick="units.importLink()"><span
  15. class="glyphicon glyphicon-hand-up"></span> 导入外链</button>
  16. <button type="button" class="btn btn-md btn-success" style="margin-left: 10px"
  17. onclick="units.save(0)"><span
  18. class="glyphicon glyphicon-hand-down"></span> 添加单个外链</button>
  19. <button type="button" class="btn btn-md btn-danger" onclick="units.delete()"
  20. style="margin-left: 10px"> <span
  21. class="glyphicon glyphicon-remove"></span> 删除</button>
  22. {{--<button type="button" class="btn btn-md btn-danger"--}}
  23. {{--style="margin-left: 10px"><span--}}
  24. {{--class="glyphicon glyphicon-remove"></span> 清空外链</button>--}}
  25. </span>
  26. </div>
  27. </div>
  28. @endif
  29. <div class="col-md-6 pull-right">
  30. <div class="input-group">
  31. <input type="text" placeholder="请输入平台链接" class="input-md form-control"
  32. name="keyword"
  33. id="keyword" style="width: 300px;float: right">
  34. <span class="input-group-btn">
  35. <button type="button" class="btn btn-md btn-primary" onclick="units.search()"> 搜索</button>
  36. <button type="button" class="btn btn-md btn-primary" style="margin-left: 10px" name="btnReset"> 重置</button>
  37. <button type="button" class="btn btn-md btn-info" style="margin-left: 10px"
  38. onclick="units.exportExcel()"> 导出</button>
  39. </span>
  40. </div>
  41. </div>
  42. </form>
  43. <hr>
  44. <div class="table-responsive">
  45. <table id="table" class="table table-condensed"
  46. data-mobile-responsive="true"></table>
  47. </div>
  48. @endsection
  49. @section('footer_extend')
  50. <script>
  51. var units = {
  52. exportExcel: function () {
  53. var keyword = $("#keyword").val();
  54. window.open('/admin/link/export/{{$siteId}}?keyword=' + keyword);
  55. },
  56. search: function () {
  57. tips.selectPage();
  58. },
  59. importLink: function () {
  60. var str = '<div class="ibox-content" id="importLayer">' +
  61. '<form class="form-horizontal">' +
  62. '<div class="form-group">' +
  63. '<label class="col-sm-3 control-label">请选择excel文件:</label>' +
  64. '<div class="col-sm-6">' +
  65. '<input type="file" id="excel_file" class="form-control">' +
  66. '<input type="hidden" id="excel_path">' +
  67. '</div>' +
  68. '<div class="col-sm-2"><button class="btn btn-info" type="button" onclick="units.fileUpload()">上传</button></div>' +
  69. '</div>' +
  70. ' <div class="form-group">' +
  71. '<div class="col-sm-6 col-sm-offset-3">' +
  72. '<a href="{{asset('tpl/link_tpl.xlsx')}}">请下载导入模板</a>' +
  73. '</div>' +
  74. '</div>' +
  75. '</form>' +
  76. '</div>';
  77. var openIndex = layer.open({
  78. type: 1,
  79. content: str,
  80. area: ['60%', '40%'],
  81. btn: ['导入', '取消'],
  82. title: '导入外链',
  83. yes: function (index, layero) {
  84. var data = {excel_path: $("#excel_path").val(), siteId: "{{$siteId}}"};
  85. var config = {
  86. url: '/admin/link/import/{{$siteId}}',
  87. type: 'post',
  88. data: data,
  89. success: function (result) {
  90. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  91. layer.close(openIndex);
  92. tips.tableRefresh();
  93. });
  94. }
  95. };
  96. tips.ajax(config);
  97. }
  98. });
  99. },
  100. fileUpload: function () {
  101. var config = {
  102. url: '/admin/tool/excel-upload'
  103. };
  104. config.success = function (result) {
  105. $("#excel_path").val(result.data.file_url);
  106. layer.msg(result.message, {icon: 6, time: 1500});
  107. };
  108. tips.fileUpload($("#excel_file"), config);
  109. },
  110. getIdsBySelections: function () {
  111. var selections = $("#table").bootstrapTable('getSelections');
  112. var ids = [];
  113. $.each(selections, function (inx, val) {
  114. ids.push(val.id);
  115. });
  116. return ids;
  117. },
  118. delete: function () {
  119. var ids = units.getIdsBySelections();
  120. if (ids.length === 0) {
  121. layer.alert('请先选择您所要操作的对象', {icon: 0});
  122. return;
  123. }
  124. layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function () {
  125. tips.ajax({url: '/admin/link/link-detail', type: 'delete', data: {ids: ids}});
  126. tips.tableRefresh('#table');
  127. });
  128. },
  129. save: function (id) {
  130. layer.open({
  131. type: 2,
  132. content: ['/admin/link/link-count/' + id + '?siteId={{$siteId}}'],
  133. area: ['60%', '70%'],
  134. title: '保存'
  135. });
  136. }
  137. // detail: function (id) {
  138. // layer.open({
  139. // type: 2,
  140. // content: ['/admin/link/task/' + id],
  141. // area: ['90%', '100%'],
  142. // title: '',
  143. // closeBtn: 0
  144. // });
  145. // },
  146. };
  147. var config = {};
  148. config.url = '/admin/link/sites/{{$siteId}}/link-count';
  149. config.columns = [ //字段
  150. {checkbox: true},
  151. {
  152. title: '序号', align: 'center', formatter: function (value, item, index) {
  153. return index + 1;
  154. }
  155. },
  156. {title: '类型', field: 'link_type_source', align: 'center'},
  157. {title: '平台链接', field: 'link_url_source', align: 'center'},
  158. {title: '关联外链标题', field: 'task_title', align: 'center'},
  159. {title: '用户名', field: 'username', align: 'center'},
  160. {title: '邮箱', field: 'email', align: 'center'},
  161. {title: '密码', field: 'password', align: 'center'},
  162. {title: 'profile演示地址', field: 'url', align: 'center'},
  163. {title: '页面演示地址数量', field: 'urls_count', align: 'center'},
  164. {title: '创建时间', field: 'created_at', align: 'center'},
  165. {
  166. title: '操作', field: 'id', align: 'center',
  167. formatter: function (value, row) {
  168. var str = '';
  169. @if($hasEdit)
  170. str += '<button onclick="units.save(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button>';
  171. @endif
  172. return str;
  173. }
  174. }
  175. ];
  176. tips.bootstrapTable(config);
  177. </script>
  178. @endsection