@@ -198,16 +198,24 @@
< / div >
< div class = "isJoin" >
< van-radio-group v-model = "vehicleStatus" :class="{ 'disabled-tree': vehicleInfoDisabled }" :disabled="vehicleInfoDisabled" @change="isVehicleChange" class="joinWrap" >
< van -radio :name = "1" style = "margin-right: 26 px" >
启用
< van -radio :name = "1" style = "margin-right: 14 px" >
启1 用
< img
slot = "icon"
slot -scope = " props "
: src = "props.checked ? activeIcon : inactiveIcon"
>
< / van-radio >
< van-radio :name = "2" >
停用
< van-radio :name = "2" style = "margin-right: 14px" >
停1 用
< img
slot = "icon"
slot -scope = " props "
: src = "props.checked ? activeIcon : inactiveIcon"
>
< / van-radio >
< van-radio :name = "12" disabled >
否 - 服务商停用
< img
slot = "icon"
slot -scope = " props "
@@ -243,7 +251,7 @@
< / van-radio-group >
< / div >
< / div >
< div class = "item_content_btn" >
< div class = "item_content_btn" v-if = "[2,3].includes(this.liabilityInsuranceAudit)" >
< span @click ="goContinueInsurance" > 续保更新 < / span >
< / div >
< span style = "color: red" > 如有投保 , 选 “ 有 ” , 未投保选 “ 无 ” , 不必上传交强险或者商业险等其他保单 < / span >
@@ -261,6 +269,7 @@
:deletable = "!disabledShow"
max -count = " 1 "
:preview-size = "54"
@ click -preview = " clickPreview "
/ >
< / div >
< div class = "lineBot" > < / div >
@@ -338,7 +347,30 @@
< two-common-btn class = "btn" @cancelClick ="h5GoBack" @submitClick ="submitBtn" / >
< van-calendar v-model = "showDatePicker" :min-date="minDate"
:max-date = "maxDate" type = "range" @confirm ="onConfirm" / >
< / div >
< van-popup ref = "success" v-model = "approvalDialogShow" >
< div class = "pop_wrap" >
< div class = "pop_title" > 车辆提交审批 < / div >
< div class = "pop_content" >
< div class = "iptWrap" v-if = "vehicleInfoChange" >
< div > 车辆和服务备注 < / div >
< el-input placeholder = "请输入车辆和服务备注" type = "textarea" show -word -limit maxlength = "200"
v-model = "approvalForm.serviceRemark" > < / el -input >
< / div >
< div class = "iptWrap" v-if = "insuranceChange" >
< div > 保单备注 < / div >
< el-input placeholder = "请输入保单备注" type = "textarea" show -word -limit maxlength = "200"
v-model = "approvalForm.insuranceRemark" > < / el -input >
< / div >
< / div >
< div class = "tip_button_wrap" >
< div class = "continue close" @click ="closeApproval" > 取消 < / div >
< div class = "continue" : class = "{'loading': loading}" @click ="submitApprovalHandle" > 提交审批 < / div >
< / div >
< / div >
< / van -popup >
< / div >
< / template >
@@ -347,7 +379,8 @@
import { Dialog } from "vant" ;
import { formatDate1 } from "@/utils/common"
import { myMixins } from "@/utils/myMixins"
import { vehicleTypeList , saveVehicle , getInfoById , supplierServiceTree , uploadImage , ocrHandler , userOperationPermissions } from "@/api/mine"
import { vehicleTypeList , saveVehicle , getInfoById , supplierServiceTree , uploadImage , ocrHandler ,
userOperationPermissions , saveSupplierApproval } from "@/api/mine"
import TwoCommonBtn from "@/components/twoBtnCommon.vue"
import CellGroup from "@/components/cellGroup.vue" ;
export default {
@@ -378,6 +411,7 @@ export default {
typeList : [ ] , //车辆类型列表
selectedOption : [ ] , //车辆类型
id : '' , //车辆Id
supplierId : '' , //服务商Id
serviceIds : [ ] , //车辆服务种类,
supplierServiceList : [ ] ,
oldSupplierServiceList : [ ] ,
@@ -505,7 +539,25 @@ export default {
} , {
name : '其他' ,
value : 14
} ]
} ] ,
approvalForm : {
type : 2 ,
supplierId : '' ,
vehicleId : '' ,
serviceChange : null ,
serviceRemark : '' ,
insuranceChange : null ,
insuranceRemark : '' ,
vehicleOtherChange : null ,
vehicleOtherRemark : '' ,
} ,
originData : { } , //记录更改之前的数据
changedFields : [ ] , // 用于存储变更过的字段
approvalDialogShow : false ,
vehicleInfoChange : false ,
insuranceChange : false ,
loading : false ,
}
} ,
computed : {
@@ -553,13 +605,25 @@ export default {
this . setDefault ( ) ;
} ,
} ,
async mounted ( ) {
this . id = this . $route . params ? . id
this . approvalForm . supplierId = this . $route . params ? . supplierId
await this . getSupplierServiceTree ( ) ;
await this . getTypeList ( ) ;
if ( this . id ) {
await this . vehicleInfo ( )
} else {
this . originData = {
vehicleType : '' ,
vehicleStatus : '' ,
virtualVehicle : '' ,
serviceIds : [ ] ,
hasLiabilityInsurance : '' ,
insuranceCorp : '' ,
liabilityInsuranceStartTime : '' ,
liabilityInsuranceEndTime : '' ,
insurancePicturePhoto : ''
}
}
} ,
methods : {
@@ -592,6 +656,10 @@ export default {
const [ start , end ] = date ;
this . showDatePicker = false ;
this . dateVal = ` ${ this . formatDate ( start ) } - ${ this . formatDate ( end ) } ` ;
console . log ( 'this.dateVal' , this . dateVal )
let timeObj = this . formatDateTimeRange ( this . dateVal )
console . log ( 'timeObj' , timeObj )
} ,
formatDateTimeRange ( str ) {
const [ startStr , endStr ] = str . split ( ' - ' ) . map ( s => s . trim ( ) ) ;
@@ -673,6 +741,12 @@ export default {
this . vehicleFrontPhoto = res . data ;
await this . ocrCarFrontHandler ( )
} ,
clickPreview ( ) {
console . log ( ' this.insurancePicturePhoto' , this . insurancePicturePhoto )
if ( this . insurancePicturePhoto && this . insurancePicturePhoto . indexOf ( '.pdf' ) !== - 1 ) {
window . open ( this . insurancePicturePhoto . replace ( "http://" , "https://" ) )
}
} ,
async insurancePictureFilesHandler ( file ) {
const formData = new FormData ( ) ;
formData . append ( "file" , file . file ) ;
@@ -805,6 +879,7 @@ export default {
let result = res . data ;
console . log ( "result" , result )
this . id = result . vehicleId
this . approvalForm . vehicleId = this . id
this . carNum = result . plateNumber
this . isJoin = result . hasPolymerization . code
this . selectedOption = result . vehicleType ? . split ( ',' ) . map ( ( item ) => {
@@ -846,6 +921,17 @@ export default {
if ( result . liabilityInsuranceEndTime && result . liabilityInsuranceStartTime ) {
this . dateVal = formatDate1 ( result . liabilityInsuranceStartTime ) + ' - ' + formatDate1 ( result . liabilityInsuranceEndTime )
}
this . originData = {
vehicleType : result . vehicleType ,
vehicleStatus : result . vehicleStatus ,
virtualVehicle : result . virtualVehicle ,
serviceIds : result . serviceIds ,
hasLiabilityInsurance : result . hasLiabilityInsurance ,
insuranceCorp : result . insuranceCorp ,
liabilityInsuranceStartTime : result . liabilityInsuranceStartTime ,
liabilityInsuranceEndTime : result . liabilityInsuranceEndTime ,
insurancePicturePhoto : result . insurancePicturePhoto
}
} ,
isChange ( e ) {
this . hasLiabilityInsurance = e
@@ -863,6 +949,187 @@ export default {
isVehicleChange ( e ) {
this . vehicleStatus = e
} ,
async submitAuditHandle ( ) { //提交审核
let urls = [ ]
this . insurancePictureFiles ? . forEach ( item => urls . push ( item . url ) )
let time = this . dateVal ? this . formatDateTimeRange ( this . dateVal ) : ''
// let time1=time.endTime?.split(' ')
let newFormValue = {
vehicleStatus : this . vehicleStatus ,
virtualVehicle : this . virtualVehicle ,
serviceIds : this . $refs . tree . getCheckedKeys ( true ) || [ ] ,
vehicleType : this . selectedOption ? . join ( ',' ) || '' ,
hasLiabilityInsurance : this . hasLiabilityInsurance ,
insuranceCorp : this . insuranceCorp ,
insurancePicturePhoto : urls ? . join ( ',' ) ,
// liabilityInsuranceStartTime:time.startTime ? time.startTime : '',
liabilityInsuranceEndTime : time . endTime ? time . endTime : '' ,
}
console . log ( 'newFormValue' , newFormValue )
let oldFormValue = { ... this . originData , }
console . log ( 'oldFormValue' , oldFormValue )
this . compareObjects ( newFormValue , oldFormValue ) ;
if ( this . changedFields && this . changedFields . length > 0 ) {
const arr1Set = new Set ( this . changedFields ) ;
const change1 = [ 'vehicleStatus' , 'virtualVehicle' , 'vehicleType' , 'serviceIds' ]
const change2 = [ 'hasLiabilityInsurance' , 'insurancePicturePhoto' , 'insuranceCorp' , 'liabilityInsuranceStartTime' , 'liabilityInsuranceEndTime' ]
const serviceChangeItems = change1 . filter ( item => arr1Set . has ( item ) ) ;
console . log ( 'serviceChangeItems' , serviceChangeItems )
if ( serviceChangeItems ? . length > 0 ) {
this . vehicleInfoChange = true
this . approvalForm . serviceChange = { }
change1 . forEach ( key => {
this . approvalForm . serviceChange [ key ] = this [ key ] ;
if ( key == 'serviceIds' ) {
this . approvalForm . serviceChange [ key ] = this . $refs . tree . getCheckedKeys ( true )
}
if ( key == 'vehicleType' ) {
this . approvalForm . serviceChange [ key ] = this . selectedOption ? . join ( ',' ) || ''
}
} ) ;
} else {
this . vehicleInfoChange = false
this . approvalForm . serviceChange = null
}
const insuranceChangeItems = change2 . filter ( item => arr1Set . has ( item ) ) ;
console . log ( 'insuranceChangeItems' , insuranceChangeItems )
if ( insuranceChangeItems ? . length > 0 ) {
this . insuranceChange = true
this . approvalForm . insuranceChange = { }
change2 . forEach ( key => {
this . approvalForm . insuranceChange [ key ] = this [ key ] ;
let time = this . dateVal ? this . formatDateTimeRange ( this . dateVal ) : ''
if ( key == 'liabilityInsuranceStartTime' && time && time . startTime ) {
this . approvalForm . insuranceChange [ key ] = time . startTime
}
if ( key == 'liabilityInsuranceEndTime' && time && time . endTime ) {
// let time1=time.endTime?.split(' ')
this . approvalForm . insuranceChange [ key ] = time . endTime
}
if ( key == 'insurancePicturePhoto' && this . insurancePictureFiles ? . length > 0 ) {
let urls = [ ]
this . insurancePictureFiles ? . forEach ( item => urls . push ( item . url ) )
this . approvalForm . insuranceChange [ key ] = urls ? . join ( ',' )
}
} ) ;
} else {
this . insuranceChange = false
this . approvalForm . insuranceChange = null
}
}
if ( ( this . vehicleInfoChange || this . insuranceChange ) && this . id ) {
// this.approvalDialogShow=true
this . submitApprovalHandle ( )
console . log ( '11111' , this . approvalForm . serviceChange )
console . log ( '2222' , this . approvalForm . insuranceChange )
} else {
this . approvalDialogShow = false
await this . submitBtn ( ) ;
}
} ,
async submitApprovalHandle ( ) { //提交审批-走接口
if ( this . vehicleInfoChange ) {
if ( ! ( this . selectedOption . length > 0 ) ) {
this . $toast ( '车辆类别不能为空' )
return
}
let res = this . checkDisabledItems ( ) ;
if ( ! res ) {
return false
}
if ( ! this . virtualVehicle ) {
this . $toast ( '车辆属性不能为空' )
return
}
if ( ! this . vehicleStatus ) {
this . $toast ( '车辆状态不能为空' )
return
}
/* if(!this.approvalForm.serviceRemark){
this.$toast('车辆和服务备注不能为空')
return
}*/
}
if ( this . insuranceChange ) {
if ( this . hasLiabilityInsurance === null || this . hasLiabilityInsurance === undefined || this . hasLiabilityInsurance === '' ) { // 有职业责任险,就需要有保单照片
this . $toast ( '救援职业责任险不能为空' )
return
}
if ( ! this . insurancePicturePhoto && this . hasLiabilityInsurance == 1 ) { // 有职业责任险,就需要有保单照片
this . $toast ( '保单照片不能为空' )
return
}
if ( this . selectedOption ? . length == 1 && this . selectedOption . includes ( 1 ) ) { //选择小修车时需清除原本的拖车服务类型
let data = this . oldSupplierServiceList . filter ( item => item . name === '拖车服务' )
this . serviceIds = this . serviceIds . filter ( item => ! data [ 0 ] . children . some ( obj => obj . id === item ) ) ;
}
if ( ! this . insuranceCorp && this . hasLiabilityInsurance == 1 ) { // 有职业责任险,就需要有保单照片
this . $toast ( '承保保司不能为空' )
return
}
if ( ! this . dateVal && this . hasLiabilityInsurance == 1 ) { // 有职业责任险,就需要有保单照片
this . $toast ( '保单有效期不能为空' )
return
}
/* if(!this.approvalForm.insuranceRemark){
this.$toast('保单备注不能为空')
return
}*/
}
try {
this . loading = true ;
await saveSupplierApproval ( { ... this . approvalForm } )
} finally {
this . loading = false ;
}
this . $toast ( '提交审批成功' )
this . closeApproval ( )
setTimeout ( ( ) => {
this . $router . back ( ) ;
} , 2000 )
} ,
compareObjects ( newObj , oldObj ) {
this . changedFields = [ ]
for ( let key in newObj ) {
if ( Array . isArray ( newObj [ key ] ) ) {
if ( newObj [ key ] ? . length != oldObj [ key ] ? . length ) {
this . changedFields . push ( key ) ;
} else {
// console.log('newObj[key]',newObj[key])
if ( newObj [ key ] [ 0 ] ? . id ) {
let flag = newObj [ key ] . every ( ( item , index ) => item . id == oldObj [ key ] [ index ] ? . id ) ;
// console.log('flag',flag)
if ( ! flag ) {
this . changedFields . push ( key ) ;
}
} else {
let flag = newObj [ key ] . every ( ( value , index ) => value == oldObj [ key ] [ index ] ) ;
if ( ! flag ) {
this . changedFields . push ( key ) ;
}
}
}
} else {
let isEqual = (
( newObj [ key ] == null && oldObj [ key ] == 0 ) ||
( newObj [ key ] == 0 && oldObj [ key ] == null ) ||
( newObj [ key ] == oldObj [ key ] )
) ;
if ( ! isEqual ) {
this . changedFields . push ( key ) ;
}
}
}
} ,
closeApproval ( ) {
this . approvalForm . serviceRemark = ''
this . approvalForm . insuranceRemark = ''
this . approvalForm . vehicleOtherRemark = ''
this . approvalDialogShow = false
this . vehicleInfoChange = false
this . insuranceChange = false
} ,
async submitBtn ( ) {
if ( ! this . vehicleLicenseFront ) {
this . $toast ( '行驶证主页照片不能为空' )
@@ -929,6 +1196,8 @@ export default {
timeObj = this . formatDateTimeRange ( this . dateVal )
}
this . serviceIds = this . $refs . tree . getCheckedKeys ( true )
console . log ( '1122' , this . vehicleStatus )
// return
await saveVehicle ( {
vehicleId : this . id ? this . id : '' ,
plateNumber : this . carNum ? this . carNum : '' ,
@@ -948,6 +1217,8 @@ export default {
liabilityInsuranceStartTime : this . hasLiabilityInsurance == 1 ? ( timeObj ? . startTime || '' ) : '' ,
liabilityInsuranceEndTime : this . hasLiabilityInsurance == 1 ? ( timeObj ? . endTime || '' ) : '' ,
virtualVehicle : this . virtualVehicle ,
canSubmitApproval : true ,
vehicleStatus : this . vehicleStatus
} )
if ( this . id ) {
this . $toast ( '修改成功' )
@@ -1088,4 +1359,69 @@ export default {
pointer - events : none ;
opacity : 0.6 ;
}
. pop _wrap {
width : 340 px ;
box - sizing : border - box ;
padding : 10 px 15 px ;
position : relative ;
. pop _title {
font - size : 14 px ;
font - weight : 500 ;
}
. pop _content {
width : 304 px ;
font - size : 14 px ;
color : # 4 C5361 ;
margin - left : 6 px ;
line - height : 25 px ;
. iptWrap {
margin : 10 px 0 ;
}
}
. tip _button _wrap {
display : flex ;
justify - content : flex - end ;
. close {
border : 1 px solid # ccc ;
color : black ;
background - color : # FFFFFF ;
}
. continue {
padding : 6 px 10 px ;
border - radius : 4 px ;
}
div : last - child {
background - color : # 3266 be ;
color : # FFFFFF ;
margin - left : 8 px ;
margin - right : 4 px ;
}
}
}
. loading {
position : relative ;
}
. loading : : after {
content : '' ;
position : absolute ;
top : 50 % ;
left : 50 % ;
transform : translate ( - 50 % , - 50 % ) ;
width : 20 px ;
height : 20 px ;
border : 2 px solid # 000 ;
border - top - color : transparent ;
border - radius : 50 % ;
animation : spin 1 s linear infinite ;
}
@ keyframes spin {
0 % {
transform : translate ( - 50 % , - 50 % ) rotate ( 0 deg ) ;
}
100 % {
transform : translate ( - 50 % , - 50 % ) rotate ( 360 deg ) ;
}
}
< / style >