识别图片修改

This commit is contained in:
cwchen 2025-12-23 17:29:07 +08:00
parent f146e49177
commit 8ba5c68ae0
3 changed files with 112 additions and 32 deletions

View File

@ -368,11 +368,27 @@ export default {
/* 生成查询参数 */ /* 生成查询参数 */
this.formLabel.map((e) => { this.formLabel.map((e) => {
if (e.f_type === 'dateRange' || e.f_type === 'dateTimeRange') { if (e.f_type === 'dateRange' || e.f_type === 'dateTimeRange') {
//
let defaultValues = null
if (e.defaultValue) {
// defaultValue 使
defaultValues = typeof e.defaultValue === 'function' ? e.defaultValue() : e.defaultValue
}
// //
this.$set(this.queryParams, e.dateType[0], '') if (defaultValues && Array.isArray(defaultValues) && defaultValues.length === 2) {
this.$set(this.queryParams, e.dateType[1], '') // 使
// v-model this.$set(this.queryParams, e.dateType[0], defaultValues[0] || '')
this.$set(this.queryParams, e.f_model, null) this.$set(this.queryParams, e.dateType[1], defaultValues[1] || '')
// v-model
this.$set(this.queryParams, e.f_model, defaultValues)
} else {
//
this.$set(this.queryParams, e.dateType[0], '')
this.$set(this.queryParams, e.dateType[1], '')
// v-model
this.$set(this.queryParams, e.f_model, null)
}
this.typeList = e.dateType this.typeList = e.dateType
if (this.isOneMonth) { if (this.isOneMonth) {
@ -488,26 +504,36 @@ export default {
/** 重置按钮 */ /** 重置按钮 */
resetQuery() { resetQuery() {
this.$refs.queryFormRef.resetFields() this.$refs.queryFormRef.resetFields()
if (this.typeList.length > 1) { //
if (this.isCurrentDate) { this.formLabel.forEach((e) => {
this.queryParams[this.typeList[0]] = new Date() if (e.f_type === 'dateRange' || e.f_type === 'dateTimeRange') {
.toISOString() //
.split('T')[0] let defaultValues = null
this.queryParams[this.typeList[1]] = new Date() if (e.defaultValue) {
.toISOString() defaultValues = typeof e.defaultValue === 'function' ? e.defaultValue() : e.defaultValue
.split('T')[0] }
this.queryParams.time = [
new Date().toISOString().split('T')[0], if (e.dateType && e.dateType.length >= 2) {
new Date().toISOString().split('T')[0], if (this.isCurrentDate && e.f_type === 'dateRange') {
] //
} else { const today = new Date().toISOString().split('T')[0]
this.queryParams[this.typeList[0]] = '' this.queryParams[e.dateType[0]] = today
this.queryParams[this.typeList[1]] = '' this.queryParams[e.dateType[1]] = today
this.queryParams.time = [] this.queryParams[e.f_model] = [today, today]
} else if (defaultValues && Array.isArray(defaultValues) && defaultValues.length === 2) {
//
this.queryParams[e.dateType[0]] = defaultValues[0] || ''
this.queryParams[e.dateType[1]] = defaultValues[1] || ''
this.queryParams[e.f_model] = defaultValues
} else {
//
this.queryParams[e.dateType[0]] = ''
this.queryParams[e.dateType[1]] = ''
this.queryParams[e.f_model] = null
}
}
} }
} else { })
this.queryParams[this.typeList[0]] = ''
}
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
this.queryParams.pageSize = 10 this.queryParams.pageSize = 10
this.getTableList() this.getTableList()

View File

@ -7,6 +7,23 @@ export const formLabel = [
f_width: '400px', f_width: '400px',
dateType: ['startTime', 'endTime'], dateType: ['startTime', 'endTime'],
valueFormat: 'yyyy-MM-dd HH:mm', valueFormat: 'yyyy-MM-dd HH:mm',
// 默认时间设置,可以是数组 [startTime, endTime] 或函数返回数组
// 函数形式:() => [startTime, endTime],支持动态计算
defaultValue: () => {
// 默认设置为当天00:00到23:59
const now = new Date()
const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0)
const todayEnd = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59)
const formatTime = (date) => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}`
}
return [formatTime(todayStart), formatTime(todayEnd)]
},
}, },
] ]

View File

@ -31,7 +31,7 @@
</div> </div>
<!-- 图像网格 --> <!-- 图像网格 -->
<div class="image-grid-container" v-loading="loading"> <div class="image-grid-container" :class="{ 'has-scroll': needsScroll() }" v-loading="loading">
<div v-for="(item, index) in imageList" :key="index" class="image-card"> <div v-for="(item, index) in imageList" :key="index" class="image-card">
<div class="image-wrapper"> <div class="image-wrapper">
<el-image :src="item.imageUrl || test_image" fit="cover" class="detection-image" <el-image :src="item.imageUrl || test_image" fit="cover" class="detection-image"
@ -96,10 +96,31 @@ export default {
}, },
created() { created() {
// 00 2359
this.initDefaultTimeRange()
this.getImageList() this.getImageList()
}, },
methods: { methods: {
/** 初始化默认时间范围 */
initDefaultTimeRange() {
const now = new Date()
const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0)
const todayEnd = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59)
const formatTime = (date) => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}`
}
const defaultTimeRange = [formatTime(todayStart), formatTime(todayEnd)]
this.timeRange = defaultTimeRange
this.queryParams.startTime = defaultTimeRange[0]
this.queryParams.endTime = defaultTimeRange[1]
},
/** 格式化日期时间字符串(从接口返回的格式转换) */ /** 格式化日期时间字符串(从接口返回的格式转换) */
formatDateTimeFromString(dateStr) { formatDateTimeFromString(dateStr) {
if (!dateStr) return '' if (!dateStr) return ''
@ -200,9 +221,8 @@ export default {
/** 重置操作 */ /** 重置操作 */
handleReset() { handleReset() {
this.queryParams.carType = '' this.queryParams.carType = ''
this.queryParams.startTime = '' // 00 2359
this.queryParams.endTime = '' this.initDefaultTimeRange()
this.timeRange = null
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
this.getImageList() this.getImageList()
}, },
@ -259,6 +279,11 @@ export default {
if (item.vehicleType) parts.push(item.vehicleType) if (item.vehicleType) parts.push(item.vehicleType)
return parts.join(' ') || '未知位置' return parts.join(' ') || '未知位置'
}, },
/** 判断是否需要滚动 */
needsScroll() {
return this.imageList.length > 4
},
}, },
} }
</script> </script>
@ -330,7 +355,7 @@ export default {
} }
.table-card { .table-card {
height: calc(100vh - 230px); min-height: calc(100vh - 230px);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -338,7 +363,7 @@ export default {
padding: 20px; padding: 20px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; min-height: 0;
} }
.table-header { .table-header {
@ -354,12 +379,20 @@ export default {
} }
.image-grid-container { .image-grid-container {
flex: 1;
overflow-y: auto;
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
gap: 16px; gap: 16px;
padding: 0 0 16px 0; padding: 0 0 16px 0;
//
align-content: start;
grid-auto-rows: min-content;
//
&.has-scroll {
flex: 1;
overflow-y: auto;
min-height: 0;
}
&::-webkit-scrollbar { &::-webkit-scrollbar {
width: 6px; width: 6px;
@ -384,6 +417,8 @@ export default {
overflow: hidden; overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transition: all 0.3s; transition: all 0.3s;
// grid
align-self: start;
&:hover { &:hover {
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
@ -395,6 +430,8 @@ export default {
width: 100%; width: 100%;
padding-top: 75%; // 4:3 padding-top: 75%; // 4:3
overflow: hidden; overflow: hidden;
//
height: 0;
.detection-image { .detection-image {
position: absolute; position: absolute;
@ -504,7 +541,7 @@ export default {
flex-shrink: 0; flex-shrink: 0;
margin-top: 16px; margin-top: 16px;
padding-top: 16px; padding-top: 16px;
border-top: 1px solid #ebeef5; border-top: none;
} }
} }
</style> </style>