<template>
  <a-row :gutter="24">
    <a-col :md="24">
      <a-card :style="cardStyle" :bordered="false">
        <!-- 操作按钮区域 -->
        <div class="table-operator" style="margin-top: 5px">
          <a-button @click="handleAdd" type="primary" icon="plus">发布新版本</a-button>
        </div>
        <!-- table区域-begin -->
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :scroll="scroll"
            :loading="loading"
            @change="handleTableChange"
          >
          </a-table>
        </div>
        <!-- table区域-end -->
        <!-- 表单区域 -->
        <app-version-modal ref="modalForm" @ok="modalFormOk"></app-version-modal>
      </a-card>
    </a-col>
  </a-row>
</template>
<script>
import AppVersionModal from './modules/AppVersionModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { postAction } from '@/api/manage'

export default {
  name: 'AppVersionList',
  mixins: [JeecgListMixin],
  components: {
    AppVersionModal,
  },
  data() {
    return {
      // 表头
      columns: [
        { title: '版本号', dataIndex: 'version', },
        { title: '发布时间', dataIndex: 'createTime', },
        { title: '文件路径', dataIndex: 'url',},
      ],
      url: {
        list: '/apkVersion/list',
      },
    }
  },
  computed: {},
  methods: {
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      this.loading = true
      const url = this.url.list + '?currentPage=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
      postAction(url, {}).then((res) => {
        if (res.code === 200) {
          this.dataSource = res.data.rows
          this.ipagination.total = Number(res.data.total)
          this.tableAddTotalRow(this.columns, this.dataSource)
        } else if (res.code === 510) {
          this.$message.warning(res.data)
        } else {
          this.$message.warning(res.data.message)
        }
        this.loading = false
        this.onClearSelected()
      })
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
