提交代码

pull/1/head
胡锐 3 years ago
parent b38d26efe3
commit 650d39e5b6
  1. 2
      src/app/admin/company-amount/company-amount-record/company-amount-record.component.html
  2. 97
      src/app/admin/navigation/navigation.component.html
  3. 129
      src/app/admin/navigation/navigation.component.ts
  4. 252
      src/app/admin/oil-card/oil-card-list/oil-card-list.component.html
  5. 3
      src/app/admin/oil-card/oil-card-list/oil-card-list.component.scss
  6. 25
      src/app/admin/oil-card/oil-card-list/oil-card-list.component.spec.ts
  7. 390
      src/app/admin/oil-card/oil-card-list/oil-card-list.component.ts
  8. 13
      src/app/admin/oil-card/oil-card-routing.module.ts
  9. 26
      src/app/admin/oil-card/oil-card.module.ts
  10. 5
      src/app/app-common.module.ts
  11. 5
      src/app/app-routing.module.ts
  12. 2
      src/app/pipes/index.ts
  13. 16
      src/app/pipes/oil-card/oil-card-bind-status.pipe.ts
  14. 19
      src/app/pipes/oil-card/oil-card-status.pipe.ts
  15. 51
      src/app/services/company-two-pwd.service.ts
  16. 87
      src/app/services/oil-card.service.ts

@ -8,7 +8,7 @@
<div nz-row> <div nz-row>
<div nz-col nzSpan="8" *ngIf="roleType == 5 && adminFlag == 1"> <div nz-col nzSpan="8" *ngIf="roleType == 5 && adminFlag == 1">
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="8">代理商编号</nz-form-label> <nz-form-label [nzSpan]="8">部门</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<nz-select nzShowSearch nzAllowClear formControlName="orgId"> <nz-select nzShowSearch nzAllowClear formControlName="orgId">
<nz-option *ngFor="let item of orgArray" nzLabel="{{item.name}}" nzValue="{{item.id}}"></nz-option> <nz-option *ngFor="let item of orgArray" nzLabel="{{item.name}}" nzValue="{{item.id}}"></nz-option>

@ -38,6 +38,9 @@
<li nz-menu-item> <li nz-menu-item>
<a (click)="openUpdatePwd()">修改密码</a> <a (click)="openUpdatePwd()">修改密码</a>
</li> </li>
<li *ngIf="userInfo['bsOrganization'] != null" nz-menu-item>
<a (click)="setTowPwd()">二级密码</a>
</li>
<li nz-menu-item> <li nz-menu-item>
<a (click)="loginOut()">退出</a> <a (click)="loginOut()">退出</a>
</li> </li>
@ -101,3 +104,97 @@
</form> </form>
</nz-drawer> </nz-drawer>
<nz-drawer
[nzBodyStyle]="{ height: 'calc(100% - 55px)', overflow: 'auto', 'padding-bottom': '53px' }"
[nzWidth]="500"
[nzVisible]="setTwoPwdVisible"
nzTitle="设置二级密码"
[nzMaskClosable] = "true"
(nzOnClose)="closeSetTowPwd()"
>
<form nz-form [formGroup]="setTwoPwdForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>
<span> 密码 </span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-input-group [nzSuffix]="suffixTemplate">
<input nz-input [type]="passwordVisible ? 'text' : 'password'" formControlName="password" placeholder="请输入您的新密码" />
</nz-input-group>
<ng-template #suffixTemplate>
<i nz-icon [nzType]="passwordVisible ? 'eye-invisible' : 'eye'" (click)="passwordVisible = !passwordVisible"></i>
</ng-template>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>确认密码</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" [nzErrorTip]="errorTpl">
<input nz-input type="password" formControlName="checkPassword" placeholder="请再次输入您的密码" />
<ng-template #errorTpl let-control>
<ng-container *ngIf="control.hasError('confirm')">
您输入的两个密码不一致!
</ng-container>
</ng-template>
</nz-form-control>
</nz-form-item>
<nz-form-control [nzSpan]="8" >
<button nz-button nzType="primary" style="margin-left: 130px;width: 200px;" (click)="submitSetTowPwd()">提交</button>
</nz-form-control>
</form>
</nz-drawer>
<nz-drawer
[nzBodyStyle]="{ height: 'calc(100% - 55px)', overflow: 'auto', 'padding-bottom': '53px' }"
[nzWidth]="500"
[nzVisible]="updateTwoPwdVisible"
nzTitle="修改二级密码"
[nzMaskClosable] = "true"
(nzOnClose)="closeUpdateTowPwd()"
>
<form nz-form [formGroup]="updateTwoPwdForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>旧密码</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input type="password" formControlName="oldPassword" placeholder="请输入您的旧密码" />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>
<span> 新密码 </span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-input-group [nzSuffix]="suffixTemplate">
<input nz-input [type]="passwordVisible ? 'text' : 'password'" formControlName="newPassword" placeholder="请输入您的新密码" />
</nz-input-group>
<ng-template #suffixTemplate>
<i nz-icon [nzType]="passwordVisible ? 'eye-invisible' : 'eye'" (click)="passwordVisible = !passwordVisible"></i>
</ng-template>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>确认新密码</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" [nzErrorTip]="errorTpl">
<input nz-input type="password" formControlName="checkNewPassword" placeholder="请再次输入您的新密码" />
<ng-template #errorTpl let-control>
<ng-container *ngIf="control.hasError('confirm')">
您输入的两个密码不一致!
</ng-container>
</ng-template>
</nz-form-control>
</nz-form-item>
<nz-form-control [nzSpan]="8" >
<button nz-button nzType="primary" style="margin-left: 130px;width: 200px;" (click)="submitUpdateTowPwd()">提交</button>
</nz-form-control>
</form>
</nz-drawer>

@ -5,13 +5,13 @@ import {LoginService} from '../../services/login.service';
import {NzMessageService, NzModalService} from 'ng-zorro-antd'; import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {IconService} from '../../services/icon.service'; import {IconService} from '../../services/icon.service';
import {RechargeService} from '../../services/recharge.service';
import {CommonsService} from '../../services/commons.service'; import {CommonsService} from '../../services/commons.service';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'; import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {ValidatorsService} from '../../services/validators.service'; import {ValidatorsService} from '../../services/validators.service';
import {Md5} from 'ts-md5'; import {Md5} from 'ts-md5';
import {environment} from '../../../environments/environment'; import {environment} from '../../../environments/environment';
import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {CompanyTwoPwdService} from '../../services/company-two-pwd.service';
@Component({ @Component({
selector: 'app-navigation', selector: 'app-navigation',
@ -24,6 +24,12 @@ export class NavigationComponent implements OnInit {
validateForm: FormGroup; // 定义表单 validateForm: FormGroup; // 定义表单
passwordVisible = false; passwordVisible = false;
setTwoPwdVisible = false;
setTwoPwdForm: FormGroup; // 定义表单
updateTwoPwdVisible = false;
updateTwoPwdForm: FormGroup; // 定义表单
isCollapsed = false; isCollapsed = false;
userInfo: any; userInfo: any;
menuList: any; menuList: any;
@ -34,6 +40,7 @@ export class NavigationComponent implements OnInit {
private loginService: LoginService, private loginService: LoginService,
private message: NzMessageService, private message: NzMessageService,
private commonsService: CommonsService, private commonsService: CommonsService,
private companyTwoPwdService: CompanyTwoPwdService,
private http: HttpClient, // http请求 private http: HttpClient, // http请求
private iconService: IconService, private iconService: IconService,
private modal: NzModalService, private modal: NzModalService,
@ -48,6 +55,17 @@ export class NavigationComponent implements OnInit {
checkNewPassword: [null, [Validators.required, this.checkPwd]], checkNewPassword: [null, [Validators.required, this.checkPwd]],
}); });
this.setTwoPwdForm = this.fb.group({
password: [null, [Validators.required, ValidatorsService.minLength(6), ValidatorsService.maxLength(16)]],
checkPassword: [null, [Validators.required, this.checkSetTowPwd]],
});
this.updateTwoPwdForm = this.fb.group({
oldPassword: [null, [Validators.required, ValidatorsService.minLength(6), ValidatorsService.maxLength(16)]],
newPassword: [null, [Validators.required, ValidatorsService.minLength(6), ValidatorsService.maxLength(16)]],
checkNewPassword: [null, [Validators.required, this.checkUpdateTowPwd]],
});
this.routeName = this.storage.get(ROUTENAME) == null ? 'index' : this.storage.get(ROUTENAME); this.routeName = this.storage.get(ROUTENAME) == null ? 'index' : this.storage.get(ROUTENAME);
this.userInfo = this.storage.getList(ADMIN_INFO_OBJECT); this.userInfo = this.storage.getList(ADMIN_INFO_OBJECT);
this.commonsService.mappingSysNameOl('RECHARGE', data => { this.commonsService.mappingSysNameOl('RECHARGE', data => {
@ -169,5 +187,114 @@ export class NavigationComponent implements OnInit {
return {}; return {};
} }
// 设置密码
setTowPwd() {
this.companyTwoPwdService.isSetTwoPwd(data => {
if (data['return_data'] === true) {
this.openUpdateTowPwd();
} else {
this.openSetTowPwd();
}
});
}
// 打开设置二级密码抽屉
openSetTowPwd(): void {
this.setTwoPwdVisible = true;
}
// 关闭设置二级密码抽屉
closeSetTowPwd(): void {
this.setTwoPwdVisible = false;
this.setTwoPwdForm.reset();
}
// 提交二级密码
submitSetTowPwd(): void {
for (const i in this.setTwoPwdForm.controls) {
this.setTwoPwdForm.controls[i].markAsDirty();
this.setTwoPwdForm.controls[i].updateValueAndValidity();
}
if (this.setTwoPwdForm.status == null || this.setTwoPwdForm.status !== 'VALID') {
this.modal.warning({
nzTitle: '提示',
nzContent: '请规范填写所有的必填项信息',
});
return;
}
this.companyTwoPwdService.setTwoPwd(this.setTwoPwdForm.value, data => {
if (data['return_code'] === '000000') {
this.modal.success({
nzTitle: '提示',
nzContent: '设置成功',
});
this.closeSetTowPwd();
} else {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg'],
});
}
});
}
checkSetTowPwd = (control: FormControl): { [s: string]: boolean } => {
if (!control.value) {
return { required: true };
} else if (control.value !== this.setTwoPwdForm.controls.password.value) {
return { confirm: true, error: true };
}
return {};
}
// 打开修改二级密码抽屉
openUpdateTowPwd(): void {
this.updateTwoPwdVisible = true;
}
// 关闭修改二级密码抽屉
closeUpdateTowPwd(): void {
this.updateTwoPwdVisible = false;
this.updateTwoPwdForm.reset();
}
// 提交二级密码
submitUpdateTowPwd(): void {
for (const i in this.updateTwoPwdForm.controls) {
this.updateTwoPwdForm.controls[i].markAsDirty();
this.updateTwoPwdForm.controls[i].updateValueAndValidity();
}
if (this.updateTwoPwdForm.status == null || this.updateTwoPwdForm.status !== 'VALID') {
this.modal.warning({
nzTitle: '提示',
nzContent: '请规范填写所有的必填项信息',
});
return;
}
this.companyTwoPwdService.updateTwoPwd(this.updateTwoPwdForm.value, data => {
if (data['return_code'] === '000000') {
this.modal.success({
nzTitle: '提示',
nzContent: '修改成功',
});
this.closeUpdateTowPwd();
} else {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg'],
});
}
});
}
checkUpdateTowPwd = (control: FormControl): { [s: string]: boolean } => {
if (!control.value) {
return { required: true };
} else if (control.value !== this.updateTwoPwdForm.controls.newPassword.value) {
return { confirm: true, error: true };
}
return {};
}
} }

@ -0,0 +1,252 @@
<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->
<!--条件搜索-->
<nz-spin [nzSpinning]="loadingObject.spinning" nzTip="{{loadingObject.msg}}">
<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 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">
<input nz-input formControlName="cardNo" />
</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">
<input nz-input formControlName="contactName" />
</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">
<input nz-input formControlName="contactPhone" />
</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 nzAllowClear formControlName="status">
<nz-option nzValue="1" nzLabel="正常"></nz-option>
<nz-option nzValue="2" nzLabel="禁用"></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 nzAllowClear formControlName="isConfigContact">
<nz-option nzValue="false" nzLabel="未设置"></nz-option>
<nz-option nzValue="true" nzLabel="已设置"></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 nzAllowClear formControlName="bindStatus">
<nz-option nzValue="0" nzLabel="未绑定"></nz-option>
<nz-option nzValue="1" nzLabel="已绑定"></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="bindTime"
[nzShowTime]="{ nzHideDisabledOptions: true}"
nzFormat="yyyy-MM-dd HH:mm:ss"
></nz-range-picker>
</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 nz-button nzType="primary" class="right-btn" (click)="showGenerateCardModal()" ><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: '1100px'}">
<thead>
<tr>
<th nzWidth="60px">序号</th>
<th nzWidth="80px" *ngIf="roleType == 5 && adminFlag == 1">部门</th>
<th nzWidth="160px">卡号</th>
<th nzWidth="110px">余额</th>
<th nzWidth="100px">联系人</th>
<th nzWidth="120px">联系电话</th>
<th nzWidth="100px">油卡状态</th>
<th nzWidth="100px">绑定状态</th>
<th nzWidth="160px">绑定时间</th>
<th nzWidth="80px">操作人</th>
<th nzWidth="160px">生成时间</th>
<th nzWidth="160px" nzRight="0px">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data;let i = index">
<td>{{i+1}}</td>
<td *ngIf="roleType == 5 && adminFlag == 1">{{data.orgName}}</td>
<td>{{data.cardNo}}</td>
<td>¥{{data.amount}}</td>
<td>{{data.contactName?data.contactName:'未设置'}}</td>
<td>{{data.contactPhone?data.contactPhone:'未设置'}}</td>
<td>{{data.status | oilCardStatus}}</td>
<td>{{data.bindStatus | oilCardBindStatus}}</td>
<td>
<span *ngIf="data.bindTime != null">{{data.bindTime | date : 'yyyy-MM-dd HH:mm:ss'}}</span>
<span *ngIf="data.bindTime == null">未绑定</span>
<td>{{data.opUserName}}</td>
<td>{{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td>
<td nzRight="0px" class="table-td-operation">
<a (click)="showRechargeModal(data.cardNo)"> 充值 </a>
<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 *ngIf="!data.contactPhone" (click)="showEditContactModal(data)"><a >设置联系人</a></li>
<li nz-menu-item *ngIf="data.contactPhone" (click)="showEditContactModal(data)"><a >更换联系人</a></li>
<li nz-menu-item *ngIf="data.status == 1" (click)="showDisabledConfirm(data.cardNo)"><a>禁用</a></li>
<li nz-menu-item *ngIf="data.status == 2" (click)="showEnableConfirm(data.cardNo)"><a>启用</a></li>
<li nz-menu-item><a>变更记录</a></li>
<li nz-menu-item><a>油卡流水</a></li>
</ul>
</nz-dropdown-menu>
</td>
</tr>
</tbody>
</nz-table>
</div>
</nz-spin>
<nz-modal [(nzVisible)]="generateCardModal" nzTitle="生成油卡" (nzOnCancel)="closeGenerateCardModal()" nzWidth="500px" [nzFooter]="null">
<form nz-form [formGroup]="generateCardForm">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired >生成数量</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-input-number style="width: 100%" formControlName="generateNum" [nzMin]="1" [nzMax]="1000" [nzStep]="1"></nz-input-number>
</nz-form-control>
</nz-form-item>
<div style="text-align: center;">
<button nz-button nzType="primary" style="width: 150px;" (click)="submitGenerateCard()">确定</button>
</div>
</form>
</nz-modal>
<nz-modal [(nzVisible)]="editContactModal" nzTitle="设置联系人" (nzOnCancel)="closeEditContactModal()" nzWidth="500px" [nzFooter]="null">
<form nz-form [formGroup]="editContactForm">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired >联系人</nz-form-label>
<nz-form-control [nzSpan]="14">
<input nz-input formControlName="contactName" placeholder="请输入联系姓名" />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired >联系电话</nz-form-label>
<nz-form-control [nzSpan]="14">
<input nz-input formControlName="contactPhone" placeholder="请输入联系电话" />
</nz-form-control>
</nz-form-item>
<div style="text-align: center;">
<button nz-button nzType="primary" style="width: 150px;" (click)="submitEditContact()">确定</button>
</div>
</form>
</nz-modal>
<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">
<input nz-input formControlName="cardNo" disabled />
</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="price" [nzMin]="1" [nzMax]="1000" [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">
<input type="password" formControlName="twoPwd" nz-input placeholder="请输入二级密码" />
</nz-form-control>
</nz-form-item>
<div style="text-align: center;">
<button nz-button nzType="primary" style="width: 150px;" (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 { OilCardListComponent } from './oil-card-list.component';
describe('OilCardListComponent', () => {
let component: OilCardListComponent;
let fixture: ComponentFixture<OilCardListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ OilCardListComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(OilCardListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,390 @@
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 {LocalStorageService} from '../../../services/local-storage.service';
import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace';
import {OilCardService} from '../../../services/oil-card.service';
import {CompanyAccountService} from '../../../services/company-account.service';
import {OrganizationService} from "../../../services/organization.service";
import {NavigationComponent} from "../../navigation/navigation.component";
@Component({
selector: 'app-oil-card-list',
templateUrl: './oil-card-list.component.html',
styleUrls: ['./oil-card-list.component.scss']
})
export class OilCardListComponent implements OnInit {
roleType;
adminFlag;
loadingObject = {
spinning: false,
msg: '加载中'
};
dataObject: any = {};
tableLoading = true;
searchForm: FormGroup;
pageNum: number;
whereObject: any = {};
generateCardModal = false;
generateCardForm: FormGroup;
editContactModal = false;
editContactForm: FormGroup;
rechargeModal = false;
rechargeForm: FormGroup;
orgArray = [];
accountObject = {
amounts: 0
};
constructor(private modal: NzModalService,
private message: NzMessageService,
private store: LocalStorageService,
private oilCardService: OilCardService,
private organizationService: OrganizationService,
private navigationComponent: NavigationComponent,
private companyAccountService: CompanyAccountService,
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],
cardNo: [null],
contactName: [null],
contactPhone: [null],
createTime: [null],
createTimeS: [null],
createTimeE: [null],
bindTime: [null],
bindTimeS: [null],
bindTimeE: [null],
isConfigContact: [null],
status: [null],
bindStatus: [null],
});
this.editContactForm = this.form.group({
cardNo: [null, [Validators.required]],
contactName: [null, [Validators.required]],
contactPhone: [null, [Validators.required]],
});
this.generateCardForm = this.form.group({
generateNum: [1, [Validators.required]],
});
this.rechargeForm = this.form.group({
cardNo: [{ value: null, disabled: true }, [Validators.required]],
price: [100, [Validators.required]],
twoPwd: [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.getAccount();
}
this.requestData(1);
}
/**
*
*/
requestData(pageNum) {
this.tableLoading = true;
this.whereObject['pageNum'] = pageNum;
this.whereObject['pageSize'] = 10;
this.oilCardService.getCardList(this.whereObject, data => {
if (data['return_code'] === '000000') {
this.dataObject = data['return_data'];
} else {
this.modal.error(data['return_msg']);
}
this.tableLoading = false;
});
}
/**
*
*/
getAccount() {
this.companyAccountService.getAccount(data => {
this.accountObject = data['return_data'];
});
}
/**
*
* @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;
}
if (this.searchForm.value.bindTime != null) {
this.searchForm.value.bindTimeS = new Date(this.searchForm.value.bindTime[0]).getTime();
this.searchForm.value.bindTimeE = new Date(this.searchForm.value.bindTime[1]).getTime();
} else {
this.searchForm.value.bindTimeS = null;
this.searchForm.value.bindTimeE = null;
}
this.requestData(1);
}
/**
*
*/
resetForm(): void {
this.searchForm.reset();
}
/**
*
*/
showGenerateCardModal() {
this.generateCardModal = true;
}
/**
*
*/
closeGenerateCardModal() {
this.generateCardModal = false;
}
/**
*
*/
submitGenerateCard() {
for (const i in this.generateCardForm.controls) {
this.generateCardForm.controls[i].markAsDirty();
this.generateCardForm.controls[i].updateValueAndValidity();
}
if (this.generateCardForm.status == null || this.generateCardForm.status !== 'VALID') {
this.modal.warning({
nzTitle: '提示',
nzContent: '请填写所有必填项',
});
return;
}
this.loadingObject.spinning = true;
this.loadingObject.msg = '生成油卡中...';
this.closeGenerateCardModal();
this.oilCardService.generateCard(this.generateCardForm.value, data => {
if (data['return_code'] === '000000') {
this.modal.success({
nzTitle: '提示',
nzContent: '生成成功',
});
this.requestData(this.whereObject['pageNum']);
} else {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg'],
});
}
this.loadingObject.spinning = false;
});
}
/**
*
*/
showEditContactModal(data: object) {
this.editContactForm.patchValue(data);
this.editContactModal = true;
}
/**
*
*/
closeEditContactModal() {
this.editContactForm.reset();
this.editContactModal = false;
}
/**
*
*/
submitEditContact() {
if (this.editContactForm.value['bindStatus'] === 1) {
this.modal.confirm({
nzTitle: '警告',
nzContent: '油卡更换联系人后,油卡会自动与用户解绑!',
nzOkText: '是',
nzCancelText: '否',
nzOkType: 'danger',
nzOnOk: () => this.submitEditContactData()
});
} else {
this.submitEditContactData();
}
}
/**
*
*/
submitEditContactData() {
for (const i in this.editContactForm.controls) {
this.editContactForm.controls[i].markAsDirty();
this.editContactForm.controls[i].updateValueAndValidity();
}
if (this.editContactForm.status == null || this.editContactForm.status !== 'VALID') {
this.modal.warning({
nzTitle: '提示',
nzContent: '请填写所有必填项',
});
return;
}
this.oilCardService.setContact(this.editContactForm.value, data => {
if (data['return_code'] === '000000') {
this.modal.success({
nzTitle: '提示',
nzContent: '设置成功',
});
this.closeEditContactModal();
this.requestData(this.whereObject['pageNum']);
} else {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg'],
});
}
});
}
/**
*
*/
showDisabledConfirm(cardNo: string): void {
this.modal.confirm({
nzTitle: '警告',
nzContent: '是否禁用油卡',
nzOkText: '是',
nzCancelText: '否',
nzOkType: 'danger',
nzOnOk: () => this.disabledData(cardNo)
});
}
/**
*
*/
disabledData(cardNo: string) {
this.oilCardService.disabled({ cardNo: cardNo}, data => {
if (data['return_code'] === '000000') {
this.requestData(this.whereObject['pageNum']);
} else {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg']
});
}
});
}
/**
*
*/
showEnableConfirm(cardNo: string): void {
this.modal.confirm({
nzTitle: '警告',
nzContent: '是否启用油卡',
nzOkText: '是',
nzCancelText: '否',
nzOkType: 'danger',
nzOnOk: () => this.enableData(cardNo)
});
}
/**
*
*/
enableData(cardNo: string) {
this.oilCardService.enable({ cardNo: cardNo}, data => {
if (data['return_code'] === '000000') {
this.requestData(this.whereObject['pageNum']);
} else {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg']
});
}
});
}
/**
*
*/
showRechargeModal(cardNo: string) {
this.rechargeForm.patchValue({cardNo: cardNo});
this.rechargeModal = true;
}
/**
*
*/
closeRechargeModal() {
this.rechargeModal = false;
}
/**
*
*/
submitRecharge() {
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: '请填写所有必填项',
});
return;
}
this.rechargeForm.value['cardNo'] = this.rechargeForm.controls['cardNo']['value'];
this.oilCardService.recharge(this.rechargeForm.value, data => {
if (data['return_code'] === '000000') {
this.modal.success({
nzTitle: '提示',
nzContent: '充值成功',
});
this.closeRechargeModal();
this.getAccount();
this.requestData(this.whereObject['pageNum']);
} else if (data['return_code'] === '102136') {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg'],
});
this.closeRechargeModal();
this.navigationComponent.openSetTowPwd();
} else {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg'],
});
}
});
}
}

@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {OilCardListComponent} from './oil-card-list/oil-card-list.component';
const routes: Routes = [
{ path: 'list', component: OilCardListComponent}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class OilCardRoutingModule { }

@ -0,0 +1,26 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { OilCardRoutingModule } from './oil-card-routing.module';
import { OilCardListComponent } from './oil-card-list/oil-card-list.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: [OilCardListComponent],
imports: [
CommonModule,
OilCardRoutingModule,
NgZorroAntdModule,
ReactiveFormsModule,
FormsModule,
BreadcrumbModule,
AppCommonModule,
NgxEchartsModule,
]
})
export class OilCardModule { }

@ -37,8 +37,9 @@ import {
DiscountPackageStatusPipe, DiscountPackageStatusPipe,
PriceShowPipe, PriceShowPipe,
ShowTypePipe, ShowTypePipe,
EnergyTypePipe, CompanyAmountRecordTypePipe, CompanyAmountRecordSourceTypePipe EnergyTypePipe, CompanyAmountRecordTypePipe, CompanyAmountRecordSourceTypePipe, OilCardBindStatusPipe
} from './pipes'; } from './pipes';
import {OilCardStatusPipe} from "./pipes/oil-card/oil-card-status.pipe";
@ -76,6 +77,8 @@ const PIPES = [
EnergyTypePipe, EnergyTypePipe,
CompanyAmountRecordTypePipe, CompanyAmountRecordTypePipe,
CompanyAmountRecordSourceTypePipe, CompanyAmountRecordSourceTypePipe,
OilCardStatusPipe,
OilCardBindStatusPipe
]; ];

@ -107,6 +107,11 @@ const routes: Routes = [
loadChildren: () => import('./admin/company-amount/company-amount.module').then(m => m.CompanyAmountModule), loadChildren: () => import('./admin/company-amount/company-amount.module').then(m => m.CompanyAmountModule),
canActivate: [InitGuardService] canActivate: [InitGuardService]
}, },
{
path: 'oil-card',
loadChildren: () => import('./admin/oil-card/oil-card.module').then(m => m.OilCardModule),
canActivate: [InitGuardService]
},
], ],
}, },
]; ];

@ -28,3 +28,5 @@ export * from './price-show.pipe';
export * from './index/energy-type.pipe'; export * from './index/energy-type.pipe';
export * from './company-amount/company-amount-record-type.pipe'; export * from './company-amount/company-amount-record-type.pipe';
export * from './company-amount/company-amount-record-source-type.pipe'; export * from './company-amount/company-amount-record-source-type.pipe';
export * from './oil-card/oil-card-status.pipe';
export * from './oil-card/oil-card-bind-status.pipe';

@ -0,0 +1,16 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'oilCardBindStatus'
})
export class OilCardBindStatusPipe implements PipeTransform {
transform(value: number): string {
switch (value) {
case 0:
return '未绑定';
case 1:
return '已绑定';
}
}
}

@ -0,0 +1,19 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'oilCardStatus'
})
export class OilCardStatusPipe implements PipeTransform {
transform(value: number): string {
switch (value) {
case 0:
return '删除';
case 1:
return '正常';
case 2:
return '禁用';
}
}
}

@ -0,0 +1,51 @@
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 CompanyTwoPwdService {
constructor(
private http: HttpClient,
private common: CommonsService
) { }
/**
*
*
* @param paramsObject
* @param callBack
*/
public isSetTwoPwd(callBack) {
this.http.post(environment.baseUrl + 'companyTwoPwd/isSetTwoPwd', null).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param paramsObject
* @param callBack
*/
public setTwoPwd(paramsObject: object, callBack) {
this.http.post(environment.baseUrl + 'companyTwoPwd/setTwoPwd', paramsObject).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param paramsObject
* @param callBack
*/
public updateTwoPwd(paramsObject: object, callBack) {
this.http.post(environment.baseUrl + 'companyTwoPwd/updateTwoPwd', paramsObject).subscribe(data => {
callBack(data);
});
}
}

@ -0,0 +1,87 @@
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 OilCardService {
constructor(
private http: HttpClient,
private common: CommonsService
) { }
/**
*
*
* @param param
* @param callBack
*/
public recharge(param: object, callBack) {
this.http.post(environment.baseUrl + 'oilCard/recharge', param).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param param
* @param callBack
*/
public generateCard(param: object, callBack) {
this.http.post(environment.baseUrl + 'oilCard/generateCard', param).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param param
* @param callBack
*/
public setContact(param: object, callBack) {
this.http.post(environment.baseUrl + 'oilCard/setContact', param).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param param
* @param callBack
*/
public disabled(param: object, callBack) {
this.http.post(environment.baseUrl + 'oilCard/disabled', param).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param param
* @param callBack
*/
public enable(param: object, callBack) {
this.http.post(environment.baseUrl + 'oilCard/enable', param).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param param
* @param callBack
*/
public getCardList(param: object, callBack) {
this.http.get(environment.baseUrl + 'oilCard/getCardList?' + this.common.getWhereCondition(param)).subscribe(data => {
callBack(data);
});
}
}
Loading…
Cancel
Save