|
|
|
@ -29,7 +29,6 @@ import {NzCheckboxModule} from "ng-zorro-antd/checkbox"; |
|
|
|
|
import {DiscountPkService} from "../../../services/discount/discount-pk.service"; |
|
|
|
|
import {environment} from "../../../../environments/environment"; |
|
|
|
|
import {Observable, Observer} from "rxjs"; |
|
|
|
|
import {ka_GE} from "ng-zorro-antd/i18n"; |
|
|
|
|
import { |
|
|
|
|
NzCellFixedDirective, |
|
|
|
|
NzTableCellDirective, |
|
|
|
@ -38,6 +37,7 @@ import { |
|
|
|
|
NzTheadComponent, |
|
|
|
|
NzThMeasureDirective, NzThSelectionComponent, NzTrDirective |
|
|
|
|
} from "ng-zorro-antd/table"; |
|
|
|
|
import {NzDividerModule} from "ng-zorro-antd/divider"; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-discount-pk-edit', |
|
|
|
@ -78,7 +78,8 @@ import { |
|
|
|
|
NzTrDirective, |
|
|
|
|
NzCellFixedDirective, |
|
|
|
|
NzTdAddOnComponent, |
|
|
|
|
NzThSelectionComponent |
|
|
|
|
NzThSelectionComponent, |
|
|
|
|
NzDividerModule |
|
|
|
|
], |
|
|
|
|
templateUrl: './discount-pk-edit.component.html', |
|
|
|
|
styleUrl: './discount-pk-edit.component.less' |
|
|
|
@ -101,6 +102,9 @@ export class DiscountPkEditComponent { |
|
|
|
|
// 选中的优惠券数据
|
|
|
|
|
checkedDiscountData: any = []; |
|
|
|
|
|
|
|
|
|
editNumberForm: FormGroup; |
|
|
|
|
editNumberModal = false; |
|
|
|
|
|
|
|
|
|
constructor(private fb: NonNullableFormBuilder, |
|
|
|
|
private merService: MerService, |
|
|
|
|
private discountService: DiscountService, |
|
|
|
@ -116,6 +120,12 @@ export class DiscountPkEditComponent { |
|
|
|
|
listImg: [null], |
|
|
|
|
content: [null], |
|
|
|
|
}); |
|
|
|
|
// 初始化表单
|
|
|
|
|
this.editNumberForm = this.fb.group({ |
|
|
|
|
discountNo: [{ value: null, disabled: true}, [Validators.required]], |
|
|
|
|
discountName: [{ value: null, disabled: true}, [Validators.required]], |
|
|
|
|
number: [null, [Validators.required]], |
|
|
|
|
}); |
|
|
|
|
// 查询优惠券数据
|
|
|
|
|
this.queryDiscount(); |
|
|
|
|
|
|
|
|
@ -160,20 +170,19 @@ export class DiscountPkEditComponent { |
|
|
|
|
submitCheckedDiscount() { |
|
|
|
|
let array = []; |
|
|
|
|
for (let discountNo of this.setOfCheckedId) { |
|
|
|
|
// 优惠券数据是否存在
|
|
|
|
|
let data = this.discountData.find((o: any) => o.discountNo == discountNo); |
|
|
|
|
if (data != null) { |
|
|
|
|
// 是否已选择
|
|
|
|
|
let checkedDiscount = this.checkedDiscountData.find((o: any) => o.discountNo == discountNo); |
|
|
|
|
if (checkedDiscount == null) { |
|
|
|
|
data['number'] = 1; |
|
|
|
|
let s = { |
|
|
|
|
discountNo: data.discountNo |
|
|
|
|
} |
|
|
|
|
array.push(data); |
|
|
|
|
} |
|
|
|
|
array.push(data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.checkedDiscountData = array; |
|
|
|
|
this.closeCheckedModal(); |
|
|
|
|
this.closeCheckedModal(); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 提交表单 |
|
|
|
@ -185,7 +194,6 @@ export class DiscountPkEditComponent { |
|
|
|
|
} |
|
|
|
|
if (this.form.valid) { |
|
|
|
|
const param = this.form.value; |
|
|
|
|
param['useScope'] = this.form.controls['useScope'].value.join(','); |
|
|
|
|
param['endTime'] = new Date(this.form.controls['endTime'].value).getTime(); |
|
|
|
|
this.discountPkService.edit(param, (data: any) => { |
|
|
|
|
if (data['return_code'] == '000000') { |
|
|
|
@ -289,11 +297,33 @@ export class DiscountPkEditComponent { |
|
|
|
|
refreshCheckedStatus(): void { |
|
|
|
|
// @ts-ignore
|
|
|
|
|
this.checked = this.discountData.every(({ discountNo }) => this.setOfCheckedId.has(discountNo)); |
|
|
|
|
|
|
|
|
|
console.log(this.setOfCheckedId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 修改数量 |
|
|
|
|
* @param data 数据 |
|
|
|
|
*/ |
|
|
|
|
showEditNumber(data: any): void { |
|
|
|
|
this.editNumberForm.patchValue(data); |
|
|
|
|
this.editNumberModal = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
editNumber() { |
|
|
|
|
if (this.editNumberForm.valid) { |
|
|
|
|
let data = this.checkedDiscountData.find((o: any) => o.discountNo == this.editNumberForm.controls['discountNo'].value); |
|
|
|
|
if (data != null) { |
|
|
|
|
data['number'] = this.editNumberForm.controls['number'].value; |
|
|
|
|
} |
|
|
|
|
this.editNumberForm.reset(); |
|
|
|
|
this.editNumberModal = false; |
|
|
|
|
} else { |
|
|
|
|
Object.values(this.editNumberForm.controls).forEach(control => { |
|
|
|
|
if (control.invalid) { |
|
|
|
|
control.markAsDirty(); |
|
|
|
|
control.updateValueAndValidity({ onlySelf: true }); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|