|
@@ -5,7 +5,7 @@ import {
|
|
|
addReportQueryCenter,
|
|
|
delReportQueryCenterById,
|
|
|
getReportTree,
|
|
|
- ReportForms, updateParentById
|
|
|
+ ReportForms, updateName, updateParentById
|
|
|
} from "@/api/reports/report-query-center";
|
|
|
import {componentType} from "@/components/query-components/page-help-type";
|
|
|
import {dataTree} from '../public-data'
|
|
@@ -15,6 +15,8 @@ import type {
|
|
|
NodeDropType,
|
|
|
} from 'element-plus/es/components/tree/src/tree.type'
|
|
|
import {useCompRef} from "@/utils/useCompRef";
|
|
|
+import RightClickMenu from "@/components/menu-item/RightClickMenu.vue";
|
|
|
+import {CyMessageBox} from "@/components/cy/message-box";
|
|
|
|
|
|
const props = defineProps<{
|
|
|
currentPage: (data: ReportForms) => void
|
|
@@ -22,20 +24,12 @@ const props = defineProps<{
|
|
|
|
|
|
const treeRef = useCompRef(ElTree)
|
|
|
|
|
|
-const contextmenu = (event: Event, data: ReportForms) => {
|
|
|
- console.log(event, data)
|
|
|
-}
|
|
|
|
|
|
const addPageClick = async () => {
|
|
|
- let {value} = await ElMessageBox.prompt('创建文件夹', '提示', {
|
|
|
- type: "warning",
|
|
|
- confirmButtonText: '确认',
|
|
|
- cancelButtonText: '取消',
|
|
|
- inputPattern: /\S/,
|
|
|
- inputValidator: (val) => {
|
|
|
- return val.length <= 20;
|
|
|
- },
|
|
|
- inputErrorMessage: '名称不能为空,且不能超过 20 个字。',
|
|
|
+ let {value} = await CyMessageBox.prompt({
|
|
|
+ title: '创建文件夹',
|
|
|
+ inputMaxLength: 20,
|
|
|
+ inputRows: 2,
|
|
|
})
|
|
|
|
|
|
addReportQueryCenter({
|
|
@@ -65,8 +59,8 @@ const nodeClick = (data: ReportForms, a) => {
|
|
|
currentTreeParent.value = data.parentId === null ? null : temp
|
|
|
}
|
|
|
|
|
|
-const currentTree = ref<ReportForms>(null)
|
|
|
-const currentTreeParent = ref<ReportForms>(null)
|
|
|
+const currentTree = ref<ReportForms | any>({})
|
|
|
+const currentTreeParent = ref<ReportForms | any>({})
|
|
|
const addFile = async () => {
|
|
|
let defaultValue: componentType = {
|
|
|
isShow: true,
|
|
@@ -129,8 +123,9 @@ const addFile = async () => {
|
|
|
}
|
|
|
|
|
|
const delReportQueryCenterClick = async (data: ReportForms) => {
|
|
|
- await ElMessageBox.alert('是否删除', '提示', {
|
|
|
- type: 'error'
|
|
|
+ await CyMessageBox.confirm({
|
|
|
+ message: '你确定要删除吗?',
|
|
|
+ type: 'delete'
|
|
|
})
|
|
|
delReportQueryCenterById(data.id).then((res) => {
|
|
|
getReportTreeFunc()
|
|
@@ -149,6 +144,37 @@ const handleDragEnd = (draggingNode: Node, dropNode: Node, dropType: NodeDropTyp
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const config = [
|
|
|
+ {
|
|
|
+ name: '修改文件名',
|
|
|
+ click: async (data: ReportForms) => {
|
|
|
+ const {value} = await CyMessageBox.prompt({
|
|
|
+ title: '文件名',
|
|
|
+ inputMaxLength: 20,
|
|
|
+ inputRows: 2,
|
|
|
+ inputDefaultValue: data.name
|
|
|
+ })
|
|
|
+ await updateName(data.id, value)
|
|
|
+ data.name = value
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '删除',
|
|
|
+ click: (data: ReportForms) => {
|
|
|
+ delReportQueryCenterClick(data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+]
|
|
|
+
|
|
|
+const mousePosition = ref({})
|
|
|
+const contextmenu = (event: Event, data: ReportForms) => {
|
|
|
+ mousePosition.value = {
|
|
|
+ event,
|
|
|
+ data: data,
|
|
|
+ index: data['$treeNodeId']
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
getReportTreeFunc()
|
|
|
})
|
|
@@ -158,6 +184,7 @@ onMounted(() => {
|
|
|
<template>
|
|
|
<el-button @click="addPageClick">新增文件夹</el-button>
|
|
|
<el-button @click="addFile">新增文件</el-button>
|
|
|
+ <RightClickMenu :config="config" :mouse-position="mousePosition"/>
|
|
|
<el-tree :data="dataTree"
|
|
|
ref="treeRef"
|
|
|
@node-click="nodeClick"
|
|
@@ -165,14 +192,8 @@ onMounted(() => {
|
|
|
highlight-current
|
|
|
draggable
|
|
|
:allow-drop="allowDrop"
|
|
|
- @node-drag-end="handleDragEnd"
|
|
|
- default-expand-all>
|
|
|
+ @node-drag-end="handleDragEnd">
|
|
|
<template #default="{node,data}">
|
|
|
- <el-button type="danger"
|
|
|
- text
|
|
|
- @click.stop="delReportQueryCenterClick(data)">
|
|
|
- 删除
|
|
|
- </el-button>
|
|
|
<el-icon>
|
|
|
<Document v-if="data.type === 0"/>
|
|
|
<Folder v-else/>
|