From 0a2b69f11a717c47203604e2d13e4ab60b73f821 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 22 Mar 2021 22:15:11 +0800 Subject: [PATCH] 1\ --- .../coupon-edit/coupon-edit.component.html | 7 +- .../coupon-edit/coupon-edit.component.ts | 31 ++-- .../coupon-list/coupon-list.component.html | 4 +- .../coupon-list/coupon-list.component.ts | 11 ++ src/app/admin/coupon/coupon-routing.module.ts | 2 + src/app/admin/coupon/coupon.module.ts | 3 +- .../sales-code-list.component.html | 168 ++++++++++++++++++ .../sales-code-list.component.scss | 0 .../sales-code-list.component.ts | 153 ++++++++++++++++ src/app/app-common.module.ts | 2 + src/app/pipes/coupon-code.pipe.ts | 21 +++ src/app/pipes/index.ts | 1 + src/app/services/coupon.service.ts | 24 +++ src/app/services/icon.service.ts | 2 +- 14 files changed, 411 insertions(+), 18 deletions(-) create mode 100644 src/app/admin/coupon/sales-code-list/sales-code-list.component.html create mode 100644 src/app/admin/coupon/sales-code-list/sales-code-list.component.scss create mode 100644 src/app/admin/coupon/sales-code-list/sales-code-list.component.ts create mode 100644 src/app/pipes/coupon-code.pipe.ts diff --git a/src/app/admin/coupon/coupon-edit/coupon-edit.component.html b/src/app/admin/coupon/coupon-edit/coupon-edit.component.html index 3f817dd..67624fc 100644 --- a/src/app/admin/coupon/coupon-edit/coupon-edit.component.html +++ b/src/app/admin/coupon/coupon-edit/coupon-edit.component.html @@ -90,8 +90,7 @@ 截止日期 @@ -118,10 +117,10 @@
- 选择卡券 + 选择卡券 { return new Promise((resolve, reject) => { const reader = new FileReader(); @@ -37,6 +38,7 @@ export class CouponEditComponent implements OnInit { isLoading = false; pageNum = 1; pageSize = 10; + pageSizeCoupon = 10; merchantName: string; optionListCoupon: string[] = []; isLoadingCoupon = false; @@ -47,6 +49,7 @@ export class CouponEditComponent implements OnInit { private fb: FormBuilder, private merchant: MerchantService, private coupon: CouponService, + private common: CommonsService, private message: NzMessageService, // 信息提示 private activatedRoute: ActivatedRoute, ) { @@ -59,7 +62,9 @@ export class CouponEditComponent implements OnInit { this.id = queryParams.couponId; this.getDetails(queryParams.couponId); this.pageSize = 10000; + this.pageSizeCoupon = 10000; this.loadMore(); + this.loadMoreCoupon(); } }); this.validateForm = this.fb.group({ @@ -74,7 +79,7 @@ export class CouponEditComponent implements OnInit { salesCount: [null, [Validators.required]], merchantId: [null, [Validators.required]], isPresent: [false, [Validators.required]], - handselCouponList: [null], + handselCouponId: [null], status: [null], couponKey: [null], createTime: [null], @@ -126,7 +131,7 @@ export class CouponEditComponent implements OnInit { this.isLoadingCoupon = true; const paramsObject = { pageNum: this.pageNumCoupon, - pageSize: 10, + pageSize: this.pageSizeCoupon, merchantName: this.merchantName, }; this.getCouponList(paramsObject); @@ -140,7 +145,7 @@ export class CouponEditComponent implements OnInit { this.pageNumCoupon = 1; const paramsObject = { pageNum: this.pageNumCoupon, - pageSize: 10, + pageSize: this.pageSizeCoupon, merchantName: e, }; this.getCouponList(paramsObject); @@ -210,14 +215,18 @@ export class CouponEditComponent implements OnInit { this.validateForm.value.couponCarouselImg = couponCarouselImg.join(','); this.validateForm.value.couponDesc = this.content; if (this.editFlag) { - this.validateForm.value.id = this.id; - this.coupon.updateCoupon(this.validateForm.value, data => { - if (data['return_code'] === '000000') { - this.getBack(); - this.message.success('修改成功'); - } else { - this.message.create('error', '修改失败'); - } + this.common.showConfirm('是否确定修改,确定将下架' , dataR => { + if (dataR) { + this.validateForm.value.id = this.id; + this.coupon.updateCoupon(this.validateForm.value, data => { + if (data['return_code'] === '000000') { + this.getBack(); + this.message.success('修改成功,卡券已下架!'); + } else { + this.message.create('error', '修改失败'); + } + }); + } }); } else { diff --git a/src/app/admin/coupon/coupon-list/coupon-list.component.html b/src/app/admin/coupon/coupon-list/coupon-list.component.html index eee1e56..8b1b1ca 100644 --- a/src/app/admin/coupon/coupon-list/coupon-list.component.html +++ b/src/app/admin/coupon/coupon-list/coupon-list.component.html @@ -107,7 +107,7 @@ 卡券状态 销售截止时间 创建时间 - 操作 + 操作 @@ -128,6 +128,8 @@ + + diff --git a/src/app/admin/coupon/coupon-list/coupon-list.component.ts b/src/app/admin/coupon/coupon-list/coupon-list.component.ts index a9d3d9a..63c7835 100644 --- a/src/app/admin/coupon/coupon-list/coupon-list.component.ts +++ b/src/app/admin/coupon/coupon-list/coupon-list.component.ts @@ -193,4 +193,15 @@ export class CouponListComponent implements OnInit { }); } + // 查看门店列表 + public getList(id: number , couponName: string , couponType: number): void { + this.router.navigate(['/admin/coupon/salesCode-list'], { + queryParams: { + couponId: id, + name: couponName, + type: couponType, + } + }).then(r => console.log(r)); + } + } diff --git a/src/app/admin/coupon/coupon-routing.module.ts b/src/app/admin/coupon/coupon-routing.module.ts index ab68db5..dd1794c 100644 --- a/src/app/admin/coupon/coupon-routing.module.ts +++ b/src/app/admin/coupon/coupon-routing.module.ts @@ -3,12 +3,14 @@ import { Routes, RouterModule } from '@angular/router'; import {CouponListComponent} from './coupon-list/coupon-list.component'; import {CouponEditComponent} from './coupon-edit/coupon-edit.component'; import {CouponDetailComponent} from './coupon-detail/coupon-detail.component'; +import {SalesCodeListComponent} from './sales-code-list/sales-code-list.component'; const routes: Routes = [ { path: 'coupon-list', component: CouponListComponent }, { path: 'coupon-edit', component: CouponEditComponent }, { path: 'coupon-detail', component: CouponDetailComponent }, + { path: 'salesCode-list', component: SalesCodeListComponent }, ]; @NgModule({ diff --git a/src/app/admin/coupon/coupon.module.ts b/src/app/admin/coupon/coupon.module.ts index a756a54..fda519f 100644 --- a/src/app/admin/coupon/coupon.module.ts +++ b/src/app/admin/coupon/coupon.module.ts @@ -11,9 +11,10 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; import {RichtextModule} from '../../common/richtext/richtext.module'; import {AppCommonModule} from '../../app-common.module'; +import { SalesCodeListComponent } from './sales-code-list/sales-code-list.component'; @NgModule({ - declarations: [CouponListComponent, CouponEditComponent, CouponDetailComponent], + declarations: [CouponListComponent, CouponEditComponent, CouponDetailComponent, SalesCodeListComponent], imports: [ CommonModule, CouponRoutingModule, diff --git a/src/app/admin/coupon/sales-code-list/sales-code-list.component.html b/src/app/admin/coupon/sales-code-list/sales-code-list.component.html new file mode 100644 index 0000000..0de2db3 --- /dev/null +++ b/src/app/admin/coupon/sales-code-list/sales-code-list.component.html @@ -0,0 +1,168 @@ + + + + + +
+
+
+ +
+ + 消费码KEY + + + + +
+
+ + 消费码状态 + + + + + + + + + +
+
+ +
+
+ + +
+
+
+
+ + +
+ 共计 {{total}} 条数据 + + 卡券名称: + {{name}}({{type === 1 ? '内部卷' : '外部卷'}}) + +
+ + + + +
+ + + + 编号 + 消费码 + 订单ID + 领取时间 + 消费时间 + 销售截止时间 + 使用截止时间 + 创建时间 + 状态 + + + + + {{i + 1}} + {{data.salesCode}} + {{data.orderId == null ? '暂无' : data.orderId}} + {{data.receiveTime == null ? '未领取' : data.receiveTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.consumeTime == null ? '未消费' : data.consumeTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.useEndTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.status | couponCode}} + + +
+ + + + +
+
+
+ + 销售截止日期 + + + + +
+
+ + 使用截止日期 + + + + +
+
+ + 消费码数量 + + + + +
+
+ + +
+
+
+ + + + + + + 序号 + 销售码 + 销售截止时间 + 使用截止时间 + 原因 + + + + + {{ i + 1}} + {{data.salesCode}} + {{data.salesEndTime}} + {{data.useEndTime}} + {{data.errorMessage}} + + + + diff --git a/src/app/admin/coupon/sales-code-list/sales-code-list.component.scss b/src/app/admin/coupon/sales-code-list/sales-code-list.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/coupon/sales-code-list/sales-code-list.component.ts b/src/app/admin/coupon/sales-code-list/sales-code-list.component.ts new file mode 100644 index 0000000..adb5dbb --- /dev/null +++ b/src/app/admin/coupon/sales-code-list/sales-code-list.component.ts @@ -0,0 +1,153 @@ +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {FormBuilder, FormGroup, Validators} from '@angular/forms'; +import {NzMessageService, NzModalService, NzUploadChangeParam} from 'ng-zorro-antd'; +import {CouponService} from '../../../services/coupon.service'; +import {environment} from '../../../../environments/environment'; + +@Component({ + selector: 'app-sales-code-list', + templateUrl: './sales-code-list.component.html', + styleUrls: ['./sales-code-list.component.scss'] +}) +export class SalesCodeListComponent implements OnInit { + + searchForm: FormGroup; // 搜索框 + codeForm: FormGroup; // 搜索框 + requestData = []; // 列表数据 + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + id = null; + name: string; + type: number; + isVisible = false; + WEB_SERVE_URL = environment.baseUrl; + importErrorStudentArray = []; + errorStudentVisible = false; + + constructor( + private form: FormBuilder, + private activatedRoute: ActivatedRoute, + private message: NzMessageService, + private modal: NzModalService, + private coupon: CouponService + ) { + } + + ngOnInit(): void { + this.activatedRoute.queryParams.subscribe(queryParams => { + if (queryParams.couponId != null) { + this.id = queryParams.couponId; + this.name = queryParams.name; + this.type = Number(queryParams.type); + this.searchForm = this.form.group({ + status: [null], + salesCode: [null], + }); + this.getRequest(true, this.searchForm.value); + } + }); + this.codeForm = this.form.group({ + salesEndTime: [null, [Validators.required]], + useEndTime: [null, [Validators.required]], + generateNum: [null, [Validators.required]], + }); + } + + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { + + this.loading = false; + if (reset) { + this.pageNum = 1; + } + whereObject['couponId'] = this.id; + whereObject['pageNum'] = this.pageNum; + whereObject['pageSize'] = this.pageSize; + this.coupon.getCouponCodeList(whereObject, data => { + if (data['return_code'] === '000000') { + this.requestData = data['return_data'].list; + this.total = data['return_data'].total; + } else { + this.message.error(data['return_msg']); + } + }); + + } + + // 重置 + public resetForm(): void { + this.searchForm.reset(); + } + + showModal(): void { + this.isVisible = true; + } + + handleOk(): void { + // tslint:disable-next-line:forin + for (const i in this.codeForm.controls) { + this.codeForm.controls[i].markAsDirty(); + this.codeForm.controls[i].updateValueAndValidity(); + if (this.codeForm.controls[i].errors != null) { + this.message.error('必填项不能为空'); + return; + } + } + this.codeForm.value['couponId'] = this.id; + this.coupon.writeStock(this.codeForm.value , data => { + if (data['return_code'] === '000000') { + this.getRequest(true, this.searchForm.value); + this.message.success('生成成功'); + } else { + this.message.create('error', '生成失败'); + } + }); + this.isVisible = false; + } + + handleCancel(): void { + console.log('Button cancel clicked!'); + this.isVisible = false; + } + + handleCancelError(): void { + this.errorStudentVisible = false; + } + + handleChange(info: NzUploadChangeParam): void { + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList); + } + if (info.file.status === 'done') { + if (info.file.response.return_code === '000000') { + this.loading = false; + if (info.file.response.return_data == null || info.file.response.return_data.length === 0) { + this.message.success('导入成功'); + this.getRequest(true, this.searchForm.value); + } else { + this.modal.warning({ + nzTitle: '提示', + nzOkText: '查看失败数据', + nzContent: '只有部分数据导入成功', + nzOnOk: () => this.showErrorStudentModal(info.file.response.return_data) + }); + } + } else { + this.loading = false; + this.message.error(info.file.response.return_msg); + } + } else if (info.file.status === 'error') { + this.message.error('上传错误'); + } + } + + // 打开模态框 + showErrorStudentModal(data: []) { + this.getRequest(true, this.searchForm.value); + this.importErrorStudentArray = data['errorData']; + this.errorStudentVisible = true; + } +} diff --git a/src/app/app-common.module.ts b/src/app/app-common.module.ts index bfa16a1..2553f38 100644 --- a/src/app/app-common.module.ts +++ b/src/app/app-common.module.ts @@ -12,6 +12,7 @@ import {NgxNeditorModule} from '@notadd/ngx-neditor'; import {TimesPipe , TextareaPipe} from './pipes'; import { SystemPipe } from './pipes/system.pipe'; import { CouponStatusPipe } from './pipes/coupon-status.pipe'; +import { CouponCodePipe } from './pipes/coupon-code.pipe'; @@ -21,6 +22,7 @@ const PIPES = [ TextareaPipe, SystemPipe, CouponStatusPipe, + CouponCodePipe, ]; diff --git a/src/app/pipes/coupon-code.pipe.ts b/src/app/pipes/coupon-code.pipe.ts new file mode 100644 index 0000000..0299016 --- /dev/null +++ b/src/app/pipes/coupon-code.pipe.ts @@ -0,0 +1,21 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'couponCode' +}) +export class CouponCodePipe implements PipeTransform { + + transform(value: number): string { + switch (value) { + case 1: + return '待销售'; + case 2: + return '待使用'; + case 3: + return '已使用'; + case 4: + return '已过期'; + } + } + +} diff --git a/src/app/pipes/index.ts b/src/app/pipes/index.ts index 947e9d4..5663590 100644 --- a/src/app/pipes/index.ts +++ b/src/app/pipes/index.ts @@ -2,3 +2,4 @@ export * from './commons/times.pipe'; export * from './commons/textarea.pipe'; export * from './system.pipe'; export * from './coupon-status.pipe'; +export * from './coupon-code.pipe'; diff --git a/src/app/services/coupon.service.ts b/src/app/services/coupon.service.ts index 60d06fb..a000286 100644 --- a/src/app/services/coupon.service.ts +++ b/src/app/services/coupon.service.ts @@ -24,6 +24,18 @@ export class CouponService { }); } + /** + * 查询卡券消费码列表 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getCouponCodeList(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'couponCode/getCouponCodeList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + /** * 新增卡券 * @@ -87,6 +99,18 @@ export class CouponService { }); } + /** + * 生成消费码 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public writeStock(params: object, callBack) { + this.http.post(environment.baseUrl + 'coupon/writeStock', params).subscribe(data => { + callBack(data); + }); + } } diff --git a/src/app/services/icon.service.ts b/src/app/services/icon.service.ts index 3ea594e..7f9f424 100644 --- a/src/app/services/icon.service.ts +++ b/src/app/services/icon.service.ts @@ -12,7 +12,7 @@ export class IconService { constructor(private iconService: NzIconService) { this.iconService.fetchFromIconfont({ - scriptUrl: 'https://at.alicdn.com/t/font_2424521_elodxcgd21v.js' + scriptUrl: 'https://at.alicdn.com/t/font_2424521_2fwfzlplp0d.js' }); } }