parent
8b0bbb3df5
commit
b7a66d3ba0
@ -0,0 +1,132 @@ |
|||||||
|
<form nz-form [formGroup]="searchForm" class="search_form"> |
||||||
|
<div nz-row [nzGutter]="24"> |
||||||
|
<div nz-col [nzSpan]="6"> |
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label nzRequired>油站渠道</nz-form-label> |
||||||
|
<nz-form-control> |
||||||
|
<nz-select formControlName="gasChannelType" [nzPlaceHolder]="'请选择'"> |
||||||
|
<nz-option *ngFor="let item of merSourceTypeArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||||
|
</nz-select> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
</div> |
||||||
|
<div nz-col [nzSpan]="6"> |
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label nzRequired>油号</nz-form-label> |
||||||
|
<nz-form-control> |
||||||
|
<nz-select formControlName="oilNo" [nzPlaceHolder]="'请选择'"> |
||||||
|
<nz-option *ngFor="let item of oilNoArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||||
|
</nz-select> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
</div> |
||||||
|
<div nz-col [nzSpan]="6"> |
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label [nzNoColon]="true"></nz-form-label> |
||||||
|
<nz-form-control> |
||||||
|
<button nz-button style="margin-right: 8px" [nzType]="'primary'" (click)="searchFormSubmit()">查询</button> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
|
||||||
|
<nz-table #basicTable |
||||||
|
[nzScroll]="{ x: '1200' }" |
||||||
|
[nzBordered]="true" |
||||||
|
[nzShowPagination]="false" |
||||||
|
[nzFrontPagination]="false" |
||||||
|
[nzShowQuickJumper]="false" |
||||||
|
[nzShowTotal]="totalTemplate" |
||||||
|
[nzTotal]="tableData.length" |
||||||
|
[nzData]="tableData" > |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th nzWidth="100px">渠道</th> |
||||||
|
<th nzWidth="100px">日期</th> |
||||||
|
<th nzWidth="100px">油号</th> |
||||||
|
<th nzWidth="100px">折扣(%)</th> |
||||||
|
<th nzWidth="100px">服务费(%)</th> |
||||||
|
<th nzWidth="100px">更新时间</th> |
||||||
|
<th nzRight nzWidth="50px">操作</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<tr *ngFor="let data of basicTable.data"> |
||||||
|
<td style="{{today == data.weeks?'color: red':''}}">{{data.gasChannelType | dictionary: "MER_SOURCE_TYPE"}}</td> |
||||||
|
<td style="{{today == data.weeks?'color: red':''}}"> |
||||||
|
{{data.weeks | week}} {{today == data.weeks?'(今日)':''}} |
||||||
|
</td> |
||||||
|
<td style="{{today == data.weeks?'color: red':''}}">{{data.oilNo}}</td> |
||||||
|
<td style="{{today == data.weeks?'color: red':''}}">{{data.priceRate}}</td> |
||||||
|
<td style="{{today == data.weeks?'color: red':''}}">{{data.serviceFeeRate}}</td> |
||||||
|
<td style="{{today == data.weeks?'color: red':''}}">{{data.updateTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td> |
||||||
|
<td nzRight> |
||||||
|
<button nz-button nzType="link" (click)="showEditModal(data)" [nzSize]="'small'" >修改</button> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template> |
||||||
|
</nz-table> |
||||||
|
|
||||||
|
<nz-modal [(nzVisible)]="editDataModal" |
||||||
|
[nzWidth]="500" |
||||||
|
nzTitle="修改价格" |
||||||
|
[nzFooter]="null" |
||||||
|
(nzOnCancel)="closeEditModal()"> |
||||||
|
<ng-container *nzModalContent> |
||||||
|
<form nz-form [formGroup]="editDataForm"> |
||||||
|
|
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label [nzSm]="6" [nzXs]="24">渠道</nz-form-label> |
||||||
|
<nz-form-control [nzSm]="14" [nzXs]="24"> |
||||||
|
<nz-select formControlName="gasChannelType" [nzPlaceHolder]="'请选择'"> |
||||||
|
<nz-option *ngFor="let item of merSourceTypeArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||||
|
</nz-select> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
|
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label [nzSm]="6" [nzXs]="24">日期</nz-form-label> |
||||||
|
<nz-form-control [nzSm]="14" [nzXs]="24"> |
||||||
|
<nz-select formControlName="week" [nzPlaceHolder]="'请选择'"> |
||||||
|
<nz-option nzValue="1" nzLabel="星期一"></nz-option> |
||||||
|
<nz-option nzValue="2" nzLabel="星期二"></nz-option> |
||||||
|
<nz-option nzValue="3" nzLabel="星期三"></nz-option> |
||||||
|
<nz-option nzValue="4" nzLabel="星期四"></nz-option> |
||||||
|
<nz-option nzValue="5" nzLabel="星期五"></nz-option> |
||||||
|
<nz-option nzValue="6" nzLabel="星期六"></nz-option> |
||||||
|
<nz-option nzValue="7" nzLabel="星期日"></nz-option> |
||||||
|
</nz-select> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
|
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label [nzSm]="6" [nzXs]="24">油品</nz-form-label> |
||||||
|
<nz-form-control [nzSm]="14" [nzXs]="24"> |
||||||
|
<nz-select formControlName="oilNo" nzAllowClear [nzPlaceHolder]="'请选择'"> |
||||||
|
<nz-option *ngFor="let item of oilNoArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||||
|
</nz-select> |
||||||
|
</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"> |
||||||
|
<nz-input-number formControlName="priceRate" [nzMin]="0" [nzMax]="100" [nzStep]="1" [nzPrecision]="2" [nzPlaceHolder]="'折扣'"></nz-input-number> |
||||||
|
</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"> |
||||||
|
<nz-input-number formControlName="serviceFeeRate" [nzMin]="0" [nzMax]="100" [nzStep]="1" [nzPrecision]="2" [nzPlaceHolder]="'服务费'"></nz-input-number> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
|
||||||
|
<div nz-flex style="margin-top: 15px" [nzJustify]="'center'"> |
||||||
|
<button nz-button nzType="primary" (click)="submitData()" class="submit-btn">保存</button> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</ng-container> |
||||||
|
</nz-modal> |
@ -0,0 +1,3 @@ |
|||||||
|
nz-input-number { |
||||||
|
width: 100%; |
||||||
|
} |
@ -0,0 +1,196 @@ |
|||||||
|
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; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
import { Injectable } from '@angular/core'; |
||||||
|
import {HttpClient} from "@angular/common/http"; |
||||||
|
import {environment} from "../../../environments/environment"; |
||||||
|
import {ObjectData} from "../../utils/objectData.service"; |
||||||
|
|
||||||
|
@Injectable({ |
||||||
|
providedIn: 'root' |
||||||
|
}) |
||||||
|
export class OilChannelWeekService { |
||||||
|
|
||||||
|
constructor(private http: HttpClient) { } |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改价格 |
||||||
|
* @param params |
||||||
|
* @param callBack |
||||||
|
*/ |
||||||
|
public updatePrice(params: any, callBack:any) { |
||||||
|
params.time = new Date().getTime(); |
||||||
|
this.http.post(environment.baseUrl + 'gasChannelPriceWeek/updatePrice', params).subscribe(data => { |
||||||
|
callBack(data); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询价格 |
||||||
|
* @param params |
||||||
|
* @param callBack |
||||||
|
*/ |
||||||
|
public getPriceList(params: any, callBack:any) { |
||||||
|
params.time = new Date().getTime(); |
||||||
|
this.http.get(environment.baseUrl + 'gasChannelPriceWeek/getPriceList?'+ObjectData.objectByString(params)).subscribe(data => { |
||||||
|
callBack(data); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue