Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7f63f4de
authored
Jul 06, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增车辆到期信息样式处理及单元测试
1 parent
0f9b04c4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
1 deletions
src/views/usedCarManagement/evaluationManagement/components/vehicleInfo.vue
src/views/usedCarManagement/evaluationManagement/components/vehicleInfoExpiry.js
src/views/usedCarManagement/evaluationManagement/components/vehicleInfoExpiry.spec.js
src/views/usedCarManagement/evaluationManagement/components/vehicleInfo.vue
View file @
7f63f4d
...
...
@@ -150,7 +150,7 @@
</template>
</template>
<template v-else>
<div class="
flex
">
<div class="
flex
"
:style="
getExpiryTextStyle
(
item
,
detailInfo
)
"
>
<div v-if="
item
.
className
&&
item
.
className
(
detailInfo
)
"
class="
dot
"
:style="
{
...
...
@@ -236,6 +236,7 @@ import {
}
from
"@/common/constants.js"
;
import
{
deepClone
}
from
"@/common/util"
;
import
preview
from
"../../components/preview"
;
import
{
getExpiryTextStyle
}
from
"./vehicleInfoExpiry"
;
export
default
{
components
:
{
...
...
@@ -308,10 +309,18 @@ export default {
}
,
}
,
{
title
:
"交强险到期"
,
key
:
"compulsoryInsuranceExpiry"
,
}
,
{
title
:
"表显里程"
,
key
:
"mileageStr"
,
}
,
{
title
:
"年审到期"
,
key
:
"annualInspectionExpiry"
,
}
,
{
title
:
"使用性质"
,
key
:
"carTypeName"
,
formatter
:
(
row
)
=>
{
...
...
@@ -325,6 +334,10 @@ export default {
}
,
}
,
{
title
:
"商业险到期"
,
key
:
"commercialInsuranceExpiry"
,
}
,
{
title
:
"所有人性质"
,
key
:
"ownerType"
,
formatter
:
(
row
)
=>
{
...
...
@@ -494,6 +507,7 @@ export default {
}
;
}
,
methods
:
{
getExpiryTextStyle
,
getStatusItem
(
baseData
,
optKey
,
row
,
rowKey
)
{
if
(
!
baseData
||
!
baseData
[
optKey
]
||
!
row
)
{
return
null
;
...
...
src/views/usedCarManagement/evaluationManagement/components/vehicleInfoExpiry.js
0 → 100644
View file @
7f63f4d
const
expiryKeys
=
[
"compulsoryInsuranceExpiry"
,
"annualInspectionExpiry"
,
"commercialInsuranceExpiry"
,
];
function
getLocalDate
(
value
)
{
if
(
!
value
)
{
return
null
;
}
if
(
value
instanceof
Date
)
{
return
new
Date
(
value
.
getFullYear
(),
value
.
getMonth
(),
value
.
getDate
());
}
const
matched
=
String
(
value
).
match
(
/^
(\d{4})[
-
/](\d{1,2})[
-
/](\d{1,2})
/
);
if
(
matched
)
{
return
new
Date
(
Number
(
matched
[
1
]),
Number
(
matched
[
2
])
-
1
,
Number
(
matched
[
3
]),
);
}
const
date
=
new
Date
(
value
);
if
(
Number
.
isNaN
(
date
.
getTime
()))
{
return
null
;
}
return
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
());
}
export
function
getExpiryTextStyle
(
item
,
row
)
{
if
(
!
item
||
!
expiryKeys
.
includes
(
item
.
key
)
||
!
row
)
{
return
{};
}
const
expiryDate
=
getLocalDate
(
row
[
item
.
key
]);
if
(
!
expiryDate
)
{
return
{};
}
const
now
=
new
Date
();
const
today
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
(),
now
.
getDate
());
const
diffDays
=
Math
.
ceil
((
expiryDate
.
getTime
()
-
today
.
getTime
())
/
86400000
);
if
(
diffDays
<
0
)
{
return
{
color
:
"#EB4E4E"
};
}
if
(
diffDays
<=
30
)
{
return
{
color
:
"#FF8D1A"
};
}
return
{};
}
src/views/usedCarManagement/evaluationManagement/components/vehicleInfoExpiry.spec.js
0 → 100644
View file @
7f63f4d
import
{
getExpiryTextStyle
}
from
"./vehicleInfoExpiry"
;
describe
(
"vehicleInfo expiry date colors"
,
()
=>
{
beforeEach
(()
=>
{
jest
.
useFakeTimers
(
"modern"
);
jest
.
setSystemTime
(
new
Date
(
2026
,
6
,
6
));
});
afterEach
(()
=>
{
jest
.
useRealTimers
();
});
it
(
"marks expired expiry fields red"
,
()
=>
{
const
style
=
getExpiryTextStyle
(
{
key
:
"annualInspectionExpiry"
},
{
annualInspectionExpiry
:
"2026-07-05"
},
);
expect
(
style
).
toEqual
({
color
:
"#EB4E4E"
});
});
it
(
"marks expiry fields within thirty days orange"
,
()
=>
{
const
style
=
getExpiryTextStyle
(
{
key
:
"commercialInsuranceExpiry"
},
{
commercialInsuranceExpiry
:
"2026-08-05"
},
);
expect
(
style
).
toEqual
({
color
:
"#FF8D1A"
});
});
it
(
"keeps non-expiry fields and later dates default"
,
()
=>
{
expect
(
getExpiryTextStyle
(
{
key
:
"licensePlate"
},
{
licensePlate
:
"A12345"
},
)).
toEqual
({});
expect
(
getExpiryTextStyle
(
{
key
:
"compulsoryInsuranceExpiry"
},
{
compulsoryInsuranceExpiry
:
"2026-08-06"
},
)).
toEqual
({});
});
});
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment