<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" ></basicInformation>
        </el-tab-pane>
<!--        <el-tab-pane label="备注区"  name="remarkPage" >-->
<!--          <remarkPage ref="remarkPage"  ></remarkPage>-->
<!--        </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="图稿信息"  name="drawing" v-if="getPageIf('drawing')">
          <drawing ref="drawing"></drawing>
        </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="品质文件"  name="qualityDocument" v-if="getPageIf('qualityDocument')">
          <qualityDocument ref="qualityDocument"></qualityDocument>
        </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="PE确认信息"  name="PEConfirm" v-if="getPageIf('PEConfirm')">-->
<!--          <PEConfirm ref="PEConfirm"></PEConfirm>-->
<!--        </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>-->
<!--&lt;!&ndash;        可能不要&ndash;&gt;-->
<!--        <el-tab-pane label="报价专员确认信息"  name="queteConfirm" v-if="getPageIf('queteConfirm')">-->
<!--          <queteConfirm ref="queteConfirm"></queteConfirm>-->
<!--        </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 remarkPage from "./com_bm_remarkSlot.vue";/*备注*/
  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";/*组件*/
  import printing from "./com_bm_printing";/*组件*/

  import CNC from "./com_bm_cnc";
  import Cut from "./com_bm_cut";
  export default {
    name: "technicalSpecificationDetail",
    components: {
      basicInformation,
      customerInfo,
      packageInfo,
      bom,
      routing,
      technicalRequirement,
      drawing,
      PEConfirm,
      qualityDocument,
      documentControl,
      peReviewed,
      queteConfirm,
      fai,
      cqeComfirm,
      tpInfo,
      remarkPage,
    },
    data() {
      return {
        dataForm:{
          site:'',
          codeNo:'',
          buNo:'',
          username:this.$store.state.user.name,
          type:'',
          ifDisableFlag:false,
          fieldId:'',
        },
        pageRole:'',
        activeName:'baseInfo',
      }
    },
    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
        this.dataForm.username=data.username
        localStorage.removeItem('tsfData');
      }
      this.$nextTick(() => {
        this.getPageRole()
        this.changeHeightAuto();
        this.getBaseInfoData();
      })
    },
    methods: {
      refreshCurrentTabTable(){
        this.dataForm.fieldId=this.activeName
        //先调整页面的高度
        this.changeHeightAuto()
        if (this.activeName == 'baseInfo') {
          this.getBaseInfoData();
        // }else if (this.activeName == 'remarkPage') {
        //   this.changeHeight(800);
        //   this.getRemarkSlot();
        }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.changeHeight(2000);
          this.getRouting();
        }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 == '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();

        }
      },
      getBaseInfoData(){
        this.$refs.basicInformation.init(JSON.parse(JSON.stringify(this.dataForm)))
      },
      getRemarkSlot(){
        this.$refs.remarkPage.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)))
      },
      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)))
      },
      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)))
      },

   //看有没有这个页面的权限
      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>
