|
@@ -10,13 +10,7 @@
|
|
|
<by-form :propConfig="config" 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">
|
|
|
- <template v-slot:slotField='{ value }'>
|
|
|
- <div class="updateBuyer">
|
|
|
- <el-checkbox v-model="value.slotField">更新买家收货人信息</el-checkbox>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </by-form>
|
|
|
+ <by-form :propConfig="config2" ref="infoform"></by-form>
|
|
|
</el-collapse-item>
|
|
|
<el-collapse-item title="商品订单" name="3" class="add-order-item">
|
|
|
<div class="addProductTool">
|
|
@@ -35,6 +29,7 @@
|
|
|
<div class="other-info">
|
|
|
<span>{{ row.styleId }}</span>
|
|
|
<span>{{ row.skuId }}</span>
|
|
|
+ <el-tag v-if="row.isGift == 1" size="mini" type="success">赠</el-tag>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -42,7 +37,8 @@
|
|
|
<el-input v-model="row.qty" placeholder="数量" class="number-input" size="mini" type="number" @input="qtyChange($event, row)"></el-input>
|
|
|
</template>
|
|
|
<template v-slot:price='{ row }'>
|
|
|
- <el-input v-model="row.price" placeholder="单价" class="number-input" size="mini" type="number" @input="priceChange($event, row)"></el-input>
|
|
|
+ <span v-if="row.isGift == 1">0</span>
|
|
|
+ <el-input v-else v-model="row.price" placeholder="单价" class="number-input" size="mini" type="number" @input="priceChange($event, row)"></el-input>
|
|
|
</template>
|
|
|
</by-table>
|
|
|
<div class="product-row">
|
|
@@ -76,11 +72,11 @@
|
|
|
</el-collapse-item>
|
|
|
<el-collapse-item title="订单支付情况" name="4" class="add-order-item">
|
|
|
<el-radio-group v-model="radioPay" @input="inputPay" class="payType">
|
|
|
- <el-radio :label="1">待付款</el-radio>
|
|
|
- <el-radio :label="2">快速支付&已付款</el-radio>
|
|
|
- <el-radio :label="3">手工添加支付信息</el-radio>
|
|
|
+ <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 == 3" :propConfig="payConfig" ref="payform"></by-form>
|
|
|
+ <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">
|
|
|
<by-form :propConfig="invoicesConfig" ref="invoicesform"></by-form>
|
|
@@ -100,32 +96,30 @@
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
|
-import { save } from '@/api/omsOrder'
|
|
|
-import { add,multiply } from '@/benyun/utils/accuracy'
|
|
|
+import { addOrder } from '@/api/omsOrder'
|
|
|
+import { add,multiply,subtract,divide } from '@/benyun/utils/accuracy'
|
|
|
|
|
|
@Component
|
|
|
export default class AddOrder extends Vue {
|
|
|
value=false;
|
|
|
- num=0;
|
|
|
+ isValidate = true; //验证结果
|
|
|
+ num:any=0;
|
|
|
freeAmount="";
|
|
|
- productTotal=0;
|
|
|
- productData:Array<any>=[]
|
|
|
+ productTotal:any=0;
|
|
|
userName:any='';//用户信息
|
|
|
orderValue:any={}; //新增订单值
|
|
|
- radioPay=null;
|
|
|
+ radioPay=0;
|
|
|
+ isHandleGift = false; //是否在操作赠品
|
|
|
activeNames:Array<any> =['1','2','3','4','5'];
|
|
|
config:any={
|
|
|
attr:{
|
|
|
size:'mini',
|
|
|
rules:{
|
|
|
shopName:[{
|
|
|
- required: true, message: '请输入名称', trigger: 'blur'
|
|
|
- }],
|
|
|
- sourceId:[{
|
|
|
- required: true, message: '请输入名称', trigger: 'blur'
|
|
|
+ required: true, message: '店铺名称', trigger: 'blur'
|
|
|
}],
|
|
|
orderDate:[{
|
|
|
- required: true, message: '请输入名称', trigger: 'blur'
|
|
|
+ required: true, message: '请选择订单日期', trigger: 'blur'
|
|
|
}]
|
|
|
}
|
|
|
},
|
|
@@ -148,8 +142,8 @@ export default class AddOrder extends Vue {
|
|
|
component:'by-input',
|
|
|
compConfig:{
|
|
|
attr:{
|
|
|
- placeholder:'请输入线上订单',
|
|
|
- clearable:true
|
|
|
+ placeholder:'自动生成',
|
|
|
+ readonly:true
|
|
|
}
|
|
|
}
|
|
|
},{
|
|
@@ -179,10 +173,10 @@ export default class AddOrder extends Vue {
|
|
|
span:6,
|
|
|
label:'快递公司',
|
|
|
prop:'logisticsCompany',
|
|
|
- component:'by-select',
|
|
|
+ component:'by-input',
|
|
|
compConfig:{
|
|
|
attr:{
|
|
|
- placeholder:'请选择快递公司',
|
|
|
+ placeholder:'请输入快递公司',
|
|
|
clearable:true
|
|
|
}
|
|
|
}
|
|
@@ -268,12 +262,6 @@ export default class AddOrder extends Vue {
|
|
|
clearable:true
|
|
|
}
|
|
|
}
|
|
|
- },{
|
|
|
- span:6,
|
|
|
- // label:'插槽',
|
|
|
- labelWidth:'0px',
|
|
|
- slot:true,
|
|
|
- prop:'slotField',
|
|
|
}],
|
|
|
[{
|
|
|
span:24,
|
|
@@ -298,7 +286,7 @@ export default class AddOrder extends Vue {
|
|
|
[{
|
|
|
span:24,
|
|
|
label:'详细地址',
|
|
|
- prop:'address',
|
|
|
+ prop:'receiverAddress',
|
|
|
component:'by-input',
|
|
|
compConfig:{
|
|
|
attr:{
|
|
@@ -416,17 +404,18 @@ export default class AddOrder extends Vue {
|
|
|
{
|
|
|
name: '添加赠品', icon: 'el-icon-plus', event:{
|
|
|
click:()=>{
|
|
|
- console.log('新增123')
|
|
|
+ this.isHandleGift = true;
|
|
|
+ (this.$refs.product as any).setShow(true);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- {
|
|
|
- name: '导入商品', icon: 'el-icon-bottom', event:{
|
|
|
- click:()=>{
|
|
|
- console.log('新增123')
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // {
|
|
|
+ // name: '导入商品', icon: 'el-icon-bottom', event:{
|
|
|
+ // click:()=>{
|
|
|
+ // console.log('新增123')
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
]
|
|
|
}
|
|
|
invoicesConfig:any={
|
|
@@ -678,12 +667,9 @@ export default class AddOrder extends Vue {
|
|
|
}
|
|
|
//订单支付情况单选值
|
|
|
inputPay(v:number){
|
|
|
- if(!this.orderValue.pays) this.orderValue.pays = {};
|
|
|
- this.orderValue.pays.isOrderPay = null;
|
|
|
- if(v == 1){
|
|
|
- this.orderValue.pays.isOrderPay = 0
|
|
|
- }else if(v == 2){
|
|
|
- this.orderValue.pays.isOrderPay = 1
|
|
|
+ this.orderValue.isPay = null;
|
|
|
+ if(v != 2){
|
|
|
+ this.orderValue.isPay = v;
|
|
|
}
|
|
|
}
|
|
|
mounted(){
|
|
@@ -699,47 +685,82 @@ export default class AddOrder extends Vue {
|
|
|
//抵扣金额数值变化
|
|
|
freeAmountChange(v:any){
|
|
|
this.orderValue.freeAmount = 0;
|
|
|
- if(v){
|
|
|
- if(Number(v) >= 0){
|
|
|
- this.orderValue.freeAmount = Number(v)
|
|
|
+ this.amountChange();
|
|
|
+ this.payAmountChange();
|
|
|
+ }
|
|
|
+ //商品成交总金额
|
|
|
+ totalAmount(){
|
|
|
+ let nowData = (this.$refs.table as any).getValue();
|
|
|
+ this.productTotal = 0;
|
|
|
+ for(const item of nowData){
|
|
|
+ if(Number(item.amount)){
|
|
|
+ this.productTotal = add(item.amount, this.productTotal)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.productTotal = this.productTotal.toFixed(2);
|
|
|
+ }
|
|
|
+ //具体折扣数目
|
|
|
+ amountChange(){
|
|
|
+ if(this.freeAmount){
|
|
|
+ if(Number(this.freeAmount) >= 0){
|
|
|
+ this.orderValue.freeAmount = Number(this.freeAmount)
|
|
|
}else{
|
|
|
- let arr = v.split("%");
|
|
|
+ let arr:Array<any> = this.freeAmount.split("%");
|
|
|
if(arr.length == 2 && Number(arr[0]) > 0){
|
|
|
- let nowData = (this.$refs.table as any).getValue();
|
|
|
- let totalPrice:any = 0;
|
|
|
- for(const item of nowData){
|
|
|
- if(Number(item.amount)){
|
|
|
- totalPrice = add(item.amount, totalPrice)
|
|
|
- }
|
|
|
- }
|
|
|
- this.orderValue.freeAmount = multiply(totalPrice,Number(arr[0]))
|
|
|
+ const n = divide(Number(arr[0]),100)
|
|
|
+ this.orderValue.freeAmount = multiply(this.productTotal,n)
|
|
|
}
|
|
|
}
|
|
|
+ this.orderValue.freeAmount = this.orderValue.freeAmount.toFixed(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //应付总金额
|
|
|
+ payAmountChange(){
|
|
|
+ const freight = Number(this.orderValue.freight)?Number(this.orderValue.freight):0;
|
|
|
+ const freeAmount = Number(this.orderValue.freeAmount)?Number(this.orderValue.freeAmount):0;
|
|
|
+ let t = subtract(this.productTotal, freeAmount);
|
|
|
+ this.orderValue.payAmount = subtract(t, freight);
|
|
|
+ this.orderValue.payAmount = this.orderValue.payAmount.toFixed(2);
|
|
|
+ }
|
|
|
+ //商品总数量
|
|
|
+ totalNum(){
|
|
|
+ let nowData = (this.$refs.table as any).getValue();
|
|
|
+ this.num = 0;
|
|
|
+ for(const item of nowData){
|
|
|
+ if(Number(item.qty)){
|
|
|
+ this.num = add(item.qty, this.num)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //基本信息表单数据变化
|
|
|
formChangeBase(data:any){
|
|
|
if(!this.orderValue[data.code]){
|
|
|
Vue.set(this.orderValue, data.code, data.value);
|
|
|
}else{
|
|
|
this.orderValue[data.code] = data.value;
|
|
|
}
|
|
|
-
|
|
|
+ if(data.code == 'freight'){
|
|
|
+ this.payAmountChange();
|
|
|
+ }
|
|
|
}
|
|
|
+ //确定新增的商品
|
|
|
confirmProduct(data:Array<any>){
|
|
|
let nowData = (this.$refs.table as any).getValue();
|
|
|
let ids='';
|
|
|
if(data.length > 0){
|
|
|
for(const item of data){
|
|
|
let t = true;
|
|
|
- for(const t_item of nowData){
|
|
|
- if(item.id == t_item.skuId){
|
|
|
- if(!ids){
|
|
|
- ids = item.id
|
|
|
- }else{
|
|
|
- ids = ids + ',' + item.id
|
|
|
+ if(!this.isHandleGift){
|
|
|
+ for(const t_item of nowData){
|
|
|
+ if(item.id == t_item.skuId){
|
|
|
+ if(!ids){
|
|
|
+ ids = item.id
|
|
|
+ }else{
|
|
|
+ ids = ids + ',' + item.id
|
|
|
+ }
|
|
|
+ t = false;
|
|
|
+ break;
|
|
|
}
|
|
|
- t = false;
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
if(t){
|
|
@@ -748,7 +769,14 @@ export default class AddOrder extends Vue {
|
|
|
obj.skuId = item.id; //商品编码
|
|
|
obj.styleId = item.newNumber; //款式编码
|
|
|
obj.qty = 1;
|
|
|
- obj.price = item.price; //单价
|
|
|
+ if(this.isHandleGift){
|
|
|
+ obj.price = 0; //单价
|
|
|
+ obj.isGift = 1;
|
|
|
+ }else{
|
|
|
+ obj.price = item.price; //单价
|
|
|
+ obj.isGift = 0;
|
|
|
+ }
|
|
|
+
|
|
|
obj.basePrice = item.basePrice; //原价
|
|
|
obj.amount = item.price;
|
|
|
obj.stock = item.stock;
|
|
@@ -756,6 +784,10 @@ export default class AddOrder extends Vue {
|
|
|
}
|
|
|
}
|
|
|
(this.$refs.table as any).setValue(nowData);
|
|
|
+ this.totalAmount();
|
|
|
+ this.amountChange();
|
|
|
+ this.payAmountChange();
|
|
|
+ this.totalNum();
|
|
|
if(ids){
|
|
|
this.$alert('编码“'+ids+'”已添加!', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
@@ -763,22 +795,34 @@ export default class AddOrder extends Vue {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ this.isHandleGift = false;
|
|
|
}
|
|
|
+ //数量的变化
|
|
|
qtyChange(v:any,row:any){
|
|
|
if(v && row.price){
|
|
|
- row.amount = v*row.price
|
|
|
+ row.amount = multiply(v,row.price)
|
|
|
}else{
|
|
|
row.amount = 0
|
|
|
}
|
|
|
+ this.totalAmount();
|
|
|
+ this.amountChange();
|
|
|
+ this.payAmountChange();
|
|
|
+ this.totalNum();
|
|
|
}
|
|
|
+ //单价的变化
|
|
|
priceChange(v:any,row:any){
|
|
|
if(v && row.qty){
|
|
|
- row.amount = v*row.qty
|
|
|
+ row.amount =multiply(v,row.qty)
|
|
|
}else{
|
|
|
row.amount = 0
|
|
|
}
|
|
|
+ this.totalAmount();
|
|
|
+ this.amountChange();
|
|
|
+ this.payAmountChange();
|
|
|
}
|
|
|
+ //清楚整个订单数据
|
|
|
clearValue(){
|
|
|
+ this.orderValue = {};
|
|
|
(this.$refs.baseform as any).setValue({});
|
|
|
(this.$refs.infoform as any).setValue({});
|
|
|
(this.$refs.table as any).setValue([]);
|
|
@@ -786,9 +830,12 @@ export default class AddOrder extends Vue {
|
|
|
(this.$refs.payform as any).setValue({});
|
|
|
}
|
|
|
(this.$refs.invoicesform as any).setValue({});
|
|
|
+ this.num = 0;
|
|
|
+ this.productTotal = 0;
|
|
|
+ this.radioPay = 0;
|
|
|
}
|
|
|
getOrderValue(){
|
|
|
- this.orderValue = {};
|
|
|
+ // this.orderValue = {};
|
|
|
let r = true;
|
|
|
(this.$refs.baseform as any).validate({noMsg:true}).then(()=>{
|
|
|
let baseInfo = (this.$refs.baseform as any).getValue();
|
|
@@ -820,16 +867,12 @@ export default class AddOrder extends Vue {
|
|
|
});
|
|
|
if(this.$refs.table){
|
|
|
let productOrder:Array<any> = (this.$refs.table as any).getValue();
|
|
|
- this.orderValue.item = productOrder;
|
|
|
+ this.orderValue.items = productOrder;
|
|
|
}
|
|
|
- this.orderValue.status = null;
|
|
|
- if(this.radioPay != 3){
|
|
|
- if(this.radioPay == 1){
|
|
|
- this.orderValue.status = 'WaitPay'
|
|
|
- }else if(this.radioPay == 2){
|
|
|
- this.orderValue.status = 'WaitConfirm'
|
|
|
- }
|
|
|
- }else{
|
|
|
+ if(this.radioPay != 2){
|
|
|
+ this.orderValue.isPay = this.radioPay;
|
|
|
+ }
|
|
|
+ if(this.radioPay == 2){
|
|
|
(this.$refs.payform as any).validate({noMsg:true}).then(()=>{
|
|
|
this.orderValue.pays = [];
|
|
|
let payFormValue = (this.$refs.payform as any).getValue();
|
|
@@ -847,16 +890,25 @@ export default class AddOrder extends Vue {
|
|
|
let invoiceValue = (this.$refs.invoicesform as any).getValue();
|
|
|
this.orderValue.invoices=[];
|
|
|
this.orderValue.invoices.push(invoiceValue);
|
|
|
+ this.isValidate = r;
|
|
|
}
|
|
|
+ //确定
|
|
|
btn(){
|
|
|
this.getOrderValue();
|
|
|
setTimeout(()=>{
|
|
|
- save({data:this.orderValue}).then((res:any) => {
|
|
|
- (this as any).$message({
|
|
|
- message: '订单添加成功!',
|
|
|
- type: 'success',
|
|
|
- })
|
|
|
- }).catch((err:any) => {})
|
|
|
+ if(this.isValidate){
|
|
|
+ if(this.orderValue.orderDate){
|
|
|
+ this.orderValue.orderDate = this.orderValue.orderDate + ' 00:00:00'
|
|
|
+ }
|
|
|
+ this.orderValue.receiverCountryCode = '86';
|
|
|
+ this.orderValue.receiverCountry="中华人民共和国";
|
|
|
+ addOrder(this.orderValue).then((res:any) => {
|
|
|
+ (this as any).$message({
|
|
|
+ message: '订单添加成功!',
|
|
|
+ type: 'success',
|
|
|
+ })
|
|
|
+ }).catch((err:any) => {})
|
|
|
+ }
|
|
|
},500)
|
|
|
|
|
|
}
|