| | |
| | | ref="leftTreeRef" |
| | | :defaultProps="{ |
| | | id: 'group_id', |
| | | label: 'group_name', |
| | | label: 'label', |
| | | children: 'children', |
| | | }" |
| | | :treedata="listTreeData" |
| | |
| | | <template v-for="item in columnList" :key="item.prop"> |
| | | <el-table-column |
| | | v-if="item.isShow ?? true" |
| | | :type="item.type" |
| | | :prop="item.prop" |
| | | :label="item.label" |
| | | :fixed="item.fixed" |
| | | :width="item.width" |
| | | :align="item.align" |
| | | showOverflowTooltip |
| | | > |
| | | <template #default="scope" v-if="item.prop === 'published'"> |
| | |
| | | deleteCurrentRow(scope.row, '页面', supervisorAdminApi.deleteSupervisor, () => { |
| | | const foundIndex = tableData.findIndex((item) => item === scope.row); |
| | | foundIndex > -1 && tableData.splice(foundIndex, 1); |
| | | setCurrentLen(-1); |
| | | }); |
| | | } |
| | | " |
| | |
| | | |
| | | <script setup lang="ts"> |
| | | import { useDraggable } from '@vueuse/core'; |
| | | import { debounce, travelTree } from '/@/utils/util'; |
| | | 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 { CancelTokenSource } from 'axios'; |
| | | import axios from 'axios'; |
| | | import type { FormInstance, FormRules } from 'element-plus'; |
| | | import { ElMessage, ElMessageBox } from 'element-plus'; |
| | | import { nextTick } from 'vue'; |
| | |
| | | import Chat from '/@/components/chat/Chat.vue'; |
| | | import AHMContainer from '/@/components/layout/AHMContainer.vue'; |
| | | import ColFilter from '/@/components/table/colFilter/ColFilter.vue'; |
| | | import { TableCol } from '/@/components/table/colFilter/types'; |
| | | import type { TableCol } from '/@/components/table/colFilter/types'; |
| | | import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue'; |
| | | import { useUpdateData } from '/@/hooks/useUpdateData'; |
| | | import emitter from '/@/utils/mitt'; |
| | |
| | | import { OptClassificationMap, classificationEnum } from '/@/views/types/metrics'; |
| | | |
| | | const columnList = ref<TableCol[]>([ |
| | | { type: 'index', label: '序号', width: 55, fixed: 'left', align: 'center' }, |
| | | { prop: 'title', label: '标题', width: 300, fixed: 'left' }, |
| | | { prop: 'published', label: '发布状态', width: 85 }, |
| | | { prop: 'prompt', label: '提示词', width: 300 }, |
| | |
| | | { prop: 'note', label: '备注' }, |
| | | { prop: 'operate', label: '操作', width: 200, fixed: 'right' }, |
| | | ]); |
| | | |
| | | //#region ====================== 左侧树数据,tree init ====================== |
| | | const leftTreeRef = useCompRef(LeftTreeByMgr); |
| | | const treeLoading = ref(false); |
| | |
| | | //#endregion |
| | | |
| | | //#region ====================== 表格数据,table init ====================== |
| | | const getLenById =(data:any[],id:string,value:any)=>{ |
| | | return data.filter( |
| | | (item) => |
| | | item.group_id === id || value.children?.some((treeItem) => treeItem.group_id === item.group_id) |
| | | ).length; |
| | | } |
| | | |
| | | 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); |
| | |
| | | |
| | | return item; |
| | | }); |
| | | |
| | | travelTree(listTreeData.value, (value, index, array, parent) => { |
| | | const len = getLenById(allTableData.value,value.group_id,value); |
| | | value.group_name =`${value.group_name} (${len})` |
| | | |
| | | }) |
| | | |
| | | setListLen(); |
| | | } |
| | | tableData.value = allTableData.value.filter( |
| | | (item) => |
| | |
| | | |
| | | const insertOpt = (newData) => { |
| | | tableData.value.unshift({ ...newData, published: SupervisorPublished.N }); |
| | | allTableData.value.unshift({ ...newData, published: SupervisorPublished.N }); |
| | | |
| | | setCurrentLen(1); |
| | | }; |
| | | //#endregion |
| | | |