Browse Source

车辆总汇

Shan9312 8 months ago
parent
commit
f2b23c06bc

BIN
dist-现代牧业-正式-240702.zip


File diff suppressed because it is too large
+ 0 - 0
dist/index.html


+ 9 - 0
src/api/common.js

@@ -356,3 +356,12 @@ export function getVehicRate(data) {
     params: data
   })
 }
+
+
+export function getVehicRateTotal(data) {
+  return request({
+    url: '/authdata/running/rate',
+    method: 'get',
+    params: data
+  })
+}

+ 11 - 11
src/router/index.js

@@ -79,17 +79,17 @@ export const constantRoutes = [
   //   }]
   // },
 
-  // {
-  //   path: '/vehiclRateTotal',
-  //   component: Layout,
-  //   redirect: '/vehiclRateTotal',
-  //   children: [{
-  //     path: 'vehiclRateTotal',
-  //     name: 'VehiclRateTotal',
-  //     component: () => import('@/views/vehiclRateTotal/index.vue'),
-  //     meta: { title: '车辆运转率总览', icon: '', affix: true }
-  //   }]
-  // }
+  {
+    path: '/vehiclRateTotal',
+    component: Layout,
+    redirect: '/vehiclRateTotal',
+    children: [{
+      path: 'vehiclRateTotal',
+      name: 'VehiclRateTotal',
+      component: () => import('@/views/report/vehiclRateTotal/index.vue'),
+      meta: { title: '车辆运转率总览', icon: '', affix: true }
+    }]
+  }
 
 ]
 

+ 100 - 52
src/views/report/vehiclRateTotal/index.vue

@@ -11,7 +11,7 @@
       >
       </el-date-picker>
       <el-select
-        v-model="getdataListParm.pastureName"
+        v-model="getdataListParm.pastureId"
         placeholder="牧场"
         class="filter-item"
         style="width: 120px"
@@ -24,13 +24,20 @@
           :value="item.id"
         />
       </el-select>
-      <el-input
-        v-model="getdataListParm.eqCode"
-        placeholder="车辆编号"
-        clearable
-        style="width: 140px"
+      <el-select
+        v-model="getdataListParm.eqClassId"
+        placeholder="工作类型"
         class="filter-item"
-      ></el-input>
+        style="width: 120px"
+        clearable
+      >
+        <el-option
+              v-for="(item,index) in workList"
+              :key="index"
+              :label="item"
+              :value="item"
+            />
+      </el-select>
 
       <el-button
         type="primary"
@@ -53,8 +60,9 @@
       style="width: 99%; margin-top: 30px"
       max-height="590px"
       v-loading="loading"
-      element-loading-text="数据中在加载中"
+      element-loading-text="数据正在加载..."
       ref="table"
+      :row-class-name="tableRowClassName"
     >
       <template v-for="(item, index) in tableHeader">
         <el-table-column
@@ -67,7 +75,6 @@
           align="center"
         >
         </el-table-column>
-
         <el-table-column
           v-else="item.prop == 'runningRate'"
           :key="index"
@@ -79,12 +86,7 @@
           :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>
     <!--  -->
@@ -100,7 +102,7 @@
 
 <script>
 import Cookies from 'js-cookie'
-import { GetDataByNames, getVehicRate } from '@/api/common'
+import { GetDataByNames, getVehicRateTotal, getWorkList } from '@/api/common'
 import { parseTime, json2excel } from '@/utils/index.js'
 import Pagination from '@/components/Pagination'
 
@@ -108,15 +110,16 @@ export default {
   components: { Pagination },
   data() {
     return {
+      workList: [], // 工作类别
       total: 0,
       loading: false,
+      // pastureName: Cookies.get('pasturename'),
       getdataListParm: {
         pagecount: 10,
         offset: 1,
-        pastureId: Cookies.get('pastureid'),
-        pastureName: Cookies.get('pasturename'),
+        pastureId: parseInt(Cookies.get('pastureid')),
         date: parseTime(new Date(), '{y}-{m}'), // 日期
-        eqCode: ''
+        eqClassId: ''
       },
       requestParams: [
         {
@@ -128,13 +131,8 @@ export default {
         }
       ],
       findAllPasture: [], // 牧场数据
-      tableData: [
-        {
-          pastureName: '圣牧'
-        }
-      ],
-      tableHeader: [],
-      headerArr: [
+      tableData: [],
+      tableHeader: [
         {
           label: '序号',
           prop: 'sort',
@@ -146,34 +144,34 @@ export default {
           width: '100'
         },
         {
-          label: '物料网号',
-          prop: 'license',
+          label: '月份',
+          prop: 'date',
           width: '120'
         },
         {
-          label: '车辆编号',
-          prop: 'eqCode',
-          width: '100'
+          label: '工作类型',
+          prop: 'eqClassName',
+          // width: '100'
         },
         {
-          label: '车辆名称',
-          prop: 'eqName',
-          width: '100'
+          label: '车辆数量',
+          prop: 'count'
+          // width: '100'
         },
         {
-          label: '车辆类别',
-          prop: 'eqClassName',
+          label: '总工作时长',
+          prop: 'hour',
           width: '100'
         },
         {
-          label: '标准时长',
-          prop: 'duration',
-          width: '80'
+          label: '标准时长',
+          prop: 'duration'
+          // width: '80'
         },
         {
-          label: `运转率`,
+          label: `车辆运转率`,
           prop: 'runningRate',
-          width: '140'
+          width: '150'
         }
       ]
     }
@@ -181,11 +179,53 @@ export default {
   created() {
     this.getPasture()
     this.getTableList()
+    this.getWorks()
   },
   methods: {
+    tableRowClassName({row, rowIndex}) {
+        if (row.isFirst == true) {
+          return 'success-row'
+        }
+        return ''
+      },
+    // 给数组分第一个值打标签
+    markFirstObjectByName(data) {
+      // Step 1: Categorize by name
+      const categorizedData = data.reduce((acc, obj) => {
+        if (!acc[obj.pastureName]) {
+          acc[obj.pastureName] = []
+        }
+        acc[obj.pastureName].push(obj)
+        return acc
+      }, {});
+
+      // Step 2: Mark the first item in each category
+      const result = []
+      for (const name in categorizedData) {
+        if (categorizedData.hasOwnProperty(name)) {
+          const items = categorizedData[name]
+          if (items.length > 0) {
+            items[0].isFirst = true // 标记第一个对象
+          } else {
+            items[0].isFirst = false
+          }
+          result.push(...items)// 将分类的对象合并到结果数组中
+        }
+      }
+
+   return result
+},
+
+    // 获取工作类别的数据
+    async getWorks() {
+      const data = await getWorkList()
+      this.workList = data.data
+      console.log(data, '工作列表')
+    },
     // 点击
     chosePasture(val) {
-      this.getdataListParm.pastureId = val
+      this.getdataListParm.pastureId = this.findAllPasture.find(item => item.id == val).id
+      console.log(val, this.getdataListParm.pastureId, 'hss')
     },
     // 点击搜索
     handlerSerch() {
@@ -202,16 +242,19 @@ export default {
     // 获取列表数据
     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
+      const { data } = await getVehicRateTotal(this.getdataListParm)
+      if (data) {
+        data.list.length &&
+            data.list.forEach((item, index) => {
+              item.sort = index + 1
+              item.runningRate = `${item.runningRate}%`
+            })
+        const arr= JSON.parse(JSON.stringify(data.list))
+        this.total = data.total
+        this.tableData = this.markFirstObjectByName(arr);
+        console.log(this.tableData,'this.tableData')
+      }
       this.loading = false
-      console.log(this.tableHeader, 'tableHeader')
     },
 
     //  获取当前月份的天数
@@ -232,8 +275,9 @@ export default {
     // 导出功能
     handleDownload() {
       this.getdataListParm.pagecount = 9999
-      getVehicRate(this.getdataListParm).then((res) => {
+      getVehicRateTotal(this.getdataListParm).then((res) => {
         const { data } = res
+        this.getdataListParm.pagecount = 10
         data.list.length &&
           data.list.forEach((item, index) => {
             item.sort = index + 1
@@ -295,4 +339,8 @@ export default {
   // white-space: pre;
   white-space: pre-wrap; // 也行。
 }
+
+/deep/  .el-table .success-row {
+    background: #daeffe;
+  }
 </style>

+ 2 - 2
src/views/report/vehiclUtilizaRate/index.vue

@@ -53,7 +53,7 @@
       style="width: 99%; margin-top: 30px"
       max-height="590px"
       v-loading="loading"
-      element-loading-text="数据中在加载中"
+      element-loading-text="数据正在加载..."
       ref="table"
     >
       <template v-for="(item, index) in tableHeader">
@@ -114,7 +114,7 @@ export default {
         pagecount: 10,
         offset: 1,
         pastureId: parseInt(Cookies.get('pastureid')),
-        pastureName: Cookies.get('pasturename'),
+        // pastureName: Cookies.get('pasturename'),
         date: parseTime(new Date(), '{y}-{m}'), // 日期
         eqCode: ''
       },

Some files were not shown because too many files changed in this diff