|
@@ -0,0 +1,293 @@
|
|
|
+<template>
|
|
|
+ <div class="container">
|
|
|
+ <div class="serch">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="getdataListParm.date"
|
|
|
+ type="month"
|
|
|
+ placeholder="选择月"
|
|
|
+ :clearable="false"
|
|
|
+ format="yyyy-MM"
|
|
|
+ value-format="yyyy-MM"
|
|
|
+ >
|
|
|
+ </el-date-picker>
|
|
|
+ <el-select
|
|
|
+ v-model="getdataListParm.pastureName"
|
|
|
+ placeholder="牧场"
|
|
|
+ class="filter-item"
|
|
|
+ style="width: 120px"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in findAllPasture"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.name"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <el-input
|
|
|
+ v-model="getdataListParm.eqCode"
|
|
|
+ placeholder="车辆编号"
|
|
|
+ clearable
|
|
|
+ style="width: 140px"
|
|
|
+ class="filter-item"
|
|
|
+ ></el-input>
|
|
|
+
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ style="margin-left: 20px"
|
|
|
+ icon="el-icon-search"
|
|
|
+ @click="handlerSerch"
|
|
|
+ >搜 索</el-button
|
|
|
+ >
|
|
|
+
|
|
|
+ <el-button type="success" icon="el-icon-download" @click="handleDownload"
|
|
|
+ >导 出</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 列表table -->
|
|
|
+ <el-table
|
|
|
+ :data="tableData"
|
|
|
+ border
|
|
|
+ header-align="center"
|
|
|
+ style="width: 99%; margin-top: 30px"
|
|
|
+ max-height="590px"
|
|
|
+ v-loading="loading"
|
|
|
+ element-loading-text="数据中在加载中"
|
|
|
+ ref="table"
|
|
|
+ >
|
|
|
+ <template v-for="(item, index) in tableHeader">
|
|
|
+ <el-table-column
|
|
|
+ v-if="item.prop !== 'runningRate'"
|
|
|
+ :key="index"
|
|
|
+ show-overflow-tooltip
|
|
|
+ :prop="item.prop"
|
|
|
+ :label="item.label"
|
|
|
+ :width="item.width"
|
|
|
+ align="center"
|
|
|
+ >
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column
|
|
|
+ v-else="item.prop == 'runningRate'"
|
|
|
+ :key="index"
|
|
|
+ show-overflow-tooltip
|
|
|
+ :prop="item.prop"
|
|
|
+ :label="item.label"
|
|
|
+ :width="item.width"
|
|
|
+ align="center"
|
|
|
+ :render-header="renderColumnHeader"
|
|
|
+ >
|
|
|
+ </el-table-column>
|
|
|
+ <!-- <template sloat-scope="scope">
|
|
|
+ <span v-if="item.prop !== 'runningRate'">{{
|
|
|
+ scope.row[item.prop]
|
|
|
+ }}</span>
|
|
|
+ <span v-else>{{ scope.row[item.prop] }}</span>
|
|
|
+ </template> -->
|
|
|
+ </template>
|
|
|
+ </el-table>
|
|
|
+ <!-- -->
|
|
|
+ <Pagination
|
|
|
+ v-show="total > 0"
|
|
|
+ :total="total"
|
|
|
+ :page.sync="getdataListParm.offset"
|
|
|
+ :limit.sync="getdataListParm.pagecount"
|
|
|
+ @pagination="getTableList"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import Cookies from 'js-cookie'
|
|
|
+import { GetDataByNames, getVehicRate } from '@/api/common'
|
|
|
+import { parseTime, json2excel } from '@/utils/index.js'
|
|
|
+import Pagination from '@/components/Pagination'
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: { Pagination },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ total: 0,
|
|
|
+ loading: false,
|
|
|
+ getdataListParm: {
|
|
|
+ pagecount: 10,
|
|
|
+ offset: 1,
|
|
|
+ pastureId: Cookies.get('pastureid'),
|
|
|
+ pastureName: Cookies.get('pasturename'),
|
|
|
+ date: parseTime(new Date(), '{y}-{m}'), // 日期
|
|
|
+ eqCode: ''
|
|
|
+ },
|
|
|
+ requestParams: [
|
|
|
+ {
|
|
|
+ name: 'findAllPasture',
|
|
|
+ offset: 0,
|
|
|
+ pagecount: 0,
|
|
|
+ returntype: 'Map',
|
|
|
+ parammaps: { id: Cookies.get('pastureid') } // id:18 默认查询所有
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ findAllPasture: [], // 牧场数据
|
|
|
+ tableData: [
|
|
|
+ {
|
|
|
+ pastureName: '圣牧'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tableHeader: [],
|
|
|
+ headerArr: [
|
|
|
+ {
|
|
|
+ label: '序号',
|
|
|
+ prop: 'sort',
|
|
|
+ width: '50'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '牧场',
|
|
|
+ prop: 'pastureName',
|
|
|
+ width: '100'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '物料网号',
|
|
|
+ prop: 'license',
|
|
|
+ width: '120'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '车辆编号',
|
|
|
+ prop: 'eqCode',
|
|
|
+ width: '100'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '车辆名称',
|
|
|
+ prop: 'eqName',
|
|
|
+ width: '100'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '车辆类别',
|
|
|
+ prop: 'eqClassName',
|
|
|
+ width: '100'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '标准时长',
|
|
|
+ prop: 'duration',
|
|
|
+ width: '80'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: `运转率\n(截止导出日期)`,
|
|
|
+ prop: 'runningRate',
|
|
|
+ width: '140'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getPasture()
|
|
|
+ this.getTableList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 点击搜索
|
|
|
+ handlerSerch() {
|
|
|
+ this.getdataListParm.pagecount = 10
|
|
|
+ this.getdataListParm.offset = 1
|
|
|
+ this.getTableList()
|
|
|
+ },
|
|
|
+ // 获取当前用户牧场信息
|
|
|
+ async getPasture() {
|
|
|
+ const { data } = await GetDataByNames(this.requestParams)
|
|
|
+ this.findAllPasture = data.findAllPasture.list
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取列表数据
|
|
|
+ async getTableList() {
|
|
|
+ this.loading = true
|
|
|
+ const { data } = await getVehicRate(this.getdataListParm)
|
|
|
+ data.list.length &&
|
|
|
+ data.list.forEach((item, index) => {
|
|
|
+ item.sort = index + 1
|
|
|
+ })
|
|
|
+ this.tableData = data.list
|
|
|
+ this.tableHeader = [...this.headerArr]
|
|
|
+ this.total = data.total
|
|
|
+ this.loading = false
|
|
|
+ console.log(this.tableHeader, 'tableHeader')
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取当前月份的天数
|
|
|
+ getMounth() {
|
|
|
+ const arr = []
|
|
|
+ const temp = this.getdataListParm.date.split('-')
|
|
|
+ const year = temp[0]
|
|
|
+ const month = temp[1]
|
|
|
+ const day = new Date(year, month, 0)
|
|
|
+ for (let index = 1; index <= day.getDate(); index++) {
|
|
|
+ index = JSON.stringify(index)
|
|
|
+ const value = { label: index, prop: index, width: '60' }
|
|
|
+ arr.push(value)
|
|
|
+ }
|
|
|
+ return arr
|
|
|
+ },
|
|
|
+
|
|
|
+ // 导出功能
|
|
|
+ handleDownload() {
|
|
|
+ this.getdataListParm.pagecount = 9999
|
|
|
+ getVehicRate(this.getdataListParm).then((res) => {
|
|
|
+ const { data } = res
|
|
|
+ data.list.length &&
|
|
|
+ data.list.forEach((item, index) => {
|
|
|
+ item.sort = index + 1
|
|
|
+ item.runningRate = `${item.runningRate}%`
|
|
|
+ })
|
|
|
+ const table = this.$refs.table
|
|
|
+ const labels = table.columns.map((column) => column.label)
|
|
|
+ const filterVal = this.tableHeader.map((item) => {
|
|
|
+ return item.prop
|
|
|
+ })
|
|
|
+ console.log(labels, filterVal, 'label')
|
|
|
+ const elecExcelDatas = [
|
|
|
+ {
|
|
|
+ tHeader: labels,
|
|
|
+ filterVal: filterVal,
|
|
|
+ tableDatas: data.list,
|
|
|
+ sheetName: 'SheetJS'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ json2excel(elecExcelDatas, '车辆运转率', true, 'xlsx')
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 运转率展示的内容
|
|
|
+ renderColumnHeader(h, { column }) {
|
|
|
+ return h(
|
|
|
+ 'el-tooltip',
|
|
|
+ {
|
|
|
+ effect: 'dark',
|
|
|
+ placement: 'top-start'
|
|
|
+ },
|
|
|
+ [
|
|
|
+ h(
|
|
|
+ 'div',
|
|
|
+ {
|
|
|
+ slot: 'content'
|
|
|
+ },
|
|
|
+ [h('span', {}, '实际时长累计和/标准时长累计和')]
|
|
|
+ ),
|
|
|
+ h('div', [
|
|
|
+ h('span', column.label),
|
|
|
+ h('i', {
|
|
|
+ class: 'el-icon-question',
|
|
|
+ style: 'color:#606266;margin-left:5px;vertical-align:middle'
|
|
|
+ })
|
|
|
+ ])
|
|
|
+ ]
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.container {
|
|
|
+ padding: 20px;
|
|
|
+}
|
|
|
+/deep/ .el-table th div {
|
|
|
+ // white-space: pre;
|
|
|
+ white-space: pre-wrap; // 也行。
|
|
|
+}
|
|
|
+</style>
|