diff --git a/src/app/admin/activate/activate-edit/activate-edit.component.html b/src/app/admin/activate/activate-edit/activate-edit.component.html index 255950f..72c2b5d 100644 --- a/src/app/admin/activate/activate-edit/activate-edit.component.html +++ b/src/app/admin/activate/activate-edit/activate-edit.component.html @@ -34,7 +34,7 @@ formControlName="productIdArray" nzPlaceHolder="请选择有抽奖资格的产品" > - + @@ -67,10 +67,38 @@ -
-
+ +
+ 共计 {{11}} 条数据 +
+
- + + + + 奖励名称 + 数量 + 图片 + 操作 + + + + + {{ data.name }} + {{ data.num }} + + + + + Action 一 {{ data.name }} + + Delete + + + + + +
@@ -79,3 +107,84 @@
+ + + + +
基本信息
+
+ + 奖励名称 + + + + + + 奖励数量 + + + + + + 奖励图片 + + + +
上传图片
+
+ + + + + +
+
+
+
奖品信息
+
+
+
+ + 代理商 + + + + + {{control.agentName}} + + +
+
+ + 优惠券 + + + + + {{control.discountName}} + + +
+
+ + 奖励数量 + + + {{control.prizeNum}} + + +
+
+
+ +
+ +
+
+
diff --git a/src/app/admin/activate/activate-edit/activate-edit.component.scss b/src/app/admin/activate/activate-edit/activate-edit.component.scss index 60ffd9a..dd309eb 100644 --- a/src/app/admin/activate/activate-edit/activate-edit.component.scss +++ b/src/app/admin/activate/activate-edit/activate-edit.component.scss @@ -1,14 +1,62 @@ .main { width: 90%; margin-left: 5%; - .title { - width: 100%; - height: 46px; - line-height: 46px; - font-size: 16px; - text-align: center; - color: #1890ff; - background-color: #f3f9ff; - margin-bottom: 20px; + .idCard { + img { + width: 200px; + } + .userImg { + width: 90px; + } } + .post_p_l { + margin-left: 5% ; + } + .main_post_p { + font-size: 12px; + color: #999999; + margin-top: -10px; + } + .btn { + margin-top: 20px; + } + .bottom_solid { + border-bottom: 1px solid #e4e4e4; + } + .btn-post { + width: 20%; + margin-left: 40%; + margin-top: 40px; + } + +} +.pics{ + display: flex; + align-items: center; + +} +.pic{ + width:10rem; + height:8rem; + margin-right: 1rem; + position: relative; +} +.delPic{ + width:1rem !important; + height:1rem; + position: absolute; + right: -10px;top:-10px; +} +.btn { + margin-top: 20px; +} +.title { + width: 100%; + height: 46px; + line-height: 46px; + font-size: 16px; + text-align: center; + color: #1890ff; + background-color: #f3f9ff; + margin-bottom: 20px; } diff --git a/src/app/admin/activate/activate-edit/activate-edit.component.ts b/src/app/admin/activate/activate-edit/activate-edit.component.ts index cbb0809..7f0a115 100644 --- a/src/app/admin/activate/activate-edit/activate-edit.component.ts +++ b/src/app/admin/activate/activate-edit/activate-edit.component.ts @@ -4,6 +4,20 @@ import {NzMessageService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; import {ActivatedRoute} from '_@angular_router@9.0.7@@angular/router'; import {CouponService} from '../../../services/coupon.service'; import {ActivateService} from '../../../services/activate.service'; +import {NzUploadFile} from 'ng-zorro-antd'; +import {environment} from '../../../../environments/environment'; +import {Observable, Observer} from 'rxjs'; +import {AgentService} from "../../../services/agent.service"; +import {DiscountService} from "../../../services/discount.service"; + +function getBase64(file: File): Promise { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result); + reader.onerror = error => reject(error); + }); +} @Component({ selector: 'app-activate-edit', @@ -17,14 +31,36 @@ export class ActivateEditComponent implements OnInit { data: any; editFlag = false; id: number; + agentId: number; listOfOption: string[] = []; - current = 0; + listOfData = []; + agentData = []; + current = 1; + listOfControl = [{ + isEdit: true, + agentId: null, + agentName: null, + prizeNum: null, + prizeId: null, + discountName: null, + loading : false + }]; + FILE_URL = environment.imageUrl; + POST_URL = environment.baseUrl; + isVisible = false; + logoFile = []; + previewImage: string | undefined = ''; + previewVisible = false; + discountList = []; // 列表数据 constructor( private fb: FormBuilder, private coupon: CouponService, private activate: ActivateService, private message: NzMessageService, // 信息提示 private activatedRoute: ActivatedRoute, + private agent: AgentService, + private discount: DiscountService, + private msg: NzMessageService, ) { } ngOnInit(): void { @@ -44,17 +80,31 @@ export class ActivateEditComponent implements OnInit { }); this.validateFormAward = this.fb.group({ - activityInfoId: [null, [Validators.required]], - img: [null, [Validators.required]], name: [null, [Validators.required]], + img: [null, [Validators.required]], num: [null, [Validators.required]], }); const whereObject = { pageNum: 1 , - pageSize: 200 , - status: 2 , + pageSize: 800 , + status: 2 }; + + const whereObjectA = { + pageNum: 1 , + 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; @@ -64,6 +114,52 @@ export class ActivateEditComponent implements OnInit { }); } + // 绑定优惠券 + 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].discountName = 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') { + this.agentData = data['return_data'].list; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 图片查看 + handlePreview = async (file: NzUploadFile) => { + if (!file.url && !file.preview) { + // tslint:disable-next-line:no-non-null-assertion + file.preview = await getBase64(file.originFileObj!); + } + this.previewImage = file.url || file.preview; + this.previewVisible = true; + } + // 返回 getBack() { history.back(); @@ -128,8 +224,10 @@ export class ActivateEditComponent implements OnInit { // 下一步 getNest(): void { - if (this.current === 1) { + if (this.current === 0) { this.editActivityInfo(); + } else { + } } @@ -140,4 +238,79 @@ export class ActivateEditComponent implements OnInit { } + // 新增 + addField(i): void { + if ( + this.listOfControl[i].prizeId == null || + this.listOfControl[i].prizeNum == null || + this.listOfControl[i].agentId == null + ) { + this.message.error('请填写必填项!'); + return; + } + this.listOfControl[i].isEdit = false; + const control = { + isEdit: true, + agentId: null, + agentName: null, + prizeNum: null, + prizeId: null, + discountName: null, + loading : false + }; + this.listOfControl.push(control); + + } + + // 删除资质 + removeField(i, e: MouseEvent): void { + e.preventDefault(); + if (this.listOfControl.length > 1) { + this.listOfControl.splice(i, 1); + this.listOfControl[i - 1].isEdit = true; + } + } + + + // 添加配置 + getAdd(): void { + this.isVisible = true; + } + + + handleOk(): void { + + // tslint:disable-next-line:forin + for (const i in this.validateFormAward.controls) { + this.validateFormAward.controls[i].markAsDirty(); + this.validateFormAward.controls[i].updateValueAndValidity(); + if (this.validateFormAward.controls[i].errors != null) { + this.message.error('必填项不能为空'); + return; + } + } + + if ( + this.listOfControl[this.listOfControl.length - 1].prizeId == null || + this.listOfControl[this.listOfControl.length - 1].prizeNum == null || + this.listOfControl[this.listOfControl.length - 1].agentId == null + ) { + this.message.error('请填写必填项!'); + return; + } + + this.validateForm.value.ruleArray = [{ + partakeMode: 1, + productType: 1 , + productIdArray: this.validateForm.value.productIdArray + }]; + + console.log(this.listOfControl); + + } + + handleCancel(): void { + this.isVisible = false; + } + } diff --git a/src/assets/images/post.png b/src/assets/images/post.png new file mode 100644 index 0000000..fd650f6 Binary files /dev/null and b/src/assets/images/post.png differ