最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Avue實現(xiàn)動態(tài)查詢與數(shù)據(jù)展示的示例代碼

 更新時間:2024年08月20日 11:22:38   作者:碼農(nóng)研究僧  
Avue是一個基于Vue.js的前端框架,它是由阿里云開發(fā)的一款企業(yè)級UI組件庫,旨在提供一套全面、易用且高性能的界面解決方案本文介紹了Avue實現(xiàn)動態(tài)查詢與數(shù)據(jù)展示的示例,需要的朋友可以參考下

下面是一個前端查詢頁面的總結(jié),包括Demo示例和注釋

1. 基本知識

數(shù)據(jù)展示配置 (optiontotal, datatotal, totalPage)

<avue-crud
  :option="optiontotal"
  :data="datatotal"
  :page="totalPage"
  @on-load="loadPage">
  <!-- 插槽模板 -->
  <template slot-scope="scope" slot="menu">
    <el-button style="margin-left:10px;" size="small" type="text" @click.native="showDetail(scope.row)">查看</el-button>
  </template>
  <template slot-scope="scope" slot="remainCapacity" class="el-progress-bar__innerText">
    <el-progress :text-inside="true" :stroke-width="24" :color="percentageStyle(scope.row.remainCapacity)" :percentage="scope.row.remainCapacity"></el-progress>
  </template>
</avue-crud>
  • :option="optiontotal":配置avue-crud組件的顯示選項,如表格列的定義、是否顯示刪除、編輯、添加按鈕等
  • :data="datatotal": 綁定要顯示的數(shù)據(jù),通常是從API獲取的結(jié)果數(shù)組
  • :page="totalPage":配置分頁信息,包括當前頁碼、每頁大小、總記錄數(shù)等
  • @on-load="loadPage": 當數(shù)據(jù)需要加載時調(diào)用loadPage方法,通常用于處理分頁和數(shù)據(jù)加載

基本的注意事項如下:

  • 分頁參數(shù):
    確保分頁參數(shù)(currentPage和pageSize)正確傳遞,并與后端API的分頁要求一致
    在分頁變化時(如頁碼變動),需要重新加載數(shù)據(jù)以反映當前頁的數(shù)據(jù)

  • 數(shù)據(jù)綁定:
    :data="datatotal"綁定的數(shù)據(jù)應確保格式正確,并與表格列定義中的prop屬性一致
    數(shù)據(jù)中每一項的字段名稱應與optiontotal中定義的列字段一致,以確保數(shù)據(jù)能正確顯示

  • 插槽使用:
    slot="menu"用于自定義行操作按鈕,如“查看”按鈕
    slot="remainCapacity"用于自定義進度條顯示,動態(tài)設(shè)置顏色和百分比,提供直觀的設(shè)備狀態(tài)反饋

2. Demo

以下為充電樁的實時動態(tài)數(shù)據(jù),通過PLC實時傳輸?shù)綌?shù)據(jù)庫中,對應這個頁面動態(tài)查詢數(shù)據(jù)即可

整體界面邏輯如下:

  1. 組件初始化:在組件掛載時,啟動定時器每30秒自動刷新數(shù)據(jù)
  2. 查詢功能
    -搜索:根據(jù)輸入的條件(如車輛名稱)查詢數(shù)據(jù)并更新展示
    -重置:重置表單字段和查詢條件,重新加載數(shù)據(jù)
  3. 數(shù)據(jù)顯示:通過avue-crud組件展示車輛信息,包括車輛名稱、狀態(tài)、充電槍狀態(tài)、電池溫度、剩余電量和更新時間等
  4. 詳情查看:點擊“查看”按鈕時,跳轉(zhuǎn)到設(shè)備詳情頁面,并將設(shè)備名稱作為查詢參數(shù)傳遞
  5. 設(shè)備詳情對話框:顯示設(shè)備詳細信息的對話框(在此例中為空)
<template>
  <div>
    <basic-container>
      <!-- 查詢表單 -->
      <el-form :inline="true" ref="formInline" :model="formInline" label-width="150px">
        <el-form-item label="車輛名稱">
          <el-input v-model="formInline.deviceName" placeholder="請輸入車輛名稱"></el-input>
        </el-form-item>
        
        <el-form-item>
          <el-button type="primary" size="small" @click="onSearch">查詢</el-button>
          <el-button size="small" @click="resetForm('formInline')">重置</el-button>
        </el-form-item>
      </el-form>

      <!-- 數(shù)據(jù)展示卡片 -->
      <el-card class="box-card">
        <div class="clearfix">
          <span>總數(shù)為:{{totalPage.total}}輛</span>
          <avue-crud
            :option="optiontotal"
            :data="datatotal"
            :page="totalPage"
            @on-load="loadPage">
            <!-- 查看按鈕模板 -->
            <template slot-scope="scope" slot="menu">
              <el-button style="margin-left:10px;" size="small" type="text" @click.native="showDetail(scope.row)">查看</el-button>
            </template>
            <!-- 剩余電量進度條模板 -->
            <template slot-scope="scope" slot="remainCapacity" class="el-progress-bar__innerText">
              <el-progress :text-inside="true" :stroke-width="24" :color="percentageStyle(scope.row.remainCapacity)" :percentage="scope.row.remainCapacity"></el-progress>
            </template>
          </avue-crud>
        </div>
      </el-card>
    </basic-container>

    <!-- 設(shè)備詳情對話框 -->
    <el-dialog title="設(shè)備詳情" :append-to-body='true' :visible="detailVisible" @close="closeDetialDialog"></el-dialog>
  </div>
</template>

<script>
import { getDeviceRealList } from "@/api/equipment/chargingSchedule/devicereal";

export default {
  data() {
    return {
      timer: null,
      detailVisible: false,
      query: {},
      totalPage: {
        pageSize: 20,
        currentPage: 1,
        total: 0
      },
      formInline: {
        deviceName: ''
      },
      datatotal: [],
      optiontotal: {
        height: 'auto',
        calcHeight: 95,
        fit: true,
        border: true,
        delBtn: false,
        editBtn: false,
        addBtn: false,
        menuWidth: 100,
        highlightCurrentRow: true,
        column: [
          {
            label: '車輛名稱',
            prop: 'deviceName'
          },
          {
            label: '車輛狀態(tài)',
            prop: 'vehicleStatus',
            dicData: [
              { label: '啟動', value: '01' },
              { label: '熄火', value: '02' },
              { label: '充電', value: '03' },
              { label: '離線', value: '99' }
            ]
          },
          {
            label: '充電槍狀態(tài)',
            prop: 'chargeGun',
            dicData: [
              { label: '未連接', value: '00' },
              { label: '已連接', value: '11' }
            ]
          },
          {
            label: '電池系統(tǒng)溫度(℃)',
            prop: 'batteryTemp'
          },
          {
            label: '剩余電量(%)',
            prop: 'remainCapacity',
            slot: true
          },
          {
            label: '更新時間',
            prop: 'infoUpdateTime',
            width: '150'
          },
          {
            label: '時間差值(天)',
            prop: 'timeDifferenceDay',
            width: '70',
            formatter: (row) => this.calculateTimeDifference(row.infoUpdateTime)
          }
        ]
      }
    };
  },
  computed: {
    currentTime() {
      return new Date();
    }
  },
  mounted() {
    // 定時刷新頁面
    this.timer = setInterval(() => {
      setTimeout(() => this.loadPage(this.totalPage, this.query), 0);
    }, 1000 * 30);
  },
  methods: {
    calculateTimeDifference(updateTime) {
      const updateTimeObj = new Date(updateTime);
      const timeDifference = this.currentTime - updateTimeObj; // 時間差值,單位為毫秒
      const dayDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
      return dayDifference;
    },
    onSearch() {
      let searchInfo = {
        deviceName: this.formInline.deviceName === '' ? null : this.formInline.deviceName
      };
      this.totalPage.currentPage = 1;
      this.loadPage(this.totalPage, searchInfo);
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
      this.formInline.deviceName = null;
      this.onSearch();
    },
    showDetail(row) {
      this.$router.push({ path: '/equipment/chargingSchedule/deviceInfoVisual', query: { deviceName: row.deviceName } });
    },
    loadPage(page, params = {}) {
      getDeviceRealList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        const data = res.data.data;
        this.totalPage.total = data.total;
        this.datatotal = data.records;
      });
    },
    percentageStyle(percentage) {
      if (percentage <= 20) return '#CD0000';
      if (percentage > 20 && percentage <= 40) return '#FF0000';
      if (percentage > 80) return '#32CD32';
      if (percentage > 60 && percentage <= 80) return '#EEEE00';
      if (percentage <= 60 && percentage > 40) return '#EEC900';
    },
    closeDetialDialog() {
      this.detailVisible = false;
    }
  }
}
</script>

<style>
.el-progress-bar__innerText {
  color: #0b0a0a;
  font-size: 12px;
  margin: 0px 5px;
}
</style>

最終界面如下所示:

到此這篇關(guān)于Avue實現(xiàn)動態(tài)查詢與數(shù)據(jù)展示的示例代碼的文章就介紹到這了,更多相關(guān)Avue動態(tài)查詢與數(shù)據(jù)展示內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Django+Vue.js實現(xiàn)搜索功能

    Django+Vue.js實現(xiàn)搜索功能

    本文主要介紹了Django+Vue.js實現(xiàn)搜索功能,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2024-06-06
  • vue-mounted中如何處理data數(shù)據(jù)

    vue-mounted中如何處理data數(shù)據(jù)

    這篇文章主要介紹了vue-mounted中如何處理data數(shù)據(jù)方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • vue實現(xiàn)前端展示后端實時日志帶顏色示例詳解

    vue實現(xiàn)前端展示后端實時日志帶顏色示例詳解

    這篇文章主要為大家介紹了vue實現(xiàn)前端展示后端實時日志帶顏色示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-11-11
  • vue的style綁定background-image的方式和其他變量數(shù)據(jù)的區(qū)別詳解

    vue的style綁定background-image的方式和其他變量數(shù)據(jù)的區(qū)別詳解

    今天小編就為大家分享一篇vue的style綁定background-image的方式和其他變量數(shù)據(jù)的區(qū)別詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • 用Vue實現(xiàn)頁面訪問攔截的方法詳解

    用Vue實現(xiàn)頁面訪問攔截的方法詳解

    大家在做前端項目的時候,大部分頁面, 游客都可以直接訪問 , 如遇到 需要登錄才能進行的操作,頁面將提示并跳轉(zhuǎn)到登錄界面,那么如何才能實現(xiàn)頁面攔截并跳轉(zhuǎn)到對應的登錄界面呢,本文小編就來給大家介紹一下Vue實現(xiàn)頁面訪問攔截的方法,需要的朋友可以參考下
    2023-08-08
  • Vue3 實現(xiàn)文件上傳功能

    Vue3 實現(xiàn)文件上傳功能

    在Vue3中實現(xiàn)文件上傳功能,你可以使用多種方法,包括使用原生的HTML <input type="file">元素,或者使用第三方庫如?axios和vue-axios來處理文件上傳,本文給大家介紹Vue3 實現(xiàn)文件上傳功能,感興趣的朋友一起看看吧
    2025-07-07
  • Vue-router 中hash模式和history模式的區(qū)別

    Vue-router 中hash模式和history模式的區(qū)別

    這篇文章主要介紹了Vue-router 中hash模式和history模式的區(qū)別,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-07-07
  • Vue生命周期函數(shù)調(diào)用詳解

    Vue生命周期函數(shù)調(diào)用詳解

    這篇文章主要介紹了Vue生命周期函數(shù)調(diào)用詳解,本文將實現(xiàn)Vue生命周期相關(guān)代碼的核心邏輯,從源碼層面來理解生命周期,感興趣的小伙伴可以參考一下
    2022-08-08
  • VUE+Element環(huán)境搭建與安裝的方法步驟

    VUE+Element環(huán)境搭建與安裝的方法步驟

    這篇文章主要介紹了VUE+Element環(huán)境搭建與安裝的方法步驟,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-01-01
  • 利用vue實現(xiàn)密碼輸入框/驗證碼輸入框

    利用vue實現(xiàn)密碼輸入框/驗證碼輸入框

    這篇文章主要為大家詳細介紹了如何利用vue實現(xiàn)密碼輸入框或驗證碼輸入框的效果,文中的示例代碼講解詳細,感興趣的小伙伴可以參考一下
    2023-08-08

最新評論

湟中县| 都江堰市| 满城县| 广灵县| 灌云县| 闵行区| 手机| 杭锦后旗| 土默特右旗| 廉江市| 上栗县| 乐都县| 淮阳县| 泽普县| 齐河县| 平阴县| 礼泉县| 盘山县| 尉氏县| 宣汉县| 伊宁县| 赤峰市| 福清市| 高密市| 溆浦县| 什邡市| 简阳市| 蒙自县| 霍城县| 西和县| 张掖市| 元谋县| 延川县| 思南县| 剑川县| 江北区| 龙游县| 沙田区| 自治县| 涟源市| 西丰县|