<template>
  <div class="updates pagePadding" style="padding-top: 25px">
    <div
      v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
    >
      <el-table
        :data="tableData"
        v-loading="loading"
        border
        :size="size"
        stripe
        style="width: 100%"
      >
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form
              :size="size"
              label-position="top"
              inline
              class="demo-table-expand"
            >
              <el-form-item label="更新内容">
                <p v-html="props.row.system"></p>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column label="版本号" prop="version"> </el-table-column>
        <el-table-column label="更新模块" prop="module"> </el-table-column>
        <el-table-column label="更新时间" prop="addtime"> </el-table-column>
      </el-table>
      <div
        class="Pagination"
        style="text-align: right; margin-top: 10px"
        v-show="count > 0"
      >
        <el-pagination
          :size="searchSize"
          @size-change="handleSizeChange"
          @current-change="handlePageChange"
          :current-page="parmValue.page"
          :page-sizes="[15, 50, 100]"
          :page-size="parmValue.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="count"
        ></el-pagination>
      </div>
    </div>
    <no-auth v-else></no-auth>
  </div>
</template>
<script>
import asyncRequest from "@/apis/service/system/updates";
import mixinPage from "@/mixins/elPaginationHandle";
import PeriodDatePicker from "@/components/PeriodDatePicker";
import { mapGetters } from "vuex";
import resToken from "@/mixins/resToken";
export default {
  name: "updates",
  mixins: [mixinPage, resToken],
  components: {
    PeriodDatePicker,
  },
  computed: {
    //组件SIZE设置
    ...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 [];
      }
    },
  },
  data() {
    return {
      loading: true,
      showModel: false,
      isDetail: false,
      modelId: 0,
      parmValue: {
        type: "VER",
        page: 1, // 页码
        size: 15, // 每页显示条数
      },
      count: 0, // 总条数

      // 表格 - 数据
      tableData: [],
    };
  },
  mounted() {
    this.searchList();
  },
  methods: {
    restSearch() {
      this.parmValue = {
        type: "VER",
        page: 1, // 页码
        size: 15, // 每页显示条数
      };
      this.count = 0;
      this.searchList();
    },

    // 刷新表格
    async searchList() {
      this.loading = true;
      const res = await asyncRequest.list(this.parmValue);
      if (res && res.code === 0 && res.data) {
        this.tableData = res.data.list;
        this.count = Number(res.data.count);
      } else if (res && res.code >= 100 && res.code <= 104) {
        await this.logout();
      } else {
        this.tableData = [];
        this.count = 0;
      }
      this.loading = false;
    },
  },
};
</script>

<style lang="scss" scoped>
</style>






