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.
905 lines
25 KiB
905 lines
25 KiB
import { Component, OnInit } from '@angular/core';
|
|
import {FormBuilder, FormGroup} from '@angular/forms';
|
|
import {NzMessageService, NzModalService} from 'ng-zorro-antd';
|
|
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 {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace';
|
|
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',
|
|
templateUrl: './petrol-station-manage.component.html',
|
|
styleUrls: ['./petrol-station-manage.component.scss']
|
|
})
|
|
export class PetrolStationManageComponent implements OnInit {
|
|
roleType;
|
|
adminFlag;
|
|
loadingObject = {
|
|
spinning: false,
|
|
msg: '加载中'
|
|
};
|
|
|
|
dataObject: any = {};
|
|
tableLoading = true;
|
|
searchForm: FormGroup;
|
|
pageNum: number;
|
|
pageSize = 10;
|
|
whereObject: any = {};
|
|
|
|
allChecked = false;
|
|
checkedData = [];
|
|
|
|
orgArray = [];
|
|
agentArray = [];
|
|
salesmanArray = [];
|
|
|
|
assignOrgModal = false;
|
|
assignOrgForm: FormGroup;
|
|
|
|
assignAgentModal = false;
|
|
assignAgentForm: FormGroup;
|
|
|
|
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,
|
|
private tyAgentOilStationService: TyAgentOilStationService,
|
|
private store: LocalStorageService,
|
|
private form: FormBuilder) {
|
|
this.roleType = Number(this.store.get(ADMIN_INFO_OBJECT)['secRole'].roleType);
|
|
this.adminFlag = Number(this.store.get(ADMIN_INFO_OBJECT)['secUser'].adminFlag);
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
this.searchForm = this.form.group({
|
|
regionName: [null],
|
|
storeName: [null],
|
|
isAssignOrgId: [null],
|
|
organizationName: [null],
|
|
isAssignTyAgent: [null],
|
|
tyAgentName: [null],
|
|
isAssignTySalesman: [null],
|
|
tySalesmanName: [null],
|
|
});
|
|
this.assignOrgForm = this.form.group({
|
|
orgId: [null, [Validators.required]],
|
|
});
|
|
this.assignAgentForm = this.form.group({
|
|
agentId: [null, [Validators.required]],
|
|
});
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* 请求数据
|
|
*/
|
|
requestData(pageNum) {
|
|
this.tableLoading = true;
|
|
this.whereObject['pageNum'] = pageNum;
|
|
this.whereObject['pageSize'] = this.pageSize;
|
|
this.tyAgentOilStationService.getOilStationList(this.whereObject, data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.dataObject = data['return_data'];
|
|
|
|
let checkoutNum = 0;
|
|
for (const dataObject of this.dataObject['list']) {
|
|
if (this.checkedData.find(o => Number(o['storeId']) === Number(dataObject['storeId'])) != null) {
|
|
checkoutNum++;
|
|
dataObject['checked'] = true;
|
|
}
|
|
}
|
|
|
|
if (Number(checkoutNum) === this.dataObject['list'].length) {
|
|
this.allChecked = true;
|
|
} else {
|
|
this.allChecked = false;
|
|
}
|
|
} else {
|
|
this.modal.error(data['return_msg']);
|
|
}
|
|
this.tableLoading = false;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 搜索
|
|
* @param whereObject 条件
|
|
*/
|
|
search(whereObject: object) {
|
|
this.whereObject = whereObject;
|
|
this.requestData(1);
|
|
}
|
|
|
|
/**
|
|
* 重置
|
|
*/
|
|
resetForm(): void {
|
|
this.searchForm.reset();
|
|
}
|
|
|
|
/**
|
|
* 弹出分配代理公司模态框
|
|
*/
|
|
showAssignOrgModal() {
|
|
if (this.orgArray.length === 0) {
|
|
this.organizationService.getOrganizationList(this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['id'] , data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.orgArray = data['return_data'];
|
|
}
|
|
});
|
|
}
|
|
this.assignOrgModal = true;
|
|
}
|
|
|
|
/**
|
|
* 关闭分配代理公司模态框
|
|
*/
|
|
closeAssignOrgModal() {
|
|
this.assignOrgModal = false;
|
|
}
|
|
|
|
/**
|
|
* 提交分配代理公司
|
|
*/
|
|
submitAssignOrg() {
|
|
this.loadingObject.spinning = true;
|
|
this.loadingObject.msg = '加油站分配中...';
|
|
this.closeAssignOrgModal();
|
|
|
|
for (const i in this.assignOrgForm.controls) {
|
|
this.assignOrgForm.controls[i].markAsDirty();
|
|
this.assignOrgForm.controls[i].updateValueAndValidity();
|
|
}
|
|
if (this.assignOrgForm.status == null || this.assignOrgForm.status !== 'VALID') {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请选择代理公司',
|
|
});
|
|
return;
|
|
}
|
|
if (this.checkedData.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请选择需要分配的油站',
|
|
});
|
|
return;
|
|
}
|
|
const storeList = [];
|
|
for (const data of this.checkedData) {
|
|
storeList.push({ storeId: data['storeId'] });
|
|
}
|
|
this.assignOrgForm.value['storeList'] = storeList;
|
|
this.tyAgentOilStationService.assignOrg(this.assignOrgForm.value, data => {
|
|
this.loadingObject.spinning = false;
|
|
if (data['return_code'] === '000000') {
|
|
this.modal.success({
|
|
nzTitle: '提示',
|
|
nzContent: '分配成功',
|
|
});
|
|
this.checkedData = [];
|
|
this.requestData(this.whereObject['pageNum']);
|
|
this.closeAssignOrgModal();
|
|
} else {
|
|
this.modal.error({
|
|
nzTitle: '提示',
|
|
nzContent: data['return_msg'],
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 弹出解绑代理商公司对话框
|
|
*/
|
|
showUnbindOrgConfirm(): void {
|
|
if (this.checkedData.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请选择需要解绑的油站',
|
|
});
|
|
return;
|
|
}
|
|
this.modal.confirm({
|
|
nzTitle: '警告',
|
|
nzContent: '确定解绑油站吗',
|
|
nzOkText: '是',
|
|
nzCancelText: '否',
|
|
nzOkType: 'danger',
|
|
nzOnOk: () => this.unbindOrg()
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 解绑代理商公司
|
|
*
|
|
*/
|
|
unbindOrg() {
|
|
this.loadingObject.spinning = true;
|
|
this.loadingObject.msg = '加油站解绑中...';
|
|
const oilStationArray = [];
|
|
for (const data of this.checkedData) {
|
|
if ( data['tyAgentOilStationId'] != null) {
|
|
oilStationArray.push({ oilStationId: data['tyAgentOilStationId'] });
|
|
}
|
|
}
|
|
if (oilStationArray.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '没有需要解绑加油站'
|
|
});
|
|
this.loadingObject.spinning = false;
|
|
return;
|
|
}
|
|
|
|
this.tyAgentOilStationService.unbindOrg({ oilStationList: oilStationArray}, data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.loadingObject.spinning = false;
|
|
this.checkedData = [];
|
|
this.modal.success({
|
|
nzTitle: '提示',
|
|
nzContent: '解绑成功!'
|
|
});
|
|
this.requestData(this.whereObject['pageNum']);
|
|
} else {
|
|
this.loadingObject.spinning = false;
|
|
this.modal.error({
|
|
nzTitle: '提示',
|
|
nzContent: data['return_msg']
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 弹出分配代理商模态框
|
|
*/
|
|
showAssignAgentModal() {
|
|
if (this.agentArray.length === 0) {
|
|
const param = {
|
|
orgId: this.store.get(ADMIN_INFO_OBJECT)['bsOrganization']['id'],
|
|
pageNum: 1,
|
|
pageSize: 99999,
|
|
};
|
|
this.tyAgentService.getAgentList(param , data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.agentArray = data['return_data']['list'];
|
|
}
|
|
});
|
|
}
|
|
this.assignAgentModal = true;
|
|
}
|
|
|
|
/**
|
|
* 关闭分配代理商模态框
|
|
*/
|
|
closeAssignAgentModal() {
|
|
this.assignAgentModal = false;
|
|
}
|
|
|
|
/**
|
|
* 提交分配代理公司
|
|
*/
|
|
submitAssignAgent() {
|
|
this.loadingObject.spinning = true;
|
|
this.loadingObject.msg = '加油站分配中...';
|
|
for (const i in this.assignAgentForm.controls) {
|
|
this.assignAgentForm.controls[i].markAsDirty();
|
|
this.assignAgentForm.controls[i].updateValueAndValidity();
|
|
}
|
|
if (this.assignAgentForm.status == null || this.assignAgentForm.status !== 'VALID') {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请选择代理商',
|
|
});
|
|
return;
|
|
}
|
|
if (this.checkedData.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请选择需要分配的油站',
|
|
});
|
|
return;
|
|
}
|
|
|
|
const storeList = [];
|
|
for (const data of this.checkedData) {
|
|
storeList.push({ oilStationId: data['tyAgentOilStationId'] });
|
|
}
|
|
this.assignAgentForm.value['oilStationList'] = storeList;
|
|
this.tyAgentOilStationService.assignAgent(this.assignAgentForm.value, data => {
|
|
this.loadingObject.spinning = false;
|
|
if (data['return_code'] === '000000') {
|
|
this.modal.success({
|
|
nzTitle: '提示',
|
|
nzContent: '分配成功',
|
|
});
|
|
this.checkedData = [];
|
|
this.requestData(this.whereObject['pageNum']);
|
|
this.closeAssignAgentModal();
|
|
} else {
|
|
this.modal.error({
|
|
nzTitle: '提示',
|
|
nzContent: data['return_msg'],
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 弹出解绑代理商对话框
|
|
*/
|
|
showUnbindAgentConfirm(): void {
|
|
if (this.checkedData.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请选择需要解绑的油站',
|
|
});
|
|
return;
|
|
}
|
|
this.modal.confirm({
|
|
nzTitle: '警告',
|
|
nzContent: '确定解绑油站吗',
|
|
nzOkText: '是',
|
|
nzCancelText: '否',
|
|
nzOkType: 'danger',
|
|
nzOnOk: () => this.unbindAgent()
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 解绑代理商
|
|
*
|
|
*/
|
|
unbindAgent() {
|
|
this.loadingObject.spinning = true;
|
|
this.loadingObject.msg = '加油站解绑中...';
|
|
const oilStationArray = [];
|
|
for (const data of this.checkedData) {
|
|
if ( data['tyAgentOilStationId'] != null) {
|
|
oilStationArray.push({ oilStationId: data['tyAgentOilStationId'] });
|
|
}
|
|
}
|
|
if (oilStationArray.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '没有需要解绑加油站'
|
|
});
|
|
this.loadingObject.spinning = false;
|
|
return;
|
|
}
|
|
|
|
this.tyAgentOilStationService.unbindAgent({ oilStationList: oilStationArray}, data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.loadingObject.spinning = false;
|
|
this.checkedData = [];
|
|
this.modal.success({
|
|
nzTitle: '提示',
|
|
nzContent: '解绑成功!'
|
|
});
|
|
this.requestData(this.whereObject['pageNum']);
|
|
} else {
|
|
this.loadingObject.spinning = false;
|
|
this.modal.error({
|
|
nzTitle: '提示',
|
|
nzContent: data['return_msg']
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 弹出分配业务员模态框
|
|
*/
|
|
showAssignSalesmanModal() {
|
|
if (this.salesmanArray.length === 0) {
|
|
const param = {
|
|
tyAgentId: this.store.get(ADMIN_INFO_OBJECT)['highTyAgent']['id'],
|
|
pageNum: 1,
|
|
pageSize: 99999,
|
|
};
|
|
this.tySalesmanService.getSalesmanList(param , data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.salesmanArray = data['return_data']['list'];
|
|
}
|
|
});
|
|
}
|
|
this.assignSalesmanModal = true;
|
|
}
|
|
|
|
/**
|
|
* 关闭分配业务员模态框
|
|
*/
|
|
closeAssignSalesmanModal() {
|
|
this.assignSalesmanModal = false;
|
|
}
|
|
|
|
/**
|
|
* 提交分配业务员
|
|
*/
|
|
submitAssignSalesman() {
|
|
this.loadingObject.spinning = true;
|
|
this.loadingObject.msg = '加油站分配中...';
|
|
this.assignSalesmanModal = false;
|
|
for (const i in this.assignSalesmanForm.controls) {
|
|
this.assignSalesmanForm.controls[i].markAsDirty();
|
|
this.assignSalesmanForm.controls[i].updateValueAndValidity();
|
|
}
|
|
if (this.assignSalesmanForm.status == null || this.assignSalesmanForm.status !== 'VALID') {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请选择代理商',
|
|
});
|
|
this.loadingObject.spinning = false;
|
|
return;
|
|
}
|
|
if (this.checkedData.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请选择需要分配的油站',
|
|
});
|
|
this.loadingObject.spinning = false;
|
|
return;
|
|
}
|
|
|
|
const oilStationList = [];
|
|
for (const data of this.checkedData) {
|
|
oilStationList.push({ oilStationId: data['tyAgentOilStationId'] });
|
|
}
|
|
this.assignSalesmanForm.value['oilStationList'] = oilStationList;
|
|
this.tyAgentOilStationService.assignSalesman(this.assignSalesmanForm.value, data => {
|
|
this.loadingObject.spinning = false;
|
|
if (data['return_code'] === '000000') {
|
|
this.modal.success({
|
|
nzTitle: '提示',
|
|
nzContent: '分配成功',
|
|
});
|
|
this.checkedData = [];
|
|
this.requestData(this.whereObject['pageNum']);
|
|
this.closeAssignSalesmanModal();
|
|
} else {
|
|
this.modal.error({
|
|
nzTitle: '提示',
|
|
nzContent: data['return_msg'],
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 弹出解绑代理商对话框
|
|
*/
|
|
showUnbindSalesmanConfirm(): void {
|
|
if (this.checkedData.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '请选择需要解绑的油站',
|
|
});
|
|
return;
|
|
}
|
|
this.modal.confirm({
|
|
nzTitle: '警告',
|
|
nzContent: '确定解绑油站吗',
|
|
nzOkText: '是',
|
|
nzCancelText: '否',
|
|
nzOkType: 'danger',
|
|
nzOnOk: () => this.unbindSalesman()
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 解绑代理商
|
|
*
|
|
*/
|
|
unbindSalesman() {
|
|
this.loadingObject.spinning = true;
|
|
this.loadingObject.msg = '加油站解绑中...';
|
|
const oilStationArray = [];
|
|
for (const data of this.checkedData) {
|
|
if ( data['tyAgentOilStationId'] != null) {
|
|
oilStationArray.push({ oilStationId: data['tyAgentOilStationId'] });
|
|
}
|
|
}
|
|
if (oilStationArray.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
nzContent: '没有需要解绑加油站'
|
|
});
|
|
this.loadingObject.spinning = false;
|
|
return;
|
|
}
|
|
|
|
this.tyAgentOilStationService.unbindSalesman({ oilStationList: oilStationArray}, data => {
|
|
if (data['return_code'] === '000000') {
|
|
this.loadingObject.spinning = false;
|
|
this.checkedData = [];
|
|
this.modal.success({
|
|
nzTitle: '提示',
|
|
nzContent: '解绑成功!'
|
|
});
|
|
this.requestData(this.whereObject['pageNum']);
|
|
} else {
|
|
this.loadingObject.spinning = false;
|
|
this.modal.error({
|
|
nzTitle: '提示',
|
|
nzContent: data['return_msg']
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 弹出优惠配置模态框
|
|
*/
|
|
showDiscountConfigModal(oilStationId: number) {
|
|
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.modal.success({
|
|
nzTitle: '提示',
|
|
nzContent: '处理成功',
|
|
});
|
|
this.checkedData = [];
|
|
this.requestData(this.whereObject['pageNum']);
|
|
this.closeBatchDiscountConfigModal();
|
|
} else {
|
|
this.modal.error({
|
|
nzTitle: '提示',
|
|
nzContent: data['return_msg'],
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 弹出批量优惠配置模态框
|
|
*/
|
|
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'],
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 提交分配业务员
|
|
*/
|
|
submitDiscountConfig() {
|
|
if (this.discountConfigData.length === 0) {
|
|
this.modal.warning({
|
|
nzTitle: '提示',
|
|
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({
|
|
nzTitle: '提示',
|
|
nzContent: '保存成功',
|
|
});
|
|
this.closeDiscountConfigModal();
|
|
} else {
|
|
this.loadingObject.spinning = false;
|
|
this.modal.error({
|
|
nzTitle: '提示',
|
|
nzContent: data['return_msg'],
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 弹出油品配置模态框
|
|
*/
|
|
showOilConfigModal(oilStationId: number) {
|
|
this.getOilStationPrice(oilStationId);
|
|
this.oilConfigModal = true;
|
|
}
|
|
|
|
/**
|
|
* 关闭油品配置模态框
|
|
*/
|
|
closeOilConfigModal() {
|
|
this.oilConfigModal = false;
|
|
}
|
|
|
|
/**
|
|
* 全选
|
|
* @param data
|
|
*/
|
|
onAllChecked(checked: boolean) {
|
|
if (checked === true) {
|
|
const filterArray = this.dataObject['list'].filter(({ disabled }) => !disabled);
|
|
for (const data of filterArray) {
|
|
if (this.checkedData.find(o => Number(o['storeId']) === Number(data['storeId'])) == null) {
|
|
data['checked'] = true;
|
|
this.checkedData.push(data);
|
|
}
|
|
}
|
|
} else {
|
|
const filterArray = this.dataObject['list'].filter(({ disabled }) => !disabled);
|
|
for (const data of filterArray) {
|
|
data['checked'] = false;
|
|
const findIndex = this.checkedData.findIndex(o => Number(o['storeId']) === Number(data['storeId']));
|
|
this.checkedData.splice(findIndex, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 选中
|
|
* @param data
|
|
* @param checked
|
|
*/
|
|
checkedChange(data: object, checked: boolean) {
|
|
if (checked === true) {
|
|
if (this.checkedData.find(o => Number(o['storeId']) === Number(data['storeId'])) == null) {
|
|
data['checked'] = true;
|
|
this.checkedData.push(data);
|
|
}
|
|
} else {
|
|
data['checked'] = true;
|
|
const findIndex = this.checkedData.findIndex(o => Number(o['storeId']) === Number(data['storeId']));
|
|
this.checkedData.splice(findIndex, 1);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 油品禁用提示
|
|
*/
|
|
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 }, 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 }, 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'],
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
pageSizeChange(pageSize: number) {
|
|
this.pageSize = pageSize;
|
|
this.requestData(1);
|
|
}
|
|
}
|
|
|
|
export class PetrolStationManage {
|
|
belongType: number;
|
|
oilStationId: number;
|
|
lowPrice: number;
|
|
oilNo: string;
|
|
oilNoName: string;
|
|
priceRate: number;
|
|
status: number;
|
|
}
|
|
|
|
|