/*

*/
import { afterTheTrialTabsList } from './tenderBulletinTabsPath'
import { getConstructionProjectById } from '@/api/purchasePlan/taskplan'
import { queryBaseTenderProjectInfo } from '@/api/bidding/biddingProject'// 获取信息
/* api*/
import { queryTenderBailPriceInfo } from '@/api/bidding/bidBulletin'
// tab路由配置url
export const tenderProjectMixin = {
  data() {
    return {
      tenderId: this.$route.query.id, // 项目Id
      projectData: [], // 项目信息
      tenderInfo: [],
      confirmLoading: false, // 暂存、下一步Loding
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      stageId: this.$store.getters.groupId.stageId, // 阶段Id
      bulletinId: this.$route.query.bulletinId, // 公告Id
      baseTenderProjectInfo: []
    }
  },
  created() {
    this.delectTabsList()
    if (this.bulletinId) {
      this.getTenderBailPriceInfo()
    }
  },
  methods: {
    getTenderBailPriceInfo() {
      const data = {
        tenderId: this.tenderId, // 项目Id
        bizId: this.bulletinId, // 公共Id
        bulletinType: this.tenderBase.bulletinType, // 公告类型 21资审公告 01 招标公告
        requestSource: this.requestSource, // 来源 00:资审公告 01:招标公告 02:资格预审通知书 03:资审邀请函 04:后审邀请函
        stageId: this.stageId
      }
      queryTenderBailPriceInfo(data).then((response) => {
        this.tenderInfo = response.data
        this.getBaseTenderProjectInfo() // 项目信息
      })
    },
    // 获取建设项目信息
    getBaseTenderProjectInfo() {
      queryBaseTenderProjectInfo(this.tenderId).then(response => {
        this.baseTenderProjectInfo = response.data
        if (response.data.constructionProjectId) {
          this.getConstructionProjectById(response.data.constructionProjectId)
        }
      }).catch(() => {
      })
    },
    getConstructionProjectById(id) {
      getConstructionProjectById(id).then(res => {
        this.projectData = res.data
        this.isMonitorDeptCode(this.tenderInfo.mediaPartners, this.projectData.monitorDeptCode, this.projectData.proLevelCode)
      }).catch(() => {
      })
    },
    // 是否是行业监管部门 monitorDeptCode 0  、 项目级别 proLevelCode 1 河北省公共平台
    isMonitorDeptCode(mediaPartners, monitorDeptCode, proLevelCode) {
      if (mediaPartners.includes('02') && monitorDeptCode === '0' && proLevelCode === '1') {
        afterTheTrialTabsList.splice(7, 0, {
          name: '交通信息',
          path: '/bidding/projectDrive/bulletin/tabs/tenderBulleInformation-add'
        })
      } else {
        this.delectTabsList()
        // afterTheTrialTabsList.map((item, index) => {
        //   if (item.name === '交通信息') {
        //     afterTheTrialTabsList.splice(index, 1)
        //   }
        // })
      }
      this.$forceUpdate()
    },
    delectTabsList() {
      afterTheTrialTabsList.map((item, index) => {
        if (item.name === '交通信息') {
          afterTheTrialTabsList.splice(index, 1)
        }
      })
    }
  }
}
