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.
252 lines
7.1 KiB
252 lines
7.1 KiB
import { Component, OnInit } from '@angular/core';
|
|
import {environment} from '../../../../environments/environment';
|
|
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
|
|
import {NzMessageService, NzModalService, NzUploadChangeParam} from 'ng-zorro-antd';
|
|
import {LocalStorageService} from '../../../services/local-storage.service';
|
|
import {FleetOilCardUserService} from '../../../services/fleet-oil-card-user.service';
|
|
import {OrganizationService} from '../../../services/organization.service';
|
|
import {CompanyAccountService} from '../../../services/company-account.service';
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace';
|
|
import {FleetOilCardCarService} from '../../../services/fleet-oil-card-car.service';
|
|
|
|
@Component({
|
|
selector: 'app-fleet-oil-card-car',
|
|
templateUrl: './fleet-oil-card-car.component.html',
|
|
styleUrls: ['./fleet-oil-card-car.component.scss']
|
|
})
|
|
export class FleetOilCardCarComponent implements OnInit {
|
|
WEB_SERVE_URL = environment.baseUrl;
|
|
FILE_URL = environment.imageUrl;
|
|
roleType;
|
|
adminFlag;
|
|
loadingObject = {
|
|
spinning: false,
|
|
msg: '加载中'
|
|
};
|
|
dataObject: any = {};
|
|
tableLoading = true;
|
|
searchForm: FormGroup;
|
|
pageNum: number;
|
|
whereObject: any = {};
|
|
|
|
fleetCardNo: string;
|
|
|
|
rechargeModal = false;
|
|
rechargeForm: FormGroup;
|
|
rechargeBtnLoading = false;
|
|
|
|
orgArray = [];
|
|
accountObject = {
|
|
amounts: 0
|
|
};
|
|
|
|
importErrorDataModal = false;
|
|
errorDataArray = [];
|
|
|
|
constructor(private modal: NzModalService,
|
|
private message: NzMessageService,
|
|
private store: LocalStorageService,
|
|
private fleetOilCardCarService: FleetOilCardCarService,
|
|
private organizationService: OrganizationService,
|
|
private companyAccountService: CompanyAccountService,
|
|
private activatedRoute: ActivatedRoute,
|
|
private router: Router,
|
|
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.activatedRoute.queryParams.subscribe(queryParams => {
|
|
if (queryParams.cardNo != null) {
|
|
this.fleetCardNo = queryParams.cardNo;
|
|
}
|
|
});
|
|
|
|
this.searchForm = this.form.group({
|
|
contactName: [null],
|
|
contactPhone: [null],
|
|
});
|
|
|
|
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'];
|
|
});
|
|
}
|
|
this.requestData(1);
|
|
}
|
|
|
|
/**
|
|
* 请求数据
|
|
*/
|
|
requestData(pageNum) {
|
|
this.tableLoading = true;
|
|
this.whereObject['fleetOilCardNo'] = this.fleetCardNo;
|
|
this.whereObject['pageNum'] = pageNum;
|
|
this.whereObject['pageSize'] = 10;
|
|
this.fleetOilCardCarService.getCarList(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();
|
|
}
|
|
|
|
/**
|
|
* 弹出删除对话框
|
|
*/
|
|
showDelConfirm(id: number): void {
|
|
this.modal.confirm({
|
|
nzTitle: '警告',
|
|
nzContent: '是否删除该数据?',
|
|
nzOkText: '是',
|
|
nzCancelText: '否',
|
|
nzOkType: 'danger',
|
|
nzOnOk: () => this.delData(id)
|
|
});
|
|
}
|
|
|
|
delData(id: number) {
|
|
this.fleetOilCardCarService.delete({ id: id }, data => {
|
|
if (data['return_code'] === '000000') {
|
|
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.fleetOilCardService.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.fleetOilCardService.enable({ cardNo: cardNo}, data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.requestData(this.whereObject['pageNum']);
|
|
} else {
|
|
this.modal.error({
|
|
nzTitle: '提示',
|
|
nzContent: data['return_msg']
|
|
});
|
|
}
|
|
});*/
|
|
}
|
|
|
|
handleChange(info: NzUploadChangeParam): void {
|
|
if (info.file.status === 'done') {
|
|
if (info.file.response.return_code === '000000') {
|
|
if (info.file.response.return_data == null || info.file.response.return_data.errorTotal === 0) {
|
|
|
|
this.requestData(1);
|
|
this.message.success('导入成功');
|
|
|
|
} else {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzOkText: '查看失败数据',
|
|
nzContent: '只有部分数据导入成功',
|
|
nzOnOk: () => this.showImportErrorDataModal(info.file.response.return_data)
|
|
});
|
|
}
|
|
} else {
|
|
this.message.error(info.file.response.return_msg);
|
|
}
|
|
} else if (info.file.status === 'error') {
|
|
this.message.error('上传错误');
|
|
}
|
|
}
|
|
|
|
// 打开模态框
|
|
showImportErrorDataModal(data: []) {
|
|
this.errorDataArray = data['errorData'];
|
|
this.importErrorDataModal = true;
|
|
}
|
|
|
|
closeImportErrorDataModal() {
|
|
this.importErrorDataModal = false;
|
|
}
|
|
|
|
downloadTemplate() {
|
|
window.location.href = this.FILE_URL + "template/导入车辆模板.xlsx";
|
|
}
|
|
|
|
}
|
|
|