|
@@ -9,18 +9,25 @@ Vue.component("trave", {
|
|
|
data: function () {
|
|
|
return {
|
|
|
// 行程时间
|
|
|
+ traveDay: 0,
|
|
|
tripTime: "",
|
|
|
|
|
|
regionOption: region,
|
|
|
- regionLeve2Option: region[0].child,
|
|
|
- arrivalLeve2Option: region[0].child,
|
|
|
+ // regionLeve2Option: region[0].child,
|
|
|
+ // arrivalLeve2Option: region[0].child,
|
|
|
+ regionLeve2Option: region[defaultTraveProvinceIndex].child,
|
|
|
+ arrivalLeve2Option: region[defaultTraveProvinceIndex].child,
|
|
|
|
|
|
// 出发地 省 市
|
|
|
- departureProvince: region[0].name,
|
|
|
- departureCity: region[0].child[0].name,
|
|
|
+ // departureProvince: region[0].name,
|
|
|
+ // departureCity: region[0].child[0].name,
|
|
|
+ departureProvince: defaultTraveProvince,
|
|
|
+ departureCity: region[defaultTraveProvinceIndex].child[0].name,
|
|
|
// 结束地 省 市
|
|
|
- arrivalProvince: region[0].name,
|
|
|
- arrivalCity: region[0].child[0].name,
|
|
|
+ // arrivalProvince: region[0].name,
|
|
|
+ // arrivalCity: region[0].child[0].name,
|
|
|
+ arrivalProvince: defaultTraveProvince,
|
|
|
+ arrivalCity: region[defaultTraveProvinceIndex].child[0].name,
|
|
|
// 目的地数组
|
|
|
arrivalList: [],
|
|
|
|
|
@@ -33,24 +40,77 @@ Vue.component("trave", {
|
|
|
// arrivalListEdi: [],
|
|
|
}
|
|
|
},
|
|
|
- props: ['traveItem', 'alertDia', 'traveList','traveExplain'],
|
|
|
+ props: ['traveItem', 'alertDia', 'traveList', 'traveExplain'],
|
|
|
computed: {
|
|
|
travePrice: function () {
|
|
|
return travePrice(this.traveList);
|
|
|
- // let sum = 0;
|
|
|
- // this.traveList.forEach(element => {
|
|
|
- // element.tripList.forEach(elementlv2 => {
|
|
|
- // elementlv2.tripItem.forEach(elementlv3 => {
|
|
|
- // sum += Number(elementlv3.price);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // });
|
|
|
- // return sum.toFixed(2);
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ //行程时间验证
|
|
|
changeCount: function (event) {
|
|
|
this.tripTime = event.target.value;
|
|
|
+ this.tripTimeEdi = event.target.value;
|
|
|
+ let dateArray = event.target.value.split(" - ");
|
|
|
+ if (dateArray.length != 2) {
|
|
|
+ this.alertDia("差旅行程时间填写有误");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
|
+ if (!dateFormat.test(dateArray[0])) {
|
|
|
+ this.alertDia("差旅行程时间填写有误");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!dateFormat.test(dateArray[1])) {
|
|
|
+ this.alertDia("差旅行程时间填写有误");
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ traveDay = (Math.abs(Date.parse(dateArray[0]) - Date.parse(dateArray[1]))) / (1000 * 60 * 60 * 24) + 1;
|
|
|
+ if (!isNaN(traveDay)) {
|
|
|
+ this.traveDay = traveDay;
|
|
|
+ let alertDia = this.alertDia;
|
|
|
+ // 验证时间
|
|
|
+ $.ajax({
|
|
|
+ type: "GET",
|
|
|
+ url: "/json/trave/date/all",
|
|
|
+ dataType: "json",
|
|
|
+ processData: false,
|
|
|
+ contentType: false,
|
|
|
+ }).success(function (sortList) {
|
|
|
+ let item = new Array(new Date(Math.round(new Date(dateArray[0]).getTime() / 1000 - 28800)).getTime(), new Date(Math.round(new Date(dateArray[1]).getTime() / 1000 - 28800)).getTime());
|
|
|
+ sortList.push(item);
|
|
|
+ let TraveStatus = isTraveDate(sortList);
|
|
|
+ if (TraveStatus == 2) {
|
|
|
+ alertDia("差旅行程日期段-有重复");
|
|
|
+ }
|
|
|
+ // console.log(sortList);
|
|
|
+ // sortList.forEach((element,index) => {
|
|
|
+ // const start = element[0];
|
|
|
+ // const end = element[1];
|
|
|
+ // itemIndex=index+1;
|
|
|
+ // if(sortList.length===itemIndex){
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // const isRangeStartAndEnd = sortList.some(item => {
|
|
|
+ // return (sortList[itemIndex][0]<=start&&sortList[itemIndex][1]>=start)||(sortList[itemIndex][0]<=end&&sortList[itemIndex][1]>=end)
|
|
|
+ // })
|
|
|
+ // if(isRangeStartAndEnd) {
|
|
|
+ // // 有重复区间
|
|
|
+ // alertDia("历史差旅行程时间段-有重复");
|
|
|
+ // flag = true;
|
|
|
+ // return ;
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+
|
|
|
+
|
|
|
+ }).fail(function (msg) {
|
|
|
+ alertDia("历史差旅时间获取失败");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // this.traveDay=new Date(dateArray[1]).getDate()-new Date(dateArray[0]).getDate()+1;
|
|
|
},
|
|
|
changeRegionLeve2: function (event, model) {
|
|
|
this.regionOption.forEach(element => {
|
|
@@ -58,14 +118,26 @@ Vue.component("trave", {
|
|
|
if (model == "departureCity") {
|
|
|
this.regionLeve2Option = element.child;
|
|
|
this.departureCity = element.child[0].name;
|
|
|
+ this.departureCityEdi = element.child[0].name;
|
|
|
+ this.arrivalProvinceEdi = element.name;
|
|
|
+ this.arrivalProvince = element.name;
|
|
|
+ this.arrivalLeve2Option = element.child;
|
|
|
+ this.arrivalCity = element.child[0].name;
|
|
|
+ this.arrivalCityEdi = element.child[0].name;
|
|
|
} else if (model == "arrivalCity") {
|
|
|
this.arrivalLeve2Option = element.child;
|
|
|
this.arrivalCity = element.child[0].name;
|
|
|
+ this.arrivalCityEdi = element.child[0].name;
|
|
|
+
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ changeArrivalCity: function (event) {
|
|
|
+ this.arrivalCity = event.target.value
|
|
|
+ this.arrivalCityEdi = event.target.value
|
|
|
+ },
|
|
|
// 行程单相关
|
|
|
// 打开行程单
|
|
|
openTrip: function () {
|
|
@@ -200,11 +272,39 @@ Vue.component("trave", {
|
|
|
this.arrivalList = [];
|
|
|
$('#route-edi').modal('hide')
|
|
|
},
|
|
|
- addArrivalDom: function () {
|
|
|
+ addArrivalDom: function (option) {
|
|
|
+ // dom = {
|
|
|
+ // "arrivalProvince": region[0].name,
|
|
|
+ // "arrivalCity": region[0].child[0].name,
|
|
|
+ // "arrivalCityOption": region[0].child,
|
|
|
+ // }
|
|
|
+ //1.没有目的地的时候
|
|
|
+
|
|
|
+ let arrivalProvince = this.departureProvince;
|
|
|
+ let arrivalCity = this.departureCity;
|
|
|
+ let childIndexValue = this.departureProvince;
|
|
|
+ if (option == "edi") {
|
|
|
+ arrivalProvince = this.departureProvinceEdi;
|
|
|
+ arrivalCity = this.departureCityEdi;
|
|
|
+ childIndexValue = this.departureProvinceEdi;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.arrivalList.length !== 0) {
|
|
|
+ childIndexValue = this.arrivalList[this.arrivalList.length - 1].arrivalProvince
|
|
|
+ arrivalProvince = childIndexValue;
|
|
|
+ arrivalCity = this.arrivalList[this.arrivalList.length - 1].arrivalCity;
|
|
|
+ }
|
|
|
+ let index = 0;
|
|
|
+ region.forEach((element, i) => {
|
|
|
+ if (element.name === childIndexValue) {
|
|
|
+ index = i;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
dom = {
|
|
|
- "arrivalProvince": region[0].name,
|
|
|
- "arrivalCity": region[0].child[0].name,
|
|
|
- "arrivalCityOption": region[0].child,
|
|
|
+ "arrivalProvince": arrivalProvince,
|
|
|
+ "arrivalCity": arrivalCity,
|
|
|
+ "arrivalCityOption": region[index].child,
|
|
|
}
|
|
|
this.arrivalList.push(dom);
|
|
|
},
|
|
@@ -372,7 +472,9 @@ Vue.component("trave", {
|
|
|
<tr>
|
|
|
<th>出发/结束日期</th>
|
|
|
<td><input class="datepicker-here span3" placeholder="按时间筛选" type="text" data-range="true"
|
|
|
- data-multiple-dates-separator=" - " data-language="zh" @blur.prevent="changeCount" v-model="tripTimeEdi" ></td>
|
|
|
+ data-multiple-dates-separator=" - " data-language="zh" @blur.prevent="changeCount" v-model="tripTimeEdi" >
|
|
|
+ 旅程合计:<b class="colRed">{{ traveDay }}</b>天
|
|
|
+ </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<th><span>┌</span> 出发地</th>
|
|
@@ -380,10 +482,10 @@ Vue.component("trave", {
|
|
|
<select v-model="departureProvinceEdi" @change="changeRegionLeve2($event,'departureCity')" >
|
|
|
<option v-for="option in regionOption" :value="option.name" >{{option.name}}</option>
|
|
|
</select>
|
|
|
- <select v-model="departureCityEdi">
|
|
|
+ <select v-model="departureCityEdi" @change="changeArrivalCity($event)">
|
|
|
<option v-for="option in regionLeve2Option">{{option.name}}</option>
|
|
|
</select>
|
|
|
- <a href="javascript:void(0)" @click="addArrivalDom" >+添加目的地</a>
|
|
|
+ <a href="javascript:void(0)" @click="addArrivalDom('edi')" >+添加目的地</a>
|
|
|
</td>
|
|
|
</tr>
|
|
|
|
|
@@ -437,7 +539,9 @@ Vue.component("trave", {
|
|
|
<tr>
|
|
|
<th>出发/结束日期</th>
|
|
|
<td><input class="datepicker-here span3" placeholder="按时间筛选" type="text" data-range="true"
|
|
|
- data-multiple-dates-separator=" - " data-language="zh" @blur.prevent="changeCount" v-model="tripTime" ></td>
|
|
|
+ data-multiple-dates-separator=" - " data-language="zh" @blur.prevent="changeCount" v-model="tripTime" >
|
|
|
+ 旅程合计:<b class="colRed">{{ traveDay }}</b>天
|
|
|
+ </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<th><span>┌</span> 出发地</th>
|
|
@@ -445,7 +549,7 @@ Vue.component("trave", {
|
|
|
<select v-model="departureProvince" @change="changeRegionLeve2($event,'departureCity')" >
|
|
|
<option v-for="option in regionOption" :value="option.name" >{{option.name}}</option>
|
|
|
</select>
|
|
|
- <select v-model="departureCity">
|
|
|
+ <select v-model="departureCity" @change="changeArrivalCity($event)">
|
|
|
<option v-for="option in regionLeve2Option">{{option.name}}</option>
|
|
|
</select>
|
|
|
<a href="javascript:void(0)" @click="addArrivalDom" >+添加目的地</a>
|