index.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. <div class="form-group ml-4 mt-3" data-toggle="tooltip" data-placement="top" title="选择全部">
  8. <input @change="checkAllBtn()" v-model="checkAll" type="checkbox" class="form-check-input"
  9. id="checkAll">
  10. <label class="form-check-label" for="checkAll">选择全部</label>
  11. </div>
  12. <div class="form-group m-2">
  13. <select class="form-control selectpicker" title="分页大小" v-model="size">
  14. <option value="50">50</option>
  15. <option value="100">100</option>
  16. <option value="200">200</option>
  17. <option value="500">500</option>
  18. <option value="1000">1000</option>
  19. </select>
  20. </div>
  21. <div class="form-group m-2" style="max-width: 200px !important;">
  22. <select v-model="search.warehouseId" class="selectpicker form-control" title="仓库"
  23. data-actions-box="true"
  24. data-live-search="true"
  25. data-live-search-placeholder="搜索"
  26. >
  27. <option v-for="(v,k) of selectData.warehouses" :value="v.id" :key="v.id">@{{ v.name }}</option>
  28. </select>
  29. </div>
  30. <div class="form-group m-2">
  31. <select class="form-control selectpicker" title="类型" v-model="search.type">
  32. <option value="托盘">托盘</option>
  33. <option value="周转箱">周转箱</option>
  34. </select>
  35. </div>
  36. <div class="form-group m-2">
  37. <select class="form-control selectpicker" title="是否允许混放" v-model="search.allowMixed">
  38. <option value="允许">允许</option>
  39. <option value="不允许">不允许</option>
  40. </select>
  41. </div>
  42. <div class="form-group m-2">
  43. <button class="form-control btn btn-sm btn-info" @click="searchData()">查询</button>
  44. </div>
  45. <td class="form-group m-2">
  46. <div class="btn-group mt-2" role="group">
  47. <button id="btnGroupDrop1" type="button" class="form-control btn btn-sm btn-info dropdown-toggle"
  48. data-toggle="dropdown">
  49. 批量操作
  50. </button>
  51. <div class="dropdown-menu m-2" aria-labelledby="btnGroupDrop1">
  52. <button type="button" class="btn btn-danger" @click="switchContainerStatusBench('停用')">停用
  53. </button>
  54. <button type="button" class="btn btn-success" @click="switchContainerStatusBench('启用')">启用
  55. </button>
  56. </div>
  57. </div>
  58. </td>
  59. </div>
  60. <!-- 导出-->
  61. <span class="dropdown"></span>
  62. <!-- 表格-->
  63. <table class="table table-striped table-bordered table-hover card-body td-min-width-80" id="table">
  64. <tr v-for="(item,i) in details.data" @click="selectTr===i+1?selectTr=0:selectTr=i+1"
  65. :class="selectTr===i+1?'focusing' : ''">
  66. <td>
  67. <input class="checkItem" type="checkbox" v-model="item.checked">
  68. </td>
  69. <td class="td-warm text-muted"><span>@{{ i+1 }}</span></td>
  70. <td class="td-warm text-muted"><span>@{{ item.containerNo }}</span></td>
  71. <td class="td-warm text-muted"><span>@{{ item.type }}</span></td>
  72. <td class="td-warm text-muted"><span>@{{ item.warehouseCode }}</span></td>
  73. <td class="td-warm text-muted"><span>@{{ item.allowMixed }}</span></td>
  74. <td class="td-warm text-muted"><span>@{{ item.volume }}</span></td>
  75. <td class="td-warm text-muted"><span>@{{ item.loadWeight }}</span></td>
  76. <td class="td-warm text-muted"><span>@{{ item.username }}</span></td>
  77. <td class="td-warm text-muted"><span>@{{ item.status }}</span></td>
  78. <td class="td-warm text-muted"><span>
  79. <button v-if="item.status == '启用'" @click="switchContainerStatus(item,'停用')" type="button"
  80. class="btn btn-danger">停用</button>
  81. <button v-if="item.status == '停用'" @click="switchContainerStatus(item,'启用')" type="button"
  82. class="btn btn-success">启用</button>
  83. </span>
  84. </td>
  85. </tr>
  86. </table>
  87. <nav aria-label="...">
  88. <ul class="pagination">
  89. <li class="page-item" :class="current===1?'disabled':''">
  90. <button class="page-link" @click="pagination('pre')">上一页</button>
  91. </li>
  92. <li class="page-item" :class="current===details.pages?'disabled':''">
  93. <button class="page-link" @click="pagination('next')">下一页</button>
  94. </li>
  95. </ul>
  96. </nav>
  97. </div>
  98. @endsection
  99. @section('lastScript')
  100. <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>{{--新版2--}}
  101. <script>
  102. let vue = new Vue({
  103. el: "#list",
  104. data: {
  105. submitData: {
  106. type: null,
  107. warehouseId: null,
  108. allowMixed: null,
  109. volume: null,
  110. loadWeight: null,
  111. createAmount: null,
  112. },
  113. selectData: {
  114. warehouses: {!! $warehouses !!}
  115. },
  116. checkAll: false,
  117. selectTr: 0,
  118. details: {
  119. data: [],
  120. total: null,
  121. current: 1,
  122. pages: null,
  123. size: 50,
  124. },
  125. search: {
  126. type: null,
  127. warehouseId: null,
  128. allowMixed: null,
  129. },
  130. size: 50,
  131. current: 1,
  132. },
  133. created() {
  134. let url = this.getBaseUrl() + `/api/wms/containerManage/list?size=${this.size}&current=${this.current}`;
  135. this.getPageResult(url);
  136. },
  137. mounted: function () {
  138. $('#list').removeClass('d-none');
  139. $(".up").slideUp();
  140. let column = [
  141. {name: 'id', value: '序号'},
  142. {name: 'containerNo', value: '容器号'},
  143. {name: 'type', value: '容器类型'},
  144. {name: 'warehouseCode', value: '所在仓库'},
  145. {name: 'allowMixed', value: '是否允许混放'},
  146. {name: 'volume', value: '容积'},
  147. {name: 'loadWeight', value: '载重'},
  148. {name: 'username', value: '创建人'},
  149. {name: 'status', value: '状态'},
  150. {name: 'action', value: '操作'},
  151. ];
  152. new Header({
  153. el: "table",
  154. name: "details",
  155. column: column,
  156. data: this.details.data,
  157. restorationColumn: 'addtime',
  158. fixedTop: ($('#form_div').height()) + ($('#btn').height()) + 1,
  159. }).init();
  160. },
  161. methods: {
  162. checkAllBtn() {
  163. for (let item of this.details.data) {
  164. item.checked = this.checkAll;
  165. }
  166. },
  167. getPageResult(url) {
  168. tempTip.showSuccess('开始查询,请稍后!');
  169. axios.post(url, this.getSearch()).then(res => {
  170. tempTip.showSuccess('查询成功!');
  171. if (res.data.code !== 200) {
  172. tempTip.show('接口异常!');
  173. this.details.data = [];
  174. this.details.total = 0
  175. this.details.current = 1
  176. this.details.pages = 0
  177. this.details.size = 50;
  178. } else {
  179. this.details.data = res.data.data.list;
  180. this.details.total = res.data.data.page.total;
  181. this.details.current = res.data.data.page.pageNum;
  182. this.details.pages = res.data.data.page.pages
  183. this.details.size = res.data.data.page.pageSize;
  184. }
  185. });
  186. },
  187. getSearch() {
  188. return Object.assign({}, this.search);
  189. },
  190. searchData() {
  191. this.current = 1;
  192. this.pagination();
  193. },
  194. //根据环境获取不同的url
  195. getBaseUrl() {
  196. let url = null;
  197. let env = "{{ config('app.env') }}";
  198. if (env === 'local') {
  199. url = 'http://127.0.0.1:8118'
  200. } else if (env === 'production') {
  201. url = 'https://swms.baoshi56.com'
  202. }
  203. return url;
  204. },
  205. pagination(flag) {
  206. if (flag === 'pre' && this.current > 1) {
  207. this.current--;
  208. } else if (flag === 'next' && this.current < this.details.pages) {
  209. this.current++;
  210. }
  211. let url = this.getBaseUrl() + `/api/wms/containerManage/list?size=${this.size}&current=${this.current}`;
  212. this.getPageResult(url);
  213. },
  214. switchContainerStatus(item, status) {
  215. let url = this.getBaseUrl() + `/api/wms/containerManage/update`;
  216. axios.patch(url, {
  217. id: item.id,
  218. status
  219. }).then(res => {
  220. tempTip.showSuccess('修改状态成功!');
  221. item.status = status;
  222. })
  223. },
  224. switchContainerStatusBench(status) {
  225. let url = this.getBaseUrl() + `/api/wms/containerManage/benchSwitchStatus`;
  226. let filter = this.details.data.filter(i => i.checked === true);
  227. if (filter.length === 0) {
  228. tempTip.show("选中的元素为空");
  229. return;
  230. }
  231. let idList = filter.map(i => i.id);
  232. axios.patch(url, {
  233. idList,
  234. status
  235. }).then(res => {
  236. if (res.data.code !== 200) {
  237. let errors = "";
  238. for (let i in res.data.data) {
  239. errors += i + ': ' + res.data.data[i];
  240. }
  241. tempTip.show(errors);
  242. } else {
  243. tempTip.showSuccess('批量修改状态成功!');
  244. for (let item of filter) {
  245. item.status = status;
  246. }
  247. }
  248. });
  249. }
  250. },
  251. });
  252. </script>
  253. @endsection