<template>
<section class="h-full shadow-[1px_0px_4px_rgba(0,0,0,0.25)] bg-neutral-100 absolute inset-y-0 left-0 z-10" :class="!notShowActList ? (isShowBar ? 'w-full' : 'w-[312px]') : 'w-[312px]'">
  <!-- header -->
  <div class="bg-neutral-200 px-4">
    <p class="h2">Rule Settings</p>
  </div>
  <!-- contanier -->
  <div class="p-4 h-[calc(100%_-_40px)] flex">
    <div class="h-full flex flex-col justify-between w-[280px]">
      <!-- select -->
      <div class="h-full overflow-y-auto scrollbar w-[280px]">
        <!-- radio group -->
        <ConformanceRadioGroup></ConformanceRadioGroup>
        <!-- show and hidden button -->
        <div v-if="!notShowActList" class="flex items-center justify-between mr-1" :class="isShowBar ? 'text-primary' : ''">
          <p class="h2">Activity Selector</p>
          <span class="material-symbols-outlined cursor-pointer duration-300 hover:bg-primary/50 hover:rounded" @click="isShowBar = !isShowBar" id="cyp-showbaricon">{{ isShowBar ? 'keyboard_double_arrow_right' : 'keyboard_double_arrow_left' }}</span>
        </div>
        <!-- select result -->
        <ConformanceSelectResult
        :isSubmit="isSubmit"
        :isSubmitTask="isSubmitTask"
        :isSubmitStartAndEnd="isSubmitStartAndEnd"
        :isSubmitCfmSeqDirectly="isSubmitCfmSeqDirectly"
        :isSubmitCfmSeqEventually="isSubmitCfmSeqEventually"
        :isSubmitDurationData="isSubmitDurationData"
        :isSubmitCfmPtEteStart="isSubmitCfmPtEteStart"
        :isSubmitCfmPtEteEnd="isSubmitCfmPtEteEnd"
        :isSubmitCfmPtEteSE="isSubmitCfmPtEteSE"
        :isSubmitCfmPtPStart="isSubmitCfmPtPStart"
        :isSubmitCfmPtPEnd="isSubmitCfmPtPEnd"
        :isSubmitCfmPtPSE="isSubmitCfmPtPSE"
        :isSubmitCfmWtEteStart="isSubmitCfmWtEteStart"
        :isSubmitCfmWtEteEnd="isSubmitCfmWtEteEnd"
        :isSubmitCfmWtEteSE="isSubmitCfmWtEteSE"
        :isSubmitCfmWtPStart="isSubmitCfmWtPStart"
        :isSubmitCfmWtPEnd="isSubmitCfmWtPEnd"
        :isSubmitCfmWtPSE="isSubmitCfmWtPSE"
        :isSubmitCfmCtEteStart="isSubmitCfmCtEteStart"
        :isSubmitCfmCtEteEnd="isSubmitCfmCtEteEnd"
        :isSubmitCfmCtEteSE="isSubmitCfmCtEteSE"
        ></ConformanceSelectResult>
        <!-- Time Range -->
        <ConformanceTimeRange
        @min-total-seconds="minTotalSeconds"
        @max-total-seconds="maxTotalSeconds"
        :isSubmitDurationTime="isSubmitDurationTime"
        :isSubmitTimeCfmPtEteAll="isSubmitTimeCfmPtEteAll"
        :isSubmitTimeCfmPtEteStart="isSubmitTimeCfmPtEteStart"
        :isSubmitTimeCfmPtEteEnd="isSubmitTimeCfmPtEteEnd"
        :isSubmitTimeCfmPtEteSE="isSubmitTimeCfmPtEteSE"
        :isSubmitTimeCfmPtPStart="isSubmitTimeCfmPtPStart"
        :isSubmitTimeCfmPtPEnd="isSubmitTimeCfmPtPEnd"
        :isSubmitTimeCfmPtPSE="isSubmitTimeCfmPtPSE"
        :isSubmitTimeCfmWtEteAll="isSubmitTimeCfmWtEteAll"
        :isSubmitTimeCfmWtEteStart="isSubmitTimeCfmWtEteStart"
        :isSubmitTimeCfmWtEteEnd="isSubmitTimeCfmWtEteEnd"
        :isSubmitTimeCfmWtEteSE="isSubmitTimeCfmWtEteSE"
        :isSubmitTimeCfmWtPStart="isSubmitTimeCfmWtPStart"
        :isSubmitTimeCfmWtPEnd="isSubmitTimeCfmWtPEnd"
        :isSubmitTimeCfmWtPSE="isSubmitTimeCfmWtPSE"
        :isSubmitTimeCfmCtEteAll="isSubmitTimeCfmCtEteAll"
        :isSubmitTimeCfmCtEteStart="isSubmitTimeCfmCtEteStart"
        :isSubmitTimeCfmCtEteEnd="isSubmitTimeCfmCtEteEnd"
        :isSubmitTimeCfmCtEteSE="isSubmitTimeCfmCtEteSE"
         ></ConformanceTimeRange>
      </div>
      <!-- button -->
      <div class="space-x-4 p-4 flex justify-center items-content border-t border-neutral-300">
        <button type="button"  class="btn btn-sm btn-neutral" @click="reset">Clear</button>
        <button type="button" class="btn btn-sm " @click="submit" :class="this.isDisabled ? 'btn-disable' : 'btn-neutral'" :disabled="isDisabledButton" >Apply</button>
      </div>
    </div>
    <!-- show bar -->
    <ConformanceShowBar v-if="!notShowActList" :class="isShowBar?'':'hidden'"
    :isSubmit="isSubmit"
    :isSubmitTask="isSubmitTask"
    :isSubmitStartAndEnd="isSubmitStartAndEnd"
    :isSubmitCfmSeqDirectly="isSubmitCfmSeqDirectly"
    :isSubmitCfmSeqEventually="isSubmitCfmSeqEventually"
    :isSubmitDurationData="isSubmitDurationData"
    :isSubmitCfmPtEteStart="isSubmitCfmPtEteStart"
    :isSubmitCfmPtEteEnd="isSubmitCfmPtEteEnd"
    :isSubmitCfmPtEteSE="isSubmitCfmPtEteSE"
    :isSubmitCfmPtPStart="isSubmitCfmPtPStart"
    :isSubmitCfmPtPEnd="isSubmitCfmPtPEnd"
    :isSubmitCfmPtPSE="isSubmitCfmPtPSE"
    :isSubmitCfmWtEteStart="isSubmitCfmWtEteStart"
    :isSubmitCfmWtEteEnd="isSubmitCfmWtEteEnd"
    :isSubmitCfmWtEteSE="isSubmitCfmWtEteSE"
    :isSubmitCfmWtPStart="isSubmitCfmWtPStart"
    :isSubmitCfmWtPEnd="isSubmitCfmWtPEnd"
    :isSubmitCfmWtPSE="isSubmitCfmWtPSE"
    :isSubmitCfmCtEteStart="isSubmitCfmCtEteStart"
    :isSubmitCfmCtEteEnd="isSubmitCfmCtEteEnd"
    :isSubmitCfmCtEteSE="isSubmitCfmCtEteSE"
    :isSubmitShowDataSeq="isSubmitShowDataSeq"
    :isSubmitShowDataPtEte="isSubmitShowDataPtEte"
    :isSubmitShowDataPtP="isSubmitShowDataPtP"
    :isSubmitShowDataWtEte="isSubmitShowDataWtEte"
    :isSubmitShowDataWtP="isSubmitShowDataWtP"
    :isSubmitShowDataCt="isSubmitShowDataCt"
    ></ConformanceShowBar>
  </div>
</section>
</template>

<script>
import { storeToRefs } from 'pinia';
import LoadingStore from '@/stores/loading.js';
import ConformanceStore from '@/stores/conformance.js';
import ConformanceRadioGroup from './ConformanceSidebar/ConformanceRadioGroup.vue';
import ConformanceShowBar from './ConformanceSidebar/ConformanceShowBar.vue';
import ConformanceTimeRange from './ConformanceSidebar/ConformanceTimeRange.vue';
import ConformanceSelectResult from './ConformanceSidebar/ConformanceSelectResult.vue';

export default {
  setup() {
    const loadingStore = LoadingStore();
    const conformanceStore = ConformanceStore();
    const { isLoading } = storeToRefs(loadingStore);
    const { selectedRuleType, selectedActivitySequence, selectedMode, selectedProcessScope, selectedActSeqMore, selectedActSeqFromTo, conformanceAllTasks, cfmPtEteWhole, cfmPtEteStart, cfmPtEteEnd, cfmPtEteSE, cfmPtPStart, cfmPtPEnd, cfmPtPSE, cfmWtEteWhole, cfmWtEteStart, cfmWtEteEnd, cfmWtEteSE,  cfmWtPStart, cfmWtPEnd, cfmWtPSE, cfmCtEteWhole, cfmCtEteStart, cfmCtEteEnd, cfmCtEteSE, isStartSelected, isEndSelected, conformanceRuleData, conformanceLogCreateCheckId, conformanceFilterCreateCheckId, conformanceTempReportData } = storeToRefs(conformanceStore);

    return { isLoading, selectedRuleType, selectedActivitySequence, selectedMode, selectedProcessScope, selectedActSeqMore, selectedActSeqFromTo, conformanceStore, conformanceAllTasks, cfmPtEteWhole, cfmPtEteStart, cfmPtEteEnd, cfmPtEteSE, cfmPtPStart, cfmPtPEnd, cfmPtPSE, cfmWtEteWhole, cfmWtEteStart, cfmWtEteEnd, cfmWtEteSE,  cfmWtPStart, cfmWtPEnd, cfmWtPSE, cfmCtEteWhole, cfmCtEteStart, cfmCtEteEnd, cfmCtEteSE, isStartSelected, isEndSelected, conformanceRuleData, conformanceLogCreateCheckId, conformanceFilterCreateCheckId, conformanceTempReportData }
  },
  data() {
    return {
      isDisabled: true,
      isShowBar: false,
      visibleLeft: false,
      selectConformanceTask: null,
      selectConformanceStartAndEnd: null, // Activity sequence
      selectCfmSeqStart: null,
      selectCfmSeqEnd: null,
      selectCfmSeqDirectly: [],
      selectCfmSeqEventually: [],
      selectDurationData: null, // Activity duration
      selectDurationTime: { min: 0, max: 0},
      selectTimeRangeMin: 0, // Time Range min
      selectTimeRangeMax: 0, // Time Range max
      selectCfmPtEteStart: null, // Processing time
      selectCfmPtEteEnd: null,
      selectCfmPtEteSEStart: null,
      selectCfmPtEteSEEnd: null,
      selectCfmPtPStart: null,
      selectCfmPtPEnd: null,
      selectCfmPtPSEStart: null,
      selectCfmPtPSEEnd: null,
      selectCfmWtEteStart: null, // Waiting time
      selectCfmWtEteEnd: null,
      selectCfmWtEteSEStart: null,
      selectCfmWtEteSEEnd: null,
      selectCfmWtPStart: null,
      selectCfmWtPEnd: null,
      selectCfmWtPSEStart: null,
      selectCfmWtPSEEnd: null,
      selectCfmCtEteStart: null, // Cycle time
      selectCfmCtEteEnd: null,
      selectCfmCtEteSEStart: null,
      selectCfmCtEteSEEnd: null,
      isSubmit: false,
      isSubmitData: null, // 已 Apply 後，沒有重新改變規則的 Data
      isSubmitTask: null,
      isSubmitStartAndEnd: null, // Activity sequence
      isSubmitCfmSeqDirectly: [],
      isSubmitCfmSeqEventually: [],
      isSubmitDurationData: null, // Activity duration
      isSubmitCfmPtEteStart: null, // Processing time
      isSubmitCfmPtEteEnd: null,
      isSubmitCfmPtEteSE: null,
      isSubmitCfmPtPStart: null,
      isSubmitCfmPtPEnd: null,
      isSubmitCfmPtPSE: null,
      isSubmitCfmWtEteStart: null, // Waiting time
      isSubmitCfmWtEteEnd: null,
      isSubmitCfmWtEteSE: null,
      isSubmitCfmWtPStart: null,
      isSubmitCfmWtPEnd: null,
      isSubmitCfmWtPSE: null,
      isSubmitCfmCtEteStart: null, // Cycle time
      isSubmitCfmCtEteEnd: null,
      isSubmitCfmCtEteSE: null,
      isSubmitDurationTime: null, // Activity duration Time Range
      isSubmitTimeCfmPtEteAll: null, // Processing time Time Range
      isSubmitTimeCfmPtEteStart: null,
      isSubmitTimeCfmPtEteEnd: null,
      isSubmitTimeCfmPtEteSE: null,
      isSubmitTimeCfmPtPStart: null,
      isSubmitTimeCfmPtPEnd: null,
      isSubmitTimeCfmPtPSE: null,
      isSubmitTimeCfmWtEteAll: null, // Waiting time Time Range
      isSubmitTimeCfmWtEteStart: null,
      isSubmitTimeCfmWtEteEnd: null,
      isSubmitTimeCfmWtEteSE: null,
      isSubmitTimeCfmWtPStart: null,
      isSubmitTimeCfmWtPEnd: null,
      isSubmitTimeCfmWtPSE: null,
      isSubmitTimeCfmCtEteAll: null, // Cycle time Time Range
      isSubmitTimeCfmCtEteStart: null,
      isSubmitTimeCfmCtEteEnd: null,
      isSubmitTimeCfmCtEteSE: null,
      isSubmitShowDataSeq: {
        task: null,
        taskStart: null,
        taskEnd: null,
        isStartSelected: null,
        isEndSelected: null
      }, // To Start & End 連動資料
      isSubmitShowDataPtEte: {
        task: null,
        taskStart: null,
        taskEnd: null,
        isStartSelected: null,
        isEndSelected: null
      },
      isSubmitShowDataPtP: {
        task: null,
        taskStart: null,
        taskEnd: null,
        isStartSelected: null,
        isEndSelected: null
      },
      isSubmitShowDataWtEte: {
        task: null,
        taskStart: null,
        taskEnd: null,
        isStartSelected: null,
        isEndSelected: null
      },
      isSubmitShowDataWtP: {
        task: null,
        taskStart: null,
        taskEnd: null,
        isStartSelected: null,
        isEndSelected: null
      },
      isSubmitShowDataCt: {
        task: null,
        taskStart: null,
        taskEnd: null,
        isStartSelected: null,
        isEndSelected: null
      },
    }
  },
  components: {
    ConformanceRadioGroup,
    ConformanceShowBar,
    ConformanceTimeRange,
    ConformanceSelectResult,
  },
  computed: {
    notShowActList: function() {
      return (this.selectedRuleType === 'Activity sequence' && this.selectedActivitySequence === 'Sequence' && (this.selectedMode === 'Short loop(s)' || this.selectedMode === 'Self loop(s)')) || (this.selectedRuleType === 'Processing time' && this.selectedProcessScope === 'End to end' && this.selectedActSeqMore === 'All') || (this.selectedRuleType === 'Waiting time' && this.selectedProcessScope === 'End to end' && this.selectedActSeqMore === 'All') || (this.selectedRuleType === 'Cycle time' && this.selectedProcessScope === 'End to end' && this.selectedActSeqMore === 'All')
    },
    /**
     * Apply button is disabled or not
     */
    isDisabledButton() {
      let disabled = true;
      switch (this.selectedRuleType) {
        case 'Have activity': // Rule Type 選 Have activity 的行為
          if(this.selectConformanceTask?.length) disabled = false;
          break
        case 'Activity sequence': // Rule Type 選 Activity sequence 的行為
          switch (this.selectedActivitySequence) {
            case 'Start & End': // Activity Sequence 選 Start & End 的行為
              if(this.selectCfmSeqStart && this.selectCfmSeqEnd) disabled = false;
              break;
            case 'Sequence': // Activity Sequence 選 Sequence 的行為
              switch (this.selectedMode) {
                case 'Directly follows':
                  if(this.selectCfmSeqDirectly.length >= 2) disabled = false;
                  break;
                case 'Eventually follows':
                  if(this.selectCfmSeqEventually.length >= 2) disabled = false;
                  break;
                case 'Short loop(s)':
                  disabled = false;
                  break;
                case 'Self loop(s)':
                  disabled = false;
                  break;
                default:
                  break;
              };
            default:
              break;
          }
          break;
        case 'Activity duration': // Rule Type 選 Activity duration 的行為
          if(this.selectDurationData?.length) disabled = false;
          break;
        case 'Processing time': // Rule Type 選 Processing time 的行為
          switch (this.selectedProcessScope) {
            case 'End to end':
              switch (this.selectedActSeqMore) {
                case 'All':
                  disabled = false;
                  break;
                case 'Start':
                  if(this.selectCfmPtEteStart) disabled = false;
                  break;
                case 'End':
                  if(this.selectCfmPtEteEnd) disabled = false;
                  break;
                case 'Start & End':
                  if(this.selectCfmPtEteSEStart && this.selectCfmPtEteSEEnd) disabled = false;
                break;
                default:
                  break;
              };
              break;
            case 'Partial':
              switch (this.selectedActSeqFromTo) {
                case 'From':
                  if(this.selectCfmPtPStart) disabled = false;
                  break;
                case 'To':
                  if(this.selectCfmPtPEnd) disabled = false;
                  break;
                case 'From & To':
                  if(this.selectCfmPtPSEStart && this.selectCfmPtPSEEnd) disabled = false;
                break;
                default:
                  break;
              };
              break;
            default:
              break;
          };
          break;
        case 'Waiting time': // Rule Type 選 Waiting time 的行為
          switch (this.selectedProcessScope) {
            case 'End to end':
              switch (this.selectedActSeqMore) {
                case 'All':
                  disabled = false;
                  break;
                case 'Start':
                  if(this.selectCfmWtEteStart) disabled = false;
                  break;
                case 'End':
                  if(this.selectCfmWtEteEnd) disabled = false;
                  break;
                case 'Start & End':
                  if(this.selectCfmWtEteSEStart && this.selectCfmWtEteSEEnd) disabled = false;
                  break;
                default:
                  break;
              };
              break;
            case 'Partial':
              switch (this.selectedActSeqFromTo) {
                case 'From':
                  if(this.selectCfmWtPStart) disabled = false;
                  break;
                case 'To':
                  if(this.selectCfmWtPEnd) disabled = false;
                  break;
                case 'From & To':
                  if(this.selectCfmWtPSEStart && this.selectCfmWtPSEEnd) disabled = false;
                  break;
                default:
                  break;
              };
              break;
            default:
              break;
          };
          break;
        case 'Cycle time': // Rule Type 選 Cycle time 的行為
          switch (this.selectedActSeqMore) {
            case 'All':
              disabled = false;
              break;
            case 'Start':
              if(this.selectCfmCtEteStart) disabled = false;
              break;
            case 'End':
              if(this.selectCfmCtEteEnd) disabled = false;
              break;
            case 'Start & End':
              if(this.selectCfmCtEteSEStart && this.selectCfmCtEteSEEnd) disabled = false;
              break;
            default:
              break;
          };
          break;
        default:
          break;
      };
      return this.isDisabled = disabled;
    },
  },
  watch: {
    isSubmitData: function(newValue) {
      this.isSubmitData = newValue;
    },
    // 打開 rule 檔要顯示儲存的選項、規則、時間
    conformanceTempReportData: {
      handler: function(newValue) {
        setTimeout(() => {
          if(newValue !== null) {
            const rule = newValue.rule;

            this.isSubmitData = newValue.rule;
            this.isSubmit = true;
            switch (rule.type) {
              case 'contains-tasks': // Rule Type 選 Have activity 的行為
                this.selectedRuleType = 'Have activity';
                this.isSubmitTask = rule.tasks;
                break;
              case 'start-end': // Rule Type 選 Activity sequence 的行為
                this.selectedRuleType = 'Activity sequence';
                this.selectedActivitySequence = 'Start & End';
                this.isSubmitStartAndEnd = [
                  {category: 'Start', task: rule.starts_with},
                  {category: 'End', task: rule.ends_with},
                ];
                break;
              case 'directly-follows': // Activity Sequence 選 Sequence 的行為
                this.selectedRuleType = 'Activity sequence';
                this.selectedActivitySequence = 'Sequence';
                this.selectedMode = 'Directly follows';
                this.isSubmitCfmSeqDirectly = rule.task_seq;
                break;
              case 'eventually-follows':
                this.selectedRuleType = 'Activity sequence';
                this.selectedActivitySequence = 'Sequence';
                this.selectedMode = 'Eventually follows';
                this.isSubmitCfmSeqEventually = rule.task_seq;
                break;
              case 'short-loops':
                this.selectedRuleType = 'Activity sequence';
                this.selectedActivitySequence = 'Sequence';
                this.selectedMode = 'Short loop(s)';
                break;
              case 'self-loops':
                this.selectedRuleType = 'Activity sequence';
                this.selectedActivitySequence = 'Sequence';
                this.selectedMode = 'Self loop(s)';
                break;
              case 'task-duration': // Rule Type 選 Activity duration 的行為
                this.selectedRuleType = 'Activity duration';
                this.isSubmitDurationData = [rule.task];
                this.isSubmitDurationTime = { min: rule.min, max: rule.max};
                break;
              case 'processing-time-end-to-end-whole': // Rule Type 選 Processing time 的行為
                this.selectedRuleType = 'Processing time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'All';
                this.isSubmitTimeCfmPtEteAll = { min: rule.min, max: rule.max};
                break;
              case 'processing-time-end-to-end-starts-with':
                this.selectedRuleType = 'Processing time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'Start';
                this.isSubmitCfmPtEteStart = [
                  {category: 'Start', task: rule.task}
                ];
                this.isSubmitTimeCfmPtEteStart = { min: rule.min, max: rule.max};
                break;
              case 'processing-time-end-to-end-ends-with':
                this.selectedRuleType = 'Processing time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'End';
                this.isSubmitCfmPtEteEnd = [
                  {category: 'End', task: rule.task}
                ];
                this.isSubmitTimeCfmPtEteEnd = { min: rule.min, max: rule.max};
                break;
              case 'processing-time-end-to-end-start-end':
                this.selectedRuleType = 'Processing time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'Start & End';
                this.isSubmitCfmPtEteSE = [
                  {category: 'Start', task: rule.start},
                  {category: 'End', task: rule.end}
                ];
                this.isSubmitTimeCfmPtEteSE = { min: rule.min, max: rule.max};
                break;
              case 'processing-time-partial-starts-with':
                this.selectedRuleType = 'Processing time';
                this.selectedProcessScope = 'Partial';
                this.selectedActSeqFromTo = 'From';
                this.isSubmitCfmPtPStart = [
                  {category: 'From', task: rule.task}
                ];
                this.isSubmitTimeCfmPtPStart = { min: rule.min, max: rule.max};
                break;
              case 'processing-time-partial-ends-with':
                this.selectedRuleType = 'Processing time';
                this.selectedProcessScope = 'Partial';
                this.selectedActSeqFromTo = 'To';
                this.isSubmitCfmPtPEnd = [
                  {category: 'To', task: rule.task}
                ];
                this.isSubmitTimeCfmPtPEnd = { min: rule.min, max: rule.max};
                break;
              case 'processing-time-partial-start-end':
                this.selectedRuleType = 'Processing time';
                this.selectedProcessScope = 'Partial';
                this.selectedActSeqFromTo = 'From & To';
                this.isSubmitCfmPtPSE = [
                  {category: 'From', task: rule.start},
                  {category: 'To', task: rule.end}
                ];
                this.isSubmitTimeCfmPtPSE = { min: rule.min, max: rule.max};
                this.isSubmitShowDataPtP = this.setSubmitShowData(rule.start, rule.end);
                break;
              case 'waiting-time-end-to-end-whole': // Rule Type 選 Waiting time 的行為
                this.selectedRuleType = 'Waiting time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'All';
                this.isSubmitTimeCfmWtEteAll = { min: rule.min, max: rule.max};
                break;
              case 'waiting-time-end-to-end-starts-with':
                this.selectedRuleType = 'Waiting time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'Start';
                this.isSubmitCfmWtEteStart = [
                  {category: 'Start', task: rule.task}
                ];
                this.isSubmitTimeCfmWtEteStart = { min: rule.min, max: rule.max};
                break;
              case 'waiting-time-end-to-end-ends-with':
                this.selectedRuleType = 'Waiting time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'End';
                this.isSubmitCfmWtEteEnd = [
                  {category: 'End', task: rule.task}
                ];
                this.isSubmitTimeCfmWtEteEnd = { min: rule.min, max: rule.max};
                break;
              case 'waiting-time-end-to-end-start-end':
                this.selectedRuleType = 'Waiting time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'Start & End';
                this.isSubmitCfmWtEteSE = [
                  {category: 'Start', task: rule.start},
                  {category: 'End', task: rule.end}
                ];
                this.isSubmitTimeCfmWtEteSE = { min: rule.min, max: rule.max};
                this.isSubmitShowDataWtEte = this.setSubmitShowData(rule.start, rule.end);
                break;
              case 'waiting-time-partial-starts-with':
                this.selectedRuleType = 'Waiting time';
                this.selectedProcessScope = 'Partial';
                this.selectedActSeqFromTo = 'From';
                this.isSubmitCfmWtPStart = [
                  {category: 'From', task: rule.task}
                ];
                this.isSubmitTimeCfmWtPStart = { min: rule.min, max: rule.max};
                break;
              case 'waiting-time-partial-ends-with':
                this.selectedRuleType = 'Waiting time';
                this.selectedProcessScope = 'Partial';
                this.selectedActSeqFromTo = 'To';
                this.isSubmitCfmWtPEnd = [
                  {category: 'To', task: rule.task}
                ];
                this.isSubmitTimeCfmWtPEnd = { min: rule.min, max: rule.max};
                break;
              case 'waiting-time-partial-start-end':
                this.selectedRuleType = 'Waiting time';
                this.selectedProcessScope = 'Partial';
                this.selectedActSeqFromTo = 'From & To';
                this.isSubmitCfmWtPSE = [
                  {category: 'From', task: rule.start},
                  {category: 'To', task: rule.end}
                ];
                this.isSubmitTimeCfmWtPSE = { min: rule.min, max: rule.max};
                this.isSubmitShowDataWtP = this.setSubmitShowData(rule.start, rule.end);
                break;
              case 'cycle-time-end-to-end-whole': // Rule Type 選 Cycle time 的行為
                this.selectedRuleType = 'Cycle time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'All';
                this.isSubmitTimeCfmCtEteAll = { min: rule.min, max: rule.max};
                break;
              case 'cycle-time-end-to-end-starts-with':
                this.selectedRuleType = 'Cycle time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'Start';
                this.isSubmitCfmCtEteStart = [
                  {category: 'Start', task: rule.task}
                ];
                this.isSubmitTimeCfmCtEteStart = { min: rule.min, max: rule.max};
                break;
              case 'cycle-time-end-to-end-ends-with':
                this.selectedRuleType = 'Cycle time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'End';
                this.isSubmitCfmCtEteEnd = [
                  {category: 'End', task: rule.task}
                ];
                this.isSubmitTimeCfmCtEteEnd = { min: rule.min, max: rule.max};
                break;
              case 'cycle-time-end-to-end-start-end':
                this.selectedRuleType = 'Cycle time';
                this.selectedProcessScope = 'End to end';
                this.selectedActSeqMore = 'Start & End';
                this.isSubmitCfmCtEteSE = [
                  {category: 'Start', task: rule.start},
                  {category: 'End', task: rule.end}
                ];
                this.isSubmitTimeCfmCtEteSE = { min: rule.min, max: rule.max};
                this.isSubmitShowDataCt = this.setSubmitShowData(rule.start, rule.end);
                break;
            }
          }
        }, 300);
      }
    }
  },
  methods: {
    /**
     * get min total seconds
     * @param {Number} e
     */
     minTotalSeconds(e) {
      this.selectTimeRangeMin = e;
    },
    /**
     * get min total seconds
     * @param {Number} e
     */
    maxTotalSeconds(e) {
      this.selectTimeRangeMax = e;
    },
    /**
     * select Time Reset
     */
    selectTimeReset() {
      // 不包含 this.selectDurationTime
      this.selectConformanceTask = null; // Have activity
      this.selectConformanceStartAndEnd = null; // Activity Sequence
      this.selectCfmSeqStart = null;
      this.selectCfmSeqEnd = null;
      this.selectCfmSeqDirectly = [];
      this.selectCfmSeqEventually = [];
      this.selectDurationData = null; // Activity durations
      this.selectTimeRangeMin = 0; // Time Range min
      this.selectTimeRangeMax = 0; // Time Range max
      this.selectCfmPtEteStart = null; // Processing time
      this.selectCfmPtEteEnd = null;
      this.selectCfmPtEteSEStart = null;
      this.selectCfmPtEteSEEnd = null;
      this.selectCfmPtPStart = null;
      this.selectCfmPtPEnd = null;
      this.selectCfmPtPSEStart = null;
      this.selectCfmPtPSEEnd = null;
      this.selectCfmWtEteStart = null; // Waiting time
      this.selectCfmWtEteEnd = null;
      this.selectCfmWtEteSEStart = null;
      this.selectCfmWtEteSEEnd = null;
      this.selectCfmWtPStart = null;
      this.selectCfmWtPEnd = null;
      this.selectCfmWtPSEStart = null;
      this.selectCfmWtPSEEnd = null;
      this.selectCfmCtEteStart = null; // Cycle time
      this.selectCfmCtEteEnd = null;
      this.selectCfmCtEteSEStart = null;
      this.selectCfmCtEteSEEnd = null;
    },
    /**
     * is submit select Reset
     */
    isSubmitReset() {
      // 不包含 isSubmitData
      this.isSubmitTask = null;
      this.isSubmitStartAndEnd = null;
      this.isSubmitCfmSeqDirectly = [];
      this.isSubmitCfmSeqEventually = [];
      this.isSubmitDurationData = null;
      this.isSubmitDurationTime = null;
      this.isSubmitCfmPtEteStart = null; // Processing time
      this.isSubmitCfmPtEteEnd = null;
      this.isSubmitCfmPtEteSE = null;
      this.isSubmitCfmPtPStart = null;
      this.isSubmitCfmPtPEnd = null;
      this.isSubmitCfmPtPSE = null;
      this.isSubmitCfmWtEteStart = null; // Waiting time
      this.isSubmitCfmWtEteEnd = null;
      this.isSubmitCfmWtEteSE = null;
      this.isSubmitCfmWtPStart = null;
      this.isSubmitCfmWtPEnd = null;
      this.isSubmitCfmWtPSE = null;
      this.isSubmitCfmCtEteStart = null; // Cycle time
      this.isSubmitCfmCtEteEnd = null;
      this.isSubmitCfmCtEteSE = null;
      this.isSubmitTimeCfmPtEteAll = null; // Processing time Time Range
      this.isSubmitTimeCfmPtEteStart = null;
      this.isSubmitTimeCfmPtEteEnd = null;
      this.isSubmitTimeCfmPtEteSE = null;
      this.isSubmitTimeCfmPtPStart = null;
      this.isSubmitTimeCfmPtPEnd = null;
      this.isSubmitTimeCfmPtPSE = null;
      this.isSubmitTimeCfmWtEteAll = null; // Waiting time Time Range
      this.isSubmitTimeCfmWtEteStart = null;
      this.isSubmitTimeCfmWtEteEnd = null;
      this.isSubmitTimeCfmWtEteSE = null;
      this.isSubmitTimeCfmWtPStart = null;
      this.isSubmitTimeCfmWtPEnd = null;
      this.isSubmitTimeCfmWtPSE = null;
      this.isSubmitTimeCfmCtEteAll = null; // Cycle time Time Range
      this.isSubmitTimeCfmCtEteStart = null;
      this.isSubmitTimeCfmCtEteEnd = null;
      this.isSubmitTimeCfmCtEteSE = null;
    },
    /**
     * @param {boolean} massage true | false 清空選單選項, 選擇的結果
     */
     reset() {
      // Results page Cover Plate(遮罩為 ture)
      this.$emitter.emit('coverPlate', true);
      // is submit select Reset
      this.isSubmitReset();
      this.isSubmitData = null; // 已 Apply 後，沒有重新改變規則的 Data
      this.isSubmit = false;

      // 其他子元件 reset
      this.selectTimeReset();
      this.$emitter.emit('reset', null);
      // reset 成功訊息
      this.$toast.success('Rule cleared.');
      this.isShowBar = true;
    },
    /**
     * 設定 Start & End Data 連動資料
     * @param {string} start task
     * @param {string} end task
     * @returns {object}
     */
    setSubmitShowData(start, end) {
      if(this.isStartSelected) {
        return {
          task: start,
          taskStart: start,
          taskEnd: end,
          isStartSelected:true,
          isEndSelected: false
        };
      }else {
        return {
          task: end,
          taskStart: start,
          taskEnd: end,
          isStartSelected:false,
          isEndSelected: true
        };
      }

    },
    /**
     * Apply button 發送選項，取得 Check Id.
     */
    async submit() {
      let data;

      this.selectDurationTime = await {
        min: this.selectTimeRangeMin,
        max: this.selectTimeRangeMax
      };
      this.$emitter.emit('timeRangeMaxMin', this.selectDurationTime);

      switch (this.selectedRuleType) {
        case 'Have activity': // Rule Type 選 Have activity 的行為
          data = {
            type: 'contains-tasks',
            tasks: this.selectConformanceTask,
          };
          // 其他 isSubmitData 為 null
          this.isSubmitReset();
          this.isSubmitTask = this.selectConformanceTask;
          break;
        case 'Activity sequence': // Rule Type 選 Activity sequence 的行為
          switch (this.selectedActivitySequence) {
            case 'Start & End': // Activity Sequence 選 Start & End 的行為
              data = {
                type: 'start-end',
                starts_with: this.selectCfmSeqStart,
                ends_with: this.selectCfmSeqEnd,
              };
              this.isSubmitReset();
              this.isSubmitStartAndEnd = [
                {category: 'Start', task: this.selectCfmSeqStart},
                {category: 'End', task: this.selectCfmSeqEnd},
              ];
              this.isSubmitShowDataSeq = this.setSubmitShowData(this.selectCfmSeqStart, this.selectCfmSeqEnd);
              break;
            case 'Sequence': // Activity Sequence 選 Sequence 的行為
              switch (this.selectedMode) {
                case 'Directly follows':
                  data = {
                    type: 'directly-follows',
                    task_seq: this.selectCfmSeqDirectly,
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmSeqDirectly = JSON.parse(JSON.stringify(this.selectCfmSeqDirectly));
                  break;
                case 'Eventually follows':
                  data = {
                    type: 'eventually-follows',
                    task_seq: this.selectCfmSeqEventually,
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmSeqEventually = JSON.parse(JSON.stringify(this.selectCfmSeqEventually));
                  break;
                case 'Short loop(s)':
                  data = {
                    type: 'short-loops',
                  };
                  break;
                case 'Self loop(s)':
                  data = {
                    type: 'self-loops',
                  };
                  break;
                default:
                  break;
              };
            default:
              break;
          }
          break;
        case 'Activity duration': // Rule Type 選 Activity duration 的行為
          data = {
            type: 'task-duration',
            task: this.selectDurationData[0],
            min: this.selectDurationTime.min,
            max: this.selectDurationTime.max,
          };
          this.isSubmitReset();
          this.isSubmitDurationData = this.selectDurationData;
          this.isSubmitDurationTime = this.selectDurationTime;
          break;
        case 'Processing time': // Rule Type 選 Processing time 的行為
          switch (this.selectedProcessScope) {
            case 'End to end':
              switch (this.selectedActSeqMore) {
                case 'All':
                  data = {
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'processing-time-end-to-end-whole',
                  };
                  this.isSubmitReset();
                  this.isSubmitTimeCfmPtEteAll = this.selectDurationTime;
                  break;
                case 'Start':
                  data = {
                    task: this.selectCfmPtEteStart,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'processing-time-end-to-end-starts-with',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmPtEteStart =  [
                    {category: 'Start', task: this.selectCfmPtEteStart},
                  ];
                  this.isSubmitTimeCfmPtEteStart = this.selectDurationTime;
                  break;
                case 'End':
                  data = {
                    task: this.selectCfmPtEteEnd,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'processing-time-end-to-end-ends-with',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmPtEteEnd =  [
                    {category: 'End', task: this.selectCfmPtEteEnd},
                  ];
                  this.isSubmitTimeCfmPtEteEnd = this.selectDurationTime;
                  break;
                case 'Start & End':
                  data = {
                    start: this.selectCfmPtEteSEStart,
                    end: this.selectCfmPtEteSEEnd,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'processing-time-end-to-end-start-end',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmPtEteSE =  [
                    {category: 'Start', task: this.selectCfmPtEteSEStart},
                    {category: 'End', task: this.selectCfmPtEteSEEnd},
                  ];
                  this.isSubmitTimeCfmPtEteSE = this.selectDurationTime;
                  this.isSubmitShowDataPtEte = this.setSubmitShowData(this.selectCfmPtEteSEStart, this.selectCfmPtEteSEEnd);
                break;
              };
              break;
            case 'Partial':
              switch (this.selectedActSeqFromTo) {
                case 'From':
                  data = {
                    task: this.selectCfmPtPStart,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'processing-time-partial-starts-with',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmPtPStart =  [
                    {category: 'From', task: this.selectCfmPtPStart},
                  ];
                  this.isSubmitTimeCfmPtPStart = this.selectDurationTime;
                  break;
                case 'To':
                  data = {
                    task: this.selectCfmPtPEnd,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'processing-time-partial-ends-with',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmPtPEnd =  [
                    {category: 'To', task: this.selectCfmPtPEnd},
                  ];
                  this.isSubmitTimeCfmPtPEnd = this.selectDurationTime;
                  break;
                case 'From & To':
                  data = {
                    start: this.selectCfmPtPSEStart,
                    end: this.selectCfmPtPSEEnd,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'processing-time-partial-start-end',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmPtPSE =  [
                    {category: 'From', task: this.selectCfmPtPSEStart},
                    {category: 'To', task: this.selectCfmPtPSEEnd},
                  ];
                  this.isSubmitTimeCfmPtPSE = this.selectDurationTime;
                  this.isSubmitShowDataPtP = this.setSubmitShowData(this.selectCfmPtPSEStart, this.selectCfmPtPSEEnd);
                break;
                default:
                  break;
              };
              break;
            default:
              break;
          };
          break;
        case 'Waiting time': // Rule Type 選 Waiting time 的行為
          switch (this.selectedProcessScope) {
            case 'End to end':
              switch (this.selectedActSeqMore) {
                case 'All':
                  data = {
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'waiting-time-end-to-end-whole',
                  };
                  this.isSubmitReset();
                  this.isSubmitTimeCfmWtEteAll = this.selectDurationTime;
                  break;
                case 'Start':
                  data = {
                    task: this.selectCfmWtEteStart,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'waiting-time-end-to-end-starts-with',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmWtEteStart =  [
                    {category: 'Start', task: this.selectCfmWtEteStart},
                  ];
                  this.isSubmitTimeCfmWtEteStart = this.selectDurationTime;
                  break;
                case 'End':
                  data = {
                    task: this.selectCfmWtEteEnd,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'waiting-time-end-to-end-ends-with',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmWtEteEnd =  [
                    {category: 'End', task: this.selectCfmWtEteEnd},
                  ];
                  this.isSubmitTimeCfmWtEteEnd = this.selectDurationTime;
                  break;
                case 'Start & End':
                  data = {
                    start: this.selectCfmWtEteSEStart,
                    end: this.selectCfmWtEteSEEnd,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'waiting-time-end-to-end-start-end',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmWtEteSE =  [
                    {category: 'Start', task: this.selectCfmWtEteSEStart},
                    {category: 'End', task: this.selectCfmWtEteSEEnd},
                  ];
                  this.isSubmitTimeCfmWtEteSE = this.selectDurationTime;
                  this.isSubmitShowDataWtEte = this.setSubmitShowData(this.selectCfmWtEteSEStart, this.selectCfmWtEteSEEnd);
                  break;
                default:
                  break;
              };
              break;
            case 'Partial':
              switch (this.selectedActSeqFromTo) {
                case 'From':
                  data = {
                    task: this.selectCfmWtPStart,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'waiting-time-partial-starts-with',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmWtPStart =  [
                    {category: 'From', task: this.selectCfmWtPStart},
                  ];
                  this.isSubmitTimeCfmWtPStart = this.selectDurationTime;
                  break;
                case 'To':
                  data = {
                    task: this.selectCfmWtPEnd,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'waiting-time-partial-ends-with',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmWtPEnd =  [
                    {category: 'To', task: this.selectCfmWtPEnd},
                  ];
                  this.isSubmitTimeCfmWtPEnd = this.selectDurationTime;
                  break;
                case 'From & To':
                  data = {
                    start: this.selectCfmWtPSEStart,
                    end: this.selectCfmWtPSEEnd,
                    min: this.selectDurationTime.min,
                    max: this.selectDurationTime.max,
                    type: 'waiting-time-partial-start-end',
                  };
                  this.isSubmitReset();
                  this.isSubmitCfmWtPSE =  [
                    {category: 'From', task: this.selectCfmWtPSEStart},
                    {category: 'To', task: this.selectCfmWtPSEEnd},
                  ];
                  this.isSubmitTimeCfmWtPSE = this.selectDurationTime;
                  this.isSubmitShowDataWtP = this.setSubmitShowData(this.selectCfmWtPSEStart, this.selectCfmWtPSEEnd);
                  break;
                default:
                  break;
              };
              break;
            default:
              break;
          };
          break;
        case 'Cycle time': // Rule Type 選 Cycle time 的行為
          switch (this.selectedActSeqMore) {
            case 'All':
              data = {
                min: this.selectDurationTime.min,
                max: this.selectDurationTime.max,
                type: 'cycle-time-end-to-end-whole',
              };
              this.isSubmitReset();
              this.isSubmitTimeCfmCtEteAll = this.selectDurationTime;
              break;
            case 'Start':
              data = {
                task: this.selectCfmCtEteStart,
                min: this.selectDurationTime.min,
                max: this.selectDurationTime.max,
                type: 'cycle-time-end-to-end-starts-with',
              };
              this.isSubmitReset();
              this.isSubmitCfmCtEteStart =  [
                {category: 'Start', task: this.selectCfmCtEteStart},
              ];
              this.isSubmitTimeCfmCtEteStart = this.selectDurationTime;
              break;
            case 'End':
              data = {
                task: this.selectCfmCtEteEnd,
                min: this.selectDurationTime.min,
                max: this.selectDurationTime.max,
                type: 'cycle-time-end-to-end-ends-with',
              };
              this.isSubmitReset();
              this.isSubmitCfmCtEteEnd =  [
                {category: 'End', task: this.selectCfmCtEteEnd},
              ];
              this.isSubmitTimeCfmCtEteEnd = this.selectDurationTime;
              break;
            case 'Start & End':
              data = {
                start: this.selectCfmCtEteSEStart,
                end: this.selectCfmCtEteSEEnd,
                min: this.selectDurationTime.min,
                max: this.selectDurationTime.max,
                type: 'cycle-time-end-to-end-start-end',
              };
              this.isSubmitReset();
              this.isSubmitCfmCtEteSE =  [
                {category: 'Start', task: this.selectCfmCtEteSEStart},
                {category: 'End', task: this.selectCfmCtEteSEEnd},
              ];
              this.isSubmitTimeCfmCtEteSE = this.selectDurationTime;
              this.isSubmitShowDataCt = this.setSubmitShowData(this.selectCfmCtEteSEStart, this.selectCfmCtEteSEEnd);
              break;
            default:
              break;
          };
          break;
      };
      if(data.min > data.max) return this.$toast.error('Please check time range setting.');
      if(JSON.stringify(data) === JSON.stringify(this.isSubmitData)) return this.$toast.error('Please set the new rule.');

      this.isLoading = true;
      this.isSubmit = true;
      this.isSubmitData = data; // 已 Apply 後，沒有重新改變規則的 Data
      this.conformanceRuleData = data; // 給存檔的 Data
      await this.conformanceStore.addConformanceCheckId(data);
      await this.conformanceStore.getConformanceReport();
      this.isShowBar = false;
      this.isLoading = false;
      // Results page Cover Plate
      this.$emitter.emit('coverPlate', false);
      this.$toast.success('Rule applied.');
    },
  },
  created() {
    this.isShowBar = this.conformanceLogCreateCheckId || this.conformanceFilterCreateCheckId ? false : true;
    // 選取 list 的結果
    this.$emitter.on('actListData', (data) => {
      this.selectConformanceTask = data;
    });
    this.$emitter.on('actRadioData', (data) => {
      switch (data.category) {
        // Activity sequence
        case 'cfmSeqStart':
          if(this.isStartSelected === true && data.task !== this.selectCfmSeqStart) this.selectCfmSeqEnd = null;
          this.selectCfmSeqStart = data.task;
          break;
        case 'cfmSeqEnd':
          if(this.isEndSelected === true && data.task !== this.selectCfmSeqEnd) this.selectCfmSeqStart = null;
          this.selectCfmSeqEnd = data.task;
          break;
        // Processing time
        case 'cfmPtEteStart':
          this.selectCfmPtEteStart = data.task;
          break;
        case 'cfmPtEteEnd':
          this.selectCfmPtEteEnd = data.task;
          break;
        case 'cfmPtEteSEStart':
          if(this.isStartSelected === true && data.task !== this.selectCfmPtEteSEStart) this.selectCfmPtEteSEEnd = null;
          this.selectCfmPtEteSEStart = data.task;
          break;
        case 'cfmPtEteSEEnd':
          if(this.isEndSelected === true && data.task !== this.selectCfmPtEteSEEnd) this.selectCfmPtEteSEStart = null;
          this.selectCfmPtEteSEEnd = data.task;
          break;
        case 'cfmPtPStart':
          this.selectCfmPtPStart = data.task;
          break;
        case 'cfmPtPEnd':
          this.selectCfmPtPEnd = data.task;
          break;
        case 'cfmPtPSEStart':
          if(this.isStartSelected === true && data.task !== this.selectCfmPtPSEStart) this.selectCfmPtPSEEnd = null;
          this.selectCfmPtPSEStart = data.task;
          break;
        case 'cfmPtPSEEnd':
          if(this.isEndSelected === true && data.task !== this.selectCfmPtPSEEnd) this.selectCfmPtPSEStart = null;
          this.selectCfmPtPSEEnd = data.task;
          break;
        // Waiting time
        case 'cfmWtEteStart':
          this.selectCfmWtEteStart = data.task;
          break;
        case 'cfmWtEteEnd':
          this.selectCfmWtEteEnd = data.task;
          break;
        case 'cfmWtEteSEStart':
          if(this.isStartSelected === true && data.task !== this.selectCfmWtEteSEStart) this.selectCfmWtEteSEEnd = null;
          this.selectCfmWtEteSEStart = data.task;
          break;
        case 'cfmWtEteSEEnd':
          if(this.isEndSelected === true && data.task !== this.selectCfmWtEteSEEnd) this.selectCfmWtEteSEStart = null;
          this.selectCfmWtEteSEEnd = data.task;
          break;
        case 'cfmWtPStart':
          this.selectCfmWtPStart = data.task;
          break;
        case 'cfmWtPEnd':
          this.selectCfmWtPEnd = data.task;
          break;
        case 'cfmWtPSEStart':
          if(this.isStartSelected === true && data.task !== this.selectCfmWtPSEStart) this.selectCfmWtPSEEnd = null;
          this.selectCfmWtPSEStart = data.task;
          break;
        case 'cfmWtPSEEnd':
          if(this.isEndSelected === true && data.task !== this.selectCfmWtPSEEnd) this.selectCfmWtPSEStart = null;
          this.selectCfmWtPSEEnd = data.task;
          break;
        // Cycle time
        case 'cfmCtEteStart':
          this.selectCfmCtEteStart = data.task;
          break;
        case 'cfmCtEteEnd':
          this.selectCfmCtEteEnd = data.task;
          break;
        case 'cfmCtEteSEStart':
          if(this.isStartSelected === true && data.task !== this.selectCfmCtEteSEStart) this.selectCfmCtEteSEEnd = null;
          this.selectCfmCtEteSEStart = data.task;
          break;
        case 'cfmCtEteSEEnd':
          if(this.isEndSelected === true && data.task !== this.selectCfmCtEteSEEnd) this.selectCfmCtEteSEStart = null;
          this.selectCfmCtEteSEEnd = data.task;
          break;
        default:
          if(this.selectedRuleType === 'Activity duration') {
            this.selectDurationData = [data.task];
          };
          break;
      };
    });
    this.$emitter.on('getListSequence', (data) => {
      switch (data.category) {
        case 'cfmSeqDirectly':
          this.selectCfmSeqDirectly = data.task;
          break;
        case 'cfmSeqEventually':
          this.selectCfmSeqEventually = data.task;
          break;
        default:
          break;
      }
    });
    // Radio 切換時，資料要清空
    this.$emitter.on('isRadioChange', (data) => {
      if(data) {
        this.selectTimeReset();
        this.selectDurationTime = { min: 0, max: 0};
      };
    });
    this.$emitter.on('isRadioSeqChange', (data) => {
      if(data) {
        this.selectTimeReset();
      };
    });
    this.$emitter.on('isRadioProcessScopeChange', (data) => {
      if(data) {
        this.selectTimeReset();
        this.selectDurationTime = { min: 0, max: 0};
      };
    });
    this.$emitter.on('isRadioActSeqMoreChange', (data) => {
      if(data) {
        this.selectTimeReset();
        if(this.selectedActSeqMore !== 'All') this.selectDurationTime = { min: 0, max: 0};
      };
    });
    this.$emitter.on('isRadioActSeqFromToChange', (data) => {
      if(data) {
        this.selectTimeReset();
        this.selectDurationTime = { min: 0, max: 0};
      };
    });
  },
  beforeUnmount() {
    this.isSubmitReset();
    this.selectTimeReset();
  },
}
</script>
<style>
.text-shadow{
  text-shadow: 1.5px 1px 8px black;
}
</style>
