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.
 
 
 
hai-oil-web/src/app/pages/merchant/mer-chain-brand-amount/mer-chain-brand-amount.comp...

247 lines
6.9 KiB

import { Component } from '@angular/core';
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzMessageService} from "ng-zorro-antd/message";
import { NzModalModule, NzModalService} from "ng-zorro-antd/modal";
import {DatePipe, NgForOf, NgIf} from "@angular/common";
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
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 {NzFlexDirective} from "ng-zorro-antd/flex";
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 {NzInputNumberComponent, NzInputNumberModule} from "ng-zorro-antd/input-number";
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
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 {MerChainBrandAmountService} from "../../../services/merchant/mer-chain-brand-amount.service";
import {MerChainBrandService} from "../../../services/merchant/mer-chain-brand.service";
@Component({
selector: 'app-mer-chain-brand-amount',
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
],
templateUrl: './mer-chain-brand-amount.component.html',
styleUrl: './mer-chain-brand-amount.component.less'
})
export class MerChainBrandAmountComponent {
// 表单页数
tablePageNum = 1;
// 每页数量
tablePageSize = 10;
// 表单数据
tableData: any = {
total: 0,
list: [],
};
// 搜索表单
searchForm: FormGroup;
// 充值表单
rechargeForm: FormGroup;
rechargeModal = false;
// 记录模态框
recordModal = false;
recordChainBrandId: any = null;
// 表单页数
recordTablePageNum = 1;
// 每页数量
recordTablePageSize = 10;
recordData: any = {
total: 0,
list: [],
};
constructor(private fb: NonNullableFormBuilder,
private message: NzMessageService,
private merChainBrandService: MerChainBrandService,
private merChainBrandAmountService: MerChainBrandAmountService,
private modalService: NzModalService) {
// 初始化搜索框
this.searchForm = this.fb.group({
merNo: [''],
merName: [''],
});
// 初始化搜索框
this.rechargeForm = this.fb.group({
id: [null, [Validators.required]],
name: [null],
amount: [null, [Validators.required]],
});
this.queryData();
}
/**
* 获取数据
*/
queryData() {
this.searchForm.value.pageNum = this.tablePageNum;
this.searchForm.value.pageSize = this.tablePageSize;
this.searchForm.value.time = new Date().getTime();
this.merChainBrandService.getList(this.searchForm.value, (data: any) => {
if (data['return_code'] == '000000') {
this.tableData = data['return_data'];
}
});
}
/**
* 搜索表单提交
*/
searchFormSubmit(): void {
this.tablePageNum = 1;
this.queryData();
}
/**
* 搜索表单重置
*/
searchFormReset(): void {
this.searchForm.reset();
}
/**
* 打卡充值模态框
* @param data
*/
showRechargeModal(data: any) {
this.rechargeForm.patchValue(data);
this.rechargeForm.controls['amount'].setValue(0);
this.rechargeForm.controls['id'].disable();
this.rechargeForm.controls['name'].disable();
this.rechargeModal = true;
}
/**
* 充值确认框
*/
rechargeConfirm() {
if (this.rechargeForm.valid) {
this.modalService.confirm({
nzTitle: '充值提醒',
nzContent: '确认为【' + this.rechargeForm.controls['name'].value + '】连锁余额充值:' +this.rechargeForm.controls['amount'].value + '元吗?',
nzOnOk: () => this.submitRecharge()
});
} else {
Object.values(this.rechargeForm.controls).forEach(control => {
if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({ onlySelf: true });
}
});
}
}
/**
* 提交表单数据
*/
submitRecharge() {
let param = this.rechargeForm.value;
param['chainBrandId'] = this.rechargeForm.controls['id'].value;
this.merChainBrandAmountService.recharge(param, (data: any) => {
if (data['return_code'] == '000000') {
this.message.create('success', '操作成功');
this.queryData();
// 关闭弹窗
this.closeRechargeModal();
} else {
this.message.create('error', data['return_msg']);
}
});
}
/**
* 关闭充值模态框
*/
closeRechargeModal() {
this.rechargeForm.reset();
this.rechargeModal = false;
}
/**
* 打开动账记录模态框
* @param merNo
*/
showRecordModal(recordChainBrandId: number) {
if (this.recordChainBrandId != recordChainBrandId) {
this.recordChainBrandId = recordChainBrandId;
// 查询数据
this.queryRecord();
}
this.recordModal = true;
}
/**
* 获取数据
*/
queryRecord() {
const param = {
chainBrandId: this.recordChainBrandId,
pageNum: this.recordTablePageNum,
pageSize: this.recordTablePageSize,
time: this.tablePageSize,
};
this.merChainBrandAmountService.getRecordList(param, (data: any) => {
if (data['return_code'] == '000000') {
this.recordData = data['return_data'];
}
});
}
}