index.blade.php 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. @extends('layouts.app')
  2. @section('title')查询-运输管理@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('waybill.menu')
  6. @endcomponent
  7. </div>
  8. <div class="container-fluid" style="min-width: 1500px;">
  9. <div class="d-none" id="list">
  10. @include("waybill._batchUploadImg")
  11. <div class="container-fluid nav3">
  12. <div class="card menu-third" >
  13. <ul class="nav nav-pills">
  14. @can('运输管理-查询')
  15. <li class="nav-item">
  16. <a class="nav-link @if($uriType=='') active @endif" href="{{url('waybill/index')}}">全部</a>
  17. </li> @endcan
  18. @can('运输管理-查询')
  19. <li class="nav-item">
  20. <a class="nav-link @if($uriType=='专线') active @endif" href="{{url('waybill/index?uriType=专线')}}">专线</a>
  21. </li> @endcan
  22. @can('运输管理-查询')
  23. <li class="nav-item">
  24. <a class="nav-link @if($uriType=='直发车') active @endif" href="{{url('waybill/index?uriType=直发车')}}">直发车</a>
  25. </li> @endcan
  26. </ul>
  27. </div>
  28. </div>
  29. <div id="form_div"></div>
  30. <span class="dropdown">
  31. <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
  32. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
  33. 导出Excel
  34. </button>
  35. <div class="dropdown-menu">
  36. <a class="dropdown-item" @click="waybillExport(false)" href="javascript:">导出勾选内容</a>
  37. <a class="dropdown-item" @click="waybillExport(true)" href="javascript:">导出所有页</a>
  38. </div>
  39. </span>
  40. @can('运输管理-图片上传')<button class="btn btn-sm btn-outline-info" data-target="#batchUploadImg" data-toggle="modal">批量上传图片</button>@endcan
  41. <div>
  42. @if(Session::has('successTip'))
  43. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  44. @endif
  45. </div>
  46. <label for="all" class="d-none" id="cloneCheckAll">
  47. <input id="all" type="checkbox" @click="checkAll($event)">全选
  48. </label>
  49. <table class="table table-striped table-sm table-bordered table-hover text-nowrap d-none" id="headerRoll"></table>
  50. <table class="table table-striped table-sm table-bordered table-hover text-nowrap waybill-table" style="background: #fff;" id="headerParent">
  51. <tr>
  52. <th class="table-header-layer-1" colspan="4"></th>
  53. <th class="table-header-layer-1" colspan="11"><span class="fa fa-file-text-o"></span> 运单信息</th>
  54. <th class="table-header-layer-1" colspan="16"><span class="fa fa-truck"></span> 运输信息</th>
  55. <th class="table-header-layer-1" colspan="5"><span class="fa fa-rmb"></span> 费用信息
  56. @can('运输管理-删除')
  57. <th class="table-header-layer-1" colspan="1"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
  58. @endcan
  59. </tr>
  60. <tr id="header"></tr>
  61. <tr v-for="(waybill,i) in waybills" :style="[{color:waybill.status=='待重审'?'red':''||waybill.status=='已完结'?'green':''},{'font-weight': waybill.id==selectedStyle?'bold':''}]"
  62. :id="'waybill'+waybill.id" @click="selectedColor(waybill.id)" position="static" @mouseover="hidetop($event)" @mouseleave="showtop($event)">
  63. <td>
  64. <input class="checkItem" type="checkbox" :value="waybill.id" v-model="checkData">
  65. </td>
  66. <td>
  67. <span v-if=waybill.status==="未审核"||waybill.status==="待重审">
  68. @can('运输管理-运单审核')
  69. <button class="btn btn-outline-primary btn-sm" @click="waybillAudit(waybill.id,waybill.waybill_number)">审核</button>
  70. @endcan
  71. @can('运输管理-编辑')
  72. <a target="_blank" class="btn btn-outline-secondary btn-sm" :href= "('{{url('waybill/waybillEdit')}}/'+waybill.id)">修改</a>
  73. @endcan
  74. </span>
  75. <span v-if=waybill.status==="已审核">
  76. @can('运输管理-调度')
  77. <button class="btn btn-outline-secondary btn-sm" @click="waybillRetreatAudit(waybill.id,waybill.waybill_number)">取消审核</button>
  78. <a target="_blank" class="btn btn-outline-secondary btn-sm" :href= "('{{url('waybill')}}/'+waybill.id+'/edit')">调度</a>
  79. @endcan
  80. </span>
  81. <span v-if=waybill.status==="待终审">
  82. @can('运输管理-调度审核')
  83. <button class="btn btn-outline-success btn-sm" @click="waybillEndAudit(waybill.id,waybill.waybill_number)">完结</button>
  84. @endcan
  85. @can('运输管理-调度')
  86. <a target="_blank" class="btn btn-outline-secondary btn-sm" :href= "('{{url('waybill')}}/'+waybill.id+'/edit')">改调度</a>
  87. @endcan
  88. </span>
  89. </td>
  90. @can('运输管理-置顶')
  91. <td class="td-warm text-muted" v-if="waybill.remark" style="height: 55px">
  92. <button type="button" class="btn btn-sm btn-outline-danger " @click="cancelOnTop($event)" :data_id="waybill.id" style="opacity: 0.75">取消</button>
  93. </td>
  94. <td v-else>
  95. <button type="button" class="btn btn-sm btn-outline-secondary" @click="waybillOnTop($event)" :data_id="waybill.id" style="opacity: 0.75">置顶</button>
  96. </td>
  97. @endcan
  98. <td :class="[waybill.status=='已审核'?'text-success':'']">@{{waybill.status}}</td>
  99. <td class="td-warm text-muted toptd" >
  100. <div v-if="waybill.remark" class="bg-light-yellow text-danger top" data-toggle="tooltip" style="opacity: 0.1;position: absolute;z-index: 1"
  101. >置顶备注:@{{ waybill.remark }}</div>
  102. @{{ i+1 }}</td>
  103. <td class="td-warm text-muted">@{{waybill.created_at}}</td>
  104. <td class="td-warm">@{{waybill.type}} <span class="badge badge-sm bg-warning" v-if="waybill.collect_fee">到付</span></td>
  105. <td class="td-warm">@{{waybill.owner}}</td>
  106. <td class="td-warm toptd" :title="waybill.remark? '置顶备注:'+waybill.remark :''">@{{waybill.source_bill}}</td>
  107. <td class="td-warm">
  108. <span class="badge badge-pill badge-danger" v-if="waybill.is_cancel">取消</span>
  109. @{{waybill.wms_bill_number}}
  110. </td>
  111. <td class="td-warm">@{{waybill.waybill_number}}</td>
  112. @can('运输管理-运单编辑')
  113. <td class="td-warm" >
  114. <span v-if="waybill.charge" class="btn-sm btn-outline-secondary btn" @click="waybillChargeCheck($event)" :data_id="waybill.id">@{{waybill.charge|money}}</span>
  115. <input v-else type="number" class="form-control form-control-sm" @blur="addWaybillCharge($event)" onfocus="$(this).css('width','85px')" :value="waybill.charge" :data_id="waybill.id" >
  116. <input type="number" class="form-control form-control-sm" @blur="updateWaybillCharge($event)" :value="waybill.charge" :data_id="waybill.id" style="min-width:85px;display: none">
  117. </td>
  118. @else
  119. <td class="td-warm" ><span v-if="waybill.charge">@{{waybill.charge|money}}</span></td>
  120. @endcan
  121. <td class="td-warm">@{{waybill.other_charge}}</td>
  122. <td class="td-warm">@{{waybill.other_charge_remark}}</td>
  123. <td class="td-warm">
  124. <div align="center" @mouseleave="removeCommonImg('common_img_'+waybill.id)" @mouseenter="commonImg('img_'+waybill.id,waybill.url,waybill.suffix)">
  125. <img v-if="waybill.url" :id="'img_'+waybill.id" :src="waybill.url+'-thumbnail.'+waybill.suffix"
  126. {{--:data-src="waybill.url+'-thumbnail.'+waybill.suffix" src="{{url('icon/img404-thumbnail.jpg')}}"--}}>
  127. @can('运输管理-图片上传')<div v-if="!waybill.url">
  128. <input class="btn btn-sm btn-outline-secondary" type="button" @click="certiimg(waybill.waybill_number)" value="上传照片 "/>
  129. <input type="file" @change="submitFile($event,waybill.waybill_number)" :id="waybill.waybill_number"
  130. style="display: none" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg"/>
  131. </div>@endcan
  132. </div>
  133. </td>
  134. <td class="td-cool">@{{waybill.recipient}}</td>
  135. <td class="td-cool">@{{waybill.recipient_mobile}}</td>
  136. <td class="td-cool text-muted">@{{waybill.origination}}</td>
  137. <td class="td-cool text-muted">@{{waybill.province}}</td>
  138. <td class="td-cool text-muted">@{{waybill.city}}</td>
  139. <td class="td-cool text-muted">@{{waybill.district}}</td>
  140. <td class="td-cool text-muted">@{{waybill.destination}}</td>
  141. <td class="td-cool">@{{waybill.carrier}}</td>
  142. <td class="td-cool">
  143. <span v-if="waybill.carrier_bill">
  144. @{{waybill.carrier_bill}}<span v-if="waybill.carType">/@{{ waybill.carType.name }}<i v-if="waybill.carType.length">(@{{waybill.carType.length}}米)</i></span>
  145. </span>
  146. {{-- <span v-if="waybill.type==='专线'">@{{waybill.carrier_bill}}</span>--}}
  147. {{-- <span v-if="waybill.type==='直发车'">--}}
  148. {{-- <span v-if="waybill.carType">--}}
  149. {{-- @{{ waybill.carType.name }}<i v-if="waybill.carType.length">(@{{waybill.carType.length}}米)</i>--}}
  150. {{-- </span>--}}
  151. {{-- </span>--}}
  152. </td>
  153. <td class="td-cool">
  154. <span v-if="waybill.type === '直发车'">
  155. @{{ waybill.car_owner_info }}
  156. </span>
  157. </td>
  158. <td class="td-cool"><span v-if="waybill.warehouse_weight">@{{waybill.warehouse_weight|filterZero}} @{{waybill.warehouse_weight_unit}}</span></td>
  159. <td class="td-cool"><span v-if="waybill.carrier_weight">@{{waybill.carrier_weight|filterZero}} @{{waybill.carrier_weight_unit}}</span></td>
  160. <td class="td-cool text-center" style="position: relative" @mouseenter="btnRefreshWeightZoomOut(waybill)" @mouseleave="btnRefreshWeightZoomIn(waybill)">
  161. <span v-if="waybill.warehouse_weight_other&&waybill.btn_refresh_weight=='zoomIn'"> @{{waybill.warehouse_weight_other}} @{{waybill.warehouse_weight_unit_other}}</span>
  162. <button type="button" class="btn btn-sm btn-outline-info" @click="refreshWaveHouseWeight(waybill.wms_bill_number)"
  163. :style="[
  164. {position:waybill.btn_refresh_weight&&waybill.btn_refresh_weight=='zoomIn'?'absolute':'static'},
  165. {transform:waybill.btn_refresh_weight&&waybill.btn_refresh_weight=='zoomIn'?'scale(0.55)':'scale(1)'},
  166. {right:waybill.btn_refresh_weight&&waybill.btn_refresh_weight=='zoomIn'?'-10px':'auto'},
  167. {bottom:waybill.btn_refresh_weight&&waybill.btn_refresh_weight=='zoomIn'?'-6px':'auto'},
  168. ]">刷新</button>
  169. </td>
  170. <td class="td-cool"><span v-if="waybill.carrier_weight_other">@{{waybill.carrier_weight_other|filterZero}} @{{waybill.carrier_weight_unit_other}}</span></td>
  171. <td class="td-cool"><span v-if="waybill.amount">@{{waybill.amount}} @{{waybill.amount_unit_name }}</span></td>
  172. <td class="td-cool">@{{waybill.mileage|km}} </td>
  173. @can('运输管理-可见费用项')
  174. @can('运输管理-运费')
  175. <td class="td-helpful" v-if="waybill.fee">
  176. <span v-if="waybill.type==='专线'"></span>
  177. <span v-else-if="waybill.fee" class="btn-sm btn-outline-secondary btn" @click="waybillFeeCheck($event)" :data_id="waybill.id">@{{waybill.fee|money}}</span>
  178. <input type="number" class="form-control form-control-sm" @blur="updateWaybillFee($event)" :value="waybill.fee" :data_id="waybill.id" style="min-width:85px;display: none">
  179. </td>
  180. <td class="td-helpful" v-else>
  181. <span v-if="waybill.type==='专线'"></span>
  182. <input v-else type="number" class="form-control form-control-sm" @blur="addWaybillFee($event)" onfocus="$(this).css('width','85px')" :value="waybill.fee" :data_id="waybill.id" >
  183. </td>
  184. @endcan
  185. <td class="td-helpful">@{{waybill.pick_up_fee}}</td>
  186. <td class="td-helpful">@{{waybill.other_fee}}</td>
  187. @endcan
  188. <td class="td-helpful">@{{waybill.deliver_at}}</td>
  189. <td class="td-helpful"><span v-html="waybill.dispatch_remark"></span></td>
  190. @can('运输管理-删除')
  191. <td class="td-operation">
  192. <button type="button" class="btn btn-outline-danger btn-sm" @click="waybillDestroy(waybill.id,waybill.waybill_number,i)">删</button>
  193. </td>
  194. @endcan
  195. </tr>
  196. </table>
  197. <div class="modal fade " id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  198. <div class="modal-dialog modal-dialog-centered">
  199. <div class="modal-content">
  200. <div class="modal-header">
  201. <h5 class="modal-title" id="exampleModalLabel">请输入置顶备注</h5>
  202. <button type="button" class="close" data-dismiss="modal" aria-label="Close" @click="changeRemark">
  203. <span aria-hidden="true">&times;</span>
  204. </button>
  205. </div>
  206. <div class="modal-body">
  207. <input type="hidden" class="form-control" id="onTopId">
  208. <textarea type="text" class="form-control" required id="remark" @change="changeRemark" ></textarea>
  209. <div class="invalid-feedback">
  210. 备注信息不能为空
  211. </div>
  212. </div>
  213. <div class="modal-footer">
  214. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal" @click="changeRemark" >关闭</button>
  215. <button type="button" class="btn btn-sm btn-primary" @click="submitOnTop">提交</button>
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. <div class="text-info h5 btn btn">@{{ ((page-1)*paginate) + count }}/{{$waybills->total()}}</div>
  221. {{$waybills->appends($paginateParams)->links()}}
  222. </div>
  223. </div>
  224. @endsection
  225. @section('lastScript')
  226. <style type="text/css">
  227. @keyframes anima
  228. {
  229. from {
  230. opacity:0.1;
  231. }
  232. to{
  233. opacity:1;
  234. }
  235. }
  236. @-webkit-keyframes anima
  237. {
  238. from {
  239. opacity:0.75;
  240. }
  241. to{
  242. opacity:0.1;
  243. }
  244. }
  245. .bg-light-yellow{
  246. background: #fffff8;
  247. }
  248. .top{
  249. padding-top: 0px;
  250. padding-left: 10px;
  251. margin-top: -4px;
  252. margin-left: -5px;
  253. line-height: 55px;
  254. position: absolute;
  255. animation: anima;
  256. animation-duration: 3s;
  257. animation-timing-function: cubic-bezier(0,0,1,1);
  258. animation-direction: alternate;
  259. animation-play-state: running;
  260. -webkit-animation-name: anima;
  261. -webkit-animation-duration: 3s;
  262. -webkit-animation-timing-function: cubic-bezier(0,0,1,1);
  263. -webkit-animation-iteration-count: infinite;
  264. -webkit-animation-direction: alternate;
  265. -webkit-animation-play-state: running;
  266. }
  267. </style>
  268. <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
  269. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  270. <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>
  271. <script>
  272. let vue = new Vue({
  273. el:'#list',
  274. data:{
  275. waybills:[
  276. @foreach($waybills as $waybill)
  277. {
  278. id:'{{$waybill->id}}',
  279. created_at:'{{$waybill->created_at}}',
  280. updated_at:'{{$waybill->updated_at}}',
  281. url:'{{$waybill->uploadFile ? asset('/storage'.$waybill->uploadFile->url) : ''}}',
  282. suffix:'{{$waybill->uploadFile ? $waybill->uploadFile->type : ''}}',
  283. status:'{{$waybill->status}}',
  284. type:'{{$waybill->type}}',
  285. waybill_number:'{{$waybill->waybill_number}}',
  286. owner:'{{$waybill->owner_name ?? ($waybill->owner->name ?? '')}}',
  287. source_bill:'{{$waybill->source_bill}}',
  288. wms_bill_number:'{{$waybill->wms_bill_number}}',
  289. is_cancel:'{{$waybill->order->wms_status ?? ''}}' === '订单取消',
  290. origination:'{{$waybill->origination}}',
  291. destination:'{{$waybill->order_address ?? $waybill->destination}}',
  292. recipient:'{{$waybill->order_consignee_name ?? $waybill->recipient}}',
  293. recipient_mobile:'{{$waybill->order_consignee_phone ?? $waybill->recipient_mobile}}',
  294. charge:'{{$waybill->charge}}',
  295. ordering_remark:'{{preg_replace("/[\n\s]/",' ',($waybill->ordering_remark??""))}}',
  296. carrier:'{{$waybill->logistic->name ?? ''}}',
  297. carrier_bill:'{{$waybill->carrier_bill}}',
  298. warehouse_weight:'{{$waybill->warehouse_weight}}',
  299. warehouse_weight_unit:'{{$waybill->warehouse_weight_unit ? $waybill->warehouse_weight_unit->name : ''}}',
  300. carrier_weight:'{{$waybill->carrier_weight}}',
  301. carrier_weight_unit:'{{$waybill->carrier_weight_unit ? $waybill->carrier_weight_unit->name : ''}}',
  302. warehouse_weight_other:'{{$waybill->warehouse_weight_other}}',
  303. warehouse_weight_unit_other:'{{$waybill->warehouse_weight_unit_other ? $waybill->warehouse_weight_unit_other->name : ''}}',
  304. carrier_weight_other:'{{$waybill->carrier_weight_other}}',
  305. carrier_weight_unit_other:'{{$waybill->carrier_weight_unit_other ? $waybill->carrier_weight_unit_other->name : ''}}',
  306. amount_unit_name:'{{$waybill->amount_unit ? $waybill->amount_unit->name : ''}}',
  307. other_charge:'{{$waybill->other_charge}}',
  308. other_charge_remark:'{{$waybill->other_charge_remark}}',
  309. mileage:'{{$waybill->mileage}}',
  310. amount:'{{$waybill->amount}}',
  311. @if($waybill->carType)carType:{!! $waybill->carType !!},car_owner_info:'{{$waybill->car_owner_info}}',@endif
  312. @can('运输管理-可见费用项') fee:'{{$waybill->fee}}',
  313. pick_up_fee:'{{$waybill->pick_up_fee}}',other_fee:'{{$waybill->other_fee}}',
  314. collect_fee:'{{$waybill->collect_fee}}', @endcan
  315. deliver_at:'{{$waybill->deliver_at}}',
  316. dispatch_remark:'{{$waybill->dispatch_remark}}',
  317. isBtn:false,
  318. waybillAuditLogs:{!! $waybill->waybillAuditLogs !!},
  319. btn_refresh_weight:'zoomIn',
  320. remark:'{{$waybill->remark ?? ''}}',
  321. province:'{{$waybill->order_province ?? ($waybill->destinationCity->parent->name ?? '')}}',
  322. city:'{{$waybill->order_city ?? ($waybill->destinationCity->name ?? '')}}',
  323. district:'{{$waybill->order_district ?? ($waybill->district->name ?? '')}}',
  324. },
  325. @endforeach
  326. ],
  327. checkData:[],
  328. selectedStyle:[],
  329. owners:[
  330. @foreach($owners as $owner)
  331. {name:'{{$owner->id}}',value:'{{$owner->name}}'},
  332. @endforeach
  333. ],
  334. logistics:[
  335. @foreach($logistics as $logistic)
  336. {name:"{{$logistic->id}}",value:'{{$logistic->name}}'},
  337. @endforeach
  338. ],
  339. status:[
  340. {name:'未审核',value:'未审核'},
  341. {name:'已审核',value:'已审核'},
  342. {name:'待调度',value:'待调度'},
  343. {name:'待终审',value:'待终审'},
  344. {name:'已完结',value:'已完结'},
  345. ],
  346. isOut:false,
  347. isBlur:false,
  348. isOwnersBtn:false,
  349. imgs:'',
  350. is_ownerSelectShow:true,
  351. sum:{!! $waybills->total() !!},
  352. paginate : 50,
  353. page : Number('{{$waybills->currentPage()}}'),
  354. count : Number('{{$waybills->count()}}'),
  355. images:[],
  356. batchUploadError:[],
  357. size:0,
  358. },
  359. watch:{
  360. checkData:{
  361. handler(){
  362. if (this.checkData.length === this.waybills.length){
  363. document.querySelector('#all').checked = true;
  364. document.querySelector('#all_temp').checked = true;
  365. }else {
  366. document.querySelector('#all').checked = false;
  367. document.querySelector('#all_temp').checked = false;
  368. }
  369. },
  370. deep:true
  371. },
  372. },
  373. mounted:function(){
  374. $(".tooltipTarget").tooltip({'trigger':'hover'});
  375. $('#list').removeClass('d-none');
  376. let waybill = $('.table-header-layer-1')[1];
  377. $('.top').css('min-width', waybill.scrollWidth);
  378. /*this.imgs=Array.from(document.getElementById('list').querySelectorAll('img'));
  379. this.lazy();
  380. if (this.imgs&&this.imgs.length>0){
  381. window.addEventListener('scroll',this.lazy)
  382. }*/
  383. let data=[
  384. [
  385. {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
  386. placeholder:['货主','定位或多选货主'],data:this.owners},
  387. {name:'created_at_start',type:'time',tip:['选择显示指定日期的起始时间','选择显示指定日期的起始时间']},
  388. {name:'origination',type:'input',tip:'始发地:可在左侧增加百分号(%)进行模糊搜索',placeholder: '始发地'},
  389. {name:'carrier_bill',type:'input',tip:'承运商单号:可在左侧增加百分号(%)进行模糊搜索',placeholder: '承运商单号'},
  390. {name:'status',type:'select',placeholder: '运单状态',data:this.status},
  391. {name:'source_bill',type:'input',tip: '上游单号:可在左侧增加百分号(%)进行模糊搜索',placeholder: '上游单号'},
  392. {name:'recipient',type:'input',tip: '收货人姓名:可在左侧增加百分号(%)进行模糊搜索',placeholder: '收货人姓名'},
  393. {name:'car_owner_info',type:'input',tip: '车辆信息:可在左侧增加百分号(%)进行模糊搜索',placeholder: '车辆信息'},
  394. ],
  395. [
  396. {name:'wms_bill_number',type:'input',tip:'WMS单号:可在两侧增加百分号(%)进行模糊搜索',placeholder: 'WMS单号'},
  397. {name:'created_at_end',type:'time',tip:['选择显示指定日期的结束时间','选择显示指定日期的结束时间']},
  398. {name:'destination',type:'input',tip:'目的地:可在两侧增加百分号(%)进行模糊搜索',placeholder: '目的地'},
  399. {name:'waybill_number',type:'input',tip:'运单号:可在两侧增加百分号(%)进行模糊搜索',placeholder: '运单号'},
  400. {name:'logistic_id',type:'select',placeholder: '承运商',data:this.logistics},
  401. {name:'recipient_mobile',type:'input',tip: '收货人电话:可在左侧增加百分号(%)进行模糊搜索',placeholder: '收货人电话'},
  402. ],
  403. ];
  404. let param=[];
  405. this.$set(param,"uriType",'{{$uriType}}');
  406. this.form = new query({
  407. el:"#form_div",
  408. condition:data,
  409. param:param,
  410. });
  411. this.form.init();
  412. let column = [
  413. {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
  414. dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
  415. @can('运输管理-编辑','运输管理-运单审核','运输管理-调度','运输管理-编辑')
  416. {name:'operation',value: '操作', neglect: true, class:"td-operation"},@endcan
  417. {name:'onTop',value: '置顶', neglect: true, class:"td-operation"},
  418. {name:'status',value: '状态', class:"td-operation"},
  419. {name:'index',value: '序号', neglect: true, class:"td-warm"},
  420. {name:'created_at',value: '创建时间', class:"td-warm"},
  421. {name:'type',value: '运单类型', class:"td-warm"},
  422. {name:'owner',value: '货主', class:"td-warm"},
  423. {name:'source_bill',value: '上游单号', class:"td-warm"},
  424. {name:'wms_bill_number',value: 'WMS订单号', class:"td-warm"},
  425. {name:'waybill_number',value: '运单号', class:"td-warm"},
  426. {name:'charge',value: '运输收费', neglect: true, class:"td-warm"},
  427. {name:'other_charge',value: '其他收费', neglect: true, class:"td-warm"},
  428. {name:'other_charge_remark',value: '其他收费备注', class:"td-warm"},
  429. @can('运输管理-图片上传'){name:'img',value: '照片', neglect: true, class:"td-warm"},@endcan
  430. {name:'recipient',value: '收件人', class:"td-cool"},
  431. {name:'recipient_mobile',value: '收件人电话', class:"td-cool"},
  432. {name:'origination',value: '始发地', class:"td-cool"},
  433. {name:'province',value: '省', class:"td-cool"},
  434. {name:'city',value: '市', class:"td-cool"},
  435. {name:'district',value: '区', class:"td-cool"},
  436. {name:'destination',value: '目的地', class:"td-cool"},
  437. {name:'carrier',value: '承运商', class:"td-cool"},
  438. {name:'carrier_bill',value: '单号/车型', neglect: true, class:"td-cool"},
  439. {name:'car_owner_info',value: '车辆信息', neglect: true, class:"td-cool"}, // 车辆信息
  440. {name:'warehouse_weight',value: '仓库计抛', neglect: true, class:"td-cool"},
  441. {name:'carrier_weight',value: '承运商计抛', neglect: true, class:"td-cool"},
  442. {name:'warehouse_weight_other',value: '仓库计重', neglect: true, class:"td-cool"},
  443. {name:'carrier_weight_other',value: '承运商计重', neglect: true, class:"td-cool"},
  444. {name:'amount',value: '计件', neglect: true, class:"td-cool"},
  445. {name:'mileage',value: '里程', neglect: true, class:"td-cool"},
  446. @can('运输管理-运费'){name:'fee',value: '运费', neglect: true, class:"td-helpful"},@endcan
  447. {name:'pick_up_fee',value: '提货费', neglect: true, class:"td-helpful"},
  448. {name:'other_fee',value: '其他支出', neglect: true, class:"td-helpful"},
  449. {name:'deliver_at',value: '发货时间', class:"td-helpful"},
  450. {name:'dispatch_remark',value: '调度备注', class:"td-helpful"},
  451. @can('运输管理-删除'){name:'remove',value: '操作', neglect: true, class:"td-delete"},@endcan
  452. ];
  453. let _this = this;
  454. setTimeout(function () {
  455. let header = new Header({
  456. el: "#header",
  457. column: column,
  458. data: _this.waybills,
  459. restorationColumn: 'id',
  460. fixedTop:($('#form_div').height())+2,
  461. offset:0.5,
  462. vue : vue,
  463. });
  464. header.init();
  465. },0);
  466. this.paginate = $("#paginate").val();
  467. },
  468. methods:{
  469. btnRefreshWeightZoomIn(waybill){
  470. waybill.btn_refresh_weight='zoomIn'
  471. },
  472. btnRefreshWeightZoomOut(waybill){
  473. waybill.btn_refresh_weight='zoomOut'
  474. },
  475. /*lazy(){
  476. //高度
  477. let h=(window.innerWidth)+(document.documentElement.scrollTop || document.body.scrollTop);
  478. this.imgs.forEach((img,i)=>{
  479. let src = img.getAttribute('data-src');
  480. if ((h>this.getElementToPageTop(img)-500) && src){
  481. let t = new Image();
  482. t.src = src;
  483. if (t.complete) {
  484. img.src = src;
  485. this.$delete(this.imgs,i);
  486. return;
  487. }
  488. t.onload = ()=>{
  489. img.src = src;
  490. this.$delete(this.imgs,i);
  491. };
  492. }
  493. });
  494. },
  495. getElementToPageTop(el) {
  496. if(el.parentElement) {
  497. return this.getElementToPageTop(el.parentElement) + el.offsetTop
  498. }
  499. return el.offsetTop
  500. },*/
  501. waybillAudit(id,waybill_number){
  502. if(!confirm('确定要通过“'+waybill_number+'”的审核吗?')){return};
  503. let _this=this;
  504. let w;
  505. let url = '{{url('waybill/waybillAudit')}}';
  506. axios.post(url, {id:id})
  507. .then(
  508. function (response) {
  509. if (response.data.success){
  510. _this.waybills.forEach(function (waybill) {
  511. if (waybill.id===id){
  512. waybill.status=response.data.status;
  513. waybill.waybillAuditLogs.push(response.data.waybillAuditLog);
  514. w=waybill.waybill_number;
  515. }
  516. });
  517. tempTip.setDuration(3000);
  518. tempTip.showSuccess('审核'+w+'成功!');
  519. }else if (response.data.exception!=null){
  520. tempTip.setDuration(3000);
  521. tempTip.show(response.data.exception);
  522. }else {
  523. tempTip.setDuration(3000);
  524. tempTip.show('审核失败!');
  525. }
  526. }
  527. ).catch(function (err) {
  528. tempTip.setDuration(3000);
  529. tempTip.show('审核失败,网络连接错误!'+err);
  530. });
  531. },
  532. waybillDestroy(id,waybill_number,index){
  533. if(!confirm('确定要删除运单号为:“'+waybill_number+'”的运单吗?')){return};
  534. let url = '{{url('waybill')}}/'+id;
  535. let _this = this;
  536. axios.delete(url).then(
  537. function (response) {
  538. if(!response.data.success){
  539. tempTip.setDuration(3000);
  540. tempTip.show('运单:'+waybill_number+'删除失败!');
  541. }else {
  542. tempTip.setDuration(2000);
  543. tempTip.showSuccess('运单:'+waybill_number+'删除成功!');
  544. _this.$delete(_this.waybills,index);
  545. }
  546. }
  547. ).catch(function (err) {
  548. tempTip.setDuration(3000);
  549. tempTip.show('删除失败,网络链接错误!'+err);
  550. });
  551. },
  552. waybillRetreatAudit(id,waybill_number){
  553. if(!confirm('确定要驳回“'+waybill_number+'”的审核吗?')){return};
  554. let _this=this;
  555. let w;
  556. let url='{{url('files')}}';
  557. axios.post(url,{id:id})
  558. .then(
  559. function (response) {
  560. if (response.data.success){
  561. _this.waybills.forEach(function (waybill){
  562. if (waybill.id===id){
  563. waybill.status=response.data.status;
  564. waybill.waybillAuditLogs=[];
  565. w=waybill.waybill_number;
  566. }
  567. });
  568. tempTip.setDuration(3000);
  569. tempTip.showSuccess(w+'审核驳回成功!');
  570. }else {
  571. tempTip.setDuration(3000);
  572. tempTip.show('审核驳回失败!');
  573. }
  574. }
  575. ).catch(function (err) {
  576. tempTip.setDuration(3000);
  577. tempTip.show('审核驳回失败,网络连接错误!'+err);
  578. });
  579. },
  580. waybillEndAudit(id,waybill_number){
  581. if(!confirm('确定要通过“'+waybill_number+'”的终审吗?')){return};
  582. let _this=this;
  583. let w;
  584. let url='{{url('waybill/waybillEndAudit')}}';
  585. axios.post(url, {id:id})
  586. .then(
  587. function (response) {
  588. if (response.data.success){
  589. _this.waybills.forEach(function (s) {
  590. if (s.id===id){
  591. s.status=response.data.status;
  592. s.waybillAuditLogs.push(response.data.waybillAuditLog);
  593. w=s.waybill_number;
  594. }
  595. });
  596. tempTip.setDuration(3000);
  597. tempTip.showSuccess(w+'终审完毕!');
  598. }else if (response.data.exception!=null){
  599. tempTip.setDuration(3000);
  600. tempTip.show(response.data.exception);
  601. }else {
  602. tempTip.setDuration(3000);
  603. tempTip.show('终审失败!');
  604. }
  605. }
  606. ).catch(function (err) {
  607. tempTip.setDuration(3000);
  608. tempTip.show('终审失败,网络连接错误!'+err);
  609. });
  610. },
  611. checkAll(e){
  612. if (e.target.checked){
  613. this.waybills.forEach((el,i)=>{
  614. if (this.checkData.indexOf(el.id) == '-1'){
  615. this.checkData.push(el.id);
  616. }
  617. });
  618. }else {
  619. this.checkData = [];
  620. }
  621. },
  622. waybillExport(checkAllSign){
  623. let url = '{{url('waybill/export')}}';
  624. let token='{{ csrf_token() }}';
  625. excelExport(checkAllSign,this.checkData,url,this.sum,token);
  626. },
  627. selectedColor(id){
  628. if (id==this.selectedStyle){
  629. this.selectedStyle='';
  630. return;
  631. }
  632. this.selectedStyle=id;
  633. },
  634. mouseleaveOwner:function () {
  635. if(!this.isOut&&!this.isBlur){
  636. this.isOwnersBtn=false;
  637. }
  638. },
  639. blurOwner:function () {
  640. if (!this.isOut&&!this.isBlur){
  641. this.isOwnersBtn=false;
  642. }
  643. },
  644. certiimg(waybill_number){
  645. $('#'+waybill_number).click();
  646. },
  647. submitFile(e,waybill_number){
  648. let file=e.target.files[0];
  649. if (file.size >=5242880){
  650. tempTip.setDuration(3000);
  651. tempTip.show("图片大小不能超过5MB!");
  652. return;
  653. }
  654. let _this=this;
  655. let formData=new FormData();
  656. formData.append("file",file);
  657. formData.append("waybill_number",waybill_number);
  658. axios.post('{{url('waybill/upload')}}',formData)
  659. .then(function (response) {
  660. if (!response.data.success){
  661. tempTip.setDuration(4000);
  662. tempTip.show(response.data.error);
  663. return;
  664. }
  665. _this.waybills.some(function (waybill) {
  666. if (waybill.waybill_number===waybill_number){
  667. waybill.url=response.data.data.url;
  668. waybill.suffix=response.data.data.type;
  669. /*setTimeout(function () {
  670. _this.imgs.push(document.getElementById('img_'+waybill.id));
  671. _this.lazy();
  672. },1);*/
  673. tempTip.setDuration(3000);
  674. tempTip.showSuccess("上传成功!");
  675. return true;
  676. }
  677. });
  678. }).catch(function (err) {
  679. tempTip.setDuration(4000);
  680. tempTip.show("网络错误:"+err);
  681. })
  682. },
  683. commonImg(id,url,suffix){
  684. $('#'+id).after(
  685. "<div id=\"common_"+id+"\" style='position: absolute;padding-top: 2px;z-index: 99'>" +
  686. "<div style='position:absolute'>"+
  687. "<div >"+
  688. "<a target='_blank' href='"+url+'-bulky.'+suffix+"'>" +
  689. "<img src=\""+url+'-common.'+suffix+"\" style='position: relative;left:-50px;' >" +
  690. "</a>" +
  691. "</div>"+
  692. @can('运输管理-图片删除')"<button type='button' class='btn btn-sm btn-danger' onclick='vue.btnDeleteImg(this)' value='"+id+"' style='position: relative;float: right;margin-right: 51px;margin-top: -30px;' >删除</button>" +@endcan
  693. "</div>"+
  694. "</div>");
  695. },
  696. removeCommonImg(id){
  697. $('#'+id).remove();
  698. },
  699. btnDeleteImg(e){
  700. let idstr = $(e).val();
  701. let id = idstr.substr( idstr.indexOf('_')+1);
  702. if (!confirm('确定要删除所选图片吗?'))return;
  703. this.destroyImg([id]);
  704. },
  705. deleteImg(){
  706. if (this.checkData.length <= 0) {
  707. tempTip.setDuration(2000);
  708. tempTip.showSuccess('没有勾选任何记录');
  709. return;
  710. }
  711. if (!confirm('确定要删除所选图片吗?'))return;
  712. this.destroyImg(this.checkData);
  713. },
  714. destroyImg(id){
  715. let _this = this;
  716. axios.post('{{url('waybill/deleteImg')}}',{'ids':id})
  717. .then(function (response) {
  718. if (!response.data.success){
  719. tempTip.setDuration(4000);
  720. tempTip.show("删除失败");
  721. return;
  722. }
  723. id.forEach(function (id) {
  724. _this.waybills.some(function (waybill) {
  725. if (waybill.id===id){
  726. waybill.url='';
  727. return true;
  728. }
  729. });
  730. });
  731. tempTip.setDuration(3000);
  732. tempTip.showSuccess("删除成功!");
  733. }).catch(function (err) {
  734. tempTip.setDuration(4000);
  735. tempTip.show("网络错误:"+err);
  736. });
  737. },
  738. // 运输收费修改
  739. waybillChargeCheck:function (e) {
  740. let target = $(e.target);
  741. target.hide();
  742. let input = target.next();
  743. input.show();
  744. input.focus();
  745. },
  746. // 运输收费失焦事件
  747. updateWaybillCharge:function (e) {
  748. let target = $(e.target);
  749. let _this = this;
  750. let span = target.prev();
  751. let id = target.attr('data_id');
  752. let oldCharge = span.text();
  753. let charge = target.val();
  754. if(charge !== span.text()){
  755. let ajaxUrl= '{{url("apiLocal/waybill/changeCharge")}}';
  756. axios.post(ajaxUrl,{'id':id,'charge':charge}).then(function (response) {
  757. if(response.data.success){
  758. _this.updateWaybill(id,charge);
  759. tempTip.setDuration(2000);
  760. tempTip.showSuccess('运输收费修改成功');
  761. }else{
  762. tempTip.setDuration(3000);
  763. tempTip.show('运输收费修改失败!'+response.data.fail_info);
  764. _this.updateWaybill(id,oldCharge);
  765. }
  766. }).catch(function (err) {
  767. tempTip.setDuration(3000);
  768. tempTip.show('运输收费修改失败!网络异常:'+err);
  769. _this.updateWaybill(id,oldCharge);
  770. });
  771. }
  772. span.show();
  773. target.hide();
  774. },
  775. // 为运单添加运输收费
  776. addWaybillCharge(e){
  777. let target = $(e.target);
  778. target.css('width','85px');
  779. let _this = this;
  780. let id = target.attr('data_id');
  781. let charge = target.val();
  782. let ajaxUrl= '{{url("apiLocal/waybill/changeCharge")}}';
  783. if(charge === ''|| charge === null){
  784. target.css('width','75px');
  785. return;
  786. }else{
  787. axios.post(ajaxUrl,{'id':id,'charge':charge}).then(function (response) {
  788. if(response.data.success){
  789. tempTip.setDuration(2000);
  790. tempTip.showSuccess('运输收费添加成功');
  791. _this.updateWaybill(id,charge);
  792. }else{
  793. tempTip.setDuration(3000);
  794. tempTip.show('运输收费添加失败!'+response.data.fail_info);
  795. }
  796. }).catch(function (err) {
  797. tempTip.setDuration(3000);
  798. tempTip.show('运输收费添加失败!网络异常:'+err);
  799. });
  800. target.css('width','75px');
  801. }
  802. },
  803. // 修改运输收费更新表格数据
  804. updateWaybill(id,newCharge){
  805. this.waybills.some(function(waybill){
  806. if(waybill.id === id){
  807. waybill.charge = newCharge;
  808. return true;
  809. }
  810. })
  811. },
  812. // 运费修改
  813. waybillFeeCheck:function (e) {
  814. let target = $(e.target);
  815. target.hide();
  816. let input = target.next();
  817. input.show();
  818. input.focus();
  819. },
  820. // 失焦事件
  821. updateWaybillFee:function (e) {
  822. let target = $(e.target);
  823. let _this = this;
  824. let span = target.prev();
  825. let id = target.attr('data_id');
  826. let oldFee = span.text();
  827. let fee = target.val();
  828. if(fee !== span.text()){
  829. let ajaxUrl= '{{url("apiLocal/waybill/changeFee")}}';
  830. axios.post(ajaxUrl,{'id':id,'fee':fee}).then(function (response) {
  831. if(response.data.success){
  832. _this.updateWaybills(id,fee);
  833. tempTip.setDuration(2000);
  834. tempTip.showSuccess('运单运费修改成功');
  835. }else{
  836. tempTip.setDuration(3000);
  837. tempTip.show('运单运费修改失败!'+response.data.fail_info);
  838. _this.updateWaybills(id,oldFee);
  839. }
  840. }).catch(function (err) {
  841. tempTip.setDuration(3000);
  842. tempTip.show('运单运费修改失败!网络异常:'+err);
  843. _this.updateWaybills(id,oldFee);
  844. });
  845. }
  846. span.show();
  847. target.hide();
  848. },
  849. // 为直发车运单添加运费
  850. addWaybillFee(e){
  851. let target = $(e.target);
  852. target.css('width','85px');
  853. let _this = this;
  854. let id = target.attr('data_id');
  855. let fee = target.val();
  856. let ajaxUrl= '{{url("apiLocal/waybill/changeFee")}}';
  857. if(fee === ''|| fee === null){
  858. target.css('width','75px');
  859. return;
  860. }else{
  861. axios.post(ajaxUrl,{'id':id,'fee':fee}).then(function (response) {
  862. if(response.data.success){
  863. tempTip.setDuration(2000);
  864. tempTip.showSuccess('运单运费添加成功');
  865. _this.updateWaybills(id,fee);
  866. }else{
  867. tempTip.setDuration(3000);
  868. tempTip.show('运单运费添加失败!'+response.data.fail_info);
  869. }
  870. }).catch(function (err) {
  871. tempTip.setDuration(3000);
  872. tempTip.show('运单运费添加失败!网络异常:'+response.data.fail_info);
  873. });
  874. target.css('width','75px');
  875. }
  876. },
  877. // 更新表格数据
  878. updateWaybills(id,newFee){
  879. this.waybills.some(function(waybill){
  880. if(waybill.id === id){
  881. waybill.fee = newFee;
  882. return true;
  883. }
  884. })
  885. },
  886. // 置顶操作
  887. waybillOnTop:function(e){
  888. let target = $(e.target);
  889. let id = target.attr('data_id');
  890. $("#onTopId").val(id);
  891. $('#exampleModal').modal('show');
  892. },
  893. submitOnTop:function(){
  894. let ajaxUrl = '{{url('waybill/ontop/top')}}';
  895. let remark = $("#remark").val();
  896. let id = $("#onTopId").val();
  897. if(remark === ''){
  898. $("#remark").focus();
  899. $('#remark').addClass('is-invalid');
  900. }else{
  901. axios.post(ajaxUrl,{'id':id,'detail':remark}).then(function (response) {
  902. if(response.data.success){
  903. tempTip.setDuration(3000);
  904. tempTip.showSuccess('置顶成功');
  905. $('#exampleModal').modal('hide');
  906. setTimeout(function(){
  907. window.location.reload();
  908. }
  909. ,1000);
  910. }else{
  911. tempTip.setDuration(3000);
  912. tempTip.show('置顶失败!'+response.fail_info);
  913. }
  914. }).catch(function (err) {
  915. tempTip.setDuration(3000);
  916. tempTip.show('置顶失败,网络连接错误!'+err);
  917. });
  918. }
  919. },
  920. changeRemark:function(){
  921. $('#remark').removeClass('is-invalid');
  922. },
  923. cancelOnTop:function (e) {
  924. let target = $(e.target);
  925. let id = target.attr('data_id');
  926. let ajaxUrl='{{url('waybill/ontop/cancel')}}';
  927. if(id !== null){
  928. axios.post(ajaxUrl,{'id':id}).then(function (response) {
  929. if(response.data.success){
  930. tempTip.setDuration(30000);
  931. tempTip.showSuccess('取消置顶成功');
  932. setTimeout(function(){
  933. window.location.reload();
  934. }
  935. ,1000);
  936. }else{
  937. tempTip.setDuration(3000);
  938. tempTip.show('取消置顶失败!'+response.fail_info);
  939. }
  940. }).catch(function (err) {
  941. tempTip.setDuration(3000);
  942. tempTip.show('取消置顶失败,网络连接错误!'+err);
  943. });
  944. }
  945. },
  946. hidetop:function(e) {
  947. let target = $(e.target);
  948. let top = target.parent().find('.top');
  949. let tip = target.parent().find('.toptd');
  950. top.hide();
  951. tip.tooltip('show');
  952. },
  953. showtop:function(e){
  954. let target = $(e.target);
  955. let top = target.parent().find('.top');
  956. let tip = target.parent().find('.toptd');
  957. top.show();
  958. tip.tooltip('hide');
  959. },
  960. refreshWaveHouseWeight(wms_bill_number) {
  961. let _this=this;
  962. let url='{{url('waybill/refreshWaveHouseWeight')}}';
  963. window.axios.post(url,{'wms_bill_number':wms_bill_number}).then(function (response) {
  964. if(response.data.success){
  965. _this.waybills.every(function (waybill) {
  966. if (waybill.wms_bill_number==wms_bill_number){
  967. waybill.warehouse_weight_other=response.data.warehouseWeight;
  968. return false;
  969. }
  970. return true;
  971. });
  972. window.tempTip.setDuration(3000);
  973. window.tempTip.showSuccess('刷新计重成功');
  974. }else{
  975. window.tempTip.setDuration(3000);
  976. window.tempTip.show('刷新计重失败!'+response.data.fail_info);
  977. }
  978. }).catch(function (err) {
  979. window.tempTip.setDuration(3000);
  980. window.tempTip.show('刷新计重失败,网络连接错误!'+err);
  981. });
  982. },
  983. //选择文件
  984. selectedFile(){
  985. $("#uploadImg").click();
  986. },
  987. //上传文件
  988. uploadFiles(event){
  989. let images = event.target.files;
  990. for(let i=0;i<images.length;i++){
  991. let MAX_HEIGHT = 1000;
  992. let image = new Image();
  993. image.onload = ()=>{
  994. let canvas = document.createElement("canvas");
  995. if (image.height > MAX_HEIGHT && image.height >= image.width) {
  996. image.width *= MAX_HEIGHT / image.height;
  997. image.height = MAX_HEIGHT;
  998. }
  999. if (image.width > MAX_HEIGHT && image.width > image.height) {
  1000. image.height *= MAX_HEIGHT / image.width;
  1001. image.width = MAX_HEIGHT;
  1002. }
  1003. let ctx = canvas.getContext("2d");
  1004. ctx.clearRect(0, 0, canvas.width, canvas.height);
  1005. canvas.width = image.width;
  1006. canvas.height = image.height;
  1007. ctx.drawImage(image, 0, 0, image.width, image.height);
  1008. let src = canvas.toDataURL("image/jpeg");
  1009. let size = src.length;
  1010. this.images.push({
  1011. src : src,
  1012. name : images[i]["name"],
  1013. size : size,
  1014. });
  1015. this.size += size;
  1016. };
  1017. image.src = window.URL.createObjectURL(images[i]);
  1018. }
  1019. },
  1020. //删除图片
  1021. delTempImg(index){
  1022. this.$delete(this.images,index);
  1023. },
  1024. //上传图片
  1025. batchUploadImages(){
  1026. window.tempTip.setDuration(3000);
  1027. if (this.images.length<1){
  1028. window.tempTip.show("未选择图片");
  1029. return;
  1030. }
  1031. if (this.size > 104857600){
  1032. window.tempTip.show("上传图片超出100MB,请分开上传");
  1033. return;
  1034. }
  1035. window.tempTip.postBasicRequest('{{url('waybill/batchUploadImages')}}',{images:this.images},res=>{
  1036. let result = res.data;
  1037. let errors = res.errors;
  1038. if (errors.length>0)this.batchUploadError = errors;
  1039. result.forEach(r=>{
  1040. this.waybills.some(waybill=> {
  1041. if (waybill.id==r.id){
  1042. waybill.url="/storage"+r.upload_file.url;
  1043. waybill.suffix=r.upload_file.type;
  1044. /*setTimeout(()=> {
  1045. this.imgs.push(document.getElementById('img_'+waybill.id));
  1046. this.lazy();
  1047. },1);*/
  1048. return true;
  1049. }
  1050. });
  1051. this.size = 0;
  1052. });
  1053. this.$forceUpdate();
  1054. return "上传成功";
  1055. },true);
  1056. },
  1057. },
  1058. filters:{
  1059. km:function(value){
  1060. if(!value)return '';
  1061. return value + ' km';
  1062. },
  1063. money:function(value){
  1064. if(value.indexOf('.')>0){
  1065. return value
  1066. }
  1067. return value += '.00';
  1068. },
  1069. filterZero:function(value){
  1070. value=value.replace(/\.00$/,'');
  1071. value=value.replace(/(\.[1-9])0$/,'$1');
  1072. return value;
  1073. },
  1074. size:function (val) {
  1075. if (!val)return '';
  1076. val = Number(parseInt(val/1024));
  1077. if (val >= 1024){
  1078. return parseInt(val/1024)+"MB";
  1079. }
  1080. return val+"KB";
  1081. },
  1082. }
  1083. });
  1084. // modal 隐藏时修改 input 为空
  1085. $("#exampleModal").on('hide.bs.modal',function(e){
  1086. $('#remark').val('');
  1087. });
  1088. </script>
  1089. @endsection