Browse Source

Merge branch 'space2'

master
han2015 15 hours ago
parent
commit
c73a2ecb00
  1. 15
      src/api/doc/index.ts
  2. 11
      src/api/doc/space.ts
  3. 4
      src/api/doc/type.ts
  4. 36
      src/views/doc/manage.vue
  5. 344
      src/views/doc/movepanel.vue
  6. 23
      src/views/doc/space.vue

15
src/api/doc/index.ts

@ -188,4 +188,19 @@ export function postMatterRename(uid:string,data?: {uuid:string;name:string}){
},
data: data
});
}
/**
*
*/
export function postMatterMove(uid:string,data?: {srcUuids:string;destUuid:string}){
return request({
url: '/hxpan/api/matter/move',
method: 'post',
headers: {
'Identifier':uid,
'Content-Type': 'application/x-www-form-urlencoded'
},
data: data
});
}

11
src/api/doc/space.ts

@ -119,6 +119,17 @@ export function doAiTraining(_url:string,data?: any){
data: data
});
}
//文档删除
export function doAiDocDels(_url:string,data?: any){
return request({
url: '/aibot'+_url,
method: 'post',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: data
});
}
export interface aiChatData{
inputs:object;

4
src/api/doc/type.ts

@ -15,6 +15,7 @@ export interface matterPage{
deleted?:boolean;
orderDir?:string;
name?:string;
dir?:string;// ‘true’ or ‘false’ 字符串,表示是否只查询文件夹或文件
space?:string;
orderCreateTime?:string;
}
@ -89,12 +90,13 @@ export interface respCreateShare{
/**
*
*/
export function doFileUpload(params:FormData,_url:string): AxiosPromise<matterInfo> {
export function doFileUpload(uid:string,params:FormData,_url:string): AxiosPromise<matterInfo> {
return request({
url: _url,
method: 'post',
data: params,
headers: {
'Identifier':uid,
'Content-Type': 'multipart/form-data'
}
});

36
src/views/doc/manage.vue

@ -7,7 +7,7 @@
import { getExpirTime, getFileIcon, readableSize,fileType} from "./tools"
import sharePermission from './sharePermission.vue';
import { useUserStore } from "@/store/modules/user";
import { getMatterList,postCreateDir,postDelMatter,postCreateShare,postMatterRename,
import { getMatterList,postCreateDir,postDelMatter,postCreateShare,postMatterRename,postMatterMove,
postDelMatBatch,getMySpaces,doCreateSpace,getRecyclingList} from "@/api/doc/index"
import { matterPage,matterInfo,respCreateShare,matterTree, doFileUpload,matterPermit} from "@/api/doc/type"
import { h } from 'vue'
@ -28,6 +28,7 @@ import SvgIcon from "@/components/SvgIcon/index.vue";
import {doDelSpace,doAccessManage,doCreateAiagent,setAgentQueryURL,getAgentQueryURL} from "@/api/doc/space"
import Space from "./space.vue";
import Logpanel from "./logpanel.vue";
import Movepanel from "./movepanel.vue";
//TODO: add file icons done!
//TODO: click on table-item 1preview on file .....................
@ -279,6 +280,30 @@ function onMatterRename(row:matterInfo){
})
}
//
function onMoveFile(row:matterInfo){
const dstuuid=ref(row.puuid)
ElMessageBox({
customStyle: { '--el-messagebox-width':'800px',padding:'40px'},
message:() => h(Movepanel,{
style: { width:'100%' },
modelValue: dstuuid.value,
'onUpdate:modelValue': (val) => {
dstuuid.value = val
},
}),
}).then(() => {
if(dstuuid.value!=row.puuid){
postMatterMove(uid,{
srcUuids:row.uuid,
destUuid:dstuuid.value as string,
}).then(()=>onLoadMatterList())
}else{
alert("目录相同不需要移动")
}
})
}
//
function onSearchFile(name?:string){
let _page: matterPage = {
@ -596,7 +621,7 @@ async function handleSingleFile(ff:File){
fields.append("puuid",uploadFormData.value.puuid)
fields.append("file",ff)
const res = await doFileUpload(fields,'/hxpan/api/matter/upload')
const res = await doFileUpload(uid,fields,'/hxpan/api/matter/upload')
if(res.code!=200){
console.log(ff.name+"上传失败! ")
throw new Error(ff.name+"上传失败!<br> ")
@ -661,7 +686,7 @@ async function handleFolderFile(option:File){
fields.append('file', option)
fields.append("space",uploadFormData.value.space)
fields.append("puuid",puuid)
const res = await doFileUpload(fields,'/hxpan/api/matter/upload')
const res = await doFileUpload(uid,fields,'/hxpan/api/matter/upload')
if(res.code!=200){
console.log(_path+"上传失败! ")
throw new Error(_path +" 上传失败!<br> ")
@ -1095,7 +1120,8 @@ const handleSelectionChange = (val:matterInfo[]) => {
<el-button size="small" :icon="Share" circle @click="onShareMatter(scope.row)"></el-button>
<el-button size="small" :icon="Download" circle @click="onDownload(scope.row)"></el-button>
<el-button size="small" :icon="Edit" circle @click="onlyOfficeEdit(scope.row)"></el-button>
<el-button size="small" :icon="Delete" circle @click="onDelMatter(scope.row)"></el-button>
<el-button size="small" circle @click="onMoveFile(scope.row)"></el-button>
<el-button size="small" :icon="Delete" circle @click="onDelMatter(scope.row)"></el-button>
<el-button size="small" circle @click="onMatterRename(scope.row)"></el-button>
</span>
</div>
@ -1133,6 +1159,7 @@ const handleSelectionChange = (val:matterInfo[]) => {
<li @click="onShareMatter(row)">分享</li>
<li @click="onDownload(row)">下载</li>
<li @click="onlyOfficeEdit(row)">编辑</li>
<li @click="onMoveFile(row)">移动</li>
<li @click="onDelMatter(row)">删除</li>
<li @click="onMatterRename(row)">重命名</li>
</span>
@ -1251,6 +1278,7 @@ const handleSelectionChange = (val:matterInfo[]) => {
display: flex;
flex-wrap: wrap; /* 关键属性,允许子元素自动换行 */
align-content: flex-start;
min-height: 500px;
.grid-item{
position: relative;
width: 134px;

344
src/views/doc/movepanel.vue

@ -0,0 +1,344 @@
<!--
@ 作者: han2015
@ 时间: 2025-05-12 15:39:13
@ 备注: 文档管理组件
-->
<script lang="ts" setup>
import { useUserStore } from "@/store/modules/user";
import { getMatterList,getMySpaces} from "@/api/doc/index"
import { matterPage,matterInfo,matterTree,matterPermit} from "@/api/doc/type"
import Space from "./space.vue";
import {ElSelect,ElOption, ElText,ElInput,ElTree,TreeNode,ElDropdown,ElDropdownItem} from "element-plus";
import { doAccessManage,getSpaceMatterList,doCreateSpaceDir,doDelSpaceMatter,
doAiTraining,doAiDocDels,spaceMatterRename} from "@/api/doc/space"
//
defineProps({
modelValue: String //
})
const emit = defineEmits(['update:modelValue'])
const userStore = useUserStore();
const uid=btoa("p0"+userStore.userInfoCont.userId);
const rawUid="p0"+userStore.userInfoCont.userId
const matterList = ref<matterInfo[]>([])
const treeData=ref<matterTree[]>([])//{name:'',uuid:'root',children:[]}
const currentNode=ref<matterTree>({}) //
const paginInfo = ref({ page: 0, total: 0 })
const SpaceID= ref<{name:string,uuid:string,userUuid:string,manager:boolean,permits:matterPermit}>({}) //spaceid
const spaceEleRef = ref() //space,spaceTreeRefspaceTree
const spaceTreeRef = ref(); //space
let spaceNodeUid="" //currentNode
let isNewSpaceNode=true //
const spaceCutLevelPermit=ref(0)
const Departs = computed(() => {
return `${'p0'+userStore.userInfoCont.userId},${userStore.userInfoCont.company},${userStore.userInfoCont.department},${userStore.userInfoCont.organization}`
})
enum PERMITS {
FORBID, //0
VIEW, //1
DOWNLOAD, //2
UPLOAD, //3
UPANDDOWNLOAD, //4
EDIT, //5
MANAGER, //6
}
//
function onLoadMatterList(){
emit('update:modelValue', currentNode.value.uuid)
let _page: matterPage = {
page: paginInfo.value.page,
pageSize: 50,
orderCreateTime: "DESC",
orderDir: "DESC",
dir:"true",
puuid:currentNode.value.uuid,
deleted:false
};
getMatterList(uid,_page).then((resp)=>{
//page+1 index1apiindex0
paginInfo.value={total:resp.data.totalPages,page:resp.data.page}
matterList.value=resp.data.data
})
}
//
function onNodeExpand(node: TreeNode, resolve: (data: matterTree[]) => void, reject: () => void) {
let cuuid ="root"
if ((node.data as matterTree).uuid) {
cuuid= (node.data as matterTree).uuid
currentNode.value = node.data
}
let _page: matterPage = {
page: 0,
pageSize: 50,
orderCreateTime: "DESC",
orderDir: "DESC",
dir:"true",
puuid: cuuid,
deleted: false
};
getMatterList(uid, _page).then((resp) => {
let node_data = resp.data.data.filter((item) => {
return item.dir
}).map((val) => {
const copy = structuredClone(val)
copy.dir = !copy.dir
return copy
})
resolve(node_data)
}).catch(() => reject())
emit('update:modelValue', currentNode.value.uuid)
}
//
function onNodeClick(data:matterTree,node:TreeNode,self:any,env:any){
if (data){
if (currentNode.value.uuid === data.uuid) return;
currentNode.value = data
}else{
currentNode.value={uuid:"root",name:"个人空间"}
}
onLoadMatterList()
}
//-------------------space feature---------------------
function onSpaceNodeClick(data:matterTree,node:TreeNode,self:any,env:any){
//
if(spaceNodeUid==data.uuid) return;
spaceNodeUid=data.uuid
if(data.uuid.startsWith("s0") && data.uuid!=SpaceID.value.uuid){ //
currentNode.value={uuid:"root",name:data.name}//currentNode
SpaceID.value={
name: data.name ?? "",
uuid: data.uuid ?? "",
userUuid: data.userUuid ?? "",
manager: data.manager ?? false,
permits:data.permits ?? { id: 0, MatterUuid: '', data: '{}' }
};
onSpaceMatterList()
}else{
let matter= {
uuid:data.uuid==SpaceID.value.uuid?"root":data.uuid,
puuid: data.puuid,
name:data.name,
agent:data.agent,
dir:true,
permits:data.permits,
path:data.path,
permitVal:data.permitVal
}
//
handleSpaceDoubleClick(matter)
}
}
function flushSpaceTree(uuid:string,data:matterTree[]){
if(uuid==="root") uuid=SpaceID.value.uuid
spaceTreeRef.value.updateKeyChildren(uuid,data)
}
function handleSpaceDoubleClick(row:matterInfo,ind?:number){
if(row.dir){
//
if(row.permitVal){
spaceCutLevelPermit.value=row.permitVal
}else{
if (SpaceID.value.manager) {
spaceCutLevelPermit.value=9
}else{
let _pert: Record<string, number>
_pert = JSON.parse(row.permits!.data)
let val=_pert[rawUid.replace("p0","")]
if(val){
spaceCutLevelPermit.value = val
}else{
spaceCutLevelPermit.value = PERMITS.FORBID //
}
}
}
isNewSpaceNode=true
//1
//2:
if(currentNode.value.puuid==row.uuid || row.uuid=="root") isNewSpaceNode=false
currentNode.value=row
onSpaceMatterList()
}
}
//
function onSpaceMatterList(){
emit('update:modelValue', currentNode.value.uuid)
let _page: matterPage= {
page: paginInfo.value.page,
pageSize: 50,
orderCreateTime: "DESC",
orderDir: "DESC",
puuid:currentNode.value.uuid,
dir:"true",
deleted:false,
space:SpaceID.value.uuid,
};
getSpaceMatterList(uid,_page).then((resp)=>{
if (SpaceID.value.manager) {
resp.data.data.forEach(item => {
item.permitVal=PERMITS.MANAGER
})
matterList.value=resp.data.data
}else{
matterList.value=resp.data.data.filter(item=>{ //
if(item.permits.ID==0){
item.permitVal=spaceCutLevelPermit.value
}else{
//
let _pert: Record<string, number>
_pert = JSON.parse(item.permits!.data)
let val=_pert[rawUid.replace("p0","")]
if(val){
item.permitVal = val
}else{
item.permitVal = PERMITS.FORBID //
}
}
if(item.permitVal>0){
return true
}
return false
})
}
//使
let node_data = matterList.value.filter(item=> {
return item.dir
}).map(val => {
const copy = structuredClone(toRaw(val))
copy.dir = !copy.dir
copy.manager=SpaceID.value.manager
return copy
})
if(isNewSpaceNode) {
//uuidrootspaceiduuid
//rootuuidspaceidroot
if(currentNode.value.uuid=="root") flushSpaceTree(SpaceID.value.uuid,node_data);
else flushSpaceTree(currentNode.value.uuid,node_data);
}
})
}
///////////////////////////////////////////////////////
//
onMounted(async () => {
currentNode.value={uuid:"root",name:"个人空间"}
//
await getMySpaces(uid,{roles:Departs.value}).then((resp)=>{
resp.data.forEach((item)=>{
let ismanager=false
if(item.userUuid==rawUid || item.managers.includes(rawUid)) ismanager=true;
spaceTreeRef.value.append({name:item.name,uuid:item.uuid,dir:false,userUuid:item.userUuid,manager:ismanager,permits:item.permits})
})
})
emit('update:modelValue', currentNode.value.uuid)
});
</script>
<template>
<p> <span style="font-size:20px;font-weight: bold;">请选择目标节点</span> 当前节点 > {{ currentNode.name }}</p>
<div class="menus_tree">
<div class="area_header">
<el-icon :size="20"><House /></el-icon><span class="area_name" > </span>
</div>
<el-tree
ref="treeRef"
style="max-width: 600px"
:data="treeData"
node-key="uuid"
highlight-current
lazy
:load="onNodeExpand"
:props="{label: 'name',children:'children',isLeaf:'dir'}"
:default-expanded-keys="['root']"
@node-click="onNodeClick"
>
<template #default="{ node, data }">
<div class="tree-item">
<span>{{ node.label }}</span>
</div>
</template>
</el-tree>
<div class="area_header">
<el-icon :size="20"><Collection /></el-icon> <span class="area_name" > </span>
</div>
<el-tree
ref="spaceTreeRef"
style="max-width: 600px"
node-key="uuid"
accordion
highlight-current
lazy
:props="{label: 'name',children:'children',isLeaf:'dir'}"
@node-click="onSpaceNodeClick"
>
<template #default="{ node, data }">
<div class="tree-item">
<span>{{ node.label}}</span>
</div>
</template>
</el-tree>
</div>
</template>
<style lang="scss" scoped>
.menus_tree{
display: flex;
flex-direction: column;
height:550px;
overflow-y: scroll;
.el-tree{
--el-color-primary-light-9:#6eb3f8;
--el-tree-node-hover-bg-color:#a1c7ee;
--el-tree-node-content-height:43px;
--el-tree-expand-icon-color:#4c4c4e;
}
}
.area_header{
display: flex;
margin-top: 9px;
padding: 5px 0;
background-color: white;
align-items: center;
.area_name{
align-content: center;
margin-left: 8px;
color: #686854;
font-weight: bold;
}
}
</style>
<style lang="scss">
.el-message-box__message{
width: 100%;
}
</style>

23
src/views/doc/space.vue

@ -10,7 +10,7 @@ import sharePermission from './sharePermission.vue';
import spacePermission from './spacePermission.vue';
import { matterPage,matterInfo,matterTree,doFileUpload,matterPermit} from "@/api/doc/type"
import { doAccessManage,getSpaceMatterList,doCreateSpaceDir,doDelSpaceMatter,
doAiTraining ,spaceMatterRename} from "@/api/doc/space"
doAiTraining,doAiDocDels,spaceMatterRename} from "@/api/doc/space"
import { h } from 'vue'
import {
Delete,
@ -159,6 +159,7 @@ function onDelMatter(row:matterInfo){
currentNode.value.uuid = row.puuid ?? ""
onLoadMatterList()
})
handleAiDelete(row)
})
}
}
@ -412,7 +413,7 @@ async function handleSingleFile(ff:File){
fields.append("puuid",uploadFormData.value.puuid)
fields.append("file",ff)
const res = await doFileUpload(fields,'/hxpan/api/space/upload')
const res = await doFileUpload(props.uid,fields,'/hxpan/api/space/upload')
if(res.code!=200){
console.log(ff.name+"上传失败! ")
throw new Error(ff.name+"上传失败!<br> ")
@ -478,7 +479,7 @@ async function handleFolderFile(option:File){
fields.append('file', option)
fields.append("space",uploadFormData.value.space)
fields.append("puuid",puuid)
const res = await doFileUpload(fields,'/hxpan/api/space/upload')
const res = await doFileUpload(props.uid,fields,'/hxpan/api/space/upload')
if(res.code!=200){
console.log(_path+"上传失败! ")
throw new Error(_path+"上传失败!<br> ")
@ -530,6 +531,22 @@ function handleAiUpload(info:matterInfo){
}
}
function handleAiDelete(info:matterInfo){
//
if (info.path?.startsWith(currentAgent.value.path)){
doAiDocDels(`/agents/${currentAgent.value.uuid}/deldoc`,{
"name":info.name,
"path":info.path,
}).then(resp=>{
ElMessage({
message: '已成功删除',
type: 'error',
plain: true,
})
})
}
}
//-------------------------------------------------
//-------------------edit & preive file for space---------------------

Loading…
Cancel
Save