src/components/bg-task/FYBgTaskCard.vue
@@ -84,6 +84,22 @@
        this.refreshTaskById(data)
      })
    },
    computeRunTime(data) {
      const taskStatus = data.status
      const startTime = new Date(data.startTime).getTime()
      const endTime = new Date(data.endTime).getTime()
      const now = (new Date()).getTime();
      switch (taskStatus) {
        case BG_TASK_STATUS.WAITING.name:
          return 0;
        case BG_TASK_STATUS.RUNNING.name:
          return (now - startTime) / 1000; // 转换为秒
        case BG_TASK_STATUS.SUCCESS.name:
        case BG_TASK_STATUS.FAIL.name:
        case BG_TASK_STATUS.SHUTDOWN.name:
          return (endTime - startTime) / 1000; // 转换为秒
      }
    },
    /**
     * 刷新一个任务通过id,如果是新的任务则添加到任务列表taskList中
     * @param data 
@@ -97,6 +113,18 @@
          const task = this.taskList[index];
          if (task.id == data.id) {
            this.taskList[index] = data
          // 时间转换
          const hasStartTime = 'startTime' in data && data.startTime != {}
          const hasEndTime = 'endTime' in data && data.endTime != {}
          if (hasEndTime) {
            this.taskList[index].endTime = this.formatDate(data.endTime)
          }
          if (hasStartTime) {
            this.taskList[index].startTime = this.formatDate(data.startTime)
          }
          if (hasStartTime && hasEndTime) {
            this.taskList[index].runTime = this.computeRunTime(this.taskList[index])
          }
            isNewTask = false
            break
          }
@@ -105,6 +133,30 @@
          this.taskList.push(data)
        }
    },
    /**
     * 拷贝属性
     * @param from
     * @param to
     */
    copyProperties(from, to) {
      for (const prop in to) {
        if (prop in from) {
          to[prop] = from[prop]
        }
      }
    },
    formatDate(date) {
      const dateObj = date.date
      const timeObj = date.time
      let year = dateObj.year;
      let month = dateObj.month < 10 ? '0' + dateObj.month : dateObj.month;
      let day = dateObj.day < 10 ? '0' + dateObj.day : dateObj.day;
      let hour = timeObj.hour < 10 ? '0' + timeObj.hour : timeObj.hour;
      let minute = timeObj.minute < 10 ? '0' + timeObj.minute : timeObj.minute;
      let second = timeObj.second < 10 ? '0' + timeObj.second : timeObj.second;
      return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
    },
    addTask() {},
    newTestTask() {
      this.fetchData((page, pageSize) => {