<template>
  <div>
    <div class="home">
      <breadCrumb :breads = "breads"></breadCrumb>
      <changeNav :navs="navs"></changeNav>
      <div class="flex-item icon-style">
        <i class="el-icon-warning" style="margin:0 10px"></i>
        <div>若已购标请联系平台方审核，若未购标请及时购买，客服电话：400-6666-6666.</div>
      </div>
      <div class="flex-arround info">
        <div>项目标号:{{projectCode}}</div>
        <div>项目名称:{{projectName}}</div>
        <div>标书获取结束时间:2018-08-08 18:23</div>
      </div>
      <dataTable :table-data="files" :columns = "columns" :is-pageobj="false" style="marginBottom:100px">
        <el-table-column slot="operate" label="操作" fixed="right" width="100"> 
          <template slot-scope = "scope">
            <el-button type="text" align="center"  v-if="scope.row.operation=='无权限'">无权限</el-button>
			<el-button type="text" align="center" @click="isDown(scope.row.fileUrl,scope.row.id)" v-else>下载</el-button>
          </template>
        </el-table-column>
      </dataTable>
    </div>
  </div>
</template>

<script>
	import {bidBooklist,downLoad} from '@api/supply/bid'
import dataTable from '@components/nopageTable.vue'
import changeNav from '@components/changeNav.vue'
import breadCrumb from '@components/dataBreadcrumb.vue'
export default {
  components: {
    dataTable,
    breadCrumb,
    changeNav
  },
  data() {
    return {
      navs: ['标书费缴纳管理'],
      files: [],
      breads: ['投标管理', '我参与的项目', '工作台'],
      columns: [{
        label: '文件名称',
        prop: 'fileName'
      },
      {
        label: '文件大小',
        prop: 'fileSize'
      },
      {
        label: '文件类型',
        prop: 'type'
      },
      {
        label: '价格(元)',
        prop: 'price'
      }, {
        slot: 'operate'
      }],
	  projectName:"",
	  projectCode:""
    }
  },
  created() {
  	this.getbidBooklist()
	this.projectName=localStorage.getItem("projectName")
	this.projectCode=localStorage.getItem("projectCode")
  },
  methods:{
	  //  检测是否能下载
	 async isDown(url,id){
		 try {
			 let data={}
			data.bidBookId=id
		   data.projectId=localStorage.getItem("projectId")
		   const {
		     msg,
		     code
		   } = await downLoad(data)
		   if (code === 200) {
			  window.open(url)
		   }else{
			   this.$message.error(msg)
		   }
		 } catch (e) {
		   console.log(e)
		 } 
	  },
	  // 获取列表
	    async getbidBooklist() {
	        try {
			  let message={}
			  message.projectId=localStorage.getItem("projectId")
			  message.companyId=localStorage.getItem("companyId")
	          const {
	            data,
	            code
	          } = await bidBooklist(message)
	          if (code === 200) {
				  console.log(data)
	            this.files = data
	          }
	        } catch (e) {
	          console.log(e)
	        }
	      }
  }
}
</script>

<style scoped>
.home{
    padding:30px;
    box-sizing: border-box;
    background: #fff;
}
.font-buttom{
    font-size: 14px;
    border-bottom:2px solid blue;
    width:100px;
}
.icon-style{
	padding:5px 0;
    border:1px orange solid;
    background: #bfa;
}
.info>div{
    font-size: 16px;
}
.info{
	margin:20px 0
}
</style>
