|
|
@ -8,6 +8,7 @@ import {Router} from '@angular/router'; |
|
|
|
import {CommonsService} from '../../../services/commons.service'; |
|
|
|
import {CommonsService} from '../../../services/commons.service'; |
|
|
|
import {AgentService} from '../../../services/agent.service'; |
|
|
|
import {AgentService} from '../../../services/agent.service'; |
|
|
|
import {DiscountService} from '../../../services/discount.service'; |
|
|
|
import {DiscountService} from '../../../services/discount.service'; |
|
|
|
|
|
|
|
import {CouponService} from '../../../services/coupon.service'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-agent-list', |
|
|
|
selector: 'app-agent-list', |
|
|
@ -19,25 +20,32 @@ export class AgentListComponent implements OnInit { |
|
|
|
WEB_SERVE_URL = environment.imageUrl; |
|
|
|
WEB_SERVE_URL = environment.imageUrl; |
|
|
|
searchForm: FormGroup; // 搜索框
|
|
|
|
searchForm: FormGroup; // 搜索框
|
|
|
|
validateForm: FormGroup; // 搜索框
|
|
|
|
validateForm: FormGroup; // 搜索框
|
|
|
|
|
|
|
|
validateFormDistribute: FormGroup; // 搜索框
|
|
|
|
requestData = []; // 列表数据
|
|
|
|
requestData = []; // 列表数据
|
|
|
|
discountList = []; // 列表数据
|
|
|
|
discountList = []; // 列表数据
|
|
|
|
|
|
|
|
distributeList = []; // 列表数据
|
|
|
|
total: number; // 页码
|
|
|
|
total: number; // 页码
|
|
|
|
pageNum = 1; // 页码
|
|
|
|
pageNum = 1; // 页码
|
|
|
|
pageSize = 10; // 条码
|
|
|
|
pageSize = 10; // 条码
|
|
|
|
loading = true; |
|
|
|
loading = true; |
|
|
|
isVisible = false; |
|
|
|
isVisible = false; |
|
|
|
isVisibleDiscount = false; |
|
|
|
isVisibleDiscount = false; |
|
|
|
|
|
|
|
isVisibleDistribute = false; |
|
|
|
id: number; |
|
|
|
id: number; |
|
|
|
isSpinning = false; |
|
|
|
isSpinning = false; |
|
|
|
|
|
|
|
isSpinningDistribute = false; |
|
|
|
requestDataDiscount = []; // 列表数据
|
|
|
|
requestDataDiscount = []; // 列表数据
|
|
|
|
totalDiscount: number; // 页码
|
|
|
|
totalDiscount: number; // 页码
|
|
|
|
pageNumDiscount = 1; // 页码
|
|
|
|
pageNumDiscount = 1; // 页码
|
|
|
|
pageSizeDiscount = 10; // 条码
|
|
|
|
pageSizeDiscount = 10; // 条码
|
|
|
|
loadingDiscount = true; |
|
|
|
loadingDiscount = true; |
|
|
|
|
|
|
|
agentId: number; |
|
|
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
constructor( |
|
|
|
private form: FormBuilder, |
|
|
|
private form: FormBuilder, |
|
|
|
private agent: AgentService, |
|
|
|
private agent: AgentService, |
|
|
|
private discount: DiscountService, |
|
|
|
private discount: DiscountService, |
|
|
|
|
|
|
|
private coupon: CouponService, |
|
|
|
private iconService: IconService, |
|
|
|
private iconService: IconService, |
|
|
|
private message: NzMessageService, |
|
|
|
private message: NzMessageService, |
|
|
|
private router: Router, |
|
|
|
private router: Router, |
|
|
@ -59,6 +67,10 @@ export class AgentListComponent implements OnInit { |
|
|
|
discountId: [null, [Validators.required]], |
|
|
|
discountId: [null, [Validators.required]], |
|
|
|
stockCount: [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); |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -98,7 +110,6 @@ export class AgentListComponent implements OnInit { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 修改
|
|
|
|
// 修改
|
|
|
|
public getEdit(id: number): void { |
|
|
|
public getEdit(id: number): void { |
|
|
|
this.router.navigate(['/admin/agent/agent-edit'], { |
|
|
|
this.router.navigate(['/admin/agent/agent-edit'], { |
|
|
@ -143,10 +154,11 @@ export class AgentListComponent implements OnInit { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.isSpinning = true; |
|
|
|
// this.isSpinning = true;
|
|
|
|
this.validateForm.value['agentId'] = this.id; |
|
|
|
this.validateForm.value['agentId'] = this.id; |
|
|
|
this.agent.insertDiscountAgent(this.validateForm.value , data => { |
|
|
|
this.agent.insertDiscountAgent(this.validateForm.value , data => { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
|
|
|
this.message.success('生成中,请耐心等待!'); |
|
|
|
this.isVisible = false; |
|
|
|
this.isVisible = false; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.error(data['return_msg']); |
|
|
|
this.message.error(data['return_msg']); |
|
|
@ -168,7 +180,9 @@ export class AgentListComponent implements OnInit { |
|
|
|
handleCancelDiscount() { |
|
|
|
handleCancelDiscount() { |
|
|
|
this.isVisibleDiscount = false; |
|
|
|
this.isVisibleDiscount = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
handleCancelDistribute() { |
|
|
|
|
|
|
|
this.isVisibleDistribute = false; |
|
|
|
|
|
|
|
} |
|
|
|
// 查询列表
|
|
|
|
// 查询列表
|
|
|
|
public getRequestDiscount(reset: boolean = false) { |
|
|
|
public getRequestDiscount(reset: boolean = false) { |
|
|
|
const whereObject = {}; |
|
|
|
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; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|