<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>
|