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.
360 lines
12 KiB
360 lines
12 KiB
import { HttpClient } from '@angular/common/http'; |
|
import { Component, OnInit } from '@angular/core'; |
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
import { ObjectsSimpleService } from 'src/app/service/objectsSimple.service'; |
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
|
import * as moment from 'moment'; |
|
import Viewer from 'viewerjs'; |
|
import { Router, ActivatedRoute } from '@angular/router' |
|
@Component({ |
|
selector: 'app-oil-station-info', |
|
templateUrl: './oil-station-info.component.html', |
|
styleUrls: ['./oil-station-info.component.scss'] |
|
}) |
|
export class OilStationInfoComponent implements OnInit { |
|
validateForm!: FormGroup; |
|
constructor(private router: Router, private fb: FormBuilder, private objectsSrv: ObjectsSimpleService, private http: HttpClient, private message: NzMessageService) { } |
|
|
|
|
|
userdata: any |
|
dateFormat = 'yyyy-MM-dd'; |
|
ngOnInit(): void { |
|
this.userdata = JSON.parse(sessionStorage.getItem('userdata')) |
|
this.validateForm = this.fb.group({ |
|
oilStation: this.fb.group({ |
|
organization: [this.userdata.organization.displayName], |
|
startBusinessTime: [null, [Validators.required]], |
|
oilStationType: [null], |
|
laneNumber: [null], |
|
address: [null], |
|
locationName: [null], |
|
companyName: [null], |
|
leaderName: [null], |
|
leaderContact: [null], |
|
stationLevel: [null], |
|
sellVariety: [null], |
|
gasStationCount: [null], |
|
tankVolume: [null], |
|
}), |
|
policeStation: this.fb.group({ |
|
name: [null], |
|
address: [null], |
|
distance: [null], |
|
contactInformation: [null] |
|
}), |
|
hospital: this.fb.group({ |
|
name: [null], |
|
address: [null], |
|
distance: [null], |
|
contactInformation: [null] |
|
}), |
|
fireBrigade: this.fb.group({ |
|
name: [null], |
|
address: [null], |
|
distance: [null], |
|
contactInformation: [null] |
|
}) |
|
}); |
|
|
|
this.getInfo() |
|
|
|
} |
|
|
|
|
|
|
|
//获取油站信息 |
|
// gallery |
|
getInfo() { |
|
this.http.get('/api/services/app/GasStation/Get', { |
|
params: { |
|
organizationUnitId: this.userdata.organization.id |
|
} |
|
}).subscribe((data: any) => { |
|
|
|
this.httpBody = data.result |
|
if (!this.httpBody.govUnitDetail) { |
|
this.httpBody.govUnitDetail = { |
|
policeStation: {}, |
|
hospital: {}, |
|
fireBrigade: {} |
|
} |
|
} else { |
|
this.httpBody.govUnitDetail = JSON.parse(data.result.govUnitDetail) |
|
this.policeStation = data.result.govUnitDetail.policeStation |
|
this.hospital = data.result.govUnitDetail.hospital |
|
this.fireBrigade = data.result.govUnitDetail.fireBrigade |
|
} |
|
// if (this.httpBody.licenses.length == 0) { |
|
// this.httpBody.licenses = [ |
|
// { name: '营业执照', code: '', isPerpetual: false, startTime: '', endTime: '', firstWarnTime: '', secondWarnTime: '', imageUrl: '', annualInspectionTime: '', annualInspectionWarnTime: '', annualInspectionOrganizationName: '', type: 1, hasAnnualInspection: true }, |
|
// { name: '危险化学品', code: '', isPerpetual: false, startTime: '', endTime: '', firstWarnTime: '', secondWarnTime: '', imageUrl: '', annualInspectionTime: '', annualInspectionWarnTime: '', annualInspectionOrganizationName: '', type: 3, hasAnnualInspection: false }, |
|
// { name: '成品油零售', code: '', isPerpetual: false, startTime: '', endTime: '', firstWarnTime: '', secondWarnTime: '', imageUrl: '', annualInspectionTime: '', annualInspectionWarnTime: '', annualInspectionOrganizationName: '', type: 2, hasAnnualInspection: true } |
|
// ] |
|
// } else { |
|
// console.log('走这里了',this.httpBody.licenses) |
|
// this.httpBody.licenses.forEach(item => { |
|
// if (item.endTime == '9999-01-01T00:00:00') { |
|
// item.isPerpetual = true |
|
// } else { |
|
// item.isPerpetual = false |
|
// } |
|
// }) |
|
// } |
|
// this.httpBody.stationType ? this.httpBody.stationType = String(this.httpBody.stationType) : null |
|
|
|
console.log('油站信息', this.httpBody) |
|
// setTimeout(() => { |
|
// this.gallery = new Viewer(document.getElementById('images'), { |
|
// show: () => { // 动态加载图片后,更新实例 |
|
// this.gallery.update(); |
|
// }, |
|
// }); |
|
// }, 0); |
|
|
|
}, err => { |
|
console.log('油站错误信息', err.error.error.message) |
|
}) |
|
} |
|
|
|
exportExcel() { |
|
const httpOptions = { |
|
responseType: 'blob' as 'json' |
|
}; |
|
this.http.get(`/api/services/app/GasStation/ExportExcelFile?gasStationId=${this.httpBody.id}`, httpOptions).subscribe((data: any) => { |
|
// console.log('导出成功') |
|
// 文件名中有中文 则对文件名进行转码 |
|
const link = document.createElement('a'); |
|
const blob = new Blob([data], { type: 'application/vnd.ms-excel' }); |
|
link.setAttribute('href', window.URL.createObjectURL(blob)); |
|
link.setAttribute('download', this.httpBody.stationName + '基本信息' + '.xls'); |
|
link.style.visibility = 'hidden'; |
|
document.body.appendChild(link); |
|
link.click(); |
|
document.body.removeChild(link); |
|
this.message.create('success', '导出成功!'); |
|
}, err => { |
|
this.message.create('error', '导出失败!'); |
|
}) |
|
} |
|
|
|
policeStation = { |
|
name: '', |
|
address: '', |
|
distance: '', |
|
contactInformation: '' |
|
} |
|
hospital = { |
|
name: '', |
|
address: '', |
|
distance: '', |
|
contactInformation: '' |
|
} |
|
fireBrigade = { |
|
name: '', |
|
address: '', |
|
distance: '', |
|
contactInformation: '' |
|
} |
|
httpBody = { |
|
id: null, |
|
stationName: JSON.parse(sessionStorage.getItem('userdata')).organization.displayName, |
|
organizationUnitId: JSON.parse(sessionStorage.getItem('userdata')).organization.id, |
|
auditStatus: null, |
|
openTime: '', |
|
stationType: '', |
|
laneCount: '', |
|
address: '', |
|
locationName: '', |
|
companyName: '', |
|
leaderName: '', |
|
leaderContact: '', |
|
stationLevel: '', |
|
sellVariety: '', |
|
gasStationCount: '', |
|
tankVolume: '', |
|
govUnitDetail: { |
|
policeStation: {}, |
|
hospital: {}, |
|
fireBrigade: {} |
|
}, |
|
businessLicenseImage: '', |
|
dangerousChemicalLicenseImage: '', |
|
gasSellLicenseImage: '', |
|
licenses: [ |
|
] |
|
} |
|
|
|
perpetualChange(item, $event) { |
|
if ($event) { |
|
item.endTime = '9999-01-01' |
|
} |
|
} |
|
|
|
|
|
// addName = '' |
|
// isVisible = false; |
|
// showModal(): void { |
|
// this.addName = '' |
|
// this.isVisible = true; |
|
// } |
|
|
|
// handleOk(): void { |
|
// this.isVisible = false; |
|
// if (this.addName) { |
|
// this.addTr() |
|
// } |
|
// } |
|
|
|
// handleCancel(): void { |
|
// console.log('Button cancel clicked!'); |
|
// this.isVisible = false; |
|
// } |
|
// addTr() { |
|
// this.httpBody.licenses.push( |
|
// { name: this.addName, code: '', isPerpetual: false, startTime: '', endTime: '', firstWarnTime: '', secondWarnTime: '', imageUrl: '', annualInspectionTime: '', annualInspectionWarnTime: '', annualInspectionOrganizationName: '', type: -1, hasAnnualInspection: false }, |
|
// ) |
|
// } |
|
// deleteTrConfirm(key) { |
|
// console.log(key) |
|
// this.httpBody.licenses.splice(key, 1); |
|
// } |
|
goback() { |
|
this.router.navigate(['/todaywarning/petrolStation']) |
|
} |
|
|
|
isLoadingSave: boolean = false |
|
submitForm() { |
|
// let valid = true |
|
// console.log(this.httpBody.licenses) |
|
// this.httpBody.licenses.forEach(element => { |
|
// if (!element.startTime || !element.endTime || !element.firstWarnTime || !element.secondWarnTime || !element.code) { |
|
// valid = false |
|
// console.log('普通拦截') |
|
// return |
|
// } |
|
// if (element.hasAnnualInspection) { |
|
// if (!element.annualInspectionWarnTime || !element.annualInspectionOrganizationName || !element.annualInspectionTime) { |
|
// valid = false |
|
// console.log('年检拦截') |
|
// return |
|
// } |
|
// } |
|
// }); |
|
// if (!valid) { |
|
// this.message.create('error', '请将证照信息填写完整!'); |
|
// return |
|
// } |
|
if (this.validateForm.valid) { |
|
this.isLoadingSave = true |
|
this.httpBody.openTime = moment(this.httpBody.openTime).format('YYYY-MM-MM')//开业时间格式化 |
|
this.httpBody.govUnitDetail.policeStation = this.validateForm.value.policeStation |
|
this.httpBody.govUnitDetail.hospital = this.validateForm.value.hospital |
|
this.httpBody.govUnitDetail.fireBrigade = this.validateForm.value.fireBrigade |
|
|
|
let body = JSON.parse(JSON.stringify(this.httpBody)) |
|
body.stationType |
|
body.govUnitDetail = JSON.stringify(this.httpBody.govUnitDetail) |
|
console.log(body) |
|
|
|
body.licenses.forEach(item => { |
|
delete item.isPerpetual |
|
}) |
|
|
|
this.http.put('/api/services/app/GasStation/Update', body).subscribe((data: any) => { |
|
this.isLoadingSave = false |
|
this.message.create('success', '保存成功!'); |
|
}, err => { |
|
this.isLoadingSave = false |
|
this.message.create('error', '保存失败!'); |
|
}) |
|
} else { |
|
this.message.create('warning', '请填写完整!'); |
|
return false |
|
} |
|
|
|
} |
|
|
|
// uploadIndex: string |
|
// filechange(e, index) { |
|
// let file = e.target.files[0] || null //获取上传的文件 |
|
// this.uploadIndex = index |
|
// this.openFileSelect(file, `stationPhotos/${this.userdata.organization.id}/`) |
|
// } |
|
// //设置文件路径并上传 |
|
// postFilePath |
|
// async openFileSelect(file: File, extensionPath: string) { |
|
// this.postFilePath = extensionPath; |
|
// let fileSize = file.size || null //上传文件的总大小 |
|
// let shardSize = 5 * 1024 * 1024 //5MB 超过5MB要分块上传 |
|
// if (fileSize >= shardSize) // 超过5MB要分块上传 |
|
// { |
|
// await this.postFileByMul(file); |
|
// setTimeout(() => { |
|
// this.gallery.destroy() |
|
// this.gallery = new Viewer(document.getElementById('images')); |
|
// }, 0); |
|
// } |
|
// else //普通上传 |
|
// { |
|
// await this.postFile(file); |
|
// setTimeout(() => { |
|
// this.gallery.destroy() |
|
// this.gallery = new Viewer(document.getElementById('images')); |
|
// }, 0); |
|
// } |
|
// } |
|
// //上传文件 |
|
// async postFile(file: File) { |
|
// await new Promise((resolve, reject) => { |
|
// this.objectsSrv.postFile(this.postFilePath, file).subscribe(data => { |
|
// let dataObj = data as any; |
|
// let filePath: string = ObjectsSimpleService.baseUrl + dataObj.objectName; |
|
// this.httpBody.licenses[this.uploadIndex].imageUrl = filePath |
|
// resolve('success') |
|
// }); |
|
// }) |
|
// } |
|
|
|
// /** |
|
// * 分块上传 |
|
// * @param file |
|
// */ |
|
// postFileByMul(file: File) { |
|
// this.objectsSrv.postFile_MultipartUpload(this.postFilePath, file).then((value) => { |
|
// let dataObj = value as any; |
|
// this.httpBody.licenses[this.uploadIndex].imageUrl = dataObj.filePath |
|
// }); |
|
|
|
// } |
|
|
|
|
|
isSubmitAuditLoading: boolean = false |
|
submitAudit() { |
|
let params = { |
|
id: this.httpBody.id |
|
} |
|
this.http.post('/api/services/app/GasStation/Commit', null, { params: params }).subscribe((data: any) => { |
|
this.isSubmitAuditLoading = false |
|
this.getInfo() |
|
this.message.create('success', '提交审核成功!'); |
|
}, err => { |
|
this.isSubmitAuditLoading = false |
|
this.message.create('error', '提交审核失败!'); |
|
}) |
|
} |
|
|
|
isRevocationAuditLoading: boolean = false |
|
revocationAudit() { |
|
let params = { |
|
id: this.httpBody.id |
|
} |
|
this.http.post('/api/services/app/GasStation/Uncommit', null, { params: params }).subscribe((data: any) => { |
|
this.isRevocationAuditLoading = false |
|
this.getInfo() |
|
this.message.create('success', '撤销审核成功!'); |
|
}, err => { |
|
this.isRevocationAuditLoading = false |
|
this.message.create('error', '撤销审核失败!'); |
|
}) |
|
} |
|
}
|
|
|