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 c121e49..ec2bc40 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'}} - - - - - - - - - - + 编辑 + 更多 + + + @@ -104,22 +110,24 @@ - + 有效天数 截止日期 库存数量 - 二维码 @@ -164,9 +171,65 @@ {{data['highDiscount'].effectiveDay}} {{data['highDiscount'].salesEndTime | date: 'yyyy-MM-dd HH:mm'}} {{data.stockCount}} - - - + + + + + + + + + + + + + + + + + 卡券名称 + 卡券销售价格 + 库存数量 + 销售数量 + 分发时间 + + + + + {{data['couponName']}} + {{data['salesPrice']}}元 + {{data['stockCount']}} + {{data['salesCount']}} + {{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 5053c3b..54bddea 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,37 @@ 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; + isVisibleList = false; id: number; - + isSpinning = false; + isSpinningDistribute = false; requestDataDiscount = []; // 列表数据 totalDiscount: number; // 页码 pageNumDiscount = 1; // 页码 pageSizeDiscount = 10; // 条码 loadingDiscount = true; + agentId: number; + requestDataList = []; // 列表数据 + totalList: number; // 页码 + pageNumList = 1; // 页码 + pageSizeList = 10; // 条码 + loadingList = true; constructor( private form: FormBuilder, private agent: AgentService, private discount: DiscountService, + private coupon: CouponService, private iconService: IconService, private message: NzMessageService, private router: Router, @@ -59,6 +72,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 +115,6 @@ export class AgentListComponent implements OnInit { }); } - // 修改 public getEdit(id: number): void { this.router.navigate(['/admin/agent/agent-edit'], { @@ -143,14 +159,16 @@ export class AgentListComponent implements OnInit { return; } } + // this.isSpinning = true; this.validateForm.value['agentId'] = this.id; this.agent.insertDiscountAgent(this.validateForm.value , data => { if (data['return_code'] === '000000') { - console.log(data); + this.message.success('生成中,请耐心等待!'); this.isVisible = false; } else { this.message.error(data['return_msg']); } + this.isSpinning = false; }); } @@ -164,14 +182,26 @@ export class AgentListComponent implements OnInit { this.getRequestDiscount(true); } + public getDistributionList(id: number): void { + this.id = id; + this.isVisibleList = true; + this.getRequestList(true); + } + + handleCancelList() { + this.isVisibleList = false; + } + handleCancelDiscount() { this.isVisibleDiscount = false; } - + handleCancelDistribute() { + this.isVisibleDistribute = false; + } // 查询列表 public getRequestDiscount(reset: boolean = false) { const whereObject = {}; - this.loadingDiscount = false; + this.loadingDiscount = true; if (reset) { this.pageNumDiscount = 1; } @@ -179,6 +209,7 @@ export class AgentListComponent implements OnInit { whereObject['pageSize'] = this.pageSizeDiscount; whereObject['agentId'] = this.id; this.agent.getDiscountAgentList(whereObject, data => { + this.loadingDiscount = false; if (data['return_code'] === '000000') { this.requestDataDiscount = data['return_data'].list; this.totalDiscount = data['return_data'].total; @@ -187,5 +218,68 @@ 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; + } + + // 查询f分发列表 + public getRequestList(reset: boolean = false) { + const whereObject = {}; + this.loadingList = true; + if (reset) { + this.pageNumList = 1; + } + whereObject['pageNum'] = this.pageNumList; + whereObject['pageSize'] = this.pageSizeList; + whereObject['agentId'] = this.id; + this.agent.getCouponByAgent(whereObject, data => { + this.loadingList = false; + if (data['return_code'] === '000000') { + this.requestDataList = data['return_data'].list; + this.totalList = data['return_data'].total; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 提交分发 + 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.validateFormDistribute.reset(); + this.message.success('分发成功'); + this.isVisibleDistribute = false; + } else { + this.message.error(data['return_msg']); + } + this.isSpinning = false; + }); + } } diff --git a/src/app/admin/discount/discount-edit/discount-edit.component.html b/src/app/admin/discount/discount-edit/discount-edit.component.html index 34080ef..f973e2c 100644 --- a/src/app/admin/discount/discount-edit/discount-edit.component.html +++ b/src/app/admin/discount/discount-edit/discount-edit.component.html @@ -67,7 +67,7 @@ 领取有效天数 - +
diff --git a/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts b/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts index 0a88cb1..bb2d957 100644 --- a/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts +++ b/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts @@ -51,7 +51,7 @@ export class MerchantEditComponent implements OnInit { this.validateForm = this.fb.group({ loginTelephone: [null, [Validators.required, ValidatorsService.mobile]], password: [null, [Validators.required, ValidatorsService.minLength(6)]], - merchantName: [null, [Validators.required, ValidatorsService.pwdLength(2, 5)]], + merchantName: [null, [Validators.required]], telephone: [null, [Validators.required]], address: [null, [Validators.required]], bankName: [null], diff --git a/src/app/services/agent.service.ts b/src/app/services/agent.service.ts index 863e116..1433f6a 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); + }); + } + /** * 查询列表 * @@ -103,4 +116,16 @@ export class AgentService { }); } + /** + * 查询列表 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getCouponByAgent(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'highCouponAgent/getCouponByAgent?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + }