嗨森逛PC管理端
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.
 
 
 
 
high-web/src/app/admin/system/oils-discount/oils-discount.component.ts

171 lines
4.9 KiB

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, Validators} from '@angular/forms';
import {NzMessageService, NzModalService} 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;
configOilMerNumModal = false;
configOilMerNumForm: FormGroup;
constructor(
private form: FormBuilder,
private modal: NzModalService,
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.configOilMerNumForm = this.form.group({
codeType: ['OIL_WX_MER'],
codeValue: [null, [Validators.required]],
});
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;
}
showConfigOilMerNum() {
this.common.mappingSysNameOl('OIL_WX_MER', data => {
this.configOilMerNumForm.patchValue(data['return_data']);
});
this.configOilMerNumModal = true;
}
closeConfigOilMerNum() {
this.configOilMerNumModal = false;
}
submitConfigOilMerNum() {
for (const i in this.configOilMerNumForm.controls) {
this.configOilMerNumForm.controls[i].markAsDirty();
this.configOilMerNumForm.controls[i].updateValueAndValidity();
}
if (this.configOilMerNumForm.status == null || this.configOilMerNumForm.status !== 'VALID') {
this.modal.warning({
nzTitle: '提示',
nzContent: '请填写所有必填项',
});
return;
}
this.common.editConfig(this.configOilMerNumForm.value, data => {
if (data['return_code'] === '000000') {
this.modal.success({
nzTitle: '提示',
nzContent: '操作成功',
});
this.closeConfigOilMerNum();
} else {
this.modal.error({
nzTitle: '提示',
nzContent: data['return_msg'],
});
}
});
}
}