数据过滤

This commit is contained in:
2025-08-05 17:09:41 +08:00
parent 2836fe4892
commit 4a2d3de48b
6 changed files with 48 additions and 9 deletions

14
main.js
View File

@ -2,19 +2,23 @@ import Vue from 'vue'
import App from './App' import App from './App'
import store from './store' // store import store from './store' // store
import plugins from './plugins' // plugins import plugins from './plugins' // plugins
import {
formatNumber
} from './utils/filters.js' //数据过滤
import './permission' // permission import './permission' // permission
import { getDicts } from "@/api/system/dict/data" import {
getDicts
} from "@/api/system/dict/data"
Vue.use(plugins) Vue.use(plugins)
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$store = store Vue.prototype.$store = store
Vue.prototype.getDicts = getDicts Vue.prototype.getDicts = getDicts
Vue.filter('formatNumber', formatNumber)
App.mpType = 'app' App.mpType = 'app'
const app = new Vue({ const app = new Vue({
...App ...App
}) })
app.$mount() app.$mount()

View File

@ -34,7 +34,7 @@
:key="infoDataIndex+'infoData'"> :key="infoDataIndex+'infoData'">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">{{infoDataItem.label}}</view> <view class="title">{{infoDataItem.label}}</view>
<text class="text">{{item[infoDataItem.attr]}} <text class="text">{{item[infoDataItem.attr] | formatNumber}}
<text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text> <text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text>
</text> </text>
</view> </view>

View File

@ -34,7 +34,7 @@
:key="infoDataIndex+'infoData'"> :key="infoDataIndex+'infoData'">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">{{infoDataItem.label}}</view> <view class="title">{{infoDataItem.label}}</view>
<text class="text">{{item[infoDataItem.attr]}} <text class="text">{{item[infoDataItem.attr] | formatNumber}}
<text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text> <text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text>
</text> </text>
</view> </view>

View File

@ -188,6 +188,10 @@
// 运行状态颜色区分 // 运行状态颜色区分
.running { .running {
.uni-group__title {
background-color: #05AEA3;
}
.uni-collapse-item__title-text { .uni-collapse-item__title-text {
color: #05AEA3; color: #05AEA3;
} }
@ -199,6 +203,10 @@
} }
.danger { .danger {
.uni-group__title {
background-color: #FC6B69;
}
.uni-collapse-item__title-text { .uni-collapse-item__title-text {
color: #FC6B69; color: #FC6B69;
} }

View File

@ -5,7 +5,7 @@
<uni-grid-item v-for="(item,index) in runningHeadData" :key="index+'head'"> <uni-grid-item v-for="(item,index) in runningHeadData" :key="index+'head'">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">{{item.title}}</view> <view class="title">{{item.title}}</view>
<text class="text">{{runningHeadInfo[item.attr] || '-'}}</text> <text class="text">{{runningHeadInfo[item.attr] | formatNumber}}</text>
</view> </view>
</uni-grid-item> </uni-grid-item>
</uni-grid> </uni-grid>
@ -61,7 +61,7 @@
:key="infoDataIndex+'infoData'"> :key="infoDataIndex+'infoData'">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">{{infoDataItem.label}}</view> <view class="title">{{infoDataItem.label}}</view>
<text class="text">{{item[infoDataItem.attr]}} <text class="text">{{item[infoDataItem.attr] | formatNumber}}
<text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text> <text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text>
</text> </text>
</view> </view>

27
utils/filters.js Normal file
View File

@ -0,0 +1,27 @@
export const formatNumber = (val) => {
if (val || [0, '0'].includes(val)) {
return val
} else {
return '-'
}
}
export const formatDate = (val, toSeconds = false, onlyTime = false) => {
if (!val) return ''
const date = new Date(val)
const month = date.getMonth() + 1,
day = date.getDate()
const hours = date.getHours(),
minuets = date.getMinutes(),
seconds = date.getSeconds();
const front = `${date.getFullYear()}-${month<10?'0'+month : month}-${day<10 ? '0'+day : day}`
const back =
`${hours<10 ? '0'+hours : hours}:${minuets<10 ? '0'+minuets : minuets}:${seconds<10 ? '0'+seconds : seconds}`
if (onlyTime) return back
if (!toSeconds) {
return front
} else {
return front + '' + back
}
}