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.
254 lines
7.6 KiB
254 lines
7.6 KiB
import { Component } from '@angular/core';
|
|
import {DatePipe, NgForOf, NgIf} from "@angular/common";
|
|
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
|
|
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms";
|
|
import {NzButtonComponent} from "ng-zorro-antd/button";
|
|
import {
|
|
NzCellFixedDirective,
|
|
NzTableCellDirective,
|
|
NzTableComponent, NzTableModule,
|
|
NzTbodyComponent, NzTheadComponent,
|
|
NzThMeasureDirective, NzTrDirective
|
|
} from "ng-zorro-antd/table";
|
|
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
|
|
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
|
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
|
import {NzInputNumberModule} from "ng-zorro-antd/input-number";
|
|
import {NzModalModule, NzModalService} from "ng-zorro-antd/modal";
|
|
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
|
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
|
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
|
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
|
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
|
|
import {NzDescriptionsModule} from "ng-zorro-antd/descriptions";
|
|
import {NzUploadComponent} from "ng-zorro-antd/upload";
|
|
import {NzAvatarModule} from "ng-zorro-antd/avatar";
|
|
import {NzImageModule} from "ng-zorro-antd/image";
|
|
import {NzSwitchComponent} from "ng-zorro-antd/switch";
|
|
import {NzMessageService} from "ng-zorro-antd/message";
|
|
import {BrowserStorageService} from "../../../utils/localStorage.service";
|
|
import {CommonService} from "../../../services/common/common.service";
|
|
import {DATA} from "../../../data/login/localStorage.namespace";
|
|
import {GasOilPriceWeekService} from "../../../services/mer-oil-price/gas-oil-price-week.service";
|
|
import {WeekPipe} from "../../../pipes/common/week.pipe";
|
|
import {OilGunNoService} from "../../../services/mer-oil-price/oil-gun-no.service";
|
|
import {OilPriceService} from "../../../services/mer-oil-price/oil-price.service";
|
|
import {NzTypographyComponent} from "ng-zorro-antd/typography";
|
|
import {RouterLink} from "@angular/router";
|
|
import {OilNoConfigComponent} from "../oil-no-config/oil-no-config.component";
|
|
|
|
@Component({
|
|
selector: 'app-oil-config',
|
|
standalone: true,
|
|
imports: [
|
|
DatePipe,
|
|
DictionaryPipe,
|
|
FormsModule,
|
|
NgForOf,
|
|
NgIf,
|
|
NzButtonComponent,
|
|
NzCellFixedDirective,
|
|
NzColDirective,
|
|
NzDividerComponent,
|
|
NzDropDownADirective,
|
|
NzDropDownDirective,
|
|
NzDropdownMenuComponent,
|
|
NzFormControlComponent,
|
|
NzFormDirective,
|
|
NzFormItemComponent,
|
|
NzFormLabelComponent,
|
|
NzIconDirective,
|
|
NzInputDirective,
|
|
NzMenuDirective,
|
|
NzMenuItemComponent,
|
|
NzOptionComponent,
|
|
NzRowDirective,
|
|
NzSelectComponent,
|
|
NzTableCellDirective,
|
|
NzTableComponent,
|
|
NzTbodyComponent,
|
|
NzThMeasureDirective,
|
|
NzTheadComponent,
|
|
NzTrDirective,
|
|
ReactiveFormsModule,
|
|
NzTableModule,
|
|
NzModalModule,
|
|
NzFlexDirective,
|
|
NzDescriptionsModule,
|
|
NzUploadComponent,
|
|
NzAvatarModule,
|
|
NzImageModule,
|
|
NzSwitchComponent,
|
|
NzDatePickerComponent,
|
|
NzInputNumberModule,
|
|
WeekPipe,
|
|
NzTypographyComponent,
|
|
RouterLink,
|
|
OilNoConfigComponent
|
|
],
|
|
templateUrl: './oil-config.component.html',
|
|
styleUrl: './oil-config.component.less'
|
|
})
|
|
export class OilConfigComponent {
|
|
// 表单数据
|
|
tableData: any = {};
|
|
// 搜索表单
|
|
searchForm: FormGroup;
|
|
// 油号
|
|
oilNoArray = new DictionaryPipe().getDictionaryList('OIL_NO');
|
|
// 商户号
|
|
merNo = null;
|
|
// 编辑数据表单
|
|
editDataForm: FormGroup;
|
|
editDataModal = false;
|
|
|
|
setOilNoModal = false;
|
|
setOilNo: any;
|
|
setOilMerNo: any;
|
|
|
|
constructor(private fb: NonNullableFormBuilder,
|
|
private message: NzMessageService,
|
|
private storage: BrowserStorageService,
|
|
private oilGunNoService: OilGunNoService,
|
|
private oilPriceService: OilPriceService,
|
|
private commonService: CommonService,
|
|
private modal: NzModalService) {
|
|
this.merNo = this.storage.get(DATA)['merchant']['merNo'];
|
|
this.searchForm = this.fb.group({
|
|
merNo: [this.merNo],
|
|
});
|
|
this.editDataForm = this.fb.group({
|
|
merNo: [this.merNo],
|
|
oilNo: [null, Validators.required],
|
|
});
|
|
// 查询数据
|
|
this.queryData();
|
|
}
|
|
|
|
/**
|
|
* 获取数据
|
|
*/
|
|
queryData() {
|
|
this.searchForm.value.time = new Date().getTime();
|
|
this.searchForm.value.pageNum = 1;
|
|
this.searchForm.value.pageSize = 100;
|
|
this.oilPriceService.queryOilList(this.searchForm.value, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.tableData = data['return_data'];
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 打开编辑模态框
|
|
*/
|
|
showEditModal() {
|
|
this.editDataModal = true;
|
|
}
|
|
|
|
/**
|
|
* 提交数据
|
|
*/
|
|
submitData() {
|
|
if (this.editDataForm.valid) {
|
|
this.oilPriceService.createOil(this.editDataForm.value, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.message.create('success', '操作成功');
|
|
// 刷新数据
|
|
this.queryData();
|
|
// 关闭弹窗
|
|
this.closeEditModal();
|
|
} else {
|
|
this.message.create('error', data['return_msg']);
|
|
}
|
|
});
|
|
} else {
|
|
Object.values(this.editDataForm.controls).forEach(control => {
|
|
if (control.invalid) {
|
|
control.markAsDirty();
|
|
control.updateValueAndValidity({ onlySelf: true });
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 关闭编辑任务模态框
|
|
*/
|
|
closeEditModal() {
|
|
this.editDataForm.reset();
|
|
this.editDataModal = false;
|
|
}
|
|
|
|
/**
|
|
* 打开设置油枪号模态框
|
|
*/
|
|
showSetOilNoModal(oilNo:string) {
|
|
this.setOilMerNo = this.merNo;
|
|
this.setOilNo = oilNo;
|
|
this.setOilNoModal = true;
|
|
}
|
|
|
|
/**
|
|
* 禁用油号
|
|
* @param oilNo
|
|
*/
|
|
disable(oilNo:string) {
|
|
this.modal.confirm({
|
|
nzTitle: '提醒',
|
|
nzContent: '确定禁用'+oilNo+'号油吗?禁用后此油号无法加油',
|
|
nzOnOk: () => this.oilPriceService.disable({'merNo':this.merNo, 'oilNo':oilNo}, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.message.create('success', '操作成功');
|
|
// 刷新数据
|
|
this.queryData();
|
|
} else {
|
|
this.message.create('error', data['return_msg']);
|
|
}
|
|
})
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 恢复油号
|
|
* @param oilNo
|
|
*/
|
|
restore(oilNo:string) {
|
|
this.modal.confirm({
|
|
nzTitle: '提醒',
|
|
nzContent: '确定恢复'+oilNo+'号油吗?恢复后可进行加油',
|
|
nzOnOk: () => this.oilPriceService.restore({'merNo':this.merNo, 'oilNo':oilNo}, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.message.create('success', '操作成功');
|
|
// 刷新数据
|
|
this.queryData();
|
|
} else {
|
|
this.message.create('error', data['return_msg']);
|
|
}
|
|
})
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 删除油号
|
|
* @param oilNo
|
|
*/
|
|
delOil(oilNo:string) {
|
|
this.modal.confirm({
|
|
nzTitle: '提醒',
|
|
nzContent: '确定删除'+oilNo+'号油吗?',
|
|
nzOnOk: () => this.oilPriceService.delete({'merNo':this.merNo, 'oilNo':oilNo}, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.message.create('success', '操作成功');
|
|
// 刷新数据
|
|
this.queryData();
|
|
} else {
|
|
this.message.create('error', data['return_msg']);
|
|
}
|
|
})
|
|
});
|
|
}
|
|
|
|
}
|
|
|