index.blade.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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-title"></div>
  9. <div class="ibox-content">
  10. <form class="row" id="searchForm">
  11. <div class="col-md-4">
  12. <div class="input-group">
  13. <span class="input-group-btn">
  14. <button type="button" class="btn btn-md btn-primary"
  15. style="margin-left: 10px" onclick="units.edit(0)"> <span
  16. class="glyphicon glyphicon-plus"></span> 添加</button>
  17. <button type="button" class="btn btn-md btn-danger" onclick="units.delete()"
  18. style="margin-left: 10px"><span
  19. class="glyphicon glyphicon-remove"></span> 删除</button>
  20. </span>
  21. </div>
  22. </div>
  23. {{--<div class="col-md-6 pull-right">--}}
  24. {{--<div class="input-group">--}}
  25. {{--<input type="text" placeholder="请输入名称" class="input-md form-control"--}}
  26. {{--name="keyword"--}}
  27. {{--id="keyword">--}}
  28. {{--<span class="input-group-btn">--}}
  29. {{--<button type="button" class="btn btn-md btn-primary"--}}
  30. {{--onclick="units.search()"> 搜索</button>--}}
  31. {{--<button type="reset" class="btn btn-md btn-primary" style="margin-left: 10px"--}}
  32. {{--name="resetBtn"> 重置</button> </span>--}}
  33. {{--</div>--}}
  34. {{--</div>--}}
  35. </form>
  36. <hr>
  37. <div class="table-responsive">
  38. <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </body>
  46. @endsection
  47. @section('footer')
  48. <script>
  49. var units = {
  50. search: function () {
  51. tips.selectPage();
  52. },
  53. getIdsBySelections: function () {
  54. var selections = $("#table").bootstrapTable('getSelections');
  55. var ids = [];
  56. $.each(selections, function (inx, val) {
  57. ids.push(val.id);
  58. });
  59. return ids;
  60. },
  61. edit: function (id) {
  62. var title = '添加';
  63. if (id > 0) {
  64. title = '编辑';
  65. }
  66. layer.open({
  67. type: 2,
  68. content: ['/admin/invoices/' + id],
  69. area: ['100%', '100%'],
  70. title: title
  71. });
  72. },
  73. delete: function () {
  74. var ids = units.getIdsBySelections();
  75. if (ids.length === 0) {
  76. layer.alert('请先选择您所要操作的对象', {icon: 0});
  77. return;
  78. }
  79. layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function (index, layero) {
  80. layer.close(index);
  81. tips.ajax({
  82. url: '/admin/invoices',
  83. type: 'delete',
  84. data: {ids: ids},
  85. tableRefresh: '#table'
  86. });
  87. });
  88. },
  89. upload: function (id, photo) {
  90. var str = '<div class="ibox-content" id="importLayer">' +
  91. '<form class="form-horizontal">' +
  92. '<div class="form-group">' +
  93. '<label class="col-sm-3 control-label">请选择图片:</label>' +
  94. '<div class="col-sm-6">' +
  95. '<input type="file" id="excel_file" class="form-control">' +
  96. '<input type="hidden" id="excel_path">' +
  97. '</div>' +
  98. '<div class="col-sm-2"><button class="btn btn-info" type="button" onclick="units.fileUpload()">上传</button></div>' +
  99. '</div>' +
  100. '<div class="form-group">' +
  101. '<div class="col-sm-6 col-sm-offset-3">' +
  102. '<img ';
  103. if (photo.length > 10) {
  104. str += 'src="' + photo + '"';
  105. }
  106. str += ' style="height:150px" id="img">' +
  107. '</div>' +
  108. '</div>' +
  109. '</form>' +
  110. '</div>';
  111. layer.open({
  112. type: 1,
  113. content: str,
  114. area: ['60%', '50%'],
  115. btn: ['确定', '取消'],
  116. title: '拍照上传',
  117. yes: function (index, layero) {
  118. var config = {
  119. url: '/admin/invoices/' + id + '/photo',
  120. type: 'put',
  121. data: {photo: $("#img").attr('src')},
  122. success:function (result) {
  123. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  124. tips.tableRefresh('#table');
  125. layer.close(index);
  126. });
  127. }
  128. };
  129. tips.ajax(config);
  130. }
  131. });
  132. },
  133. fileUpload: function () {
  134. var config = {
  135. url: '/admin/tool/upload'
  136. };
  137. config.success = function (result) {
  138. $("#img").attr('src', result.data.file_url);
  139. layer.msg(result.message, {icon: 6, time: 1500});
  140. };
  141. tips.fileUpload($("#excel_file")[0], config);
  142. }
  143. };
  144. var config = {};
  145. config.url = '/admin/invoices';
  146. config.columns = [ //字段
  147. {checkbox: true},
  148. {
  149. title: '序号', align: 'center', formatter: function (value, item, index) {
  150. return index + 1;
  151. }
  152. },
  153. {title: '金额', field: 'amount', align: 'center'},
  154. {title: '抬头', field: 'title', align: 'center'},
  155. {title: '税号', field: 'tax_no', align: 'center'},
  156. {title: '创建时间', field: 'created_at', align: 'center'},
  157. {
  158. title: '操作', field: 'id', align: 'center',
  159. formatter: function (value, row) {
  160. return (
  161. '<button onclick="units.edit(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button>&nbsp;' +
  162. '<button onclick="units.upload(' + value + ',\'' + row.photo + '\')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>上传</button>&nbsp;'
  163. );
  164. }
  165. }
  166. ];
  167. tips.bootstrapTable(config);
  168. </script>
  169. @endsection