|
|
|
@ -1,10 +1,12 @@ |
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
|
import {NzMessageService, NzModalService} from 'ng-zorro-antd'; |
|
|
|
|
import {AgentService} from '../../../services/agent.service'; |
|
|
|
|
import {FormBuilder, FormGroup} from '@angular/forms'; |
|
|
|
|
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
|
|
|
|
import {CompanyService} from '../../../services/company.service'; |
|
|
|
|
import {LocalStorageService} from '../../../services/local-storage.service'; |
|
|
|
|
import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace'; |
|
|
|
|
import {TradeTakeConfigService} from '../../../services/trade-take-config.service'; |
|
|
|
|
import {CommonsService} from '../../../services/commons.service'; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-agent-list', |
|
|
|
@ -16,26 +18,46 @@ export class AgentListComponent implements OnInit { |
|
|
|
|
dataObject: any = {}; |
|
|
|
|
tableLoading = true; |
|
|
|
|
searchForm: FormGroup; |
|
|
|
|
tradeTakeConfigForm: FormGroup; |
|
|
|
|
pageNum: number; |
|
|
|
|
whereObject: any = {}; |
|
|
|
|
|
|
|
|
|
userObjectType: number; |
|
|
|
|
companyArray = []; |
|
|
|
|
|
|
|
|
|
tradeTakeConfigMadel = false; |
|
|
|
|
platformTypeArray = []; |
|
|
|
|
|
|
|
|
|
constructor(private modal: NzModalService, |
|
|
|
|
private message: NzMessageService, |
|
|
|
|
private agentService: AgentService, |
|
|
|
|
private companyService: CompanyService, |
|
|
|
|
private commonsService: CommonsService, |
|
|
|
|
private localStorageService: LocalStorageService, |
|
|
|
|
private tradeTakeConfigService: TradeTakeConfigService, |
|
|
|
|
private form: FormBuilder) { |
|
|
|
|
this.userObjectType = Number(this.localStorageService.get(ADMIN_INFO_OBJECT)['secUser']['objectType']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
if (this.userObjectType != null && this.userObjectType === 0) { |
|
|
|
|
this.getCompanyList(); |
|
|
|
|
} |
|
|
|
|
this.commonsService.getDictionary('PLATFORM_TYPE', data => { |
|
|
|
|
this.platformTypeArray = data['return_data']; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.tradeTakeConfigForm = this.form.group({ |
|
|
|
|
platformType: ['4', [Validators.required]], |
|
|
|
|
receiverName: [null, [Validators.required]], |
|
|
|
|
receiverAccount: [null, [Validators.required]], |
|
|
|
|
receiverRatio: [100, [Validators.required]], |
|
|
|
|
|
|
|
|
|
subReceiverName: [null, [Validators.required]], |
|
|
|
|
subReceiverAccount: [null, [Validators.required]], |
|
|
|
|
subReceiverRatio: [{ value: 0, disabled: true }, [Validators.required]], |
|
|
|
|
subReceiverObjectId: [null, [Validators.required]], |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.searchForm = this.form.group({ |
|
|
|
|
companyId: [null], |
|
|
|
@ -155,4 +177,79 @@ export class AgentListComponent implements OnInit { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 展示交易分账配置 |
|
|
|
|
*/ |
|
|
|
|
showTradeTakeConfigMadel(agentId: number) { |
|
|
|
|
this.tradeTakeConfigService.getAgentTradeTakeConfig(this.tradeTakeConfigForm.controls['platformType'].value, agentId, 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; |
|
|
|
|
data['return_data']['subReceiverRatio'] = data['return_data']['subReceiverRatio'] * 100; |
|
|
|
|
this.tradeTakeConfigForm.patchValue(data['return_data']); |
|
|
|
|
} else { |
|
|
|
|
this.tradeTakeConfigForm.controls['subReceiverObjectId'].setValue(agentId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.tradeTakeConfigMadel = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭交易分账配置 |
|
|
|
|
*/ |
|
|
|
|
closeTradeTakeConfigMadel() { |
|
|
|
|
this.tradeTakeConfigForm.reset(); |
|
|
|
|
this.tradeTakeConfigForm.controls['platformType'].setValue('4'); |
|
|
|
|
this.tradeTakeConfigForm.controls['receiverRatio'].setValue('100'); |
|
|
|
|
this.tradeTakeConfigForm.controls['subReceiverRatio'].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.tradeTakeConfigForm.value['subReceiverRatio'] = this.tradeTakeConfigForm.controls['subReceiverRatio']['value'] / 100; |
|
|
|
|
this.tradeTakeConfigService.editAgentConfig(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'], |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 计算 |
|
|
|
|
* @param ratio |
|
|
|
|
* @param subRatio |
|
|
|
|
*/ |
|
|
|
|
compute(ratio: number) { |
|
|
|
|
// console.log(parentRatio);
|
|
|
|
|
// this.tradeTakeConfigForm['receiverRatio'].value = parentRatio;
|
|
|
|
|
this.tradeTakeConfigForm.controls['subReceiverRatio'].setValue(100 - ratio); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|