|
@@ -21,12 +21,14 @@
|
|
|
|
|
|
<script lang="ts">
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
|
-import { productCommissionSave,productCommissionQueryByProductId } from '@/api/distribution'
|
|
|
+import { productCommissionSave,productCommissionQueryByProductId,productCommissionUpdate } from '@/api/distribution'
|
|
|
import { saleRankList } from '@/api/distribution'
|
|
|
+import { v } from "vxe-table";
|
|
|
@Component({components:{}})
|
|
|
export default class CommissionModal extends Vue {
|
|
|
value=false;
|
|
|
load=false;
|
|
|
+ productCommissionValue:any=null;
|
|
|
val1:any=0;
|
|
|
val2:any=0;
|
|
|
data:any=[];
|
|
@@ -39,26 +41,26 @@ export default class CommissionModal extends Vue {
|
|
|
this.getCommissionValue()
|
|
|
}
|
|
|
minValChange(){
|
|
|
- if(!this.commissionVal){
|
|
|
- this.val1 = 0
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.val1 < this.commissionVal.minRate){
|
|
|
+ // if(!this.commissionVal){
|
|
|
+ // this.val1 = 0
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ if(this.commissionVal && this.val1 < this.commissionVal.minRate){
|
|
|
this.val1 = this.commissionVal.minRate
|
|
|
}
|
|
|
- if(this.val1 > this.commissionVal.maxRate){
|
|
|
+ if(this.commissionVal && this.val1 > this.commissionVal.maxRate){
|
|
|
this.val1 = this.commissionVal.maxRate
|
|
|
}
|
|
|
}
|
|
|
maxValChange(){
|
|
|
- if(!this.commissionVal){
|
|
|
- this.val2 = 0
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.val2 < this.commissionVal.minRate){
|
|
|
+ // if(!this.commissionVal){
|
|
|
+ // this.val2 = 0
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ if(this.commissionVal && this.val2 < this.commissionVal.minRate){
|
|
|
this.val2 = this.commissionVal.minRate
|
|
|
}
|
|
|
- if(this.val2 > this.commissionVal.maxRate){
|
|
|
+ if(this.commissionVal && this.val2 > this.commissionVal.maxRate){
|
|
|
this.val2 = this.commissionVal.maxRate
|
|
|
}
|
|
|
}
|
|
@@ -68,27 +70,45 @@ export default class CommissionModal extends Vue {
|
|
|
}
|
|
|
show(){}
|
|
|
hide(){
|
|
|
- this.val1 = null
|
|
|
- this.val2 = null
|
|
|
+ this.val1 = null;
|
|
|
+ this.val2 = null;
|
|
|
+ this.productCommissionValue=null;
|
|
|
}
|
|
|
queryProductCommission(){
|
|
|
productCommissionQueryByProductId({productId:this.data.id}).then((res:any) => {
|
|
|
this.val1 = res.data.commission1;
|
|
|
this.val2 = res.data.commission2;
|
|
|
+ this.productCommissionValue = res.data;
|
|
|
}).catch(() =>{})
|
|
|
}
|
|
|
btn(){
|
|
|
- productCommissionSave({
|
|
|
- productId:this.data.id,
|
|
|
- commission1:this.val1,
|
|
|
- commission2:this.val2
|
|
|
- }).then(() => {
|
|
|
- this.$message({
|
|
|
- message:'商品“' + this.data.skuTitle + '”佣金设置成功!',
|
|
|
- type:'success'
|
|
|
- });
|
|
|
- this.value = false
|
|
|
- }).catch(() => {})
|
|
|
+ if(this.productCommissionValue && this.productCommissionValue.id){
|
|
|
+ productCommissionUpdate({
|
|
|
+ id:this.productCommissionValue.id,
|
|
|
+ productId:this.data.id,
|
|
|
+ commission1:this.val1,
|
|
|
+ commission2:this.val2
|
|
|
+ }).then(() => {
|
|
|
+ this.$message({
|
|
|
+ message:'商品“' + this.data.skuTitle + '”佣金修改成功!',
|
|
|
+ type:'success'
|
|
|
+ });
|
|
|
+ this.value = false
|
|
|
+ }).catch(() => {})
|
|
|
+ }else{
|
|
|
+ productCommissionSave({
|
|
|
+ productId:this.data.id,
|
|
|
+ commission1:this.val1,
|
|
|
+ commission2:this.val2
|
|
|
+ }).then(() => {
|
|
|
+ this.$message({
|
|
|
+ message:'商品“' + this.data.skuTitle + '”佣金设置成功!',
|
|
|
+ type:'success'
|
|
|
+ });
|
|
|
+ this.value = false
|
|
|
+ }).catch(() => {})
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
getCommissionValue(){
|
|
|
saleRankList({
|