更新WeChat API以使用新端点,调整获取可转移客服列表的逻辑。重构ProfileCard组件以更改默认活动选项卡为“profile”,并优化状态管理。移除未使用的状态和逻辑,简化代码结构。
This commit is contained in:
@@ -94,7 +94,7 @@ export function WechatFriendAllot(params: {
|
||||
|
||||
//获取可转移客服列表
|
||||
export function getTransferableAgentList() {
|
||||
return request2("/api/account/myDepartmentAccountsForTransfer", {}, "GET");
|
||||
return request("/v1/kefu/accounts/list", {}, "GET");
|
||||
}
|
||||
|
||||
// 微信好友列表
|
||||
|
||||
@@ -49,7 +49,7 @@ const ToContract: React.FC<ToContractProps> = ({
|
||||
const openModal = () => {
|
||||
setVisible(true);
|
||||
getTransferableAgentList().then(data => {
|
||||
setCustomerServiceList(data);
|
||||
setCustomerServiceList(data.list);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import React, { useCallback } from "react";
|
||||
import { Button, Input } from "antd";
|
||||
|
||||
import styles from "../Person.module.scss";
|
||||
|
||||
export interface DetailValueField {
|
||||
label: string;
|
||||
key: string;
|
||||
ifEdit?: boolean;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export interface DetailValueProps {
|
||||
fields: DetailValueField[];
|
||||
value?: Record<string, string>;
|
||||
onChange?: (next: Record<string, string>) => void;
|
||||
onSubmit?: (next: Record<string, string>) => void;
|
||||
submitText?: string;
|
||||
submitting?: boolean;
|
||||
renderFooter?: React.ReactNode;
|
||||
}
|
||||
|
||||
const DetailValue: React.FC<DetailValueProps> = ({
|
||||
fields,
|
||||
value,
|
||||
onChange,
|
||||
onSubmit,
|
||||
submitText = "保存",
|
||||
submitting = false,
|
||||
renderFooter,
|
||||
}) => {
|
||||
const handleFieldChange = useCallback(
|
||||
(fieldKey: string, nextVal: string) => {
|
||||
const baseValue = value ?? {};
|
||||
const nextValue = {
|
||||
...baseValue,
|
||||
[fieldKey]: nextVal,
|
||||
};
|
||||
onChange?.(nextValue);
|
||||
},
|
||||
[onChange, value],
|
||||
);
|
||||
|
||||
const handleSubmit = useCallback(() => {
|
||||
onSubmit?.(value ?? {});
|
||||
}, [onSubmit, value]);
|
||||
|
||||
const formValue = value ?? {};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{fields.map(field => {
|
||||
const disabled = field.ifEdit === false;
|
||||
const fieldValue = formValue[field.key] ?? "";
|
||||
|
||||
return (
|
||||
<div key={field.key} className={styles.infoItem}>
|
||||
<span className={styles.infoLabel}>{field.label}:</span>
|
||||
<div className={styles.infoValue}>
|
||||
{disabled ? (
|
||||
<span>{fieldValue || field.placeholder || "--"}</span>
|
||||
) : (
|
||||
<Input
|
||||
value={fieldValue}
|
||||
placeholder={field.placeholder}
|
||||
onChange={event =>
|
||||
handleFieldChange(field.key, event.target.value)
|
||||
}
|
||||
onPressEnter={handleSubmit}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
{(onSubmit || renderFooter) && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "flex-end",
|
||||
marginTop: 16,
|
||||
}}
|
||||
>
|
||||
{renderFooter}
|
||||
{onSubmit && (
|
||||
<Button
|
||||
type="primary"
|
||||
loading={submitting}
|
||||
onClick={handleSubmit}
|
||||
style={{ marginLeft: renderFooter ? 8 : 0 }}
|
||||
>
|
||||
{submitText}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DetailValue;
|
||||
@@ -97,9 +97,7 @@ const Person: React.FC<PersonProps> = ({ contract }) => {
|
||||
useState(false);
|
||||
const [isTransferOwnerSelectionVisible, setIsTransferOwnerSelectionVisible] =
|
||||
useState(false);
|
||||
const [selectedFriends, setSelectedFriends] = useState<FriendSelectionItem[]>(
|
||||
[],
|
||||
);
|
||||
|
||||
const [contractList, setContractList] = useState<any[]>([]);
|
||||
|
||||
const handleAddFriend = member => {
|
||||
@@ -374,16 +372,6 @@ const Person: React.FC<PersonProps> = ({ contract }) => {
|
||||
messageApi.success("已应用AI生成的群公告内容");
|
||||
};
|
||||
|
||||
// 点击编辑群公告按钮
|
||||
const handleEditGroupNotice = () => {
|
||||
if (!hasGroupManagePermission()) {
|
||||
messageApi.error("只有群主才能修改群公告");
|
||||
return;
|
||||
}
|
||||
setGroupNoticeValue(contract.notice || "");
|
||||
setIsGroupNoticeModalVisible(true);
|
||||
};
|
||||
|
||||
// 处理我在本群中的昵称保存
|
||||
const handleSaveSelfDisplayName = () => {
|
||||
sendCommand("CmdChatroomOperate", {
|
||||
@@ -397,12 +385,6 @@ const Person: React.FC<PersonProps> = ({ contract }) => {
|
||||
setIsEditingSelfDisplayName(false);
|
||||
};
|
||||
|
||||
// 点击编辑群昵称按钮
|
||||
const handleEditSelfDisplayName = () => {
|
||||
setSelfDisplayNameValue(contract.selfDisplyName || "");
|
||||
setIsEditingSelfDisplayName(true);
|
||||
};
|
||||
|
||||
// 处理取消编辑
|
||||
const handleCancelEdit = () => {
|
||||
setRemarkValue(contract.conRemark || "");
|
||||
@@ -508,18 +490,19 @@ const Person: React.FC<PersonProps> = ({ contract }) => {
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const extendFields = JSON.parse(contract.extendFields || "{}");
|
||||
// 构建联系人或群聊详细信息
|
||||
const contractInfo = {
|
||||
name: contract.name || contract.nickname,
|
||||
nickname: contract.nickname,
|
||||
conRemark: remarkValue, // 使用当前编辑的备注值
|
||||
alias: contract.alias,
|
||||
wechatId: contract.wechatId,
|
||||
chatroomId: isGroup ? contract.chatroomId : undefined,
|
||||
chatroomOwner: isGroup ? contract.chatroomOwner : undefined,
|
||||
avatar: contract.avatar || contract.chatroomAvatar,
|
||||
phone: contract.phone || "-",
|
||||
conRemark: remarkValue, // 使用当前编辑的备注值
|
||||
remark: extendFields.remark || "-",
|
||||
email: contract.email || "-",
|
||||
department: contract.department || "-",
|
||||
position: contract.position || "-",
|
||||
@@ -1278,7 +1261,6 @@ const Person: React.FC<PersonProps> = ({ contract }) => {
|
||||
visible={isFriendSelectionVisible}
|
||||
onCancel={() => setIsFriendSelectionVisible(false)}
|
||||
onConfirm={(selectedIds, selectedItems) => {
|
||||
setSelectedFriends(selectedItems);
|
||||
handleAddMember(
|
||||
selectedIds.map(id => parseInt(id)),
|
||||
selectedItems,
|
||||
|
||||
@@ -16,7 +16,7 @@ interface PersonProps {
|
||||
}
|
||||
|
||||
const Person: React.FC<PersonProps> = ({ contract }) => {
|
||||
const [activeKey, setActiveKey] = useState("quickwords");
|
||||
const [activeKey, setActiveKey] = useState("profile");
|
||||
const isGroup = "chatroomId" in contract;
|
||||
const tabItems = useMemo(() => {
|
||||
const baseItems = [
|
||||
@@ -42,8 +42,8 @@ const Person: React.FC<PersonProps> = ({ contract }) => {
|
||||
}, [contract, isGroup]);
|
||||
|
||||
useEffect(() => {
|
||||
setActiveKey("quickwords");
|
||||
setRenderedKeys(["quickwords"]);
|
||||
setActiveKey("profile");
|
||||
setRenderedKeys(["profile"]);
|
||||
}, [contract]);
|
||||
|
||||
const tabHeaderItems = useMemo(
|
||||
@@ -56,9 +56,7 @@ const Person: React.FC<PersonProps> = ({ contract }) => {
|
||||
[tabItems],
|
||||
);
|
||||
|
||||
const [renderedKeys, setRenderedKeys] = useState<string[]>(() => [
|
||||
"quickwords",
|
||||
]);
|
||||
const [renderedKeys, setRenderedKeys] = useState<string[]>(() => ["profile"]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!availableKeys.includes(activeKey) && availableKeys.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user