	<template>
  <div>
    <div class="content">
      <dataBreadcrumb :breads="breads"></dataBreadcrumb>
      <changeNav :navs="navs"></changeNav>
      <div class="set">
        <div class="flex-between">
          <div>项目编号：{{projectCode}}</div>
          <div>项目名称：{{projectName}}</div>
        </div>
        <div class="flex-between">
          <div>开标时间：{{openBidTime}}</div>
          <div>项目状态：{{projectStatus}}</div>
        </div>
        <div>
          <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
            <div class="flex-between">
              <el-form-item label="解密时限" prop="decodeTime">
                <el-input v-model="ruleForm.decodeTime" style="width: 250px;"   onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入分钟数"></el-input>
              </el-form-item>
              <el-form-item label="签名时限" prop="signatureTime">
                <el-input v-model="ruleForm.signatureTime" style="width: 250px;"  onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入分钟数"></el-input>
              </el-form-item>
            </div>
            <div>
              <el-form-item label="开标人" prop="bidOpener">
                <el-select v-model="ruleForm.bidOpener" placeholder="请选择" style="width: 250px;">
                  <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </div>
            <div class="flex-between">
              <el-form-item label="监标人" prop="supervisionerList">
                <el-select v-model="ruleForm.supervisionerList" multiple placeholder="请选择" style="width: 250px;">
                 <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="序列人员" prop="delegaterList">
                <el-select v-model="ruleForm.delegaterList" multiple placeholder="请选择" style="width: 250px;">
                  <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </div>
          </el-form>
          <div style="width:200px;margin:100px auto">
            <el-button @click="cancle">取消</el-button>
            <el-button type="primary" @click="submitData">保存</el-button>
          </div>
        </div>

      </div>
    </div>
  </div>
</template>
<script>
	import { bidsetting} from '@api/purchaser/bid'
	import { timeInfo} from '@api/supply/bid'
	import { opener,mamager} from '@api/common/list'
import dataTable from '@components/dataTable.vue'
import dataBreadcrumb from '@components/dataBreadcrumb.vue'
import changeNav from '@components/changeNav.vue'
export default {
  components: {
    dataTable,
    changeNav,
    dataBreadcrumb
  },
  data() {
    return {
		projectStatus:"",
      options: [],
	  bidOpeners:[],
      ruleForm: {
        decodeTime: '',
        signatureTime: '',
        pereson: '选项2',
        bidOpener: '',
        supervisionerList: '',
        delegaterList: ''
      },
      rules: {
        signatureTime: [{
          required: true,
          message: '请输入时间',
          trigger: 'blue'
        }],
        decodeTime: [{
          required: true,
          message: '请输入时间',
          trigger: 'blue'
        }],
        bidOpener: [{
          required: true,
          message: '请输入',
          trigger: 'change'
        }]
      },
      navs: ['开标设置'],
      breads: ['招标管理', '招标项目管理', '工作台'],
	  projectCode:"",
	  projectName:"",
	  openBidTime:""
    }
  },
  created() {
	  this.projectCode=localStorage.getItem("projectCode")
	  this.projectName=localStorage.getItem("projectName")
	  this.projectStatus=localStorage.getItem("projectStatus")
  	this.getopener()
	this.getmamager()
	this.gettimeInfo()
  },
  methods: {
    cancle() {
      this.$router.go(-1)
    },
	  async gettimeInfo() {
		    let projectId=localStorage.getItem("projectId")
	        const {
	          data,
	          code
	        } = await timeInfo(projectId)
			this.openBidTime=data.openBidTime
	    },
	// 获取公司人员列表
	  async getopener() {
		  let companyId=localStorage.getItem("companyId")
	        const {
	          data,
	          code
	        } = await opener(companyId)
	        if (code === 200) {
	          this.options=data
	        }
	    },
	// 获取该项目下的项目经理
	async getmamager() {
			  let projectId=localStorage.getItem("projectId")
	      const {
	        data,
	        code
	      } = await mamager(projectId)
	      if (code === 200) {
	         this.ruleForm.bidOpener=data
	      }
	  },
	  //提交表单
	  async submitData() {
	        try {
	          const valid = await this.$refs['ruleForm'].validate()
	          if (valid) {
				  let message=this.ruleForm
				  message.projectId=localStorage.getItem("projectId")
	            const { code,msg } = await bidsetting(message)
	            if (code === 200) {
	               this.$message({
	                            message: msg,
	                            type: 'success',
	              			  duration:1500
	                          })
	              			setTimeout(()=>{
	              				 this.$router.go(-1)
	              	},1500)
	            }
	          }
	        } catch (e) {
	         console.log(e)
	      }
	 }
  }

}
</script>

<style scoped>
	.set {
		width: 50%;
		margin: 50px auto;
	}

	.set>div {
		margin-bottom: 50px;
	}

</style>
