|
|
|
@ -1,4 +1,13 @@ |
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
|
import {FormBuilder, FormGroup} from '_@angular_forms@9.0.7@@angular/forms'; |
|
|
|
|
import {NzMessageService, NzModalService} from '_ng-zorro-antd@9.3.0@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"; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-petrol-station-manage', |
|
|
|
@ -6,10 +15,569 @@ import { Component, OnInit } from '@angular/core'; |
|
|
|
|
styleUrls: ['./petrol-station-manage.component.scss'] |
|
|
|
|
}) |
|
|
|
|
export class PetrolStationManageComponent implements OnInit { |
|
|
|
|
roleType; |
|
|
|
|
adminFlag; |
|
|
|
|
loadingObject = { |
|
|
|
|
spinning: false, |
|
|
|
|
msg: '加载中' |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
constructor() { } |
|
|
|
|
dataObject: any = {}; |
|
|
|
|
tableLoading = true; |
|
|
|
|
searchForm: FormGroup; |
|
|
|
|
pageNum: number; |
|
|
|
|
whereObject: any = {}; |
|
|
|
|
|
|
|
|
|
allChecked = false; |
|
|
|
|
checkedData = []; |
|
|
|
|
|
|
|
|
|
orgArray = []; |
|
|
|
|
agentArray = []; |
|
|
|
|
salesmanArray = []; |
|
|
|
|
|
|
|
|
|
assignOrgModal = false; |
|
|
|
|
assignOrgForm: FormGroup; |
|
|
|
|
|
|
|
|
|
assignAgentModal = false; |
|
|
|
|
assignAgentForm: FormGroup; |
|
|
|
|
|
|
|
|
|
assignSalesmanModal = false; |
|
|
|
|
assignSalesmanForm: FormGroup; |
|
|
|
|
|
|
|
|
|
constructor(private modal: NzModalService, |
|
|
|
|
private message: NzMessageService, |
|
|
|
|
private tyAgentService: TyAgentService, |
|
|
|
|
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.requestData(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 请求数据 |
|
|
|
|
*/ |
|
|
|
|
requestData(pageNum) { |
|
|
|
|
this.tableLoading = true; |
|
|
|
|
this.whereObject['pageNum'] = pageNum; |
|
|
|
|
this.whereObject['pageSize'] = 10; |
|
|
|
|
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 => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.modal.success({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: '分配成功', |
|
|
|
|
}); |
|
|
|
|
this.checkedData = []; |
|
|
|
|
this.loadingObject.spinning = false; |
|
|
|
|
this.requestData(this.whereObject['pageNum']); |
|
|
|
|
this.closeAssignOrgModal(); |
|
|
|
|
} else { |
|
|
|
|
this.loadingObject.spinning = false; |
|
|
|
|
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 => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.modal.success({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: '分配成功', |
|
|
|
|
}); |
|
|
|
|
this.checkedData = []; |
|
|
|
|
this.loadingObject.spinning = false; |
|
|
|
|
this.requestData(this.whereObject['pageNum']); |
|
|
|
|
this.closeAssignAgentModal(); |
|
|
|
|
} else { |
|
|
|
|
this.loadingObject.spinning = false; |
|
|
|
|
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 => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.modal.success({ |
|
|
|
|
nzTitle: '提示', |
|
|
|
|
nzContent: '分配成功', |
|
|
|
|
}); |
|
|
|
|
this.checkedData = []; |
|
|
|
|
this.loadingObject.spinning = false; |
|
|
|
|
this.requestData(this.whereObject['pageNum']); |
|
|
|
|
this.closeAssignSalesmanModal(); |
|
|
|
|
} else { |
|
|
|
|
this.loadingObject.spinning = false; |
|
|
|
|
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'] |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 全选 |
|
|
|
|
* @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['id']) === Number(data['id'])) == 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['id']) === Number(data['id'])); |
|
|
|
|
this.checkedData.splice(findIndex, 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 选中 |
|
|
|
|
* @param data |
|
|
|
|
* @param checked |
|
|
|
|
*/ |
|
|
|
|
checkedChange(data: object, checked: boolean) { |
|
|
|
|
if (checked === true) { |
|
|
|
|
if (this.checkedData.find(o => Number(o['id']) === Number(data['id'])) == null) { |
|
|
|
|
data['checked'] = true; |
|
|
|
|
this.checkedData.push(data); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
data['checked'] = true; |
|
|
|
|
const findIndex = this.checkedData.findIndex(o => Number(o['id']) === Number(data['id'])); |
|
|
|
|
this.checkedData.splice(findIndex, 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|