|
@@ -24,7 +24,7 @@
|
|
|
<el-input size="small" class="phone-after" v-model="form.sendAddress.extension" placeholder="分机号"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="发件人地址" required>
|
|
|
- <el-input size="small" v-model="form.sendAddress.address" placeholder="请填写/选择发件人地址" disabled>
|
|
|
+ <el-input size="small" v-model="form.sendAddress.address" placeholder="请选择发件人地址" disabled>
|
|
|
<el-image @click="showMap(1)" slot="append" class="map" src="../../static/image/icon_map.png"></el-image>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
@@ -48,7 +48,7 @@
|
|
|
<el-input size="small" class="phone-after" v-model="form.receiptAddress.extension" placeholder="分机号"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="收件人地址" required>
|
|
|
- <el-input size="small" v-model="form.receiptAddress.address" placeholder="请填写/选择收件人地址" disabled>
|
|
|
+ <el-input size="small" v-model="form.receiptAddress.address" placeholder="请选择收件人地址" disabled>
|
|
|
<el-image @click="showMap(2)" slot="append" class="map" src="../../static/image/icon_map.png"></el-image>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
@@ -90,7 +90,7 @@
|
|
|
<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="选择日期时间" default-time="12:00:00" :picker-options="pickerOptions">
|
|
|
+ <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>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="发单备注">
|
|
@@ -115,8 +115,8 @@
|
|
|
</div>
|
|
|
|
|
|
<!-- 选择门店 -->
|
|
|
- <el-dialog v-loading="loading" element-loading-text="拼命加载中" :title="sendType === 1 ? '选择门店' : '常用地址'" :visible.sync="showChooseShop" width="600px" center>
|
|
|
- <el-input placeholder="请输入姓名/手机号/地址" v-model="searchKey" clearable>
|
|
|
+ <el-dialog v-loading="loading" element-loading-text="拼命加载中" :title="sendType === 1 && addressType !== 2 ? '选择门店' : '常用地址'" :visible.sync="showChooseShop" width="600px" center>
|
|
|
+ <el-input placeholder="请输入姓名/手机号/地址" v-model="searchKey" @keydown.enter.native="seachEnterFun" clearable>
|
|
|
<el-button size="medium" type="primary" @click.stop="getData" slot="append" icon="el-icon-search"></el-button>
|
|
|
</el-input>
|
|
|
<div class="shop-list">
|
|
@@ -185,8 +185,11 @@ export default {
|
|
|
createType: 1,
|
|
|
shopId: this.$store.state.userInfo.shopId,
|
|
|
productAmount: 50,
|
|
|
- chooseAddressType: 1,
|
|
|
+ invoiceTitle: "",
|
|
|
+ taxpayerId: "",
|
|
|
+ transport: "0",
|
|
|
},
|
|
|
+ chooseMapAddress: 1, // 1 发件选择地址2 收件选择地址
|
|
|
showChooseShop: false,
|
|
|
showChooseAddress: false,
|
|
|
loading: false,
|
|
@@ -243,14 +246,17 @@ export default {
|
|
|
activated() {},
|
|
|
// 方法集合
|
|
|
methods: {
|
|
|
- dbChoose(){
|
|
|
- console.log('进来了',this.curIdx);
|
|
|
+ seachEnterFun(e) {
|
|
|
+ var keyCode = window.event ? e.keyCode : e.which;
|
|
|
+ if (keyCode == 13) {
|
|
|
+ this.getData();
|
|
|
+ }
|
|
|
},
|
|
|
chooseTime(time) {
|
|
|
let min = 15; // 多少分钟后发起配送
|
|
|
let now = new Date().getTime();
|
|
|
let inputTime = new Date(time).getTime();
|
|
|
- if (inputTime < now + 60 * 1000 * min) {
|
|
|
+ if (inputTime < now + 60 * 1000 * (min - 1)) {
|
|
|
this.$message({
|
|
|
type: "error",
|
|
|
message: `至少选择${min}分钟后发单!`,
|
|
@@ -278,6 +284,7 @@ export default {
|
|
|
},
|
|
|
showShop(addressType) {
|
|
|
this.addressType = addressType;
|
|
|
+ this.searchKey = "";
|
|
|
if (this.sendType) {
|
|
|
this.addressList.forEach((v, index) => {
|
|
|
if (v.id === this.form.shopId) {
|
|
@@ -338,27 +345,42 @@ export default {
|
|
|
|
|
|
onSubmit() {
|
|
|
// 个人发件
|
|
|
-
|
|
|
if (!this.sendType) {
|
|
|
- if (
|
|
|
- !this.form.sendAddress.contact.trim() ||
|
|
|
- !this.form.sendAddress.phone.trim() ||
|
|
|
- !this.form.sendAddress.address.trim()
|
|
|
- ) {
|
|
|
+ if (!this.form.sendAddress.contact.trim()) {
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "请先输入发件人姓名!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!this.form.sendAddress.phone.trim()) {
|
|
|
return this.$message({
|
|
|
type: "error",
|
|
|
- message: "请先完善个人发件地址信息!",
|
|
|
+ message: "请先输入发件人电话!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!this.form.sendAddress.address.trim()) {
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "请先选择发件人地址!",
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- if (
|
|
|
- !this.form.receiptAddress.contact.trim() ||
|
|
|
- !this.form.receiptAddress.phone.trim() ||
|
|
|
- !this.form.receiptAddress.address.trim()
|
|
|
- ) {
|
|
|
+ if (!this.form.receiptAddress.contact.trim()) {
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "请先输入收件人姓名!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!this.form.receiptAddress.phone.trim()) {
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "请先输入收件人电话!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!this.form.receiptAddress.address.trim()) {
|
|
|
return this.$message({
|
|
|
type: "error",
|
|
|
- message: "请先完善收件地址信息!",
|
|
|
+ message: "请先选择收件人地址!",
|
|
|
});
|
|
|
}
|
|
|
let reg = new RegExp(/^([1-4][0-9]{0,1}|50)$/);
|
|
@@ -378,6 +400,19 @@ export default {
|
|
|
message: "物品价值大于0最多保留2位小数且不得超过20000元!",
|
|
|
});
|
|
|
}
|
|
|
+ let reg2 = new RegExp(/^1[3456789]\d{9}$/);
|
|
|
+ if (!reg2.test(this.form.sendAddress.phone)) {
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "发件人电话不合法,请重新输入!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!reg2.test(this.form.receiptAddress.phone)) {
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "收件人电话不合法,请重新输入!",
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
// 预约发单
|
|
|
if (this.form.takeType) {
|
|
@@ -395,12 +430,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
saveOrder() {
|
|
|
+ console.dir("form", this.form);
|
|
|
saveOrder(this.form).then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
this.$message({
|
|
|
type: "success",
|
|
|
message: "预约单保存成功!",
|
|
|
});
|
|
|
+ this.$router.push({
|
|
|
+ name: "HomeIndex",
|
|
|
+ params: { tabNum: 1 },
|
|
|
+ });
|
|
|
} else {
|
|
|
this.$message({
|
|
|
type: "error",
|
|
@@ -434,13 +474,13 @@ export default {
|
|
|
},
|
|
|
showMap(type) {
|
|
|
this.searchKey = "";
|
|
|
- this.chooseAddressType = type;
|
|
|
- if (this.sendType === 1 && this.chooseAddressType === 1) return;
|
|
|
+ this.chooseMapAddress = type;
|
|
|
+ if (this.sendType === 1 && this.chooseMapAddress === 1) return;
|
|
|
this.$refs.orderMap.chooseLocation();
|
|
|
},
|
|
|
getAddressDetail(v, lng, lat) {
|
|
|
let type = "sendAddress";
|
|
|
- if (this.chooseAddressType === 1) {
|
|
|
+ if (this.chooseMapAddress === 1) {
|
|
|
type = "sendAddress";
|
|
|
} else {
|
|
|
type = "receiptAddress";
|