This commit is contained in:
mkm 2023-08-14 18:18:33 +08:00
parent 6d52c2d2db
commit 2ada816d09

View File

@ -15,7 +15,7 @@
:class="data.isSelected ? 'is-selected' : ''"
style="padding: 8px 8px 0 8px"
>
{{ data.day.split("-").slice(1).join("-") }}
{{ data.day.split('-').slice(1).join('-') }}
</p>
<div
class="task"
@ -48,17 +48,17 @@
</template>
<script lang="ts" setup name="task">
import { timeFormat } from "@/utils/util";
import feedback from "@/utils/feedback";
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
// import { getRoutePath } from "router";
import EditPopup from "./edit.vue";
import EditTowPopup from "./editTow.vue";
import { reactive, watch } from "vue";
import { apiTaskList, apiTaskDetails } from "@/api/task";
import { apiTaskSchedulingPlanAdd } from "@/api/task_scheduling_plan";
const route = useRoute();
import EditPopup from './edit.vue'
import EditTowPopup from './editTow.vue'
import { reactive, watch } from 'vue'
import { apiTaskList, apiTaskDetails } from '@/api/task'
import { apiTaskSchedulingPlanAdd } from '@/api/task_scheduling_plan'
const route = useRoute()
const dateValue = ref(new Date());
const dateValue = ref(new Date())
// watch(
// () => dateValue,
// async (newValue, oldValue) => {
@ -81,102 +81,101 @@ const dateValue = ref(new Date());
//
const task = ref({
create_user_id: 0,
end_time: "",
end_time: '',
id: 0,
scheduling_id: 0,
start_time: "",
start_time: '',
status: 0,
template_id: 0,
template_name: "",
});
const popupType = ref("add");
template_name: ''
})
const popupType = ref('add')
const clickTask = (e: any) => {
popupType.value = "show";
task.value = e;
handleSelect();
};
popupType.value = 'show'
task.value = e
handleSelect()
}
//
const loading = ref(true);
const loading = ref(true)
const editRef = shallowRef<InstanceType<typeof EditPopup>>();
const editTowRef = shallowRef<InstanceType<typeof EditPopup>>();
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const editTowRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false);
const showEditTow = ref(false);
const showEdit = ref(false)
const showEditTow = ref(false)
//
const queryParams = reactive({
start_time: "",
end_time: "",
scheduling_id: '',
start_time: '',
end_time: '',
page_no: 1,
pageSize: 150,
});
const taskList = ref<any>([]);
pageSize: 150
})
if (route.query.id) {
queryParams.scheduling_id = route.query.id.toString()
}
const taskList = ref<any>([])
//
const loadTask = async () => {
apiTaskList(queryParams).then((res) => {
taskList.value = res.lists;
});
loading.value = false;
};
taskList.value = res.lists
})
loading.value = false
}
const start_date = ref("");
const end_date = ref("");
const start_date = ref('')
const end_date = ref('')
//
const initShowDate = (dateStr = "") => {
const currentDate = dateStr ? new Date(dateStr) : new Date();
const currentYear = currentDate.getFullYear();
const currentMonth = currentDate.getMonth();
const lastDay = new Date(currentYear, currentMonth + 1, 0).getDay(); //
const startDay = new Date(currentYear, currentMonth, 1).getDay(); //
const initShowDate = (dateStr = '') => {
const currentDate = dateStr ? new Date(dateStr) : new Date()
const currentYear = currentDate.getFullYear()
const currentMonth = currentDate.getMonth()
const lastDay = new Date(currentYear, currentMonth + 1, 0).getDay() //
const startDay = new Date(currentYear, currentMonth, 1).getDay() //
// console.log(new Date(currentYear, currentMonth, 1-startDay).getDate());
// console.log(new Date(currentYear, currentMonth + 1, 6-lastDay).getDate());
start_date.value = timeFormat(
new Date(currentYear, currentMonth, 1 - startDay).getTime()
); //
end_date.value = timeFormat(
new Date(currentYear, currentMonth + 1, 6 - lastDay).getTime()
); //
start_date.value = timeFormat(new Date(currentYear, currentMonth, 1 - startDay).getTime()) //
end_date.value = timeFormat(new Date(currentYear, currentMonth + 1, 6 - lastDay).getTime()) //
if (queryParams.start_time != start_date.value) {
queryParams.start_time = start_date.value;
queryParams.end_time = end_date.value;
loading.value = true;
loadTask();
queryParams.start_time = start_date.value
queryParams.end_time = end_date.value
loading.value = true
loadTask()
}
};
initShowDate();
}
initShowDate()
//
const taskListFilter = (e: any) => {
return taskList.value
.filter((item: any) => {
let now = new Date(e).getTime() / 1000;
let start = new Date(item.start_time).getTime() / 1000;
let end = new Date(item.end_time).getTime() / 1000;
return now - start >= 0 && now - end <= 0;
const now = new Date(e).getTime() / 1000
const start = new Date(item.start_time).getTime() / 1000
const end = new Date(item.end_time).getTime() / 1000
return now - start >= 0 && now - end <= 0
})
.slice(0, 5);
};
.slice(0, 5)
}
//
const handleAdd = async () => {
popupType.value = "add";
showEditTow.value = true;
await nextTick();
editTowRef.value?.open("add");
editTowRef.value?.updatedForm();
};
popupType.value = 'add'
showEditTow.value = true
await nextTick()
editTowRef.value?.open('add')
editTowRef.value?.updatedForm()
}
//
const handleSelect = async () => {
popupType.value = "show";
showEditTow.value = true;
await nextTick();
editTowRef.value?.open("show");
editTowRef.value?.updatedForm();
};
popupType.value = 'show'
showEditTow.value = true
await nextTick()
editTowRef.value?.open('show')
editTowRef.value?.updatedForm()
}
</script>
<style lang="scss">