index.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <include file="public@header"/>
  2. <style>
  3. .box {
  4. padding: .5rem;
  5. }
  6. .header {
  7. /*text-align: center;*/
  8. height: 48px;
  9. line-height: 48px;
  10. }
  11. .header .name {
  12. font-weight: bold;
  13. font-size: 20px;
  14. margin-left: 44%;
  15. }
  16. .header .date {
  17. float: right;
  18. margin-right: 15px;
  19. }
  20. .box .money {
  21. text-align: center;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <div class="wrap js-check-wrap">
  27. <ul class="nav nav-tabs">
  28. <li class="active"><a>采购支出列表</a></li>
  29. <li><a href="{:url('admin/stock/add')}">添加采购记录</a></li>
  30. </ul>
  31. <form class="well form-inline margin-top-20" method="post" action="{:url('admin/stock/index')}">
  32. 关键字:
  33. <input class="form-control" type="text" id="keyword" name="keyword" style="width: 200px;" value="{:input('request.keyword')}"
  34. placeholder="设备名称">
  35. <input type="submit" class="btn btn-primary" value="搜索"/>
  36. <a class="btn btn-default" href="{:url('admin/stock/index')}">清空</a>
  37. <a class="btn btn-success" onclick="doPrint()">打印</a>
  38. <a class="btn btn-warning" href="{:url('admin/stock/export')}">导出</a>
  39. <a class="btn btn-danger" onclick="doDelete()">批量删除</a>
  40. </form>
  41. <form method="post" class="js-ajax-form">
  42. <table class="table table-hover table-bordered">
  43. <thead>
  44. <tr>
  45. <th width="60"><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">全选</th>
  46. <th>设备名称</th>
  47. <th>采购人</th>
  48. <th>采购金额</th>
  49. <th>入库数量</th>
  50. <th>入库时间</th>
  51. <th>{:lang('ACTIONS')}</th>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <php>
  56. $user_statuses=array("0"=>lang('USER_STATUS_BLOCKED'),"1"=>lang('USER_STATUS_ACTIVATED'),"2"=>lang('USER_STATUS_UNVERIFIED'));
  57. </php>
  58. <foreach name="list" item="vo">
  59. <tr>
  60. <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}" title="ID:{$vo.id}"></td>
  61. <td>{$vo.title}</td>
  62. <td>{$vo['name']?$vo['name']:lang('NOT_FILLED')}</td>
  63. <td>{$vo['nums']?$vo['nums']:lang('NOT_FILLED')}</td>
  64. <td>{$vo.money}</td>
  65. <td>{$vo['created_at']?$vo['created_at']:lang('NOT_FILLED')}</td>
  66. <td>
  67. <a class="btn btn-xs btn-warning js-ajax-dialog-btn" href="{:url('stock/del',array('id'=>$vo['id']))}" data-msg="确认删除?">删除</a>
  68. </td>
  69. </tr>
  70. </foreach>
  71. </tbody>
  72. </table>
  73. <div class="pagination">{$page}</div>
  74. </form>
  75. <div id="printBox" style="display: none;">
  76. <!--startprint-->
  77. <title>单据打印</title>
  78. <div class="box">
  79. <div class="header">
  80. <span class="name">采 购 单</span>
  81. <span class="date">日期:<php>echo date('Y年m月d日')</php></span>
  82. </div>
  83. <table class="table table-hover table-bordered">
  84. <thead>
  85. <tr>
  86. <th>货号</th>
  87. <th>设备名称</th>
  88. <th>采购人</th>
  89. <th>采购数量</th>
  90. <th>采购金额</th>
  91. <th>备注</th>
  92. </tr>
  93. </thead>
  94. <tbody id="dataList">
  95. <tr id="counts">
  96. <td>合计</td>
  97. <td colspan="5" class="money"><span id="money"></span> 元</td>
  98. </tr>
  99. </tbody>
  100. </table>
  101. </div>
  102. <!--endprint-->
  103. </div>
  104. </div>
  105. <script src="__STATIC__/js/admin.js"></script>
  106. <script>
  107. function doDelete() {
  108. var ids = [];
  109. $(".js-check:checked").each(function () {
  110. var id = $(this).val();
  111. if (id > 0) {
  112. ids.push(id);
  113. }
  114. });
  115. if (ids.length <= 0) {
  116. showMsg('请先选择操作项');
  117. return false;
  118. }
  119. if(confirm('确定批量删除选择项?不可恢复')){
  120. $.post('/admin/stock/del',{id:ids},function(res){
  121. if(res.code == 1){
  122. showMsg(res.msg);
  123. setTimeout(function () {
  124. location.reload();
  125. }, 800)
  126. }else{
  127. showMsg(res.msg);
  128. }
  129. },"json")
  130. }
  131. }
  132. /**
  133. * 打印数据
  134. */
  135. function doPrint(){
  136. var keyword = $.trim($("#keyword").val());
  137. $.post('/admin/stock/getDataList',{keyword: keyword},function(res){
  138. if(res.code == 'success'){
  139. var dataList = res.data.list;
  140. var total = res.data.total;
  141. if(dataList.length<=0){
  142. showMsg('暂无数据可以打印');
  143. return false;
  144. }
  145. var html = '';
  146. $.each(dataList, function(k, item){
  147. html += '<tr><td>'+(k+1)+'</td>';
  148. html += '<td>'+item.title+'</td>';
  149. html += '<td>'+item.name+'</td>';
  150. html += '<td>'+item.nums+'</td>';
  151. html += '<td>'+item.money+'</td>';
  152. html += '<td></td></tr>';
  153. });
  154. $("#counts").before(html);
  155. $("#money").text(total);
  156. htmlPrint();
  157. }else{
  158. showMsg(res.msg);
  159. }
  160. },"json")
  161. }
  162. /**
  163. * 打印
  164. */
  165. function htmlPrint(){
  166. window.document.body.innerHTML=$("#printBox").html();
  167. window.print();
  168. location.reload();
  169. }
  170. </script>
  171. </body>
  172. </html>