statistics.blade.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. @extends('layouts.app')
  2. @section('title')入库管理@endsection
  3. @section('content')
  4. <span id="nav2">
  5. @component('weight.menu')@endcomponent
  6. </span>
  7. <div class="d-none" id="statistics">
  8. <div class="container-fluid">
  9. <div class="">
  10. <form method="GET" action="{{url('package/statistics')}}" id="optionSubmit">
  11. <table class="table table-sm table-bordered text-nowrap mb-0">
  12. <tr v-if="isBeingFilterConditions">
  13. <td colspan="10"><div class="col" style="padding:0">
  14. <a href="{{url('package/statistics')}}"><span class="btn btn-warning text-dark">清除过滤条件</span></a>
  15. </div></td>
  16. </tr>
  17. <tr >
  18. <td rowspan="2" class="" style=" width: 150px">
  19. <div class="d-flex" style="height: 100px;">
  20. <span class="text-muted align-items-center d-flex">根据条件过滤:</span>
  21. </div>
  22. </td>
  23. <td>
  24. <div class="form-inline pl-3" style="height: 100px">
  25. <div class="align-items-center">
  26. <div class="text-right">货主:</div>
  27. <p>
  28. <input type="text" style="width: 100px;opacity: 0.6" class="form-control-sm tooltipTarget" placeholder="定位货主"
  29. @input="owner_seek"
  30. title="输入关键词快速定位下拉列表">
  31. </p>
  32. </div>
  33. <div style="max-height: 90px; overflow-y: scroll;border: solid 1px #ddd;border-radius:5px;opacity:0.5;text-align: center;transform:scale(0.9)" v-if="ownersCopy.length>0">
  34. <ul class="list-group tooltipTarget" id="seek" onselectstart="return false;">
  35. <li title="单击添加货主" v-for="ownerCopy in ownersCopy" :id="ownerCopy.name" class="list-group-item list-group-item-action pt-0 pb-0"
  36. @click="selectedOwner(ownerCopy)" :class="ownerCopy.style ? 'active' :''"><span style="cursor: default;" :id="ownerCopy.name">@{{ ownerCopy.name }}</span></li>
  37. </ul>
  38. <input hidden name="owner_id" :value="selectedOwners">
  39. </div>
  40. </div>
  41. </td>
  42. <td >
  43. <div class="form-inline pl-3" style="height: 100px">
  44. <div class="align-items-center">
  45. <div class="text-right">物流公司:</div>
  46. <p>
  47. <input type="text" style="width: 100px;opacity: 0.6" class="form-control-sm tooltipTarget" placeholder="定位物流公司"
  48. @input="logistic_seek"
  49. title="输入关键词快速定位下拉列表">
  50. </p>
  51. </div>
  52. <div style="max-height: 90px;overflow-y: scroll;border: solid 1px #ddd;border-radius:5px;text-align: center;transform:scale(0.9)" v-if="logisticsAll.length>0">
  53. <ul class="list-group tooltipTarget" onselectstart="return false;">
  54. <li title="单击添加物流公司" v-for="logistic in logisticsAll" class=" list-group-item list-group-item-action pt-0 pb-0"
  55. @click="selectedLogistic(logistic)" :class="logistic.style ? 'active' :''" >
  56. <span style="cursor: default;" :id="logistic.name">@{{ logistic.name }}</span></li>
  57. </ul>
  58. <input hidden name="logistic_id" :value="selectedLogistics">
  59. </div>
  60. </div>
  61. </td>
  62. <td style="position: relative">
  63. <table class="table table-sm table-borderless">
  64. <tr>
  65. <td class="text-right" style="line-height: 60px">
  66. 时间:
  67. </td>
  68. <td>
  69. <div class="form-inline">
  70. <div class="form-group">
  71. <input style="width: 170px;transform:scale(0.8)" type="date" v-model="filterData.date_start" class="form-control" @change="makeFilterDuration">
  72. <input id="hour_input" type="text" class="form-control" placeholder="00:00" @change="makeFilterDuration" autocomplete="off"
  73. @input="hourFilter($event)" v-model="inputtingAdd_start" style="transform:scale(0.8);width: 80px"
  74. @keypress="hourFilter($event)" >
  75. <input v-if="filterData.date_start" hidden name="date_start" :value="filterData.date_start+' '+inputtingAdd_start">
  76. </div>
  77. </div>
  78. <div class="form-inline">
  79. <div class="form-group">
  80. <input style="transform:scale(0.8);width: 170px" type="date" v-model="filterData.date_end" class="form-control" @change="makeFilterDuration">
  81. <input id="hour_input" type="text" class="form-control" placeholder="00:00" @change="makeFilterDuration" autocomplete="off"
  82. @input="hourFilter($event)" v-model="inputtingAdd_end" style="transform:scale(0.8);width:80px"
  83. @keypress="hourFilter($event)" >
  84. <input v-if="filterData.date_end" hidden name="date_end" :value="filterData.date_end+' '+inputtingAdd_end">
  85. </div>
  86. </div>
  87. </td>
  88. </tr>
  89. <tr>
  90. <td class="text-center" colspan="2">
  91. <button class="btn btn-primary btn-sm pl-5 pr-5">提交</button>
  92. </td>
  93. </tr>
  94. </table>
  95. <span class="text-muted"
  96. style="position: absolute; bottom: 48px;left:30px;transform: scale(0.65)" v-if="filterData.date_start || filterData.date_end">
  97. @{{ dateTime }}</span>
  98. </td>
  99. <td>
  100. </td>
  101. </tr>
  102. <tr></tr>
  103. <tr>
  104. <td>
  105. <div>
  106. <span class="text-muted">操作选定记录:</span>
  107. </div>
  108. </td>
  109. <td colspan="3">
  110. <span class="dropdown">
  111. <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" {{--:class="[rejectedBills_checkBoxes.length>0?'btn-dark text-light':'']"--}}
  112. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的过滤结果,将其全部记录(每一页)导出">
  113. 导出Excel
  114. </button>
  115. <div class="dropdown-menu">
  116. <a class="dropdown-item" @click="statisticExport(1)" href="javascript:">导出勾选内容</a>
  117. <a class="dropdown-item" @click="statisticExport(2)" href="javascript:">导出所有页</a>
  118. </div>
  119. </span>
  120. </td>
  121. </tr>
  122. </table>
  123. </form>
  124. <div class="">
  125. <table class="table table-striped table-sm text-nowrap table-hover">
  126. <tr>
  127. <th>
  128. <label for="all">
  129. <input id="all" type="checkbox" @click="checkAll($event)">全选
  130. </label>
  131. </th>
  132. <th>货主</th>
  133. <th>总计</th>
  134. <th v-for="logistic in logisticsAll" v-if="logistics[logistic.id]">@{{ logistic.name }}</th>
  135. </tr>
  136. <tr v-for="ownerModel in ownersModel">
  137. <td>
  138. <input class="checkItem" type="checkbox" :value="ownerModel.id" v-model="checkData">
  139. </td>
  140. <th class="text-muted">@{{ ownerModel.name }}</th>
  141. <td><p v-if="ownerModel.sum">@{{ ownerModel.sum }}</p><p v-else>0</p></td>
  142. <td class="text-muted" v-for="logistic in logisticsAll" v-if="logistics[logistic.id]"><p v-if="ownerModel.logistics[logistic.id]">@{{ ownerModel.logistics[logistic.id] }}</p>
  143. <p v-else>0</p></td>
  144. </tr>
  145. </table>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. @endsection
  151. @section('lastScript')
  152. <script>
  153. new Vue({
  154. el:"#statistics",
  155. data:{
  156. packages:[
  157. @foreach($packages as $package)
  158. {owner_id:'{{$package->owner_id}}',logistic_id:'{{$package->logistic_id}}',count:'{{$package->count}}',
  159. owner_name:'',logistic_name:''},
  160. @endforeach
  161. ],
  162. owners:{
  163. @foreach($owners as $owner)
  164. '{{$owner->id}}' : "{{$owner->name}}",
  165. @endforeach
  166. },
  167. logisticsAll:[
  168. @foreach($logistics as $logistic)
  169. {id:'{{$logistic->id}}', name: '{{$logistic->name}}',style:false},
  170. @endforeach
  171. ],
  172. ownersCopy:[
  173. @foreach($owners as $owner)
  174. {id:'{{$owner->id}}',name:"{{$owner->name}}",style:false},
  175. @endforeach
  176. ],
  177. logistics:[],
  178. ownersModel:[],
  179. filterData:
  180. {date_start:'',date_end:''},
  181. selectedOwners:[],
  182. selectedLogistics:[],
  183. checkData:[],
  184. checkSign:'',
  185. inputtingAdd_start:'',
  186. inputtingAdd_end:'',
  187. dateTime:'',
  188. },
  189. computed:{
  190. isBeingFilterConditions:function(){
  191. for(let key in this.filterData){
  192. if(this.filterData[key]){
  193. return true
  194. }
  195. }
  196. if (this.selectedOwners.length>0||this.selectedLogistics.length>0){
  197. return true;
  198. }
  199. return false;
  200. },
  201. },
  202. watch:{
  203. checkData:{
  204. handler(){
  205. if (this.checkData.length === this.ownersModel.length){
  206. document.querySelector('#all').checked = true;
  207. }else {
  208. document.querySelector('#all').checked = false;
  209. }
  210. },
  211. deep:true
  212. }
  213. },
  214. mounted:function(){
  215. let _this=this;
  216. let owners=this.owners;
  217. this.packages.forEach(function (package){
  218. if (owners[package.owner_id]){
  219. package.owner_name=owners[package.owner_id];
  220. }
  221. let isEvery=true;
  222. if (_this.ownersModel) {
  223. isEvery=_this.ownersModel.every(function (ownerModel) {
  224. if (ownerModel.name==package.owner_name){
  225. ownerModel.logistics[package.logistic_id]=package.count;
  226. ownerModel.sum=parseInt(ownerModel.sum)+parseInt(package.count);
  227. return false;
  228. }
  229. return true;
  230. });
  231. }
  232. if (isEvery){
  233. let obj={};
  234. _this.logisticsAll.every(function (logistic) {
  235. if (logistic.id==package.logistic_id) {
  236. obj[package.logistic_id]=package.count;
  237. return false;
  238. }
  239. return true;
  240. });
  241. _this.ownersModel.push({'id':package.owner_id,'name':package.owner_name,'sum':package.count,'logistics':obj,});
  242. }
  243. });
  244. this.initInputs();
  245. $(".tooltipTarget").tooltip({'trigger':'hover'});
  246. $('#statistics').removeClass('d-none');
  247. this.makeFilterDuration();
  248. },
  249. methods: {
  250. makeFilterDuration(){
  251. let date=new Date();
  252. let thisDate=this.getDate(date);
  253. let startTime=this.inputtingAdd_start;
  254. let endTime=this.inputtingAdd_end;
  255. let endDate=this.filterData.date_end;
  256. let startDate=this.filterData.date_start;
  257. if (this.filterData.date_start && !this.inputtingAdd_start) startTime="00:00";
  258. if (this.filterData.date_end && !this.inputtingAdd_end) endTime="23:59";
  259. if (this.filterData.date_start && !this.filterData.date_end) endDate=thisDate;
  260. if (this.filterData.date_end && !this.filterData.date_start) startDate="2000-01-01 00:00";
  261. this.dateTime="选择区间:"+startDate+" "+startTime+" 至 "+endDate+" "+endTime;
  262. },
  263. getDate(date){
  264. let da=[
  265. date.getFullYear(),
  266. date.getMonth()+1,
  267. date.getDate(),
  268. date.getHours(),
  269. date.getMinutes(),
  270. ]
  271. return da.slice(0,3).join("-")+" "+
  272. da.slice(3).join(":");
  273. },
  274. initInputs:function(){
  275. let data=this;
  276. let uriParts =decodeURI(location.href).split("?");
  277. let isLogistic=true;
  278. if(uriParts.length>1){
  279. let params = uriParts[1].split('&');
  280. params.every(function(paramPair){
  281. let pair=paramPair.split('=');
  282. let key = pair[0], val = pair[1];
  283. $('input[name="'+key+'"]').val(val);
  284. $('select[name="'+key+'"]').val(val);
  285. if (key!='owner_id'||key!='logistic_id') {
  286. decodeURI(data.filterData[key]=val);
  287. }
  288. let str=unescape(val);
  289. let strs=new Array();
  290. strs=str.split(",");
  291. if (key=='owner_id' && val){
  292. for (let i=0;i<strs.length;i++){
  293. data.selectedOwners.push(strs[i]);
  294. data.ownersCopy.every(function (ownerCopy) {
  295. if (strs[i]==ownerCopy.id){
  296. ownerCopy.style=true;
  297. return false;
  298. }
  299. return true;
  300. });
  301. }
  302. }
  303. if (key=='logistic_id' && val){
  304. for (let i=0;i<strs.length;i++){
  305. data.selectedLogistics.push(strs[i]);
  306. data.logisticsAll.every(function (logistic) {
  307. if (strs[i]==logistic.id){
  308. logistic.style=true;
  309. return false;
  310. }
  311. return true;
  312. });
  313. }
  314. {{--URL有参数且有logistic字段 --}}
  315. let logistics=data.selectedLogistics;
  316. if (logistics.length>0){
  317. for (let i=0;i<logistics.length;i++){
  318. data.logisticsAll.every(function (logistic) {
  319. if (logistic.id==logistics[i]){
  320. data.logistics[logistic.id]=logistic.name;
  321. return false;
  322. }
  323. return true;
  324. });
  325. }
  326. }else{
  327. data.logisticsAll.every(function (logistic) {
  328. data.logistics[logistic.id]=logistic.name;
  329. return true;
  330. });
  331. };
  332. isLogistic=false;
  333. }
  334. if (key=='date_start'){
  335. strs=str.split("+");
  336. if (strs.length!=2) return;
  337. data.filterData.date_start=strs[0];
  338. data.inputtingAdd_start=strs[1];
  339. }
  340. if (key=='date_end'){
  341. strs=str.split("+");
  342. if (strs.length!=2) return;
  343. data.filterData.date_end=strs[0];
  344. data.inputtingAdd_end=strs[1];
  345. }
  346. return true;
  347. });
  348. }
  349. {{--URL无参数以packages所存在物流公司为显示标准 --}}
  350. if (uriParts.length<=1 || isLogistic){
  351. data.packages.every(function (package) {
  352. data.logisticsAll.every(function (logistic) {
  353. if (package.logistic_id==logistic.id){
  354. data.logistics[logistic.id]=logistic.name;
  355. return false;
  356. }
  357. return true;
  358. });
  359. return true;
  360. });
  361. }
  362. },
  363. owner_seek:function (e) {
  364. let _this=this;
  365. let $val=e.target.value;
  366. if($val==='')_this.filterData.owner_id='';
  367. else{
  368. @foreach($owners as $owner)
  369. if ("{{ $owner->name }}".includes($val)){
  370. _this.filterData.owner_id="{{ $owner->id }}";
  371. location.href="#{{$owner->name}}";
  372. }
  373. @endforeach
  374. }
  375. $(e.target).focus();
  376. },
  377. logistic_seek:function(e){
  378. let _this=this;
  379. let $val=e.target.value;
  380. if($val){
  381. _this.logisticsAll.every(function (logistic) {
  382. let name=logistic.name;
  383. if (name.includes($val)){
  384. location.href="#"+logistic.name;
  385. return false;
  386. }
  387. return true;
  388. });
  389. }
  390. $(e.target).focus();
  391. },
  392. selectedOwner:function (e) {
  393. let selectedOwners=this.selectedOwners;
  394. let sign = true;
  395. for (let i=0;i<selectedOwners.length;i++){
  396. if (selectedOwners[i]==e.id){
  397. selectedOwners.splice(i,1);
  398. this.ownersCopy.every(function (ownerCopy) {
  399. if (ownerCopy.id==e.id) {
  400. ownerCopy.style=false;
  401. return false;
  402. }
  403. return true;
  404. });
  405. sign=false;
  406. break;
  407. }
  408. }
  409. if (sign) {
  410. this.selectedOwners.push(e.id);
  411. this.ownersCopy.every(function (ownerCopy) {
  412. if (ownerCopy.id==e.id) {
  413. ownerCopy.style=true;
  414. return false;
  415. }
  416. return true;
  417. });
  418. }
  419. },
  420. selectedLogistic:function (e) {
  421. let selectedLogistics=this.selectedLogistics;
  422. let sign = true;
  423. for (let i=0;i<selectedLogistics.length;i++){
  424. if (selectedLogistics[i]==e.id){
  425. selectedLogistics.splice(i,1);
  426. this.logisticsAll.every(function (logistic) {
  427. if (logistic.id==e.id) {
  428. logistic.style=false;
  429. return false;
  430. }
  431. return true;
  432. });
  433. sign=false;
  434. break;
  435. }
  436. }
  437. if (sign) {
  438. this.selectedLogistics.push(e.id);
  439. this.logisticsAll.every(function (logistic) {
  440. if (logistic.id==e.id) {
  441. logistic.style=true;
  442. return false;
  443. }
  444. return true;
  445. });
  446. }
  447. },
  448. checkAll(e){
  449. if (e.target.checked){
  450. this.ownersModel.forEach((el,i)=>{
  451. if (this.checkData.indexOf(el.id) == '-1'){
  452. this.checkData.push(el.id);
  453. }
  454. });
  455. }else {
  456. this.checkData = [];
  457. }
  458. },
  459. statisticExport:function (e) {
  460. if (e==1){
  461. if (this.checkData&&this.checkData.length<=0){
  462. tempTip.setDuration(4000);
  463. tempTip.showSuccess('没有勾选任何记录');
  464. return;
  465. }
  466. location.href="{{url('package/statistics?checkSign=')}}"+this.checkData;
  467. }else{
  468. location.href="{{url('package/statistics?owner_id=')}}"+this.selectedOwners+
  469. "&logistic_id="+this.selectedLogistics+"&date_start="+this.filterData.date_start
  470. +"&date_end="+this.filterData.date_end+"&checkSign=-1";
  471. }
  472. },
  473. hourFilter:function(e){
  474. datetimeRelating.verifyTime(e);
  475. },
  476. }
  477. });
  478. </script>
  479. @endsection