<template>
  <div class="app-container">
    <el-card shadow="never">
      <i class="el-icon-tickets"></i>
      <span>数据列表</span>
      <el-button style="float: right" @click="handlePage(null)" size="mini">
        添加资讯
      </el-button>
    </el-card>
    <el-table style="width: 100%" class="table-container" :data="categoryList">
      <el-table-column
        label="序号"
        align="center"
        type="index"
      ></el-table-column>
      <el-table-column label="资讯标题" prop="title" align="center">
        <template slot-scope="scope">
          <el-link type="primary" :underline="false">{{
            scope.row.title
          }}</el-link>
        </template>
      </el-table-column>
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
      ></el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button @click="handlePage(scope.row.id)" type="text" size="small"
            >编辑</el-button
          >
          <el-button @click="handleDelete(scope.row)" type="text" size="small"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { getInformation, handleInformation } from '@/api/front/expressNews';
export default {
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 100
      },
      categoryList: []
    };
  },
  methods: {
    handleSearchList() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    getList() {
      getInformation(this.queryParams).then(({ data }) => {
        this.categoryList = data.list;
        // this.total = data.total
      });
    },
    // 跳转页面
    handlePage(id) {
      this.$router.push({ path: '/front/addExpressNews', query: { id } });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$confirm('确认删除该分类?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(function() {
          row.status = -1;
          return handleInformation(row);
        })
        .then(() => {
          this.getList();
          this.msgSuccess('删除成功');
        });
    }
  },
  created() {
    this.getList();
  }
};
</script>
<style lang="scss" scoped>
// .el-tag + .el-tag {
//   margin-left: 10px;
// }
</style>
