# 详情页表格数据改为统计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
export function fetchDeviceLogs(query) {
return request({
url: '/api/counter/logs/',
url: '/api/counter/device/logs/history/',
method: 'get',
params: query
})

View File

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

View File

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