<template>
  <div class="updates pagePadding">
    <div
      v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
    >
      <el-table
        v-loading="loading"
        :data="tableData"
        stripe
        :size="size"
        border
        style="width: 100%"
      >
        <el-table-column
          prop="version"
          label="版本号"
          show-overflow-tooltip
          align="center"
        />
        <el-table-column
          prop="content"
          label="版本内容"
          show-overflow-tooltip
          align="center"
        />

        <el-table-column
          prop="addtime"
          label="更新时间"
          show-overflow-tooltip
          align="center"
        />
      </el-table>
      <div
        v-if="count > 0"
        class="Pagination"
        style="text-align: right; margin-top: 10px"
      >
        <el-pagination
          v-if="count > 0"
          :size="searchSize"
          :current-page="parmValue.page"
          :page-sizes="[10, 15, 20, 30, 40]"
          :page-size="parmValue.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="count"
          @size-change="handleSizeChange"
          @current-change="handlePageChange"
        />
      </div>
    </div>
    <div v-else>
      <no-auth></no-auth>
    </div>
  </div>
</template>
<script>
import mixinPage from "@/mixins/elPaginationHandle";
import asyncRequest from "@/apis/service/system/updates";
import { mapGetters } from "vuex";
export default {
  name: "Updates",
  mixins: [mixinPage],
  data() {
    return {
      loading: true,
      showModel: false,
      isDetail: false,
      modelId: 0,
      parmValue: {
        page: 1, // 页码
        size: 10, // 每页显示条数
      },
      count: 0, // 总条数
      tableData: [],
    };
  },
  computed: {
    ...mapGetters(["tablebtnSize", "searchSize", "size"]),
    powers() {
      let tran =
        this.$store.getters.btnList.find(
          (item) => item.menu_route == "updates"
        ) || {};
      if (tran && tran.action && tran.action.length > 0) {
        return tran.action;
      } else {
        return [];
      }
    },
  },
  mounted() {
    this.searchList();
  },
  methods: {
    restSearch() {
      this.parmValue = {
        page: 1, // 页码
        size: 10, // 每页显示条数
      };
      this.searchList();
    },

    async searchList() {
      this.loading = true;
      const res = await asyncRequest.list(this.parmValue);
      if (res.code === 0 && res.data) {
        this.tableData = res.data.list;
        this.tableData.map((v1) => {
          v1.addtime = v1.addtime.replaceAll(".000", "");
          return v1;
        });
        this.count = Number(res.data.count);
      } else {
        this.tableData = [];
        this.count = 0;
      }
      this.loading = false;
    },
  },
};
</script>
<style lang="scss" scoped>
.updates {
}
</style>
