riku
2024-10-15 e38ea524ec4107ed7f8b1d7491a4177632dd3402
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<template>
  <el-row justify="space-between">
    <el-text>单日计划</el-text>
    <el-button type="success" size="small" @click="editTask">新增</el-button>
  </el-row>
  <el-divider />
  <ItemSubTask v-for="stask in curSubTaskList" :key="stask.guid" :item="stask">
    <template #default="{ item }">
      <el-button type="danger" size="small" @click="editTask">移除</el-button>
    </template>
  </ItemSubTask>
</template>
<script setup>
import { ref, watch, onMounted } from 'vue';
import taskApi from '@/api/fysp/taskApi';
 
const props = defineProps({
  // 日任务
  dayTask: Object
});
 
// 巡查子任务集合
const curSubTaskList = ref([]);
 
// 监听日任务变化
watch(
  () => props.dayTask,
  (nV, oV) => {
    // if (nV != oV) {
    //   onDayTaskChange(nV)
    // }
    onDayTaskChange(nV)
  },
  { immediate: true }
);
 
// 根据日任务获取对应子任务
function onDayTaskChange(dayTask) {
  if (dayTask) {
    fetchSubTask(dayTask.guid);
  } else {
    curSubTaskList.value = [];
  }
}
 
// 获取巡查子任务
function fetchSubTask(dayTaskId) {
  taskApi.fetchSubtaskByDayTask(dayTaskId).then((res) => {
    curSubTaskList.value = res;
  });
}
</script>
<style scoped></style>