From 4e3bc8ddc20f6ba3204747a7cdb5f9c17b7b6fd8 Mon Sep 17 00:00:00 2001 From: 1708-huayu <57060237+1708-huayu@users.noreply.github.com> Date: Tue, 29 Jul 2025 18:47:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BA=8C=E7=BB=B4=E7=A0=81=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DiaryOption.tsx | 75 ++- src/components/SettingCron.tsx | 270 +++++++++++ src/components/SettingCton.module.css | 87 ++++ src/components/ShareOption.tsx | 99 ++-- src/components/StepSort.tsx | 112 +++++ src/components/type/TaskSort.d.tsx | 5 + src/ui/task/calendar/CalShow.tsx | 7 +- src/ui/task/project/DetailModelForm.tsx | 620 ++++++++++++------------ 8 files changed, 904 insertions(+), 371 deletions(-) create mode 100644 src/components/SettingCron.tsx create mode 100644 src/components/SettingCton.module.css create mode 100644 src/components/StepSort.tsx create mode 100644 src/components/type/TaskSort.d.tsx diff --git a/src/components/DiaryOption.tsx b/src/components/DiaryOption.tsx index 0825d4e..9cc40ff 100644 --- a/src/components/DiaryOption.tsx +++ b/src/components/DiaryOption.tsx @@ -16,16 +16,13 @@ import {OPERATION_BUTTON_TYPE} from "@/lib/task/project/data"; const DiaryOption = (props: SelectDiary) => { // 抽屉 start const [open, setOpen] = useState(false); - const showDrawer = () => { - setOpen(true); - }; const onClose = () => { setOpen(false); }; // 抽屉 end const [shouldScroll, setShouldScroll] = React.useState(true); // 设置高度 start - const { height } = useWindowSize(); + const {height} = useWindowSize(); const [containerHeight, setContainerHeight] = useState(400); useEffect(() => { setDiaryList([]) @@ -55,7 +52,7 @@ const DiaryOption = (props: SelectDiary) => { // observer.observe(contentRef.current); // // return () => observer.disconnect(); - }, [open,height]); + }, [open, height]); // 设置高度 end // 头按钮设置 start @@ -99,7 +96,7 @@ const DiaryOption = (props: SelectDiary) => { } const appendData = (showMessage = true) => { - if (!open){ + if (!open) { return } const fakeDataUrl = process.env.NEXT_PUBLIC_TODO_REQUEST_URL + `/task/message/diary/select`; @@ -202,58 +199,58 @@ const DiaryOption = (props: SelectDiary) => { const [popConfirmLoading, setPopConfirmLoading] = useState(false); const popConfirmOk = () => { setPopConfirmLoading(true) - if (clickTaskDiary){ - deleteTaskLogByIdAPI(clickTaskDiary.id).then(res=>{ - if (res.data.status.success){ + if (clickTaskDiary) { + deleteTaskLogByIdAPI(clickTaskDiary.id).then(res => { + if (res.data.status.success) { setDiaryList(diaryList.filter(taskLog => taskLog.id != clickTaskDiary.id)) message.info("删除成功") setPopConfirmLoading(false) setPopConfirmOpen(false) - }else { + } else { message.error(res.data.status.message) } }) } } - const handleCancel = () =>{ + const handleCancel = () => { setPopConfirmOpen(false) } - const editEnableFlag = (enableFlag:string) => { - if (clickTaskDiary){ - editEnableFlagAPI(clickTaskDiary.id,enableFlag).then(res=>{ - if (res.data.status.success){ + const editEnableFlag = (enableFlag: string) => { + if (clickTaskDiary) { + editEnableFlagAPI(clickTaskDiary.id, enableFlag).then(res => { + if (res.data.status.success) { setDiaryList(diaryList.map(taskLog => { - if(taskLog.id == clickTaskDiary.id){ + if (taskLog.id == clickTaskDiary.id) { taskLog.enableFlag = enableFlag; } return taskLog; })) message.info("设置成功") - }else { + } else { message.error(res.data.status.message) } }) } } - const [addTaskOpen,setAddTaskOpen] = useState(false) + const [addTaskOpen, setAddTaskOpen] = useState(false) const commonItems: MenuProps['items'] = [ { label: '复制', key: '1', onClick: () => { - copyToClipboard(clickTaskDiary!.description).then(res=>{ - res && message.info(`复制成功${clickTaskDiary!.description.length>5?clickTaskDiary!.description.substring(0,5)+"...":clickTaskDiary!.description}`) + copyToClipboard(clickTaskDiary!.description).then(res => { + res && message.info(`复制成功${clickTaskDiary!.description.length > 5 ? clickTaskDiary!.description.substring(0, 5) + "..." : clickTaskDiary!.description}`) }) } }, { label: '创建计划', key: '3', - onClick:()=>{ - // 打开添加任务窗口 + onClick: () => { + // 打开添加任务窗口 setAddTaskOpen(true) } }, @@ -267,28 +264,26 @@ const DiaryOption = (props: SelectDiary) => { { label: '取消', key: '5', - onClick:()=>{ + onClick: () => { setClickTaskDiary(undefined) } }, ] - const items: MenuProps['items'] = [ - ]; + const items: MenuProps['items'] = []; items.push(...commonItems) - items.splice(1,0,{ + items.splice(1, 0, { label: '失效', key: '2', - onClick:()=>{ + onClick: () => { editEnableFlag("0") }, }) - const itemsEnable: MenuProps['items'] = [ - ]; + const itemsEnable: MenuProps['items'] = []; itemsEnable.push(...commonItems) - itemsEnable.splice(1,0,{ + itemsEnable.splice(1, 0, { label: '生效', key: '2', - onClick:()=>{ + onClick: () => { editEnableFlag("1") }, }) @@ -296,7 +291,7 @@ const DiaryOption = (props: SelectDiary) => { return ( - { 5 ? item.description.substring(0, 5) + '...' : item.description}?`} - open={popConfirmOpen&&clickTaskDiary?.id==item.id} + open={popConfirmOpen && clickTaskDiary?.id == item.id} onConfirm={popConfirmOk} okButtonProps={{loading: popConfirmLoading}} onCancel={handleCancel} @@ -420,13 +415,13 @@ const DiaryOption = (props: SelectDiary) => { - {addTaskOpen&&setAddTaskOpen(false)} - taskContent={clickTaskDiary?.description} + {addTaskOpen && setAddTaskOpen(false)} + taskContent={clickTaskDiary?.description} />} ); diff --git a/src/components/SettingCron.tsx b/src/components/SettingCron.tsx new file mode 100644 index 0000000..52a6dd6 --- /dev/null +++ b/src/components/SettingCron.tsx @@ -0,0 +1,270 @@ +import React, {useState, useEffect, Fragment} from 'react'; +import dayjs, {Dayjs} from 'dayjs'; +import {Button, Input, Modal, Segmented} from 'antd'; +import style from "@/components/SettingCton.module.css" + +type PresetType = 'everyMinute' | 'everyHour' | 'daily' | 'weekly' | 'monthly'; + +interface CronGeneratorProps { + setCronFunction: (data: boolean) => void; + cron?: string; +} + +const CronGenerator: React.FC = ({setCronFunction, cron}) => { + const [showModal,setShowModal] = useState(false); + const [current, setCurrent] = useState(0); + const [cronSeconds, setCronSeconds] = useState(cron ? cron.split(' ')[0] : '*'); + const [cronMinutes, setCronMinutes] = useState(cron ? cron.split(' ')[1] : '*'); + const [cronHours, setCronHours] = useState(cron ? cron.split(' ')[2] : '*'); + const [cronDayOfMonth, setCronDayOfMonth] = useState(cron ? cron.split(' ')[3] : '*'); + const [cronMonth, setCronMonth] = useState(cron ? cron.split(' ')[4] : '*'); + const [cronDayOfWeek, setCronDayOfWeek] = useState(cron ? cron.split(' ')[5] : '*'); + const [everyNumber, setEveryNumber] = useState(1); + const [nextOccurrences, setNextOccurrences] = useState([]); + const [fullCronExpression, setFullCronExpression] = useState( + `${cronMinutes} ${cronHours} ${cronDayOfMonth} ${cronMonth} ${cronDayOfWeek}`.trim() + ); + + const titleItem = ['具体时间', '周期', '自定义cron']; + + useEffect(() => { + setFullCronExpression(`${cronMinutes} ${cronHours} ${cronDayOfMonth} ${cronMonth} ${cronDayOfWeek}`.trim()); + }, [cronMinutes, cronHours, cronDayOfMonth, cronMonth, cronDayOfWeek]); + + const onClickItem = (index: number) => { + setCurrent(index); + }; + + const onClickConfirmCron = () => { + if (fullCronExpression) { + try { + // Replace generateNextTimeAPI with your actual API call + // generateNextTimeAPI('0 ' + fullCronExpression).then(res => { + // setNextOccurrences(res.map((next: string) => dayjs(next))); + // setCronFunction(false); + // }); + console.log('Cron confirmed:', fullCronExpression); + setCronFunction(false); + } catch (error) { + console.error('Cron expression is invalid', error); + } + } else { + setCronFunction(false); + } + }; + + const resetOccurrences = () => { + setCronSeconds('0'); + setCronMinutes('*'); + setCronHours('*'); + setCronDayOfMonth('*'); + setCronMonth('*'); + setCronDayOfWeek('*'); + }; + + const generateNextOccurrences = () => { + try { + if (!fullCronExpression) { + console.error('Please set the next generation time correctly'); + return; + } + console.log('cron' + fullCronExpression); + // Replace generateNextTimeAPI with your actual API call + // generateNextTimeAPI('0 ' + fullCronExpression).then(res => { + // setNextOccurrences(res.map((next: string) => dayjs(next))); + // }); + } catch (error) { + console.error('Cron expression is invalid', error); + } + }; + + const setPreset = (type: PresetType) => { + switch (type) { + case 'everyMinute': + setCronSeconds('0'); + setCronMinutes(`*/${everyNumber}`); + setCronHours('*'); + setCronDayOfMonth('*'); + setCronMonth('*'); + setCronDayOfWeek('*'); + break; + case 'everyHour': + setCronSeconds('0'); + setCronMinutes('0'); + setCronHours(`*/${everyNumber}`); + setCronDayOfMonth('*'); + setCronMonth('*'); + setCronDayOfWeek('*'); + break; + case 'daily': + setCronSeconds('0'); + setCronMinutes('0'); + setCronHours('0'); + setCronDayOfMonth(`*/${everyNumber}`); + setCronMonth('*'); + setCronDayOfWeek('*'); + break; + case 'weekly': + setCronSeconds('0'); + setCronMinutes('0'); + setCronHours('0'); + setCronDayOfMonth('*'); + setCronMonth('*'); + setCronDayOfWeek(`${everyNumber}`); + break; + case 'monthly': + setCronSeconds('0'); + setCronMinutes('0'); + setCronHours('0'); + setCronDayOfMonth('1'); + setCronMonth('*'); + setCronDayOfWeek('*'); + break; + } + }; + + return ( + + + setShowModal(false)} + > +
+
+
+ onClickItem(titleItem.indexOf(value as string))} + block + /> +
+
+ {current === 0 && ( + <> +
+
分钟(0-59)
+ + setCronMinutes(e.target.value)} + placeholder="*" + /> +
+ +
+
小时(0-23)
+ + setCronHours(e.target.value)} + placeholder="*" + /> +
+ +
+
日期(1-31)
+ setCronDayOfMonth(e.target.value)} + placeholder="*" + /> +
+ +
+
月份(1-12)
+ setCronMonth(e.target.value)} + placeholder="*" + /> +
+ +
+
星期(0-6,0=周日)
+ setCronDayOfWeek(e.target.value)} + placeholder="*" + /> +
+ + )} + + {current === 1 && ( +
+
+ setEveryNumber(parseInt(e.target.value) || 1)} + placeholder="1" + /> +
+ + + + + +
+ )} + {current === 2 && ( +
+
!!!目前只支持5位设定,分钟、小时、日、月、星期
+ setFullCronExpression(e.target.value)}/> +
+ )} +
+
+ + +
+
+ + {nextOccurrences.length > 0 && ( +
+
最近触发时间:
+ {nextOccurrences.map((item, index) => ( +
+
{dayjs(item).format('YYYY-MM-DD HH:mm')}
+
+ ))} +
+ )} + +
+
+
+ + ); +}; + +export default CronGenerator; \ No newline at end of file diff --git a/src/components/SettingCton.module.css b/src/components/SettingCton.module.css new file mode 100644 index 0000000..7614134 --- /dev/null +++ b/src/components/SettingCton.module.css @@ -0,0 +1,87 @@ +.container { + padding: 20px; + background-color: #f5f5f5; + min-height: 100vh; +} + +.header { + margin-bottom: 20px; +} + +.title { + font-size: 20px; + font-weight: bold; + color: #000; +} + +.content { + margin-top: 10px; +} + +.cronForm { + background-color: #fff; + border-radius: 8px; + padding: 15px; + margin-bottom: 20px; +} + +.formItem { + margin-bottom: 15px; +} + +.label { + display: block; + margin-bottom: 5px; + font-size: 14px; + color: #333; +} + +.input { + width: 90%; + padding: 10px; + border: 1px solid #ddd; + border-radius: 4px; + font-size: 14px; +} + +.results { + background-color: #fff; + border-radius: 8px; + padding: 15px; + margin-bottom: 20px; +} + +.resultsTitle { + font-weight: bold; + margin-bottom: 10px; + display: block; +} + +.occurrence-item { + padding: 8px 0; + border-bottom: 1px solid #eee; +} + +.presetButtons { + display: flex; + flex-wrap: wrap; + gap: 10px; + margin-bottom: 10px; +} + +.buttonFlex { + display: flex; + gap: 10px; + margin-top: 10px; +} + +.presetBtn { + background-color: #f0f0f0; + color: #000; + padding: 8px 12px; + border-radius: 4px; + font-size: 14px; + flex: 1; + min-width: 100px; + border: 1px solid #d9d9d9; +} \ No newline at end of file diff --git a/src/components/ShareOption.tsx b/src/components/ShareOption.tsx index d70a21e..c513ad4 100644 --- a/src/components/ShareOption.tsx +++ b/src/components/ShareOption.tsx @@ -1,39 +1,60 @@ import React, {Fragment, useEffect, useState} from 'react'; -import {Button, Image, Modal, QRCode} from 'antd'; -import { v4 as uuidv4 } from 'uuid'; +import {Button, Image, Input, Modal, QRCode, Space } from 'antd'; +import {v4 as uuidv4} from 'uuid'; +import {copyToClipboard} from "@/lib/copyToClipboard"; -const ShareOption = (props:{taskId:string} ) => { - const [loading, setLoading] = useState(false); +const ShareOption = (props: { taskId: string }) => { + // const [loading, setLoading] = useState(false); const [open, setOpen] = useState(false); - const [buttonIndex, setButtonIndex] = useState(0); + const [buttonIndex, setButtonIndex] = useState(1); const [qrCodeValue, setQrCodeValue] = useState("-"); - const [qrCodeStatus, setQrCodeStatus]=useState<'active' | 'expired' | 'loading' | 'scanned'>("active"); + const [qrCodeStatus, setQrCodeStatus] = useState<'active' | 'expired' | 'loading' | 'scanned'>("loading"); - const generateQrcode =()=>{ + function doDownload(url: string, fileName: string) { + const a = document.createElement('a'); + a.download = fileName; + a.href = url; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + } + + const downloadCanvasQRCode = () => { + const canvas = document.getElementById('myqrcode')?.querySelector('canvas'); + if (canvas) { + const url = canvas.toDataURL(); + doDownload(url, 'QRCode.png'); + } + }; + + const downloadSvgQRCode = () => { + const svg = document.getElementById('myqrcode')?.querySelector('svg'); + const svgData = new XMLSerializer().serializeToString(svg!); + const blob = new Blob([svgData], {type: 'image/svg+xml;charset=utf-8'}); + const url = URL.createObjectURL(blob); + console.log({url}) + doDownload(url, '微信小程序马上行计划管理扫码加入计划.svg'); + }; + + const generateQrcode = () => { } const showModal = () => { setOpen(true); }; - const handleOk = () => { - setLoading(true); - setTimeout(() => { - setLoading(false); - setOpen(false); - }, 3000); - }; - const handleCancel = () => { setOpen(false); }; useEffect(() => { // 分享人必须有权限 + // 生成分享信息同时适用链接和二维码 const clientId: string = uuidv4(); - let qrCodeData={ - taskId:props.taskId,pass:clientId,local:"马上行计划管理",opType:"SHARE_OPTION" + let qrCodeData = { + taskId: props.taskId, pass: clientId, local: "马上行计划管理", opType: "SHARE_OPTION" } setQrCodeValue(JSON.stringify(qrCodeData)) + setQrCodeStatus("active") }, []); return ( @@ -43,41 +64,55 @@ const ShareOption = (props:{taskId:string} ) => { 返回 , - , , ]} > - {buttonIndex==1&&
-
+ {buttonIndex == 1 &&
+
微信小程序二维码
- +
-
+
小程序扫描二维码,有效期7天
- - + +
} - + {buttonIndex == 2 &&
+
分享链接7日内有效
+ + + + +
} ); diff --git a/src/components/StepSort.tsx b/src/components/StepSort.tsx new file mode 100644 index 0000000..356f4ba --- /dev/null +++ b/src/components/StepSort.tsx @@ -0,0 +1,112 @@ +import React, {CSSProperties, Fragment, useState} from "react"; +import {DragDropContext, Droppable, Draggable, DropResult, DraggingStyle, NotDraggingStyle} from "react-beautiful-dnd"; +import {TaskStepSortVO} from "@/components/type/TaskSort.d"; +import {Button, Drawer} from "antd"; + +// fake data generator +const getItems = (count: number, offset = 0) => + Array.from({length: count}, (v, k) => k).map(k => ({ + id: `item-${k + offset}-${new Date().getTime()}`, + stepDesc: `item ${k + offset}`, + sortIndex: k + offset, + })); + +const reorder = (list: TaskStepSortVO[], startIndex: number, endIndex: number) => { + const result = Array.from(list); + const [removed] = result.splice(startIndex, 1); + result.splice(endIndex, 0, removed); + + return result; +}; +const grid = 8; + +const getItemStyle = (isDragging: boolean, draggableStyle: DraggingStyle | NotDraggingStyle | undefined): CSSProperties => ({ + // some basic styles to make the items look a bit nicer + userSelect: "none", + padding: grid * 2, + margin: `0 0 ${grid}px 0`, + + // change background colour if dragging + background: isDragging ? "lightgreen" : "grey", + + // styles we need to apply on draggables + ...draggableStyle +}); +const getListStyle = (isDraggingOver: boolean) => ({ + background: isDraggingOver ? "lightblue" : "lightgrey", + padding: grid, + width: 250 +}); + +const StepSort = (props: { taskId: string }) => { + const [state, setState] = useState(getItems(5, 10)); + // 抽屉 start + const [open, setOpen] = useState(false); + + function onDragEnd(result: DropResult) { + const {source, destination} = result; + // dropped outside the list + if (!destination) { + return; + } + const items = reorder(state, source.index, destination.index); + let newState = [...state]; + newState = items; + setState(newState); + } + + return ( + + + +
+ + + {(provided, snapshot) => ( +
+ {state.map((item, index) => ( + + {(provided, snapshot) => ( +
+
+ {item.stepDesc} +
+
+ )} +
+ ))} + {provided.placeholder} +
+ )} +
+
+
+
+
+ ); +} +export default StepSort + diff --git a/src/components/type/TaskSort.d.tsx b/src/components/type/TaskSort.d.tsx new file mode 100644 index 0000000..5bd8a46 --- /dev/null +++ b/src/components/type/TaskSort.d.tsx @@ -0,0 +1,5 @@ +export type TaskStepSortVO = { + id: string, + sortIndex: number, + stepDesc: string +} \ No newline at end of file diff --git a/src/ui/task/calendar/CalShow.tsx b/src/ui/task/calendar/CalShow.tsx index 1499ade..b722231 100644 --- a/src/ui/task/calendar/CalShow.tsx +++ b/src/ui/task/calendar/CalShow.tsx @@ -148,7 +148,7 @@ const CalShow: React.FC = () => { clearClickTimeout() clickRef.current = window.setTimeout(() => { // window.alert(event.title); - console.log(event) + console.log("event") setOperationId(OPERATION_BUTTON_TYPE.DETAIL) setDescription("任务详情") setItemId(event.resource) @@ -265,7 +265,10 @@ const CalShow: React.FC = () => { } return
- {open && setOpen(false)} diff --git a/src/ui/task/project/DetailModelForm.tsx b/src/ui/task/project/DetailModelForm.tsx index 571685b..114afb1 100644 --- a/src/ui/task/project/DetailModelForm.tsx +++ b/src/ui/task/project/DetailModelForm.tsx @@ -6,8 +6,8 @@ import { ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect, } from '@ant-design/pro-components'; -import {Button, Form, message, Popconfirm} from 'antd'; -import React, {useEffect, useState} from "react"; +import {Button, Form, message, Popconfirm, Spin} from 'antd'; +import React, {Fragment, useEffect, useState} from "react"; import { addTask, deleteTask, getTask, getTaskTreeResult, @@ -19,12 +19,14 @@ import {DataType} from "@/lib/definitions"; import dayjs, {Dayjs} from "dayjs"; import DiaryOption from "@/components/DiaryOption"; import ShareOption from "@/components/ShareOption"; +import StepSort from "@/components/StepSort"; +import SettingCron from "@/components/SettingCron"; export type DetailModelFormProps = { // 当前内容id itemId?: string, pid?: string, - taskType?:string, + taskType?: string, // 祖宗任务id pPid?: string, // 操作id @@ -52,6 +54,8 @@ export const DetailModelForm: React.FC = (props) => { const [editFormDisable, setEditFormDisable] = useState(props.operationId === OPERATION_BUTTON_TYPE.DETAIL) // 团队第一层 pid必须为0 const [taskType, setTaskType] = useState('0') + const [spinning, setSpinning] = useState(true) + const [operationRequest,setOperationRequest] = useState(false) useEffect(() => { if (props.itemId != undefined && ( props.operationId === OPERATION_BUTTON_TYPE.DETAIL || props.operationId === OPERATION_BUTTON_TYPE.UPDATE)) { @@ -69,13 +73,19 @@ export const DetailModelForm: React.FC = (props) => { if (task.data.pid == "0") { form.setFieldValue("pid", undefined) } + if (task.data.taskType) { + setTaskType(task.data.taskType) + } setRequestTask(task.data) console.log("form.setFieldsValue(task.data)" + JSON.stringify(task.data)) } else { message.error(task.status.message); props.reloadData?.() } - }) + }).finally(() => { + setSpinning(false) + } + ) } else if (props.operationId === OPERATION_BUTTON_TYPE.ADD || props.operationId === OPERATION_BUTTON_TYPE.ADD_CHILD) { let data = { 'expectedTimeRange': [props.expectedStartTime ? props.expectedStartTime : dayjs(), props.expectedEndTime], @@ -84,6 +94,7 @@ export const DetailModelForm: React.FC = (props) => { 'name': props.taskContent && props.taskContent?.length > 10 ? props.taskContent.substring(0, 10) : props.taskContent, }; form.setFieldsValue(data) + setSpinning(false) } }, [props]) @@ -105,309 +116,324 @@ export const DetailModelForm: React.FC = (props) => { // 所以你需要用 setFieldsValue 来更新。 initialValues 只在 form 初始化时生效且只生效一次,如果你需要异步加载, // 推荐使用 request,或者 initialValues ?
: null return ( - - title={props.description} - open={props.open && !props.haveButton} - trigger={props.haveButton ? - : undefined - } - form={form} - autoFocusFirstInput - modalProps={{ - destroyOnClose: true, - onCancel: () => { - props.reloadData?.(); - }, - }} - readonly={editFormDisable} - submitter={props.itemId !== undefined && props.itemId !== '-1' ? { - render: (prop, defaultDoms) => { - console.log("submitter render: ", {prop}) - let result = [ - editFormDisable ? : undefined, - props.operationId === OPERATION_BUTTON_TYPE.DETAIL || props.operationId === OPERATION_BUTTON_TYPE.UPDATE ? - } - okText="确认" - cancelText="取消" - onConfirm={() => { - if (props.itemId !== undefined) { - deleteTask(props.itemId).then((response => { - console.log('response', response) - if (response.status.success) { - message.success("删除任务成功:" + response.data) - props.reloadData?.() - } - })); - } + + + + title={props.description} + open={!spinning&&props.open && !props.haveButton} + trigger={props.haveButton ? + : undefined + } + form={form} + loading={operationRequest} + autoFocusFirstInput + modalProps={{ + destroyOnClose: true, + onCancel: () => { + props.reloadData?.(); + }, + }} + readonly={editFormDisable} + submitter={props.itemId !== undefined && props.itemId !== '-1' ? { + render: (prop, defaultDoms) => { + console.log("submitter render: ", {prop}) + let result = [ + editFormDisable ? - : undefined, - requestTask && requestTask.id ? - : undefined, - ] + >编辑 : undefined, + props.operationId === OPERATION_BUTTON_TYPE.DETAIL || props.operationId === OPERATION_BUTTON_TYPE.UPDATE ? + } + okText="确认" + cancelText="取消" + onConfirm={() => { + if (props.itemId !== undefined) { + deleteTask(props.itemId).then((response => { + console.log('response', response) + if (response.status.success) { + message.success("删除任务成功:" + response.data) + props.reloadData?.() + } + })); + } + }} + > + + : undefined, + requestTask && requestTask.id ? + : undefined, + ] - // 非新增或者编辑状态不展示 - if (!editFormDisable) { - result.push(...defaultDoms) + // 非新增或者编辑状态不展示 + if (!editFormDisable) { + result.push(...defaultDoms) + } else { + if (editFormDisable && taskType == '1') { + result.push() + } + if (editFormDisable && taskType == '2') { + result.push() + } + result.push() + } + return result; + }, + } : { + render: (prop, defaultDoms) => { + console.log("submitter render: ", {prop}, {props}, {taskType}, {defaultDoms}) + // if ( prop.searchConfig) { + // if (taskType == '1') { + // prop.searchConfig.submitText = "创建团队" + // }else { + // prop.searchConfig.submitText = "确认" + // } + // } + // return defaultDoms; + const result = defaultDoms.filter(defaultButton => defaultButton.key == 'rest'); + result.push() + return result; + } + } + } + onFinish={async (values) => { + {/* onFinish 返回true关闭窗口,范湖false不关闭窗口 */ + } + console.log('Received values of form: ', values, {...requestTask, ...values}); + setOperationRequest(true) + if (requestTask) { + const {sortNo} = requestTask; + values.sortNo = sortNo; + } + if (values.pid === undefined) { + values.pid = '0' + } + if (values.expectedTimeRange?.[0] != undefined) { + values.expectedStartTime = dayjs(values.expectedTimeRange[0]).format() + } + if (values.expectedTimeRange?.[1] != undefined) { + values.expectedEndTime = dayjs(values.expectedTimeRange[1]).format() + } + if (values.actualTimeRange?.[0] != undefined) { + values.actualStartTime = dayjs(values.actualTimeRange[0]).toDate() + } + if (values.actualTimeRange?.[1] != undefined) { + values.actualEndTime = dayjs(values.actualTimeRange[1]).toDate() + } + var result: boolean = false; + + let state = taskStateList.find(taskState => taskState.name === values.state?.toString()); + if (state) { + values.state = state.code + } + let priority = taskPriorityList.find(taskPriority => taskPriority.name === values.priority?.toString()) + if (priority) { + values.priority = priority.code + } + // todo 修改 + if (props.operationId === OPERATION_BUTTON_TYPE.UPDATE || (props.operationId === OPERATION_BUTTON_TYPE.DETAIL && !editFormDisable)) { + await updateTask(values).then(response => { + console.log('response', response) + if (response.status.success) { + message.success("修改任务成功:" + response.data) + // 树任务重新刷新 + // 四象限任务重新刷新 + // 如果可以直接更新列表而不请求。。。。。。 + console.log('props.reloadData?.()', props.reloadData) + props.reloadData?.() + result = true + } else { + message.error(response.status.message) + result = false + } + } + ); } else { - if (props.taskType=='1') { - result.push() - } - result.push() + await addTask(values).then(response => { + console.log('response', response) + if (response.data.status.success) { + message.success(`添加计划${response.data.data.name}成功`) + // 树任务重新刷新 + // 四象限任务重新刷新 + // 如果可以直接更新列表而不请求。。。。。。 + console.log('props.reloadData?.()', props.reloadData) + result = (taskType != '1') + props.reloadData?.() + } else { + message.error(response.data.status.message) + result = false + } + } + ); } + setOperationRequest(false) return result; - }, - } : { - render: (prop, defaultDoms) => { - console.log("submitter render: ", {prop}, {props},{taskType},{defaultDoms}) - // if ( prop.searchConfig) { - // if (taskType == '1') { - // prop.searchConfig.submitText = "创建团队" - // }else { - // prop.searchConfig.submitText = "确认" - // } - // } - // return defaultDoms; - const result = defaultDoms.filter(defaultButton=>defaultButton.key=='rest'); - result.push() - return result; - } - } - } - onFinish={async (values) => { - {/* onFinish 返回true关闭窗口,范湖false不关闭窗口 */ - } - console.log('Received values of form: ', values, {...requestTask, ...values}); - if (requestTask) { - const {sortNo} = requestTask; - values.sortNo = sortNo; - } - if (values.pid === undefined) { - values.pid = '0' - } - if (values.expectedTimeRange?.[0] != undefined) { - values.expectedStartTime = dayjs(values.expectedTimeRange[0]).format() - } - if (values.expectedTimeRange?.[1] != undefined) { - values.expectedEndTime = dayjs(values.expectedTimeRange[1]).format() - } - if (values.actualTimeRange?.[0] != undefined) { - values.actualStartTime = dayjs(values.actualTimeRange[0]).toDate() - } - if (values.actualTimeRange?.[1] != undefined) { - values.actualEndTime = dayjs(values.actualTimeRange[1]).toDate() - } - var result: boolean = false; - - let state = taskStateList.find(taskState => taskState.name === values.state?.toString()); - if (state) { - values.state = state.code - } - let priority = taskPriorityList.find(taskPriority => taskPriority.name === values.priority?.toString()) - if (priority) { - values.priority = priority.code - } - // todo 修改 - if (props.operationId === OPERATION_BUTTON_TYPE.UPDATE || (props.operationId === OPERATION_BUTTON_TYPE.DETAIL && !editFormDisable)) { - await updateTask(values).then(response => { - console.log('response', response) - if (response.status.success) { - message.success("修改任务成功:" + response.data) - // 树任务重新刷新 - // 四象限任务重新刷新 - // 如果可以直接更新列表而不请求。。。。。。 - console.log('props.reloadData?.()', props.reloadData) - props.reloadData?.() - result = true - } else { - message.error(response.status.message) - result = false - } - } - ); - } else { - await addTask(values).then(response => { - console.log('response', response) - if (response.data.status.success) { - message.success(`添加计划${response.data.data.name}成功`) - // 树任务重新刷新 - // 四象限任务重新刷新 - // 如果可以直接更新列表而不请求。。。。。。 - console.log('props.reloadData?.()', props.reloadData) - result = (taskType!='1') - props.reloadData?.() - } else { - message.error(response.data.status.message) - result = false - } - } - ); - } - return result; - }} - > -