|
|
@ -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 {ActivatedRoute} from '_@angular_router@9.0.7@@angular/router'; |
|
|
|
import {CouponService} from '../../../services/coupon.service'; |
|
|
|
import {CouponService} from '../../../services/coupon.service'; |
|
|
|
import {ActivateService} from '../../../services/activate.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<string | ArrayBuffer | null> { |
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
const reader = new FileReader(); |
|
|
|
|
|
|
|
reader.readAsDataURL(file); |
|
|
|
|
|
|
|
reader.onload = () => resolve(reader.result); |
|
|
|
|
|
|
|
reader.onerror = error => reject(error); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-activate-edit', |
|
|
|
selector: 'app-activate-edit', |
|
|
@ -17,14 +31,36 @@ export class ActivateEditComponent implements OnInit { |
|
|
|
data: any; |
|
|
|
data: any; |
|
|
|
editFlag = false; |
|
|
|
editFlag = false; |
|
|
|
id: number; |
|
|
|
id: number; |
|
|
|
|
|
|
|
agentId: number; |
|
|
|
listOfOption: string[] = []; |
|
|
|
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( |
|
|
|
constructor( |
|
|
|
private fb: FormBuilder, |
|
|
|
private fb: FormBuilder, |
|
|
|
private coupon: CouponService, |
|
|
|
private coupon: CouponService, |
|
|
|
private activate: ActivateService, |
|
|
|
private activate: ActivateService, |
|
|
|
private message: NzMessageService, // 信息提示
|
|
|
|
private message: NzMessageService, // 信息提示
|
|
|
|
private activatedRoute: ActivatedRoute, |
|
|
|
private activatedRoute: ActivatedRoute, |
|
|
|
|
|
|
|
private agent: AgentService, |
|
|
|
|
|
|
|
private discount: DiscountService, |
|
|
|
|
|
|
|
private msg: NzMessageService, |
|
|
|
) { } |
|
|
|
) { } |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
ngOnInit(): void { |
|
|
@ -44,17 +80,31 @@ export class ActivateEditComponent implements OnInit { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.validateFormAward = this.fb.group({ |
|
|
|
this.validateFormAward = this.fb.group({ |
|
|
|
activityInfoId: [null, [Validators.required]], |
|
|
|
|
|
|
|
img: [null, [Validators.required]], |
|
|
|
|
|
|
|
name: [null, [Validators.required]], |
|
|
|
name: [null, [Validators.required]], |
|
|
|
|
|
|
|
img: [null, [Validators.required]], |
|
|
|
num: [null, [Validators.required]], |
|
|
|
num: [null, [Validators.required]], |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const whereObject = { |
|
|
|
const whereObject = { |
|
|
|
pageNum: 1 , |
|
|
|
pageNum: 1 , |
|
|
|
pageSize: 200 , |
|
|
|
pageSize: 800 , |
|
|
|
status: 2 , |
|
|
|
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 => { |
|
|
|
this.coupon.getCouponList(whereObject, data => { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
this.listOfOption = data['return_data'].list; |
|
|
|
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() { |
|
|
|
getBack() { |
|
|
|
history.back(); |
|
|
|
history.back(); |
|
|
@ -128,8 +224,10 @@ export class ActivateEditComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
// 下一步
|
|
|
|
// 下一步
|
|
|
|
getNest(): void { |
|
|
|
getNest(): void { |
|
|
|
if (this.current === 1) { |
|
|
|
if (this.current === 0) { |
|
|
|
this.editActivityInfo(); |
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|