<template>
  <!-- 任务名 跳转详情页 -->
  <view class="u-font-14 flex justify-between item-center">
    {{ task.name }}
    <u-icon name="arrow-right" class="ml-3" @click="toDetail(task)"></u-icon>
  </view>
</template>

<script setup>
  import { useStore } from 'vuex';

  const store = useStore();

  defineProps({ task: { type: Object, default: () => {} } });

  function toDetail(task) {
    store.commit('task/clearTasks'); // 清空定期任务
    store.commit('task/clearRealTasks'); // 清空真实任务数据
    store.commit('socket/setCurrLocationTaskId', '');
    store.commit('task/setUpNextPage', 1);
    store.commit('task/setDownNextPage', 1);
    store.commit('task/setTimeLineType', 1);
    store.commit('role/setRoleId', '');
    
    const { id, projectId, executorRoleId, businessUrl, businessCode } = task;
    uni.reLaunch({ url: `/pages/project/project?p=${projectId}&url=${encodeURIComponent(businessUrl)}&businessCode=${businessCode}&taskId=${id}&roleId=${executorRoleId}` });
  }
</script>

<style>
</style>