|
@@ -74,7 +74,7 @@
|
|
|
<el-form-item label="物品重量" required>
|
|
|
<div class="printer-num">
|
|
|
<img @click="reduce()" src="../../static/image/icon_reduce.png" class="reduce" alt="" srcset="" />
|
|
|
- <el-input type="number" size="small" class="num" v-model="form.weight" clearable>
|
|
|
+ <el-input ref="weight" @blur="checkWeight" size="small" class="num" v-model="form.weight" clearable>
|
|
|
<template slot="append">KG</template>
|
|
|
</el-input>
|
|
|
<img @click="add()" src="../../static/image/icon_add.png" class="add" alt="" srcset="" />
|
|
@@ -83,14 +83,14 @@
|
|
|
</el-input-number> -->
|
|
|
</el-form-item>
|
|
|
<el-form-item label="物品价值" required>
|
|
|
- <el-input size="small" type="number" v-model="form.productAmount" placeholder="请输入物品价值!" clearable>
|
|
|
+ <el-input class="product-amount" ref="productAmount" @blur="checkProductAmount" size="small" v-model="form.productAmount" placeholder="请输入物品价值!" clearable>
|
|
|
<template slot="append">元</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="发单时间">
|
|
|
<el-button @click="form.takeType = 0" :class="!form.takeType ? 'but active' : 'but'" type="info">立即发单</el-button>
|
|
|
<el-button @click="form.takeType = 1" :class="form.takeType ? 'but but-r active' : 'but'" type="info">预约发单</el-button>
|
|
|
- <el-date-picker @change="chooseTime" size="small" v-show="form.takeType === 1" v-model="form.takeTime" type="datetime" placeholder="选择日期时间" format="yyyy-MM-dd HH:mm" :picker-options="pickerOptions">
|
|
|
+ <el-date-picker @focus="focus" @change="chooseTime" size="small" v-show="form.takeType === 1" v-model="form.takeTime" type="datetime" placeholder="选择日期时间" format="yyyy-MM-dd HH:mm" :picker-options="pickerOptions">
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="发单备注">
|
|
@@ -244,8 +244,35 @@ export default {
|
|
|
},
|
|
|
// 方法集合
|
|
|
methods: {
|
|
|
- closeAddress(){
|
|
|
- this.getData()
|
|
|
+ checkWeight() {
|
|
|
+ let reg = new RegExp(/^([1-4][0-9]{0,1}|50)$/);
|
|
|
+ if (!reg.test(Number(this.form.weight))) {
|
|
|
+ this.$refs.weight.focus();
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "物品重量为正整数且不得超过50KG!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkProductAmount() {
|
|
|
+ let reg1 = new RegExp(/(^[1-9]{1}[0-9]*$)|(^[0-9]*\.[0-9]{2}$)/);
|
|
|
+ if (!reg1.test(Number(this.form.productAmount))) {
|
|
|
+ this.$refs.productAmount.focus();
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "请输入正确的金额!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (Number(this.form.productAmount) > 20000) {
|
|
|
+ this.$refs.productAmount.focus();
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "物品价值不得超过20000元!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ closeAddress() {
|
|
|
+ this.getData();
|
|
|
},
|
|
|
seachEnterFun(e) {
|
|
|
var keyCode = window.event ? e.keyCode : e.which;
|
|
@@ -338,20 +365,38 @@ export default {
|
|
|
},
|
|
|
|
|
|
onSubmit() {
|
|
|
- // 个人发件
|
|
|
+ // 去除电话中的空格
|
|
|
+ this.form.sendAddress.phone = this.form.sendAddress.phone.replace(
|
|
|
+ /\s/g,
|
|
|
+ ""
|
|
|
+ );
|
|
|
+ this.form.receiptAddress.phone = this.form.receiptAddress.phone.replace(
|
|
|
+ /\s/g,
|
|
|
+ ""
|
|
|
+ );
|
|
|
+ // 个人发件、
|
|
|
+ let reg2 = new RegExp(/^1[3456789]\d{9}$/);
|
|
|
if (!this.sendType) {
|
|
|
+ this.form.shopId = "";
|
|
|
if (!this.form.sendAddress.contact.trim()) {
|
|
|
return this.$message({
|
|
|
type: "error",
|
|
|
message: "请先输入发件人姓名!",
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
if (!this.form.sendAddress.phone.trim()) {
|
|
|
return this.$message({
|
|
|
type: "error",
|
|
|
message: "请先输入发件人电话!",
|
|
|
});
|
|
|
}
|
|
|
+ if (!reg2.test(this.form.sendAddress.phone)) {
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "请输入正确的发件人电话!",
|
|
|
+ });
|
|
|
+ }
|
|
|
if (!this.form.sendAddress.address.trim()) {
|
|
|
return this.$message({
|
|
|
type: "error",
|
|
@@ -371,43 +416,24 @@ export default {
|
|
|
message: "请先输入收件人电话!",
|
|
|
});
|
|
|
}
|
|
|
- if (!this.form.receiptAddress.address.trim()) {
|
|
|
- return this.$message({
|
|
|
- type: "error",
|
|
|
- message: "请先选择收件人地址!",
|
|
|
- });
|
|
|
- }
|
|
|
- let reg = new RegExp(/^([1-4][0-9]{0,1}|50)$/);
|
|
|
- if (!reg.test(Number(this.form.weight))) {
|
|
|
+ if (!reg2.test(this.form.receiptAddress.phone)) {
|
|
|
return this.$message({
|
|
|
type: "error",
|
|
|
- message: "物品重量为整数且不得超过50KG!",
|
|
|
+ message: "请输入正确的收件人电话!",
|
|
|
});
|
|
|
}
|
|
|
- let reg1 = new RegExp(/(^[1-9]{1}[0-9]*$)|(^[0-9]*\.[0-9]{2}$)/);
|
|
|
- if (
|
|
|
- !reg1.test(Number(this.form.productAmount)) ||
|
|
|
- Number(this.form.productAmount) > 20000
|
|
|
- ) {
|
|
|
+ if (!this.form.receiptAddress.address.trim()) {
|
|
|
return this.$message({
|
|
|
type: "error",
|
|
|
- message: "物品价值大于0最多保留2位小数且不得超过20000元!",
|
|
|
+ message: "请先选择收件人地址!",
|
|
|
});
|
|
|
}
|
|
|
- let reg2 = new RegExp(/^1[3456789]\d{9}$/);
|
|
|
- if (!reg2.test(this.form.sendAddress.phone)) {
|
|
|
- return this.$message({
|
|
|
- type: "error",
|
|
|
- message: "发件人电话不合法,请重新输入!",
|
|
|
- });
|
|
|
+ if (this.checkWeight()) {
|
|
|
+ return;
|
|
|
}
|
|
|
- if (!reg2.test(this.form.receiptAddress.phone)) {
|
|
|
- return this.$message({
|
|
|
- type: "error",
|
|
|
- message: "收件人电话不合法,请重新输入!",
|
|
|
- });
|
|
|
+ if (this.checkProductAmount()) {
|
|
|
+ return;
|
|
|
}
|
|
|
-
|
|
|
// 预约发单
|
|
|
if (this.form.takeType) {
|
|
|
if (!this.form.takeTime.trim()) {
|
|
@@ -433,7 +459,6 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
saveOrder() {
|
|
|
- console.dir("form", this.form);
|
|
|
saveOrder(this.form).then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
this.$message({
|
|
@@ -456,7 +481,6 @@ export default {
|
|
|
sendValuation() {
|
|
|
this.isLoading = true;
|
|
|
sendValuation(this.form).then((res) => {
|
|
|
- console.log(res, "发起配送计算");
|
|
|
this.isLoading = false;
|
|
|
if (res.code == 200) {
|
|
|
res.data.optionals.forEach((item) => {
|
|
@@ -502,6 +526,13 @@ export default {
|
|
|
add() {
|
|
|
this.form.weight = ++this.form.weight;
|
|
|
},
|
|
|
+ focus() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ document
|
|
|
+ .getElementsByClassName("el-button--text")[0]
|
|
|
+ .setAttribute("style", "display:none"); // 隐藏此刻按钮
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -514,6 +545,9 @@ export default {
|
|
|
width: calc(100% - 40px);
|
|
|
padding: 20px;
|
|
|
background: #fff;
|
|
|
+ .product-amount {
|
|
|
+ width: 190px;
|
|
|
+ }
|
|
|
.moudle-list {
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|