index.blade.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. @extends('layouts.app')
  2. @section('title')扫描计件-详情@endsection
  3. @section('content')
  4. <div class="d-none" id="list">
  5. <!--查询 -->
  6. <div class="row m-3" style="background-color: #fff;">
  7. <!-- 分页数量 -->
  8. <div class="form-group m-2">
  9. <select class="form-control selectpicker" title="分页大小" v-model="size">
  10. <option value="50">50</option>
  11. <option value="100">100</option>
  12. <option value="200">200</option>
  13. <option value="500">500</option>
  14. <option value="1000">1000</option>
  15. </select>
  16. </div>
  17. <!--用户-->
  18. <div class="form-group m-2" style="max-width: 200px !important;">
  19. <select v-model="search.userIds" class="selectpicker form-control" multiple title="选择用户"
  20. data-actions-box="true"
  21. data-live-search="true"
  22. data-live-search-placeholder="搜索"
  23. >
  24. <option v-for="(v,k) of users" :value="v.id" :key="v.id">@{{ v.name }}</option>
  25. </select>
  26. </div>
  27. <div class="form-group m-2" data-toggle="tooltip" data-placement="top" title="起始日期">
  28. <input v-model="search.startTime" class="form-control" type="date">
  29. </div>
  30. <div class="form-group m-2" data-toggle="tooltip" data-placement="top" title="截止日期">
  31. <input v-model="search.endTime" class="form-control" type="date">
  32. </div>
  33. <div class="form-group m-2" data-toggle="tooltip" data-placement="top" title="单号">
  34. <input v-model="search.content" class="form-control" type="text" placeholder="单号">
  35. </div>
  36. <div class="form-group m-2" data-toggle="tooltip" data-placement="top" title="桌号">
  37. <input v-model="search.scanLocationCode" class="form-control" type="text" placeholder="桌号">
  38. </div>
  39. <div class="form-group m-2">
  40. <button class="form-control btn btn-sm btn-info" @click="searchData()">查询</button>
  41. </div>
  42. <div class="form-group m-2">
  43. <button class="form-control btn btn-sm btn-success" @click="resetSearch()">重置</button>
  44. </div>
  45. </div>
  46. <!-- 导出-->
  47. <span class="dropdown"></span>
  48. <!-- 表格-->
  49. <table class="table table-striped table-bordered table-hover text-nowrap waybill-table td-min-width-80"
  50. style="background: #fff;" id="table">
  51. <tr v-for="(item,i) in details.data" :key="i">
  52. <td class="td-warm text-muted"><span>@{{ i+1 }}</span></td>
  53. <td class="td-warm text-muted"><span>@{{ item.username }}</span></td>
  54. <td class="td-warm text-muted"><span>@{{ item.macAddress }}</span></td>
  55. <td class="td-warm text-muted"><span>@{{ item.scanLocationCode }}</span></td>
  56. <td class="td-warm text-muted"><span>@{{ item.content }}</span></td>
  57. <td class="td-warm text-muted"><span>@{{ item.skuAmount }}</span></td>
  58. <td class="td-warm text-muted"><span>@{{ item.waveDesc }}</span></td>
  59. <td class="td-warm text-muted"><span>@{{ item.createTime }}</span></td>
  60. <td class="td-warm text-muted"><span>@{{ item.recheckTime }}</span></td>
  61. </tr>
  62. </table>
  63. <nav aria-label="...">
  64. <ul class="pagination">
  65. <li class="page-item" :class="current===1?'disabled':''">
  66. <button class="page-link" @click="pagination('pre')">上一页</button>
  67. </li>
  68. <li class="page-item" :class="current===details.pages?'disabled':''">
  69. <button class="page-link" @click="pagination('next')">下一页</button>
  70. </li>
  71. </ul>
  72. </nav>
  73. </div>
  74. @endsection
  75. @section('lastScript')
  76. <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>{{--新版2--}}
  77. <script>
  78. let vue = new Vue({
  79. el: "#list",
  80. data: {
  81. users: [],
  82. selectTr: '',
  83. details: {
  84. data: [],
  85. total: null,
  86. current: null,
  87. pages: null,
  88. size: null
  89. },
  90. size: 50,
  91. current: 1,
  92. search: {
  93. startTime: '',
  94. endTime: '',
  95. userIds: [],
  96. }
  97. },
  98. created() {
  99. this.initData();
  100. let url = this.getBaseUrl();
  101. url += `/api/device/listPage?size=${this.size}&current=${this.current}`;
  102. axios.post(url, this.search).then(res => {
  103. this.details.data = res.data.data.list;
  104. this.details.total = res.data.data.page.total;
  105. this.details.current = res.data.data.page.pageNum;
  106. this.details.pages = res.data.data.page.pages
  107. this.details.size = res.data.data.page.pageSize;
  108. });
  109. },
  110. mounted: function () {
  111. $('#list').removeClass('d-none');
  112. let column = [
  113. {name: 'username', value: '用户'},
  114. {name: 'macAddress', value: 'MAC地址'},
  115. {name: 'locationCode', value: '桌号'},
  116. {name: 'content', value: '单号'},
  117. {name: 'content', value: '数量'},
  118. {name: 'content', value: '波次类型'},
  119. {name: 'createTime', value: '打包时间'},
  120. {name: 'recheckTime', value: '复核时间'},
  121. ];
  122. new Header({
  123. el: "table",
  124. name: "details",
  125. column: column,
  126. data: this.details.data,
  127. restorationColumn: 'addtime',
  128. fixedTop: ($('#form_div').height()) + ($('#btn').height()) + 1,
  129. }).init();
  130. },
  131. methods: {
  132. resetSearch() {
  133. this.current = 1;
  134. this.size = 50;
  135. this.search = {
  136. startTime: null,
  137. endTime: null,
  138. customerCodeList: [],
  139. };
  140. },
  141. searchData() {
  142. this.current = 1;
  143. this.pagination();
  144. },
  145. //根据环境获取不同的url
  146. getBaseUrl() {
  147. let url = '';
  148. let env = "{{ config('app.env') }}";
  149. if (env === 'local') {
  150. url = 'http://127.0.0.1:8116'
  151. } else if (env === 'production') {
  152. url = 'https://device.baoshi56.com'
  153. }
  154. return url;
  155. },
  156. pagination(flag) {
  157. if (flag === 'pre' && this.current > 1) {
  158. this.current--;
  159. } else if (flag === 'next' && this.current < this.details.pages) {
  160. this.current++;
  161. }
  162. let env = "{{ config('env') }}";
  163. console.log(env);
  164. let url = this.getBaseUrl();
  165. url += `/api/device/listPage?size=${this.size}&current=${this.current}`;
  166. let search = Object.assign({}, this.search)
  167. if (search.startTime != null && search.startTime !== '') {
  168. search.startTime += " 00:00:00";
  169. }
  170. if (search.endTime != null && search.endTime !== '') {
  171. search.endTime += " 23:59:59";
  172. }
  173. axios.post(url, search).then(res => {
  174. if (res.data.data === undefined) {
  175. this.details.data = [];
  176. this.details.total = 0
  177. this.details.current = 1
  178. this.details.pages = 0
  179. this.details.size = 50;
  180. } else {
  181. this.details.data = res.data.data.list;
  182. this.details.total = res.data.data.page.total;
  183. this.details.current = res.data.data.page.pageNum;
  184. this.details.pages = res.data.data.page.pages
  185. this.details.size = res.data.data.page.pageSize;
  186. }
  187. });
  188. },
  189. //初始化数据 大类型和小类型的初始化,完成后才可以渲染页面
  190. initData() {
  191. let names = ['device/users'];
  192. let requests = names.map(name => axios.get(this.getBaseUrl() + "/api/" + name));
  193. Promise.all(requests).then(resList => {
  194. for (let res of resList) {
  195. if ((res.config.url + '').endsWith('users')) {
  196. this.users = res.data.data;
  197. }
  198. }
  199. setTimeout(() => {
  200. $(".selectpicker").selectpicker('refresh');
  201. $('#list').removeClass('d-none');
  202. }, 50);
  203. });
  204. },
  205. },
  206. });
  207. </script>
  208. @endsection