-
- {{item.oilNoName}}
-
+
{{item.oilNoName}}
保存
+
+
+
+
+ {{item.oilNoName}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.ts b/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.ts
index 2f80e6e..c4186a5 100644
--- a/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.ts
+++ b/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.ts
@@ -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;
}
diff --git a/src/app/services/gas.service.ts b/src/app/services/gas.service.ts
new file mode 100644
index 0000000..6dc73e5
--- /dev/null
+++ b/src/app/services/gas.service.ts
@@ -0,0 +1,39 @@
+import { Injectable } from '@angular/core';
+import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http';
+import {CommonsService} from './commons.service';
+import {environment} from "../../environments/environment";
+
+@Injectable({
+ providedIn: 'root'
+})
+export class GasService {
+
+ constructor(
+ private http: HttpClient,
+ private common: CommonsService
+ ) { }
+
+ /**
+ * 禁用油品
+ *
+ * @param param 参数对象
+ * @param callBack 回调
+ */
+ public disabledOil(param: object, callBack) {
+ this.http.post(environment.baseUrl + 'highGas/disabledOil', param).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ /**
+ * 启用油品
+ *
+ * @param param 参数对象
+ * @param callBack 回调
+ */
+ public enableOil(param: object, callBack) {
+ this.http.post(environment.baseUrl + 'highGas/enableOil', param).subscribe(data => {
+ callBack(data);
+ });
+ }
+}
diff --git a/src/app/services/ty-agent-price.service.ts b/src/app/services/ty-agent-price.service.ts
index 2b10df0..b358bae 100644
--- a/src/app/services/ty-agent-price.service.ts
+++ b/src/app/services/ty-agent-price.service.ts
@@ -24,14 +24,37 @@ export class TyAgentPriceService {
});
}
+ /**
+ * 批量配置价格
+ * @param paramObject 参数
+ * @param callBack
+ */
+ batchConfigPrice(paramObject: object, callBack) {
+ this.http.post(environment.baseUrl + 'tyAgentPrice/batchConfigPrice', paramObject).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ /**
+ * 批量配置油品
+ * @param paramObject 参数
+ * @param callBack
+ */
+ batchConfigOilNo(paramObject: object, callBack) {
+ this.http.post(environment.baseUrl + 'tyAgentPrice/batchConfigOilNo', paramObject).subscribe(data => {
+ callBack(data);
+ });
+ }
+
/**
* 油站价格
* @param paramObject 参数
* @param callBack
*/
- getOilStationPrice(oilStationId: number, callBack) {
- this.http.get(environment.baseUrl + 'tyAgentPrice/getOilStationPrice?oilStationId=' + oilStationId).subscribe(data => {
+ getOilStationPrice(belongType: number, oilStationId: number, callBack) {
+ this.http.get(environment.baseUrl + 'tyAgentPrice/getOilStationPrice?belongType=' + belongType + '&oilStationId=' + oilStationId).subscribe(data => {
callBack(data);
});
}
+
}