|
@@ -1,16 +1,30 @@
|
|
|
<template>
|
|
|
<vxe-modal v-model="value" id="addOrder" @show="show" width="70%" height="80%" min-width="460" min-height="320"
|
|
|
- show-zoom resize transfer show-footer>
|
|
|
+ show-zoom resize transfer :show-footer="!orderValue.id" @hide="hide" v-loading="load">
|
|
|
<template #title>
|
|
|
<span>创建新订单</span>
|
|
|
</template>
|
|
|
<template #default>
|
|
|
<el-collapse v-model="activeNames">
|
|
|
<el-collapse-item title="基本信息" name="1" class="add-order-item">
|
|
|
- <by-form :propConfig="config" ref="baseform" @formChange="formChangeBase"></by-form>
|
|
|
+ <by-form :propConfig="baseConfig" ref="baseform" @formChange="formChangeBase"></by-form>
|
|
|
</el-collapse-item>
|
|
|
<el-collapse-item title="买家信息" name="2" class="add-order-item">
|
|
|
- <by-form :propConfig="config2" ref="infoform"></by-form>
|
|
|
+ <by-form :propConfig="buyerInfoConfig" ref="infoform"></by-form>
|
|
|
+ </el-collapse-item>
|
|
|
+ <el-collapse-item title="发票信息" name="5" class="add-order-item" v-if="orderValue.id">
|
|
|
+ <by-form :propConfig="invoicesConfig" ref="invoicesform"></by-form>
|
|
|
+ </el-collapse-item>
|
|
|
+ <div class="btn-save" v-if="orderValue.id">
|
|
|
+ <el-button type="primary" size="small" @click="saveBase">保存基本信息及收获地址</el-button>
|
|
|
+ </div>
|
|
|
+ <el-collapse-item title="订单支付情况" name="4" class="add-order-item" v-if="orderValue.id">
|
|
|
+ <el-radio-group v-model="radioPay" @input="inputPay" class="payType">
|
|
|
+ <el-radio :label="0">待付款</el-radio>
|
|
|
+ <el-radio :label="1">快速支付&已付款</el-radio>
|
|
|
+ <el-radio :label="2">手工添加支付信息</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ <by-form v-if="radioPay == 2" :propConfig="payConfig" ref="payform"></by-form>
|
|
|
</el-collapse-item>
|
|
|
<el-collapse-item title="商品订单" name="3" class="add-order-item">
|
|
|
<div class="addProductTool">
|
|
@@ -70,7 +84,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-collapse-item>
|
|
|
- <el-collapse-item title="订单支付情况" name="4" class="add-order-item">
|
|
|
+ <el-collapse-item title="订单支付情况" name="4" class="add-order-item" v-if="!orderValue.id">
|
|
|
<el-radio-group v-model="radioPay" @input="inputPay" class="payType">
|
|
|
<el-radio :label="0">待付款</el-radio>
|
|
|
<el-radio :label="1">快速支付&已付款</el-radio>
|
|
@@ -78,14 +92,14 @@
|
|
|
</el-radio-group>
|
|
|
<by-form v-if="radioPay == 2" :propConfig="payConfig" ref="payform"></by-form>
|
|
|
</el-collapse-item>
|
|
|
- <el-collapse-item title="发票信息" name="5" class="add-order-item">
|
|
|
+ <el-collapse-item title="发票信息" name="5" class="add-order-item" v-if="!orderValue.id">
|
|
|
<by-form :propConfig="invoicesConfig" ref="invoicesform"></by-form>
|
|
|
</el-collapse-item>
|
|
|
</el-collapse>
|
|
|
<productDialog ref="product" @confirm="confirmProduct" />
|
|
|
<productDialog ref="productGift" @confirm="confirmProductGift" />
|
|
|
</template>
|
|
|
- <template #footer>
|
|
|
+ <template #footer v-if="!orderValue.id">
|
|
|
<div class="btn">
|
|
|
<el-button type="primary" size="small" @click="btn('continue')">确定并继续</el-button>
|
|
|
<el-button type="primary" size="small" @click="btn">确定</el-button>
|
|
@@ -97,19 +111,22 @@
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
|
-import { addOrder,getSingleData } from '@/api/omsOrder'
|
|
|
+import { addOrder,saveBaseOrder } from '@/api/omsOrder'
|
|
|
import { add,multiply,subtract,divide } from '@/benyun/utils/accuracy'
|
|
|
|
|
|
@Component
|
|
|
export default class AddOrder extends Vue {
|
|
|
value=false;
|
|
|
num:any=0;
|
|
|
+ load = false;
|
|
|
freeAmount="";
|
|
|
productTotal:any=0;
|
|
|
userName:any='';//用户信息
|
|
|
orderValue:any={}; //新增订单值
|
|
|
radioPay=0;
|
|
|
- activeNames:Array<any> =['1','2','3','4','5'];
|
|
|
+ activeNames:Array<any> =['1','2','3','4','5','save'];
|
|
|
+ baseConfig:any={};
|
|
|
+ buyerInfoConfig:any={};
|
|
|
config:any={
|
|
|
attr:{
|
|
|
size:'mini',
|
|
@@ -663,12 +680,10 @@ export default class AddOrder extends Vue {
|
|
|
}
|
|
|
setDetail(data:any){
|
|
|
this.orderValue = data;
|
|
|
- let infoConfig = (this as any).$lodash.cloneDeep(this.config);
|
|
|
- for(const col of infoConfig.columns){
|
|
|
- for(const item of col){
|
|
|
- if(!item.compConfig.attr) item.compConfig.attr = {};
|
|
|
- item.compConfig.attr.readonly = true;
|
|
|
- }
|
|
|
+ if(this.orderValue.isPay == 0 || this.orderValue.isPay == 1){
|
|
|
+ this.radioPay = this.orderValue.isPay
|
|
|
+ }else{
|
|
|
+ this.radioPay = 2;
|
|
|
}
|
|
|
}
|
|
|
//订单支付情况单选值
|
|
@@ -682,36 +697,42 @@ export default class AddOrder extends Vue {
|
|
|
this.userName = this.$store.getters.name;
|
|
|
}
|
|
|
show(){
|
|
|
+ this.baseConfig = (this as any).$lodash.cloneDeep(this.config);
|
|
|
+ this.buyerInfoConfig = (this as any).$lodash.cloneDeep(this.config2);
|
|
|
+
|
|
|
if(this.orderValue.id){
|
|
|
let data = this.orderValue;
|
|
|
+ this.freeAmount = this.orderValue.freeAmount;
|
|
|
//基本信息
|
|
|
let info:any={};
|
|
|
info.shopName = data.shopName;
|
|
|
info.sourceId = data.sourceId;
|
|
|
info.orderDate = data.orderDate;
|
|
|
- info.freight = data.freight;
|
|
|
+ info.freight = Number(data.freight)?Number(data.freight):0;
|
|
|
info.logisticsCompany = data.logisticsCompany;
|
|
|
info.createBy = data.createBy;
|
|
|
info.note = data.note;
|
|
|
info.buyerMessage = data.buyerMessage;
|
|
|
info.remark = data.remark;
|
|
|
+ this.baseConfig.attr.data = info;
|
|
|
(this.$refs.baseform as any).setValue(info);
|
|
|
//买家
|
|
|
let buyerInfo:any={};
|
|
|
buyerInfo.buyerId = data.buyerId;
|
|
|
buyerInfo.receiverName = data.receiverName;
|
|
|
- buyerInfo.province=data.receiverProvince;//省
|
|
|
- buyerInfo.provinceCode=data.receiverProvinceCode; //省编码
|
|
|
- buyerInfo.city=data.receiverCity; //市
|
|
|
- buyerInfo.cityCode=data.receiverCityCode; //市编码
|
|
|
- buyerInfo.county=data.receiverDistrict; //县/区
|
|
|
- buyerInfo.countyCode=data.receiverDistrictCode; //县/区编码
|
|
|
- buyerInfo.townCode=data.receiverTownCode;
|
|
|
- buyerInfo.town=data.receiverTown;
|
|
|
+ buyerInfo.receiverProvince=data.receiverProvince;//省
|
|
|
+ buyerInfo.receiverProvinceCode=data.receiverProvinceCode; //省编码
|
|
|
+ buyerInfo.receiverCity=data.receiverCity; //市
|
|
|
+ buyerInfo.receiverCityCode=data.receiverCityCode; //市编码
|
|
|
+ buyerInfo.receiverDistrict=data.receiverDistrict; //县/区
|
|
|
+ buyerInfo.receiverDistrictCode=data.receiverDistrictCode; //县/区编码
|
|
|
+ buyerInfo.receiverTownCode=data.receiverTownCode;
|
|
|
+ buyerInfo.receiverTown=data.receiverTown;
|
|
|
buyerInfo.receiverAddress = data.receiverAddress;
|
|
|
buyerInfo.receiverPhone = data.receiverPhone;
|
|
|
buyerInfo.receiverMobile = data.receiverMobile;
|
|
|
buyerInfo.receiverZip = data.receiverZip;
|
|
|
+ this.buyerInfoConfig.attr.data = buyerInfo;
|
|
|
(this.$refs.infoform as any).setValue(buyerInfo);
|
|
|
//商品
|
|
|
const productData:Array<any> = data.items ? data.items : [];
|
|
@@ -731,14 +752,41 @@ export default class AddOrder extends Vue {
|
|
|
if(data.invoices && data.invoices[0]){
|
|
|
(this.$refs.invoicesform as any).setValue(data.invoices[0]);
|
|
|
}
|
|
|
+
|
|
|
+ for(let col of this.baseConfig.columns){
|
|
|
+ for(let item of col){
|
|
|
+ if(item.prop != 'freight'){
|
|
|
+ if(!item.compConfig.attr) item.compConfig.attr = {};
|
|
|
+ item.compConfig.attr.disabled = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(this.orderValue.isPay != 0){
|
|
|
+ for(let col of this.buyerInfoConfig.columns){
|
|
|
+ for(let item of col){
|
|
|
+ if(!item.compConfig.attr) item.compConfig.attr = {};
|
|
|
+ item.compConfig.attr.disabled = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.totalAmount();
|
|
|
+ this.amountChange();
|
|
|
+ this.payAmountChange();
|
|
|
+ this.totalNum();
|
|
|
+
|
|
|
}else{
|
|
|
let value:any = (this.$refs.baseform as any).getValue();
|
|
|
value.createBy = this.userName;
|
|
|
(this.$refs.baseform as any).setValue(value);
|
|
|
}
|
|
|
-
|
|
|
+ (this.$refs.baseform as any).setConfig(this.baseConfig);
|
|
|
+ (this.$refs.infoform as any).setConfig(this.buyerInfoConfig);
|
|
|
|
|
|
}
|
|
|
+ hide(){
|
|
|
+ this.clearValue();
|
|
|
+ }
|
|
|
//抵扣金额数值变化
|
|
|
freeAmountChange(v:any){
|
|
|
this.orderValue.freeAmount = 0;
|
|
@@ -929,29 +977,34 @@ export default class AddOrder extends Vue {
|
|
|
this.radioPay = 0;
|
|
|
this.freeAmount = '';
|
|
|
}
|
|
|
- getOrderValue(){
|
|
|
+ getOrderValue(n?:string){
|
|
|
// this.orderValue = {};
|
|
|
return new Promise((resolve:Function, reject:Function) => {
|
|
|
let r = true;
|
|
|
- let a = (this.$refs.baseform as any).getValue();
|
|
|
//基本信息
|
|
|
(this.$refs.baseform as any).validate({noMsg:true}).then(()=>{
|
|
|
let baseInfo = (this.$refs.baseform as any).getValue();
|
|
|
for(const key in baseInfo){
|
|
|
this.orderValue[key] = baseInfo[key]
|
|
|
}
|
|
|
-
|
|
|
- //卖家信息
|
|
|
+ if(this.orderValue.orderDate){
|
|
|
+ this.orderValue.orderDate = this.orderValue.orderDate + ' 00:00:00'
|
|
|
+ }
|
|
|
+ //买家信息
|
|
|
(this.$refs.infoform as any).validate({noMsg:true}).then(()=>{
|
|
|
let infoValue = (this.$refs.infoform as any).getValue();
|
|
|
for(const key in infoValue){
|
|
|
this.orderValue[key] = infoValue[key]
|
|
|
}
|
|
|
+ if(n == 'base'){
|
|
|
+ resolve();
|
|
|
+ return
|
|
|
+ }
|
|
|
//商品
|
|
|
let productOrder:Array<any> = [];
|
|
|
if(this.$refs.table){
|
|
|
productOrder = (this.$refs.table as any).getValue();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if(productOrder.length > 0){
|
|
|
this.orderValue.items = productOrder;
|
|
@@ -989,6 +1042,7 @@ export default class AddOrder extends Vue {
|
|
|
}else{
|
|
|
resolve();
|
|
|
}
|
|
|
+
|
|
|
}).catch(()=>{
|
|
|
if(r){
|
|
|
(this as any).$message({
|
|
@@ -1019,25 +1073,43 @@ export default class AddOrder extends Vue {
|
|
|
//确定
|
|
|
btn(n?:string){
|
|
|
this.getOrderValue().then(()=>{
|
|
|
- if(this.orderValue.orderDate){
|
|
|
- this.orderValue.orderDate = this.orderValue.orderDate + ' 00:00:00'
|
|
|
- }
|
|
|
+
|
|
|
this.orderValue.receiverCountryCode = '86';
|
|
|
this.orderValue.receiverCountry="中华人民共和国";
|
|
|
+ this.load = true;
|
|
|
addOrder(this.orderValue).then((res:any) => {
|
|
|
if(n != 'continue'){
|
|
|
this.value = false;
|
|
|
}
|
|
|
-
|
|
|
+ this.load = false;
|
|
|
(this as any).$message({
|
|
|
message: '订单添加成功!',
|
|
|
type: 'success',
|
|
|
})
|
|
|
- this.clearValue();
|
|
|
- this.$emit('addSuccess');
|
|
|
- }).catch((err:any) => {})
|
|
|
+ this.$emit('handleSuccess');
|
|
|
+ }).catch((err:any) => {
|
|
|
+ this.load = false;
|
|
|
+ })
|
|
|
}).catch((err:any) => {})
|
|
|
}
|
|
|
+
|
|
|
+ //保存基本信息及守护地址
|
|
|
+ saveBase(){
|
|
|
+ this.getOrderValue('base').then(()=>{
|
|
|
+ this.load = true;
|
|
|
+ saveBaseOrder(this.orderValue).then(() => {
|
|
|
+ this.load = false;
|
|
|
+ (this as any).$message({
|
|
|
+ message: '订单修改成功!',
|
|
|
+ type: 'success',
|
|
|
+ })
|
|
|
+ this.$emit('handleSuccess');
|
|
|
+ }).catch((err:any) => {
|
|
|
+ this.load = false;
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|
|
@@ -1047,6 +1119,13 @@ export default class AddOrder extends Vue {
|
|
|
display: flex;
|
|
|
justify-content: flex-end;
|
|
|
}
|
|
|
+.btn-save{
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ padding: 16px 0;
|
|
|
+ border-bottom: 1px solid #e6ebf5;
|
|
|
+}
|
|
|
.updateBuyer{
|
|
|
padding: 0 16px;
|
|
|
}
|