index.blade.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. @extends('admin/layout')
  2. @section('content')
  3. <body class="gray-bg">
  4. <div class="wrapper wrapper-content animated fadeInRight">
  5. <div class="row">
  6. <div class="col-sm-12">
  7. <div class="ibox float-e-margins">
  8. <div class="ibox-content">
  9. <form class="row" id="searchForm" onsubmit="units.search();return false;">
  10. <div class="col-md-2">
  11. <div class="input-group">
  12. <span class="input-group-btn">
  13. <button type="button" class="btn btn-md btn-primary" onclick="units.save(0)"
  14. style="margin-left: 10px;border-radius:2px;"> <span class="glyphicon glyphicon-plus"></span> 添加</button>
  15. <button type="button" class="btn btn-md btn-danger" onclick="units.delete()"
  16. style="margin-left: 10px;border-radius:2px;"><span
  17. class="glyphicon glyphicon-remove"></span> 删除</button>
  18. <button type="button" class="btn btn-md btn-primary"
  19. onclick="units.import()" style="margin-left: 10px;border-radius:2px;">
  20. 导入外链
  21. </button>
  22. </span>
  23. </div>
  24. </div>
  25. <div class="col-md-7 pull-right">
  26. <div class="input-group">
  27. <select name="type" id="" class="form-control" title=""
  28. style="width: 150px;float: right">
  29. <option value="">请选择类型</option>
  30. @foreach(\App\Http\Models\Link::TYPES as $key=>$val)
  31. <option value="{{$key}}">{{$val}}</option>
  32. @endforeach
  33. </select>
  34. <select name="business_ids" id="" class="form-control" title=""
  35. style="width: 150px;float: right">
  36. <option value="">请选择行业</option>
  37. @foreach ($businesses as $business)
  38. <option value="{{$business->id}}">{{$business->title}}</option>
  39. @endforeach
  40. </select>
  41. <input type="text" placeholder="请输入平台链接" class="form-control"
  42. name="keyword"
  43. id="keyword" style="width: 300px;float: right">
  44. <span class="input-group-btn">
  45. <button type="button" class="btn btn-md btn-primary" style="border-radius:2px;"
  46. onclick="units.search()"> 搜索
  47. </button>
  48. <button type="reset" class="btn btn-md btn-primary" style="margin-left: 10px;border-radius:2px;"
  49. name="resetBtn"> 重置
  50. </button>
  51. <button type="button" class="btn btn-md btn-primary" style="margin-left: 10px;border-radius:2px;"
  52. onclick="units.exportExcel()"> 导出</button>
  53. </span>
  54. </div>
  55. </div>
  56. </form>
  57. <div style="padding: 20px 10px">
  58. @foreach($list as $value)
  59. {{$value->type}} : {{$value->count}}
  60. @endforeach
  61. </div>
  62. <hr>
  63. <div class="table-responsive">
  64. <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </body>
  72. @endsection
  73. @section('footer')
  74. <script>
  75. var units = {
  76. getIdsBySelections: function () {
  77. var selections = $("#table").bootstrapTable('getSelections');
  78. var ids = [];
  79. $.each(selections, function (inx, val) {
  80. ids.push(val.id);
  81. });
  82. return ids;
  83. },
  84. save: function (id) {
  85. layer.open({
  86. type: 2,
  87. content: ['/admin/link/' + id + '/save'],
  88. area: ['60%', '60%'],
  89. title: '保存'
  90. });
  91. },
  92. search: function () {
  93. tips.selectPage();
  94. },
  95. delete: function () {
  96. var ids = units.getIdsBySelections();
  97. if (ids.length === 0) {
  98. layer.alert('请先选择您所要操作的对象', {icon: 0});
  99. return;
  100. }
  101. layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function (index, layero) {
  102. layer.close(index);
  103. tips.ajax({url: '/admin/links', type: 'delete', data: {ids: ids}, tableRefresh: '#table'});
  104. });
  105. },
  106. exportExcel: function () {
  107. var formValues = tips.getFormValues("#searchForm");
  108. var str = $.param(formValues);
  109. window.open('/admin/link/externalChainLibraryExport?' + str)
  110. },
  111. import: function () {
  112. var str = '<div class="ibox-content" id="importLayer">' +
  113. '<form class="form-horizontal">' +
  114. '<div class="form-group">' +
  115. '<label class="col-sm-3 control-label">请选择excel文件:</label>' +
  116. '<div class="col-sm-6">' +
  117. '<input type="file" id="excel_file" class="form-control">' +
  118. '<input type="hidden" id="excel_path">' +
  119. '</div>' +
  120. '<div class="col-sm-2"><button class="btn btn-info" type="button" onclick="units.fileUploadExl()">上传</button></div>' +
  121. '</div>' +
  122. ' <div class="form-group">' +
  123. '<div class="col-sm-6 col-sm-offset-3">' +
  124. '<a href="{{asset('tpl/outer_chain.xls')}}">请下载导入模板</a>' +
  125. '</div>' +
  126. '</div>' +
  127. '</form>' +
  128. '</div>';
  129. openIndex = layer.open({
  130. type: 1,
  131. content: str,
  132. area: ['60%', '30%'],
  133. title: '导入关键词'
  134. });
  135. },
  136. fileUploadExl: function () {
  137. var config = {
  138. url: '/admin/tool/excel-upload'
  139. };
  140. config.success = function (result) {
  141. var data = {excel_path: result.data.file_url};
  142. var config = {
  143. url: '/admin/link/externalChainLibraryImport',
  144. type: 'post',
  145. data: data,
  146. success: function (result) {
  147. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  148. layer.close(openIndex);
  149. window.location.reload();
  150. });
  151. }
  152. };
  153. tips.ajax(config);
  154. };
  155. tips.fileUpload($("#excel_file"), config);
  156. },
  157. };
  158. var config = {};
  159. config.url = '/admin/links';
  160. config.columns = [ //字段
  161. {checkbox: true},
  162. {
  163. title: '序号', align: 'center', formatter: function (value, item, index) {
  164. return index + 1;
  165. }
  166. },
  167. {title: '外链类型', field: 'typeTitle', align: 'center'},
  168. {title: '标签', field: 'tag', align: 'center'},
  169. {title: '平台链接', field: 'url', align: 'center'},
  170. {title: '行业', field: 'business', align: 'center'},
  171. {title: 'Authority Score', field: 'authority_score', align: 'center'},
  172. {title: 'Spam Score', field: 'spam_score', align: 'center'},
  173. {title: '锚文本', field: 'bigBall', align: 'center'},
  174. {title: '备注', field: 'remark', align: 'center'},
  175. {title: '创建时间', field: 'created_at', align: 'center'},
  176. {
  177. title: '操作', field: 'id', align: 'center',
  178. formatter: function (value, row) {
  179. var str = '';
  180. // if (row.status === 1) {
  181. str += '<button onclick="units.save(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button>';
  182. // }
  183. return str;
  184. }
  185. }
  186. ];
  187. tips.bootstrapTable(config);
  188. </script>
  189. @endsection