<template>
  <div class="app-container">
      <div class="mb-10">
          <h2 class="page-title mb-5">下载队列</h2>
          <div>*{{$t('文件生成成功后，保留12小时，12小时后自动删除')}}</div>
      </div>
    <!--el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
      <el-form-item :label="$t('文件名称')" prop="fileName">
        <el-input v-model="queryParams.fileName" :placeholder="$t('请输入文件名称')" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{$t('搜索')}}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{$t('重置')}}</el-button>
      </el-form-item>
    </el-form-->

    <el-table v-loading="loading" :data="list">
      <el-table-column :label="$t('下载编号')" align="center" prop="id" width="100" />
      <el-table-column :label="$t('分类')" align="center" prop="type" :show-overflow-tooltip="true"/>
      <!--<el-table-column :label="$t('业务编号')" align="center" prop="type" width="100" /-->
      <el-table-column :label="$t('下载内容')" align="center" prop="fileName" width="100" />
        <el-table-column :label="$t('开始下载时间')" align="center" prop="createTime"  width="150">
            <template slot-scope="scope">
                <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
        </el-table-column>
      <el-table-column :label="$t('下载状态')" align="center" prop="createBy"  width="150">
          <template v-slot:default="{row}">
              {{statusMap[row.status]}}
          </template>
      </el-table-column>
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width" width="200">
        <template slot-scope="scope" >
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleDownload(scope.row)"
                     v-hasPermi="['system:notice:update']">{{$t('下载')}}</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

  </div>
</template>

<script>
import {downloadPage} from "@/api/system/download";
import {parseTime} from "../../../utils/ruoyi";
import Template from "@/views/cms/template/index.vue";

export default {
  name: "Download",
    components: {Template},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      list: [],
      queryParams: {
        pageNo: 1,
        pageSize: 10
      },
        statusMap: {
          0: "待处理",
          1:"处理中",
          2: "处理成功",
          3: "处理失败"
        }
    };
  },
  created() {
    this.getList();
  },
  methods: {
      parseTime,
      handleDownload(row){
        console.log('下载', row)
      },
    /** 查询公告列表 */
    getList() {
      this.loading = true;
      downloadPage(this.queryParams).then(response => {
        this.noticeList = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      }).finally(() => {
        this.loading = false;
      })
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
