edit.blade.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. @extends('layouts.app')
  2. @section('content')
  3. <div id="nav2">
  4. @component('waybill.menu')
  5. <li class="nav-item">
  6. <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',3)}">调度</a>
  7. </li>
  8. @endcomponent
  9. </div>
  10. <div class="container-fluid" id="list">
  11. <div class="card">
  12. <div class="card-body">
  13. <form method="POST" id="waybillForm" action='{{url("waybill/".$waybill->id)}}'>
  14. @csrf
  15. @method('PUT')
  16. <div class="form-group row">
  17. <label class="col-2 col-form-label text-right text-secondary">运单类型</label>
  18. <div class="col-8">
  19. <div class="h5 mb-3 col-8">
  20. <button type="button" @click="waybill.type='专线'" class="btn" :class="waybill.type=='专线'?'btn-primary':'btn-outline-primary'">专线</button>
  21. <button type="button" @click="waybill.type='直发车'" class="btn ml-2" :class="waybill.type!='专线'?'btn-primary':'btn-outline-primary'">直发车</button>
  22. </div>
  23. <input name="type" id="type" :value="waybill.type" hidden>
  24. </div>
  25. </div>
  26. <div class="form-group row">
  27. <label class="col-2 col-form-label text-right text-secondary">运单号</label>
  28. <div class="col-8">
  29. <input type="text" class="form-control" disabled="disabled" :value="waybill.waybill_number" >
  30. </div>
  31. </div>
  32. <div class="form-group row">
  33. <label class="col-2 col-form-label text-right text-secondary">货主</label>
  34. <div class="col-8">
  35. <input type="text" class="form-control" disabled="disabled" :value="waybill.owner_name" >
  36. </div>
  37. </div>
  38. <div class="form-group row">
  39. <label class="col-2 col-form-label text-right text-secondary">WMS单号</label>
  40. <div class="col-8">
  41. <input type="text" class="form-control" disabled="disabled" :value="waybill.wms_bill_number" >
  42. </div>
  43. </div>
  44. <div id="origination">
  45. <div class="col-8" style="margin-left: 15%" id="btn" hidden>
  46. <button type="button" class="btn btn-outline-primary btn-sm" @click="waybill.origination='上海市松江区泗砖仓'" style="transform: scale(0.9)">松江泗砖仓</button>
  47. <button type="button" class="btn btn-outline-primary btn-sm" @click="waybill.origination='上海市松江区九干仓'" style="transform: scale(0.9)">松江九干仓</button>
  48. <button type="button" class="btn btn-outline-primary btn-sm" @click="waybill.origination='上海市嘉定区武乡仓'" style="transform: scale(0.9)">嘉定武乡仓</button>
  49. </div>
  50. <div class="form-group row">
  51. <label class="col-2 col-form-label text-right text-secondary" for="origination_seek">始发地</label>
  52. <div class="col-8">
  53. <input type="text" class="form-control @error('origination') is-invalid @enderror"
  54. id="origination_seek" name="origination" disabled="disabled" v-model="waybill.origination">
  55. </div>
  56. @error('origination')
  57. <span class="invalid-feedback" role="alert">
  58. <strong>{{ $message }}</strong>
  59. </span>
  60. @enderror
  61. </div>
  62. </div>
  63. <div class="form-group row">
  64. <label class="col-2 col-form-label text-right text-secondary" for="destination_seek">目的地</label>
  65. <div class="col-8">
  66. <input id="destination_seek" type="text" class="form-control" disabled="disabled" :value="waybill.destination" >
  67. </div>
  68. </div>
  69. <div class="form-group row">
  70. <label class="col-2 col-form-label text-right text-secondary">收件人</label>
  71. <div class="col-8">
  72. <input type="text" class="form-control" disabled="disabled" :value="waybill.recipient" >
  73. </div>
  74. </div>
  75. <div class="form-group row">
  76. <label class="col-2 col-form-label text-right text-secondary">收件人电话</label>
  77. <div class="col-8">
  78. <input type="text" class="form-control" disabled="disabled" :value="waybill.recipient_mobile" >
  79. </div>
  80. </div>
  81. <div class="form-group row" id="ordering_remark">
  82. <label class="col-2 col-form-label text-right text-secondary">下单备注</label>
  83. <div class="col-8">
  84. <textarea class="form-control" disabled="disabled" >@{{waybill.ordering_remark}}</textarea>
  85. </div>
  86. </div>
  87. {{--编辑区--}}
  88. <div class="form-group row">
  89. <label class="col-2 col-form-label text-right text-secondary">运输收费(元)</label>
  90. <div class="col-8">
  91. <input type="text" class="form-control @error('charge') is-invalid @enderror"
  92. id="charge" name="charge" v-model="waybill.charge" >
  93. </div>
  94. @error('charge')
  95. <span class="invalid-feedback" role="alert">
  96. <strong>{{ $message }}</strong>
  97. </span>
  98. @enderror
  99. </div>
  100. <div class="form-group row">
  101. <label for="other_charge" class="col-2 col-form-label text-right text-muted">其他收费(元)</label>
  102. <div class="col-8">
  103. <input type="text" class="form-control @error('other_charge') is-invalid @enderror"
  104. name="other_charge" autocomplete="off" value="@if(old('other_charge')){{ old('other_charge') }}@else{{$waybill->other_charge}}@endif" >
  105. @error('other_charge')
  106. <span class="invalid-feedback" role="alert">
  107. <strong>{{ $message }}</strong>
  108. </span>
  109. @enderror
  110. </div>
  111. </div>
  112. <div class="form-group row">
  113. <label for="other_charge_remark" class="col-2 col-form-label text-right text-muted">其他收费备注</label>
  114. <div class="col-8">
  115. <input type="text" class="form-control @error('other_charge') is-invalid @enderror"
  116. name="other_charge_remark" autocomplete="off" value="@if(old('other_charge_remark')){{ old('other_charge_remark') }}@else{{$waybill->other_charge_remark}}@endif" >
  117. @error('other_charge_remark')
  118. <span class="invalid-feedback" role="alert">
  119. <strong>{{ $message }}</strong>
  120. </span>·
  121. @enderror
  122. </div>
  123. </div>
  124. <div class="form-group row" style="margin-bottom: 20px">
  125. <label for="carrier_id" class="col-2 col-form-label text-right text-primary">承运商 *</label>
  126. <div class="col-8" style="position: relative">
  127. <select name="carrier_id" class="form-control @error('carrier_id') is-invalid @enderror"
  128. :class="errors['carrier_id'] ? 'is-invalid' :''" id="carrier_id" v-model="waybill.carrier_id" style="width: 30%; ">
  129. <option v-for="carrier in carriers" :value="carrier.id">@{{carrier.name}}</option>
  130. </select>
  131. <div v-if="errors['carrier_id'] && errors['carrier_id'].length>0" class="invalid-feedback" role="alert" style="position: relative">
  132. <strong class="">@{{ errors['carrier_id'][0] }}</strong>
  133. </div>
  134. <span class="col-sm-5" style="position: absolute;height: 15px;padding: 0">
  135. <p class="form-control-static text-danger small font-weight-bold" style="">{{ $errors->first('carrier_id') }}</p>
  136. </span>
  137. </div>
  138. </div>
  139. <div class="form-group row">
  140. <label class="col-2 col-form-label text-right">承运商单号</label>
  141. <div class="col-8">
  142. <input type="text" class="form-control @error('carrier_bill') is-invalid @enderror"
  143. name="carrier_bill" autocomplete="off" v-model="waybill.carrier_bill" id="carrier_bill">
  144. @error('carrier_bill')
  145. <span class="invalid-feedback" role="alert">
  146. <strong>{{ $message }}</strong>
  147. </span>
  148. @enderror
  149. </div>
  150. </div>
  151. <div v-if="waybill.type=='专线'">
  152. <div class="form-group row">
  153. <label for="origination_city_id" class="col-2 col-form-label text-right text-primary">始发市 *</label>
  154. <div class="col-8 form-inline">
  155. <select class="form-control @error('origination_city_id') is-invalid @enderror" name="origination_city_id"
  156. :class="errors['origination_city_id'] ? 'is-invalid' :''" style="width: 30%; " v-model="waybill.origination_city_id" id="origination_city_id">
  157. <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
  158. </select>
  159. <input class="form-control-sm form-control" placeholder="输入关键字定位" @input="origination_city_name">
  160. </div>
  161. </div>
  162. <div class="form-group row">
  163. <label for="destination_city_id" class="col-2 col-form-label text-right text-primary">目的市 *</label>
  164. <div class="col-8 form-inline">
  165. <select class="form-control @error('destination_city_id') is-invalid @enderror" name="destination_city_id"
  166. :class="errors['destination_city_id'] ? 'is-invalid' :''" id="destination_city_id" v-model="waybill.destination_city_id" style="width: 30%; " >
  167. <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
  168. </select>
  169. <input type="text" class="form-control-sm form-control tooltipTarget" style="vertical-align: middle"
  170. placeholder="输入关键字定位" @input="destination_city_id" v-model="waybill.destination_city" id="destination_city" title="若无法显示区/县级市,可点击后方按钮手动添加" >
  171. <button type="button" class="btn btn-outline-info btn-sm" @click="addCounty" style="transform: scale(0.9)">添加市/县</button>
  172. </div>
  173. </div>
  174. </div>
  175. <div class="form-group row">
  176. <label for="warehouse_weight" class="col-2 col-form-label text-right " v-if="waybill.type=='专线'">仓库计抛</label>
  177. <div class="col-2" v-if="waybill.type=='专线'">
  178. <input type="text" class="form-control @error('warehouse_weight') is-invalid @enderror"
  179. name="warehouse_weight" autocomplete="off" v-model="waybill.warehouse_weight" id="warehouse_weight" >
  180. @error('warehouse_weight')
  181. <span class="invalid-feedback" role="alert">
  182. <strong>{{ $message }}</strong>
  183. </span>
  184. @enderror
  185. </div>
  186. <label for="warehouse_weight_unit_id" class=" col-form-label text-right " v-if="waybill.type=='专线'">单位:</label>
  187. <div class="col-1.5" v-if="waybill.type=='专线'">
  188. <select class="form-control @error('warehouse_weight_unit_id') is-invalid @enderror"
  189. name="warehouse_weight_unit_id" v-model="waybill.warehouse_weight_unit_id" id="warehouse_weight_unit_id">
  190. <option :value="unit.id" v-for="unit in units" >@{{ unit.name }}</option>
  191. </select>
  192. </div>
  193. <span v-if="waybill.type=='专线'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  194. <label for="warehouse_weight_other" class="col-form-label text-right " :class="waybill.type=='专线' ? '' : 'col-2'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;仓库重</label>
  195. <div class="col-2">
  196. <input type="text" class="form-control @error('warehouse_weight_other') is-invalid @enderror"
  197. name="warehouse_weight_other" autocomplete="off" v-model="waybill.warehouse_weight_other" id="warehouse_weight_other">
  198. @error('warehouse_weight_other')
  199. <span class="invalid-feedback" role="alert">
  200. <strong>{{ $message }}</strong>
  201. </span>
  202. @enderror
  203. </div>
  204. <label for="warehouse_weight_unit_id_other" class=" col-form-label text-right ">单位:</label>
  205. <div class="col-1.5">
  206. <select class="form-control @error('warehouse_weight_unit_id_other') is-invalid @enderror"
  207. name="warehouse_weight_unit_id_other" v-model="waybill.warehouse_weight_unit_id_other" id="warehouse_weight_unit_id_other">
  208. <option :value="unit.id" v-for="unit in units" >@{{ unit.name }}</option>
  209. </select>
  210. </div>
  211. </div>
  212. <div v-if="waybill.type=='专线'">
  213. <div class="form-group row">
  214. <label for="carrier_weight" class="col-2 col-form-label text-right ">承运商计抛</label>
  215. <div class="col-2">
  216. <input type="text" id="carrier_weight" :class="errors['carrier_weight'] ? 'is-invalid' :''" class="form-control @error('carrier_weight') is-invalid @enderror"
  217. name="carrier_weight" autocomplete="off" v-model="waybill.carrier_weight" >
  218. @error('carrier_weight')
  219. <span class="invalid-feedback" role="alert">
  220. <strong>{{ $message }}</strong>
  221. </span>
  222. @enderror
  223. </div>
  224. <label for="carrier_weight_unit_id" class="col-form-label text-right ">单位:</label>
  225. <div class="col-1.5">
  226. <select id="carrier_weight_unit_id" :class="errors['carrier_weight_unit_id'] ? 'is-invalid' :''" class="form-control @error('carrier_weight_unit_id') is-invalid @enderror"
  227. name="carrier_weight_unit_id" v-model="waybill.carrier_weight_unit_id" >
  228. <option :value="unit.id" v-for="unit in units" >@{{ unit.name }}</option>
  229. </select>
  230. </div>
  231. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  232. <label for="carrier_weight_other" class="col-form-label text-right ">承运商计重</label>
  233. <div class="col-2">
  234. <input type="text" id="carrier_weight_other" :class="errors['carrier_weight_other'] ? 'is-invalid' :''"
  235. class="form-control @error('carrier_weight_other') is-invalid @enderror"
  236. name="carrier_weight_other" autocomplete="off" v-model="waybill.carrier_weight_other" >
  237. @error('carrier_weight_other')
  238. <span class="invalid-feedback" role="alert">
  239. <strong>{{ $message }}</strong>
  240. </span>
  241. @enderror
  242. </div>
  243. <label for="carrier_weight_unit_id_other" class=" col-form-label text-right ">单位:</label>
  244. <div class="col-1.5">
  245. <select id="carrier_weight_unit_id_other" :class="errors['carrier_weight_unit_id_other'] ? 'is-invalid' :''"
  246. class="form-control @error('carrier_weight_unit_id_other') is-invalid @enderror"
  247. name="carrier_weight_unit_id_other" v-model="waybill.carrier_weight_unit_id_other" >
  248. <option :value="unit.id" v-for="unit in units" >@{{ unit.name }}</option>
  249. </select>
  250. </div>
  251. </div>
  252. </div>
  253. <div class="form-group row">
  254. <label for="carrier_id" class="col-2 col-form-label text-right text-primary">计数</label>
  255. <div class="col-5">
  256. <input type="number" class="form-control @error('amount') is-invalid @enderror"
  257. name="amount" autocomplete="off" v-model="waybill.amount" id="amount" >
  258. @error('amount')
  259. <span class="invalid-feedback" role="alert">
  260. <strong>{{ $message }}</strong>
  261. </span>
  262. @enderror
  263. </div>
  264. <label for="amount_unit_id" class=" col-form-label text-right ">单位:</label>
  265. <div class="col-1.5 form-inline">
  266. <label for="amount_unit_id" class="ml-1 @error('amount_unit_id') text-danger @enderror" >件</label>
  267. <input id="amount_unit_id" type="radio" value="4" class="form-control form-control-sm ml-1"
  268. name="amount_unit_id" v-model="waybill.amount_unit_id">
  269. <label for="amount_unit_id1" class="ml-1 @error('amount_unit_id') text-danger @enderror" >托</label>
  270. <input id="amount_unit_id1" type="radio" value="5" class="form-control form-control-sm ml-1"
  271. :class="errors['amount_unit_id'] ? 'is-invalid' :''" name="amount_unit_id" v-model="waybill.amount_unit_id">
  272. </div>
  273. @error('amount_unit_id')
  274. <div class="col-2 form-inline">
  275. <label class="form-control-static text-danger small font-weight-bold">{{$message}}</label>
  276. </div>
  277. @enderror
  278. </div>
  279. <div class="form-group row">
  280. <label for="carrier_id" class="col-2 col-form-label text-right text-dark">里程数</label>
  281. <div class="col-8">
  282. <input type="number" class="form-control @error('mileage') is-invalid @enderror"
  283. name="mileage" autocomplete="off" v-model="waybill.mileage" id="mileage" >
  284. @error('mileage')
  285. <span class="invalid-feedback" role="alert">
  286. <strong>{{ $message }}</strong>
  287. </span>
  288. @enderror
  289. </div>
  290. </div>
  291. <div v-if="waybill.type=='直发车'">
  292. <div class="form-group row">
  293. <label for="carType_id" class="col-2 col-form-label text-right">车型</label>
  294. <div class="col-8">
  295. <select class="form-control" name="carType_id" style="width: 30%;" v-model="waybill.carType_id" id="carType_id">
  296. <option v-for="carType in carTypes" :value="carType.id">@{{ carType.name }}</option>
  297. </select>
  298. </div>
  299. </div>
  300. <div class="form-group row">
  301. <label for="car_owner_info" class="col-2 col-form-label text-right">车辆信息</label>
  302. <div class="col-8">
  303. <input type="text" class="form-control"
  304. name="car_owner_info" autocomplete="off" v-model="waybill.car_owner_info" id="car_owner_info" >
  305. </div>
  306. </div>
  307. @can('运输管理-运费')
  308. <div class="form-group row">
  309. <label for="fee" class="col-2 col-form-label text-right text-primary">运费(元) </label>
  310. <div class="col-8">
  311. <input type="text" class="form-control @error('fee') is-invalid @enderror"
  312. name="fee" autocomplete="off" v-model="waybill.fee" id="fee" >
  313. @error('fee')
  314. <span class="invalid-feedback" role="alert">
  315. <strong>{{ $message }}</strong>
  316. </span>
  317. @enderror
  318. </div>
  319. </div>
  320. @endcan
  321. </div>
  322. <div v-if="waybill.type=='专线'">
  323. <div class="form-group row">
  324. <label for="pick_up_fee" class="col-2 col-form-label text-right">提货费(元)</label>
  325. <div class="col-8">
  326. <input type="text" class="form-control @error('pick_up_fee') is-invalid @enderror"
  327. name="pick_up_fee" autocomplete="off" v-model="waybill.pick_up_fee" id="pick_up_fee">
  328. @error('pick_up_fee')
  329. <span class="invalid-feedback" role="alert">
  330. <strong>{{ $message }}</strong>
  331. </span>
  332. @enderror
  333. </div>
  334. </div>
  335. </div>
  336. <div class="form-group row">
  337. <label for="other_fee" class="col-2 col-form-label text-right text-muted">其他支出(元)</label>
  338. <div class="col-8">
  339. <input type="text" class="form-control @error('other_fee') is-invalid @enderror"
  340. name="other_fee" autocomplete="off" v-model="waybill.other_fee" id="other_fee">
  341. @error('other_fee')
  342. <span class="invalid-feedback" role="alert">
  343. <strong>{{ $message }}</strong>
  344. </span>
  345. @enderror
  346. </div>
  347. </div>
  348. <div class="form-group row">
  349. <label for="deliver_at" class="col-2 col-form-label text-right text-muted">发货时间</label>
  350. <div class="col-8 form-inline">
  351. <input id="deliver_at_date" @input="spliceDeliverAt" name="deliver_at_date" type="date" class="form-control col-4"
  352. value="@if(old('deliver_at_date')){{ old('deliver_at_date') }}@else{{$waybill->deliver_at_date}}@endif">
  353. <input id="deliver_at_time" @input="spliceDeliverAt" name="deliver_at_time" type="time" class="form-control col-4"
  354. value="@if(old('deliver_at_time')){{ old('deliver_at_time') }}@else{{$waybill->deliver_at_time}}@endif">
  355. <input hidden id="deliver_at" name="deliver_at" type="text" class="form-control col-4">
  356. </div>
  357. </div>
  358. <div class="form-group row">
  359. <label for="dispatch_remark" class="col-2 col-form-label text-right text-muted">调度备注</label>
  360. <div class="col-8">
  361. <textarea class="form-control @error('dispatch_remark') is-invalid @enderror"
  362. name="dispatch_remark" autocomplete="off" v-model="waybill.dispatch_remark" id="dispatch_remark"></textarea>
  363. @error('dispatch_remark')
  364. <span class="invalid-feedback" role="alert">
  365. <strong>{{ $message }}</strong>
  366. </span>
  367. @enderror
  368. </div>
  369. </div>
  370. <input type="hidden" name="status" value="待终审">
  371. <input type="hidden" name="waybillPriceModel" id="waybillPriceModel">
  372. <div class="form-group row">
  373. <div class="col-8 offset-2">
  374. <input type="button" @click="submitForm" class="btn btn-outline-dark form-control" value="提交">
  375. </div>
  376. </div>
  377. </form>
  378. </div>
  379. </div>
  380. </div>
  381. @endsection
  382. @section('lastScript')
  383. <script>
  384. let vueList=new Vue({
  385. el:'#list',
  386. data:{
  387. cities:[
  388. @foreach($cities as $city)
  389. {
  390. id:'{{$city->id}}',name:'{{$city->name}}',type:'{{$city->type}}',
  391. },
  392. @endforeach
  393. ],
  394. units:[
  395. @foreach($units as $unit){
  396. id:'{{$unit->id}}',name:'{{$unit->name}}',
  397. },
  398. @endforeach
  399. ],
  400. carriers:[
  401. @foreach($carriers as $carrier)
  402. {id:'{{$carrier->id}}',name:'{{$carrier->name}}',},
  403. @endforeach
  404. ],
  405. carTypes:[
  406. @foreach($carTypes as $carType)
  407. {!! $carType !!},
  408. @endforeach
  409. ],
  410. errors:[],
  411. waybill:{
  412. id:'{{$waybill->id}}',type:'{{$waybill->type}}',waybill_number:'{{$waybill->waybill_number}}',owner_name:'{{$waybill->owner_name}}',
  413. wms_bill_number:'{{$waybill->wms_bill_number}}',origination:'{{$waybill->origination}}',destination:'{{$waybill->destination}}',
  414. recipient:'{{$waybill->recipient}}',recipient_mobile:'{{$waybill->recipient_mobile}}',ordering_remark:'{{$waybill->ordering_remark}}',
  415. charge:'{{$waybill->charge}}',carrier_id:'{{$waybill->carrier_id}}',carrier_bill:'{{$waybill->carrier_bill}}',
  416. warehouse_weight_other:'{{$waybill->warehouse_weight_other}}',warehouse_weight_unit_id_other:'{{$waybill->warehouse_weight_unit_id_other}}',amount:'{{$waybill->amount}}',
  417. amount_unit_id:'{{$waybill->amount_unit_id}}',mileage:'{{$waybill->mileage}}',carType_id:'{{$waybill->carType_id}}',
  418. car_owner_info:'{{$waybill->car_owner_info}}',fee:'{{$waybill->fee}}',other_fee:'{{$waybill->other_fee}}',
  419. other_charge:'{{$waybill->other_charge}}',other_charge_remark:'{{$waybill->other_charge_remark}}',dispatch_remark:'{{$waybill->dispatch_remark}}',
  420. origination_city_id:'{{$waybill->origination_city_id}}',destination_city_id:'{{$waybill->destination_city_id}}',warehouse_weight:'{{$waybill->warehouse_weight}}',
  421. warehouse_weight_unit_id:'{{$waybill->warehouse_weight_unit_id}}',carrier_weight:'{{$waybill->carrier_weight}}',carrier_weight_unit_id:'{{$waybill->carrier_weight_unit_id}}',
  422. carrier_weight_other:'{{$waybill->carrier_weight_other}}',carrier_weight_unit_id_other:'{{$waybill->carrier_weight_unit_id_other}}',pick_up_fee:'{{$waybill->pick_up_fee}}',
  423. },
  424. waybillTemp:{!! $waybill !!}
  425. },
  426. mounted:function(){
  427. let _this=this;
  428. //console.log(_this.waybillPriceModel.amount_unit_id)
  429. $(".tooltipTarget").tooltip({'trigger':'hover'});
  430. this.units.every(function (unit) {
  431. switch (unit.name) {
  432. case "kg":
  433. if (!_this.waybill.warehouse_weight_unit_id_other)_this.waybill.warehouse_weight_unit_id_other=unit.id;
  434. if (!_this.waybill.carrier_weight_unit_id_other)_this.waybill.carrier_weight_unit_id_other=unit.id;
  435. break;
  436. case "m³":
  437. if (!_this.waybill.carrier_weight_unit_id)_this.waybill.carrier_weight_unit_id=unit.id;
  438. if (!_this.waybill.warehouse_weight_unit_id)_this.waybill.warehouse_weight_unit_id=unit.id;
  439. break;
  440. }
  441. return true;
  442. });
  443. if (!this.waybill.origination){
  444. $("#btn").removeAttr("hidden");
  445. $("#ordering_remark").after($("#origination"));
  446. $("#origination_seek").attr("disabled",false);
  447. }
  448. if (!this.waybill.origination_city_id){
  449. let _this=this;
  450. this.cities.every(function (city) {
  451. if (city.name==="上海"){
  452. _this.waybill.origination_city_id=city.id;
  453. return false;
  454. }
  455. return true;
  456. });
  457. }
  458. /*将地址转换为市区,赋给data*/
  459. if (!this.waybill.origination_city_id){
  460. let origination=document.getElementById('origination_seek').value;
  461. let str;
  462. let origination_id;
  463. if (origination){
  464. let arr=origination.split("");
  465. for (let i=0;i<arr.length;i++){
  466. this.cities.some(function (city) {
  467. if (city.name.includes(str)){ origination_id=city.id; return true;}
  468. str=arr[i]+arr[i+1];
  469. });
  470. if (origination_id) {break;}
  471. }
  472. }
  473. this.waybill.origination_city_id=origination_id;
  474. }
  475. if (!this.waybill.destination_city_id) {
  476. let destination=document.getElementById('destination_seek').value;
  477. let strDestination; //两字城市关键字
  478. let destination_id; //寻找到的城市id
  479. let sign=false; //标记 用于for识别跳出
  480. if (destination){ //input有值
  481. let arr=destination.split("");//切分数组
  482. for (let i=0;i<arr.length;i++){
  483. if (!destination_id) { //城市不存在时找城市
  484. this.cities.some(function (city) {
  485. if (city.name.includes(strDestination)) {
  486. destination_id = city.id;
  487. return true;
  488. }
  489. strDestination = arr[i] + arr[i + 1];
  490. });
  491. }
  492. if (destination_id) { //城市存在时找县区
  493. this.cities.some(function (city) {
  494. if (city.type == 3 && city.name.includes(strDestination)) {
  495. destination_id = city.id;
  496. sign=true;
  497. return true; //标记
  498. }
  499. strDestination = arr[i] + arr[i + 1];
  500. });
  501. }
  502. if (sign)break; //跳出
  503. }
  504. if (!destination_id){ //城市与城市下县区都未找到,直接找县区,忽略城市
  505. for (let i=0;i<arr.length;i++) {
  506. this.cities.some(function (city) {
  507. if (city.type == 3 && city.name.includes(strDestination)) {
  508. destination_id = city.id;
  509. return true;
  510. }
  511. strDestination = arr[i] + arr[i + 1];
  512. });
  513. }
  514. }
  515. //找到赋值 未找到置空
  516. if (destination_id)this.waybill.destination_city_id=destination_id;
  517. }
  518. }
  519. },
  520. methods:{
  521. {{--计费模型阶段保留--}}
  522. is_waybillPriceModel(carrier_id,carrier_weight,carrier_weight_unit_id,destination_city_id,carrier_weight_other,carrier_weight_unit_id_other){
  523. this.errors=[];
  524. let url='{{url('waybill/is/waybillPriceModel')}}';
  525. let _this=this;
  526. axios.post(url,{carrier_id:carrier_id,carrier_weight:[carrier_weight,carrier_weight_other],
  527. carrier_weight_unit_id:[carrier_weight_unit_id,carrier_weight_unit_id_other],destination_city_id:destination_city_id})
  528. .then(
  529. function (response) {
  530. if (response.data.error){
  531. _this.errors=response.data.error;return;}
  532. if (!response.data.success) {
  533. document.getElementById('waybillPriceModel').value='';
  534. tempTip.confirm('该目的地与计量单位对应的计费模型不存在,如录入将会标为异常记录,请通知相关负责人添加计费模型,点击'+'<b class="text-primary">"确定"</b>'+'则确认提交 ',
  535. function () {
  536. document.getElementById('deliver_at').value= document.getElementById('deliver_at_date').value+' '+ document.getElementById('deliver_at_time').value;
  537. // document.getElementById('waybillForm').submit();
  538. _this.executeSubmit();
  539. });
  540. }else{
  541. document.getElementById('waybillPriceModel').value=response.data.success;
  542. document.getElementById('deliver_at').value= document.getElementById('deliver_at_date').value+' '+ document.getElementById('deliver_at_time').value;
  543. _this.executeSubmit();
  544. }
  545. }
  546. );
  547. },
  548. executeSubmit(){
  549. let data=['origination','charge','carrier_bill', 'warehouse_weight','warehouse_weight_unit_id',
  550. 'warehouse_weight_other','warehouse_weight_unit_id_other','carrier_weight','carrier_weight_unit_id'
  551. ,'carrier_weight_other','carrier_weight_unit_id_other','mileage','carType_id'
  552. ,'car_owner_info','pick_up_fee','fee','other_fee','other_charge','other_charge_remark','dispatch_remark'];
  553. let waybill=this.waybill;
  554. let waybillTemp=this.waybillTemp;
  555. data.forEach(function (name) {
  556. if (waybill[name] === waybillTemp[name]){
  557. if (document.getElementById(name))document.getElementById(name).removeAttribute('name');
  558. }
  559. });
  560. setTimeout(function () {
  561. document.getElementById('waybillForm').submit();
  562. },1);
  563. },
  564. spliceDeliverAt:function () {
  565. document.getElementById('deliver_at').value= document.getElementById('deliver_at_date').value+' '+ document.getElementById('deliver_at_time').value;
  566. },
  567. submitForm(){
  568. let type=this.waybill.type;
  569. if (type==='专线'){
  570. let carrier_id=document.getElementById('carrier_id').value;
  571. let carrier_weight=document.getElementById('carrier_weight').value;
  572. let carrier_weight_unit_id=document.getElementById('carrier_weight_unit_id').value;
  573. let destination_city_id=document.getElementById('destination_city_id').value;
  574. let carrier_weight_other=document.getElementById('carrier_weight_other').value;
  575. let carrier_weight_unit_id_other=document.getElementById('carrier_weight_unit_id_other').value;
  576. this.is_waybillPriceModel(carrier_id,carrier_weight,carrier_weight_unit_id,destination_city_id,carrier_weight_other,carrier_weight_unit_id_other);
  577. }else {
  578. document.getElementById('deliver_at').value= document.getElementById('deliver_at_date').value+' '+ document.getElementById('deliver_at_time').value;
  579. // document.getElementById('waybillForm').submit();
  580. this.executeSubmit();
  581. }
  582. },
  583. origination_city_name:function (e) {
  584. let _this=this;
  585. let $val=e.target.value;
  586. if($val==='')_this.waybill.origination_city_id='';
  587. else
  588. _this.cities.forEach(function (city) {
  589. if (city.name.includes($val)){
  590. _this.waybill.origination_city_id=city.id;
  591. }
  592. });
  593. },
  594. destination_city_id:function (e) {
  595. let _this=this;
  596. let $val=e.target.value;
  597. if($val==='')_this.waybill.destination_city_id='';
  598. else
  599. _this.cities.forEach(function (city) {
  600. if (city.name.includes($val)){
  601. _this.waybill.destination_city_id=city.id;
  602. }
  603. });
  604. },
  605. addCounty:function () {
  606. var add=window.confirm("您确认添加该市/县?");
  607. let _this=this;
  608. let url='{{url('waybill/addCounty?destination_city=')}}'+_this.destination_city;
  609. if(add){
  610. axios.post(url)
  611. .then(function (response) {
  612. if(response.data && response.data.destination_city){
  613. tempTip.setDuration(3000);
  614. tempTip.show(response.data.destination_city[0]);
  615. return ;
  616. }
  617. _this.cities.push(response.data);
  618. _this.waybill.destination_city_id=response.data.id;
  619. }).catch(function (err) {
  620. tempTip.setDuration(3000);
  621. tempTip.show("网络错误!"+err);
  622. });
  623. }
  624. }
  625. },
  626. });
  627. </script>
  628. @endsection