From a8ebb37b2239f25cb290054513c3ef2c1e7989b9 Mon Sep 17 00:00:00 2001 From: jiangyouyi <763484914@qq.com> Date: Thu, 10 Aug 2023 18:05:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/task/edit.vue | 43 ++++++++++------------ src/views/task/taskCalendar.vue | 65 +++++++++++++++++++++++++-------- 2 files changed, 69 insertions(+), 39 deletions(-) diff --git a/src/views/task/edit.vue b/src/views/task/edit.vue index 2aaf88e..30439ad 100644 --- a/src/views/task/edit.vue +++ b/src/views/task/edit.vue @@ -8,21 +8,15 @@ @confirm="handleSubmit" @close="handleClose" > - - - + + + - - + + - - + + @@ -35,7 +29,7 @@ import type { FormInstance } from "element-plus"; import Popup from "@/components/popup/index.vue"; import { apiTaskCreat, apiTaskView } from "@/api/task"; import { timeFormat } from "@/utils/util"; -import { reactive, onMounted, type PropType } from "vue"; +import { reactive,onUpdated , type PropType } from "vue"; import DialogIndexMan from "./dialog_index_man.vue"; const props = defineProps({ dictData: { @@ -57,14 +51,17 @@ const popupRef = shallowRef>(); const mode = ref("add"); const datetime = ref(null); const detailsdt = ref({}); +const defaultTime = ref({ + starttime:"", + endtime:"" +}); // 弹窗标题 // const popupTitle = computed(() => { // return mode.value == "edit" ? "创建日程安排" : "新增任务"; // }); -onMounted(() => { - // props.detailsdata?.toDateString()? (detailsdt = props.detailsdata):null; - +onUpdated(() => { + detailsdt.value=props.detailsdata }); const priorityList = reactive([ @@ -163,12 +160,12 @@ function customEventManThe(data: any) { } // 提交按钮 -const handleSubmit = async () => { - const data = { ...formData }; - mode.value == "edit" ? await apiTaskCreat(data) : await apiTaskCreat(data); - popupRef.value?.close(); - emit("success"); -}; +// const handleSubmit = async () => { +// const data = { ...formData }; +// mode.value == "edit" ? await apiTaskCreat(data) : await apiTaskCreat(data); +// popupRef.value?.close(); +// emit("success"); +// }; //打开弹窗 const open = (type = "add") => { diff --git a/src/views/task/taskCalendar.vue b/src/views/task/taskCalendar.vue index 1de4a6c..a7de82b 100644 --- a/src/views/task/taskCalendar.vue +++ b/src/views/task/taskCalendar.vue @@ -18,7 +18,7 @@ {{ data.day.split("-").slice(1).join("-") }}

-
{{dateNow(data.day)}}
+
{{ dateNow(data.day) }}
-
@@ -60,18 +59,53 @@ import feedback from "@/utils/feedback"; // import { getRoutePath } from "router"; import EditPopup from "./edit.vue"; import { reactive, watch } from "vue"; -import { apiTaskList ,apiTaskDetails} from '@/api/task' +import { apiTaskList, apiTaskDetails } from "@/api/task"; const dateValue = ref(new Date()); - watch(() => dateValue, async(newValue, oldValue) => { - editRef.value?.open("add"); +const detailsdata = reactive({ + create_time: "", + create_user_id: 0, + delete_time: "", + end_time: "", + extend: "", + id: "", + scheduling_id: "", + sn: "", + start_time: "", + status: "", + task_id: "", + task_info: { + admin_id: 0, + content: "", + create_time: "", + delete_time: "", + id: 0, + money: "", + status: 0, + title: "", + type: 0, + type_name: "", + update_time: "", + }, + template_id: 0, + update_time: "", +}); +watch( + () => dateValue, + async (newValue, oldValue) => { + const id = taskList.value.find((item) =>item.start_time.split(" ")[0] == timeFormat(newValue.value.getTime()))?.id; + if(id){ + const res = await apiTaskDetails({ id }); + Object.keys(detailsdata).forEach((key) => { + res[key] ? (detailsdata[key] = res[key]) : null; + }); + editRef.value?.open("add"); initShowDate(timeFormat(newValue.value.getTime())); - const id=taskList.value.find((item)=>item.start_time.split(' ')[0]==timeFormat(newValue.value.getTime())).template_id - const detailsdata = await apiTaskDetails({id}) + } + }, { deep: true } ); - // 加载 const loading = ref(true); @@ -93,9 +127,9 @@ const taskList = ref([]); const loadTask = async () => { // let res: any = await apiTaskIndex(queryParams); // taskList.value = res.lists; - apiTaskList(queryParams).then((res)=>{ - taskList.value = res.lists - }) + apiTaskList(queryParams).then((res) => { + taskList.value = res.lists; + }); loading.value = false; }; @@ -124,10 +158,10 @@ const initShowDate = (dateStr = "") => { } }; initShowDate(); -const dateNow = (day)=>{ - return taskList.value.find((item)=>item.start_time.split(' ')[0]==day)?.template_name; -} - +const dateNow = (day) => { + return taskList.value.find((item) => item.start_time.split(" ")[0] == day) + ?.template_name; +}; // 获取字典数据 // const { dictData } = useDictData(""); @@ -147,7 +181,6 @@ const handleAdd = async () => { // editRef.value?.setFormData(data); // }; - // 删除 // const handleDelete = async (id: number | any[]) => { // await feedback.confirm("确定要删除?");