|
@@ -1,95 +1,214 @@
|
|
|
<template>
|
|
|
- <el-dialog v-model="isOpen" append-to-body width="700">
|
|
|
- <template #header>
|
|
|
- <div class="my-header">
|
|
|
- <div class="title">选择文件</div>
|
|
|
+ <el-dialog v-model="isOpen" append-to-body width="700">
|
|
|
+ <template #header>
|
|
|
+ <div class="my-header">
|
|
|
+ <div class="title">转存到</div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div class="main-cont">
|
|
|
+ <div class="main-cont-left">
|
|
|
+ <div class="build-file" v-if="dirBulidNow">
|
|
|
+ <img :src="fileImg" alt="" class="left-img build-img" />
|
|
|
+ <el-input
|
|
|
+ v-model="dirName"
|
|
|
+ class="bulid-input"
|
|
|
+ clearable
|
|
|
+ placeholder="新建目录"
|
|
|
+ />
|
|
|
+ <el-icon size="20" color="#327CEC" @click="sureDir"
|
|
|
+ ><CircleCheckFilled
|
|
|
+ /></el-icon>
|
|
|
</div>
|
|
|
- </template>
|
|
|
- <div class="main-cont">
|
|
|
- <div class="main-cont-left">
|
|
|
- <el-tree-v2
|
|
|
- ref="treeRef"
|
|
|
- :data="treeData.data"
|
|
|
- :show-checkbox="false"
|
|
|
- :height="280"
|
|
|
- :props="defaultProps"
|
|
|
- @node-click="handleNodeClick"
|
|
|
- >
|
|
|
- <template #default="{ node }">
|
|
|
- <span style="display: flex;align-items: center;">
|
|
|
- <img :src="fileImg" alt="" style="width: 20px;height: 20px;margin-right: 5px;"/>
|
|
|
- <!-- 放置图片 -->
|
|
|
- <span>{{ node.label }}</span>
|
|
|
- <!-- 显示节点标签 -->
|
|
|
- </span>
|
|
|
- </template>
|
|
|
- </el-tree-v2>
|
|
|
+ <el-tree-v2
|
|
|
+ ref="treeRef"
|
|
|
+ :data="treeData.data"
|
|
|
+ :highlight-current="true"
|
|
|
+ :default-expanded-keys="[spaceId]"
|
|
|
+ :show-checkbox="false"
|
|
|
+ :height="280"
|
|
|
+ :props="defaultProps"
|
|
|
+ @node-click="handleNodeClick"
|
|
|
+ >
|
|
|
+ <template #default="{ node }">
|
|
|
+ <span style="display: flex; align-items: center">
|
|
|
+ <img :src="fileImg" alt="" class="left-img" />
|
|
|
+ <!-- 放置图片 -->
|
|
|
+ <span>{{ node.label }}</span>
|
|
|
+ <!-- 显示节点标签 -->
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-tree-v2>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <div class="footer">
|
|
|
+ <span
|
|
|
+ ><el-button @click.stop="buildFile" class="cancel-button"
|
|
|
+ >新建文件夹</el-button
|
|
|
+ ></span
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="isOpen = false" class="cancel-button"
|
|
|
+ >取消</el-button
|
|
|
+ >
|
|
|
+ <el-button type="primary" @click="confirm" class="sure-button">
|
|
|
+ 确认
|
|
|
+ </el-button>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <template #footer>
|
|
|
- <span class="dialog-footer">
|
|
|
- <el-button @click="isOpen = false" class="cancel-button"
|
|
|
- >取消</el-button
|
|
|
- >
|
|
|
- <el-button type="primary" @click="confirm" class="sure-button">
|
|
|
- 确认
|
|
|
- </el-button>
|
|
|
- </span>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
- </template>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
<script setup>
|
|
|
- import { reactive, ref, toRaw, toRefs, watch } from "vue";
|
|
|
- import { ElMessage } from "element-plus";
|
|
|
- import fileImg from "@/assets/images/file-img.png";
|
|
|
- import useUserStore from "@/store/modules/user";
|
|
|
- import { defineEmits } from "vue";
|
|
|
- const opent = ref(true);
|
|
|
- const props = defineProps({
|
|
|
- openForwardFile: {
|
|
|
- type: Boolean,
|
|
|
- default: false,
|
|
|
- },
|
|
|
- forwardTreeData: {
|
|
|
- type: Object,
|
|
|
- default: () => {},
|
|
|
- },
|
|
|
+import { reactive, ref, toRaw, toRefs, watch, nextTick, onMounted } from "vue";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
+import fileImg from "@/assets/images/file-img.png";
|
|
|
+import direction from "@/assets/images/direction.png";
|
|
|
+import useUserStore from "@/store/modules/user";
|
|
|
+import { defineEmits } from "vue";
|
|
|
+import { builtDir, fileCopy, spaceInfo, dirTree } from "@/api/chat/msg";
|
|
|
+const opent = ref(true);
|
|
|
+const props = defineProps({
|
|
|
+ openForwardFile: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ forwardTreeData: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {},
|
|
|
+ },
|
|
|
+ docId: {
|
|
|
+ type: String,
|
|
|
+ },
|
|
|
+ spaceId: {
|
|
|
+ type: String,
|
|
|
+ },
|
|
|
+});
|
|
|
+const defaultProps = {
|
|
|
+ children: "children",
|
|
|
+ label: "label",
|
|
|
+ value: "id",
|
|
|
+};
|
|
|
+const dirName = ref(""); //新建文件夹名称
|
|
|
+const dirBulidNow = ref(false);
|
|
|
+const treeRef = ref(null);
|
|
|
+const isOpen = ref(props.openForwardFile);
|
|
|
+watch(
|
|
|
+ () => props.openForwardFile,
|
|
|
+ (newValue) => {
|
|
|
+ isOpen.value = newValue;
|
|
|
+ }
|
|
|
+);
|
|
|
+const treeData = reactive({ data: [] });
|
|
|
+const defaultExpandedKeys = ref([]);
|
|
|
+watchEffect(() => {
|
|
|
+ treeData.data[0] = props.forwardTreeData;
|
|
|
+// //默认展开第二级
|
|
|
+// treeData.data.forEach((node) => {
|
|
|
+// if (node.children) {
|
|
|
+// // 如果节点有子节点
|
|
|
+// const childKeys = node.children.map((child) => child.id); // 获取子节点的 key 数组
|
|
|
+// defaultExpandedKeys.value= [... defaultExpandedKeys.value, ...childKeys]; // 将子节点的 key 数组合并到 defaultExpandedKeys 中
|
|
|
+// }
|
|
|
+// });
|
|
|
+});
|
|
|
+watchEffect(() => {
|
|
|
+ console.log("props.docId", props.docId);
|
|
|
+});
|
|
|
+//树
|
|
|
+const clickData = ref({});
|
|
|
+const handleNodeClick = (data) => {
|
|
|
+ clickData.value = data;
|
|
|
+};
|
|
|
+//确定按钮
|
|
|
+const emit = defineEmits(["forwardChangeMsg"]);
|
|
|
+const confirm = async () => {
|
|
|
+ const copyRes = await fileCopy({
|
|
|
+ docId: props.docId,
|
|
|
+ dirId: clickData.value.id,
|
|
|
+ spaceId: props.spaceId,
|
|
|
});
|
|
|
- const defaultProps = {
|
|
|
- children: "children",
|
|
|
- label: "label",
|
|
|
- value: "id",
|
|
|
- };
|
|
|
- const isOpen = ref(props.openForwardFile);
|
|
|
- watch(
|
|
|
- () => props.openForwardFile,
|
|
|
- (newValue) => {
|
|
|
- isOpen.value = newValue;
|
|
|
- }
|
|
|
- );
|
|
|
- const treeData = reactive({ data: [] });
|
|
|
- watchEffect(() => {
|
|
|
- treeData.data[0]=props.forwardTreeData
|
|
|
- console.log(treeData.data,'treeData.data')
|
|
|
- toRaw(treeData.data);
|
|
|
+ if (copyRes.code === 200) {
|
|
|
+ ElMessage({ message: "转存成功", type: "success" });
|
|
|
+ dirBulidNow.value = false;
|
|
|
+ }
|
|
|
+ isOpen.value = false;
|
|
|
+};
|
|
|
+//新建目录显示
|
|
|
+const clickId = ref("");
|
|
|
+const buildFile = async () => {
|
|
|
+ clickId.value = clickData.value.id;
|
|
|
+ if (!clickId.value) {
|
|
|
+ return ElMessage({ message: "请选中目录", type: "error" });
|
|
|
+ }
|
|
|
+ dirBulidNow.value = true;
|
|
|
+};
|
|
|
+//确认新建目录--点击勾选
|
|
|
+const sureDir = async () => {
|
|
|
+ const dirRes = await builtDir({
|
|
|
+ dirName: dirName.value,
|
|
|
+ spaceId: props.spaceId,
|
|
|
+ parentId: clickData.value.id,
|
|
|
});
|
|
|
-
|
|
|
- //树
|
|
|
- const clickData = ref({});
|
|
|
- const handleNodeClick = (data) => {
|
|
|
- clickData.value = data;
|
|
|
- };
|
|
|
- //确定按钮
|
|
|
- const emit = defineEmits(["forwardChangeMsg"]);
|
|
|
- const confirm = () => {
|
|
|
- const {disabled,label}=toRefs(clickData.value)
|
|
|
- if(disabled.value){
|
|
|
- return ElMessage({ message: '当前选中为目录,请重新选择文件', type: 'error' })
|
|
|
- }
|
|
|
- emit("forwardChangeMsg", clickData.value);
|
|
|
- isOpen.value = false
|
|
|
- };
|
|
|
- </script>
|
|
|
+ if (dirRes.code === 200) {
|
|
|
+ ElMessage({ message: "创建成功", type: "success" });
|
|
|
+ dirBulidNow.value = false;
|
|
|
+ clickId.value = "";
|
|
|
+ dirName.value = "";
|
|
|
+ //重新获取树结构
|
|
|
+ const resDir = await dirTree(3);
|
|
|
+ treeData.data[0] = resDir;
|
|
|
+ // treeRef.value.setCurrentKey(clickData.value.id)
|
|
|
+ }
|
|
|
+
|
|
|
+};
|
|
|
+</script>
|
|
|
<style lang="scss" scoped>
|
|
|
- @import "@/assets/styles/tree-common.scss";
|
|
|
- </style>
|
|
|
+@import "@/assets/styles/tree-common.scss";
|
|
|
+.sure-button,
|
|
|
+.cancel-button {
|
|
|
+ width: 120px;
|
|
|
+}
|
|
|
+.left-img {
|
|
|
+ width: 20px;
|
|
|
+ height: 20px;
|
|
|
+ margin-right: 5px;
|
|
|
+}
|
|
|
+.footer {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+}
|
|
|
+.title {
|
|
|
+ font-family: "Inter-Medium";
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+:deep .el-tree {
|
|
|
+ // margin-top: 4px;
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+.arrow-img {
|
|
|
+ margin-left: 5px;
|
|
|
+ width: 12px;
|
|
|
+ height: 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.build-file {
|
|
|
+ background: #f5f7f9;
|
|
|
+ padding: 3px 0;
|
|
|
+ margin: 4px 0;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .build-img {
|
|
|
+ margin-left: 24px;
|
|
|
+ }
|
|
|
+ .bulid-input {
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+ :deep .el-input {
|
|
|
+ width: 240px !important;
|
|
|
+ height: 29px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|