Commit 34bc5d0a authored by zhengke's avatar zhengke

扩展时间格式方法

parent 458b43fe
......@@ -1731,9 +1731,9 @@
</p>
</el-tooltip>
<div style="margin:10px 0 0 12px;">
<el-input type="text" class="w80" v-model="item.TicketDepartureTime" maxlength="5"
<el-input type="text" class="w80" v-model="item.TicketDepartureTime" @keyup.native="checkTime(item,'TicketDepartureTime')" maxlength="5"
:placeholder="$t('system.ph_time')"></el-input> -
<el-input type="text" class="w80" v-model="item.TicketArrivalTime" maxlength="5"
<el-input type="text" class="w80" v-model="item.TicketArrivalTime" @keyup.native="checkTime(item,'TicketArrivalTime')" maxlength="5"
:placeholder="$t('system.ph_time')"></el-input>
</div>
</div>
......@@ -1799,9 +1799,9 @@
</p>
</el-tooltip>
<div style="margin:10px 0 0 12px;">
<el-input type="text" class="w80" v-model="item.TicketDepartureTime" maxlength="5"
<el-input type="text" class="w80" v-model="item.TicketDepartureTime" @keyup.native="checkTime(item,'TicketDepartureTime')" maxlength="5"
:placeholder="$t('system.ph_time')"></el-input> -
<el-input type="text" class="w80" v-model="item.TicketArrivalTime" maxlength="5"
<el-input type="text" class="w80" v-model="item.TicketArrivalTime" @keyup.native="checkTime(item,'TicketArrivalTime')" maxlength="5"
:placeholder="$t('system.ph_time')"></el-input>
</div>
</div>
......
......@@ -279,7 +279,7 @@
</el-select>
</el-form-item>
<el-form-item :label="$t('system.ph_flightTime')" prop="Departure_time" class='flightMg_delete_icon time'>
<el-input type="text" v-model="addMsg.Departure_time" @keyup.native="changeV(addMsg)" maxlength="5"
<el-input type="text" v-model="addMsg.Departure_time" @keyup.native="checkTime(addMsg,'Departure_time')" maxlength="5"
:placeholder="$t('system.ph_time')"></el-input>
</el-form-item>
<div v-if='addMsg.Type=="2"'>
......@@ -315,7 +315,7 @@
</el-select>
</el-form-item>
<el-form-item :label="$t('system.query_arrivalTime')" prop="Arrival_time" class='flightMg_delete_icon time'>
<el-input type="text" v-model="addMsg.Arrival_time" @keyup.native="changeV2(addMsg)" maxlength="5"
<el-input type="text" v-model="addMsg.Arrival_time" @keyup.native="checkTime(addMsg,'Arrival_time')" maxlength="5"
:placeholder="$t('system.ph_time')"></el-input>
</el-form-item>
<el-form-item class="flightMg_info">
......@@ -735,95 +735,6 @@
//弹出框取消 初始化谈框内表单
this.$refs[formName].clearValidate();
},
//验证时间格式
changeV(addMsg) {
var date = addMsg.Departure_time;
if (date.length == 1) {
var v1 = date.substring(0, 1);
addMsg.Departure_time = v1.replace(/[^0-2]{1}/g, '');
}
if (date.length == 2) {
var v1 = date.substring(0, 1);
if (v1 == 2) {
var reg = /[^0-3]{1}/g;
} else {
var reg = /[^0-9]{1}/g;
}
var v2 = date.substring(1, 2);
if (!reg.test(v2)) {
addMsg.Departure_time = date + ":"
} else {
addMsg.Departure_time = date.substring(0, 1);
}
}
if (date.length == 4) {
reg = /[^0-5]{1}/g;
var v3 = date.substring(3, 4);
if (!reg.test(v3)) {
addMsg.Departure_time = date;
} else {
addMsg.Departure_time = date.substring(0, 3);
}
}
if (date.length == 5) {
var reg = /[^0-9]{1}/g;
var v4 = date.substring(4, 5);
if (!reg.test(v4)) {
addMsg.Departure_time = date
} else {
addMsg.Departure_time = date.substring(0, 4);
}
}
if (date.length > 5) {
addMsg.Departure_time = date.substring(0, 5);
}
this.$forceUpdate();
},
//验证时间格式
changeV2(addMsg) {
var date = addMsg.Arrival_time;
if (date.length == 1) {
var v1 = date.substring(0, 1);
addMsg.Arrival_time = v1.replace(/[^0-2]{1}/g, '');
}
if (date.length == 2) {
var v1 = date.substring(0, 1);
if (v1 == 2) {
var reg = /[^0-3]{1}/g;
} else {
var reg = /[^0-9]{1}/g;
}
var v2 = date.substring(1, 2);
if (!reg.test(v2)) {
addMsg.Arrival_time = date + ":"
} else {
addMsg.Arrival_time = date.substring(0, 1);
}
}
if (date.length == 4) {
reg = /[^0-5]{1}/g;
var v3 = date.substring(3, 4);
if (!reg.test(v3)) {
addMsg.Arrival_time = date;
} else {
addMsg.Arrival_time = date.substring(0, 3);
}
}
if (date.length == 5) {
var reg = /[^0-9]{1}/g;
var v4 = date.substring(4, 5);
if (!reg.test(v4)) {
addMsg.Arrival_time = date
} else {
addMsg.Arrival_time = date.substring(0, 4);
}
}
if (date.length > 5) {
addMsg.Arrival_time = date.substring(0, 5);
}
this.$forceUpdate();
},
//获取季节类型枚举列表
getSeasonTypeList() {
this.apipost(
......
......@@ -677,6 +677,49 @@ export default {
}
item[filed] = value;
}
Vue.prototype.checkTime = function(item, filed){
var date = item[filed];
if (date.length == 1) {
var v1 = date.substring(0, 1);
item[filed] = v1.replace(/[^0-2]{1}/g, '');
}
if (date.length == 2) {
var v1 = date.substring(0, 1);
if (v1 == 2) {
var reg = /[^0-3]{1}/g;
} else {
var reg = /[^0-9]{1}/g;
}
var v2 = date.substring(1, 2);
if (!reg.test(v2)) {
item[filed] = date + ":"
} else {
item[filed] = date.substring(0, 1);
}
}
if (date.length == 4) {
reg = /[^0-5]{1}/g;
var v3 = date.substring(3, 4);
if (!reg.test(v3)) {
item[filed] = date;
} else {
item[filed] = date.substring(0, 3);
}
}
if (date.length == 5) {
var reg = /[^0-9]{1}/g;
var v4 = date.substring(4, 5);
if (!reg.test(v4)) {
item[filed] = date
} else {
item[filed] = date.substring(0, 4);
}
}
if (date.length > 5) {
item[filed] = date.substring(0, 5);
}
this.$forceUpdate();
}
//价钱格式化,三位数逗号分隔,保留两位小数 duanjun
Vue.prototype.moneyFormat = function (value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment