|
@@ -126,11 +126,11 @@
|
|
|
<el-table-column prop="status" label="状态" width="100" align="center">
|
|
<el-table-column prop="status" label="状态" width="100" align="center">
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
|
<el-tag
|
|
<el-tag
|
|
|
- :type="row.status === 1 ? 'info' : row.status === 2 ? 'success' : 'danger'"
|
|
|
|
|
|
|
+ :type="getStatusType(getComputedStatus(row))"
|
|
|
size="small"
|
|
size="small"
|
|
|
effect="light"
|
|
effect="light"
|
|
|
>
|
|
>
|
|
|
- {{ getStatusText(row.status) }}
|
|
|
|
|
|
|
+ {{ getStatusText(getComputedStatus(row)) }}
|
|
|
</el-tag>
|
|
</el-tag>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
@@ -230,7 +230,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, reactive, onMounted } from 'vue'
|
|
|
|
|
|
|
+import { ref, reactive, onMounted, onBeforeUnmount } from 'vue'
|
|
|
import { useRouter } from 'vue-router'
|
|
import { useRouter } from 'vue-router'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import { Calendar, Picture } from '@element-plus/icons-vue'
|
|
import { Calendar, Picture } from '@element-plus/icons-vue'
|
|
@@ -250,6 +250,38 @@ const filters = reactive({
|
|
|
keyword: ''
|
|
keyword: ''
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const nowTs = ref(Date.now())
|
|
|
|
|
+let nowTimer = null
|
|
|
|
|
+
|
|
|
|
|
+const parseToMs = (val) => {
|
|
|
|
|
+ if (!val) return null
|
|
|
|
|
+ if (val instanceof Date) return val.getTime()
|
|
|
|
|
+ if (typeof val === 'number') return val > 1e12 ? val : val * 1000
|
|
|
|
|
+ if (typeof val === 'string') {
|
|
|
|
|
+ const trimmed = val.trim()
|
|
|
|
|
+ if (!trimmed) return null
|
|
|
|
|
+ const normalized = trimmed.replace('T', ' ').replace(/\//g, '-')
|
|
|
|
|
+ const ms = Date.parse(normalized)
|
|
|
|
|
+ if (!Number.isNaN(ms)) return ms
|
|
|
|
|
+ }
|
|
|
|
|
+ return null
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const getComputedStatus = (row) => {
|
|
|
|
|
+ const startMs = parseToMs(row?.startTime)
|
|
|
|
|
+ const endMs = parseToMs(row?.endTime)
|
|
|
|
|
+ const now = nowTs.value
|
|
|
|
|
+
|
|
|
|
|
+ if (!startMs || !endMs) {
|
|
|
|
|
+ return row?.status
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (now < startMs) return 1
|
|
|
|
|
+ if (now >= endMs) return 3
|
|
|
|
|
+ if (now >= startMs && now < endMs) return 2
|
|
|
|
|
+ return row?.status
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 规范化图片地址,兼容相对路径和缺少协议的情况
|
|
// 规范化图片地址,兼容相对路径和缺少协议的情况
|
|
|
const resolveImageUrl = (url) => {
|
|
const resolveImageUrl = (url) => {
|
|
|
if (!url || typeof url !== 'string') return ''
|
|
if (!url || typeof url !== 'string') return ''
|
|
@@ -351,7 +383,7 @@ const getStatusText = (status) => {
|
|
|
|
|
|
|
|
// 获取状态颜色
|
|
// 获取状态颜色
|
|
|
const getStatusType = (status) => {
|
|
const getStatusType = (status) => {
|
|
|
- const types = { 1: 'info', 2: 'success', 3: '' }
|
|
|
|
|
|
|
+ const types = { 1: 'info', 2: 'success', 3: 'danger' }
|
|
|
return types[status] || ''
|
|
return types[status] || ''
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -448,6 +480,16 @@ const handleDelete = async (row) => {
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
loadActivityList()
|
|
loadActivityList()
|
|
|
|
|
+ nowTimer = window.setInterval(() => {
|
|
|
|
|
+ nowTs.value = Date.now()
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+onBeforeUnmount(() => {
|
|
|
|
|
+ if (nowTimer) {
|
|
|
|
|
+ window.clearInterval(nowTimer)
|
|
|
|
|
+ nowTimer = null
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|