From dd8e297741c1bdb4fcd0a882bef86622c72d3c53 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Tue, 30 Nov 2021 00:14:21 +0800 Subject: [PATCH] 1 --- .../discount-package-edit.component.html | 71 +++--------------- .../discount-package-edit.component.ts | 72 ++++++++----------- .../discount-package-list.component.html | 31 ++++---- .../discount-edit.component.html | 6 +- .../discount-edit/discount-edit.component.ts | 5 +- src/app/app-common.module.ts | 2 + src/app/pipes/discount-package-status.pipe.ts | 19 +++++ src/app/pipes/index.ts | 1 + src/app/services/discount-package.service.ts | 1 + 9 files changed, 80 insertions(+), 128 deletions(-) create mode 100644 src/app/pipes/discount-package-status.pipe.ts diff --git a/src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.html b/src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.html index 3f08de5..83471e9 100644 --- a/src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.html +++ b/src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.html @@ -175,9 +175,17 @@ - +
基本信息
-
奖品信息
-
-
-
- - 代理商 - - - - - {{control.agentName}} - - -
-
- - 优惠券 - - - - - {{control.prizeName}} - - -
-
- - 奖励数量 - - - {{control.prizeNum}} - - -
-
-
- -
- -
-
diff --git a/src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.ts b/src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.ts index 8cdfe8b..3ac1b78 100644 --- a/src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.ts +++ b/src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.ts @@ -9,6 +9,7 @@ import {environment} from '../../../../environments/environment'; import {AgentService} from '../../../services/agent.service'; import {CommonsService} from "../../../services/commons.service"; import {DiscountPackageService} from "../../../services/discount-package.service"; +import {DiscountService} from "../../../services/discount.service"; function getBase64(file: File): Promise { return new Promise((resolve, reject) => { @@ -53,10 +54,13 @@ export class DiscountPackageEditComponent implements OnInit { previewImage: string | undefined = ''; previewVisible = false; discountList = []; // 列表数据 + usingScope = []; // 列表数据 listImg = []; bannerImg = []; detailsImg = []; + + constructor( private fb: FormBuilder, private coupon: CouponService, @@ -66,12 +70,16 @@ export class DiscountPackageEditComponent implements OnInit { private agent: AgentService, private commonsService: CommonsService, private disCountPackage: DiscountPackageService, + private discount: DiscountService ) { } ngOnInit(): void { this.commonsService.getDictionary('USING_ATTRIBUTION', data => { this.usingAttribution = data['return_data']; }); + this.commonsService.getDictionary('USING_RANGE', data => { + this.usingScope = data['return_data']; + }); this.activatedRoute.queryParams.subscribe(queryParams => { if (queryParams.id != null) { this.editFlag = true; @@ -88,8 +96,9 @@ export class DiscountPackageEditComponent implements OnInit { }); this.validateFormAward = this.fb.group({ - name: [null, [Validators.required]], + getDiscountId: [null, [Validators.required]], num: [null, [Validators.required]], + useScope: [null, [Validators.required]], }); const whereObject = { @@ -103,50 +112,11 @@ export class DiscountPackageEditComponent implements OnInit { pageSize: 800 , type: 1 }; - - this.getCouponList(whereObject); this.getListAgent(whereObjectA); } - public getCouponList(whereObject) { - whereObject.status = 2; - this.coupon.getCouponList(whereObject, data => { - if (data['return_code'] === '000000') { - this.listOfOption = data['return_data'].list; - } else { - this.message.error(data['return_msg']); - } - }); - } - - // 绑定优惠券 - public getDiscount(id: number , i ): void { - this.listOfControl[i].agentName = this.agentData.find(item => { - return item.id === id; - }).agentName; - this.agentId = id; - const whereObject = {}; - whereObject['pageNum'] = 1; - whereObject['pageSize'] = 10000; - whereObject['agentId'] = id; - this.agent.getDiscountAgentList(whereObject, data => { - if (data['return_code'] === '000000') { - this.discountList = data['return_data'].list; - } else { - this.message.error(data['return_msg']); - } - }); - } - - getDiscountName(id: number , i ) { - this.listOfControl[i].prizeName = this.discountList.find(item => { - return item['highDiscount'].id === id; - })['highDiscount'].discountName; - console.log(this.listOfControl); - } - public getListAgent(whereObject) { this.agent.getListAgent(whereObject, data => { if (data['return_code'] === '000000') { @@ -223,9 +193,9 @@ export class DiscountPackageEditComponent implements OnInit { public imgIsPost(): boolean { if (this.listImg.length !== 0) { if (this.listImg[0]['response'] != null) { - this.validateForm.value.couponImg = this.listImg[0]['response']['return_data'][0]; + this.validateForm.value.listImg = this.listImg[0]['response']['return_data'][0]; } else { - this.validateForm.value.couponImg = this.listImg[0].name; + this.validateForm.value.listImg= this.listImg[0].name; } } else { this.message.error('请上传列表图片'); @@ -260,11 +230,13 @@ export class DiscountPackageEditComponent implements OnInit { this.message.error('请上传详情展示图'); return false; } + this.validateForm.value.bannerImg = bannerImg.join(','); + this.validateForm.value.detailsImg = detailsImg.join(','); } // 查询详情 public getDetails(id) { - this.activate.getDetailById(id, data => { + this.disCountPackage.getDiscountPackageList(id, data => { if (data['return_code'] === '000000') { data['return_data'].time = [new Date(data['return_data']['startTime']), new Date(data['return_data']['endTime'])]; data['return_data'].type = String(data['return_data'].type); @@ -406,4 +378,18 @@ export class DiscountPackageEditComponent implements OnInit { } }); } + + public getDiscountPackageByList(e): void { + + const params = { + pageNum: 1, + pageSize: 10000, + useScope: e + }; + + this.discount.getDiscountList(params , data => { + this.discountList = data['return_data'].list; + console.log(data); + }); + } } 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 534cc4d..3621869 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 @@ -81,10 +81,10 @@ 编号 - 活动标题 - 活动类型 - 开始时间 - 结束时间 + 优惠券标题 + 销售类型 + 销售价格 + 限购数量 创建时间 活动状态 操作 @@ -94,21 +94,16 @@ {{i+1}} {{data.title}} - {{data.type | type}} - {{data.startTime | date: 'yyyy-MM-dd HH:mm'}} - {{data.endTime | date: 'yyyy-MM-dd HH:mm'}} - {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} - {{data.status | status}} + {{data.salesType === 1 ? '售卖' : '赠送'}} + {{data.price === null ? '暂无': data.price}} + {{data.purchaseNum === null? '暂无': data.purchaseNum}} + {{data.createdTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.status | discountPackageStatus}} - 编辑 - 发布 - 结束 - 更多操作 - - - + 编辑 + + 上架 + 下架 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 1f15dca..6e815c1 100644 --- a/src/app/admin/discount/discount-edit/discount-edit.component.html +++ b/src/app/admin/discount/discount-edit/discount-edit.component.html @@ -34,10 +34,10 @@
- 优惠券使用范围 + 优惠券使用范围 - - + + diff --git a/src/app/admin/discount/discount-edit/discount-edit.component.ts b/src/app/admin/discount/discount-edit/discount-edit.component.ts index ad11a92..d3dc50e 100644 --- a/src/app/admin/discount/discount-edit/discount-edit.component.ts +++ b/src/app/admin/discount/discount-edit/discount-edit.component.ts @@ -29,6 +29,7 @@ export class DiscountEditComponent implements OnInit { id: number; discountImg = []; usingRange = []; + usingScope = []; WEB_SERVE_URL = environment.baseUrl; previewImage: string | undefined = ''; previewVisible = false; @@ -57,7 +58,7 @@ export class DiscountEditComponent implements OnInit { discountType: [null, [Validators.required]], discountPrice: [null, [Validators.required]], salesEndTime: [null, [Validators.required]], - usingRange: [null, [Validators.required]], + usingScope: [null, [Validators.required]], effectiveDay: [1, [Validators.required]], status: [null], createTime: [null], @@ -65,7 +66,7 @@ export class DiscountEditComponent implements OnInit { }); this.commonsService.getDictionary('USING_RANGE', data => { - this.usingRange = data['return_data']; + this.usingScope = data['return_data']; }); } diff --git a/src/app/app-common.module.ts b/src/app/app-common.module.ts index 740d54e..24cc92b 100644 --- a/src/app/app-common.module.ts +++ b/src/app/app-common.module.ts @@ -35,6 +35,7 @@ import { } from './pipes'; import { PreOrderStatusPipe } from './pipes/order/pre-order-status.pipe'; import { ButtonPipe } from './pipes/commons/button.pipe'; +import { DiscountPackageStatusPipe } from './pipes/discount-package-status.pipe'; @@ -64,6 +65,7 @@ const PIPES = [ RefundStatusPipe, PreOrderStatusPipe, ButtonPipe, + DiscountPackageStatusPipe, ]; diff --git a/src/app/pipes/discount-package-status.pipe.ts b/src/app/pipes/discount-package-status.pipe.ts new file mode 100644 index 0000000..c815d67 --- /dev/null +++ b/src/app/pipes/discount-package-status.pipe.ts @@ -0,0 +1,19 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'discountPackageStatus' +}) +export class DiscountPackageStatusPipe implements PipeTransform { + + transform(value: number): string { + switch (value) { + case 1: + return '上架中'; + case 2: + return '下架中'; + case 3: + return '编辑中'; + } + } + +} diff --git a/src/app/pipes/index.ts b/src/app/pipes/index.ts index 2069b2d..59570c6 100644 --- a/src/app/pipes/index.ts +++ b/src/app/pipes/index.ts @@ -22,3 +22,4 @@ export * from './audit/refund-source.pipe'; export * from './audit/refund-status.pipe'; export * from './order/pre-order-status.pipe'; export * from './commons/button.pipe'; +export * from './discount-package-status.pipe'; diff --git a/src/app/services/discount-package.service.ts b/src/app/services/discount-package.service.ts index 1e88154..684bf0e 100644 --- a/src/app/services/discount-package.service.ts +++ b/src/app/services/discount-package.service.ts @@ -28,6 +28,7 @@ export class DiscountPackageService { } + /** * @Author Sum1Dream * @methodName insertCouponPackageInfo