edit.blade.php 37 KB

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