From 151a8028f93491da559033939400959dad6cb7af Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Thu, 22 Apr 2021 23:36:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agent-list/agent-list.component.html | 101 +++++++++++------- .../agent-list/agent-list.component.scss | 8 ++ .../agent/agent-list/agent-list.component.ts | 61 ++++++++++- src/app/services/agent.service.ts | 13 +++ 4 files changed, 143 insertions(+), 40 deletions(-) diff --git a/src/app/admin/agent/agent-list/agent-list.component.html b/src/app/admin/agent/agent-list/agent-list.component.html index c03f7ad..9cb7a24 100644 --- a/src/app/admin/agent/agent-list/agent-list.component.html +++ b/src/app/admin/agent/agent-list/agent-list.component.html @@ -7,7 +7,7 @@
-
+
名称 @@ -15,7 +15,7 @@
-
+
电话 @@ -23,12 +23,12 @@
-
+
代理商状态 - + @@ -40,7 +40,9 @@
- +
@@ -50,7 +52,10 @@
共计 {{total}} 条数据
- +
- {{i+1}} + {{i + 1}} {{data.agentName}} {{data.agentAddress}} {{data.agentUser}} {{data.agentPhone}} {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} - - - - - - - - - - + 编辑 + 更多 + + +
- - - - + - + + + + + + + + diff --git a/src/app/admin/agent/agent-list/agent-list.component.scss b/src/app/admin/agent/agent-list/agent-list.component.scss index ebfbfbd..b9c92c7 100644 --- a/src/app/admin/agent/agent-list/agent-list.component.scss +++ b/src/app/admin/agent/agent-list/agent-list.component.scss @@ -2,3 +2,11 @@ height: 80px; width: 80px; } +.table-td-operation { + a { + margin-left: 8px; + } +} +.li-a :hover { + color: #1890ff; +} diff --git a/src/app/admin/agent/agent-list/agent-list.component.ts b/src/app/admin/agent/agent-list/agent-list.component.ts index be2609d..175fbe8 100644 --- a/src/app/admin/agent/agent-list/agent-list.component.ts +++ b/src/app/admin/agent/agent-list/agent-list.component.ts @@ -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; + }); + } } diff --git a/src/app/services/agent.service.ts b/src/app/services/agent.service.ts index 863e116..b18f6e2 100644 --- a/src/app/services/agent.service.ts +++ b/src/app/services/agent.service.ts @@ -91,6 +91,19 @@ export class AgentService { }); } + /** + * 分配卡券给代理商 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public assignCouponAgent(params: object, callBack) { + this.http.post(environment.baseUrl + 'highCouponAgent/assignCouponAgent', params).subscribe(data => { + callBack(data); + }); + } + /** * 查询列表 *