From 0fba1e3e77a121ad00f3c9e18e3a7cb1cca47539 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 27 Jul 2022 15:10:21 +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 --- .../discount-package-list.component.html | 51 ++++++++++--------- .../discount-package-list.component.ts | 32 +++++++++--- src/app/services/discount-package.service.ts | 7 +++ 3 files changed, 60 insertions(+), 30 deletions(-) diff --git a/src/app/admin/discount-package/discount-package-list/discount-package-list.component.html b/src/app/admin/discount-package/discount-package-list/discount-package-list.component.html index a0d782e..23098ac 100644 --- a/src/app/admin/discount-package/discount-package-list/discount-package-list.component.html +++ b/src/app/admin/discount-package/discount-package-list/discount-package-list.component.html @@ -114,7 +114,7 @@
  • 上架
  • 下架
  • 删除
  • -
  • 赠送用户
  • +
  • 赠送用户
  • @@ -197,7 +197,8 @@ - 注意:提交赠送时系统会自动过滤 ”有误“ 和 ”重复“ 的数据,有误的数据不会赠送卷包。 + 注意:提交赠送时系统会自动过滤 ”有误“ 和 ”重复“ 的数据,有误的数据不会赠送卷包。
    + 共计 {{deliverUserArray.length}} 条数据 @@ -250,28 +251,30 @@ - 注意:导入用户会清空现有列表中的数据。 -
    -
    - - excel文件 - - - - - - + + 注意:导入用户会清空现有列表中的数据。 +
    +
    + + excel文件 + + + + + + +
    -
    -
    -
    - +
    +
    + +
    -
    + diff --git a/src/app/admin/discount-package/discount-package-list/discount-package-list.component.ts b/src/app/admin/discount-package/discount-package-list/discount-package-list.component.ts index 1f98e47..c22ed83 100644 --- a/src/app/admin/discount-package/discount-package-list/discount-package-list.component.ts +++ b/src/app/admin/discount-package/discount-package-list/discount-package-list.component.ts @@ -33,6 +33,7 @@ export class DiscountPackageListComponent implements OnInit { deliverUserAddForm: FormGroup; deliverUserAddModal = false; + userInterval; deliverUserSearchForm: FormGroup; deliverUserModal = false; @@ -225,8 +226,20 @@ export class DiscountPackageListComponent implements OnInit { // 打开 发送优惠券包给用户模态框 showDeliverUserModal(packageId: number, packageName: string) { - this.deliverUserForm.patchValue({ packageId: packageId, packageName: packageName}) - this.deliverUserModal = true; + this.discountPackage.getHandleByPackageId({ packageId: packageId}, data => { + if (data['return_code'] === '000000') { + if (data['return_data'] != null) { + this.modal.confirm({ + nzTitle: '提示', + nzContent: '当前卷包有赠送任务进行中,是否查看赠送进度?', + nzOnOk: () => this.processRate(data['return_data']['serialNumber']) + }) + } else { + this.deliverUserForm.patchValue({ packageId: packageId, packageName: packageName}); + this.deliverUserModal = true; + } + } + }); } // 关闭 发送优惠券包给用户模态框 @@ -247,6 +260,7 @@ export class DiscountPackageListComponent implements OnInit { // 关闭导入模态框 closeExcelUserModal() { + this.spinObject.status = false; this.excelUploadBtn = true; this.excelUploadFile = []; this.excelUserModal = false; @@ -260,12 +274,15 @@ export class DiscountPackageListComponent implements OnInit { this.deliverUserForm.patchValue({ phoneArray: this.deliverUserArray.filter(o => o.errorStatus == false)}); this.spinObject.status = true; this.spinObject.title = '处理中...'; - this.discountPackage.giveAway(this.deliverUserForm.value, data => { + const param = this.deliverUserForm.value; + this.closeDeliverUserModal(); + + this.discountPackage.giveAway(param, data => { if (data['return_code'] === '000000') { this.serialNumber = data['return_data']; - this.closeDeliverUserModal(); this.processRate(this.serialNumber); } else { + this.showDeliverUserModal(this.deliverUserForm.controls.packageId.value, this.deliverUserForm.controls.packageName.value); this.message.create('error', data['return_msg']); this.spinObject.status = false; } @@ -275,24 +292,27 @@ export class DiscountPackageListComponent implements OnInit { // 处理进度 processRate(serialNum: string) { this.spinObject.status = true; - let time = setInterval(() => this.commonsService.getRedisValueByType(serialNum, data => { + this.userInterval = setInterval(() => this.commonsService.getRedisValueByType(serialNum, data => { if (data['return_data'] != null) { this.spinObject.title = '已处理' + data['return_data'] + '条数据'; } else { this.spinObject.status = false; - clearTimeout(time); this.getRequest(true, this.searchForm.value); + clearTimeout(this.userInterval); } }), 1000); } // 提交excel数据 submitExcelUser() { + this.spinObject.title = '文件导入中... 数据太多会占用较长时间'; + this.spinObject.status = true; this.discountPackage.getPhoneListByFileUrl({ fileUrl: this.excelUploadFile[0]['url']}, data => { if (data['return_code'] === '000000') { this.deliverUserArray = data['return_data']['data']; this.closeExcelUserModal(); } else { + this.spinObject.status = false; this.message.error(data['return_msg']); } }); diff --git a/src/app/services/discount-package.service.ts b/src/app/services/discount-package.service.ts index c33f233..0c0db0d 100644 --- a/src/app/services/discount-package.service.ts +++ b/src/app/services/discount-package.service.ts @@ -205,6 +205,12 @@ export class DiscountPackageService { }); } + public getHandleByPackageId(paramsObject: object, callBack) { + this.http.post(environment.baseUrl + 'highDiscountPackage/getHandleByPackageId', paramsObject).subscribe(data => { + callBack(data); + }); + } + public giveAway(paramsObject: object, callBack) { this.http.post(environment.baseUrl + 'highDiscountPackage/giveAway', paramsObject).subscribe(data => { callBack(data); @@ -212,4 +218,5 @@ export class DiscountPackageService { } + }