<template>
  <!-- 项目管理 项目附件 -->
    <div class="ProjectManagement4">
      <div class="vfpHeader">
      <!-- 详情页 -->
        <div class="titleOne">项目管理</div>
        <div class="smallTitle" style="left: 100px;">项目进展详情</div>
        <el-button type="primary" @click="back">返回</el-button>
    </div>
      <hr>
       <!-- 跳转导航开始 -->
       <div class="AppBar">
        <div @click="content">项目基本内容</div>
        <div @click="remark">项目详情</div>
        <div @click="remark2">活动开展</div>
        <div class="AppBarActive">项目附件</div>
        <div @click="remark5">项目结题附件</div>
      </div>
      <!-- 跳转导航结束 -->
      <div class="pmInp">
          <!-- <el-button type="primary" class="btn"  size="mini">上传文件</el-button> -->
          <beUpload @getFile="getFile"  :navName="'上传文件'" :accept="accept"></beUpload>

        </div>
        <!-- 表格开始 -->
        <el-table
        :data="tableData"
        tooltip-effect="dark"
        stripe
        style="height: 550px;"
        class="fontSize"
        :header-cell-style="{ background: '#f2f2f2',color:'#000' }"
        >
       

        <!-- <el-table-column
          prop="title"
          label="活动名称"
          align="center"
          >
        </el-table-column> -->

        <el-table-column
          prop="fileName"
          label="活动中期报告"
          align="center"
          >
        </el-table-column>
        
        <el-table-column
          prop="size"
          label="大小"
          align="center"
          >
        </el-table-column>
       
        <el-table-column
          prop="uploadTime"
          label="时间"
          align="center"
          >
        </el-table-column>

        <el-table-column
          prop="operation"
          align="center"

          label="操作"
          >
          <template #default="scope">
              <div class="operations">
                      <el-button type="primary" class="bt1" size="mini" @click="lookDetails(scope.rows.id)" style="background: #477edd">详情查看</el-button>
              </div>
          </template>
        </el-table-column>
        </el-table>
        <!-- 表格结束 -->

        <!-- 分页 -->
        <el-pagination
            @current-change="handleCurrentChange"
            :current-page="table.currentPage"
            :page-size="table.packageSize"
            layout=" prev, pager, next"
            background
            class="pagination"
            :total="table.total">
          </el-pagination>
        <!-- 分页结束 -->
    </div>
  </template>
  
  <script>
  import beUpload from '../../components/tool/beUpload'

      export default {
        components:{beUpload},
        data() {
          return {
          accept:".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",
            table:{         // 分页数据
              total:0,
              packageSize:8,
              currentPage:1
            }, 
            tableData:[],
          }
        },
        methods:{
          getFile(val) {    //上传文件
            this.file = val;
            let oldData = [];
            this.tableData.forEach(item=>oldData.push(item))
            oldData.push(val)
          
            let param={
                uid:this.$store.state.userInfo.userid,
                cid:JSON.parse(localStorage.getItem('pid')),
                projectFile:JSON.stringify(oldData)
            }
            this.ajax
                  .post(this.$store.state.api+'/AddProjectFile',param)
                  .then(res=>{
                    // console.log(res);
                    if (res.data==1) {
                      this.$message.success('上传成功')
                      this.getData()
                    }else{
                      this.$message.error('上传失败')
                    }
                    
                  },err=>{
                    console.log(err);
                  })
          },
          handleCurrentChange(val) {   //当页数发生改变的时候调用获取列表数据请求
          // console.log(`当前页: ${val}`);
          this.table.currentPage=val
          this.getData()
        },
          getData(){       //获取基础信息
              let param={
                uid:this.$store.state.userInfo.userid,
                pid:JSON.parse(localStorage.getItem('pid')),
                page:this.table.currentPage,
                lim:this.table.packageSize
              }
              // console.log(param);
              this.ajax
                    .get(this.$store.state.api+'/SelectProjectFile',param)
                    .then(res=>{
                      // console.log(res.data);
                      let k=[]
                      res.data[0].forEach((e,i) => {
                        // console.log(e);
                        let { projectFile: l } = e;
                        // console.log(l);
                        k=JSON.parse(l)
                      });
                      // console.log(k);
                      this.tableData=k
                    },err=>{
                      console.log(err);
                    })
          },
          content(){
            this.$router.push('/ProjectManagement1')
          },
          remark(){
            this.$router.push('/ProjectManagement2')
          },
          remark2(){
            this.$router.push('/ProjectManagement3')
          },
      
          remark5(){
            this.$router.push('/ProjectManagement5')
          },
          
          backBtn2(){
            this.$router.push('/ProjectManagement1')
          },
          lookDetails(){
            console.log(111);
          },
          back(){
            this.$router.push('/ProjectManagement')
          },
        },
        mounted(){
          this.getData()
        }
      }
  </script>
  
  <style lang="less">
  .ProjectManagement4{
    .pagination{
      float: right;
      margin: 20px 55px 10px;
    }
  

   
    .pm1Tit{
        display: flex;
        margin-left: 20px;
        div{
          width: 130px;
          cursor: pointer;
          font-weight: 550;
        }
        .pr1TitBass{
          height: 2px;
          width: 100%;
          background: #3D67BC;
        }
    }
    .pmInp{
      width: 100%;
      display: flex;
      margin: 10px 0 10px 0;
      justify-content: flex-end;
      .btn{
        height: 30px;
        width: 100px;
        font-size: 16px !important;
        background: #477edd;
        margin-left: 10px;
      }
    }
    
  }
   
  </style>