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.
196 lines
6.0 KiB
196 lines
6.0 KiB
import { Component } from '@angular/core';
|
|
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms";
|
|
import {DatePipe, NgForOf, NgIf} from "@angular/common";
|
|
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
|
|
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 {NzDividerComponent} from "ng-zorro-antd/divider";
|
|
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
|
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
|
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
|
|
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
|
import {NzModalModule, NzModalService} from "ng-zorro-antd/modal";
|
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
|
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 {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
|
|
import {NzInputNumberModule} from "ng-zorro-antd/input-number";
|
|
import {WeekPipe} from "../../../pipes/common/week.pipe";
|
|
import {NzMessageService} from "ng-zorro-antd/message";
|
|
import {BrowserStorageService} from "../../../utils/localStorage.service";
|
|
import {DATA} from "../../../data/login/localStorage.namespace";
|
|
import {CommonService} from "../../../services/common/common.service";
|
|
import {OilChannelWeekService} from "../../../services/mer-oil-price/oil-channel-week.service";
|
|
|
|
@Component({
|
|
selector: 'app-oil-channel-week',
|
|
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
|
|
],
|
|
templateUrl: './oil-channel-week.component.html',
|
|
styleUrl: './oil-channel-week.component.less'
|
|
})
|
|
export class OilChannelWeekComponent {
|
|
// 表单数据
|
|
tableData: any = [];
|
|
// 搜索表单
|
|
searchForm: FormGroup;
|
|
// 油站渠道
|
|
merSourceTypeArray = new DictionaryPipe().getDictionaryList('MER_SOURCE_TYPE');
|
|
// 油号
|
|
oilNoArray = new DictionaryPipe().getDictionaryList('OIL_NO');
|
|
// 编辑数据表单
|
|
editDataForm: FormGroup;
|
|
editDataModal = false;
|
|
// 当前日期
|
|
today:number = new Date().getDay();
|
|
constructor(private fb: NonNullableFormBuilder,
|
|
private message: NzMessageService,
|
|
private storage: BrowserStorageService,
|
|
private oilChannelWeekService: OilChannelWeekService,
|
|
private commonService: CommonService,
|
|
private modal: NzModalService) {
|
|
// 初始化搜索框
|
|
this.searchForm = this.fb.group({
|
|
gasChannelType: [this.merSourceTypeArray[0].codeValue],
|
|
oilNo: [this.oilNoArray[0].codeValue],
|
|
});
|
|
|
|
this.editDataForm = this.fb.group({
|
|
id: [null, [Validators.required]],
|
|
gasChannelType: [null],
|
|
week: [null],
|
|
oilNo: [null],
|
|
priceRate: [null, [Validators.required]],
|
|
serviceFeeRate: [null, [Validators.required]],
|
|
});
|
|
// 查询数据
|
|
this.queryData();
|
|
}
|
|
|
|
/**
|
|
* 获取数据
|
|
*/
|
|
queryData() {
|
|
this.searchForm.value.time = new Date().getTime();
|
|
this.oilChannelWeekService.getPriceList(this.searchForm.value, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.tableData = data['return_data'];
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 搜索表单提交
|
|
*/
|
|
searchFormSubmit(): void {
|
|
this.queryData();
|
|
}
|
|
|
|
/**
|
|
* 搜索表单重置
|
|
*/
|
|
searchFormReset(): void {
|
|
this.searchForm.reset();
|
|
}
|
|
|
|
/**
|
|
* 打开编辑模态框
|
|
*/
|
|
showEditModal(data: any) {
|
|
data['week'] = String(data['weeks']);
|
|
data['gasChannelType'] = String(data['gasChannelType']);
|
|
this.editDataForm.patchValue(data);
|
|
this.editDataForm.controls['week'].disable();
|
|
this.editDataForm.controls['oilNo'].disable();
|
|
this.editDataForm.controls['gasChannelType'].disable();
|
|
this.editDataModal = true;
|
|
}
|
|
|
|
/**
|
|
* 提交数据
|
|
*/
|
|
submitData() {
|
|
if (this.editDataForm.valid) {
|
|
this.oilChannelWeekService.updatePrice(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;
|
|
}
|
|
}
|
|
|