<template>
    <div class="mod-config">
      <el-tabs class="tabs" tab-position="left" style="height: 200px;"  type="border-card" v-model="activeName" @tab-click="refreshCurrentTabTable">
        <el-tab-pane label="基本信息"  name="baseInfo" >
          <basicInformation ref="basicInformation"  v-if="getPageIf('baseInfo')"></basicInformation>
        </el-tab-pane>
        <el-tab-pane label="客户信息"  name="customerInfo" v-if="getPageIf('customerInfo')">
          <customerInfo ref="customerInfo"  ></customerInfo>
        </el-tab-pane>
        <el-tab-pane label="包装信息"  name="packageInfo" v-if="getPageIf('packageInfo')">
          <packageInfo ref="packageInfo"></packageInfo>
        </el-tab-pane>
        <el-tab-pane label="材料信息"  name="bom" v-if="getPageIf('bom')">
          <bom ref="bom"></bom>
        </el-tab-pane>
        <el-tab-pane label="工艺信息"  name="routing" v-if="getPageIf('routing')">
          <routing ref="routing"></routing>
        </el-tab-pane>
        <el-tab-pane label="TP工程师填写信息"  name="tpInfo" v-if="getPageIf('tpInfo')">
          <tpInfo ref="tpInfo"></tpInfo>
        </el-tab-pane>
        <el-tab-pane label="产品技术要求"  name="technicalRequirement" v-if="getPageIf('technicalRequirement')">
          <technicalRequirement ref="technicalRequirement"></technicalRequirement>
        </el-tab-pane>
        <el-tab-pane label="图稿信息"  name="drawing" v-if="getPageIf('drawing')">
          <drawing ref="drawing"></drawing>
        </el-tab-pane>
          <el-tab-pane label="PE确认信息"  name="PEConfirm" v-if="getPageIf('PEConfirm')">
          <PEConfirm ref="PEConfirm"></PEConfirm>
        </el-tab-pane>
        <el-tab-pane label="印前"  name="prepress" v-if="getPageIf('prepress')">
          <prepress ref="prepress"></prepress>
        </el-tab-pane>
<!--        <el-tab-pane label="印刷"  name="printing" v-if="getPageIf('printing')">-->
<!--          <prepress ref="printing"></prepress>-->
<!--        </el-tab-pane>-->
        <el-tab-pane label="印刷:油墨房&&其他"  name="printOther" v-if="getPageIf('printOther')">
          <printOther ref="printOther"></printOther>
        </el-tab-pane>
        <el-tab-pane label="热转移打印"  name="overprinting" v-if="getPageIf('overprinting')">
          <overprinting ref="overprinting"></overprinting>
        </el-tab-pane>
        <el-tab-pane label="分条"  name="slitting" v-if="getPageIf('slitting')">
          <slitting ref="slitting"></slitting>
        </el-tab-pane>
        <el-tab-pane label="热覆膜"  name="lamTemperature" v-if="getPageIf('lamTemperature')">
          <lamTemperature ref="lamTemperature"></lamTemperature>
        </el-tab-pane>
        <el-tab-pane label="模切"  name="cutting" v-if="getPageIf('cutting')">
          <cutting ref="cutting"></cutting>
        </el-tab-pane>
        <el-tab-pane label="油墨房"  name="InkMixing" v-if="getPageIf('InkMixing')">
          <InkMixing ref="InkMixing"></InkMixing>
        </el-tab-pane>
        <el-tab-pane label="油墨配方"  name="InkFormulation" v-if="getPageIf('InkFormulation')">
          <InkFormulation ref="InkFormulation"></InkFormulation>
        </el-tab-pane>
        <el-tab-pane label="覆膜"  name="lamination" v-if="getPageIf('Lamination')">
          <lamination ref="lamination"></lamination>
        </el-tab-pane>
        <el-tab-pane label="包装"  name="packagePage" v-if="getPageIf('packagePage')">
          <packagePage ref="packagePage"></packagePage>
        </el-tab-pane>
        <el-tab-pane label="FQC"  name="fqc" v-if="getPageIf('fqc')">
          <fqc ref="fqc"></fqc>
        </el-tab-pane>
        <el-tab-pane label="CQC"  name="cqc" v-if="getPageIf('cqc')">
          <cqc ref="cqc"></cqc>
        </el-tab-pane>
        <el-tab-pane label="品质文件"  name="qualityDocument" v-if="getPageIf('qualityDocument')">
          <qualityDocument ref="qualityDocument"></qualityDocument>
        </el-tab-pane>
        <el-tab-pane label="文档控制"  name="documentControl" v-if="getPageIf('documentControl')">
          <documentControl ref="documentControl"></documentControl>
        </el-tab-pane>
        <el-tab-pane label="产品工程师审核/确认"  name="peReviewed" v-if="getPageIf('peReviewed')">
          <peReviewed ref="peReviewed"></peReviewed>
        </el-tab-pane>
        <el-tab-pane label="报价专员确认信息"  name="queteConfirm" v-if="getPageIf('queteConfirm')">
          <queteConfirm ref="queteConfirm"></queteConfirm>
        </el-tab-pane>
        <el-tab-pane label="FAI"  name="fai" v-if="getPageIf('fai')">
          <fai ref="fai"></fai>
        </el-tab-pane>
        <el-tab-pane label="CQE确认"  name="cqeComfirm" v-if="getPageIf('cqeComfirm')">
          <cqeComfirm ref="cqeComfirm"></cqeComfirm>
        </el-tab-pane>
      </el-tabs>
    </div>
</template>

<script>
  import {
    getBMPageBase
  } from '@/api/sampleManagement/technicalSpecificationList.js'
  import basicInformation from "./com_tsd_basicInformation";/*組件*/
  import customerInfo from "./com_bm_customerInformation";/*客户信息*/
  import packageInfo from "./com_bm_packageInfo";/*包装信息*/
  import bom from "./com_bm_bom";/*BOM*/
  import routing from "./com_bm_routing";/*工艺*/
  import prepress from "./com_bm_prepress";/*组件*/
  import technicalRequirement from "./com_bm_demoSlot";/*组件*/
  import drawing from "./com_bm_demoSlot";/*组件*/
  import PEConfirm from "./com_bm_demoSlot";/*组件*/
  import overprinting from "./com_bm_demoSlot";/*组件*/
  import slitting from "./com_bm_demoSlot";/*组件*/
  import lamTemperature from "./com_bm_demoSlot";/*组件*/
  import cutting from "./com_bm_demoSlot";/*组件*/
  import packagePage from "./com_bm_demoSlot";/*组件*/
  import fqc from "./com_bm_demoSlot";/*组件*/
  import cqc from "./com_bm_demoSlot";/*组件*/
  import qualityDocument from "./com_bm_demoSlot";/*组件*/
  import documentControl from "./com_bm_demoSlot";/*组件*/
  import peReviewed from "./com_bm_demoSlot";/*组件*/
  import queteConfirm from "./com_bm_demoSlot";/*组件*/
  import fai from "./com_bm_demoSlot";/*组件*/
  import cqeComfirm from "./com_bm_demoSlot";/*组件*/
  import tpInfo from "./com_bm_tpInfo";/*组件*/
  import printOther from "./com_bm_printOther";/*组件*/
  import InkMixing from "./com_bm_inkMixing";/*组件*/
  import InkFormulation from "./com_bm_inkFormulation";/*组件*/
  import lamination from "./com_bm_lamination";/*组件*/
  export default {
    name: "technicalSpecificationDetail",
    components: {
      basicInformation,
      customerInfo,
      packageInfo,
      bom,
      routing,
      prepress,
      technicalRequirement,
      drawing,
      PEConfirm,
      overprinting,
      slitting,
      lamTemperature,
      cutting,
      packagePage,
      fqc,
      cqc,
      qualityDocument,
      documentControl,
      peReviewed,
      queteConfirm,
      fai,
      cqeComfirm,
      tpInfo,
      printOther,
      InkMixing,
      InkFormulation,
      lamination,
    },
    data() {
      return {
        dataForm:{
          site:'',
          codeNo:'',
          buNo:'',
          username:this.$store.state.user.name,
          type:'',
        },
        pageRole:'',
        activeName:'',

      }
    },
    mounted() {
      if(localStorage.getItem('tsfData')!=undefined){
        let data=JSON.parse(localStorage.getItem('tsfData'))
        this.dataForm.site=data.site
        this.dataForm.codeNo=data.codeNo
        this.dataForm.buNo=data.buNo
        localStorage.removeItem('tsfData');
        this.getPageRole()
      }
      this.$nextTick(() => {
        this.changeHeightAuto();
        this.getBaseInfoData();
      })
    },
    methods: {
      refreshCurrentTabTable(){
        //先调整页面的高度
        this.changeHeightAuto()
        if (this.activeName == 'baseInfo') {
          this.getBaseInfoData();
        }else if(this.activeName == 'customerInfo'){
          //有的页面要高一点
          this.changeHeight(800);
          this.getCustomerInfo();
        }else if(this.activeName == 'packageInfo'){
          this.getPackageInfo();
        }else if(this.activeName == 'bom'){
          this.getBom();
        }else if(this.activeName == 'routing'){
          this.getRouting();
        }else if(this.activeName == 'prepress'){
          this.changeHeight(800);
          this.getPrepress();
        }else if(this.activeName == 'technicalRequirement'){
          this.getTechnicalRequirement();
        }else if(this.activeName == 'PEConfirm'){
          this.getPEConfirm();
        }else if(this.activeName == 'drawing'){
          this.getDrawing();
        } else if(this.activeName == 'overprinting'){
          this.getOverprinting();
        }else if(this.activeName == 'slitting'){
          this.getSlitting();
        }else if(this.activeName == 'lamTemperature'){
          this.getLamTemperature();
        }else if(this.activeName == 'cutting'){
          this.getCutting();
        }else if(this.activeName == 'packagePage'){
          this.getPackagePage();
        }else if(this.activeName == 'fqc'){
          this.getFqc();
        }else if(this.activeName == 'cqc'){
          this.getCqc();
        }else if(this.activeName == 'qualityDocument'){
          this.getQualityDocument();
        }else if(this.activeName == 'documentControl'){
          this.getDocumentControl();
        }else if(this.activeName == 'peReviewed'){
          this.getPeReviewed();
        }else if(this.activeName == 'queteConfirm'){
          this.getQueteConfirm();
        }else if(this.activeName == 'fai'){
          this.getFai();
        }else if(this.activeName == 'cqeComfirm'){
          this.getCqeComfirm();
        }else if(this.activeName == 'tpInfo'){
          this.changeHeight(800);
          this.getTpInfo();
        }else if(this.activeName == 'printOther'){
          this.getPrintOther();
        }else if(this.activeName == 'InkMixing'){
          this.getInkMixing();
        }else if(this.activeName == 'InkFormulation'){
          this.changeHeight(800);
          this.getInkFormulation();
        }else if(this.activeName == 'lamination'){
          this.getLamination();
        }

      },
      getPrintOther(){
        this.$refs.printOther.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getBaseInfoData(){
        this.$refs.basicInformation.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getCustomerInfo(){
        this.$refs.customerInfo.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getPackageInfo(){
        this.$refs.packageInfo.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getBom(){
        this.$refs.bom.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getRouting(){
        this.$refs.routing.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getPrepress(){
        this.dataForm.type='prepress'
        this.$refs.prepress.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getTechnicalRequirement(){
        this.dataForm.type='technicalRequirement'
        this.$refs.technicalRequirement.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getPEConfirm(){
        this.dataForm.type='PEConfirm'
        this.$refs.PEConfirm.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getDrawing(){
        this.dataForm.type='drawing'
        this.$refs.drawing.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getOverprinting(){
        this.dataForm.type='overprinting'
        this.$refs.overprinting.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getSlitting(){
        this.dataForm.type='slitting'
        this.$refs.slitting.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getLamTemperature(){
        this.dataForm.type='lamTemperature'
        this.$refs.lamTemperature.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getCutting(){
        this.dataForm.type='cutting'
        this.$refs.cutting.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getPackagePage(){
        // 这个有点特殊  是package
        this.dataForm.type='packagePage'
        this.$refs.packagePage.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getFqc(){
        this.dataForm.type='fqc'
        this.$refs.fqc.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getCqc(){
        this.dataForm.type='cqc'
        this.$refs.cqc.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getQualityDocument(){
        this.dataForm.type='qualityDocument'
        this.$refs.qualityDocument.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getDocumentControl(){
        this.dataForm.type='documentControl'
        this.$refs.documentControl.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getPeReviewed(){
        this.dataForm.type='peReviewed'
        this.$refs.peReviewed.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getQueteConfirm(){
        this.dataForm.type='queteConfirm'
        this.$refs.queteConfirm.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getFai(){
        this.dataForm.type='fai'
        this.$refs.fai.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getCqeComfirm(){
        this.dataForm.type='cqeComfirm'
        this.$refs.cqeComfirm.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getTpInfo(){
        this.dataForm.type='tpInfo'
        this.$refs.tpInfo.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getInkMixing(){
        this.dataForm.type='InkMixing'
        this.$refs.InkMixing.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getInkFormulation(){
        this.dataForm.type='InkFormulation'
        this.$refs.InkFormulation.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getLamination(){
        this.dataForm.type='lamination'
        this.$refs.lamination.init(JSON.parse(JSON.stringify(this.dataForm)))
      },

   //看有没有这个页面的权限
      getPageRole(){
        getBMPageBase(this.dataForm).then(({data}) => {
          if (data && data.code === 0) {
            this.pageRole=data.row
          }
        })
      },
      getPageIf(key){
        return this.pageRole.indexOf(key) !== -1 || false
      },

      changeHeight(height){
        var tabsElement = document.querySelector('.tabs');
        // tabsElement.style.minHeight = window.innerHeight+'px';
        tabsElement.style.minHeight = height +'px';
      },
      changeHeightAuto(){
        //页签大小铺满网页
        var tabsElement = document.querySelector('.tabs');
        tabsElement.style.minHeight = window.innerHeight+'px';
      }
    },
  }
</script>

<style >

</style>
