edit.blade.php 39 KB

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