<template>
  <DoPage :label="actionType" :tabs="tabs" :useSpecialSplit="useSpecialSplit" />
</template>

<script>
  import DoPage from '../panels/do.vue'

  export default {
    name: 'SplitDo',
    components: { 
      DoPage
    },
    data() {
      return {
        actionType: '分卷',
        tabs: [],
        useSpecialSplit: false,
      }
    },
    watch: {
      '$route.query.actionType': {
        handler(newVal) {
          this.actionType = newVal;
          // 根据名字获取默认的查询参数
          const map = {
            '酸连轧工序': [
              {value: '1988150044862377986', label: '酸连轧原料库'},
              {value: '1988150099140866050', label: '酸连轧成品库'}, 
              {value: '1988150263284953089', label: '镀锌原料库'}, 
              {value: '1988150545175736322', label: '脱脂原料库'},
            ],
            '镀锌工序': [
              {value: '1988150263284953089', label: '镀锌原料库'}, 
              {value: '1988150323162836993', label: '镀锌成品库'},
              {value: '1988150487185289217', label: '镀锌纵剪分条原料库'},
            ],
            '脱脂工序': [
              {value: '1988150545175736322', label: '脱脂原料库'}, 
              {value: '1988150586938421250', label: '脱脂成品库'},
            ],
            '退火工序': [
              {value: '1988150648993148929', label: '罩式退火原料库'}, 
              {value: '1988150704496373761', label: '罩式退火成品库'},
            ],
            '拉矫平整工序': [
              {value: '1988150854442741762', label: '拉矫原料库'}, 
              {value: '1988150915591499777', label: '拉矫成品库'},
            ],
            '双机架工序': [
              {value: '1992873386047643650', label: '双机架原料库'}, 
              {value: '1992873437713080322', label: '双机架成品库'},
            ],
            '镀铬工序': [
              {value: '1988151076996706306', label: '镀铬原料库'}, 
              {value: '1988151132361519105', label: '镀铬成品库'},
            ],
            '纵剪分条工序': [
              {value: '', label: '原料库'},
              {value: '1988150210872930306', label: '酸连轧分条成品'},
              {value: '1988150800092950529', label: '退火分条成品'},
              {value: '1988150380649967617', label: '镀锌分条成品'},
              {value: '1988151027466170370', label: '拉矫分条成品'},
            ],
          }

          if (this.actionType === '镀锌工序' || this.actionType === '脱脂工序' || this.actionType === '拉矫平整工序' || this.actionType === '双机架工序' || this.actionType === '镀铬工序' || this.actionType === '纵剪分条工序') {
            this.useSpecialSplit = true
          }
          // 从map中获取默认的查询参数
          const defaultWarehouseIds = map[this.actionType] || []
          console.log(defaultWarehouseIds, 'defaultWarehouseIds')
          this.tabs = defaultWarehouseIds
        },
        immediate: true
      }
    }
  }
</script>