|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
|
import {Component, OnInit} from '@angular/core'; |
|
|
|
|
import {environment} from '../../../../environments/environment'; |
|
|
|
|
import {FormBuilder, FormGroup} from '@angular/forms'; |
|
|
|
|
import {AgentService} from '../../../services/agent.service'; |
|
|
|
|
import {IconService} from '../../../services/icon.service'; |
|
|
|
|
import {NzMessageService} from 'ng-zorro-antd'; |
|
|
|
|
import {Router} from '@angular/router'; |
|
|
|
@ -11,119 +10,122 @@ import {CouponService} from '../../../services/coupon.service'; |
|
|
|
|
import {MerchantService} from '../../../services/merchant.service'; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-discount-list', |
|
|
|
|
templateUrl: './discount-list.component.html', |
|
|
|
|
styleUrls: ['./discount-list.component.scss'] |
|
|
|
|
selector: 'app-discount-list', |
|
|
|
|
templateUrl: './discount-list.component.html', |
|
|
|
|
styleUrls: ['./discount-list.component.scss'] |
|
|
|
|
}) |
|
|
|
|
export class DiscountListComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
WEB_SERVE_URL = environment.imageUrl; |
|
|
|
|
searchForm: FormGroup; // 搜索框
|
|
|
|
|
searchFormCoupon: FormGroup; // 搜索框
|
|
|
|
|
requestData = []; // 列表数据
|
|
|
|
|
couponData = []; // 列表数据
|
|
|
|
|
optionList = []; // 列表数据
|
|
|
|
|
discountCoupon = []; // 列表数据
|
|
|
|
|
total: number; // 页码
|
|
|
|
|
pageNum = 1; // 页码
|
|
|
|
|
pageSize = 10; // 条码
|
|
|
|
|
loading = true; |
|
|
|
|
isVisible = false; |
|
|
|
|
isVisibleList = false; |
|
|
|
|
couponList: any; |
|
|
|
|
requestCouponData = []; // 列表数据
|
|
|
|
|
loadingCoupon = true; |
|
|
|
|
loadingDiscountCoupon = true; |
|
|
|
|
discountId: number; |
|
|
|
|
RelByDiscountId: number; |
|
|
|
|
|
|
|
|
|
setOfCheckedId = new Set<number>(); |
|
|
|
|
checked = false; |
|
|
|
|
indeterminate = false; |
|
|
|
|
|
|
|
|
|
updateCheckedSet(id: number, checked: boolean): void { |
|
|
|
|
if (checked) { |
|
|
|
|
this.setOfCheckedId.add(id); |
|
|
|
|
} else { |
|
|
|
|
this.setOfCheckedId.delete(id); |
|
|
|
|
WEB_SERVE_URL = environment.imageUrl; |
|
|
|
|
searchForm: FormGroup; // 搜索框
|
|
|
|
|
searchFormCoupon: FormGroup; // 搜索框
|
|
|
|
|
requestData = []; // 列表数据
|
|
|
|
|
couponData = []; // 列表数据
|
|
|
|
|
optionList = []; // 列表数据
|
|
|
|
|
discountCoupon = []; // 列表数据
|
|
|
|
|
total: number; // 页码
|
|
|
|
|
pageNum = 1; // 页码
|
|
|
|
|
pageSize = 10; // 条码
|
|
|
|
|
loading = true; |
|
|
|
|
isVisible = false; |
|
|
|
|
isVisibleList = false; |
|
|
|
|
couponList: any; |
|
|
|
|
requestCouponData = []; // 列表数据
|
|
|
|
|
loadingCoupon = true; |
|
|
|
|
loadingDiscountCoupon = true; |
|
|
|
|
discountId: number; |
|
|
|
|
RelByDiscountId: number; |
|
|
|
|
usingRange = []; |
|
|
|
|
setOfCheckedId = new Set<number>(); |
|
|
|
|
checked = false; |
|
|
|
|
indeterminate = false; |
|
|
|
|
|
|
|
|
|
updateCheckedSet(id: number, checked: boolean): void { |
|
|
|
|
if (checked) { |
|
|
|
|
this.setOfCheckedId.add(id); |
|
|
|
|
} else { |
|
|
|
|
this.setOfCheckedId.delete(id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onItemChecked(id: number, checked: boolean): void { |
|
|
|
|
this.updateCheckedSet(id, checked); |
|
|
|
|
this.refreshCheckedStatus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onAllChecked(value: boolean): void { |
|
|
|
|
this.requestCouponData.forEach(item => this.updateCheckedSet(item.id, value)); |
|
|
|
|
this.refreshCheckedStatus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onItemChecked(id: number, checked: boolean): void { |
|
|
|
|
this.updateCheckedSet(id, checked); |
|
|
|
|
this.refreshCheckedStatus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onAllChecked(value: boolean): void { |
|
|
|
|
this.requestCouponData.forEach(item => this.updateCheckedSet(item.id, value)); |
|
|
|
|
this.refreshCheckedStatus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refreshCheckedStatus(): void { |
|
|
|
|
this.checked = this.requestCouponData.every(item => this.setOfCheckedId.has(item.id)); |
|
|
|
|
this.indeterminate = this.requestCouponData.some(item => this.setOfCheckedId.has(item.id)) && !this.checked; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
|
private form: FormBuilder, |
|
|
|
|
private discount: DiscountService, |
|
|
|
|
private iconService: IconService, |
|
|
|
|
private merchant: MerchantService, |
|
|
|
|
private message: NzMessageService, |
|
|
|
|
private router: Router, |
|
|
|
|
private common: CommonsService, |
|
|
|
|
private coupon: CouponService |
|
|
|
|
) { |
|
|
|
|
} |
|
|
|
|
refreshCheckedStatus(): void { |
|
|
|
|
this.checked = this.requestCouponData.every(item => this.setOfCheckedId.has(item.id)); |
|
|
|
|
this.indeterminate = this.requestCouponData.some(item => this.setOfCheckedId.has(item.id)) && !this.checked; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.init(); |
|
|
|
|
const whereObject = {}; |
|
|
|
|
whereObject['pageNum'] = 1; |
|
|
|
|
whereObject['pageSize'] = 30000; |
|
|
|
|
this.merchant.getMerchantList(whereObject , data => { |
|
|
|
|
if (data['return_code'] === '000000' ) { |
|
|
|
|
this.optionList = data['return_data'].list; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
constructor( |
|
|
|
|
private form: FormBuilder, |
|
|
|
|
private discount: DiscountService, |
|
|
|
|
private iconService: IconService, |
|
|
|
|
private merchant: MerchantService, |
|
|
|
|
private message: NzMessageService, |
|
|
|
|
private router: Router, |
|
|
|
|
private common: CommonsService, |
|
|
|
|
private coupon: CouponService |
|
|
|
|
) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public init(): void { |
|
|
|
|
this.searchForm = this.form.group({ |
|
|
|
|
discountKey: [null], |
|
|
|
|
discountName: [null], |
|
|
|
|
discountType: [null], |
|
|
|
|
}); |
|
|
|
|
this.searchFormCoupon = this.form.group({ |
|
|
|
|
merchantId: [null], |
|
|
|
|
couponName: [null], |
|
|
|
|
couponType: [null], |
|
|
|
|
couponSource: [null], |
|
|
|
|
status: [2], |
|
|
|
|
}); |
|
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
|
} |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.common.getDictionary('USING_RANGE', data => { |
|
|
|
|
this.usingRange = data['return_data']; |
|
|
|
|
}); |
|
|
|
|
this.init(); |
|
|
|
|
const whereObject = {}; |
|
|
|
|
whereObject['pageNum'] = 1; |
|
|
|
|
whereObject['pageSize'] = 30000; |
|
|
|
|
this.merchant.getMerchantList(whereObject, data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.optionList = data['return_data'].list; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询列表
|
|
|
|
|
public getRequest(reset: boolean = false, whereObject: object) { |
|
|
|
|
public init(): void { |
|
|
|
|
this.searchForm = this.form.group({ |
|
|
|
|
discountKey: [null], |
|
|
|
|
discountName: [null], |
|
|
|
|
useScope: [null], |
|
|
|
|
discountType: [null], |
|
|
|
|
}); |
|
|
|
|
this.searchFormCoupon = this.form.group({ |
|
|
|
|
merchantId: [null], |
|
|
|
|
couponName: [null], |
|
|
|
|
couponType: [null], |
|
|
|
|
couponSource: [null], |
|
|
|
|
status: [2], |
|
|
|
|
}); |
|
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.loading = false; |
|
|
|
|
if (reset) { |
|
|
|
|
this.pageNum = 1; |
|
|
|
|
// 查询列表
|
|
|
|
|
public getRequest(reset: boolean = false, whereObject: object) { |
|
|
|
|
|
|
|
|
|
this.loading = false; |
|
|
|
|
if (reset) { |
|
|
|
|
this.pageNum = 1; |
|
|
|
|
} |
|
|
|
|
whereObject['pageNum'] = this.pageNum; |
|
|
|
|
whereObject['pageSize'] = this.pageSize; |
|
|
|
|
this.discount.getDiscountList(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']); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
whereObject['pageNum'] = this.pageNum; |
|
|
|
|
whereObject['pageSize'] = this.pageSize; |
|
|
|
|
this.discount.getDiscountList(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 { |
|
|
|
|