index.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. window.tempTip.show("功能关闭,移至SWMS系统进行操作");
  135. return
  136. let url = this.getBaseUrl() + `/api/wms/containerManage/list?size=${this.size}&current=${this.current}`;
  137. this.getPageResult(url);
  138. },
  139. mounted: function () {
  140. $('#list').removeClass('d-none');
  141. $(".up").slideUp();
  142. let column = [
  143. {name: 'checkbox', value: '',neglect: true},
  144. {name: 'id', value: '序号',neglect: true},
  145. {name: 'containerNo', value: '容器号'},
  146. {name: 'type', value: '容器类型'},
  147. {name: 'warehouseCode', value: '所在仓库'},
  148. {name: 'allowMixed', value: '是否允许混放'},
  149. {name: 'volume', value: '容积'},
  150. {name: 'loadWeight', value: '载重'},
  151. {name: 'username', value: '创建人'},
  152. {name: 'status', value: '状态'},
  153. {name: 'action', value: '操作'},
  154. ];
  155. new Header({
  156. el: "table",
  157. name: "details",
  158. column: column,
  159. data: this.details.data,
  160. restorationColumn: 'addtime',
  161. isCheckAllBox:false,
  162. fixedTop: ($('#form_div').height()) + ($('#btn').height()) + 1,
  163. }).init();
  164. },
  165. methods: {
  166. checkAllBtn() {
  167. for (let item of this.details.data) {
  168. item.checked = this.checkAll;
  169. }
  170. },
  171. getPageResult(url) {
  172. axios.post(url, this.getSearch()).then(res => {
  173. if (res.data.code !== 200) {
  174. tempTip.show('接口异常!');
  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. getSearch() {
  190. return Object.assign({}, this.search);
  191. },
  192. searchData() {
  193. this.current = 1;
  194. this.pagination();
  195. },
  196. //根据环境获取不同的url
  197. getBaseUrl() {
  198. let url = null;
  199. let env = "{{ config('app.env') }}";
  200. if (env === 'local') {
  201. url = 'http://127.0.0.1:8112'
  202. } else if (env === 'production') {
  203. url = 'https://api-back.baoshi56.com'
  204. }
  205. return url;
  206. },
  207. pagination(flag) {
  208. if (flag === 'pre' && this.current > 1) {
  209. this.current--;
  210. } else if (flag === 'next' && this.current < this.details.pages) {
  211. this.current++;
  212. }
  213. let url = this.getBaseUrl() + `/api/wms/containerManage/list?size=${this.size}&current=${this.current}`;
  214. this.getPageResult(url);
  215. },
  216. switchContainerStatus(item, status) {
  217. let url = this.getBaseUrl() + `/api/wms/containerManage/update`;
  218. axios.patch(url, {
  219. id: item.id,
  220. status
  221. }).then(res => {
  222. tempTip.showSuccess('修改状态成功!');
  223. item.status = status;
  224. })
  225. },
  226. switchContainerStatusBench(status) {
  227. let url = this.getBaseUrl() + `/api/wms/containerManage/benchSwitchStatus`;
  228. let filter = this.details.data.filter(i => i.checked === true);
  229. if (filter.length === 0) {
  230. tempTip.show("选中的元素为空");
  231. return;
  232. }
  233. let idList = filter.map(i => i.id);
  234. axios.patch(url, {
  235. idList,
  236. status
  237. }).then(res => {
  238. if (res.data.code !== 200) {
  239. let errors = "";
  240. for (let i in res.data.data) {
  241. errors += i + ': ' + res.data.data[i];
  242. }
  243. tempTip.show(errors);
  244. } else {
  245. tempTip.showSuccess('批量修改状态成功!');
  246. for (let item of filter) {
  247. item.status = status;
  248. }
  249. }
  250. });
  251. }
  252. },
  253. });
  254. </script>
  255. @endsection