|
|
|
@ -8,6 +8,7 @@ import {Router} from '@angular/router'; |
|
|
|
|
import {CommonsService} from '../../../services/commons.service'; |
|
|
|
|
import {AgentService} from '../../../services/agent.service'; |
|
|
|
|
import {DiscountService} from '../../../services/discount.service'; |
|
|
|
|
import {CouponService} from '../../../services/coupon.service'; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-agent-list', |
|
|
|
@ -19,25 +20,32 @@ export class AgentListComponent implements OnInit { |
|
|
|
|
WEB_SERVE_URL = environment.imageUrl; |
|
|
|
|
searchForm: FormGroup; // 搜索框
|
|
|
|
|
validateForm: FormGroup; // 搜索框
|
|
|
|
|
validateFormDistribute: FormGroup; // 搜索框
|
|
|
|
|
requestData = []; // 列表数据
|
|
|
|
|
discountList = []; // 列表数据
|
|
|
|
|
distributeList = []; // 列表数据
|
|
|
|
|
total: number; // 页码
|
|
|
|
|
pageNum = 1; // 页码
|
|
|
|
|
pageSize = 10; // 条码
|
|
|
|
|
loading = true; |
|
|
|
|
isVisible = false; |
|
|
|
|
isVisibleDiscount = false; |
|
|
|
|
isVisibleDistribute = false; |
|
|
|
|
id: number; |
|
|
|
|
isSpinning = false; |
|
|
|
|
isSpinningDistribute = false; |
|
|
|
|
requestDataDiscount = []; // 列表数据
|
|
|
|
|
totalDiscount: number; // 页码
|
|
|
|
|
pageNumDiscount = 1; // 页码
|
|
|
|
|
pageSizeDiscount = 10; // 条码
|
|
|
|
|
loadingDiscount = true; |
|
|
|
|
agentId: number; |
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
|
private form: FormBuilder, |
|
|
|
|
private agent: AgentService, |
|
|
|
|
private discount: DiscountService, |
|
|
|
|
private coupon: CouponService, |
|
|
|
|
private iconService: IconService, |
|
|
|
|
private message: NzMessageService, |
|
|
|
|
private router: Router, |
|
|
|
@ -59,6 +67,10 @@ export class AgentListComponent implements OnInit { |
|
|
|
|
discountId: [null, [Validators.required]], |
|
|
|
|
stockCount: [null, [Validators.required]], |
|
|
|
|
}); |
|
|
|
|
this.validateFormDistribute = this.form.group({ |
|
|
|
|
couponId: [null, [Validators.required]], |
|
|
|
|
stockCount: [null, [Validators.required]], |
|
|
|
|
}); |
|
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -98,7 +110,6 @@ export class AgentListComponent implements OnInit { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 修改
|
|
|
|
|
public getEdit(id: number): void { |
|
|
|
|
this.router.navigate(['/admin/agent/agent-edit'], { |
|
|
|
@ -143,10 +154,11 @@ export class AgentListComponent implements OnInit { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.isSpinning = true; |
|
|
|
|
// this.isSpinning = true;
|
|
|
|
|
this.validateForm.value['agentId'] = this.id; |
|
|
|
|
this.agent.insertDiscountAgent(this.validateForm.value , data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.message.success('生成中,请耐心等待!'); |
|
|
|
|
this.isVisible = false; |
|
|
|
|
} else { |
|
|
|
|
this.message.error(data['return_msg']); |
|
|
|
@ -168,7 +180,9 @@ export class AgentListComponent implements OnInit { |
|
|
|
|
handleCancelDiscount() { |
|
|
|
|
this.isVisibleDiscount = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleCancelDistribute() { |
|
|
|
|
this.isVisibleDistribute = false; |
|
|
|
|
} |
|
|
|
|
// 查询列表
|
|
|
|
|
public getRequestDiscount(reset: boolean = false) { |
|
|
|
|
const whereObject = {}; |
|
|
|
@ -188,5 +202,46 @@ export class AgentListComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 分发卡券
|
|
|
|
|
public getDistribution(id: number): void { |
|
|
|
|
this.isSpinningDistribute = true; |
|
|
|
|
this.agentId = id; |
|
|
|
|
const whereObject = {}; |
|
|
|
|
whereObject['pageNum'] = 1; |
|
|
|
|
whereObject['pageSize'] = 10000; |
|
|
|
|
this.coupon.getCouponList(whereObject, data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.distributeList = data['return_data'].list; |
|
|
|
|
} else { |
|
|
|
|
this.message.error(data['return_msg']); |
|
|
|
|
} |
|
|
|
|
this.isSpinningDistribute = false; |
|
|
|
|
}); |
|
|
|
|
this.isVisibleDistribute = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 提交分发
|
|
|
|
|
public handleOkDistribute(): void { |
|
|
|
|
// tslint:disable-next-line:forin
|
|
|
|
|
for (const i in this.validateFormDistribute.controls) { |
|
|
|
|
this.validateFormDistribute.controls[i].markAsDirty(); |
|
|
|
|
this.validateFormDistribute.controls[i].updateValueAndValidity(); |
|
|
|
|
if (this.validateFormDistribute.controls[i].errors != null) { |
|
|
|
|
this.message.error('必填项不能为空'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.validateFormDistribute.value['agentId'] = this.agentId; |
|
|
|
|
this.agent.assignCouponAgent(this.validateFormDistribute.value , data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.message.success('分发成功'); |
|
|
|
|
this.isVisibleDistribute = false; |
|
|
|
|
} else { |
|
|
|
|
this.message.error(data['return_msg']); |
|
|
|
|
} |
|
|
|
|
this.isSpinning = false; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|