From 042c51d1abc3c9d7768ff52a20ad1ced0ab1ccd0 Mon Sep 17 00:00:00 2001 From: zirui liu Date: Thu, 16 Mar 2023 14:38:16 +0800 Subject: [PATCH 1/7] Distinguish between confirm and cancel --- .../components/select-target-dialog/hook.ts | 63 +++++++++++++------ .../components/select-target-dialog/index.tsx | 48 +++++++------- 2 files changed, 72 insertions(+), 39 deletions(-) diff --git a/web/src/pages/enterprise/components/select-target-dialog/hook.ts b/web/src/pages/enterprise/components/select-target-dialog/hook.ts index 26662797..ccaf0d7b 100644 --- a/web/src/pages/enterprise/components/select-target-dialog/hook.ts +++ b/web/src/pages/enterprise/components/select-target-dialog/hook.ts @@ -1,5 +1,5 @@ import { clone } from "ramda" -import { useEffect, useMemo, useState } from "react" +import { useCallback, useEffect, useMemo, useState } from "react" import { PostWeChatWorkGroupCreate } from "../../../../api/enterprise" import { IDepartmentAndUserListValue, @@ -10,7 +10,7 @@ import { DeptUserCanSelectStatus, IWorkGroupCreate, IWorkCorpAppGroup, - SendObjOrGroup + SendObjOrGroup, } from "../../../../dtos/enterprise" const useAction = (props: { @@ -22,7 +22,9 @@ const useAction = (props: { lastTagsValue: string[] | undefined tagsList: ITagsList[] clickName: string + chatId: string setOpenFunction: (open: boolean) => void + setChatId?: React.Dispatch> setIsRefresh: React.Dispatch> setOuterTagsValue: React.Dispatch> setDeptUserList: React.Dispatch> @@ -35,11 +37,13 @@ const useAction = (props: { isLoading, tagsList, clickName, + chatId, + setChatId, setIsRefresh, setOpenFunction, setDeptUserList, setOuterTagsValue, - lastTagsValue + lastTagsValue, } = props const defaultGroupOwner = { @@ -48,11 +52,7 @@ const useAction = (props: { type: DepartmentAndUserType.User, parentid: "", selected: false, - children: [] - } - const defaultGroupValue = { - chatId: "", - chatName: "" + children: [], } const [departmentSelectedList, setDepartmentSelectedList] = useState< IDepartmentAndUserListValue[] @@ -67,20 +67,23 @@ const useAction = (props: { const [groupName, setGroupName] = useState("") const [tipsObject, setTipsObject] = useState({ show: false, - msg: "" + msg: "", }) const [groupDeptUserList, setGroupDeptUserList] = useState< IDepartmentKeyControl[] >([]) const [sendList, setSendList] = useState([ SendObjOrGroup.Object, - SendObjOrGroup.Group + SendObjOrGroup.Group, ]) + const [firstDeptUserList, setFirstDeptUserList] = useState< + IDepartmentKeyControl[] + >([]) + const [createLoading, setCreateLoading] = useState(false) - const [groupValue, setGroupValue] = - useState(defaultGroupValue) + const [groupValue, setGroupValue] = useState("") const recursiveSeachDeptOrUser = ( hasData: IDepartmentAndUserListValue[], @@ -109,7 +112,7 @@ const useAction = (props: { type: DepartmentAndUserType.User, parentid: String(e.parentid), selected: e.selected, - children: [] + children: [], }) : hasItemIndex > -1 && changeList.splice(hasItemIndex, 1) e.children.length > 0 && recursiveDeptList(e.children, changeList) @@ -206,7 +209,7 @@ const useAction = (props: { : groupDeptUserSelectedList.length <= 1 ? setTipsObject({ show: true, - msg: "Please select 2 or more valid users" + msg: "Please select 2 or more valid users", }) : !AppId ? setTipsObject({ show: true, msg: "Error for no AppId provided" }) @@ -216,7 +219,9 @@ const useAction = (props: { appId: AppId, name: groupName, owner: groupOwner.id as string, - userList: groupDeptUserSelectedList.map((item) => item.id as string) + userList: groupDeptUserSelectedList.map( + (item) => item.id as string + ), } if (requestData.owner === defaultGroupOwner.id) delete requestData.owner @@ -245,6 +250,16 @@ const useAction = (props: { })() } + const handleConfirm = () => { + setOpenFunction(false) + setOuterTagsValue(tagsValue) + } + + const handleCancel = () => { + setOpenFunction(false) + clearSelected() + } + useEffect(() => { // 限制条件下群组部门列表变化同步到群组搜索选择列表 !isLoading && @@ -279,13 +294,24 @@ const useAction = (props: { setGroupDeptUserList((prev) => [...prev, clone(departmentKeyValue)])) }, [departmentAndUserList, AppId]) - useEffect(() => { + const clearSelected = () => { // 切换应用时清空上次应用数据 setDepartmentSelectedList([]) setGroupDeptUserSelectedList([]) setTagsValue([]) + setDeptUserList(firstDeptUserList) + setChatId && setChatId(groupValue) + } + + useEffect(() => { + clearSelected() }, [AppId]) + useEffect(() => { + open && setFirstDeptUserList(clone(departmentAndUserList)) + open && setGroupValue(chatId) + }, [open]) + useEffect(() => { const handleData = ( prev: IDepartmentAndUserListValue[], @@ -299,7 +325,6 @@ const useAction = (props: { }) return newValue } - setOuterTagsValue(tagsValue) // 打开时load上次选中的数据 open ? clickName === "选择发送目标" @@ -364,7 +389,9 @@ const useAction = (props: { setTagsValue, handleDeptOrUserClick, setSearchToDeptValue, - handleCreateGroup + handleCreateGroup, + handleConfirm, + handleCancel, } } export default useAction diff --git a/web/src/pages/enterprise/components/select-target-dialog/index.tsx b/web/src/pages/enterprise/components/select-target-dialog/index.tsx index a1669758..d887cd4d 100644 --- a/web/src/pages/enterprise/components/select-target-dialog/index.tsx +++ b/web/src/pages/enterprise/components/select-target-dialog/index.tsx @@ -22,7 +22,7 @@ import { ITargetDialogProps, IDepartmentAndUserListValue, DeptUserCanSelectStatus, - SendObjOrGroup + SendObjOrGroup, } from "../../../../dtos/enterprise" import { CircularProgress, Snackbar, FilterOptionsState } from "@mui/material" import { LoadingButton } from "@mui/lab" @@ -81,7 +81,7 @@ const SelectTargetDialog = memo( setGroupList, setOpenFunction, setDeptUserList, - setOuterTagsValue + setOuterTagsValue, } = props const { @@ -103,7 +103,9 @@ const SelectTargetDialog = memo( setSearchToDeptValue, setTagsValue, handleTypeIsCanSelect, - handleCreateGroup + handleCreateGroup, + handleConfirm, + handleCancel, } = useAction({ open, AppId, @@ -113,10 +115,12 @@ const SelectTargetDialog = memo( lastTagsValue, tagsList, clickName, + chatId, + setChatId, setIsRefresh, setOpenFunction, setDeptUserList, - setOuterTagsValue + setOuterTagsValue, }) const recursiveRenderDeptList = ( @@ -132,7 +136,7 @@ const SelectTargetDialog = memo( type: deptUserData.type, parentid: String(deptUserData.parentid), selected: deptUserData.selected, - children: [] + children: [], } return (
@@ -144,7 +148,7 @@ const SelectTargetDialog = memo( handleDeptOrUserClick( ClickType.Collapse, Object.assign(insertData, { - isCollapsed: deptUserData.isCollapsed + isCollapsed: deptUserData.isCollapsed, }) ) }} @@ -195,7 +199,7 @@ const SelectTargetDialog = memo( display: "flex", alignItems: "center", justifyContent: "space-between", - height: "4rem" + height: "4rem", }} > <>{clickName} @@ -211,7 +215,7 @@ const SelectTargetDialog = memo( height: "15rem", overflowY: "auto", position: "relative", - marginBottom: "1rem" + marginBottom: "1rem", }} > {(clickName === "选择发送目标" @@ -234,7 +238,7 @@ const SelectTargetDialog = memo( height: "2rem", left: "50%", top: "50%", - margin: "-1rem 0 0 -1rem" + margin: "-1rem 0 0 -1rem", }} /> )} @@ -280,13 +284,13 @@ const SelectTargetDialog = memo( margin: clickName === "选择发送目标" ? "1rem 0 calc(1rem - 4px)" - : "" + : "", }} componentsProps={{ paper: { elevation: 3 }, popper: { - placement: "top" - } + placement: "top", + }, }} value={ clickName === "选择发送目标" @@ -348,8 +352,8 @@ const SelectTargetDialog = memo( componentsProps={{ paper: { elevation: 3 }, popper: { - placement: "top" - } + placement: "top", + }, }} value={ chatId @@ -375,9 +379,11 @@ const SelectTargetDialog = memo( label="群组列表" /> )} - onChange={(e, value) => + onChange={(e, value) => { + console.log(e, value) + setChatId && setChatId(value ? value.chatId : "") - } + }} /> )} {sendType === SendObjOrGroup.Object && ( @@ -440,8 +446,8 @@ const SelectTargetDialog = memo( className={styles.InputButton} sx={{ input: { - color: groupOwner.id === "-1" ? "#999" : "333" - } + color: groupOwner.id === "-1" ? "#999" : "333", + }, }} margin="dense" type="button" @@ -456,7 +462,7 @@ const SelectTargetDialog = memo( )} - + { clickName !== "选择发送目标" ? handleCreateGroup() - : setOpenFunction(false) + : handleConfirm() }} > {clickName === "选择发送目标" ? "确定" : "创建"} @@ -502,7 +508,7 @@ const SelectTargetDialog = memo( open={tipsObject.show} anchorOrigin={{ vertical: "top", - horizontal: "center" + horizontal: "center", }} />
From ee7250d0ce191731ffe6043b9f270d253ec16d93 Mon Sep 17 00:00:00 2001 From: zirui liu Date: Thu, 16 Mar 2023 15:05:28 +0800 Subject: [PATCH 2/7] delete useless code --- .../pages/enterprise/components/select-target-dialog/hook.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/src/pages/enterprise/components/select-target-dialog/hook.ts b/web/src/pages/enterprise/components/select-target-dialog/hook.ts index ccaf0d7b..28320f99 100644 --- a/web/src/pages/enterprise/components/select-target-dialog/hook.ts +++ b/web/src/pages/enterprise/components/select-target-dialog/hook.ts @@ -1,5 +1,5 @@ import { clone } from "ramda" -import { useCallback, useEffect, useMemo, useState } from "react" +import { useEffect, useState } from "react" import { PostWeChatWorkGroupCreate } from "../../../../api/enterprise" import { IDepartmentAndUserListValue, @@ -9,7 +9,6 @@ import { ClickType, DeptUserCanSelectStatus, IWorkGroupCreate, - IWorkCorpAppGroup, SendObjOrGroup, } from "../../../../dtos/enterprise" From 4e6ba36e887ae73abeb1349a64a76f9989096e0a Mon Sep 17 00:00:00 2001 From: zirui liu Date: Thu, 16 Mar 2023 16:33:25 +0800 Subject: [PATCH 3/7] Optimize structure --- web/src/dtos/enterprise/index.ts | 9 +++++ .../components/select-content/hook.ts | 5 +++ .../components/select-content/index.tsx | 5 +++ .../components/select-target-dialog/hook.ts | 35 ++++++++++++------- .../components/select-target-dialog/index.tsx | 8 +++++ 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/web/src/dtos/enterprise/index.ts b/web/src/dtos/enterprise/index.ts index 48e75544..aad31e48 100644 --- a/web/src/dtos/enterprise/index.ts +++ b/web/src/dtos/enterprise/index.ts @@ -120,6 +120,9 @@ export interface ITargetDialogProps { groupDeptUserSelectedList?: IDepartmentAndUserListValue[] chatId: string sendType?: SendObjOrGroup + outTagsValue?: ITagsList[] + updatedDeptUserList: boolean + isUpdate: boolean setSendType?: React.Dispatch> setIsRefresh: React.Dispatch> setChatId?: React.Dispatch> @@ -417,3 +420,9 @@ export interface UploadAttachmentResponseData { fileSize: number filePath: string } + +export interface IFirstState { + chatId: string + deptUserList: IDepartmentKeyControl[] + tagsValue: ITagsList[] +} diff --git a/web/src/pages/enterprise/components/select-content/hook.ts b/web/src/pages/enterprise/components/select-content/hook.ts index 67667a42..06bb198e 100644 --- a/web/src/pages/enterprise/components/select-content/hook.ts +++ b/web/src/pages/enterprise/components/select-content/hook.ts @@ -143,6 +143,8 @@ export const useAction = (props: SelectContentHookProps) => { SendObjOrGroup.Object ) + const [updatedDeptUserList, setUpdatedDeptUserList] = useState(false) + const [editor, setEditor] = useState(null) const [html, setHtml] = useState("") @@ -435,6 +437,7 @@ export const useAction = (props: SelectContentHookProps) => { } return item }) + setUpdatedDeptUserList(true) setDepartmentAndUserList(array) } }, [isLoadStop]) @@ -1119,5 +1122,7 @@ export const useAction = (props: SelectContentHookProps) => { html, setHtml, setHtmlText, + tagsValue, + updatedDeptUserList, } } diff --git a/web/src/pages/enterprise/components/select-content/index.tsx b/web/src/pages/enterprise/components/select-content/index.tsx index bad739dc..1385de39 100644 --- a/web/src/pages/enterprise/components/select-content/index.tsx +++ b/web/src/pages/enterprise/components/select-content/index.tsx @@ -104,6 +104,8 @@ const SelectContent = memo( setHtml, editorConfig, setHtmlText, + tagsValue, + updatedDeptUserList, } = useAction({ outerSendData: sendData, getSendData, @@ -387,6 +389,7 @@ const SelectContent = memo( setGroupList={setGroupList} setOpenFunction={setIsShowDialog} setDeptUserList={setDepartmentAndUserList} + outTagsValue={tagsValue} setOuterTagsValue={setTagsValue} setIsRefresh={setIsRefresh} lastTagsValue={lastTimeTagsList} @@ -395,6 +398,8 @@ const SelectContent = memo( setChatId={setChatId} sendType={sendType} setSendType={setSendType} + updatedDeptUserList={updatedDeptUserList} + isUpdate={!!updateMessageJobInformation} />
diff --git a/web/src/pages/enterprise/components/select-target-dialog/hook.ts b/web/src/pages/enterprise/components/select-target-dialog/hook.ts index 28320f99..9a53110d 100644 --- a/web/src/pages/enterprise/components/select-target-dialog/hook.ts +++ b/web/src/pages/enterprise/components/select-target-dialog/hook.ts @@ -10,6 +10,7 @@ import { DeptUserCanSelectStatus, IWorkGroupCreate, SendObjOrGroup, + IFirstState, } from "../../../../dtos/enterprise" const useAction = (props: { @@ -22,6 +23,9 @@ const useAction = (props: { tagsList: ITagsList[] clickName: string chatId: string + outTagsValue?: ITagsList[] + updatedDeptUserList: boolean + isUpdate: boolean setOpenFunction: (open: boolean) => void setChatId?: React.Dispatch> setIsRefresh: React.Dispatch> @@ -37,12 +41,15 @@ const useAction = (props: { tagsList, clickName, chatId, + outTagsValue, + updatedDeptUserList, + lastTagsValue, + isUpdate, setChatId, setIsRefresh, setOpenFunction, setDeptUserList, setOuterTagsValue, - lastTagsValue, } = props const defaultGroupOwner = { @@ -76,9 +83,7 @@ const useAction = (props: { SendObjOrGroup.Group, ]) - const [firstDeptUserList, setFirstDeptUserList] = useState< - IDepartmentKeyControl[] - >([]) + const [firstState, setFirstState] = useState() const [createLoading, setCreateLoading] = useState(false) @@ -294,12 +299,11 @@ const useAction = (props: { }, [departmentAndUserList, AppId]) const clearSelected = () => { - // 切换应用时清空上次应用数据 - setDepartmentSelectedList([]) - setGroupDeptUserSelectedList([]) - setTagsValue([]) - setDeptUserList(firstDeptUserList) - setChatId && setChatId(groupValue) + if (firstState) { + setTagsValue(firstState.tagsValue) + setDeptUserList(firstState.deptUserList) + setChatId && setChatId(firstState.chatId) + } } useEffect(() => { @@ -307,9 +311,14 @@ const useAction = (props: { }, [AppId]) useEffect(() => { - open && setFirstDeptUserList(clone(departmentAndUserList)) - open && setGroupValue(chatId) - }, [open]) + open && + (!firstState || (isUpdate && updatedDeptUserList)) && + setFirstState({ + tagsValue: outTagsValue ?? [], + chatId, + deptUserList: clone(departmentAndUserList), + }) + }, [open, updatedDeptUserList]) useEffect(() => { const handleData = ( diff --git a/web/src/pages/enterprise/components/select-target-dialog/index.tsx b/web/src/pages/enterprise/components/select-target-dialog/index.tsx index d887cd4d..fd5b4d33 100644 --- a/web/src/pages/enterprise/components/select-target-dialog/index.tsx +++ b/web/src/pages/enterprise/components/select-target-dialog/index.tsx @@ -75,6 +75,9 @@ const SelectTargetDialog = memo( clickName, chatId, sendType, + outTagsValue, + updatedDeptUserList, + isUpdate, setSendType, setIsRefresh, setChatId, @@ -116,6 +119,9 @@ const SelectTargetDialog = memo( tagsList, clickName, chatId, + outTagsValue, + updatedDeptUserList, + isUpdate, setChatId, setIsRefresh, setOpenFunction, @@ -499,6 +505,8 @@ const SelectTargetDialog = memo( setIsRefresh={setIsRefresh} clickName={"创建群组"} groupDeptUserSelectedList={groupDeptUserSelectedList} + updatedDeptUserList={updatedDeptUserList} + isUpdate={isUpdate} /> )} From 6f6009a14c2565b73ca9df21cad1ccfe458ce7b2 Mon Sep 17 00:00:00 2001 From: zirui liu Date: Fri, 17 Mar 2023 10:59:24 +0800 Subject: [PATCH 4/7] fix distinguish between confirm and cancel --- web/src/dtos/enterprise/index.ts | 4 +- .../components/select-content/hook.ts | 41 +++++++++++-------- .../components/select-content/index.tsx | 9 ++-- .../components/select-target-dialog/hook.ts | 18 +++++--- .../components/select-target-dialog/index.tsx | 11 ++--- web/src/uilts/parameter-judgment/index.tsx | 2 +- 6 files changed, 49 insertions(+), 36 deletions(-) diff --git a/web/src/dtos/enterprise/index.ts b/web/src/dtos/enterprise/index.ts index aad31e48..f0cf734c 100644 --- a/web/src/dtos/enterprise/index.ts +++ b/web/src/dtos/enterprise/index.ts @@ -120,9 +120,8 @@ export interface ITargetDialogProps { groupDeptUserSelectedList?: IDepartmentAndUserListValue[] chatId: string sendType?: SendObjOrGroup - outTagsValue?: ITagsList[] + outerTagsValue?: ITagsList[] updatedDeptUserList: boolean - isUpdate: boolean setSendType?: React.Dispatch> setIsRefresh: React.Dispatch> setChatId?: React.Dispatch> @@ -425,4 +424,5 @@ export interface IFirstState { chatId: string deptUserList: IDepartmentKeyControl[] tagsValue: ITagsList[] + sendType: SendObjOrGroup } diff --git a/web/src/pages/enterprise/components/select-content/hook.ts b/web/src/pages/enterprise/components/select-content/hook.ts index 06bb198e..ce91b523 100644 --- a/web/src/pages/enterprise/components/select-content/hook.ts +++ b/web/src/pages/enterprise/components/select-content/hook.ts @@ -1,5 +1,5 @@ import { clone, flatten, isEmpty, uniqWith } from "ramda" -import { useCallback, useEffect, useMemo, useRef, useState } from "react" +import { useEffect, useMemo, useRef, useState } from "react" import { GetCorpAppList, GetCorpsList, @@ -187,28 +187,35 @@ export const useAction = (props: SelectContentHookProps) => { const partiesSelected = flattenDepartmentList.find( (e) => e.key === corpAppValue?.appId )?.data + const workWeChatAppNotification = + sendObject ?? + outerSendData?.workWeChatAppNotification ?? + updateMessageJobInformation?.workWeChatAppNotification if (sendType === SendObjOrGroup.Object) { - outerSendData?.workWeChatAppNotification?.toParties && + workWeChatAppNotification?.toParties && partiesSelected && result.push( ...partiesSelected .filter((e) => - outerSendData.workWeChatAppNotification?.toParties?.some( + workWeChatAppNotification?.toParties?.some( (item) => item === String(e.id) ) ) .map((e) => e.name) ) - outerSendData?.workWeChatAppNotification?.toUsers && - result.push(...outerSendData.workWeChatAppNotification.toUsers) - outerSendData?.workWeChatAppNotification?.toTags && - result.push(...outerSendData.workWeChatAppNotification.toTags) + workWeChatAppNotification?.toUsers && + result.push(...workWeChatAppNotification.toUsers) + tagsValue && result.push(...tagsValue.map((x) => x.tagName)) } else { result.push(...groupList.filter((x) => x.chatId === chatId)) } return result - }, [outerSendData?.workWeChatAppNotification, chatId]) + }, [ + sendObject, + outerSendData?.workWeChatAppNotification, + updateMessageJobInformation?.workWeChatAppNotification, + ]) // 初始化企业数组 useEffect(() => { @@ -250,7 +257,7 @@ export const useAction = (props: SelectContentHookProps) => { // 获取Tags数组 useEffect(() => { - if (corpAppValue?.appId !== undefined && isNewOrUpdate === "new") { + if (corpAppValue?.appId !== undefined) { GetTagsList({ AppId: corpAppValue.appId }).then( (tagsData: ITagsListResponse | null | undefined) => { tagsData && tagsData.errcode === 0 && setTagsList(tagsData.taglist) @@ -259,13 +266,15 @@ export const useAction = (props: SelectContentHookProps) => { GetWeChatWorkCorpAppGroups(corpAppValue.id).then((data) => { data && setGroupList(data) }) - // 清空切换应用时的已选值 - setChatId("") - setTagsValue([]) - setSendObject({ - toUsers: [], - toParties: [], - }) + if (isNewOrUpdate === "new") { + // 清空切换应用时的已选值 + setChatId("") + setTagsValue([]) + setSendObject({ + toUsers: [], + toParties: [], + }) + } } }, [corpAppValue?.appId]) diff --git a/web/src/pages/enterprise/components/select-content/index.tsx b/web/src/pages/enterprise/components/select-content/index.tsx index 1385de39..e989c6f5 100644 --- a/web/src/pages/enterprise/components/select-content/index.tsx +++ b/web/src/pages/enterprise/components/select-content/index.tsx @@ -60,7 +60,6 @@ const SelectContent = memo( setIsRefresh, departmentAndUserList, setDepartmentAndUserList, - setFlattenDepartmentList, departmentKeyValue, searchKeyValue, isTreeViewLoading, @@ -389,7 +388,7 @@ const SelectContent = memo( setGroupList={setGroupList} setOpenFunction={setIsShowDialog} setDeptUserList={setDepartmentAndUserList} - outTagsValue={tagsValue} + outerTagsValue={tagsValue} setOuterTagsValue={setTagsValue} setIsRefresh={setIsRefresh} lastTagsValue={lastTimeTagsList} @@ -399,7 +398,6 @@ const SelectContent = memo( sendType={sendType} setSendType={setSendType} updatedDeptUserList={updatedDeptUserList} - isUpdate={!!updateMessageJobInformation} />
@@ -620,7 +618,10 @@ const SelectContent = memo( ) }, (prevProps, nextProps) => { - return prevProps.sendData === nextProps.sendData && prevProps === nextProps + return ( + prevProps.sendData === nextProps.sendData && + JSON.stringify(prevProps) === JSON.stringify(nextProps) + ) } ) diff --git a/web/src/pages/enterprise/components/select-target-dialog/hook.ts b/web/src/pages/enterprise/components/select-target-dialog/hook.ts index 9a53110d..6bdddf8c 100644 --- a/web/src/pages/enterprise/components/select-target-dialog/hook.ts +++ b/web/src/pages/enterprise/components/select-target-dialog/hook.ts @@ -23,9 +23,10 @@ const useAction = (props: { tagsList: ITagsList[] clickName: string chatId: string - outTagsValue?: ITagsList[] + outerTagsValue?: ITagsList[] updatedDeptUserList: boolean - isUpdate: boolean + sendType?: SendObjOrGroup + setSendType?: React.Dispatch> setOpenFunction: (open: boolean) => void setChatId?: React.Dispatch> setIsRefresh: React.Dispatch> @@ -41,10 +42,11 @@ const useAction = (props: { tagsList, clickName, chatId, - outTagsValue, + outerTagsValue, updatedDeptUserList, lastTagsValue, - isUpdate, + sendType, + setSendType, setChatId, setIsRefresh, setOpenFunction, @@ -257,6 +259,7 @@ const useAction = (props: { const handleConfirm = () => { setOpenFunction(false) setOuterTagsValue(tagsValue) + setFirstState(undefined) } const handleCancel = () => { @@ -303,6 +306,8 @@ const useAction = (props: { setTagsValue(firstState.tagsValue) setDeptUserList(firstState.deptUserList) setChatId && setChatId(firstState.chatId) + setSendType && setSendType(firstState.sendType) + setFirstState(undefined) } } @@ -312,11 +317,12 @@ const useAction = (props: { useEffect(() => { open && - (!firstState || (isUpdate && updatedDeptUserList)) && + updatedDeptUserList && setFirstState({ - tagsValue: outTagsValue ?? [], + tagsValue: outerTagsValue ?? [], chatId, deptUserList: clone(departmentAndUserList), + sendType: sendType ?? SendObjOrGroup.Object, }) }, [open, updatedDeptUserList]) diff --git a/web/src/pages/enterprise/components/select-target-dialog/index.tsx b/web/src/pages/enterprise/components/select-target-dialog/index.tsx index fd5b4d33..35e63d78 100644 --- a/web/src/pages/enterprise/components/select-target-dialog/index.tsx +++ b/web/src/pages/enterprise/components/select-target-dialog/index.tsx @@ -75,9 +75,8 @@ const SelectTargetDialog = memo( clickName, chatId, sendType, - outTagsValue, + outerTagsValue, updatedDeptUserList, - isUpdate, setSendType, setIsRefresh, setChatId, @@ -119,9 +118,10 @@ const SelectTargetDialog = memo( tagsList, clickName, chatId, - outTagsValue, + outerTagsValue, updatedDeptUserList, - isUpdate, + sendType, + setSendType, setChatId, setIsRefresh, setOpenFunction, @@ -386,8 +386,6 @@ const SelectTargetDialog = memo( /> )} onChange={(e, value) => { - console.log(e, value) - setChatId && setChatId(value ? value.chatId : "") }} /> @@ -506,7 +504,6 @@ const SelectTargetDialog = memo( clickName={"创建群组"} groupDeptUserSelectedList={groupDeptUserSelectedList} updatedDeptUserList={updatedDeptUserList} - isUpdate={isUpdate} /> )} diff --git a/web/src/uilts/parameter-judgment/index.tsx b/web/src/uilts/parameter-judgment/index.tsx index 30c52cb8..07536b50 100644 --- a/web/src/uilts/parameter-judgment/index.tsx +++ b/web/src/uilts/parameter-judgment/index.tsx @@ -26,7 +26,7 @@ export const parameterJudgment = ( } else if ( jobSetting.recurringJob !== undefined && jobSetting.recurringJob.endDate && - moment(jobSetting.recurringJob.endDate).format("DD.MM.YYYY HH:mm") >= + moment(jobSetting.recurringJob.endDate).format("DD.MM.YYYY HH:mm") < moment().format("DD.MM.YYYY HH:mm") ) { showErrorPrompt("The end time cannot exceed the current time!") From cc19a18be865865dbd47ccc034578cb2f7501ceb Mon Sep 17 00:00:00 2001 From: zirui liu Date: Fri, 17 Mar 2023 11:38:57 +0800 Subject: [PATCH 5/7] rename --- web/src/dtos/enterprise/index.ts | 2 +- .../pages/enterprise/components/select-content/index.tsx | 2 +- .../enterprise/components/select-target-dialog/index.tsx | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/src/dtos/enterprise/index.ts b/web/src/dtos/enterprise/index.ts index f0cf734c..a5550a14 100644 --- a/web/src/dtos/enterprise/index.ts +++ b/web/src/dtos/enterprise/index.ts @@ -121,7 +121,7 @@ export interface ITargetDialogProps { chatId: string sendType?: SendObjOrGroup outerTagsValue?: ITagsList[] - updatedDeptUserList: boolean + isUpdatedDeptUser: boolean setSendType?: React.Dispatch> setIsRefresh: React.Dispatch> setChatId?: React.Dispatch> diff --git a/web/src/pages/enterprise/components/select-content/index.tsx b/web/src/pages/enterprise/components/select-content/index.tsx index e989c6f5..988513ca 100644 --- a/web/src/pages/enterprise/components/select-content/index.tsx +++ b/web/src/pages/enterprise/components/select-content/index.tsx @@ -397,7 +397,7 @@ const SelectContent = memo( setChatId={setChatId} sendType={sendType} setSendType={setSendType} - updatedDeptUserList={updatedDeptUserList} + isUpdatedDeptUser={updatedDeptUserList} />
diff --git a/web/src/pages/enterprise/components/select-target-dialog/index.tsx b/web/src/pages/enterprise/components/select-target-dialog/index.tsx index 35e63d78..bd6b9376 100644 --- a/web/src/pages/enterprise/components/select-target-dialog/index.tsx +++ b/web/src/pages/enterprise/components/select-target-dialog/index.tsx @@ -76,7 +76,7 @@ const SelectTargetDialog = memo( chatId, sendType, outerTagsValue, - updatedDeptUserList, + isUpdatedDeptUser, setSendType, setIsRefresh, setChatId, @@ -119,7 +119,7 @@ const SelectTargetDialog = memo( clickName, chatId, outerTagsValue, - updatedDeptUserList, + isUpdatedDeptUser, sendType, setSendType, setChatId, @@ -503,7 +503,7 @@ const SelectTargetDialog = memo( setIsRefresh={setIsRefresh} clickName={"创建群组"} groupDeptUserSelectedList={groupDeptUserSelectedList} - updatedDeptUserList={updatedDeptUserList} + isUpdatedDeptUser={isUpdatedDeptUser} /> )} From 2fa6b6c40c6cbf8867ce8553deef1b4366c0b253 Mon Sep 17 00:00:00 2001 From: zirui liu Date: Fri, 17 Mar 2023 11:39:47 +0800 Subject: [PATCH 6/7] rename --- .../enterprise/components/select-target-dialog/hook.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/src/pages/enterprise/components/select-target-dialog/hook.ts b/web/src/pages/enterprise/components/select-target-dialog/hook.ts index 6bdddf8c..25217de4 100644 --- a/web/src/pages/enterprise/components/select-target-dialog/hook.ts +++ b/web/src/pages/enterprise/components/select-target-dialog/hook.ts @@ -24,7 +24,7 @@ const useAction = (props: { clickName: string chatId: string outerTagsValue?: ITagsList[] - updatedDeptUserList: boolean + isUpdatedDeptUser: boolean sendType?: SendObjOrGroup setSendType?: React.Dispatch> setOpenFunction: (open: boolean) => void @@ -43,7 +43,7 @@ const useAction = (props: { clickName, chatId, outerTagsValue, - updatedDeptUserList, + isUpdatedDeptUser, lastTagsValue, sendType, setSendType, @@ -317,14 +317,14 @@ const useAction = (props: { useEffect(() => { open && - updatedDeptUserList && + isUpdatedDeptUser && setFirstState({ tagsValue: outerTagsValue ?? [], chatId, deptUserList: clone(departmentAndUserList), sendType: sendType ?? SendObjOrGroup.Object, }) - }, [open, updatedDeptUserList]) + }, [open, isUpdatedDeptUser]) useEffect(() => { const handleData = ( From e00d8a53c9a695393626507a93fc7ad2e5f19e36 Mon Sep 17 00:00:00 2001 From: zirui liu Date: Fri, 17 Mar 2023 11:45:16 +0800 Subject: [PATCH 7/7] rename --- web/src/pages/enterprise/components/select-content/hook.ts | 6 +++--- .../pages/enterprise/components/select-content/index.tsx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/src/pages/enterprise/components/select-content/hook.ts b/web/src/pages/enterprise/components/select-content/hook.ts index ce91b523..426783e5 100644 --- a/web/src/pages/enterprise/components/select-content/hook.ts +++ b/web/src/pages/enterprise/components/select-content/hook.ts @@ -143,7 +143,7 @@ export const useAction = (props: SelectContentHookProps) => { SendObjOrGroup.Object ) - const [updatedDeptUserList, setUpdatedDeptUserList] = useState(false) + const [isUpdatedDeptUser, setIsUpdatedDeptUser] = useState(false) const [editor, setEditor] = useState(null) @@ -446,7 +446,7 @@ export const useAction = (props: SelectContentHookProps) => { } return item }) - setUpdatedDeptUserList(true) + setIsUpdatedDeptUser(true) setDepartmentAndUserList(array) } }, [isLoadStop]) @@ -1132,6 +1132,6 @@ export const useAction = (props: SelectContentHookProps) => { setHtml, setHtmlText, tagsValue, - updatedDeptUserList, + isUpdatedDeptUser, } } diff --git a/web/src/pages/enterprise/components/select-content/index.tsx b/web/src/pages/enterprise/components/select-content/index.tsx index 988513ca..992bede1 100644 --- a/web/src/pages/enterprise/components/select-content/index.tsx +++ b/web/src/pages/enterprise/components/select-content/index.tsx @@ -104,7 +104,7 @@ const SelectContent = memo( editorConfig, setHtmlText, tagsValue, - updatedDeptUserList, + isUpdatedDeptUser, } = useAction({ outerSendData: sendData, getSendData, @@ -397,7 +397,7 @@ const SelectContent = memo( setChatId={setChatId} sendType={sendType} setSendType={setSendType} - isUpdatedDeptUser={updatedDeptUserList} + isUpdatedDeptUser={isUpdatedDeptUser} />