<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
      <el-form-item label="项目名称" prop="projectName">
        <el-input v-model="queryParams.projectName" placeholder="请输入项目名称" clearable style="width: 240px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <div v-for="(item, index) in projectList" :key="index" class="projectItem" @click="projectDetail(item)">
      <div class="left">
        <p>{{ item.projectName }}</p>
        <p>项目类型：{{ item.projectType }} | 项目地址：{{ item.projectAddress }}</p>
      </div>
      <img src="../../../assets/images/work.svg" alt="">
    </div>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script type="text/ecmascript-6">
import { listCurrentProject } from '@/api/risk/currentProject'
export default {
  name: 'currentProject',
  data() {
    return {
      // 遮罩层
      loading: true,
      projectList: [],
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectName: null,
      },
    }
  },
  created() {
    this.getList();
  },
  mounted() {
  },
  methods: {
    /** 查询基础数据-项目列表 */
    getList() {
      this.loading = true;
      this.queryParams.userId = this.$store.getters.userId
      listCurrentProject(this.queryParams).then((response) => {
        this.projectList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    projectDetail(val) {
      this.$router.push("/risk/currentProject/projectPost/index/" + val.projectId)
    }
  },
}
</script>

<style scoped lang='scss'>
.projectItem {
  width: 100%;
  padding: 25px 120px 25px 30px;
  margin-bottom: 25px;
  border: 2px solid #e6e9f0;
  border-radius: 20px;
  box-shadow: 3px 3px 7px #e6e9f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;

  .left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;

    :first-child {
      color: #3277f5;
      font-size: 18px;
    }
  }
}
</style>
