# 详情页表格数据改为统计total

This commit is contained in:
xianfuxing 2018-09-24 21:39:47 +08:00
parent 08c55cf959
commit 781960bf17
3 changed files with 19 additions and 38 deletions

View File

@ -12,7 +12,7 @@ export function fetchDeviceList(query) {
// device log api // device log api
export function fetchDeviceLogs(query) { export function fetchDeviceLogs(query) {
return request({ return request({
url: '/api/counter/logs/', url: '/api/counter/device/logs/history/',
method: 'get', method: 'get',
params: query params: query
}) })

View File

@ -30,14 +30,14 @@
<ul> <ul>
<li>状态 <li>状态
<span <span
:class="status ? 'text-success' : 'text-danger'" :class="lastItem.status ? 'text-success' : 'text-danger'"
v-if="status == 0" v-if="lastItem.status == 0"
> >
离线 离线
</span> </span>
<span <span
:class="status ? 'text-success' : 'text-danger'" :class="lastItem.status ? 'text-success' : 'text-danger'"
v-if="status == 1" v-if="lastItem.status == 1"
> >
在线 在线
</span> </span>
@ -56,8 +56,7 @@ export default {
name: 'screen', name: 'screen',
props: { props: {
deviceID: String, deviceID: String,
lastItem: Object, lastItem: Object
status: Number
}, },
data() { data() {
return { return {
@ -73,7 +72,7 @@ export default {
// return this.lastItem.calc_time.substr(0, 16).split('') // return this.lastItem.calc_time.substr(0, 16).split('')
}, },
lastCount() { lastCount() {
const count = this.lastItem.mosq_count const count = this.lastItem.count
const qty = 'Qty.' + ' '.repeat(10 - count.length) + '00' + count const qty = 'Qty.' + ' '.repeat(10 - count.length) + '00' + count
return qty.split('') return qty.split('')
} }

View File

@ -6,7 +6,6 @@
<screen <screen
:deviceID="this.$store.getters.deviceID" :deviceID="this.$store.getters.deviceID"
:lastItem="lastItem" :lastItem="lastItem"
:status="status"
v-if="flag" v-if="flag"
> >
</screen> </screen>
@ -37,29 +36,13 @@
min-width="150"> min-width="150">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="mosq_count" prop="total"
label="计数" label="计数"
min-width="80"> min-width="80">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="signal" prop="date"
label="信号" label="日期"
min-width="50">
</el-table-column>
<el-table-column
prop="energy"
label="电量"
min-width="80">
</el-table-column>
<el-table-column
prop="coordinate"
label="坐标"
min-width="270"
:formatter="coordinate">
</el-table-column>
<el-table-column
prop="calc_time"
label="时间"
min-width="100"> min-width="100">
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -81,6 +64,7 @@ import Chart from './components/chart'
const defaultLastItem = { const defaultLastItem = {
mosq_count: '0', mosq_count: '0',
status: '0',
signal: '0', signal: '0',
energy: '0' energy: '0'
} }
@ -104,7 +88,6 @@ export default {
activeName: 'screen', activeName: 'screen',
total: 0, total: 0,
lastItem: {}, lastItem: {},
status: 0,
showChart: false, showChart: false,
flag: false flag: false
} }
@ -122,23 +105,22 @@ export default {
const dateList = [] const dateList = []
this.deviceLogs = response.data.results this.deviceLogs = response.data.results
this.deviceLogs.forEach((item, index) => { this.deviceLogs.forEach((item, index) => {
this.lineChartData.total.historyData.push(item.mosq_count) this.lineChartData.total.historyData.push(item.total)
dateList.push(item.calc_time.substr(11)) dateList.push(item.date.substr(5))
}) })
this.total = response.data.count this.total = response.data.count
this.lineChartData.total.xAxis = dateList.reverse() this.lineChartData.total.xAxis = dateList.reverse()
this.listLoading = false this.listLoading = false
this.lastItem = this.deviceLogs[0]
if (this.lastItem === undefined) {
this.lastItem = defaultLastItem
}
this.flag = true
}) })
}, },
getDevices(params) { getDevices(params) {
fetchDeviceList(params).then(response => { fetchDeviceList(params).then(response => {
this.deviceList = response.data.results this.deviceList = response.data.results
this.status = this.deviceList[0].status this.lastItem = this.deviceList[0]
if (this.lastItem === undefined) {
this.lastItem = defaultLastItem
}
this.flag = true
}) })
}, },
coordinate(row, column) { coordinate(row, column) {
@ -171,6 +153,6 @@ export default {
opacity: 0; opacity: 0;
} }
.v-enter-active, .v-leave-active { .v-enter-active, .v-leave-active {
transition: opacity 1.5s transition: opacity 1s
} }
</style> </style>