惠支付PC管理端
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.
 
 
 
 
 
gratia-pay-web/src/app/admin/company/company-list/company-list.component.ts

143 lines
4.4 KiB

import { Component, OnInit } from '@angular/core';
import {UntypedFormBuilder, UntypedFormGroup, Validators} from '@angular/forms';
import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {CompanyService} from '../../../services/company.service';
import {CommonsService} from '../../../services/commons.service';
import {TradeTakeConfigService} from '../../../services/trade-take-config.service';
@Component({
selector: 'app-company-list',
templateUrl: './company-list.component.html',
styleUrls: ['./company-list.component.scss']
})
export class CompanyListComponent implements OnInit {
dataObject: any = {};
tableLoading = true;
searchForm: UntypedFormGroup;
tradeTakeConfigForm: UntypedFormGroup;
pageNum: number;
whereObject: any = {};
tradeTakeConfigMadel = false;
platformTypeArray = [];
constructor(private modal: NzModalService,
private message: NzMessageService,
private companyService: CompanyService,
private commonsService: CommonsService,
private tradeTakeConfigService: TradeTakeConfigService,
private form: UntypedFormBuilder) { }
ngOnInit(): void {
this.searchForm = this.form.group({
name: [null],
});
this.commonsService.getDictionary('PLATFORM_TYPE', data => {
this.platformTypeArray = data['return_data'];
});
this.tradeTakeConfigForm = this.form.group({
companyId: [null, [Validators.required]],
platformType: ['4', [Validators.required]],
receiverName: [null, [Validators.required]],
receiverAccount: [null, [Validators.required]],
receiverRatio: [0, [Validators.required]]
});
this.requestData(1);
}
/**
* 请求数据
*/
requestData(pageNum) {
this.tableLoading = true;
this.whereObject['pageNum'] = pageNum;
this.whereObject['pageSize'] = 10;
this.companyService.selectCompanyList(this.whereObject, data => {
if (data['return_code'] === '000000') {
this.dataObject = data['return_data'];
} else {
this.modal.error(data['return_msg']);
}
this.tableLoading = false;
});
}
/**
* 搜索
* @param whereObject 条件
*/
search(whereObject: object) {
this.whereObject = whereObject;
this.requestData(1);
}
/**
* 重置
*/
resetForm(): void {
this.searchForm.reset();
}
/**
* 展示交易分账配置
*/
showTradeTakeConfigMadel(companyId: number) {
this.tradeTakeConfigService.getTradeTakeConfig(companyId, this.tradeTakeConfigForm.controls['platformType'].value, 1 , 2, null, data => {
if (data['return_code'] === '000000') {
if (data['return_data'] != null) {
data['return_data']['platformType'] = String(data['return_data']['platformType']);
data['return_data']['receiverRatio'] = data['return_data']['receiverRatio'] * 100;
this.tradeTakeConfigForm.patchValue(data['return_data']);
} else {
this.tradeTakeConfigForm.controls['companyId'].setValue(companyId);
}
}
});
this.tradeTakeConfigMadel = true;
}
/**
* 关闭交易分账配置
*/
closeTradeTakeConfigMadel() {
this.tradeTakeConfigForm.reset();
this.tradeTakeConfigForm.controls['platformType'].setValue('4');
this.tradeTakeConfigForm.controls['receiverRatio'].setValue(0);
this.tradeTakeConfigMadel = false;
}
/**
* 提交配置
*/
submitTradeTakeConfig() {
for (const i in this.tradeTakeConfigForm.controls) {
this.tradeTakeConfigForm.controls[i].markAsDirty();
this.tradeTakeConfigForm.controls[i].updateValueAndValidity();
}
if (this.tradeTakeConfigForm.status == null || this.tradeTakeConfigForm.status !== 'VALID') {
this.modal.warning({
nzTitle: '提示',
nzContent: '请规范填写所有的必填项信息',
});
return;
}
this.tradeTakeConfigForm.value['receiverRatio'] = this.tradeTakeConfigForm.controls['receiverRatio']['value'] / 100;
this.tradeTakeConfigService.editParentCompanyConfig(this.tradeTakeConfigForm.value, data => {
if (data['return_code'] === '000000') {
this.modal.success({
nzTitle: '提示',
nzContent: '保存成功',
nzOnOk: () => this.closeTradeTakeConfigMadel()
});
} else {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg'],
});
}
});
}
}