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.
338 lines
9.8 KiB
338 lines
9.8 KiB
import { Component } from '@angular/core';
|
|
import {DatePipe, NgForOf, NgIf} from "@angular/common";
|
|
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
|
|
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms";
|
|
import {NzButtonComponent} from "ng-zorro-antd/button";
|
|
import {
|
|
NzCellFixedDirective,
|
|
NzTableCellDirective,
|
|
NzTableComponent, NzTableModule,
|
|
NzTbodyComponent, NzTheadComponent,
|
|
NzThMeasureDirective, NzTrDirective
|
|
} from "ng-zorro-antd/table";
|
|
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
|
|
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
|
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
|
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
|
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
|
|
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
|
import {NzModalModule, NzModalService} from "ng-zorro-antd/modal";
|
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
|
import {NzDescriptionsModule} from "ng-zorro-antd/descriptions";
|
|
import {NzUploadComponent} from "ng-zorro-antd/upload";
|
|
import {NzAvatarModule} from "ng-zorro-antd/avatar";
|
|
import {NzImageModule} from "ng-zorro-antd/image";
|
|
import {NzSwitchComponent} from "ng-zorro-antd/switch";
|
|
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
|
|
import {NzInputNumberModule} from "ng-zorro-antd/input-number";
|
|
import {NzTypographyComponent} from "ng-zorro-antd/typography";
|
|
import {NzMessageService} from "ng-zorro-antd/message";
|
|
import {BrowserStorageService} from "../../../utils/localStorage.service";
|
|
import {AgentService} from "../../../services/agent/agent.service";
|
|
import {AgentStaffService} from "../../../services/agent/agent-staff.service";
|
|
import {AgentMerService} from "../../../services/agent/agent-mer.service";
|
|
import {CommonService} from "../../../services/common/common.service";
|
|
import {DATA} from "../../../data/login/localStorage.namespace";
|
|
import {MerService} from "../../../services/merchant/mer.service";
|
|
import {AgentPriceService} from "../../../services/agent/agent-price.service";
|
|
|
|
@Component({
|
|
selector: 'app-agent-price-list',
|
|
standalone: true,
|
|
imports: [
|
|
DatePipe,
|
|
DictionaryPipe,
|
|
FormsModule,
|
|
NgForOf,
|
|
NgIf,
|
|
NzButtonComponent,
|
|
NzCellFixedDirective,
|
|
NzColDirective,
|
|
NzDividerComponent,
|
|
NzDropDownADirective,
|
|
NzDropDownDirective,
|
|
NzDropdownMenuComponent,
|
|
NzFormControlComponent,
|
|
NzFormDirective,
|
|
NzFormItemComponent,
|
|
NzFormLabelComponent,
|
|
NzIconDirective,
|
|
NzInputDirective,
|
|
NzMenuDirective,
|
|
NzMenuItemComponent,
|
|
NzOptionComponent,
|
|
NzRowDirective,
|
|
NzSelectComponent,
|
|
NzTableCellDirective,
|
|
NzTableComponent,
|
|
NzTbodyComponent,
|
|
NzThMeasureDirective,
|
|
NzTheadComponent,
|
|
NzTrDirective,
|
|
ReactiveFormsModule,
|
|
NzTableModule,
|
|
NzModalModule,
|
|
NzFlexDirective,
|
|
NzDescriptionsModule,
|
|
NzUploadComponent,
|
|
NzAvatarModule,
|
|
NzImageModule,
|
|
NzSwitchComponent,
|
|
NzDatePickerComponent,
|
|
NzInputNumberModule,
|
|
NzTypographyComponent
|
|
],
|
|
templateUrl: './agent-price-list.component.html',
|
|
styleUrl: './agent-price-list.component.less'
|
|
})
|
|
export class AgentPriceListComponent {
|
|
// 表单页数
|
|
tablePageNum = 1;
|
|
// 每页数量
|
|
tablePageSize = 10;
|
|
// 表单数据
|
|
tableData: any = {
|
|
total: 0,
|
|
list: [],
|
|
};
|
|
// 搜索表单
|
|
searchForm: FormGroup;
|
|
// 油站来源
|
|
merSourceTypeArray = new DictionaryPipe().getDictionaryList('MER_SOURCE_TYPE');
|
|
// 油号
|
|
oilNoArray = new DictionaryPipe().getDictionaryList('OIL_NO');
|
|
// 地区数据
|
|
regionData: any = [];
|
|
// 优惠详情模态框
|
|
discountDetailModal = false;
|
|
// 优惠详情数据
|
|
discountDetailObj: any = [];
|
|
// 修改优惠模态框
|
|
updateDiscountModal = false;
|
|
updateDiscountForm: FormGroup;
|
|
// 批量修改优惠模态框
|
|
batchUpdateDiscountModal = false;
|
|
// 列表中全选状态
|
|
checked = false;
|
|
// 已选择的数据
|
|
setOfCheckedId = new Set<string>();
|
|
constructor(private fb: NonNullableFormBuilder,
|
|
private merService: MerService,
|
|
private message: NzMessageService,
|
|
private agentPriceService: AgentPriceService,
|
|
private agentMerService: AgentMerService,
|
|
private commonService: CommonService,
|
|
private modal: NzModalService) {
|
|
// 初始化搜索框
|
|
this.searchForm = this.fb.group({
|
|
sourceType: [''],
|
|
provinceCode: [''],
|
|
merNo: [''],
|
|
merName: [''],
|
|
status: [''],
|
|
});
|
|
|
|
this.updateDiscountForm = this.fb.group({
|
|
merNo: [''],
|
|
oilNo: ['', [Validators.required]],
|
|
priceRate: ['', [Validators.required]],
|
|
serviceFeeRate: ['', [Validators.required]],
|
|
});
|
|
// 获取地区
|
|
this.commonService.getRegion("", (data: any) => {
|
|
this.regionData = data['return_data'];
|
|
});
|
|
|
|
this.queryData();
|
|
}
|
|
|
|
/**
|
|
* 获取数据
|
|
*/
|
|
queryData() {
|
|
this.searchForm.value.pageNum = this.tablePageNum;
|
|
this.searchForm.value.pageSize = this.tablePageSize;
|
|
this.searchForm.value.time = new Date().getTime();
|
|
this.agentMerService.getAllotList(this.searchForm.value, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.tableData = data['return_data'];
|
|
this.refreshCheckedStatus();
|
|
}
|
|
});
|
|
}
|
|
|
|
updateCheckedSet(merNo: string, checked: boolean): void {
|
|
if (checked) {
|
|
this.setOfCheckedId.add(merNo);
|
|
} else {
|
|
this.setOfCheckedId.delete(merNo);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 单选
|
|
* @param merNo
|
|
* @param checked
|
|
*/
|
|
onItemChecked(merNo: string, checked: boolean): void {
|
|
this.updateCheckedSet(merNo, checked);
|
|
this.refreshCheckedStatus();
|
|
}
|
|
|
|
/**
|
|
* 全选
|
|
* @param checked
|
|
*/
|
|
onAllChecked(checked: boolean): void {
|
|
// @ts-ignore
|
|
this.tableData.list.forEach(({ merNo }) => this.updateCheckedSet(merNo, checked));
|
|
this.refreshCheckedStatus();
|
|
}
|
|
|
|
/**
|
|
* 刷新数据
|
|
*/
|
|
refreshCheckedStatus(): void {
|
|
// @ts-ignore
|
|
this.checked = this.tableData.list.every(({ merNo }) => this.setOfCheckedId.has(merNo));
|
|
console.log(this.setOfCheckedId);
|
|
}
|
|
|
|
/**
|
|
* 搜索表单提交
|
|
*/
|
|
searchFormSubmit(): void {
|
|
this.tablePageNum = 1;
|
|
this.queryData();
|
|
}
|
|
|
|
/**
|
|
* 搜索表单重置
|
|
*/
|
|
searchFormReset(): void {
|
|
this.searchForm.reset();
|
|
}
|
|
|
|
/**
|
|
* 打开批量调整弹出框
|
|
*/
|
|
showBatchUpdateDiscount() {
|
|
this.batchUpdateDiscountModal = true;
|
|
this.searchForm.controls['oilNo'].enable();
|
|
}
|
|
|
|
/**
|
|
* 提交批量修改
|
|
*/
|
|
submitBatchUpdateDiscount() {
|
|
if (this.setOfCheckedId.size == 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请再列中勾选需要调整油站'
|
|
});
|
|
return;
|
|
}
|
|
if (this.updateDiscountForm.valid) {
|
|
let param = this.updateDiscountForm.value;
|
|
let merNoList = [];
|
|
for (let merNo of this.setOfCheckedId) {
|
|
merNoList.push({merNo: merNo});
|
|
}
|
|
param['merNoList'] = merNoList;
|
|
param['oilNo'] = this.updateDiscountForm.controls['oilNo'].value;
|
|
this.agentPriceService.batchConfigPrice(param, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.message.create('success', '操作成功');
|
|
// 关闭弹窗
|
|
this.closeBatchUpdateDiscount();
|
|
} else {
|
|
this.message.create('error', data['return_msg']);
|
|
}
|
|
});
|
|
} else {
|
|
Object.values(this.updateDiscountForm.controls).forEach(control => {
|
|
if (control.invalid) {
|
|
control.markAsDirty();
|
|
control.updateValueAndValidity({ onlySelf: true });
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 关闭批量调整弹出框
|
|
*/
|
|
closeBatchUpdateDiscount() {
|
|
this.batchUpdateDiscountModal = false;
|
|
}
|
|
/**
|
|
* 打开优惠详情
|
|
*/
|
|
showDiscountDetail(merNo: string) {
|
|
this.agentPriceService.getOilNoPrice({merNo: merNo}, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.discountDetailObj = data['return_data'];
|
|
}
|
|
});
|
|
this.discountDetailModal = true;
|
|
}
|
|
|
|
/**
|
|
* 关闭优惠详情
|
|
*/
|
|
closeDiscountDetail() {
|
|
this.discountDetailModal = false;
|
|
}
|
|
|
|
/**
|
|
* 打开修改优惠模态框
|
|
* @param data
|
|
*/
|
|
showUpdateDiscount(data: any) {
|
|
this.updateDiscountForm.patchValue(data);
|
|
this.updateDiscountForm.controls['oilNo'].disable();
|
|
this.updateDiscountModal = true;
|
|
}
|
|
|
|
/**
|
|
* 提交修改优惠
|
|
*/
|
|
submitUpdateDiscount() {
|
|
if (this.updateDiscountForm.valid) {
|
|
this.updateDiscountForm.value;
|
|
let paramArr = [];
|
|
let param = this.updateDiscountForm.value;
|
|
param['oilNo'] = this.updateDiscountForm.controls['oilNo'].value;
|
|
paramArr.push(param);
|
|
this.agentPriceService.editPrice(paramArr, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.message.create('success', '操作成功');
|
|
// 关闭弹窗
|
|
this.closeUpdateDiscount();
|
|
// 刷新数据
|
|
this.showDiscountDetail(param['merNo']);
|
|
// 表单重置
|
|
this.updateDiscountForm.reset();
|
|
} else {
|
|
this.message.create('error', data['return_msg']);
|
|
}
|
|
});
|
|
} else {
|
|
Object.values(this.updateDiscountForm.controls).forEach(control => {
|
|
if (control.invalid) {
|
|
control.markAsDirty();
|
|
control.updateValueAndValidity({ onlySelf: true });
|
|
}
|
|
});
|
|
}
|
|
}
|
|
/**
|
|
* 关闭修改优惠模态框
|
|
*/
|
|
closeUpdateDiscount() {
|
|
this.updateDiscountForm.reset();
|
|
this.updateDiscountModal = false;
|
|
}
|
|
}
|
|
|