数据过滤
This commit is contained in:
10
main.js
10
main.js
@ -2,15 +2,19 @@ import Vue from 'vue'
|
||||
import App from './App'
|
||||
import store from './store' // store
|
||||
import plugins from './plugins' // plugins
|
||||
import {
|
||||
formatNumber
|
||||
} from './utils/filters.js' //数据过滤
|
||||
import './permission' // permission
|
||||
import { getDicts } from "@/api/system/dict/data"
|
||||
import {
|
||||
getDicts
|
||||
} from "@/api/system/dict/data"
|
||||
|
||||
Vue.use(plugins)
|
||||
|
||||
Vue.config.productionTip = false
|
||||
Vue.prototype.$store = store
|
||||
Vue.prototype.getDicts = getDicts
|
||||
|
||||
Vue.filter('formatNumber', formatNumber)
|
||||
App.mpType = 'app'
|
||||
|
||||
const app = new Vue({
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
:key="infoDataIndex+'infoData'">
|
||||
<view class="grid-item-box">
|
||||
<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>
|
||||
</view>
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
:key="infoDataIndex+'infoData'">
|
||||
<view class="grid-item-box">
|
||||
<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>
|
||||
</view>
|
||||
|
||||
@ -188,6 +188,10 @@
|
||||
|
||||
// 运行状态颜色区分
|
||||
.running {
|
||||
.uni-group__title {
|
||||
background-color: #05AEA3;
|
||||
}
|
||||
|
||||
.uni-collapse-item__title-text {
|
||||
color: #05AEA3;
|
||||
}
|
||||
@ -199,6 +203,10 @@
|
||||
}
|
||||
|
||||
.danger {
|
||||
.uni-group__title {
|
||||
background-color: #FC6B69;
|
||||
}
|
||||
|
||||
.uni-collapse-item__title-text {
|
||||
color: #FC6B69;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<uni-grid-item v-for="(item,index) in runningHeadData" :key="index+'head'">
|
||||
<view class="grid-item-box">
|
||||
<view class="title">{{item.title}}</view>
|
||||
<text class="text">{{runningHeadInfo[item.attr] || '-'}}</text>
|
||||
<text class="text">{{runningHeadInfo[item.attr] | formatNumber}}</text>
|
||||
</view>
|
||||
</uni-grid-item>
|
||||
</uni-grid>
|
||||
@ -61,7 +61,7 @@
|
||||
:key="infoDataIndex+'infoData'">
|
||||
<view class="grid-item-box">
|
||||
<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>
|
||||
</view>
|
||||
|
||||
27
utils/filters.js
Normal file
27
utils/filters.js
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user