riku
2024-01-09 023ea35893ed047887a43555509335eec7a8b161
src/components/bg-task/FYBgTaskCard.vue
@@ -21,7 +21,7 @@
      </el-col>
      <el-col :span="20" class="p-l-8">
        <el-row justify="space-between">
          <el-text class="m-l-4px w-150px" tag="b" size="large" truncated>{{ model.name }}</el-text>
          <el-text class="m-l-4px w-300px" tag="b" size="large" truncated>{{ model.name }}</el-text>
          <el-tag>{{ nameToLabel(model.type) }}</el-tag>
        </el-row>
        <el-row class="p-v-8" align="bottom">
@@ -91,12 +91,13 @@
</template>
<script>
import { nTlBgTask, BG_TASK_STATUS } from '@/enum/bgTask';
import { useTimer } from '../../composables/timer';
import { useTimer } from '@/composables/timer';
// import { useTimer } from '@/composables/timer2';
export default {
  setup() {
    const { time, startTimer, pauseTimer, stopTimer } = useTimer();
    return { time, startTimer, pauseTimer, stopTimer };
    const { time, startTimer, pauseTimer, stopTimer, count } = useTimer();
    return { time, startTimer, pauseTimer, stopTimer, count };
  },
  props: {
    model: Object,
@@ -110,6 +111,30 @@
      removeConfirm: false
    };
  },
  watch: {
    'model.status': {
      handler(nV) {
        switch (nV) {
          case BG_TASK_STATUS.WAITING.name:
            this.stopTimer();
            break;
          case BG_TASK_STATUS.RUNNING.name:
            this.startTimer();
            break;
          case BG_TASK_STATUS.SUCCESS.name:
          case BG_TASK_STATUS.FAIL.name:
          case BG_TASK_STATUS.SHUTDOWN.name:
            this.pauseTimer();
            break;
          default:
            this.stopTimer();
            break;
        }
        this.count = this.model.runTime
      },
      immediate: true
    }
  },
  computed: {
    waiting() {
      return this.model.status == BG_TASK_STATUS.WAITING.name;