<template>
  <div>
    <el-dropdown :hide-on-click="false" @command="handleCommand">
      <span class="el-dropdown-link">
        <el-button size="small" type="primary" >新 建</el-button>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="项目协议">项目协议</el-dropdown-item>
        <el-dropdown-item command="居间协议">居间协议</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
    <!--居间协议-->
    <IntermediationAgreement :drawerShow="intermediationShow" v-if="intermediationShow"></IntermediationAgreement>
    <!--经销协议-->
    <DistributionProjectAgreement :drawerShow="distributionProjectShow" v-if="distributionProjectShow"></DistributionProjectAgreement>
    <!--直销协议-->
    <DirectSalesProjectAgreement :drawerShow="directSalesProjectShow" v-if="directSalesProjectShow"></DirectSalesProjectAgreement>
  </div>
</template>

<script>
import IntermediationAgreement from "@/HDrpManagement/projectChange/modules/modules/contract/components/IntermediationAgreement";
import DistributionProjectAgreement from "@/HDrpManagement/projectChange/modules/modules/contract/components/DistributionProjectAgreement";
import DirectSalesProjectAgreement from "@/HDrpManagement/projectChange/modules/modules/contract/components/DirectSalesProjectAgreement";
export default {
  name: "add",
  props:["data"],
  components:{IntermediationAgreement,DistributionProjectAgreement,DirectSalesProjectAgreement},
  data(){
    return {
      intermediationShow:false,
      distributionProjectShow:false,
      directSalesProjectShow:false,
      flag:0,
    }
  },
  methods:{
    handleCommand(val){
      console.log(val)
      if (val === '居间协议'){
        this.intermediationShow = true
        this.distributionProjectShow = false
        this.directSalesProjectShow = false
      }else {
        if (this.flag === 1){
          this.distributionProjectShow = true
          this.directSalesProjectShow = false
          this.intermediationShow = false
        }else if(this.flag === 2) {
          this.directSalesProjectShow = true
          this.intermediationShow = false
          this.distributionProjectShow = false
        }
      }
    },
    /*标签查询*/
    async queryTag(){
      this.flag = 0
      const res = await this.$api.requested({
        "id": 20220929085401,
        "content": {
          "ownertable":'sa_project',
          "ownerid":this.data.sa_projectid
        }
      })
      console.log(res,"标签数据")
      if (res.data.datatag.length !== 0){
        for (let i=0;i<res.data.datatag.length;i++){
          if (res.data.datatag[i] === '经销'){
            this.flag = 1
            break
          }else if (res.data.datatag[i] === '直销'){
            this.flag = 2
            break
          }
        }
      }
      console.log(this.flag,"是否经销")
    }
  },
  mounted() {
    this.queryTag()
  }
}
</script>

<style scoped>

</style>