<template>
  <div>
    <div class="content">
      <dataTable  :columns="columns" :page-obj="pageObj" :breads="breads" :checklist="checklist" url="/tender-project/list">
        <el-button slot="moreButton" type="primary" style="margin-left: 50px;" @click="handlerelease">发布项目</el-button>
       <el-table-column slot="operate" label="项目类型" align="center" fixed="right" width="100">
         <template slot-scope="scope">
          <div v-if="scope.row.bidType==0">公开招标</div>
		   <div v-else>邀请招标</div>
         </template>
       </el-table-column>
	   <el-table-column slot="operate" label="备注" align="center" fixed="right" width="100">
         <template slot-scope="scope">
          <div>{{scope.row.remark?scope.row.remark:'空'}}</div>
         </template>
       </el-table-column>
		<el-table-column slot="operate" label="操作" align="center" fixed="right" width="100">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="examine(scope.row)">工作台</el-button>
          </template>
        </el-table-column>
      </dataTable>
    </div>
  </div>
</template>

<script>
import {projectStatusList} from '@api/common/list'
import dataTable from '@components/dataTable.vue'

export default {
  name: 'bidingList',
  components: {
    dataTable
  },
  data() {
    return {
      checklist: [{
        title: '项目名称',
        type: 'input',
        model: 'name',
      }, {
        title: '项目类型',
        type: 'select',
        selectlist: [{
          value: '0',
          label: '公开招标'
        }, {
          value: '1',
          label: '邀请招标'
        }],
        change: row => '',
        model: 'type'
      },
      {    
        title: '状态',
        type: 'select',
        selectlist: [],
        change: row => '',
        model: 'status'
      }
      ],
      breads: ['招标管理', '招标项目管理'],
      columns: [{
        label: '项目编号',
        prop: 'projectCode'
      },
      {
        label: '项目名称',
        prop: 'projectName'
      },
      {
        label: '创建时间',
        prop: 'createTime',
        sortable: true
      },
      {
        label: '项目状态',
        prop: 'status'
      },
      {
        slot: 'operate'
      }
      ], // 操作列

      pageObj: {
        size: 10,
        currentPage: 1,
        func: (currentPage) => {
          this.pageTurning(currentPage)
        }
      }
    }
  },
  created(){
	this.pageObj.companyId=localStorage.getItem("companyId");
	this.getprojectStatusList()
  },
  methods: {
	 // 跳转工作台
    examine(row) {
      this.$router.push('/purchaser/bid/workbench')
	  // 存项目信息 ，项目名称，项目编号
	   localStorage.setItem('projectId',row.projectId);
	   localStorage.setItem('projectName',row.projectName);
	   localStorage.setItem('projectCode',row.projectCode);
	    localStorage.setItem('projectStatus',row.status);
    },
    handlerelease(){
      this.$router.push('/purchaser/bid/releaseProject')
    },
	  async getprojectStatusList() {
	      try {
	        const res = await projectStatusList()
			console.log(res)
				for(let item of res){
					item.label=item.name
					item.value=item.id
				}
	          this.checklist[2].selectlist=res
	      } catch (e) {
	        console.log(e)
	      }
	    }
  }
}
</script>

<style scoped>

</style>
