|
|
@@ -135,7 +135,8 @@
|
|
|
<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%; " >
|
|
|
<option v-for="city in cities" :value="city.id">@{{city.name}}</option>
|
|
|
</select>
|
|
|
- <input class="form-control-sm" placeholder="输入关键字定位" @input="destination_city_id">
|
|
|
+ <input class="form-control-sm" placeholder="输入关键字定位" @input="destination_city_id" v-model="destination_city">
|
|
|
+ <button type="button" class="btn btn-outline-info btn-sm" @click="addCounty" style="transform: scale(0.9)">添加市/县</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group row">
|
|
|
@@ -313,11 +314,12 @@
|
|
|
carrier_weight_other:'{{old('carrier_weight_other')?old('carrier_weight_other'):$waybill->carrier_weight_other}}',
|
|
|
carrier_weight_unit_id_other:'{{old('carrier_weight_unit_id_other')?old('carrier_weight_unit_id_other'):$waybill->carrier_weight_unit_id_other}}',
|
|
|
warehouse_weight_unit_id_other:'{{old('warehouse_weight_unit_id_other')?old('warehouse_weight_unit_id_other'):$waybill->warehouse_weight_unit_id_other}}',
|
|
|
+
|
|
|
},
|
|
|
cities:[
|
|
|
@foreach($cities as $city)
|
|
|
{
|
|
|
- id:'{{$city->id}}',name:'{{$city->name}}'
|
|
|
+ id:'{{$city->id}}',name:'{{$city->name}}',type:'{{$city->type}}',
|
|
|
},
|
|
|
@endforeach
|
|
|
],
|
|
|
@@ -329,6 +331,7 @@
|
|
|
],
|
|
|
errors:[],
|
|
|
origination:'{{$waybill->origination}}',
|
|
|
+ destination_city:'',
|
|
|
},
|
|
|
mounted:function(){
|
|
|
let _this=this;
|
|
|
@@ -400,22 +403,52 @@
|
|
|
}
|
|
|
this.waybillPriceModel.origination_city_id=origination_id;
|
|
|
}
|
|
|
+
|
|
|
if (!this.waybillPriceModel.destination_city_id) {
|
|
|
let destination=document.getElementById('destination_seek').value;
|
|
|
- let strDestination;
|
|
|
- let destination_id;
|
|
|
- if (destination){
|
|
|
- let arr=destination.split("");
|
|
|
- for (i=0;i<arr.length;i++){
|
|
|
- this.cities.some(function (city) {
|
|
|
- if (city.name.includes(strDestination)){ destination_id=city.id; return true;}
|
|
|
- strDestination=arr[i]+arr[i+1];
|
|
|
- });
|
|
|
- if (destination_id) {break;}
|
|
|
+ let strDestination; //两字城市关键字
|
|
|
+ let destination_id; //寻找到的城市id
|
|
|
+ let sign=false; //标记 用于for识别跳出
|
|
|
+ if (destination){ //input有值
|
|
|
+ let arr=destination.split("");//切分数组
|
|
|
+ for (let i=0;i<arr.length;i++){
|
|
|
+ if (!destination_id) { //城市不存在时找城市
|
|
|
+ this.cities.some(function (city) {
|
|
|
+ if (city.name.includes(strDestination)) {
|
|
|
+ destination_id = city.id;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ strDestination = arr[i] + arr[i + 1];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (destination_id) { //城市存在时找县区
|
|
|
+ this.cities.some(function (city) {
|
|
|
+ if (city.type == 3 && city.name.includes(strDestination)) {
|
|
|
+ destination_id = city.id;
|
|
|
+ sign=true;
|
|
|
+ return true; //标记
|
|
|
+ }
|
|
|
+ strDestination = arr[i] + arr[i + 1];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (sign)break; //跳出
|
|
|
+ }
|
|
|
+ if (!destination_id){ //城市与城市下县区都未找到,直接找县区,忽略城市
|
|
|
+ for (let i=0;i<arr.length;i++) {
|
|
|
+ this.cities.some(function (city) {
|
|
|
+ if (city.type == 3 && city.name.includes(strDestination)) {
|
|
|
+ destination_id = city.id;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ strDestination = arr[i] + arr[i + 1];
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
+ //找到赋值 未找到置空
|
|
|
+ if (destination_id)this.waybillPriceModel.destination_city_id=destination_id;
|
|
|
}
|
|
|
- this.waybillPriceModel.destination_city_id=destination_id;
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
methods:{
|
|
|
{{--计费模型阶段保留--}}
|
|
|
@@ -478,6 +511,27 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ addCounty:function () {
|
|
|
+ var add=window.confirm("您确认添加该市/县?");
|
|
|
+ let _this=this;
|
|
|
+ let url='{{url('waybill/addCounty?destination_city=')}}'+_this.destination_city;
|
|
|
+ if(add){
|
|
|
+ axios.post(url)
|
|
|
+ .then(function (response) {
|
|
|
+ if(response.data && response.data.destination_city){
|
|
|
+ tempTip.setDuration(3000);
|
|
|
+ tempTip.show(response.data.destination_city[0]);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ _this.cities.push(response.data);
|
|
|
+ _this.waybillPriceModel.destination_city_id=response.data.id;
|
|
|
+ }).catch(function (err) {
|
|
|
+ tempTip.setDuration(3000);
|
|
|
+ tempTip.show("网络错误!"+err);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
},
|
|
|
});
|
|
|
</script>
|