index.vue 2.52 KB
<template>
  <div class="container">
    <el-tabs type="border-card">
      <el-tab-pane label="同步设备">
        <div class="top-box">
          <div class="nav-title">同步设备</div>
          <el-button type="primary" @click="handleTimeSync">开始同步</el-button>
        </div>
        <div class="table">
          <el-table
            :data="tableData"
            style="width: 100%"
            border
            :header-cell-style="{ background: '#f5f7fa', color: '#909399' }"
          >
            <el-table-column
              prop="ip"
              label="设备ip"
              width=""
            ></el-table-column>
            <el-table-column
              prop="equipmentCode"
              label="设备编号"
              width=""
            ></el-table-column>
            <el-table-column
              prop="lastModifiedTime"
              label="同步时间"
              width=""
            ></el-table-column>
          </el-table>
          <Pagination
            :limit="params.size"
            :page="params.current"
            :total="total"
            class="pagination"
            @pagination="handlePageChange"
          />
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { selectFeederPage } from "@/api/sync";
import { timeSync } from "@/api/udp";
export default {
  data() {
    return {
      tableData: [],
      params: {
        current: 1,
        size: 10,
      },
      total: 0,
    };
  },
  mounted() {
    this.handleSelectFeederPage();
  },
  methods: {
    handlePageChange(pageData) {
      this.params.size = pageData.size;
      this.params.current = pageData.page;
      this.handleSelectFeederPage();
    },

    async handleTimeSync() {
      let res = await timeSync({});
      console.log(res);
      this.$message.success("开始备份");
      this.handleSelectFeederPage();
    },
    async handleSelectFeederPage() {
      let res = await selectFeederPage(this.params);
      this.tableData = res.records;
      this.total = res.total;
    },
  },
};
</script>

<style lang="scss" scoped>
.top-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  .nav-title {
    color: #02a7f0;
    font-size: 20px;
    position: relative;
    padding-left: 16px;
    font-weight: bold;
    line-height: 28px;
  }
  .nav-title::before {
    content: "";
    position: absolute;
    left: 0px;
    top: 1px;
    width: 5px;
    height: 100%;
    background-color: #02a7f0;
    border-radius: 4px;
  }
}
</style>