parent
e0c66d07f3
commit
b38d26efe3
@ -0,0 +1,159 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
<!--条件搜索--> |
||||
|
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)"> |
||||
<div nz-row> |
||||
<div nz-col nzSpan="8" *ngIf="roleType == 5 && adminFlag == 1"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="8">代理商编号</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select nzShowSearch nzAllowClear formControlName="orgId"> |
||||
<nz-option *ngFor="let item of orgArray" nzLabel="{{item.name}}" nzValue="{{item.id}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="8">类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select nzShowSearch nzAllowClear formControlName="type"> |
||||
<nz-option nzLabel="1" nzValue="进账"></nz-option> |
||||
<nz-option nzLabel="2" nzValue="出账"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="8">来源类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select nzShowSearch nzAllowClear formControlName="sourceType"> |
||||
<nz-option nzLabel="1" nzValue="金额充值"></nz-option> |
||||
<nz-option nzLabel="2" nzValue="油卡充值"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="8">记录时间</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-range-picker |
||||
formControlName="createTime" |
||||
[nzShowTime]="{ nzHideDisabledOptions: true}" |
||||
nzFormat="yyyy-MM-dd HH:mm:ss" |
||||
></nz-range-picker> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
|
||||
<div nz-row> |
||||
<div nz-col nzSpan="24" class="search-button"> |
||||
<button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>搜索</button> |
||||
<button nz-button nzType="default" (click)="resetForm()"><i nz-icon nzType="reload" nzTheme="outline"></i>重置</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
|
||||
<div class="inner-content"> |
||||
<div *ngIf="roleType == 5 && adminFlag == 0" style="width: 100%;text-align: center;"> |
||||
<nz-row [nzGutter]="16"> |
||||
<nz-col [nzSpan]="24"> |
||||
<nz-statistic [nzValue]="accountObject['amounts']" [nzTitle]="'账户余额'"></nz-statistic> |
||||
</nz-col> |
||||
</nz-row> |
||||
</div> |
||||
<span>共计 {{dataObject.total?dataObject.total:0}} 条数据</span> |
||||
<div class="operating-button"> |
||||
<button *ngIf="roleType == 5 && adminFlag == 1" nz-button nzType="primary" class="right-btn" (click)="showRechargeModal()" ><i nz-icon nzType="plus" nzTheme="outline"></i>金额充值</button> |
||||
</div> |
||||
|
||||
<!--数组表格 --> |
||||
<nz-table #basicTable |
||||
[nzData]="dataObject.list" |
||||
[nzTotal]="dataObject.total" |
||||
[nzFrontPagination]="false" |
||||
[nzLoading]="tableLoading" |
||||
[nzPageIndex]="whereObject.pageNum" |
||||
(nzPageIndexChange)="requestData($event)" |
||||
[nzScroll]="{ x: '1150px'}"> |
||||
<thead> |
||||
<tr> |
||||
<th nzWidth="80px" *ngIf="roleType == 5 && adminFlag == 1">部门</th> |
||||
<th nzWidth="50px">类型</th> |
||||
<th nzWidth="80px">交易金额</th> |
||||
<th nzWidth="80px">变更前金额</th> |
||||
<th nzWidth="80px">变更后金额</th> |
||||
<th nzWidth="80px">来源类型</th> |
||||
<th nzWidth="180px">来源内容</th> |
||||
<th nzWidth="120px">操作人</th> |
||||
<th nzWidth="150px">记录时间</th> |
||||
<!-- <th nzWidth="100px" nzRight="0px">操作</th>--> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of basicTable.data;let i = index"> |
||||
<td *ngIf="roleType == 5 && adminFlag == 1">{{data.orgName}}</td> |
||||
<td>{{data.type | companyAmountRecordType}}</td> |
||||
<td>¥{{data.amount}}</td> |
||||
<td>¥{{data.beforeAmount}}</td> |
||||
<td>¥{{data.afterAmount}}</td> |
||||
<td>{{data.sourceType | companyAmountRecordSourceType}}</td> |
||||
<td>{{data.sourceContent}}</td> |
||||
<td>{{data.opUserName}}</td> |
||||
<td>{{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td> |
||||
<!-- <td nzRight="0px" class="table-td-operation"> |
||||
<a nz-dropdown [nzDropdownMenu]="menu"> 操作列表 <i nz-icon nzType="down"></i> </a> |
||||
<nz-dropdown-menu #menu="nzDropdownMenu"> |
||||
<ul nz-menu nzSelectable> |
||||
<li nz-menu-item><a [routerLink]="['/admin/tuanyou-agent/agent-edit']" [queryParams]="{agentKey: data.agentKey}">修改</a></li> |
||||
</ul> |
||||
</nz-dropdown-menu> |
||||
</td>--> |
||||
</tr> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
<nz-modal [(nzVisible)]="rechargeModal" nzTitle="积分充值" (nzOnCancel)="closeRechargeModal()" nzWidth="500px" [nzFooter]="null"> |
||||
<form nz-form [formGroup]="rechargeForm"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired >部门</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select nzShowSearch nzAllowClear nzPlaceHolder="请选择部门" formControlName="orgId"> |
||||
<nz-option *ngFor="let data of orgArray" nzLabel="{{data.name}}" nzValue="{{data.id}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired >充值金额¥</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-input-number style="width: 100%" formControlName="amount" [nzMin]="0" [nzMax]="9999999" [nzStep]="1" [nzPrecision]="2"></nz-input-number> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired >验证码</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-input-group nzSearch [nzAddOnAfter]="suffixButton"> |
||||
<input nz-input formControlName="smsCode" /> |
||||
</nz-input-group> |
||||
<ng-template #suffixButton> |
||||
<button nz-button nzType="primary" [disabled]="smsCodeBtnLoading" (click)="sendSmsCode()">{{smsCodeBtnName}}</button> |
||||
</ng-template> |
||||
<span *ngIf="smsCodeBtnLoading" nz-typography nzType="warning">验证码已发送!5分钟内有效</span> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<div style="text-align: center;"> |
||||
<button nz-button nzType="primary" style="width: 150px;" [nzLoading]="submitRechargeBtnLoading" (click)="submitRecharge()">确定</button> |
||||
</div> |
||||
</form> |
||||
</nz-modal> |
@ -0,0 +1,3 @@ |
||||
.table-td-operation a { |
||||
padding: 0px 5px; |
||||
} |
@ -0,0 +1,25 @@ |
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { CompanyAmountRecordComponent } from './company-amount-record.component'; |
||||
|
||||
describe('CompanyAmountRecordComponent', () => { |
||||
let component: CompanyAmountRecordComponent; |
||||
let fixture: ComponentFixture<CompanyAmountRecordComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ CompanyAmountRecordComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(CompanyAmountRecordComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,235 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {FormBuilder, FormGroup, Validators} from '_@angular_forms@9.0.7@@angular/forms'; |
||||
import {NzMessageService, NzModalService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; |
||||
import {OrganizationService} from '../../../services/organization.service'; |
||||
import {LocalStorageService} from '../../../services/local-storage.service'; |
||||
import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace'; |
||||
import {CompanyAccountService} from '../../../services/company-account.service'; |
||||
|
||||
@Component({ |
||||
selector: 'app-company-amount-record', |
||||
templateUrl: './company-amount-record.component.html', |
||||
styleUrls: ['./company-amount-record.component.scss'] |
||||
}) |
||||
export class CompanyAmountRecordComponent implements OnInit { |
||||
roleType; |
||||
adminFlag; |
||||
|
||||
dataObject: any = {}; |
||||
tableLoading = true; |
||||
searchForm: FormGroup; |
||||
pageNum: number; |
||||
whereObject: any = {}; |
||||
|
||||
rechargeModal = false; |
||||
rechargeForm: FormGroup; |
||||
rechargeParam = { |
||||
phone: null, |
||||
orgId: null, |
||||
amount: null, |
||||
smsCode: null, |
||||
}; |
||||
submitRechargeBtnLoading = false; |
||||
|
||||
smsCodeBtnName = '获取验证码'; |
||||
smsCodeBtnLoading = false; |
||||
countdownTime; |
||||
|
||||
orgArray = []; |
||||
accountObject = { |
||||
amounts: 0 |
||||
}; |
||||
|
||||
constructor(private modal: NzModalService, |
||||
private message: NzMessageService, |
||||
private store: LocalStorageService, |
||||
private companyAccountService: CompanyAccountService, |
||||
private organizationService: OrganizationService, |
||||
private form: FormBuilder) { |
||||
this.roleType = Number(this.store.get(ADMIN_INFO_OBJECT)['secRole'].roleType); |
||||
this.adminFlag = Number(this.store.get(ADMIN_INFO_OBJECT)['secUser'].adminFlag); |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.searchForm = this.form.group({ |
||||
orgId: [null], |
||||
type: [null], |
||||
sourceType: [null], |
||||
createTime: [null], |
||||
createTimeS: [null], |
||||
createTimeE: [null], |
||||
}); |
||||
|
||||
this.rechargeForm = this.form.group({ |
||||
orgId: [null, [Validators.required]], |
||||
amount: [null, [Validators.required]], |
||||
smsCode: [null, [Validators.required]], |
||||
}); |
||||
|
||||
if (this.roleType === 5 && this.adminFlag === 1) { |
||||
this.organizationService.getOrganizationList(this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['id'], data => { |
||||
this.orgArray = data['return_data']; |
||||
}); |
||||
} |
||||
|
||||
if (this.roleType === 5 && this.adminFlag === 0) { |
||||
this.companyAccountService.getAccount(data => { |
||||
this.accountObject = data['return_data']; |
||||
}); |
||||
} |
||||
|
||||
this.requestData(1); |
||||
} |
||||
|
||||
/** |
||||
* 请求数据 |
||||
*/ |
||||
requestData(pageNum) { |
||||
this.tableLoading = true; |
||||
this.whereObject['pageNum'] = pageNum; |
||||
this.whereObject['pageSize'] = 10; |
||||
this.companyAccountService.getAmountRecordList(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; |
||||
if (this.searchForm.value.createTime != null) { |
||||
this.searchForm.value.createTimeS = new Date(this.searchForm.value.createTime[0]).getTime(); |
||||
this.searchForm.value.createTimeE = new Date(this.searchForm.value.createTime[1]).getTime(); |
||||
} else { |
||||
this.searchForm.value.createTimeS = null; |
||||
this.searchForm.value.createTimeE = null; |
||||
} |
||||
this.requestData(1); |
||||
} |
||||
|
||||
/** |
||||
* 重置 |
||||
*/ |
||||
resetForm(): void { |
||||
this.searchForm.reset(); |
||||
} |
||||
|
||||
/** |
||||
* 展示充值模态框 |
||||
*/ |
||||
showRechargeModal() { |
||||
this.rechargeModal = true; |
||||
} |
||||
|
||||
/** |
||||
* 关闭充值模态框 |
||||
*/ |
||||
closeRechargeModal() { |
||||
this.rechargeModal = false; |
||||
} |
||||
|
||||
/** |
||||
* 提交充值 |
||||
*/ |
||||
submitRecharge() { |
||||
this.submitRechargeBtnLoading = true; |
||||
for (const i in this.rechargeForm.controls) { |
||||
this.rechargeForm.controls[i].markAsDirty(); |
||||
this.rechargeForm.controls[i].updateValueAndValidity(); |
||||
} |
||||
if (this.rechargeForm.status == null || this.rechargeForm.status !== 'VALID') { |
||||
this.modal.warning({ |
||||
nzTitle: '提示', |
||||
nzContent: '请填写所有必填项', |
||||
}); |
||||
this.submitRechargeBtnLoading = false; |
||||
return; |
||||
} |
||||
|
||||
this.rechargeParam.smsCode = this.rechargeForm.value['smsCode']; |
||||
this.companyAccountService.recharge(this.rechargeParam, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.modal.success({ |
||||
nzTitle: '提示', |
||||
nzContent: '充值成功', |
||||
}); |
||||
|
||||
this.rechargeForm.controls.orgId.enable(); |
||||
this.rechargeForm.controls.amount.enable(); |
||||
this.rechargeForm = this.form.group({ |
||||
orgId: [null, [Validators.required]], |
||||
amount: [null, [Validators.required]], |
||||
smsCode: [null, [Validators.required]], |
||||
}); |
||||
|
||||
this.closeRechargeModal(); |
||||
this.requestData(this.whereObject['pageNum']); |
||||
} else { |
||||
this.modal.error({ |
||||
nzTitle: '提示', |
||||
nzContent: data['return_msg'], |
||||
}); |
||||
} |
||||
this.submitRechargeBtnLoading = false; |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 发送验证码 |
||||
*/ |
||||
sendSmsCode() { |
||||
if (this.rechargeForm.value.orgId == null) { |
||||
this.modal.warning({ |
||||
nzTitle: '提示', |
||||
nzContent: '请选择部门', |
||||
}); |
||||
return; |
||||
} |
||||
|
||||
this.rechargeParam.phone = '17726395120'; |
||||
this.rechargeParam.orgId = this.rechargeForm.value['orgId']; |
||||
this.rechargeParam.amount = this.rechargeForm.value['amount']; |
||||
|
||||
this.rechargeForm.controls.orgId.disable(); |
||||
this.rechargeForm.controls.amount.disable(); |
||||
|
||||
this.companyAccountService.sendRechargeSmsCode('17726395120', this.rechargeParam.orgId, this.rechargeParam.amount, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getVerifyCodeCountdown(); |
||||
} else { |
||||
this.modal.error({ |
||||
nzTitle: '提示', |
||||
nzContent: data['return_msg'], |
||||
}); |
||||
this.rechargeForm.controls.orgId.enable(); |
||||
this.rechargeForm.controls.amount.enable(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 获取验证码倒计时 |
||||
*/ |
||||
getVerifyCodeCountdown() { |
||||
let countdownSecond = 60; // 倒计时60秒
|
||||
this.countdownTime = setInterval(() => { |
||||
if (countdownSecond <= 1) { |
||||
this.smsCodeBtnName = '获取验证码'; |
||||
this.smsCodeBtnLoading = false; |
||||
clearInterval(this.countdownTime); |
||||
} else { |
||||
countdownSecond--; |
||||
this.smsCodeBtnName = String(countdownSecond); |
||||
this.smsCodeBtnLoading = true; |
||||
} |
||||
}, 1000); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,13 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {CompanyAmountRecordComponent} from './company-amount-record/company-amount-record.component'; |
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'list', component: CompanyAmountRecordComponent }, |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class CompanyAmountRoutingModule { } |
@ -0,0 +1,26 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { CompanyAmountRoutingModule } from './company-amount-routing.module'; |
||||
import { CompanyAmountRecordComponent } from './company-amount-record/company-amount-record.component'; |
||||
import {NgZorroAntdModule} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; |
||||
import {FormsModule, ReactiveFormsModule} from '_@angular_forms@9.0.7@@angular/forms'; |
||||
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; |
||||
import {AppCommonModule} from '../../app-common.module'; |
||||
import {NgxEchartsModule} from '_ngx-echarts@4.2.2@ngx-echarts'; |
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [CompanyAmountRecordComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
CompanyAmountRoutingModule, |
||||
NgZorroAntdModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule, |
||||
AppCommonModule, |
||||
NgxEchartsModule, |
||||
] |
||||
}) |
||||
export class CompanyAmountModule { } |
@ -0,0 +1,17 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'companyAmountRecordSourceType' |
||||
}) |
||||
export class CompanyAmountRecordSourceTypePipe implements PipeTransform { |
||||
|
||||
transform(value: number): string { |
||||
switch (value) { |
||||
case 1: |
||||
return '金额充值'; |
||||
case 2: |
||||
return '油卡充值'; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'companyAmountRecordType' |
||||
}) |
||||
export class CompanyAmountRecordTypePipe implements PipeTransform { |
||||
|
||||
transform(value: number): string { |
||||
switch (value) { |
||||
case 1: |
||||
return '进账'; |
||||
case 2: |
||||
return '出账'; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,62 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class CompanyAccountService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* 余额充值 |
||||
* |
||||
* @param paramsObject 参数对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public recharge(paramsObject: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'companyAccount/recharge', paramsObject).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询余额 |
||||
* |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getAccount( callBack) { |
||||
this.http.get(environment.baseUrl + 'companyAccount/getAccount').subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 发送充值短信验证码 |
||||
* |
||||
* @param phone 手机号 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public sendRechargeSmsCode(phone: string, orgId: number, price: string, callBack) { |
||||
this.http.get(environment.baseUrl + 'sendSms/sendRechargeSmsCode?phone=' + phone + '&orgId=' + orgId + '&price=' + price).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询余额记录列表 |
||||
* |
||||
* @param paramsObject 参数对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getAmountRecordList(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'companyAccount/getAccountRecordList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue