You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
4.3 KiB
151 lines
4.3 KiB
import { Component, OnInit } from '@angular/core';
|
|
import {environment} from '../../../../environments/environment';
|
|
import {FormBuilder, FormGroup} from '_@angular_forms@9.0.7@@angular/forms';
|
|
import {CompanyService} from '../../../services/company.service';
|
|
import {ActivateService} from '../../../services/activate.service';
|
|
import {IconService} from '../../../services/icon.service';
|
|
import {NzMessageService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd';
|
|
import {Router} from '_@angular_router@9.0.7@@angular/router';
|
|
import {CommonsService} from '../../../services/commons.service';
|
|
import {DiscountPackageService} from '../../../services/discount-package.service';
|
|
|
|
@Component({
|
|
selector: 'app-discount-package-list',
|
|
templateUrl: './discount-package-list.component.html',
|
|
styleUrls: ['./discount-package-list.component.scss']
|
|
})
|
|
export class DiscountPackageListComponent implements OnInit {
|
|
|
|
WEB_SERVE_URL = environment.imageUrl;
|
|
searchForm: FormGroup; // 搜索框
|
|
requestData = []; // 列表数据
|
|
usingAttribution = []; // 列表数据
|
|
total: number; // 页码
|
|
pageNum = 1; // 页码
|
|
pageSize = 10; // 条码
|
|
loading = true;
|
|
listOfData = [];
|
|
isVisible = false;
|
|
|
|
constructor(
|
|
private form: FormBuilder,
|
|
private company: CompanyService,
|
|
private activate: ActivateService,
|
|
private iconService: IconService,
|
|
private message: NzMessageService,
|
|
private router: Router,
|
|
private discountPackage: DiscountPackageService,
|
|
private commonsService: CommonsService,
|
|
) {
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
this.init();
|
|
}
|
|
|
|
public init(): void {
|
|
this.searchForm = this.form.group({
|
|
title: [null],
|
|
salesType: [null],
|
|
usingAttribution: [null],
|
|
recordNo: [null],
|
|
phone: [null],
|
|
});
|
|
this.getRequest(true, this.searchForm.value);
|
|
this.commonsService.getDictionary('USING_ATTRIBUTION ', data => {
|
|
this.usingAttribution = data['return_data'];
|
|
});
|
|
}
|
|
|
|
// 查询列表
|
|
public getRequest(reset: boolean = false, whereObject: object) {
|
|
|
|
this.loading = false;
|
|
if (reset) {
|
|
this.pageNum = 1;
|
|
}
|
|
whereObject['pageNum'] = this.pageNum;
|
|
whereObject['pageSize'] = this.pageSize;
|
|
this.discountPackage.getDiscountPackageList(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 {
|
|
this.searchForm.reset();
|
|
}
|
|
|
|
// 活动开始
|
|
public upDiscountPackage(id: number): void {
|
|
this.discountPackage.upDiscountPackage({discountId : id}, data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.message.success('上架成功');
|
|
this.getRequest(true, this.searchForm.value);
|
|
} else {
|
|
this.message.error(data['return_msg']);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 活动结束
|
|
public downDiscountPackage(id: number): void {
|
|
this.discountPackage.downDiscountPackage({discountId : id}, data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.message.success('下架成功');
|
|
this.getRequest(true, this.searchForm.value);
|
|
} else {
|
|
this.message.error(data['return_msg']);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 删除
|
|
public deleteDiscountPackage(id: number): void {
|
|
this.commonsService.showConfirm('是否确认删除', isDelete => {
|
|
if (isDelete) {
|
|
this.discountPackage.deleteDiscountPackage({discountId : id}, data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.message.success('删除成功');
|
|
this.getRequest(true, this.searchForm.value);
|
|
} else {
|
|
this.message.error(data['return_msg']);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
// 修改
|
|
public getEdit(id: number): void {
|
|
this.router.navigate(['/admin/discount-package/discount-package-edit'], {
|
|
queryParams: {
|
|
id
|
|
}
|
|
}).then(r => console.log(r));
|
|
}
|
|
|
|
handleCancel(): void {
|
|
this.isVisible = false;
|
|
}
|
|
|
|
public getDetails(id: number): void {
|
|
this.discountPackage.getDiscountPackageRuleById(id , data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.listOfData = data['return_data'];
|
|
this.isVisible = true;
|
|
} else {
|
|
this.message.create('error', data['return_msg']);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|