| | |
| | | label: 'group_name', |
| | | children: 'children', |
| | | }" |
| | | :treedata="listTreeData" |
| | | :treedata="listLeftData" |
| | | title-name="场景列表" |
| | | :show-more-operate="false" |
| | | :show-add="false" |
| | |
| | | //#region ====================== 左侧树数据,tree init ====================== |
| | | const leftTreeRef = useCompRef(LeftTreeByMgr); |
| | | const treeLoading = ref(false); |
| | | const listData = ref([]); |
| | | const listLeftData = ref([]); |
| | | const currentListID = computed(() => currentNode.value?.group_id); |
| | | const currentNode = ref(null); |
| | | const listTreeData = computed(() => { |
| | | const byParentData = convertListToTree(listData.value, { |
| | | ID: 'group_id', |
| | | ParentID: 'p_group_id', |
| | | Children: 'children', |
| | | }); |
| | | const result = []; |
| | | byParentData.forEach((item) => { |
| | | if ( |
| | | item.group_type != OptClassificationMap[classificationEnum.Office] && |
| | | item.group_type != OptClassificationMap[classificationEnum.Knowledge] |
| | | ) { |
| | | result.push(item); |
| | | } |
| | | }); |
| | | return result; |
| | | }); |
| | | const handleClickNode = (data) => { |
| | | nextTick(() => { |
| | | leftTreeRef.value?.treeRef.setCurrentKey(data.group_id); |
| | | }); |
| | | currentNode.value = data; |
| | | getTableData(); |
| | | terminologyData.value = data.sampleList; |
| | | }; |
| | | const getListTreeData = async () => { |
| | | const res = await agentGroupApi.getSceneGroupTreeByPost(); |
| | | listData.value = res.groups || []; |
| | | const firstListTreeNode = listTreeData.value[0]; |
| | | currentNode.value = firstListTreeNode; |
| | | getTableData(); |
| | | }; |
| | | |
| | | //#endregion |
| | | //#region ====================== 推荐问题 ====================== |
| | | const terminologyData = ref([]); |
| | | const terminologyData = ref([]); //显示的数据源 |
| | | //获取场景list |
| | | const getTableData = async () => { |
| | | let selNode = currentNode.value; |
| | | let curGroupID = []; |
| | | if (selNode.children && selNode.children.length > 0) { |
| | | selNode.children.forEach((item) => { |
| | | curGroupID.push(item.group_id); |
| | | }); |
| | | } else { |
| | | curGroupID.push(selNode.group_id); |
| | | } |
| | | const res = await get_scene_group_sample(); |
| | | res.samples.forEach((sample, index) => { |
| | | sample.Icon = '/static/images/wave/ChatImg.png'; |
| | | sample.BgColor = randomHexColor(); |
| | | const initData = async () => { |
| | | const [treeData, sampleData] = await Promise.all([agentGroupApi.getSceneGroupTreeByPost(), get_scene_group_sample()]); |
| | | const tree_Data = treeData.groups ?? []; |
| | | const sample_Data = sampleData.samples ?? []; |
| | | let result = []; |
| | | let new_tree_Data = []; |
| | | tree_Data.forEach((node, index) => { |
| | | if ( |
| | | node.group_type != OptClassificationMap[classificationEnum.Office] && |
| | | node.group_type != OptClassificationMap[classificationEnum.Knowledge] |
| | | ) { |
| | | new_tree_Data.push(node); |
| | | } |
| | | }); |
| | | let terminology_Data = []; |
| | | curGroupID.forEach((curItem) => { |
| | | res.samples.forEach((sample) => { |
| | | if (curItem == sample.group_id) terminology_Data.push(sample); |
| | | |
| | | new_tree_Data.forEach((node, index) => { |
| | | node.sampleList = []; |
| | | sample_Data.forEach((sample, index) => { |
| | | sample.Icon = '/static/images/wave/ChatImg.png'; |
| | | sample.BgColor = randomHexColor(); |
| | | if (node.group_id == sample.group_id) { |
| | | node.sampleList.push(sample); |
| | | } |
| | | }); |
| | | if (node.p_group_id) { |
| | | node.group_name = `${node.group_name} (${node.sampleList.length})`; |
| | | } |
| | | }); |
| | | terminologyData.value = terminology_Data; |
| | | |
| | | const byParentData = convertListToTree(new_tree_Data, { |
| | | ID: 'group_id', |
| | | ParentID: 'p_group_id', |
| | | Children: 'children', |
| | | }); |
| | | byParentData.forEach((item) => { |
| | | if (item.children && item.children.length > 0) { |
| | | item.children.forEach((child_node) => { |
| | | item.sampleList = item.sampleList.concat(child_node.sampleList); |
| | | }); |
| | | } |
| | | result.push(item); |
| | | |
| | | item.group_name = `${item.group_name} (${item.sampleList.length})`; |
| | | }); |
| | | listLeftData.value = byParentData; |
| | | const firstListTreeNode = byParentData[0]; |
| | | terminologyData.value = firstListTreeNode.sampleList; |
| | | currentNode.value = firstListTreeNode; |
| | | }; |
| | | |
| | | //随机生成颜色 |
| | | const randomHexColor = () => { |
| | | return `#${Math.floor(Math.random() * 16777215) |
| | |
| | | const changeExample = (item) => { |
| | | openChatTest(item); |
| | | }; |
| | | |
| | | //#endregion |
| | | //#region ====================== 表格查询、排序,search form init ====================== |
| | | const queryParams = ref({ |
| | |
| | | return res; |
| | | }; |
| | | //#endregion |
| | | onMounted(() => { |
| | | getListTreeData(); |
| | | onMounted(async () => { |
| | | initData(); |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"> |