import { dayjs } from 'element-plus'; import { post } from "@/utils/request"; import { getFromValue } from '@/utils/tools'; import { ADD_TASK } from '@/pages/tasks/api'; // 封装新建任务请求 export async function createTask(submitData: any, isClose: boolean) : Promise { return new Promise((resolve, reject) => { const { executorId, startDate, endDate, repeatEndDate } = submitData; let params = { ...submitData, startDate: startDate && dayjs(startDate).format('YYYY-MM-DD HH:mm'), endDate: endDate && dayjs(endDate).format('YYYY-MM-DD HH:mm'), repeatEndDate: repeatEndDate && dayjs(repeatEndDate).format('YYYY-MM-DD') } if (executorId) { params = { ...params, executorId: executorId.join(','), taskLogs: [] } } post(ADD_TASK, getFromValue(params)).then(() => { resolve({ saveLoading: '3', isClose }) }).catch((err) => { reject({ saveLoading: '4', isClose, message: err.msg }) }) }) }