keyword_extend.blade.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. @extends('admin/site/side_layout')
  2. @section('header_extend')
  3. @endsection
  4. @section('right')
  5. <div>
  6. <div class="btn-group" role="group">
  7. <button type="button" class="btn btn-success" onclick="units.importExl()">
  8. 导入关键词
  9. </button>
  10. <button type="button" class="btn btn-md btn-danger" onclick="units.del()"
  11. style="margin-left: 10px"><span class="glyphicon glyphicon-remove"></span> 删除
  12. </button>
  13. {{-- <button type="button" class="btn btn-danger" style="margin-left: 10px"
  14. onclick="units.clear()">
  15. <span class="glyphicon glyphicon-remove"></span>清空当月关键词
  16. </button>--}}
  17. </div>
  18. </div>
  19. <div class="table-responsive">
  20. <table id="table" class="table table-condensed"
  21. data-mobile-responsive="true"></table>
  22. </div>
  23. @endsection
  24. @section('footer_extend')
  25. <script>
  26. var openIndex;
  27. var units = {
  28. importExl: function () {
  29. var str = '<div class="ibox-content" id="importLayer">' +
  30. '<form class="form-horizontal">' +
  31. '<div class="form-group">' +
  32. '<label class="col-sm-3 control-label">请选择excel文件:</label>' +
  33. '<div class="col-sm-6">' +
  34. '<input type="file" id="excel_file" class="form-control">' +
  35. '<input type="hidden" id="excel_path">' +
  36. '</div>' +
  37. '<div class="col-sm-2"><button class="btn btn-info" type="button" onclick="units.fileUpload()">上传</button></div>' +
  38. '</div>' +
  39. ' <div class="form-group">' +
  40. '<div class="col-sm-6 col-sm-offset-3">' +
  41. '<a href="{{asset('tpl/keyword_extend.xlsx')}}">请下载导入模板</a>' +
  42. '</div>' +
  43. '</div>' +
  44. '</form>' +
  45. '</div>';
  46. openIndex = layer.open({
  47. type: 1,
  48. content: str,
  49. area: ['60%', '30%'],
  50. title: '导入关键词'
  51. });
  52. },
  53. fileUpload: function () {
  54. var config = {
  55. url: '/admin/tool/excel-upload'
  56. };
  57. config.success = function (result) {
  58. var data = {excel_path: result.data.file_url, siteId: "{{$siteId}}"};
  59. var config = {
  60. url: '/admin/keyword-extend-import/sites/{{$siteId}}',
  61. type: 'post',
  62. data: data,
  63. success: function (result) {
  64. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  65. layer.close(openIndex);
  66. window.location.reload();
  67. });
  68. }
  69. };
  70. tips.ajax(config);
  71. };
  72. tips.fileUpload($("#excel_file"), config);
  73. },
  74. clear: function () {
  75. layer.confirm('您确定要清空全部关键词吗?', {icon: 3, title: '清空'}, function () {
  76. var config = {
  77. url: '/admin/keyword-extend-clear/sites/{{$siteId}}',
  78. type: 'delete',
  79. success: function (result) {
  80. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  81. window.location.reload();
  82. });
  83. }
  84. };
  85. tips.ajax(config);
  86. });
  87. },
  88. getIdsBySelections: function () {
  89. var selections = $("#table").bootstrapTable('getSelections');
  90. var ids = [];
  91. $.each(selections, function (inx, val) {
  92. ids.push(val.id);
  93. });
  94. return ids;
  95. },
  96. del: function () {
  97. var ids = units.getIdsBySelections();
  98. if (ids.length === 0) {
  99. layer.alert('请先选择您所要操作的对象', {icon: 0});
  100. return;
  101. }
  102. layer.confirm('确定删除?', {icon: 3, title: '是否删除'}, function (index, layero) {
  103. layer.close(index);
  104. tips.ajax({
  105. url: '/admin/keyword-extend-delete/sites/{{$siteId}}',
  106. type: 'post',
  107. data: {ids: ids},
  108. tableRefresh: '#table'
  109. });
  110. });
  111. }
  112. };
  113. var config = {};
  114. config.url = '/admin/keyword-extend/sites/' + "{{$siteId}}";
  115. config.pageSize = 20;
  116. config.showColumns = true;
  117. config.columns = [ //字段
  118. {checkbox: true},
  119. {
  120. title: '序号', align: 'center', formatter: function (value, item, index) {
  121. return index + 1;
  122. },
  123. width: '10px'
  124. },
  125. {title: '编号', field: 'id', align: 'center'},
  126. {title: '月份', field: 'ym', align: 'center'},
  127. {title: '推荐关键词', field: 'keyword', align: 'center'},
  128. {title: '年搜索量', field: 'search_num', align: 'center'},
  129. {title: '索引量', field: 'index_num', align: 'center'},
  130. {title: '着陆页', field: 'land_page', align: 'center'},
  131. {title: '创建时间', field: 'created_at', align: 'center'},
  132. ];
  133. tips.bootstrapTable(config);
  134. </script>
  135. @endsection