From 272000b000564f5e4ed7c5562fe72a206c8a48f9 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期二, 12 十一月 2024 10:51:02 +0800 Subject: [PATCH] 修改知识库编辑的内容 --- src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue | 80 ++++++++++++++++++++++++++++++---------- 1 files changed, 60 insertions(+), 20 deletions(-) diff --git a/src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue b/src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue index 0fdb2af..9355cc4 100644 --- a/src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue +++ b/src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue @@ -8,7 +8,7 @@ ref="leftTreeRef" :defaultProps="{ id: 'group_id', - label: 'group_name', + label: 'label', children: 'children', }" :treedata="listTreeData" @@ -25,9 +25,11 @@ <template #header> <el-form ref="queryFormRef" :inline="true" :model="queryParams"> <el-form-item label="鏍囬" prop="title"> - <el-input v-model="queryParams.title" style="width: 226.4px" placeholder="鏍囬" clearable /> + <el-input v-model="queryParams.title" style="width: 226.4px" placeholder="鏍囬" clearable @input="debounceQueryTable" /> </el-form-item> + <el-form-item> + <!-- <el-button type="primary" icon="ele-Search" @click="handleQueryTable"> 鏌ヨ </el-button> --> <el-button icon="ele-Refresh" @click="resetQuery">閲嶇疆 </el-button> <el-button icon="ele-Plus" @click="openOptDlg()"> 娣诲姞 </el-button> </el-form-item> @@ -44,7 +46,7 @@ class="flex-auto" border :row-class-name="isDragStatus ? 'cursor-move' : 'cursor-pointer'" - :data="showPageList" + :data="displayTableData" highlight-current-row > <template v-for="item in columnList" :key="item.prop"> @@ -105,6 +107,7 @@ deleteCurrentRow(scope.row, '椤甸潰', supervisorAdminApi.deleteSupervisor, () => { const foundIndex = tableData.findIndex((item) => item === scope.row); foundIndex > -1 && tableData.splice(foundIndex, 1); + setCurrentLen(-1); }); } " @@ -196,10 +199,17 @@ <script setup lang="ts"> import { useDraggable } from '@vueuse/core'; +import { debounce, deleteCurrentRow, travelTree } from '/@/utils/util'; + +import { computed, onMounted, ref } from 'vue'; +import { usePageDisplay } from '/@/hooks/usePageDisplay'; +import { useQueryTable } from '/@/hooks/useQueryTable'; +// import { useTableSort } from '/@/hooks/useTableSort'; +// import { useValidateUniqueness } from '/@/hooks/useValidateUniqueness'; import axios, { CancelTokenSource } from 'axios'; import type { FormInstance, FormRules } from 'element-plus'; import { ElMessage, ElMessageBox } from 'element-plus'; -import { computed, nextTick, onMounted, ref, watch } from 'vue'; +import { nextTick } from 'vue'; import SqlAmisEdit from './edit/SqlAmisEdit.vue'; import OptDlg from './optDlg/OptDlg.vue'; import { SupervisorPublished, supervisorPublishedMap } from './types'; @@ -212,16 +222,14 @@ import ColFilter from '/@/components/table/colFilter/ColFilter.vue'; import { TableCol } from '/@/components/table/colFilter/types'; import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue'; -import { usePageDisplay } from '/@/hooks/usePageDisplay'; -import { useQueryTable } from '/@/hooks/useQueryTable'; -import { useSearch } from '/@/hooks/useSearch'; import { useUpdateData } from '/@/hooks/useUpdateData'; import emitter from '/@/utils/mitt'; import { deepClone } from '/@/utils/other'; import { gotoRoute } from '/@/utils/route'; import { useCompRef } from '/@/utils/types'; -import { convertListToTree, debounce, travelTree } from '/@/utils/util'; +import { convertListToTree } from '/@/utils/util'; import { OptClassificationMap, classificationEnum } from '/@/views/types/metrics'; + const columnList = ref<TableCol[]>([ { prop: 'title', label: '鏍囬', width: 300, fixed: 'left' }, { prop: 'published', label: '鍙戝竷鐘舵��', width: 85 }, @@ -239,6 +247,7 @@ const listData = ref([]); const currentListID = computed(() => currentNode.value?.group_id); const currentNode = ref(null); + const listTreeData = computed(() => { const byParentData = convertListToTree(listData.value, { ID: 'group_id', @@ -385,6 +394,38 @@ //#endregion //#region ====================== 琛ㄦ牸鏁版嵁锛宼able init ====================== + +const setCurrentLen = (offset: 1 | -1) => { + currentNode.value.label = `${currentNode.value.group_name} (${tableData.value.length})`; + const pId = currentNode.value.p_group_id; + if (pId) { + travelTree(listTreeData.value, (value) => { + if (value.group_id === pId) { + value.len += offset; + value.label = `${value.group_name} (${value.len})`; + return true; + } + }); + } + // 淇敼鍚嶇О鍚庯紝涓嶇煡閬撲负浠�涔堜細澶卞幓 current 閫変腑 + setTimeout(() => { + leftTreeRef.value?.treeRef.setCurrentKey(currentListID.value); + }, 0); +}; +const setListLen = () => { + travelTree(listTreeData.value, (value, index, array, parent) => { + const id = value.group_id; + const len = allTableData.value.filter( + (item) => item.group_id === id || value.children?.some((treeItem) => treeItem.group_id === item.group_id) + ).length; + value.len = len; + value.label = `${value.group_name} (${len})`; + }); + // 淇敼鍚嶇О鍚庯紝涓嶇煡閬撲负浠�涔堜細澶卞幓 current 閫変腑 + setTimeout(() => { + leftTreeRef.value?.treeRef.setCurrentKey(currentListID.value); + }, 0); +}; const tableLoading = ref(false); const tableData = ref([]); const isDragStatus = ref(false); @@ -398,8 +439,12 @@ return item; }); + setListLen(); } - tableData.value = allTableData.value.filter((item) => item.group_id === currentListID.value || currentNode.value.children?.some(treeItem=>treeItem.group_id===item.group_id)); + tableData.value = allTableData.value.filter( + (item) => + item.group_id === currentListID.value || currentNode.value.children?.some((treeItem) => treeItem.group_id === item.group_id) + ); }; //#endregion @@ -408,17 +453,10 @@ const queryParams = ref({ title: '', }); -const { query: queryTerminology, queryData: showPageList } = useSearch(tableData, queryParams); -const pageQuery = debounce(queryTerminology); -watch( - () => queryParams.value.title, - (val) => { - pageQuery(); - } -); -const { resetQuery, handleQueryTable } = useQueryTable(tableData, queryParams, () => { - showPageList.value = tableData.value; +const { resetQuery, handleQueryTable, displayTableData } = useQueryTable(tableData, queryParams, () => { + displayTableData.value = tableData.value; }); +const debounceQueryTable = debounce(handleQueryTable, 400); //#endregion //#region ====================== 鏌ヨ蹇嵎閿� ====================== @@ -475,6 +513,9 @@ const insertOpt = (newData) => { tableData.value.unshift({ ...newData, published: SupervisorPublished.N }); + allTableData.value.unshift({ ...newData, published: SupervisorPublished.N }); + + setCurrentLen(1); }; //#endregion @@ -581,4 +622,3 @@ }); </script> <style scoped lang="scss"></style> -, watch -- Gitblit v1.9.3