|
@@ -65,7 +65,7 @@
|
|
|
<div class="preferential">
|
|
|
<div class="pre-title">抵扣金额<i class="el-icon-info" title="支持输入数字和百分比。若输入百分比,将自动计算折扣金额=商品成交总金额*百分比(举例:打9折,请输入10%),
|
|
|
只在订单创建时计算一次,在订单创建后修改商品价格不会自动计算,运费不参与折扣。"></i>:</div>
|
|
|
- <el-input v-model="freeAmount" class="freeAmount" placeholder="请输入" size="mini" @input="freeAmountChange"></el-input>
|
|
|
+ <vxe-input v-model="freeAmount" class="freeAmount" placeholder="请输入" type="number" size="mini" @input="freeAmountChange"></vxe-input>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -81,11 +81,11 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<template v-slot:qty='{ row }'>
|
|
|
- <el-input v-model="row.qty" placeholder="数量" class="number-input" size="mini" type="number" @input="qtyChange($event, row)"></el-input>
|
|
|
+ <vxe-input v-model="row.qty" placeholder="数量" align="center" size="mini" type="integer" @input="qtyChange($event, row)"></vxe-input>
|
|
|
</template>
|
|
|
<template v-slot:price='{ row }'>
|
|
|
<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>
|
|
|
+ <vxe-input v-else v-model="row.price" placeholder="单价" align="center" size="mini" type="number" @input="priceChange($event, row)"></vxe-input>
|
|
|
</template>
|
|
|
</by-table>
|
|
|
<div class="product-row">
|
|
@@ -138,6 +138,7 @@
|
|
|
</el-collapse>
|
|
|
<product-sku-modal ref="product" :mulit="true" @confirm="confirmProduct" />
|
|
|
<product-sku-modal ref="productGift" :mulit="true" @confirm="confirmProductGift" />
|
|
|
+ <add-product-modal ref="addProductModal" @handleSuccess="handleSuccess" />
|
|
|
</template>
|
|
|
<template #footer v-if="!orderValue.id">
|
|
|
<div class="btn">
|
|
@@ -151,10 +152,10 @@
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
|
-import { addOrder,saveBaseOrder } from '@/api/omsOrder'
|
|
|
+import { addOrder,saveBaseOrder,single,delItem } from '@/api/omsOrder'
|
|
|
import { add,multiply,subtract,divide } from '@/benyun/utils/accuracy'
|
|
|
-
|
|
|
-@Component
|
|
|
+import AddProductModal from "./addProductModal.vue";
|
|
|
+@Component({components:{AddProductModal}})
|
|
|
export default class AddOrder extends Vue {
|
|
|
value=false;
|
|
|
num:any=0;
|
|
@@ -498,11 +499,13 @@ export default class AddOrder extends Vue {
|
|
|
title:'成交金额',
|
|
|
field:'amount',
|
|
|
width:100
|
|
|
- },{
|
|
|
- title:'库存',
|
|
|
- field:'stock',
|
|
|
- width:100
|
|
|
- },{
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // title:'库存',
|
|
|
+ // field:'stock',
|
|
|
+ // width:100
|
|
|
+ // },
|
|
|
+ {
|
|
|
title:'操作',
|
|
|
action:true,
|
|
|
plugins:[{
|
|
@@ -522,14 +525,15 @@ export default class AddOrder extends Vue {
|
|
|
{
|
|
|
name: '新增商品', icon: 'el-icon-plus', event:{
|
|
|
click:()=>{
|
|
|
- (this.$refs.product as any).setShow(true);
|
|
|
+ this.toolAddProduct()
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
name: '添加赠品', icon: 'el-icon-plus', event:{
|
|
|
click:()=>{
|
|
|
- (this.$refs.productGift as any).setShow(true);
|
|
|
+ this.toolAddGift();
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -846,6 +850,47 @@ export default class AddOrder extends Vue {
|
|
|
created(){
|
|
|
this.userInfo = this.$store.getters.userInfo;
|
|
|
}
|
|
|
+ handleSuccess(){
|
|
|
+ this.$emit('handleSuccess');
|
|
|
+ this.getData();
|
|
|
+ }
|
|
|
+ //添加商品
|
|
|
+ toolAddProduct(){
|
|
|
+ if(this.orderValue.id){
|
|
|
+ (this.$refs.addProductModal as any).setBillValue(this.orderValue.id);
|
|
|
+ (this.$refs.addProductModal as any).setShow(true);
|
|
|
+ (this.$refs.addProductModal as any).setGift(false);
|
|
|
+ }else{
|
|
|
+ (this.$refs.product as any).setShow(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //添加赠品
|
|
|
+ toolAddGift(){
|
|
|
+ if(this.orderValue.id){
|
|
|
+ (this.$refs.addProductModal as any).setBillValue([this.orderValue.id]);
|
|
|
+ (this.$refs.addProductModal as any).setShow(true);
|
|
|
+ (this.$refs.addProductModal as any).setGift(true);
|
|
|
+ }else{
|
|
|
+ (this.$refs.productGift as any).setShow(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取数据
|
|
|
+ getData(){
|
|
|
+ if(!this.orderValue.id){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.load = true;
|
|
|
+ single({
|
|
|
+ id:this.orderValue.id
|
|
|
+ }).then((res:any) => {
|
|
|
+ this.load = false;
|
|
|
+ this.orderValue = res.data;
|
|
|
+ this.show();
|
|
|
+ this.$forceUpdate();
|
|
|
+ }).catch(()=>{
|
|
|
+ this.load = false
|
|
|
+ })
|
|
|
+ }
|
|
|
show(){
|
|
|
this.baseConfig = (this as any).$lodash.cloneDeep(this.config);
|
|
|
this.buyerInfoConfig = (this as any).$lodash.cloneDeep(this.config2);
|
|
@@ -990,7 +1035,7 @@ export default class AddOrder extends Vue {
|
|
|
this.num = 0;
|
|
|
for(const item of nowData){
|
|
|
if(Number(item.qty)){
|
|
|
- this.num = add(item.qty, this.num)
|
|
|
+ this.num = add(Number(item.qty), Number(this.num))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1080,26 +1125,44 @@ export default class AddOrder extends Vue {
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
- let data = (this.$refs.table as any).getValue();
|
|
|
- let index = -1;
|
|
|
- for(const item of data){
|
|
|
- index ++;
|
|
|
- if(row.skuId == item.skuId && row.name == item.name && row.isGift == item.isGift){
|
|
|
- break;
|
|
|
+ let del=()=>{
|
|
|
+ let data = (this.$refs.table as any).getValue();
|
|
|
+ let index = -1;
|
|
|
+ for(const item of data){
|
|
|
+ index ++;
|
|
|
+ if(row.skuId == item.skuId && row.name == item.name && row.isGift == item.isGift){
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ data.splice(index,1);
|
|
|
+ (this.$refs.table as any).setValue(data);
|
|
|
+ this.totalAmount();
|
|
|
+ this.amountChange();
|
|
|
+ this.payAmountChange();
|
|
|
+ this.totalNum();
|
|
|
}
|
|
|
- data.splice(index,1);
|
|
|
- (this.$refs.table as any).setValue(data);
|
|
|
- this.totalAmount();
|
|
|
- this.amountChange();
|
|
|
- this.payAmountChange();
|
|
|
- this.totalNum();
|
|
|
+ if(row.id){
|
|
|
+ this.load = true;
|
|
|
+ delItem({
|
|
|
+ itemId:row.id,
|
|
|
+ id:this.orderValue.id
|
|
|
+ }).then(()=>{
|
|
|
+ this.load = false;
|
|
|
+ del();
|
|
|
+ this.$emit('handleSuccess');
|
|
|
+ }).catch(()=>{
|
|
|
+ this.load = false;
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ del();
|
|
|
+ }
|
|
|
+
|
|
|
}).catch(() => { });
|
|
|
}
|
|
|
//数量的变化
|
|
|
qtyChange(v:any,row:any){
|
|
|
if(v && row.price){
|
|
|
- row.amount = multiply(v,row.price)
|
|
|
+ row.amount = multiply(v,Number(row.price))
|
|
|
}else{
|
|
|
row.amount = 0
|
|
|
}
|
|
@@ -1111,7 +1174,7 @@ export default class AddOrder extends Vue {
|
|
|
//单价的变化
|
|
|
priceChange(v:any,row:any){
|
|
|
if(v && row.qty){
|
|
|
- row.amount =multiply(v,row.qty)
|
|
|
+ row.amount =multiply(v,Number(row.qty))
|
|
|
}else{
|
|
|
row.amount = 0
|
|
|
}
|