<template>
  <div>
    <el-button size="mini"  type="primary" @click="visible = true" :disabled="disabled">添加项目</el-button>
    <el-drawer
        title="添加项目"
        :visible.sync="visible"
        size="800px"
        direction="rtl"
        append-to-body
        :show-close="false"
        @close="visible = false">
      <div class="drawer__panel">
        <el-row>
            <el-col :span="24">
              <project :visible="visible" v-if="visible" @onProject="onSubmit"></project>
            </el-col>
        </el-row>
      </div>
      <div class="fixed__btn__panel">
        <el-button size="small" @click="visible = false" class="normal-btn-width">取 消</el-button>
<!--        <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>-->
      </div>
    </el-drawer>
  </div>
</template>

<script>
import project from '../../components/projectAdd/project'
export default {
  name: "index",
  components:{project},
  props:["id","year","disabled"],
  data(){
    return {
      dialogTableVisible:false,
      visible:false,
      form:{
        projectname:'',
        sa_projectid:''
      }
    }
  },
  methods:{
    onCancel(){

    },
    async onSubmit(val){
      const res = await this.$api.requested({
        "id": 20220905154102,
        "content": {
          "year": this.year,
          "hrid": this.id,
          /*"sa_salestargetbillid":2,//可不传*/
          "project": [
            {
              "sa_projectid": val.sa_projectid,
            },
          ]
        },
      })
      this.tool.showMessage(res,()=>{
        this.visible = false
        this.$emit("onSuccess")
      })
    },
    projectList(){
      this.visible = true
    },
    onProject(data){
      this.visible = false
      console.log("获取")
      console.log(data)
      this.form.sa_projectid = data.sa_projectid
      this.form.projectname = data.projectname
     /* this.project = data*/
      console.log("项目详细信息")
      console.log(this.project)
    },
  }
}
</script>

<style scoped>
.el-pagination {
  text-align: right;
}
.panel_Target {
  border-top:1px solid #eeeeee;
  padding:5px 5px;
  margin-bottom:0px
}
</style>