From 20dd2dc0554748c4f8e507374be31e3b5ec7a270 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期二, 15 十月 2024 15:19:33 +0800 Subject: [PATCH] 修改高级示例 --- src/views/project/ch/home/Home.vue | 18 +-- src/components/drawer/CustomDrawer.vue | 279 +++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 184 insertions(+), 113 deletions(-) diff --git a/src/components/drawer/CustomDrawer.vue b/src/components/drawer/CustomDrawer.vue index 174dcfa..05156ab 100644 --- a/src/components/drawer/CustomDrawer.vue +++ b/src/components/drawer/CustomDrawer.vue @@ -30,25 +30,32 @@ <el-input v-model="queryParams.sample_title" placeholder="鎼滅储鏇村" class="set-input" :prefix-icon="Search" clearable> </el-input> </div> - <div class="mt20 w100 relative" v-show="state.businessTagList.length > 0"> + <div class="mt20 w100 relative" v-show="state.customBusinessList.length > 0"> <div class="set_custom_label"> <div class="chanel-tags"> - <div v-for="(item, index) in state.businessTagList" :key="index" class="flex items-center"> - <span class="set-group-name">{{ item.group_name }}</span> - <div - class="overflow-hidden min-h-[43px] transition-[max-height 0.2s] w100 flex flex-wrap text-xs leading-[14px] items-center" - > - <div - v-for="(itemChildren, index) in item.Children" - :key="index" - :class="{ 'set-label-active': state.activeBusinessChildName === itemChildren.group_id }" - @click="handleLabelChildClick(itemChildren)" - class="cursor-pointer rounded-xl bg-[#e0e7f] text-[#b2b2b2] text-[12px] transition-[background-color .1s, color .1s, border-color .1s]" - > - <el-divider direction="vertical" />{{ itemChildren.group_name }} - </div> - </div> + <div + v-for="(item, index) in state.customBusinessList" + :key="index" + :class="{ 'set-group-label-active': state.activeBusinessName === item.group_id }" + class="flex items-center" + @click="handleBusinessClick(item)" + > + <span class="set-group-name">{{ item.group_name }}</span + ><el-divider direction="vertical" /> </div> + </div> + </div> + <div + class="overflow-hidden min-h-[43px] transition-[max-height 0.2s] w100 flex flex-wrap text-xs leading-[14px] items-center pt-2" + > + <div + v-for="(itemChildren, index) in state.customBusinessChildList" + :key="index" + :class="{ 'set-label-active': state.activeBusinessChildName === itemChildren.group_id }" + @click="handleLabelChildClick(itemChildren)" + class="cursor-pointer m-[5px] py-[5px] pl-[10px] pr-[14px] rounded-xl border border-solid border-[#b2b2b2] bg-[#e0e7f] text-[#4c4c4c] transition-[background-color .1s, color .1s, border-color .1s]" + > + {{ itemChildren.group_name }} </div> </div> <div class="mt20 w100" v-show="finalSampleList.length > 0"> @@ -77,32 +84,39 @@ <div class="box-border w-[354px] flex-1 min-h-0 bg-[#e0e7fb]" v-show="state.activeName == 2"> <div class="flex flex-col w100 h100 pt-0 pr-[15px] pb-0 pl-[20px] overflow-auto"> <div class="flex items-center w100 h-[30px] border border-solid border-[#b2b2b2] transition-[border-color 1s] rounded-2xl"> - <el-input v-model="instructParams.template_title" placeholder="鎼滅储鏇村" class="set-input" :prefix-icon="Search" clearable> + <el-input v-model="officeParams.template_title" placeholder="鎼滅储鏇村" class="set-input" :prefix-icon="Search" clearable> </el-input> </div> <div class="mt20 w100 relative" v-show="state.customOfficeList.length > 0"> <div class="set_custom_label"> <div class="chanel-tags"> - <div v-for="(item, index) in state.customOfficeList" :key="index" class="flex items-center"> - <span class="set-group-name">{{ item.group_name }}</span> - <div - class="overflow-hidden min-h-[43px] transition-[max-height 0.2s] w100 flex flex-wrap text-xs leading-[14px] items-center" - > - <div - v-for="(itemChildren, index) in item.Children" - :key="index" - :class="{ 'set-label-active': state.activeOfficeChildName === itemChildren.group_id }" - @click="handleOfficeChildClick(itemChildren)" - class="cursor-pointer rounded-xl bg-[#e0e7f] text-[#b2b2b2] text-[12px] transition-[background-color .1s, color .1s, border-color .1s]" - > - <el-divider direction="vertical" />{{ itemChildren.group_name }} - </div> - </div> + <div + v-for="(item, index) in state.customOfficeList" + :key="index" + :class="{ 'set-group-label-active': state.activeOfficeName === item.group_id }" + class="flex items-center" + @click="handleOfficeClick(item)" + > + <span class="set-group-name">{{ item.group_name }}</span + ><el-divider direction="vertical" /> </div> </div> </div> + <div + class="overflow-hidden min-h-[43px] transition-[max-height 0.2s] w100 flex flex-wrap text-xs leading-[14px] items-center pt-2" + > + <div + v-for="(itemChildren, index) in state.customOfficeChildList" + :key="index" + :class="{ 'set-label-active': state.activeOfficeChildName === itemChildren.group_id }" + @click="handleOfficeChildClick(itemChildren)" + class="cursor-pointer m-[5px] py-[5px] pl-[10px] pr-[14px] rounded-xl border border-solid border-[#b2b2b2] bg-[#e0e7f] text-[#4c4c4c] transition-[background-color .1s, color .1s, border-color .1s]" + > + {{ itemChildren.group_name }} + </div> + </div> <div class="mt20 w100"> - <div class="w100 pb-[20px] flex overflow-auto flex-col" v-for="item in showInstructList" :key="item.group_id"> + <div class="w100 pb-[20px] flex overflow-auto flex-col" v-for="item in finalOfficeList" :key="item.group_id"> <div class="bg-[#f5f7fd] p-[12px] transition-[background-color .2s] flex flex-col rounded-2xl"> <div class="flex justify-between"> <span class="set-title">{{ item.template_title }}</span> @@ -127,22 +141,29 @@ <div class="mt20 w100 relative" v-show="state.knowledgeBaseList.length > 0"> <div class="set_custom_label"> <div class="chanel-tags"> - <div v-for="(item, index) in state.knowledgeBaseList" :key="index" class="flex items-center"> - <span class="set-group-name">{{ item.group_name }}</span> - <div - class="overflow-hidden min-h-[43px] transition-[max-height 0.2s] w100 flex flex-wrap text-xs leading-[14px] items-center" - > - <div - v-for="(itemChildren, index) in item.Children" - :key="index" - :class="{ 'set-label-active': state.activeKnowledgeChildName === itemChildren.group_id }" - @click="handleKnowledgeChildClick(itemChildren)" - class="cursor-pointer rounded-xl bg-[#e0e7f] text-[#b2b2b2] text-[12px] transition-[background-color .1s, color .1s, border-color .1s]" - > - <el-divider direction="vertical" />{{ itemChildren.group_name }} - </div> - </div> + <div + v-for="(item, index) in state.knowledgeBaseList" + :key="index" + :class="{ 'set-group-label-active': state.activeKnowledgeName === item.group_id }" + class="flex items-center" + @click="handleKnowledgeClick(item)" + > + <span class="set-group-name">{{ item.group_name }}</span + ><el-divider direction="vertical" /> </div> + </div> + </div> + <div + class="overflow-hidden min-h-[43px] transition-[max-height 0.2s] w100 flex flex-wrap text-xs leading-[14px] items-center pt-2" + > + <div + v-for="(itemChildren, index) in state.customKnowledgeChildList" + :key="index" + :class="{ 'set-label-active': state.activeKnowledgeChildName === itemChildren.group_id }" + @click="handleKnowledgeChildClick(itemChildren)" + class="cursor-pointer m-[5px] py-[5px] pl-[10px] pr-[14px] rounded-xl border border-solid border-[#b2b2b2] bg-[#e0e7f] text-[#4c4c4c] transition-[background-color .1s, color .1s, border-color .1s]" + > + {{ itemChildren.group_name }} </div> </div> <div class="mt20 w100" v-show="finalKnowledgeList.length > 0"> @@ -196,9 +217,18 @@ { ID: 3, Name: '鐭ヨ瘑搴�' }, ], activeName: 1, - activeBusinessChildName: '', //鍦烘櫙 - activeOfficeChildName: '', //鍔炲叕 - activeKnowledgeChildName: '', //鐭ヨ瘑搴� + activeBusinessName: '', //鍦烘櫙 + activeBusinessChildName: '', + customBusinessList: [], + customBusinessChildList: [], + activeOfficeName: '', //鍔炲叕 + activeOfficeChildName: '', + customOfficeList: [], + customOfficeChildList: [], + activeKnowledgeName: '', //鐭ヨ瘑搴� + activeKnowledgeChildName: '', + knowledgeBaseList: [], + customKnowledgeChildList: [], useInstructDialog: false, instructInfo: {}, inputInstruct: '', //鍙慨鏀规寚浠� @@ -208,19 +238,17 @@ listInstructLoading: false, listSampleExpand: false, listInstructExpand: false, - knowledgeBaseList: [], - customTagChildList: [], - customOfficeList: [], - businessTagList: [], }); -const instructContentList = ref([]); //鎸囦护鍒楄〃 -const exampleList = ref([]); //绀轰緥鍒楄〃 +//#region ====================== 浼犲弬 ====================== const isShow = defineModel('isShow', { type: Boolean, }); - -const emit = defineEmits(['updateChatInput']); const rightBox = computed(() => (isShow.value ? 354 : 0)); +const emit = defineEmits(['updateChatInput']); +//#endregion +//#region ====================== 涓氬姟鍦烘櫙/鍔炲叕鍔╂墜/鐭ヨ瘑搴撶殑list ====================== +const instructContentList = ref([]); //鎸囦护鍒楄〃 +const exampleList = ref([]); //绀轰緥鍒楄〃 //鑾峰彇妯$増鍒楄〃 const getSelectListSample = async () => { state.listSampleLoading = true; @@ -259,35 +287,71 @@ }); instructContentList.value = res.templates; }; -//鍒囨崲鍒版寚浠�/鎻愰棶 -const handleTabClick = (item) => { +//#endregion +//#region ====================== 榛樿閫夋嫨绗竴涓殑鍦烘櫙鐨勫瓙鍦烘櫙 ====================== +//tags鏍囩鍒囨崲 +const handleTabClick = async (item) => { state.activeName = item.ID; + if (state.activeName == 2) { + if (state.listInstructExpand) return; + await getUserTemplate(); + state.listInstructExpand = true; + } tagListClick(sectionAList.value); - getTableData(); }; //鍦烘櫙瀛愬満鏅� +const handleBusinessClick = (item) => { + state.activeBusinessName = item.group_id; + state.customBusinessChildList = item.Children; + if (item.Children.length > 0) { + state.activeBusinessChildName = item.Children[0].group_id ?? ''; + } else { + state.activeBusinessChildName = ''; + state.customBusinessChildList = []; + } +}; const handleLabelChildClick = (item) => { state.activeBusinessChildName = item.group_id; }; //鍔炲叕瀛愬満鏅� +const handleOfficeClick = (item) => { + state.activeOfficeName = item.group_id; + state.customOfficeChildList = item.Children; + if (item.Children.length > 0) { + state.activeOfficeChildName = item.Children[0].group_id ?? ''; + } else { + state.activeOfficeChildName = ''; + state.customOfficeChildList = []; + } +}; const handleOfficeChildClick = (item) => { state.activeOfficeChildName = item.group_id; }; //鐭ヨ瘑搴撳瓙鍦烘櫙 +const handleKnowledgeClick = (item) => { + state.activeKnowledgeName = item.group_id; + state.customKnowledgeChildList = item.Children; + if (item.Children.length > 0) { + state.activeKnowledgeChildName = item.Children[0].group_id ?? ''; + } else { + state.activeKnowledgeChildName = ''; + state.customKnowledgeChildList = []; + } +}; const handleKnowledgeChildClick = (item) => { state.activeKnowledgeChildName = item.group_id; }; +//#endregion +//鎵撳紑楂樼骇绀轰緥 const toggleShow = async () => { isShow.value = !isShow.value; - if (!isShow.value) { - loadingData.value = true; - await getMainSectionList().finally(() => { - loadingData.value = false; - }); - - getTableData(); - } + getTableData(); }; +//鍏抽棴楂樼骇绀轰緥 +const handleCloseTemplate = () => { + isShow.value = false; +}; +//鑾峰彇涓诲満鏅垪琛� const getMainSectionList = async () => { const res = await getSectionList(); const iconList = [ @@ -309,27 +373,19 @@ }; const loadingData = ref(false); const getTableData = async () => { - loadingData.value = true; - - try { + if (!isShow.value) { + loadingData.value = true; + await getMainSectionList().finally(() => { + loadingData.value = false; + }); if (state.activeName == 1 || state.activeName == 3) { if (state.listSampleExpand) return; await getSelectListSample(); state.listSampleExpand = true; } - if (state.activeName == 2) { - if (state.listInstructExpand) return; - await getUserTemplate(); - state.listInstructExpand = true; - } - } finally { - loadingData.value = false; } }; -//鍏抽棴楂樼骇绀轰緥 -const handleCloseTemplate = () => { - isShow.value = false; -}; + //#region ====================== templateUseClick ====================== const templateUseClick = (row) => { state.useInstructDialog = true; @@ -362,15 +418,18 @@ } ); //鍔炲叕 -const instructParams = ref({ +const officeParams = ref({ template_title: '', }); -const { query: queryInstruct, queryData: showInstructList } = useSearch(instructContentList, instructParams); - +const { query: queryInstruct, queryData: showInstructList } = useSearch(instructContentList, officeParams); +const finalOfficeList = computed(() => { + const result = showInstructList.value.filter((item) => item.template_group == state.activeOfficeChildName); + return result ?? []; +}); const instructQuery = debounce(queryInstruct); watch( - () => instructParams.value.template_title, + () => officeParams.value.template_title, (val) => { instructQuery(); } @@ -387,7 +446,7 @@ const knowledgeQuery = debounce(queryKnowledge); watch( - () => instructParams.value.template_title, + () => officeParams.value.template_title, (val) => { knowledgeQuery(); } @@ -420,8 +479,10 @@ Children: 'Children', ParentID: 'p_group_id', }); - state.activeBusinessChildName = treeBusinessList[0].Children[0].group_id ?? ''; - state.businessTagList = treeBusinessList; //涓氬姟鍦烘櫙 + state.customBusinessList = treeBusinessList; //涓氬姟鍦烘櫙鏁版嵁婧� + state.activeBusinessName = treeBusinessList[0].group_id; //榛樿閫変腑绗竴涓笟鍔″満鏅� + state.customBusinessChildList = treeBusinessList[0].Children; //榛樿閫変腑绗竴涓笟鍔″満鏅殑绗竴涓瓙鍦烘櫙鐨勬暟鎹簮 + state.activeBusinessChildName = treeBusinessList[0].Children[0].group_id; break; case 2: const treeOfficeList = convertListToTree(officeList, { @@ -429,8 +490,10 @@ Children: 'Children', ParentID: 'p_group_id', }); - state.activeOfficeChildName = treeOfficeList[0].Children[0].group_id ?? ''; - state.customOfficeList = treeOfficeList; //鍔炲叕鍔╂墜 + state.customOfficeList = treeOfficeList; //鍔炲叕鍔╂墜鏁版嵁婧� + state.activeOfficeName = treeOfficeList[0].group_id; //榛樿閫変腑绗竴涓姙鍏姪鎵� + state.customOfficeChildList = treeOfficeList[0].Children; //榛樿閫変腑绗竴涓姙鍏姪鎵嬬殑绗竴涓瓙鍦烘櫙鐨勬暟鎹簮 + state.activeOfficeChildName = treeOfficeList[0].Children[0].group_id; //榛樿閫変腑绗竴涓姙鍏姪鎵嬬殑绗竴涓瓙鍦烘櫙 break; case 3: const treeTagList = convertListToTree(selectTagList, { @@ -438,14 +501,25 @@ Children: 'Children', ParentID: 'p_group_id', }); - state.knowledgeBaseList = treeTagList; //鐭ヨ瘑搴� - state.activeKnowledgeChildName = treeTagList[0].Children[0].group_id ?? ''; + state.knowledgeBaseList = treeTagList; //鐭ヨ瘑搴撴暟鎹簮 + state.activeKnowledgeName = treeTagList[0].group_id; //榛樿閫変腑绗竴涓煡璇嗗簱 + state.customKnowledgeChildList = treeTagList[0].Children; //榛樿閫変腑绗竴涓煡璇嗗簱鐨勭涓�涓瓙鍦烘櫙鐨勬暟鎹簮 + state.activeKnowledgeChildName = treeTagList[0].Children[0].group_id; //榛樿閫変腑绗竴涓煡璇嗗簱鐨勭涓�涓瓙鍦烘櫙 break; } } else { - state.knowledgeBaseList = []; + state.customBusinessList = []; + state.customBusinessChildList = []; + state.customOfficeChildList = []; + state.customKnowledgeChildList = []; + state.activeBusinessName = ''; + state.activeBusinessChildName = ''; + state.activeOfficeName = ''; + state.activeOfficeChildName = ''; + state.activeKnowledgeName = ''; + state.activeKnowledgeChildName = ''; state.customOfficeList = []; - state.businessTagList = []; + state.knowledgeBaseList = []; } }; //#endregion @@ -454,7 +528,6 @@ </script> <style scoped lang="scss"> .exampleSlide { - // position: absolute; right: 0; top: 0; height: 100%; @@ -463,8 +536,7 @@ z-index: 100; } .set_custom_label { - // height: 141px; - min-height: 53px; + min-height: 38px; box-sizing: border-box; background-color: #f2f4f8; border-bottom: 1px solid #eee; @@ -473,9 +545,12 @@ position: relative; overflow: hidden; font-size: 12px; - color: #000; + display: flex; + flex-wrap: wrap; line-height: 26px; padding: 6px; + color: #4c4c4c; + cursor: pointer; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; @@ -571,6 +646,8 @@ color: #1c86ff; } .set-label-active { + border-color: #1c86ff; + background-color: #ccdcfb; color: #1c86ff; } .example-body { diff --git a/src/views/project/ch/home/Home.vue b/src/views/project/ch/home/Home.vue index ec19ff4..58a3440 100644 --- a/src/views/project/ch/home/Home.vue +++ b/src/views/project/ch/home/Home.vue @@ -5,8 +5,8 @@ <div class="w100 h100 overflow-hidden"> <div class="pc-chatRoom w100 h100"> <div class="homeBox w100 h-full"> - <div class="flex items-center h-full "> - <div class="flex items-center flex-column" style="overflow: unset !important;"> + <div class="flex items-center h-full"> + <div class="flex items-center flex-column" style="overflow: unset !important"> <waterTop ref="topRef" /> <waterCenter @advanceExampleClick="advanceExampleClick" @@ -14,14 +14,10 @@ ref="waterCenterRef" @updateChatInput="updateChatInput" /> - <waterBottom /> + <waterBottom /> </div> - <CustomDrawer - v-model:isShow="state.isShowAdvanceExample" - ref="customDrawerrRef" - @updateChatInput="updateChatInput" - /> + <CustomDrawer v-model:isShow="state.isShowAdvanceExample" ref="customDrawerRef" @updateChatInput="updateChatInput" /> </div> </div> <!-- <p class="declare"> @@ -44,22 +40,20 @@ import CustomDrawer from '/@/components/drawer/CustomDrawer.vue'; let state = reactive({ isShowAdvanceExample: false, - }); const topRef = ref(null); const waterCenterRef = ref(null); -const customDrawerrRef = ref(null); +const customDrawerRef = ref(null); const updateChatInput = (val) => { topRef.value.updateChatInput(val); }; const advanceExampleClick = (status: boolean) => { state.isShowAdvanceExample = status; if (status) { - customDrawerrRef.value.getTableData(); + customDrawerRef.value.getTableData(); } }; - </script> <style scoped lang="scss"> .pc-chat_room { -- Gitblit v1.9.3