|
|
|
@ -4,11 +4,13 @@ import {NzMessageService, NzModalService} from '_ng-zorro-antd@9.3.0@ng-zorro-an |
|
|
|
|
import {TyAgentService} from '../../../services/ty-agent.service'; |
|
|
|
|
import {TyAgentOilStationService} from '../../../services/ty-agent-oil-station.service'; |
|
|
|
|
import {Validators} from '@angular/forms'; |
|
|
|
|
import {OrganizationService} from "../../../services/organization.service"; |
|
|
|
|
import {LocalStorageService} from "../../../services/local-storage.service"; |
|
|
|
|
import {OrganizationService} from '../../../services/organization.service'; |
|
|
|
|
import {LocalStorageService} from '../../../services/local-storage.service'; |
|
|
|
|
import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace'; |
|
|
|
|
import {TySalesmanService} from "../../../services/ty-salesman.service"; |
|
|
|
|
import {TyAgentPriceService} from "../../../services/ty-agent-price.service"; |
|
|
|
|
import {TySalesmanService} from '../../../services/ty-salesman.service'; |
|
|
|
|
import {TyAgentPriceService} from '../../../services/ty-agent-price.service'; |
|
|
|
|
import {GasService} from '../../../services/gas.service'; |
|
|
|
|
import {CommonsService} from "../../../services/commons.service"; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-petrol-station-manage', |
|
|
|
@ -45,15 +47,27 @@ export class PetrolStationManageComponent implements OnInit { |
|
|
|
|
assignSalesmanModal = false; |
|
|
|
|
assignSalesmanForm: FormGroup; |
|
|
|
|
|
|
|
|
|
batchDiscountConfigModal = false; |
|
|
|
|
batchDiscountConfigForm: FormGroup; |
|
|
|
|
|
|
|
|
|
batchConfigOilNoModal = false; |
|
|
|
|
batchConfigOilNoForm: FormGroup; |
|
|
|
|
|
|
|
|
|
discountConfigModal = false; |
|
|
|
|
discountConfigData: PetrolStationManage[] = []; |
|
|
|
|
|
|
|
|
|
oilConfigModal = false; |
|
|
|
|
|
|
|
|
|
oilNoArray = []; |
|
|
|
|
|
|
|
|
|
formatterPercent = (value: number) => `${value} 折`; |
|
|
|
|
parserPercent = (value: string) => value.replace(' 折', ''); |
|
|
|
|
|
|
|
|
|
constructor(private modal: NzModalService, |
|
|
|
|
private message: NzMessageService, |
|
|
|
|
private tyAgentService: TyAgentService, |
|
|
|
|
private commonsService: CommonsService, |
|
|
|
|
private gasService: GasService, |
|
|
|
|
private tyAgentPriceService: TyAgentPriceService, |
|
|
|
|
private tySalesmanService: TySalesmanService, |
|
|
|
|
private organizationService: OrganizationService, |
|
|
|
@ -84,6 +98,21 @@ export class PetrolStationManageComponent implements OnInit { |
|
|
|
|
this.assignSalesmanForm = this.form.group({ |
|
|
|
|
salesmanId: [null, [Validators.required]], |
|
|
|
|
}); |
|
|
|
|
this.batchDiscountConfigForm = this.form.group({ |
|
|
|
|
belongType: [null], |
|
|
|
|
oilNo: [null, [Validators.required]], |
|
|
|
|
priceRate: [100, [Validators.required]], |
|
|
|
|
}); |
|
|
|
|
this.batchConfigOilNoForm = this.form.group({ |
|
|
|
|
status: [null, [Validators.required]], |
|
|
|
|
oilNo: [null, [Validators.required]], |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.commonsService.getDictionary('GAS_OIL_TYPE', data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.oilNoArray = data['return_data']; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.requestData(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -548,12 +577,80 @@ export class PetrolStationManageComponent implements OnInit { |
|
|
|
|
* 弹出优惠配置模态框 |
|
|
|
|
*/ |
|
|
|
|
showDiscountConfigModal(oilStationId: number) { |
|
|
|
|
this.tyAgentPriceService.getOilStationPrice(oilStationId, data => { |
|
|
|
|
this.getOilStationPrice(oilStationId); |
|
|
|
|
this.discountConfigModal = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭优惠配置模态框 |
|
|
|
|
*/ |
|
|
|
|
closeDiscountConfigModal() { |
|
|
|
|
this.discountConfigModal = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 弹出批量优惠配置模态框 |
|
|
|
|
*/ |
|
|
|
|
showBatchDiscountConfigModal() { |
|
|
|
|
this.batchDiscountConfigModal = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭批量优惠配置模态框 |
|
|
|
|
*/ |
|
|
|
|
closeBatchDiscountConfigModal() { |
|
|
|
|
this.batchDiscountConfigModal = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 批量设置优惠 |
|
|
|
|
*/ |
|
|
|
|
submitBatchDiscountConfig() { |
|
|
|
|
for (const i in this.batchDiscountConfigForm.controls) { |
|
|
|
|
this.batchDiscountConfigForm.controls[i].markAsDirty(); |
|
|
|
|
this.batchDiscountConfigForm.controls[i].updateValueAndValidity(); |
|
|
|
|
} |
|
|
|
|
if (this.batchDiscountConfigForm.status == null || this.batchDiscountConfigForm.status !== 'VALID') { |
|
|
|
|
this.modal.warning({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: '有必填项未填写', |
|
|
|
|
}); |
|
|
|
|
this.loadingObject.spinning = false; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (this.checkedData.length === 0) { |
|
|
|
|
this.modal.warning({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: '请勾选油站', |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.loadingObject.spinning = true; |
|
|
|
|
this.loadingObject.msg = '处理中...'; |
|
|
|
|
this.batchDiscountConfigModal = false; |
|
|
|
|
|
|
|
|
|
if (this.roleType === 5) { |
|
|
|
|
this.batchDiscountConfigForm.value.belongType = 1; |
|
|
|
|
} else { |
|
|
|
|
this.batchDiscountConfigForm.value.belongType = 2; |
|
|
|
|
} |
|
|
|
|
const oilStationList = []; |
|
|
|
|
for (const data of this.checkedData) { |
|
|
|
|
oilStationList.push({ oilStationId: data['storeId'], oilStationName: data['storeName'], tyAgentOilStationId: data['tyAgentOilStationId'] }); |
|
|
|
|
} |
|
|
|
|
this.batchDiscountConfigForm.value['oilStationList'] = oilStationList; |
|
|
|
|
this.tyAgentPriceService.batchConfigPrice(this.batchDiscountConfigForm.value, data => { |
|
|
|
|
this.loadingObject.spinning = false; |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.discountConfigData = data['return_data']; |
|
|
|
|
this.discountConfigModal = true; |
|
|
|
|
this.modal.success({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: '处理成功', |
|
|
|
|
}); |
|
|
|
|
this.checkedData = []; |
|
|
|
|
this.requestData(this.whereObject['pageNum']); |
|
|
|
|
this.closeBatchDiscountConfigModal(); |
|
|
|
|
} else { |
|
|
|
|
this.modal.warning({ |
|
|
|
|
this.modal.error({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: data['return_msg'], |
|
|
|
|
}); |
|
|
|
@ -562,10 +659,67 @@ export class PetrolStationManageComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭优惠配置模态框 |
|
|
|
|
* 弹出批量优惠配置模态框 |
|
|
|
|
*/ |
|
|
|
|
closeDiscountConfigModal() { |
|
|
|
|
this.discountConfigModal = false; |
|
|
|
|
showBatchConfigOilNoModal() { |
|
|
|
|
this.batchConfigOilNoModal = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭批量优惠配置模态框 |
|
|
|
|
*/ |
|
|
|
|
closeBatchConfigOilNoModal() { |
|
|
|
|
this.batchConfigOilNoModal = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 批量设置优惠 |
|
|
|
|
*/ |
|
|
|
|
submitBatchConfigOilNo() { |
|
|
|
|
for (const i in this.batchConfigOilNoForm.controls) { |
|
|
|
|
this.batchConfigOilNoForm.controls[i].markAsDirty(); |
|
|
|
|
this.batchConfigOilNoForm.controls[i].updateValueAndValidity(); |
|
|
|
|
} |
|
|
|
|
if (this.batchConfigOilNoForm.status == null || this.batchConfigOilNoForm.status !== 'VALID') { |
|
|
|
|
this.modal.warning({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: '有必填项未填写', |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (this.checkedData.length === 0) { |
|
|
|
|
this.modal.warning({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: '请勾选油站', |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.loadingObject.spinning = true; |
|
|
|
|
this.loadingObject.msg = '处理中...'; |
|
|
|
|
this.batchDiscountConfigModal = false; |
|
|
|
|
|
|
|
|
|
const oilStationList = []; |
|
|
|
|
for (const data of this.checkedData) { |
|
|
|
|
oilStationList.push({ oilStationId: data['storeId'] }); |
|
|
|
|
} |
|
|
|
|
this.batchConfigOilNoForm.value['oilStationList'] = oilStationList; |
|
|
|
|
this.tyAgentPriceService.batchConfigOilNo(this.batchConfigOilNoForm.value, data => { |
|
|
|
|
this.loadingObject.spinning = false; |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.modal.success({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: '处理成功', |
|
|
|
|
}); |
|
|
|
|
this.checkedData = []; |
|
|
|
|
this.requestData(this.whereObject['pageNum']); |
|
|
|
|
this.closeBatchConfigOilNoModal(); |
|
|
|
|
} else { |
|
|
|
|
this.modal.error({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: data['return_msg'], |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -578,6 +732,15 @@ export class PetrolStationManageComponent implements OnInit { |
|
|
|
|
nzContent: '没有配置优惠数据' |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (this.roleType === 5) { |
|
|
|
|
for (const data of this.discountConfigData) { |
|
|
|
|
data['belongType'] = 1; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
for (const data of this.discountConfigData) { |
|
|
|
|
data['belongType'] = 2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.tyAgentPriceService.editPrice(this.discountConfigData, data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.modal.success({ |
|
|
|
@ -595,6 +758,21 @@ export class PetrolStationManageComponent implements OnInit { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 弹出油品配置模态框 |
|
|
|
|
*/ |
|
|
|
|
showOilConfigModal(oilStationId: number) { |
|
|
|
|
this.getOilStationPrice(oilStationId); |
|
|
|
|
this.oilConfigModal = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭油品配置模态框 |
|
|
|
|
*/ |
|
|
|
|
closeOilConfigModal() { |
|
|
|
|
this.oilConfigModal = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 全选 |
|
|
|
|
* @param data |
|
|
|
@ -636,13 +814,86 @@ export class PetrolStationManageComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 油品禁用提示 |
|
|
|
|
*/ |
|
|
|
|
showOilDisabledConfirm(oilStationId: number, oilNo: string): void { |
|
|
|
|
this.modal.confirm({ |
|
|
|
|
nzTitle: '警告', |
|
|
|
|
nzContent: '确定要暂停销售该油品吗', |
|
|
|
|
nzOkText: '是', |
|
|
|
|
nzCancelText: '否', |
|
|
|
|
nzOkType: 'danger', |
|
|
|
|
nzOnOk: () => this.submitOilDisabled(oilStationId, oilNo) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
submitOilDisabled(oilStationId: number, oilNo: string) { |
|
|
|
|
this.gasService.disabledOil({ storeId: oilStationId, oilNo: oilNo }, data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.modal.success({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: data['return_data'], |
|
|
|
|
}); |
|
|
|
|
this.getOilStationPrice(oilStationId); |
|
|
|
|
} else { |
|
|
|
|
this.modal.warning({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: data['return_msg'], |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 油品启用提示 |
|
|
|
|
*/ |
|
|
|
|
showOilEnableConfirm(oilStationId: number, oilNo: string): void { |
|
|
|
|
this.gasService.enableOil({ storeId: oilStationId, oilNo: oilNo }, data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.modal.success({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: data['return_data'], |
|
|
|
|
}); |
|
|
|
|
this.getOilStationPrice(oilStationId); |
|
|
|
|
} else { |
|
|
|
|
this.modal.warning({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: data['return_msg'], |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询油站价格 |
|
|
|
|
* @param oilStationId |
|
|
|
|
*/ |
|
|
|
|
getOilStationPrice(oilStationId: number) { |
|
|
|
|
let belongType = 2; |
|
|
|
|
if (this.roleType === 5) { |
|
|
|
|
belongType = 1; |
|
|
|
|
} |
|
|
|
|
this.tyAgentPriceService.getOilStationPrice(belongType, oilStationId, data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.discountConfigData = data['return_data']; |
|
|
|
|
} else { |
|
|
|
|
this.modal.warning({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: data['return_msg'], |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export class PetrolStationManage { |
|
|
|
|
belongType: number; |
|
|
|
|
oilStationId: number; |
|
|
|
|
lowPrice: number; |
|
|
|
|
oilNo: string; |
|
|
|
|
oilNoName: string; |
|
|
|
|
priceRate: number; |
|
|
|
|
status: number; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|