|
|
@ -9,6 +9,7 @@ import {environment} from '../../../../environments/environment'; |
|
|
|
import {AgentService} from '../../../services/agent.service'; |
|
|
|
import {AgentService} from '../../../services/agent.service'; |
|
|
|
import {CommonsService} from "../../../services/commons.service"; |
|
|
|
import {CommonsService} from "../../../services/commons.service"; |
|
|
|
import {DiscountPackageService} from "../../../services/discount-package.service"; |
|
|
|
import {DiscountPackageService} from "../../../services/discount-package.service"; |
|
|
|
|
|
|
|
import {DiscountService} from "../../../services/discount.service"; |
|
|
|
|
|
|
|
|
|
|
|
function getBase64(file: File): Promise<string | ArrayBuffer | null> { |
|
|
|
function getBase64(file: File): Promise<string | ArrayBuffer | null> { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
@ -53,10 +54,13 @@ export class DiscountPackageEditComponent implements OnInit { |
|
|
|
previewImage: string | undefined = ''; |
|
|
|
previewImage: string | undefined = ''; |
|
|
|
previewVisible = false; |
|
|
|
previewVisible = false; |
|
|
|
discountList = []; // 列表数据
|
|
|
|
discountList = []; // 列表数据
|
|
|
|
|
|
|
|
usingScope = []; // 列表数据
|
|
|
|
|
|
|
|
|
|
|
|
listImg = []; |
|
|
|
listImg = []; |
|
|
|
bannerImg = []; |
|
|
|
bannerImg = []; |
|
|
|
detailsImg = []; |
|
|
|
detailsImg = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
constructor( |
|
|
|
private fb: FormBuilder, |
|
|
|
private fb: FormBuilder, |
|
|
|
private coupon: CouponService, |
|
|
|
private coupon: CouponService, |
|
|
@ -66,12 +70,16 @@ export class DiscountPackageEditComponent implements OnInit { |
|
|
|
private agent: AgentService, |
|
|
|
private agent: AgentService, |
|
|
|
private commonsService: CommonsService, |
|
|
|
private commonsService: CommonsService, |
|
|
|
private disCountPackage: DiscountPackageService, |
|
|
|
private disCountPackage: DiscountPackageService, |
|
|
|
|
|
|
|
private discount: DiscountService |
|
|
|
) { } |
|
|
|
) { } |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
ngOnInit(): void { |
|
|
|
this.commonsService.getDictionary('USING_ATTRIBUTION', data => { |
|
|
|
this.commonsService.getDictionary('USING_ATTRIBUTION', data => { |
|
|
|
this.usingAttribution = data['return_data']; |
|
|
|
this.usingAttribution = data['return_data']; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
this.commonsService.getDictionary('USING_RANGE', data => { |
|
|
|
|
|
|
|
this.usingScope = data['return_data']; |
|
|
|
|
|
|
|
}); |
|
|
|
this.activatedRoute.queryParams.subscribe(queryParams => { |
|
|
|
this.activatedRoute.queryParams.subscribe(queryParams => { |
|
|
|
if (queryParams.id != null) { |
|
|
|
if (queryParams.id != null) { |
|
|
|
this.editFlag = true; |
|
|
|
this.editFlag = true; |
|
|
@ -88,8 +96,9 @@ export class DiscountPackageEditComponent implements OnInit { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.validateFormAward = this.fb.group({ |
|
|
|
this.validateFormAward = this.fb.group({ |
|
|
|
name: [null, [Validators.required]], |
|
|
|
getDiscountId: [null, [Validators.required]], |
|
|
|
num: [null, [Validators.required]], |
|
|
|
num: [null, [Validators.required]], |
|
|
|
|
|
|
|
useScope: [null, [Validators.required]], |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const whereObject = { |
|
|
|
const whereObject = { |
|
|
@ -103,50 +112,11 @@ export class DiscountPackageEditComponent implements OnInit { |
|
|
|
pageSize: 800 , |
|
|
|
pageSize: 800 , |
|
|
|
type: 1 |
|
|
|
type: 1 |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this.getCouponList(whereObject); |
|
|
|
|
|
|
|
this.getListAgent(whereObjectA); |
|
|
|
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) { |
|
|
|
public getListAgent(whereObject) { |
|
|
|
this.agent.getListAgent(whereObject, data => { |
|
|
|
this.agent.getListAgent(whereObject, data => { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
@ -223,9 +193,9 @@ export class DiscountPackageEditComponent implements OnInit { |
|
|
|
public imgIsPost(): boolean { |
|
|
|
public imgIsPost(): boolean { |
|
|
|
if (this.listImg.length !== 0) { |
|
|
|
if (this.listImg.length !== 0) { |
|
|
|
if (this.listImg[0]['response'] != null) { |
|
|
|
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 { |
|
|
|
} else { |
|
|
|
this.validateForm.value.couponImg = this.listImg[0].name; |
|
|
|
this.validateForm.value.listImg= this.listImg[0].name; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.error('请上传列表图片'); |
|
|
|
this.message.error('请上传列表图片'); |
|
|
@ -260,11 +230,13 @@ export class DiscountPackageEditComponent implements OnInit { |
|
|
|
this.message.error('请上传详情展示图'); |
|
|
|
this.message.error('请上传详情展示图'); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.validateForm.value.bannerImg = bannerImg.join(','); |
|
|
|
|
|
|
|
this.validateForm.value.detailsImg = detailsImg.join(','); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询详情
|
|
|
|
// 查询详情
|
|
|
|
public getDetails(id) { |
|
|
|
public getDetails(id) { |
|
|
|
this.activate.getDetailById(id, data => { |
|
|
|
this.disCountPackage.getDiscountPackageList(id, data => { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
data['return_data'].time = [new Date(data['return_data']['startTime']), new Date(data['return_data']['endTime'])]; |
|
|
|
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); |
|
|
|
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); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|