|
@@ -4,56 +4,24 @@ import Taro, { useRouter } from "@tarojs/taro";
|
|
import PageCustom from "@/components/page-custom/index";
|
|
import PageCustom from "@/components/page-custom/index";
|
|
import NavBarNormal from "@/components/nav-bar-normal/index";
|
|
import NavBarNormal from "@/components/nav-bar-normal/index";
|
|
import ButtonCardAdd from "@/components/button-card-add";
|
|
import ButtonCardAdd from "@/components/button-card-add";
|
|
-import WemetaTabs from "@/components/wemeta-tabs/index";
|
|
|
|
-import WemetaRadioGroup from "@/components/wemeta-radio-group/index";
|
|
|
|
import ContactCard from "@/components/contact-card/index";
|
|
import ContactCard from "@/components/contact-card/index";
|
|
import editorStyle from "../editor.module.less";
|
|
import editorStyle from "../editor.module.less";
|
|
-import { useCharacterStore } from "@/store/characterStore";
|
|
|
|
-import { useComponentStore } from "@/store/componentStore";
|
|
|
|
-import { usePageStore } from "@/store/pageStore";
|
|
|
|
-import { IContactModel } from "@/types";
|
|
|
|
-import { batchGet } from "@/service/character";
|
|
|
|
-import { axios, CancelTokenSource } from "taro-axios";
|
|
|
|
-import { APP_NAME_TEXT } from '@/config'
|
|
|
|
|
|
+import Popup from "@/components/popup/popup";
|
|
|
|
+import WemetaTabs from "@/components/wemeta-tabs/index";
|
|
|
|
+import BottomBar from "@/components/BottomBar";
|
|
|
|
+import { TContactItem } from "@/types/contact";
|
|
|
|
+import AgentScrollList from './components/AgentScrollList'
|
|
|
|
|
|
export default function Index() {
|
|
export default function Index() {
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
const { id } = router.params;
|
|
const { id } = router.params;
|
|
- const deltaNum = id ? 1 : 2;
|
|
|
|
- let currentComponent = useComponentStore((state) => state.currentComponent);
|
|
|
|
- const character = useCharacterStore((state) => state.character);
|
|
|
|
- const picked = usePageStore((state) => state.picked);
|
|
|
|
- const { setPicked, setTmpPicked, clear } = usePageStore();
|
|
|
|
- const { saveComponent } = useComponentStore();
|
|
|
|
- const loading = useComponentStore((state) => state.loading);
|
|
|
|
- const { value, layout } = currentComponent?.data ?? {};
|
|
|
|
|
|
+ const [picked, setPicked] = useState<TContactItem[]>([]);
|
|
|
|
|
|
- const [radioValue, setRadioValue] = useState(layout ?? "mini");
|
|
|
|
- const profileId =
|
|
|
|
- currentComponent?.characterProfileId ?? character?.profileId;
|
|
|
|
- const radioList = [
|
|
|
|
- {
|
|
|
|
- text: "缩略宫格",
|
|
|
|
- value: "mini",
|
|
|
|
- checked: false,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- text: "大图平铺",
|
|
|
|
- value: "full",
|
|
|
|
- checked: false,
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
- const onRadioChange = (value: string) => {
|
|
|
|
- setRadioValue(value);
|
|
|
|
- return false;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const deleteFunc = (item: IContactModel) => {
|
|
|
|
- const newList = picked.filter(
|
|
|
|
- (_item) => _item.contactProfileId !== item.contactProfileId
|
|
|
|
- );
|
|
|
|
- setTmpPicked([...newList]);
|
|
|
|
- setPicked(newList);
|
|
|
|
|
|
+ // 是否显示选择器
|
|
|
|
+ const [show, setShow] = useState(false);
|
|
|
|
+
|
|
|
|
+ const deleteFunc = () => {
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
const renderContactList = () => {
|
|
const renderContactList = () => {
|
|
@@ -72,13 +40,13 @@ export default function Index() {
|
|
{picked.map((item) => {
|
|
{picked.map((item) => {
|
|
return (
|
|
return (
|
|
<ContactCard
|
|
<ContactCard
|
|
- key={item.profileId}
|
|
|
|
|
|
+ key={item.contactId}
|
|
data={item}
|
|
data={item}
|
|
renderRight={() => {
|
|
renderRight={() => {
|
|
return (
|
|
return (
|
|
<View
|
|
<View
|
|
className={`iconfont icon-icon_24_delet icon-24`}
|
|
className={`iconfont icon-icon_24_delet icon-24`}
|
|
- onClick={() => deleteFunc(item)}
|
|
|
|
|
|
+ onClick={() => deleteFunc()}
|
|
></View>
|
|
></View>
|
|
);
|
|
);
|
|
}}
|
|
}}
|
|
@@ -89,114 +57,75 @@ export default function Index() {
|
|
);
|
|
);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ const handleSubmit = async () => {
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
const tabList = [
|
|
const tabList = [
|
|
{
|
|
{
|
|
key: "1",
|
|
key: "1",
|
|
- label: "内容",
|
|
|
|
- children: renderContactList(),
|
|
|
|
|
|
+ label: "我创建的",
|
|
|
|
+ children: (
|
|
|
|
+ <View >
|
|
|
|
+ <AgentScrollList></AgentScrollList>
|
|
|
|
+ </View>
|
|
|
|
+ ),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: "2",
|
|
key: "2",
|
|
- label: "版式",
|
|
|
|
|
|
+ label: "我的联系⼈",
|
|
children: (
|
|
children: (
|
|
- <View>
|
|
|
|
- <WemetaRadioGroup
|
|
|
|
- radioList={radioList}
|
|
|
|
- value={radioValue}
|
|
|
|
- onChange={onRadioChange}
|
|
|
|
- ></WemetaRadioGroup>
|
|
|
|
|
|
+ <View >
|
|
|
|
+
|
|
|
|
+ </View>
|
|
|
|
+ ),
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ key: "3",
|
|
|
|
+ label: "企业同事",
|
|
|
|
+ children: (
|
|
|
|
+ <View >
|
|
|
|
+
|
|
</View>
|
|
</View>
|
|
),
|
|
),
|
|
},
|
|
},
|
|
];
|
|
];
|
|
|
|
|
|
- const handleSave = async () => {
|
|
|
|
- const profileIds = [...picked].map((item) => {
|
|
|
|
- return item.profileId ?? item.contactProfileId;
|
|
|
|
- });
|
|
|
|
- if (loading || !profileIds.length) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- const c = {
|
|
|
|
- data: {
|
|
|
|
- value: profileIds,
|
|
|
|
- layout: radioValue,
|
|
|
|
- },
|
|
|
|
- enabled: currentComponent?.enabled ?? true,
|
|
|
|
- id: currentComponent?.id,
|
|
|
|
- name: currentComponent?.name ?? "联系人",
|
|
|
|
- characterProfileId:
|
|
|
|
- currentComponent?.characterProfileId ?? character?.profileId,
|
|
|
|
- type: "contactList",
|
|
|
|
- };
|
|
|
|
- console.log(c);
|
|
|
|
- await saveComponent(c);
|
|
|
|
- };
|
|
|
|
|
|
|
|
- const handleNavBack = async () => {
|
|
|
|
- await handleSave();
|
|
|
|
- clear();
|
|
|
|
- };
|
|
|
|
|
|
+ const handleClick = () => {
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- const nav2ChooseContact = () => {
|
|
|
|
- Taro.navigateTo({
|
|
|
|
- url: `/pages/choose-contact/index?id=${id}&profileId=${profileId}`,
|
|
|
|
- });
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- const fetchList = async (cts: CancelTokenSource) => {
|
|
|
|
- const profileIds = currentComponent?.data?.value as string[] | undefined;
|
|
|
|
- if (!profileIds) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- const res = await batchGet(profileIds, {
|
|
|
|
- cancelToken: cts.token
|
|
|
|
- });
|
|
|
|
- if (res.code === 0) {
|
|
|
|
- const picked = res.data.map((item) => {
|
|
|
|
- return {
|
|
|
|
- ...item,
|
|
|
|
- contactProfileId: item.profileId,
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
- //
|
|
|
|
- setTmpPicked([...picked]);
|
|
|
|
- setPicked(picked);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- useEffect(() => {
|
|
|
|
- let cts = axios.CancelToken.source();
|
|
|
|
- if (id) {
|
|
|
|
- fetchList(cts);
|
|
|
|
- }
|
|
|
|
- return ()=> {
|
|
|
|
- return cts.cancel('batchGet request canceled')
|
|
|
|
- }
|
|
|
|
- }, [id]);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
return (
|
|
return (
|
|
<PageCustom>
|
|
<PageCustom>
|
|
- <NavBarNormal
|
|
|
|
- backText="保存"
|
|
|
|
- navDelta={deltaNum}
|
|
|
|
- onNavBack={handleNavBack}
|
|
|
|
- >
|
|
|
|
- {`${APP_NAME_TEXT}用户`}
|
|
|
|
- </NavBarNormal>
|
|
|
|
|
|
+ <NavBarNormal>智能体</NavBarNormal>
|
|
<View className="flex flex-col items-center w-full">
|
|
<View className="flex flex-col items-center w-full">
|
|
<View className={editorStyle.container}>
|
|
<View className={editorStyle.container}>
|
|
<ButtonCardAdd
|
|
<ButtonCardAdd
|
|
- text={`选择展示的${APP_NAME_TEXT}`}
|
|
|
|
- onClick={nav2ChooseContact}
|
|
|
|
|
|
+ text={`选择展示的智能体`}
|
|
|
|
+ onClick={handleClick}
|
|
></ButtonCardAdd>
|
|
></ButtonCardAdd>
|
|
- <WemetaTabs list={tabList} current="1"></WemetaTabs>
|
|
|
|
|
|
+ {renderContactList()}
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
|
|
+ <Popup setShow={setShow} show={show} title="知识库-链接">
|
|
|
|
+ <WemetaTabs current="1" list={tabList}></WemetaTabs>
|
|
|
|
+ <BottomBar>
|
|
|
|
+ <View
|
|
|
|
+ className="button-rounded button-primary flex-1"
|
|
|
|
+ onClick={handleSubmit}
|
|
|
|
+ >
|
|
|
|
+ 引用
|
|
|
|
+ </View>
|
|
|
|
+ </BottomBar>
|
|
|
|
+ </Popup>
|
|
|
|
+ <BottomBar>
|
|
|
|
+ <View className="button-rounded button-primary flex-1" onClick={handleSubmit}>保存</View>
|
|
|
|
+ </BottomBar>
|
|
</PageCustom>
|
|
</PageCustom>
|
|
);
|
|
);
|
|
}
|
|
}
|