pull/1/head
袁野 3 years ago
parent a9169f5cdc
commit deabca9198
  1. 101
      src/app/admin/system/oils-discount/oils-discount.component.html
  2. 0
      src/app/admin/system/oils-discount/oils-discount.component.scss
  3. 122
      src/app/admin/system/oils-discount/oils-discount.component.ts

@ -0,0 +1,101 @@
<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->
<!--条件搜索-->
<div class="inner-content">
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)">
<div nz-row>
<div nz-col nzSpan="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">油品</nz-form-label>
<nz-form-control [nzSpan]="16">
<input nz-input formControlName="oilNo"/>
</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">
<span>共计 {{total}} 条数据</span>
<div class="operating-button">
<button nz-button nzType="primary" class="right-btn" (click)="getAdd()" ><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button>
</div>
<nz-table
class="table"
#ajaxTable
nzShowSizeChanger
[nzFrontPagination]="false"
[nzData]="requestData"
[nzLoading]="loading"
[nzTotal]="total"
[(nzPageIndex)]="pageNum"
[(nzPageSize)]="pageSize"
[nzScroll]="{ x: '1200px' }"
(nzPageIndexChange)="getRequest(false , searchForm.value)"
(nzPageSizeChange)="getRequest(false , searchForm.value)">
<thead nzSingleSort>
<tr>
<th nzWidth="50px">编号</th>
<th nzWidth="80px">油品</th>
<th nzWidth="80px">优惠比例</th>
<th nzWidth="100px">创建时间</th>
<th nzWidth="100px">更新时间</th>
<th nzWidth="80px" nzRight="0px">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of ajaxTable.data; let i = index">
<td>{{i+1}}</td>
<td>{{data.oilNo}}</td>
<td>{{data.priceRate}} %</td>
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td nzRight="0px" class="table-td-operation">
<a (click)="getEdit(data.id)">编辑</a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)='getForbiddenUser(data.id)'>删除</a>
</td>
</tbody>
</nz-table>
</div>
<nz-modal [(nzVisible)]="isVisible" nzTitle="编辑" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<form nz-form [formGroup]="getForm">
<div nz-row>
<div nz-col [nzSpan]="22">
<nz-form-item>
<nz-form-label [nzFor]="'oilNoName'" nzRequired>油品名称</nz-form-label>
<nz-form-control nzErrorTip="请输入油品名称!">
<nz-select formControlName="roleType" [formControlName]="'oilNo'" nzAllowClear nzPlaceHolder="选择类型">
<nz-option *ngFor="let item of roleTypeArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="22">
<nz-form-item>
<nz-form-label [nzFor]="'oilNoName'" nzRequired>折扣比例</nz-form-label>
<nz-form-control nzErrorTip="请输入折扣比例!">
<nz-input-group nzSuffix="%" >
<input type="number" nz-input formControlName="priceRate" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
</div>
</div>
</form>
</nz-modal>

@ -0,0 +1,122 @@
import {Component, OnInit} from '@angular/core';
import {environment} from '../../../../environments/environment';
import {CompanyService} from '../../../services/company.service';
import {IconService} from '../../../services/icon.service';
import {CommonsService} from '../../../services/commons.service';
import {FormBuilder, FormGroup} from '@angular/forms';
import {NzMessageService} from 'ng-zorro-antd';
import {Router} from '@angular/router';
@Component({
selector: 'app-oils-discount',
templateUrl: './oils-discount.component.html',
styleUrls: ['./oils-discount.component.scss']
})
export class OilsDiscountComponent implements OnInit {
WEB_SERVE_URL = environment.imageUrl;
searchForm: FormGroup; // 搜索框
getForm: FormGroup; // 搜索框
requestData = []; // 列表数据
total: number; // 页码
pageNum = 1; // 页码
pageSize = 10; // 条码
loading = true;
isVisible = false;
roleTypeArray;
constructor(
private form: FormBuilder,
private company: CompanyService,
private iconService: IconService,
private message: NzMessageService,
private router: Router,
private common: CommonsService
) {
}
ngOnInit(): void {
this.common.getDictionary('GAS_OIL_TYPE', data => {
this.roleTypeArray = data['return_data'];
});
this.init();
}
public init(): void {
this.searchForm = this.form.group({
oilNo: [null],
});
this.getForm = this.form.group({
oilNo: [null],
priceRate: [null],
});
this.getRequest(true, this.searchForm.value);
}
// 查询列表
public getRequest(reset: boolean = false, whereObject: object) {
this.loading = false;
if (reset) {
this.pageNum = 1;
}
whereObject['pageNum'] = this.pageNum;
whereObject['pageSize'] = this.pageSize;
this.common.getList(whereObject, data => {
if (data['return_code'] === '000000') {
this.requestData = data['return_data'].list;
this.total = data['return_data'].total;
} else {
this.message.error(data['return_msg']);
}
});
}
// 重置
public resetForm(): void {
this.searchForm.reset();
}
public getForbiddenUser(id): void {
this.common.showConfirm('是否删除', data => {
if (data) {
this.common.delete(id, dataUser => {
this.getRequest(false, this.searchForm.value);
});
}
});
}
// 修改
public getAdd(): void {
this.isVisible = true;
}
getEdit(id: number): void {
this.isVisible = true;
this.common.getDetailById(id , data => {
this.getForm.patchValue(data['return_data']);
this.getForm.value.id = id;
});
}
handleOk(): void {
console.log(this.getForm.value);
this.common.editGasDiscountOilPrice(this.getForm.value, data => {
if (data['return_code'] === '000000') {
this.getRequest(false, this.searchForm.value);
} else {
this.message.error(data['return_msg']);
}
});
this.isVisible = false;
}
handleCancel(): void {
this.isVisible = false;
}
}
Loading…
Cancel
Save