|
@@ -14,9 +14,9 @@
|
|
|
|
|
|
<el-form-item :label="sendType ? '发件门店' : '发件人姓名'" required>
|
|
|
<el-input v-show="!sendType" size="small" class="input" v-model="form.sendAddress.contact" placeholder="请填写发件人姓名" clearable></el-input>
|
|
|
- <el-input v-show="sendType" disabled size="small" class="input" v-model="form.sendAddress.name" placeholder="请填写发件门店"></el-input>
|
|
|
+ <el-input v-show="sendType" disabled size="small" class="input" v-model="name" placeholder="请填写发件门店"></el-input>
|
|
|
<el-button v-show="sendType" @click="showShop(1)" class="but1 active" type="info">选择门店</el-button>
|
|
|
- <el-button v-show="!sendType" @click="showShop(1)" class="but1 active" type="info">常用地址</el-button>
|
|
|
+ <el-button v-show="!sendType" @click="showShop(2)" class="but1 active" type="info">常用地址</el-button>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="发件人电话" required>
|
|
|
<el-input size="small" class="phone-before" v-model="form.sendAddress.phone" placeholder="请填写发件人电话" clearable></el-input>
|
|
@@ -40,7 +40,7 @@
|
|
|
<el-form-item label="收件人姓名" required>
|
|
|
<el-input size="small" v-model="form.receiptAddress.contact" placeholder="请填写收件人姓名" clearable>
|
|
|
</el-input>
|
|
|
- <el-button @click="showShop(2)" class="but1 active" type="info">常用地址</el-button>
|
|
|
+ <el-button @click="showShop(3)" class="but1 active" type="info">常用地址</el-button>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="收件人电话" required>
|
|
|
<el-input size="small" class="phone-before" v-model="form.receiptAddress.phone" placeholder="请填写收件人电话" clearable></el-input>
|
|
@@ -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 ref="weight" @blur="checkWeight" size="small" class="num" v-model="form.weight" clearable>
|
|
|
+ <el-input ref="weight" 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,7 +83,7 @@
|
|
|
</el-input-number> -->
|
|
|
</el-form-item>
|
|
|
<el-form-item label="物品价值" required>
|
|
|
- <el-input class="product-amount" ref="productAmount" @blur="checkProductAmount" size="small" v-model="form.productAmount" placeholder="请输入物品价值!" clearable>
|
|
|
+ <el-input class="product-amount" ref="productAmount" size="small" v-model="form.productAmount" placeholder="请输入物品价值!" clearable>
|
|
|
<template slot="append">元</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
@@ -115,9 +115,9 @@
|
|
|
</div>
|
|
|
|
|
|
<!-- 选择门店 -->
|
|
|
- <el-dialog v-loading="loading" element-loading-text="拼命加载中" :title="sendType === 1 && addressType !== 2 ? '选择门店' : '常用地址'" :visible.sync="showChooseShop" width="600px" center>
|
|
|
+ <el-dialog v-loading="loading" element-loading-text="拼命加载中" :title="addressType === 1 ? '选择门店' : '常用地址'" :visible.sync="showChooseShop" width="600px" center>
|
|
|
<div class="shop-top">
|
|
|
- <div @click="showAddress = true" v-if="sendType === 0 || addressType === 2" class="management-address">地址管理</div>
|
|
|
+ <div @click="showAddress = true" v-if="addressType === 3 || addressType === 2" class="management-address">地址管理</div>
|
|
|
<el-input size="small" placeholder="请输入姓名/手机号/地址" v-model="searchKey" @keydown.enter.native="seachEnterFun" clearable>
|
|
|
<el-button type="primary" @click.stop="getData" slot="append" icon="el-icon-search"></el-button>
|
|
|
</el-input>
|
|
@@ -153,17 +153,18 @@ import addressManagement from "../components/settingComponents/addressManagement
|
|
|
import { getProductList } from "../api/shop.js";
|
|
|
import { sendValuation, saveOrder, getAddressList } from "../api/order.js";
|
|
|
import sendOrderPopup from "../components/orderComponents/sendOrderPopup.vue";
|
|
|
+import { send } from "process";
|
|
|
export default {
|
|
|
name: "manualCreate",
|
|
|
data() {
|
|
|
return {
|
|
|
products: [],
|
|
|
- sendType: this.$store.state.userInfo.memberType === 1 ? 0 : 1,
|
|
|
+ sendType: this.$store.state.userInfo.memberType === 1 ? 0 : 1, // 0是个人地址发单 1是门店地址发单
|
|
|
addressType: 1,
|
|
|
+ name: "",
|
|
|
form: {
|
|
|
name: "",
|
|
|
sendAddress: {
|
|
|
- name: "",
|
|
|
id: "",
|
|
|
address: "",
|
|
|
cityCode: "",
|
|
@@ -218,6 +219,8 @@ export default {
|
|
|
memberType: this.$store.state.userInfo.memberType,
|
|
|
min: 15,
|
|
|
showAddress: false,
|
|
|
+ personalSendAddressId: "",
|
|
|
+ personalReceiptAddressId: "",
|
|
|
};
|
|
|
},
|
|
|
components: {
|
|
@@ -229,12 +232,20 @@ export default {
|
|
|
computed: {},
|
|
|
// 监控data中的数据变化
|
|
|
watch: {
|
|
|
- sendType(newVal, oldVal) {
|
|
|
- this.searchKey = "";
|
|
|
- Object.keys(this.form.sendAddress).map((v) => {
|
|
|
- this.form.sendAddress[v] = "";
|
|
|
- });
|
|
|
- this.getData();
|
|
|
+ sendType: {
|
|
|
+ handler(newVal, oldVal) {
|
|
|
+ this.searchKey = "";
|
|
|
+ Object.keys(this.form.sendAddress).map((v) => {
|
|
|
+ this.form.sendAddress[v] = "";
|
|
|
+ });
|
|
|
+ if (newVal) {
|
|
|
+ this.addressType = 1;
|
|
|
+ } else {
|
|
|
+ this.addressType = 2;
|
|
|
+ }
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ // immediaty: true,
|
|
|
},
|
|
|
},
|
|
|
// 生命周期 - 创建完成(可以访问当前this实例)
|
|
@@ -244,33 +255,6 @@ export default {
|
|
|
},
|
|
|
// 方法集合
|
|
|
methods: {
|
|
|
- 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();
|
|
|
},
|
|
@@ -301,25 +285,20 @@ export default {
|
|
|
Object.keys(this.form.sendAddress).map((v) => {
|
|
|
this.form.sendAddress[v] = sendAddress[v];
|
|
|
});
|
|
|
- if (!this.sendType) {
|
|
|
- this.shopId = "";
|
|
|
- } else {
|
|
|
- this.form.shopId = sendAddress.id;
|
|
|
- }
|
|
|
+ this.name = sendAddress.name;
|
|
|
+ this.form.shopId = sendAddress.id;
|
|
|
+ } else if (this.addressType === 2) {
|
|
|
+ this.form.sendAddress = sendAddress;
|
|
|
+ this.personalSendAddressId = sendAddress.id;
|
|
|
} else {
|
|
|
this.form.receiptAddress = sendAddress;
|
|
|
+ this.personalReceiptAddressId = sendAddress.id;
|
|
|
}
|
|
|
},
|
|
|
showShop(addressType) {
|
|
|
+ // 1门店地址发单选择门店 2是个人地址发单选择常用地址 3是收件地址选择常用地址
|
|
|
this.addressType = addressType;
|
|
|
this.searchKey = "";
|
|
|
- if (this.sendType) {
|
|
|
- this.addressList.forEach((v, index) => {
|
|
|
- if (v.id === this.form.shopId) {
|
|
|
- this.curIdx = index;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
this.getData();
|
|
|
this.showChooseShop = true;
|
|
|
},
|
|
@@ -330,17 +309,57 @@ export default {
|
|
|
}).then((res) => {
|
|
|
this.loading = false;
|
|
|
if (res.code === 200) {
|
|
|
- if (this.sendType && this.addressType !== 2) {
|
|
|
+ let sendAddress;
|
|
|
+ if (this.addressType === 1) {
|
|
|
this.addressList = res.data.shop;
|
|
|
- let sendAddress = this.addressList.filter((v) => {
|
|
|
+ sendAddress = this.addressList.filter((v) => {
|
|
|
return v.id === this.form.shopId;
|
|
|
})[0];
|
|
|
+ this.curIdx = this.addressList.findIndex((v) => {
|
|
|
+ return v.id === this.form.shopId;
|
|
|
+ });
|
|
|
+ console.log("sendAddress1", sendAddress);
|
|
|
Object.keys(this.form.sendAddress).map((v) => {
|
|
|
this.form.sendAddress[v] = sendAddress[v];
|
|
|
});
|
|
|
+ this.name = sendAddress.name;
|
|
|
}
|
|
|
- if (!this.sendType || this.addressType === 2) {
|
|
|
+ if (this.addressType === 2) {
|
|
|
this.addressList = res.data.personal;
|
|
|
+ if (this.personalSendAddressId) {
|
|
|
+ sendAddress = this.addressList.filter((v) => {
|
|
|
+ return v.id === this.personalSendAddressId;
|
|
|
+ })[0];
|
|
|
+ this.curIdx = this.addressList.findIndex((v) => {
|
|
|
+ return v.id === this.personalSendAddressId;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ sendAddress = this.addressList.filter((v) => {
|
|
|
+ return v.isDefault;
|
|
|
+ })[0];
|
|
|
+ this.curIdx = this.addressList.findIndex((v) => {
|
|
|
+ return v.isDefault;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.log("sendAddress2", sendAddress);
|
|
|
+ Object.keys(this.form.sendAddress).map((v) => {
|
|
|
+ this.form.sendAddress[v] = sendAddress ? sendAddress[v] : "";
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (this.addressType === 3) {
|
|
|
+ this.addressList = res.data.personal;
|
|
|
+ let receiptAddress = this.addressList.filter((v) => {
|
|
|
+ return v.id === this.personalReceiptAddressId;
|
|
|
+ })[0];
|
|
|
+ this.curIdx = this.addressList.findIndex((v) => {
|
|
|
+ return v.id === this.personalReceiptAddressId;
|
|
|
+ });
|
|
|
+ console.log("receiptAddress", receiptAddress);
|
|
|
+ Object.keys(this.form.receiptAddress).map((v) => {
|
|
|
+ this.form.receiptAddress[v] = receiptAddress
|
|
|
+ ? receiptAddress[v]
|
|
|
+ : "";
|
|
|
+ });
|
|
|
}
|
|
|
} else {
|
|
|
this.$message({
|
|
@@ -387,9 +406,9 @@ export default {
|
|
|
message: "请输入正确的发件人电话!",
|
|
|
});
|
|
|
}
|
|
|
- // 个人发件、
|
|
|
+ // 个人发件
|
|
|
if (!this.sendType) {
|
|
|
- this.form.shopId = "";
|
|
|
+ this.form.shopId = this.$store.state.userInfo.shopId;
|
|
|
if (!this.form.sendAddress.contact.trim()) {
|
|
|
return this.$message({
|
|
|
type: "error",
|
|
@@ -428,11 +447,28 @@ export default {
|
|
|
message: "请先选择收件人地址!",
|
|
|
});
|
|
|
}
|
|
|
- if (this.checkWeight()) {
|
|
|
- return;
|
|
|
+ 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!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ 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 (this.checkProductAmount()) {
|
|
|
- return;
|
|
|
+ if (Number(this.form.productAmount) > 20000) {
|
|
|
+ this.$refs.productAmount.focus();
|
|
|
+ return this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "物品价值不得超过20000元!",
|
|
|
+ });
|
|
|
}
|
|
|
// 预约发单
|
|
|
if (this.form.takeType) {
|