质量管理/安全知识库

This commit is contained in:
Teo
2025-06-27 18:35:48 +08:00
parent 5ca5b5197d
commit 1f03b453b4
16 changed files with 1619 additions and 680 deletions

View File

@ -209,6 +209,8 @@
<div class="load_title">正在加载系统资源,请耐心等待</div>
</div>
</div>
<script type="text/javascript"
src="http://zmkg.cqet.top:8899/changxieoffice/web-apps/apps/api/documents/api.js"></script>
<script src="./src/assets/sdk/YJEarth.min.js"></script>
<script src="./src/utils/reconnecting-websocket.js"></script>
<script type="module" src="/src/main.ts"></script>

View File

@ -37,7 +37,7 @@
"element-plus": "2.8.8",
"esbuild": "^0.25.0",
"ezuikit-js": "^8.1.10",
"file-saver": "2.0.5",
"file-saver": "^2.0.5",
"fuse.js": "7.0.0",
"gcoord": "^1.0.7",
"geotiff": "^2.1.3",

View File

@ -1,6 +1,7 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { KnowledgeDocumentVO, KnowledgeDocumentForm, KnowledgeDocumentQuery } from '@/api/quality/knowledgeDocument/types';
import { KnowledgeDocumentPutFileNameQuery } from '@/api/safety/knowledgeDocument/types';
/**
* 查询质量知识库列表
@ -10,7 +11,7 @@ import { KnowledgeDocumentVO, KnowledgeDocumentForm, KnowledgeDocumentQuery } fr
export const listKnowledgeDocument = (query?: KnowledgeDocumentQuery): AxiosPromise<KnowledgeDocumentVO[]> => {
return request({
url: '/quality/knowledgeDocument/list',
url: '/quality/knowledgeDocument/file/page',
method: 'get',
params: query
});
@ -31,9 +32,9 @@ export const getKnowledgeDocument = (id: string | number): AxiosPromise<Knowledg
* 新增质量知识库
* @param data
*/
export const addKnowledgeDocument = (data: KnowledgeDocumentForm) => {
export const addKnowledgeDocument = (data: { file: string }, query: { projectId: string; pid: string }) => {
return request({
url: '/quality/knowledgeDocument',
url: '/quality/knowledgeDocument/file',
method: 'post',
data: data
});
@ -57,7 +58,7 @@ export const updateKnowledgeDocument = (data: KnowledgeDocumentForm) => {
*/
export const delKnowledgeDocument = (id: string | number | Array<string | number>) => {
return request({
url: '/quality/knowledgeDocument/' + id,
url: '/quality/knowledgeDocument/file/' + id,
method: 'delete'
});
};
@ -74,6 +75,57 @@ export const treeStructureData = (projectId: string | number): AxiosPromise<Know
});
};
export const uniFolderDownload = (data: any): AxiosPromise<KnowledgeDocumentVO> => {
/**
* 修改安全知识库
* @param data
*/
export const documentDataEdit = (data: KnowledgeDocumentPutFileNameQuery) => {
return request({
url: '/quality/knowledgeDocument/file',
method: 'put',
data: data
});
};
//查询质量知识库文件下载列表
export const getUniFolderDownloadList = (id: string): AxiosPromise<KnowledgeDocumentVO> => {
return request({
url: '/quality/knowledgeDocument/file/list/' + id,
method: 'get'
});
};
//查询安全知识库回收站文件列表
export const documentDataAllList = (query: any) => {
return request({
url: '/quality/knowledgeDocument/recycleBin/list',
method: 'get',
params: query
});
};
/**
* 根据主键id批量恢复
* @param data
*/
export const dataRecyclingStation = (ids: string) => {
return request({
url: '/quality/knowledgeDocument/recovery/' + ids,
method: 'post'
});
};
/**
* 根据主键id批量删除
* @param data
*/
export const templateRecycleBin = (ids: string) => {
return request({
url: '/quality/knowledgeDocument/file/recycleBin/' + ids,
method: 'delete'
});
};
export const getProfileDetail = (data: any): AxiosPromise<KnowledgeDocumentVO> => {
return request({});
};

View File

@ -13,9 +13,9 @@ import {
* @returns {*}
*/
export const listKnowledgeDocument = (query?: KnowledgeDocumentQuery): AxiosPromise<KnowledgeDocumentVO[]> => {
export const listKnowledgeDocument = (query?: any): AxiosPromise<KnowledgeDocumentVO[]> => {
return request({
url: '/safety/knowledgeDocument/file/list',
url: '/safety/knowledgeDocument/file/page',
method: 'get',
params: query
});
@ -92,8 +92,43 @@ export const documentDataEdit = (data: KnowledgeDocumentPutFileNameQuery) => {
});
};
export const uniFolderDownload = (data: any): AxiosPromise<KnowledgeDocumentVO> => {
return request({});
//查询质量知识库文件下载列表
export const getUniFolderDownloadList = (id: string): AxiosPromise<KnowledgeDocumentVO> => {
return request({
url: '/safety/knowledgeDocument/file/list/' + id,
method: 'get'
});
};
//查询安全知识库回收站文件列表
export const documentDataAllList = (query: any) => {
return request({
url: '/safety/knowledgeDocument/recycleBin/list',
method: 'get',
params: query
});
};
/**
* 根据主键id批量恢复
* @param data
*/
export const dataRecyclingStation = (ids: string) => {
return request({
url: '/safety/knowledgeDocument/recovery/' + ids,
method: 'post'
});
};
/**
* 根据主键id批量删除
* @param data
*/
export const templateRecycleBin = (ids: string) => {
return request({
url: '/safety/knowledgeDocument/file/recycleBin/' + ids,
method: 'delete'
});
};
export const getProfileDetail = (data: any): AxiosPromise<KnowledgeDocumentVO> => {

View File

@ -163,7 +163,7 @@ aside {
}
.pagination-container {
margin-top: 30px;
margin-top: 15px;
}
.text-center {

View File

@ -67,7 +67,7 @@
<el-icon class="mr"><View /></el-icon>
</a>
<a href="#">
<el-icon @click="handleDelete(file.ossId, 'ossId')"><Delete /></el-icon>
<el-icon @click="handleDelete((file as any).ossId, 'ossId')"><Delete /></el-icon>
</a>
</div>
</div>
@ -147,7 +147,7 @@ watch(
if (Array.isArray(val)) {
list = val;
} else {
const res = await listByIds(val);
const res = await listByIds(val as any);
list = res.data.map((oss) => {
return {
name: oss.originalName,
@ -211,7 +211,11 @@ const handleUploadError = () => {
};
// 上传成功回调
const handleUploadSuccess = (res: any, file: UploadFile) => {
interface UploadFileWithOssId extends UploadFile {
ossId?: string;
}
const handleUploadSuccess = (res: any, file: UploadFileWithOssId) => {
if (res.code === 200) {
if (res.data) {
uploadList.value.push({

View File

@ -30,7 +30,7 @@ const props = defineProps({
page: propTypes.number.def(1),
limit: propTypes.number.def(20),
pageSizes: {
type: Array,
type: Array<number>,
default: () => [10, 20, 30, 50]
},
// 移动端页码按钮的数量端默认值5

View File

@ -1,5 +1,6 @@
import axios from 'axios';
import FileSaver from 'file-saver';
import JSZip from 'jszip';
import errorCode from '@/utils/errorCode';
import { blobValidate } from '@/utils/ruoyi';
import { LoadingInstance } from 'element-plus/es/components/loading/src/loading';
@ -80,5 +81,49 @@ export default {
} finally {
downloadLoadingInstance.close();
}
},
/**
* 下载多个文件并打包成 zip
* @param files 文件信息列表,包含 { url, name }
* @param zipName 压缩包名称
*/
async downloadFilesAsZip(
files: any[],
options: {
urlKey?: string; // 默认为 'url'
nameKey?: string; // 默认为 'name'
zipName?: string; // 默认为 '打包下载.zip'
} = {}
) {
const { urlKey = 'url', nameKey = 'name', zipName = '打包下载.zip' } = options;
if (!files.length) {
ElMessage.warning('没有可下载的文件');
return;
}
const zip = new JSZip();
const folder = zip.folder('files');
const loading = ElLoading.service({ text: '正在打包文件,请稍候...', background: 'rgba(0,0,0,0.7)' });
try {
for (const file of files) {
const fileUrl = file[urlKey];
const fileName = file[nameKey] || '未命名文件';
if (!fileUrl) continue;
const res = await axios.get(fileUrl, { responseType: 'blob' });
folder?.file(fileName, res.data);
}
const content = await zip.generateAsync({ type: 'blob' });
FileSaver.saveAs(content, zipName);
} catch (error) {
console.error(error);
ElMessage.error('打包下载失败,请联系管理员');
} finally {
loading.close();
}
}
};

View File

@ -0,0 +1,154 @@
<template>
<div class="book_file">
<!-- 添加或修改公司对话框 -->
<el-dialog v-model="isShowDialog" width="80vw" custom-class="book_file_loading" :close-on-click-modal="false" :destroy-on-close="true">
<template #header>
<div v-drag="['.book_file .el-dialog', '.book_file .el-dialog__header']">查看资料文件</div>
</template>
<el-form ref="queryRef" :inline="true" label-width="100px">
<el-row>
<el-col :span="8" class="colBlock">
<el-form-item label="文件名称" prop="fileName">
<el-input v-model="formData.fileName" placeholder="请输入文件名称搜索" clearable @keyup.enter.native="getDataFileQuery" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item>
<el-button type="primary" @click="getDataFileQuery">
<el-icon><Search /></el-icon>搜索
</el-button>
<el-button @click="resetQuery" type="danger">
<el-icon><Refresh /></el-icon>清空
</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="content">
<div class="left_box" :style="treeList.length ? 'width: 70%' : 'width: 100%'">
<el-table v-loading="loading" :data="tableData" border height="63vh" :empty-text="emptyText">
<el-table-column label="序号" align="center" type="index" width="80px" />
<el-table-column label="文件名称" align="center" prop="fileName" min-width="100px" />
<el-table-column label="文件路径" align="center" min-width="100px">
<template #default="scope">
<span>{{ filterfilenPath(scope.row.filePath) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding" width="250px" fixed="right">
<template #default="scope">
<el-button type="success" link @click="onExport(scope.row)">
<el-icon><Download /></el-icon>下载
</el-button>
<el-button type="primary" link @click="onBook(scope.row)">
<el-icon><View /></el-icon>查看
</el-button>
</template>
</el-table-column>
</el-table>
<pagination :total="tableData.length" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getDataFileQuery" />
</div>
</div>
</el-dialog>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive, getCurrentInstance, nextTick } from 'vue';
import { listKnowledgeDocument, getProfileDetail } from '@/api/quality/knowledgeDocument';
import { useUserStoreHook } from '@/store/modules/user';
const emit = defineEmits(['onExport', 'onExportView']);
const stores = useUserStoreHook();
const { proxy } = getCurrentInstance() as any;
const documentDetailRef = ref();
const allTreeRef = ref();
const baseURL: string | undefined | boolean = import.meta.env.VITE_API_URL;
const loading = ref(false);
const tableData = ref<any[]>([]);
const isShowDialog = ref(false);
const formData = reactive({ fileName: '', projectId: stores.selectedProject.id });
const projectList = ref<any[]>([]);
const projectQuery = reactive({ name: '' });
const pageNum = ref(1);
const pageSize = ref(10);
const total = ref(0);
const showDocumentDetail = ref(false);
const emptyText = ref('暂无数据');
const treeList = ref<any[]>([]);
const arrayList = ref<any[]>([]);
const infoMap = ref(new Map());
const infoList = ref<any[]>([]);
const paramsQuery = reactive({ idStr: '', project: '' });
const openDialog = () => {
isShowDialog.value = true;
getDataFileQuery();
emptyText.value = '请输入文件名称进行搜索!';
resetForm();
};
const resetForm = () => {
tableData.value = [];
formData.fileName = '';
treeList.value = [];
emptyText.value = '暂无数据';
};
const getDataFileQuery = () => {
loading.value = true;
emptyText.value = '数据加载中……';
listKnowledgeDocument(formData).then((res: any) => {
loading.value = false;
tableData.value = [];
if (res.code == 200 && res.rows?.length) {
tableData.value = res.rows;
total.value = res.rows.length;
} else {
emptyText.value = '没有查询到数据,请重新输入搜索';
}
});
};
const onBook = (row: any) => {
return;
getProfileDetail(row.id).then((res: any) => {
if (res.code == 200) {
showDocumentDetail.value = true;
nextTick(() => {
documentDetailRef.value.openDialog(res.data);
});
}
});
};
const onExport = (row: any) => {
emit('onExportView', row);
};
const resetQuery = () => {
tableData.value = [];
formData.fileName = '';
loading.value = false;
emptyText.value = '暂无数据';
};
const filterfilenPath = (val: string): string => {
return val.replace(/^.*?知识库\//, '知识库/');
};
defineExpose({ openDialog });
</script>
<style scoped lang="scss">
.book_file {
.content {
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}
}
</style>

View File

@ -0,0 +1,161 @@
<template>
<div class="system-document-container">
<el-card shadow="hover">
<div class="system-document-search mb-5">
<el-form :model="param" ref="queryRef" :inline="true" label-width="100px">
<el-row>
<el-col :span="2">
<el-button
type="success"
v-auth="'/zm/api/v1/system/document/templateRecycleBin'"
:disabled="multiple"
@click="onRecyclingStation(null, true)"
>
<el-icon><RefreshRight /></el-icon>批量恢复
</el-button>
</el-col>
<el-col :span="2">
<el-button
type="danger"
v-auth="'/zm/api/v1/system/document/templateRecycleBin'"
:disabled="multiple"
@click="onRecyclingStation(null, false)"
>
<el-icon><DeleteFilled /></el-icon>批量删除
</el-button>
</el-col>
</el-row>
</el-form>
</div>
<el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" type="index" min-width="30px" />
<el-table-column label="文件名称" align="center" prop="fileName" min-width="100px" />
<el-table-column label="文件路径" align="center" min-width="100px">
<template #default="scope">
<span>{{ filterfilenPath(scope.row.filePath) }}</span>
</template>
</el-table-column>
<el-table-column label="删除时间" align="center" prop="createTime" min-width="100px" />
<el-table-column label="操作" align="center" class-name="small-padding" min-width="80px" fixed="right">
<template #default="scope">
<div>
<el-button type="success" v-auth="'/zm/api/v1/system/document/templateRecycleBin'" link @click="onRecyclingStation(scope.row, true)">
<el-icon><RefreshRight /></el-icon>恢复
</el-button>
</div>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="param.pageNum" v-model:limit="param.pageSize" @pagination="getDocumentDataList" />
</el-card>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive, getCurrentInstance, computed } from 'vue';
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus';
import { documentDataAllList, templateRecycleBin, dataRecyclingStation } from '@/api/quality/knowledgeDocument';
import { useUserStoreHook } from '@/store/modules/user';
const proxy = getCurrentInstance()?.proxy as any;
const userStore = useUserStoreHook();
const currentProject = computed(() => userStore.selectedProject);
const loading = ref(false);
const queryRef = ref();
const multiple = ref(true);
const ids = ref<string>('');
const tableData = ref<any[]>([]);
const param = reactive({
type: 2,
projectId: currentProject.value.id,
pageNum: 1,
pageSize: 10
});
const total = ref(0);
const value = ref('2');
const getDocumentDataList = () => {
loading.value = true;
tableData.value = [];
value.value = '2';
documentDataAllList(param).then((res: any) => {
tableData.value = res.rows ?? [];
total.value = res.total;
loading.value = false;
});
};
const handleSelectionChange = (selection: any[]) => {
ids.value = selection.map((item) => item.id).join(',');
multiple.value = !selection.length;
};
const onRecyclingStation = (row: any, flag: boolean) => {
let type = 2;
let selectedIds: string = '';
let title = '删除';
let msg = '你确定要删除所选文件或文件夹?';
if (row) {
selectedIds = row.id;
} else {
selectedIds = ids.value;
}
if (flag) {
type = 1;
title = '恢复';
msg = '你确定要恢复所选文件或文件夹?';
}
ElMessageBox.confirm(msg, '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
const loadingInstance = ElLoading.service({
lock: true,
text: `正在${title}中……`,
background: 'rgba(0, 0, 0, 0.7)'
});
if (flag) {
dataRecyclingStation(selectedIds).then((res) => {
loadingInstance.close();
if (res.code == 200) {
getDocumentDataList();
ElMessage.success('操作成功');
}
});
} else {
templateRecycleBin(selectedIds).then((res) => {
loadingInstance.close();
if (res.code == 200) {
getDocumentDataList();
ElMessage.success('操作成功');
}
});
}
})
.catch(() => {});
};
const filterfilenPath = (val: string): string => {
return val.replace(/^.*?知识库\//, '知识库/');
};
defineExpose({
getDocumentDataList
});
</script>
<style lang="scss" scoped>
.colBlock {
display: block;
}
.colNone {
display: none;
}
</style>

View File

@ -1,153 +1,138 @@
<template>
<div class="profile_engin">
<div class="box_info">
<div class="tree_left1" id="tree_left1">
<div class="check_select">
<el-button type="primary" v-auth="'/zm/api/v1/system/documentData/newFolder'" @click="addFile"
><el-icon><ele-Plus /></el-icon>新建文件夹</el-button
>
<div class="box_btn" v-auth="'/zm/api/v1/system/documentData/add'">
<span>导入</span>
<div class="btn">
<el-button type="primary" style="float: left" @click="state.bigUploadFile1"
><el-icon><ele-Plus /></el-icon>导入压缩文件</el-button
<el-tabs v-model="activeName" class="demo-tabs p5" @tab-click="handleCheckMian">
<el-tab-pane label="资料" name="first">
<div class="profile_engin">
<div class="box_info">
<div class="tree_left1" id="tree_left1">
<div class="file_upload check_select">
<div class="box_btn" v-auth="'/zm/api/v1/system/documentData/add'">
<file-upload
v-model="state.paramsQuery.file"
:limit="100"
:uploadUrl="uploadUrl"
:params="uploadParams"
:on-upload-success="uploadFile"
>
<el-button type="primary" style="float: left" :disabled="!state.parentPid">
<el-icon size="small"><Plus /></el-icon>上传文件
</el-button>
</file-upload>
</div>
<el-button
type="primary"
v-auth="'/zm/api/v1/system/documentProject/dataCompressedDownload'"
:disabled="!state.parentPid"
@click="onExport"
><el-icon><Download /></el-icon>下载</el-button
>
<el-button type="primary" style="float: left" :disabled="!state.parentPid" @click="uploadFile(2)"
><el-icon><ele-Plus /></el-icon>导入文件</el-button
<el-button type="primary" @click="onBook" v-auth="'/zm/api/v1/system/documentData/dataFileQuery'"
><el-icon><View /></el-icon>查看全项目文件</el-button
>
</div>
<div class="file_upload check_select">
<el-input class="input_left" v-model="filterText" size="small" placeholder="请输入文件名称" />
</div>
<el-tree
ref="treeRef"
highlight-current
:default-expand-all="state.checked"
:filter-node-method="filterFolder"
:data="state.treeList"
node-key="id"
accordion
:expand-on-click-node="false"
@node-click="handleNodeClick"
:current-node-key="state.selectedNodeId"
>
<template #default="{ node, data }">
<span class="custom-tree-node">
<el-icon color="#f1a81a"><FolderOpened /></el-icon>
<span>{{ node.label }}</span>
</span>
</template>
</el-tree>
<div class="resize-handle resize-handle-right right"></div>
</div>
</div>
<div class="file_upload check_select">
<el-checkbox v-model="state.checked" @change="handleCheckedTreeExpand($event)" label="展开/折叠" size="large" />
<div style="margin: 0 10px">
<el-select v-model="state.paramsQuery.switch" placeholder="当前文件夹" size="small">
<el-option v-for="item in state.options" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
</div>
<el-button type="primary" v-auth="'/zm/api/v1/system/documentProject/dataCompressedDownload'" :disabled="!state.parentPid" @click="onExport"
><el-icon><ele-Download /></el-icon>下载</el-button
>
<el-button type="primary" @click="onBook" v-auth="'/zm/api/v1/system/documentData/dataFileQuery'"
><el-icon><ele-View /></el-icon>查看全项目文件</el-button
>
</div>
<div class="file_upload check_select">
<el-input class="input_left" v-model="filterText" size="small" placeholder="请输入文件名称" />
</div>
<el-tree
ref="treeRef"
highlight-current
:default-expand-all="state.checked"
:filter-node-method="filterFolder"
:data="state.treeList"
:props="state.Props"
node-key="id"
accordion
:draggable="state.draggableCheck"
:expand-on-click-node="false"
@node-click="handleNodeClick"
:current-node-key="state.selectedNodeId"
@node-drop="handleDragEnd"
:allow-drop="allowDrop"
>
<template #default="{ node, data }">
<span class="custom-tree-node">
<el-icon color="#f1a81a"><ele-FolderOpened /></el-icon>
<span>{{ node.label }}</span>
<span style="margin-left: 20px" class="set-tool">
<el-button type="primary" v-auth="'/zm/api/v1/system/documentData/onlineImport'" link @click.stop="uploadOnlineFile(node, data)"
>在线模板复制</el-button
>
<el-button type="success" v-auth="'/zm/api/v1/system/documentData/edit'" link @click.stop="onUpdateName(node, data)"
>重命名</el-button
>
<el-button type="danger" v-auth="'/zm/api/v1/system/documentData/delete'" link @click.stop="onRemove(node, data)">删除</el-button>
</span>
</span>
</template>
</el-tree>
<div class="resize-handle resize-handle-right right"></div>
</div>
<div class="list_right" id="list_right1">
<div>
<el-form :model="state.paramsQuery" ref="queryRef" :inline="true" label-width="100px">
<el-row>
<el-col :span="6" class="colBlock">
<el-form-item label="文件名称" prop="name">
<el-input v-model="state.paramsQuery.name" placeholder="请输入文件名称" clearable @keyup.enter.native="getdocumentDataList" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" @click="searchInfo"
><el-icon><ele-Search /></el-icon>搜索</el-button
>
<el-button @click="resetQuery"
><el-icon><ele-Refresh /></el-icon>重置</el-button
>
</el-form-item>
</el-col>
<!-- <el-col :span="4">
<div class="list_right" id="list_right1">
<div>
<el-form :model="state.paramsQuery" ref="queryRef" :inline="true" label-width="100px">
<el-row>
<el-col :span="7" class="colBlock">
<el-form-item label="文件名称" prop="fileName">
<el-input
v-model="state.paramsQuery.fileName"
placeholder="请输入文件名称"
clearable
@keyup.enter.native="getdocumentDataList"
/>
</el-form-item>
</el-col>
<el-col :span="6" class="m-l10">
<el-form-item>
<el-button type="primary" @click="searchInfo"
><el-icon><Search /></el-icon>搜索</el-button
>
<el-button @click="resetQuery"
><el-icon><Refresh /></el-icon>重置</el-button
>
</el-form-item>
</el-col>
<!-- <el-col :span="4">
<el-button type="primary" v-auth="'/zm/api/v1/system/documentData/add'" :disabled="!parentPid" @click="uploadFile(2)"
><el-icon><ele-Plus /></el-icon>导入本地文件</el-button
><el-icon><Plus /></el-icon>导入本地文件</el-button
>
</el-col> -->
<!-- <el-col :span="4">
<!-- <el-col :span="4">
<el-button type="primary" @click="onMoveFile"
><el-icon><ele-Plus /></el-icon>移动</el-button
><el-icon><Plus /></el-icon>移动</el-button
>
</el-col> -->
</el-row>
</el-form>
</el-row>
</el-form>
</div>
<el-table v-loading="state.loading" :data="state.infoList" height="67vh" border>
<el-table-column label="序号" align="center" type="index" min-width="50px" />
<el-table-column label="文件名称" align="center" prop="fileName"></el-table-column>
<el-table-column label="上传时间" align="center" prop="createdAt"> </el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
type="primary"
v-auth="'/zm/api/v1/system/documentData/get'"
v-if="state.acceptType.includes(scope.row.suffix)"
link
@click="handleView(scope.row)"
><el-icon><View /></el-icon>查看</el-button
>
<el-button
type="primary"
v-auth="'/zm/api/v1/system/documentData/complaintBoxAdd'"
v-if="state.acceptType.includes(scope.row.suffix)"
link
@click="updataView(scope.row)"
><el-icon><EditPen /></el-icon>修改文件</el-button
>
<el-button type="primary" v-auth="'/zm/api/v1/system/documentData/uniFolderDownload'" link @click="onExportView(scope.row)"
><el-icon><Download /></el-icon>下载</el-button
>
<el-button type="success" v-auth="'/zm/api/v1/system/documentData/edit'" link @click="updateName(scope.row)"
><el-icon><EditPen /></el-icon>修改名称</el-button
>
<el-button type="danger" v-auth="'/zm/api/v1/system/documentData/delete'" link @click="handleDelete(scope.row)"
><el-icon><DeleteFilled /></el-icon>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
:total="state.total"
v-model:page="state.paramsQuery.pageNum"
v-model:limit="state.paramsQuery.pageSize"
@pagination="getdocumentDataList"
/>
</div>
</div>
<el-table v-loading="state.loading" :data="state.infoList" height="67vh" border>
<el-table-column label="序号" align="center" type="index" min-width="50px" />
<el-table-column label="文件名称" align="center" prop="name">
<template #default="scope">
<span>{{ scope.row.name + scope.row.suffix }}</span>
</template>
</el-table-column>
<el-table-column label="上传时间" align="center" prop="createdAt"> </el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
type="primary"
v-auth="'/zm/api/v1/system/documentData/get'"
v-if="state.acceptType.includes(scope.row.suffix)"
link
@click="handleView(scope.row)"
><el-icon><ele-View /></el-icon>查看</el-button
>
<el-button
type="primary"
v-auth="'/zm/api/v1/system/documentData/complaintBoxAdd'"
v-if="state.acceptType.includes(scope.row.suffix)"
link
@click="updataView(scope.row)"
><el-icon><ele-EditPen /></el-icon>修改文件</el-button
>
<el-button type="primary" v-auth="'/zm/api/v1/system/documentData/uniFolderDownload'" link @click="onExportView(scope.row)"
><el-icon><ele-Download /></el-icon>下载</el-button
>
<el-button type="success" v-auth="'/zm/api/v1/system/documentData/edit'" link @click="updateName(scope.row)"
><el-icon><ele-EditPen /></el-icon>修改名称</el-button
>
<el-button type="danger" v-auth="'/zm/api/v1/system/documentData/delete'" link @click="handleDelete(scope.row)"
><el-icon><ele-DeleteFilled /></el-icon>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
:total="state.total"
v-model:page="state.paramsQuery.pageNum"
v-model:limit="state.paramsQuery.pageSize"
@pagination="getdocumentDataList"
/>
</div>
</div>
<documentDetail ref="documentDetailRef" v-if="state.showDocumentDetail" @onClose="onClose"></documentDetail>
<!-- <documentDetail ref="documentDetailRef" v-if="state.showDocumentDetail" @onClose="onClose"></documentDetail>
<documentsEdit ref="documentDataEditRef" v-if="state.showdocumentDataEdit" @onClose="onCloseEdit"></documentsEdit>
<uploadFileder
ref="uploadFilederRef"
@ -156,9 +141,23 @@
@getDocumentListFileType="getdocumentDataListFileType"
></uploadFileder>
<fileOnline ref="fileOnlineRef" @getfileOnlineType="getfileOnlineType"></fileOnline>
<moveFile ref="moveFileRef"></moveFile>
<bookFile ref="bookFileRef"></bookFile>
</div>
<moveFile ref="moveFileRef"></moveFile> -->
<bookFile ref="bookFileRef" @onExportView="onExportView" @onExport="onExport"></bookFile>
<el-dialog title="上传文件" v-model="uploadFileder" width="30%">
<file-upload v-model="state.paramsQuery.file"></file-upload>
<template #footer>
<span>
<el-button @click="uploadFileder = false">取消</el-button>
<el-button type="primary" @click="subMitUpload">确定</el-button>
</span>
</template>
</el-dialog>
</div>
</el-tab-pane>
<el-tab-pane label="回收站" name="second">
<RecyclingStation ref="recylingRef"></RecyclingStation>
</el-tab-pane>
</el-tabs>
</template>
<script setup name="KnowledgeDocument" lang="ts">
@ -167,8 +166,10 @@ import {
getKnowledgeDocument,
delKnowledgeDocument,
addKnowledgeDocument,
uniFolderDownload,
getUniFolderDownloadList,
treeStructureData,
documentDataEdit,
getProfileDetail,
updateKnowledgeDocument
} from '@/api/quality/knowledgeDocument';
import { KnowledgeDocumentVO, KnowledgeDocumentQuery, KnowledgeDocumentForm } from '@/api/quality/knowledgeDocument/types';
@ -184,41 +185,51 @@ type KnowledgeDocumentOption = {
// import uploadFileder from '/@/views/OnlineEngineering/comm/uploadFileder/index.vue';
// import fileOnline from '/@/views/OnlineEngineering/profileEngineering/fileOnline/index.vue';
// import moveFile from '/@/views/OnlineEngineering/profileEngineering/moveFile/index.vue';
// import bookFile from '/@/views/OnlineEngineering/comm/bookFile/index.vue';
import { useUserStoreHook } from '@/store/modules/user';
import RecyclingStation from './component/recyclingStation.vue';
import { useUserStoreHook } from '@/store/modules/user';
import bookFile from './component/bookFile.vue';
const activeName = ref('first');
const { proxy } = getCurrentInstance() as any;
// 获取用户 store
const userStore = useUserStoreHook();
// 从 store 中获取项目列表和当前选中的项目
const currentProject = computed(() => userStore.selectedProject);
const uploadUrl = computed(() => {
return `/quality/knowledgeDocument/file`;
});
const uploadParams = computed(() => {
return {
pid: state.paramsQuery.folderId,
projectId: state.projectId
};
});
const filterText = ref('');
const treeRef = ref();
const documentDetailRef = ref();
const documentDataEditRef = ref();
const uploadFilederRef = ref();
const uploadFileder = ref(false);
const fileOnlineRef = ref();
const moveFileRef = ref();
const recylingRef = ref();
const bookFileRef = ref();
const baseURL: string | undefined | boolean = import.meta.env.VITE_API_URL;
const state = reactive({
treeList: [] as any,
arrayList: [] as any,
infoMap: new Map(),
infoList: [] as any,
Props: {
children: 'treeStructureDataRes',
label: 'name'
},
total: 0,
paramsQuery: {
idStr: '',
name: '',
switch: 1,
folderId: '',
fileName: '',
pageNum: 1,
pageSize: 20,
projectId: currentProject.value?.id
projectId: currentProject.value?.id,
file: null,
pid: null
},
loading: false,
checked: true,
@ -244,60 +255,69 @@ watch(filterText, (val: any) => {
});
// 新建文件夹
const addFile = () => {
let tip = '在根目录下新建文件夹';
if (state.parentPid) {
tip = '在“' + state.parentName + '文件夹”下新建文件夹';
}
ElMessageBox.prompt('请输入文件夹名称', tip, {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputErrorMessage: '请输入文件夹名称',
inputValue: ''
})
.then(({ value }) => {
documentDataNewFolder({ fileName: value, pid: state.parentPid, fileType: 3, projectId: state.projectId }).then((res: any) => {
if (res.code == 0) {
ElMessage({
type: 'success',
message: '添加成功'
});
gettreeStructureData();
} else {
ElMessage({
type: 'error',
message: res.message
});
}
});
})
.catch(() => {});
// const addFile = () => {
// let tip = '在根目录下新建文件夹';
// if (state.parentPid) {
// tip = '在“' + state.parentName + '文件夹”下新建文件夹';
// }
// ElMessageBox.prompt('请输入文件夹名称', tip, {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// inputErrorMessage: '请输入文件夹名称',
// inputValue: ''
// })
// .then(({ value }) => {
// documentDataNewFolder({ fileName: value, pid: state.parentPid, fileType: 3, projectId: state.projectId }).then((res: any) => {
// if (res.code == 0) {
// ElMessage({
// type: 'success',
// message: '添加成功'
// });
// gettreeStructureData();
// } else {
// ElMessage({
// type: 'error',
// message: res.message
// });
// }
// });
// })
// .catch(() => {});
// };
// 上传文件
const uploadFile = (files: any[]) => {
proxy.$modal.success('上传成功');
getdocumentDataList();
// uploadFileder.value = true;
};
// 导入文件
const uploadFile = (fileType) => {
if (fileType == 2 && !state.parentPid) {
ElMessage.warning('请选择文件目录!');
// 提交上传文件
const subMitUpload = () => {
if (!state.paramsQuery.file) {
ElMessage.warning('请选择文件!');
return;
}
// 判断上传类型 文件与压缩包区分
let acceptType = '.zip'; //压缩文件类型
if (fileType == 2) {
//文件上传
acceptType = '';
}
state.showUploadFileder = true;
nextTick(() => {
// 打开弹框
uploadFilederRef.value.openDialog(state.parentPid, fileType, acceptType, true);
addKnowledgeDocument(state.paramsQuery, { projectId: state.projectId, pid: state.parentPid }).then((res: any) => {
if (res.code == 200) {
ElMessage.success('上传成功');
uploadFileder.value = false;
state.paramsQuery.file = null; //清空文件
getdocumentDataList();
} else {
ElMessage.error(res.message);
}
});
};
const searchInfo = () => {
// 搜索
getdocumentDataList();
};
const resetQuery = () => {
// 重置
state.paramsQuery.name = '';
state.paramsQuery.fileName = '';
getdocumentDataList();
};
// 获取树形结构文件夹目录
@ -310,14 +330,14 @@ const gettreeStructureData = () => {
background: 'rgba(0, 0, 0, 0.7)',
target: '.tree_left1'
});
treeStructureData({ projectId: state.projectId }).then((res: any) => {
treeStructureData(state.projectId).then((res: any) => {
loading.close();
if (res.code == 0 && res.data && res.data.list) {
if (res.code == 200 && res.data && res.data.length) {
state.selectedNodeId = '';
state.treeList = res.data.list;
state.paramsQuery.idStr = res.data.list[0].idStr;
state.treeList = res.data;
state.paramsQuery.folderId = res.data[0].id;
getdocumentDataList();
setInfo(res.data.list);
// setInfo(res.data);
}
});
};
@ -325,7 +345,7 @@ const gettreeStructureData = () => {
const setInfo = (arr) => {
arr.forEach((element) => {
state.arrayList.push(element);
state.infoMap.set(element.idStr, element.id);
state.infoMap.set(element.folderId, element.id);
if (element.treeStructureDataRes && element.treeStructureDataRes.length) {
setInfo(element.treeStructureDataRes);
}
@ -334,10 +354,10 @@ const setInfo = (arr) => {
// 选择目录文件
const handleNodeClick = (row) => {
state.parentRow = row;
state.parentPid = row.idStr;
state.parentName = row.name;
state.paramsQuery.idStr = row.idStr;
state.paramsQuery.name = '';
state.parentPid = row.parentId;
console.log('🚀 ~ handleNodeClick ~ state.parentPid:', state.parentPid);
state.parentName = row.label;
state.paramsQuery.folderId = row.id;
getdocumentDataList();
if (row.id === state.selectedNodeId) {
// 如果当前节点已经选中,则取消选中
@ -345,7 +365,7 @@ const handleNodeClick = (row) => {
state.parentPid = null; //关闭父级选择的id
state.parentRow = null; //获取父级对象
state.parentName = ''; //获取父级对应的名称
state.paramsQuery.idStr = ''; //
state.paramsQuery.folderId = ''; //
} else {
// 否则选中当前节点 重新赋值
state.selectedNodeId = row.id;
@ -353,18 +373,15 @@ const handleNodeClick = (row) => {
};
// 获取文档列表数据
const getdocumentDataList = () => {
if (!state.paramsQuery.idStr) {
if (!state.paramsQuery.folderId) {
return;
}
state.loading = true;
documentDataList(state.paramsQuery).then((res: any) => {
listKnowledgeDocument(state.paramsQuery).then((res: any) => {
state.loading = false;
if (res.code == 0) {
res.data.list.sort((a, b) => {
return a.name.localeCompare(b.name);
});
state.infoList = res.data.list;
state.total = res.data.total;
if (res.code == 200) {
state.infoList = res.rows;
state.total = res.total;
}
});
};
@ -380,32 +397,41 @@ const handleDelete = (row) => {
getdocumentDataList();
});
};
const onExportView = (row) => {};
//切换tab
const handleCheckMian = (tab, event) => {
state.activeName = tab.name;
if (state.activeName === 'first') {
gettreeStructureData();
} else {
// 回收站
recylingRef.value.getDocumentDataList();
}
};
const onExportView = (row) => {
console.log(row);
proxy.$download.direct(row.fileUrl, row.originalName);
};
const updateName = (row) => {
// 修改名称
editName(row, '请输入文件名称', 1);
};
const handleView = (row) => {
getProfileDetail(row.id).then((res: any) => {
if (res.code == 0) {
// 查看文档
state.showDocumentDetail = true;
nextTick(() => {
documentDetailRef.value.openDialog(res.data);
});
}
});
// getProfileDetail(row.id).then((res: any) => {
// if (res.code == 200) {
// // 查看文档
// state.showDocumentDetail = true;
// nextTick(() => {
// documentDetailRef.value.openDialog(res.data);
// });
// }
// });
};
// 关闭在线编辑弹框
const onClose = () => {
state.showDocumentDetail = false;
};
// 展开或折叠节点
const handleCheckedTreeExpand = (value: any) => {
for (let i = 0; i < state.arrayList.length; i++) {
treeRef.value.store.nodesMap[state.arrayList[i].id].expanded = value;
}
};
// 关闭修改的在线文档弹框
const onCloseEdit = () => {
state.showdocumentDataEdit = false;
@ -417,55 +443,6 @@ const updataView = (row) => {
documentDataEditRef.value.openDialog(row, '/zm/api/v1/system/busConstructionUser/complaintBoxAddTwo');
});
};
const resizeHandleRight = () => {
// 右侧鼠标移动大小
const resizeHandles = document.getElementsByClassName('resize-handle');
Array.from(resizeHandles).forEach((handle) => {
handle.addEventListener('mousedown', startResize);
});
};
const startResize = (event) => {
event.preventDefault();
let dragElement = document.getElementById('tree_left1') as any;
let dragElementRight = document.getElementById('list_right1');
const currentHandle = event.target;
const direction = currentHandle.className.split(' ')[1];
const startX = event.clientX;
const startY = event.clientY;
// 左侧移动的盒子大小
const startWidth = dragElement.offsetWidth;
const startHeight = dragElement.offsetHeight;
const startLeft = dragElement.offsetLeft;
const startTop = dragElement.offsetTop;
// 右侧移动盒子宽度
const rightWidth = dragElementRight.offsetWidth;
document.addEventListener('mousemove', resize);
document.addEventListener('mouseup', stopResize);
function resize(event) {
const dx = event.clientX - startX;
const dy = event.clientY - startY;
let width = startWidth;
let height = startHeight;
let left = startLeft;
let top = startTop;
let rightWidth1 = rightWidth as any;
if (direction.includes('right')) {
width = startWidth + dx + 'px';
let w = startWidth + dx + 10 + 'px';
rightWidth1 = `calc(100% - ${w})`; //计算右侧盒子的宽度
}
if (parseInt(width) <= 0 || parseInt(height) <= 0) return;
dragElementRight.style.width = rightWidth1;
dragElement.style.width = width;
dragElement.style.height = height;
dragElement.style.left = left;
dragElement.style.top = top;
}
function stopResize() {
document.removeEventListener('mousemove', resize);
document.removeEventListener('mouseup', stopResize);
}
};
// 删除文件及文件夹
const delFile = (msg, data, cb) => {
ElMessageBox.confirm(msg, '提示', {
@ -474,8 +451,8 @@ const delFile = (msg, data, cb) => {
type: 'warning'
})
.then(() => {
documentDataDelete([data.id]).then((res: any) => {
if (res.code == 0) {
delKnowledgeDocument([data.id]).then((res: any) => {
if (res.code == 200) {
ElMessage.success('删除成功');
cb();
}
@ -483,29 +460,16 @@ const delFile = (msg, data, cb) => {
})
.catch(() => {});
};
const onRemove = (node, data) => {
const parent = node.parent;
const children = parent.data.treeStructureDataRes || parent.data;
const index = children.findIndex((d) => d.id === data.id);
let msg = '你确定要删除所选文件夹?';
delFile(msg, data, () => {
children.splice(index, 1);
if (data.idStr == state.paramsQuery.idStr) {
state.infoList = []; //清空文件列表
}
state.treeList = [...state.treeList]; //刷新当前列表数据
});
};
const editName = (data, title, type) => {
ElMessageBox.prompt(title, '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputErrorMessage: title,
inputValue: data.name
inputValue: data.fileName
})
.then(({ value }) => {
documentDataEdit({ id: data.id, name: value, type, projectId: state.projectId }).then((res: any) => {
if (res.code == 0) {
documentDataEdit({ id: data.id, fileName: value }).then((res: any) => {
if (res.code == 200) {
ElMessage({
type: 'success',
message: '修改成功'
@ -526,93 +490,31 @@ const editName = (data, title, type) => {
})
.catch(() => {});
};
const onUpdateName = (node, data) => {
editName(data, '请输入文件夹名称', 2);
};
const getdocumentDataListFileType = (fileType) => {
if (fileType == 2) {
getdocumentDataList();
} else {
gettreeStructureData();
}
};
const getfileOnlineType = (fileType) => {
if (fileType == 1) {
getdocumentDataList();
} else {
gettreeStructureData();
}
};
const onExport = () => {
uniFolderDownload(state.parentRow.filenPath).then((res: any) => {
if (res.code == 0) {
let fileUrl = res.data.RelativePath;
window.open(fileUrl, '_self');
getUniFolderDownloadList(state.paramsQuery.folderId).then((res: any) => {
if (res.code == 200) {
console.log(state.paramsQuery.fileName);
proxy.$download.downloadFilesAsZip(res.data, { urlKey: 'fileUrl', nameKey: 'originalName', zipName: state.parentName + '.zip' });
}
});
};
// 在线模板文件导入
const uploadOnlineFile = (node, data) => {
state.paramsQuery.idStr = data.idStr;
state.paramsQuery.folderId = data.folderId;
fileOnlineRef.value.openDialog(data.id);
};
const onMoveFile = () => {
// 移动文件
// moveFileRef.value.openDialog();
};
// 拖拽移动
const handleDragEnd = (draggingNode, dropNode, dropType, ev) => {
// TemplateId 被移动 DataId位置
let obj = { type: draggingNode.data.type, TemplateId: draggingNode.data.id, projectId: state.projectId, DataId: '' };
let DataId = '';
if (dropType == 'after' || dropType == 'before') {
// 获取父级id
// 通过pid找父级id
let pid = dropNode.data.pid; //子级pid
if (state.infoMap.has(pid)) {
//
DataId = state.infoMap.get(pid);
}
obj.DataId = DataId;
} else {
obj.DataId = dropNode.data.id;
}
if (!obj.DataId) {
return false;
}
const loading = ElLoading.service({
lock: true,
text: '正在加载中……',
background: 'rgba(0, 0, 0, 0.7)',
target: '.tree_left1'
});
onlineMobile(obj).then((res: any) => {
loading.close();
if (res.code == 0) {
ElMessage.success('移动成功');
// 重新获取文件接口
gettreeStructureData();
} else {
ElMessage.error(res.message);
}
});
};
const allowDrop = (draggingNode, dropNode, type) => {
// 不可移动
if (dropNode.data.pid == 0 && type != 'inner') {
//不可移动到最外层
return false;
} else {
return true;
}
};
// 查看所有资料
const onBook = () => {
bookFileRef.value.openDialog();
};
onMounted(() => {
resizeHandleRight();
gettreeStructureData();
});
</script>
@ -670,7 +572,6 @@ onMounted(() => {
padding: 4px;
border-bottom: 1px solid #f1f1f1;
.box_btn {
width: 360px;
margin: 0 10px 0 20px;
position: relative;
> span {

View File

@ -0,0 +1,154 @@
<template>
<div class="book_file">
<!-- 添加或修改公司对话框 -->
<el-dialog v-model="isShowDialog" width="80vw" custom-class="book_file_loading" :close-on-click-modal="false" :destroy-on-close="true">
<template #header>
<div v-drag="['.book_file .el-dialog', '.book_file .el-dialog__header']">查看资料文件</div>
</template>
<el-form ref="queryRef" :inline="true" label-width="100px">
<el-row>
<el-col :span="8" class="colBlock">
<el-form-item label="文件名称" prop="fileName">
<el-input v-model="formData.fileName" placeholder="请输入文件名称搜索" clearable @keyup.enter.native="getDataFileQuery" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item>
<el-button type="primary" @click="getDataFileQuery">
<el-icon><Search /></el-icon>搜索
</el-button>
<el-button @click="resetQuery" type="danger">
<el-icon><Refresh /></el-icon>清空
</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="content">
<div class="left_box" :style="treeList.length ? 'width: 70%' : 'width: 100%'">
<el-table v-loading="loading" :data="tableData" border height="63vh" :empty-text="emptyText">
<el-table-column label="序号" align="center" type="index" width="80px" />
<el-table-column label="文件名称" align="center" prop="fileName" min-width="100px" />
<el-table-column label="文件路径" align="center" min-width="100px">
<template #default="scope">
<span>{{ filterfilenPath(scope.row.filePath) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding" width="250px" fixed="right">
<template #default="scope">
<el-button type="success" link @click="onExport(scope.row)">
<el-icon><Download /></el-icon>下载
</el-button>
<el-button type="primary" link @click="onBook(scope.row)">
<el-icon><View /></el-icon>查看
</el-button>
</template>
</el-table-column>
</el-table>
<pagination :total="tableData.length" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getDataFileQuery" />
</div>
</div>
</el-dialog>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive, getCurrentInstance, nextTick } from 'vue';
import { listKnowledgeDocument, getProfileDetail } from '@/api/safety/knowledgeDocument';
import { useUserStoreHook } from '@/store/modules/user';
const emit = defineEmits(['onExport', 'onExportView']);
const stores = useUserStoreHook();
const { proxy } = getCurrentInstance() as any;
const documentDetailRef = ref();
const allTreeRef = ref();
const baseURL: string | undefined | boolean = import.meta.env.VITE_API_URL;
const loading = ref(false);
const tableData = ref<any[]>([]);
const isShowDialog = ref(false);
const formData = reactive({ fileName: '', projectId: stores.selectedProject.id });
const projectList = ref<any[]>([]);
const projectQuery = reactive({ name: '' });
const pageNum = ref(1);
const pageSize = ref(10);
const total = ref(0);
const showDocumentDetail = ref(false);
const emptyText = ref('暂无数据');
const treeList = ref<any[]>([]);
const arrayList = ref<any[]>([]);
const infoMap = ref(new Map());
const infoList = ref<any[]>([]);
const paramsQuery = reactive({ idStr: '', project: '' });
const openDialog = () => {
isShowDialog.value = true;
getDataFileQuery();
emptyText.value = '请输入文件名称进行搜索!';
resetForm();
};
const resetForm = () => {
tableData.value = [];
formData.fileName = '';
treeList.value = [];
emptyText.value = '暂无数据';
};
const getDataFileQuery = () => {
loading.value = true;
emptyText.value = '数据加载中……';
listKnowledgeDocument(formData).then((res: any) => {
loading.value = false;
tableData.value = [];
if (res.code == 200 && res.rows?.length) {
tableData.value = res.rows;
total.value = res.rows.length;
} else {
emptyText.value = '没有查询到数据,请重新输入搜索';
}
});
};
const onBook = (row: any) => {
return;
getProfileDetail(row.id).then((res: any) => {
if (res.code == 200) {
showDocumentDetail.value = true;
nextTick(() => {
documentDetailRef.value.openDialog(res.data);
});
}
});
};
const onExport = (row: any) => {
emit('onExportView', row);
};
const resetQuery = () => {
tableData.value = [];
formData.fileName = '';
loading.value = false;
emptyText.value = '暂无数据';
};
const filterfilenPath = (val: string): string => {
return val.replace(/^.*?知识库\//, '知识库/');
};
defineExpose({ openDialog });
</script>
<style scoped lang="scss">
.book_file {
.content {
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}
}
</style>

View File

@ -0,0 +1,194 @@
<template>
<div class="document_detail" id="document_detail">
<div class="move_pop" id="detial_pop">
<!-- <span>{{ title }}</span> -->
<div class="box">
<img v-if="type == 2" src="../icon/suo.png" @click="onFull(1)" />
<img v-else src="../icon/full.png" @click="onFull(2)" />
<span class="close" @click="onClose"></span>
</div>
</div>
<div class="box_app" id="box_app"></div>
</div>
</template>
<script lang="ts">
import { setMove } from '@/utils/moveDiv';
export default defineComponent({
name: 'index',
setup(props, { emit }) {
const { proxy } = <any>getCurrentInstance();
const state = reactive({
title: '',
type: 2
});
onMounted(() => {
setMove('detial_pop', 'document_detail');
});
// 打开弹窗
const openDialog = (obj) => {
state.title = obj.fileName;
init(obj);
};
const onError = function (event) {
//举例,强制保存后,判断文档内容是否保存成功
if (event.data) {
if (event.data.errorCode == 'forcesave') {
var desc = event.data.errorDescription;
desc = JSON.parse(desc);
if (desc.error == 0) {
//保存成功
} else {
//保存失败或异常
}
} else if (event.data.errorCode == 'setallcellvalue') {
var desc = event.data.errorDescription;
desc = JSON.parse(desc);
if (desc.error == 0) {
//填充成功
} else if (desc.error == -1) {
//当前文档正处于协同编辑中
} else {
//填充异常
}
} else if (event.data.errorCode == 'clearsheet') {
var desc = event.data.errorDescription;
desc = JSON.parse(desc);
if (desc.error == 0) {
//清除成功
} else if (desc.error == -1) {
//当前文档正处于协同编辑中
} else {
//清除异常
}
}
}
};
const onDocumentReady = function () {
// console.log('文档加载完成');
};
const init = (obj) => {
let documentKey = obj.id.toString() + new Date().getTime();
let baseURL = import.meta.env.VITE_APP_BASE_API + '/';
console.log(baseURL);
let url = baseURL + obj.filePath.replaceAll('+', ' ');
console.log('🚀 ~ init ~ url:', obj.fileUrl);
let type = obj.fileSuffix;
if (obj.fileSuffix.includes('.')) {
type = obj.fileSuffix.substring(1);
}
let documentType = 'word'; // docx doc
if (type == 'xlsx' || type == 'xls') {
documentType = 'cell'; //电子表格
} else if (type == 'ppt' || type == 'pptx') {
documentType = 'slide'; //演示文档文件
}
console.log(documentType, obj.fileSuffix);
new CXO_API.CXEditor('box_app', {
document: {
fileType: type,
key: documentKey,
title: obj.fileName,
url: obj.fileUrl
},
documentType,
editorConfig: {
mode: 'view',
callbackUrl: ''
},
height: '100%',
events: {
onDocumentReady: onDocumentReady,
onError: onError
},
zoom: -1
});
};
const onClose = () => {
emit('onClose', false);
};
const onFull = (type) => {
// 全屏
let document_detail = document.getElementById('document_detail');
state.type = type;
if (type == 2) {
document_detail.style.width = '100%';
document_detail.style.height = '100%';
} else {
document_detail.style.width = '1200px';
document_detail.style.height = '80vh';
}
};
return {
proxy,
openDialog,
onClose,
onFull,
...toRefs(state)
};
}
});
</script>
<style lang="scss">
.document_detail {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 999999;
width: 100%;
height: 100%;
border: 1px solid #9f9f9f;
.box_app {
// width: 1300px !important;
// height: 80vh !important;
background-color: #f1f1f1;
}
.move_pop {
width: 100%;
// position: absolute;
// top: 0;
// right: 0%;
height: 24px;
// background: linear-gradient(#2a5095, #213f7b, #111e48);
background-color: #f4f5f6;
display: grid;
place-items: center;
> span {
color: #000000;
font-weight: bold;
font-size: 20px;
letter-spacing: 2px;
}
.box {
display: flex;
width: 60px;
position: absolute;
top: 0;
right: 10px;
// height: 100%;
align-items: center;
img {
width: 22px;
margin-top: 6px;
cursor: pointer;
}
.close {
position: absolute;
right: 2px;
/* top: -8px; */
color: #8d8d8d;
width: 24px;
height: 24px;
font-size: 20px;
//border: 2px solid #0ff;
border-radius: 50%;
display: grid;
place-items: center;
cursor: pointer;
}
}
}
}
</style>

View File

@ -0,0 +1,198 @@
<template>
<div class="document_detail_eidt" id="document_detail_eidt">
<div class="move_pop" id="detial_edit">
<!-- <span>{{ title }}</span> -->
<div class="box">
<img v-if="type == 2" src="../icon/full.png" @click="onFull(1)" />
<img v-else src="../icon/suo.png" @click="onFull(2)" />
<span class="close" @click="onClose"></span>
</div>
</div>
<div class="box_app" id="box_app_edit"></div>
</div>
</template>
<script lang="ts">
import { toRefs, reactive, onMounted, ref, defineComponent, watch, getCurrentInstance } from 'vue';
import { setMove } from '@/utils/moveDiv';
import { useUserStoreHook } from '@/store/modules/user';
export default defineComponent({
name: 'index',
setup(props, { emit }) {
const stores = useUserStoreHook();
const { proxy } = <any>getCurrentInstance();
const state = reactive({
title: '',
projectId: stores.selectedProject.id,
type: 2,
postUrl: ''
});
onMounted(() => {
setMove('detial_edit', 'document_detail_eidt');
});
// 打开弹窗
const openDialog = (obj, url) => {
state.postUrl = url;
state.title = obj.name;
init(obj);
};
const onError = function (event) {
console.log('编辑器错误: code ' + event.data.errorCode + ', 描述' + event.data.errorDescription);
//举例,强制保存后,判断文档内容是否保存成功
if (event.data) {
if (event.data.errorCode == 'forcesave') {
var desc = event.data.errorDescription;
desc = JSON.parse(desc);
if (desc.error == 0) {
//保存成功
} else {
//保存失败或异常
}
} else if (event.data.errorCode == 'setallcellvalue') {
var desc = event.data.errorDescription;
desc = JSON.parse(desc);
if (desc.error == 0) {
//填充成功
} else if (desc.error == -1) {
//当前文档正处于协同编辑中
} else {
//填充异常
}
} else if (event.data.errorCode == 'clearsheet') {
var desc = event.data.errorDescription;
desc = JSON.parse(desc);
if (desc.error == 0) {
//清除成功
} else if (desc.error == -1) {
//当前文档正处于协同编辑中
} else {
//清除异常
}
}
}
};
const onDocumentReady = function () {
console.log('文档加载完成');
};
const init = (obj) => {
let documentKey = obj.id.toString() + new Date().getTime();
let baseURL = import.meta.env.VITE_APP_BASE_API;
let type = obj.fileSuffix;
if (obj.fileSuffix.includes('.')) {
type = obj.fileSuffix.substring(1);
}
let documentType = 'word'; // docx doc
if (type == 'xlsx' || type == 'xls') {
documentType = 'cell'; //电子表格
} else if (type == 'ppt' || type == 'pptx') {
documentType = 'slide'; //演示文档文件
}
console.log(documentType, obj.fileSuffix, baseURL + state.postUrl + '?path=' + obj.filePath);
new CXO_API.CXEditor('box_app_edit', {
document: {
fileType: obj.fileSuffix.substring(1),
key: documentKey,
title: obj.fileName,
url: obj.fileUrl
},
documentType,
editorConfig: {
callbackUrl: baseURL + state.postUrl + '?path=' + obj.filePath
},
events: {
onDocumentReady: onDocumentReady,
onError: onError
}
});
};
const onClose = () => {
emit('onClose', false);
};
const onFull = (type) => {
// 全屏
let document_detail = document.getElementById('document_detail_eidt');
state.type = type;
if (type == 2) {
// 弹框放大
document_detail.style.width = '100%';
document_detail.style.height = '100%';
} else {
// 弹框缩小
document_detail.style.width = '1200px';
document_detail.style.height = '80vh';
}
};
return {
proxy,
onFull,
openDialog,
onClose,
...toRefs(state)
};
}
});
</script>
<style lang="scss">
.document_detail_eidt {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 999999;
width: 100%;
height: 100%;
border: 1px solid #9f9f9f;
.box_app {
width: 1200px !important;
height: 80vh !important;
background-color: #f1f1f1;
margin-top: 100px;
}
.move_pop {
width: 100%;
// position: absolute;
// top: 0;
// right: 0%;
height: 24px;
// background: linear-gradient(#2a5095, #213f7b, #111e48);
background-color: #f4f5f6;
display: grid;
place-items: center;
> span {
color: #000000;
font-weight: bold;
font-size: 20px;
letter-spacing: 2px;
}
.box {
display: flex;
width: 60px;
position: absolute;
top: 0;
right: 10px;
// height: 100%;
align-items: center;
img {
width: 22px;
margin-top: 6px;
cursor: pointer;
}
.close {
position: absolute;
right: 2px;
/* top: -8px; */
color: #8d8d8d;
width: 24px;
height: 24px;
font-size: 20px;
//border: 2px solid #0ff;
border-radius: 50%;
display: grid;
place-items: center;
cursor: pointer;
}
}
}
}
</style>

View File

@ -0,0 +1,161 @@
<template>
<div class="system-document-container">
<el-card shadow="hover">
<div class="system-document-search mb-5">
<el-form :model="param" ref="queryRef" :inline="true" label-width="100px">
<el-row>
<el-col :span="2">
<el-button
type="success"
v-auth="'/zm/api/v1/system/document/templateRecycleBin'"
:disabled="multiple"
@click="onRecyclingStation(null, true)"
>
<el-icon><RefreshRight /></el-icon>批量恢复
</el-button>
</el-col>
<el-col :span="2">
<el-button
type="danger"
v-auth="'/zm/api/v1/system/document/templateRecycleBin'"
:disabled="multiple"
@click="onRecyclingStation(null, false)"
>
<el-icon><DeleteFilled /></el-icon>批量删除
</el-button>
</el-col>
</el-row>
</el-form>
</div>
<el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" type="index" min-width="30px" />
<el-table-column label="文件名称" align="center" prop="fileName" min-width="100px" />
<el-table-column label="文件路径" align="center" min-width="100px">
<template #default="scope">
<span>{{ filterfilenPath(scope.row.filePath) }}</span>
</template>
</el-table-column>
<el-table-column label="删除时间" align="center" prop="createTime" min-width="100px" />
<el-table-column label="操作" align="center" class-name="small-padding" min-width="80px" fixed="right">
<template #default="scope">
<div>
<el-button type="success" v-auth="'/zm/api/v1/system/document/templateRecycleBin'" link @click="onRecyclingStation(scope.row, true)">
<el-icon><RefreshRight /></el-icon>恢复
</el-button>
</div>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="param.pageNum" v-model:limit="param.pageSize" @pagination="getDocumentDataList" />
</el-card>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive, getCurrentInstance, computed } from 'vue';
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus';
import { documentDataAllList, templateRecycleBin, dataRecyclingStation } from '@/api/safety/knowledgeDocument';
import { useUserStoreHook } from '@/store/modules/user';
const proxy = getCurrentInstance()?.proxy as any;
const userStore = useUserStoreHook();
const currentProject = computed(() => userStore.selectedProject);
const loading = ref(false);
const queryRef = ref();
const multiple = ref(true);
const ids = ref<string>('');
const tableData = ref<any[]>([]);
const param = reactive({
type: 2,
projectId: currentProject.value.id,
pageNum: 1,
pageSize: 10
});
const total = ref(0);
const value = ref('2');
const getDocumentDataList = () => {
loading.value = true;
tableData.value = [];
value.value = '2';
documentDataAllList(param).then((res: any) => {
tableData.value = res.rows ?? [];
total.value = res.total;
loading.value = false;
});
};
const handleSelectionChange = (selection: any[]) => {
ids.value = selection.map((item) => item.id).join(',');
multiple.value = !selection.length;
};
const onRecyclingStation = (row: any, flag: boolean) => {
let type = 2;
let selectedIds: string = '';
let title = '删除';
let msg = '你确定要删除所选文件或文件夹?';
if (row) {
selectedIds = row.id;
} else {
selectedIds = ids.value;
}
if (flag) {
type = 1;
title = '恢复';
msg = '你确定要恢复所选文件或文件夹?';
}
ElMessageBox.confirm(msg, '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
const loadingInstance = ElLoading.service({
lock: true,
text: `正在${title}中……`,
background: 'rgba(0, 0, 0, 0.7)'
});
if (flag) {
dataRecyclingStation(selectedIds).then((res) => {
loadingInstance.close();
if (res.code == 200) {
getDocumentDataList();
ElMessage.success('操作成功');
}
});
} else {
templateRecycleBin(selectedIds).then((res) => {
loadingInstance.close();
if (res.code == 200) {
getDocumentDataList();
ElMessage.success('操作成功');
}
});
}
})
.catch(() => {});
};
const filterfilenPath = (val: string): string => {
return val.replace(/^.*?知识库\//, '知识库/');
};
defineExpose({
getDocumentDataList
});
</script>
<style lang="scss" scoped>
.colBlock {
display: block;
}
.colNone {
display: none;
}
</style>

View File

@ -1,153 +1,153 @@
<template>
<div class="profile_engin m-8">
<div class="box_info">
<div class="tree_left1" id="tree_left1">
<div class="check_select">
<!-- <el-button type="primary" v-auth="'/zm/api/v1/system/documentData/newFolder'" @click="addFile"
><el-icon><Plus /></el-icon>新建文件夹</el-button
> -->
<div class="box_btn" v-auth="'/zm/api/v1/system/documentData/add'">
<file-upload v-model="state.paramsQuery.file" :limit="1" :uploadUrl="uploadUrl" :on-upload-success="uploadFile">
<el-button type="primary" style="float: left" :disabled="!state.parentPid">
<el-icon size="small"><Plus /></el-icon>上传文件
</el-button>
</file-upload>
<el-tabs v-model="activeName" class="demo-tabs p5" @tab-click="handleCheckMian">
<el-tab-pane label="资料" name="first">
<div class="profile_engin">
<div class="box_info">
<div class="tree_left1" id="tree_left1">
<div class="file_upload check_select">
<div class="box_btn" v-auth="'/zm/api/v1/system/documentData/add'">
<file-upload
v-model="state.paramsQuery.file"
:limit="100"
:uploadUrl="uploadUrl"
:params="uploadParams"
:on-upload-success="uploadFile"
>
<el-button type="primary" style="float: left" :disabled="!state.parentPid">
<el-icon size="small"><Plus /></el-icon>上传文件
</el-button>
</file-upload>
</div>
<el-button
type="primary"
v-auth="'/zm/api/v1/system/documentProject/dataCompressedDownload'"
:disabled="!state.parentPid"
@click="onExport"
><el-icon><Download /></el-icon>下载</el-button
>
<el-button type="primary" @click="onBook" v-auth="'/zm/api/v1/system/documentData/dataFileQuery'"
><el-icon><View /></el-icon>查看全项目文件</el-button
>
</div>
<div class="file_upload check_select">
<el-input class="input_left" v-model="filterText" size="small" placeholder="请输入文件名称" />
</div>
<el-tree
ref="treeRef"
highlight-current
:default-expand-all="state.checked"
:filter-node-method="filterFolder"
:data="state.treeList"
node-key="id"
accordion
:expand-on-click-node="false"
@node-click="handleNodeClick"
:current-node-key="state.selectedNodeId"
>
<template #default="{ node, data }">
<span class="custom-tree-node">
<el-icon color="#f1a81a"><FolderOpened /></el-icon>
<span>{{ node.label }}</span>
</span>
</template>
</el-tree>
<div class="resize-handle resize-handle-right right"></div>
</div>
</div>
<div class="file_upload check_select">
<el-checkbox v-model="state.checked" @change="handleCheckedTreeExpand($event)" label="展开/折叠" size="large" />
<div style="margin: 0 10px">
<el-select v-model="state.paramsQuery.switch" placeholder="当前文件夹" size="small">
<el-option v-for="item in state.options" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
</div>
<el-button type="primary" v-auth="'/zm/api/v1/system/documentProject/dataCompressedDownload'" :disabled="!state.parentPid" @click="onExport"
><el-icon><Download /></el-icon>下载</el-button
>
<el-button type="primary" @click="onBook" v-auth="'/zm/api/v1/system/documentData/dataFileQuery'"
><el-icon><View /></el-icon>查看全项目文件</el-button
>
</div>
<div class="file_upload check_select">
<el-input class="input_left" v-model="filterText" size="small" placeholder="请输入文件名称" />
</div>
<el-tree
ref="treeRef"
highlight-current
:default-expand-all="state.checked"
:filter-node-method="filterFolder"
:data="state.treeList"
node-key="id"
accordion
:expand-on-click-node="false"
@node-click="handleNodeClick"
:current-node-key="state.selectedNodeId"
:allow-drop="allowDrop"
>
<template #default="{ node, data }">
<span class="custom-tree-node">
<el-icon color="#f1a81a"><FolderOpened /></el-icon>
<span>{{ node.label }}</span>
</span>
</template>
</el-tree>
<div class="resize-handle resize-handle-right right"></div>
</div>
<div class="list_right" id="list_right1">
<div>
<el-form :model="state.paramsQuery" ref="queryRef" :inline="true" label-width="100px">
<el-row>
<el-col :span="7" class="colBlock">
<el-form-item label="文件名称" prop="fileName">
<el-input v-model="state.paramsQuery.fileName" placeholder="请输入文件名称" clearable @keyup.enter.native="getdocumentDataList" />
</el-form-item>
</el-col>
<el-col :span="6" class="m-l10">
<el-form-item>
<el-button type="primary" @click="searchInfo"
><el-icon><Search /></el-icon>搜索</el-button
>
<el-button @click="resetQuery"
><el-icon><Refresh /></el-icon>重置</el-button
>
</el-form-item>
</el-col>
<!-- <el-col :span="4">
<div class="list_right" id="list_right1">
<div>
<el-form :model="state.paramsQuery" ref="queryRef" :inline="true" label-width="100px">
<el-row>
<el-col :span="7" class="colBlock">
<el-form-item label="文件名称" prop="fileName">
<el-input
v-model="state.paramsQuery.fileName"
placeholder="请输入文件名称"
clearable
@keyup.enter.native="getdocumentDataList"
/>
</el-form-item>
</el-col>
<el-col :span="6" class="m-l10">
<el-form-item>
<el-button type="primary" @click="searchInfo"
><el-icon><Search /></el-icon>搜索</el-button
>
<el-button @click="resetQuery"
><el-icon><Refresh /></el-icon>重置</el-button
>
</el-form-item>
</el-col>
<!-- <el-col :span="4">
<el-button type="primary" v-auth="'/zm/api/v1/system/documentData/add'" :disabled="!parentPid" @click="uploadFile(2)"
><el-icon><Plus /></el-icon>导入本地文件</el-button
>
</el-col> -->
<!-- <el-col :span="4">
<!-- <el-col :span="4">
<el-button type="primary" @click="onMoveFile"
><el-icon><Plus /></el-icon>移动</el-button
>
</el-col> -->
</el-row>
</el-form>
</el-row>
</el-form>
</div>
<el-table v-loading="state.loading" :data="state.infoList" height="67vh" border>
<el-table-column label="序号" align="center" type="index" min-width="50px" />
<el-table-column label="文件名称" align="center" prop="fileName"></el-table-column>
<el-table-column label="上传时间" align="center" prop="createTime"> </el-table-column>
<el-table-column label="操作" align="center" width="300">
<template #default="scope">
<el-button type="primary" link @click="handleView(scope.row)"
><el-icon><View /></el-icon>查看</el-button
>
<el-button type="primary" v-auth="'/zm/api/v1/system/documentData/complaintBoxAdd'" link @click="updataView(scope.row)"
><el-icon><EditPen /></el-icon>修改文件</el-button
>
<el-button type="primary" v-auth="'/zm/api/v1/system/documentData/uniFolderDownload'" link @click="onExportView(scope.row)"
><el-icon><Download /></el-icon>下载</el-button
>
<el-button type="success" v-auth="'/zm/api/v1/system/documentData/edit'" link @click="updateName(scope.row)"
><el-icon><EditPen /></el-icon>修改名称</el-button
>
<el-button type="danger" v-auth="'/zm/api/v1/system/documentData/delete'" link @click="handleDelete(scope.row)"
><el-icon><DeleteFilled /></el-icon>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
:total="state.total"
v-model:page="state.paramsQuery.pageNum"
v-model:limit="state.paramsQuery.pageSize"
@pagination="getdocumentDataList"
/>
</div>
</div>
<el-table v-loading="state.loading" :data="state.infoList" height="67vh" border>
<el-table-column label="序号" align="center" type="index" min-width="50px" />
<el-table-column label="文件名称" align="center" prop="fileName"></el-table-column>
<el-table-column label="上传时间" align="center" prop="createdAt"> </el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
type="primary"
v-auth="'/zm/api/v1/system/documentData/get'"
v-if="state.acceptType.includes(scope.row.suffix)"
link
@click="handleView(scope.row)"
><el-icon><View /></el-icon>查看</el-button
>
<el-button
type="primary"
v-auth="'/zm/api/v1/system/documentData/complaintBoxAdd'"
v-if="state.acceptType.includes(scope.row.suffix)"
link
@click="updataView(scope.row)"
><el-icon><EditPen /></el-icon>修改文件</el-button
>
<el-button type="primary" v-auth="'/zm/api/v1/system/documentData/uniFolderDownload'" link @click="onExportView(scope.row)"
><el-icon><Download /></el-icon>下载</el-button
>
<el-button type="success" v-auth="'/zm/api/v1/system/documentData/edit'" link @click="updateName(scope.row)"
><el-icon><EditPen /></el-icon>修改名称</el-button
>
<el-button type="danger" v-auth="'/zm/api/v1/system/documentData/delete'" link @click="handleDelete(scope.row)"
><el-icon><DeleteFilled /></el-icon>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
:total="state.total"
v-model:page="state.paramsQuery.pageNum"
v-model:limit="state.paramsQuery.pageSize"
@pagination="getdocumentDataList"
/>
</div>
</div>
<!-- <documentDetail ref="documentDetailRef" v-if="state.showDocumentDetail" @onClose="onClose"></documentDetail>
<documentsEdit ref="documentDataEditRef" v-if="state.showdocumentDataEdit" @onClose="onCloseEdit"></documentsEdit>
<uploadFileder
<documentsDeailsVue ref="documentDetailRef" v-if="state.showDocumentDetail" @onClose="onClose"></documentsDeailsVue>
<documentsEdit ref="documentDataEditRef" v-if="state.showdocumentDataEdit" @onClose="onCloseEdit"></documentsEdit>
<!--<uploadFileder
ref="uploadFilederRef"
v-if="state.showUploadFileder"
@onCloseFile="state.showUploadFileder = false"
@getDocumentListFileType="getdocumentDataListFileType"
></uploadFileder>
<fileOnline ref="fileOnlineRef" @getfileOnlineType="getfileOnlineType"></fileOnline>
<moveFile ref="moveFileRef"></moveFile>
<bookFile ref="bookFileRef"></bookFile> -->
<el-dialog title="上传文件" v-model="uploadFileder" width="30%">
<file-upload v-model="state.paramsQuery.file"></file-upload>
<template #footer>
<span>
<el-button @click="uploadFileder = false">取消</el-button>
<el-button type="primary" @click="subMitUpload">确定</el-button>
</span>
</template>
</el-dialog>
</div>
<moveFile ref="moveFileRef"></moveFile> -->
<bookFile ref="bookFileRef" @onExportView="onExportView" @onExport="onExport"></bookFile>
<el-dialog title="上传文件" v-model="uploadFileder" width="30%">
<file-upload v-model="state.paramsQuery.file"></file-upload>
<template #footer>
<span>
<el-button @click="uploadFileder = false">取消</el-button>
<el-button type="primary" @click="subMitUpload">确定</el-button>
</span>
</template>
</el-dialog>
</div>
</el-tab-pane>
<el-tab-pane label="回收站" name="second">
<RecyclingStation ref="recylingRef"></RecyclingStation>
</el-tab-pane>
</el-tabs>
</template>
<script setup name="KnowledgeDocument" lang="ts">
@ -156,7 +156,7 @@ import {
getKnowledgeDocument,
delKnowledgeDocument,
addKnowledgeDocument,
uniFolderDownload,
getUniFolderDownloadList,
treeStructureData,
documentDataEdit,
getProfileDetail,
@ -169,24 +169,30 @@ type KnowledgeDocumentOption = {
fileName: string;
children?: KnowledgeDocumentOption[];
};
// import documentDetail from '/@/views/OnlineEngineering/comm/documentsDetail/index.vue';
// import documentsEdit from '/@/views/OnlineEngineering/comm/documentsEdit/index.vue';
import documentsEdit from './component/documentsEdit.vue';
// import profileData from '/@/views/OnlineEngineering/profileData/index.vue';
// import uploadFileder from '/@/views/OnlineEngineering/comm/uploadFileder/index.vue';
// import fileOnline from '/@/views/OnlineEngineering/profileEngineering/fileOnline/index.vue';
// import moveFile from '/@/views/OnlineEngineering/profileEngineering/moveFile/index.vue';
// import bookFile from '/@/views/OnlineEngineering/comm/bookFile/index.vue';
import { useUserStoreHook } from '@/store/modules/user';
import documentsDeailsVue from './component/documentsDeails.vue';
import RecyclingStation from './component/recyclingStation.vue';
import { useUserStoreHook } from '@/store/modules/user';
import bookFile from './component/bookFile.vue';
const activeName = ref('first');
const { proxy } = getCurrentInstance() as any;
// 获取用户 store
const userStore = useUserStoreHook();
// 从 store 中获取项目列表和当前选中的项目
const currentProject = computed(() => userStore.selectedProject);
const uploadUrl = computed(() => {
console.log(`/safety/knowledgeDocument/file?pid=${state.paramsQuery.folderId}&projectId=${state.projectId}`);
return `/safety/knowledgeDocument/file?pid=${state.paramsQuery.folderId}&projectId=${state.projectId}`;
return `/safety/knowledgeDocument/file`;
});
const uploadParams = computed(() => {
return {
pid: state.paramsQuery.folderId,
projectId: state.projectId
};
});
const filterText = ref('');
@ -196,6 +202,7 @@ const documentDataEditRef = ref();
const uploadFileder = ref(false);
const fileOnlineRef = ref();
const moveFileRef = ref();
const recylingRef = ref();
const bookFileRef = ref();
const baseURL: string | undefined | boolean = import.meta.env.VITE_API_URL;
const state = reactive({
@ -208,7 +215,6 @@ const state = reactive({
paramsQuery: {
folderId: '',
fileName: '',
switch: 1,
pageNum: 1,
pageSize: 20,
projectId: currentProject.value?.id,
@ -268,9 +274,11 @@ watch(filterText, (val: any) => {
// })
// .catch(() => {});
// };
// 上传文件
const uploadFile = (files: any[]) => {
proxy.$modal.success('上传成功');
state.paramsQuery.file = null;
getdocumentDataList();
// uploadFileder.value = true;
};
@ -339,9 +347,8 @@ const handleNodeClick = (row) => {
state.parentRow = row;
state.parentPid = row.parentId;
console.log('🚀 ~ handleNodeClick ~ state.parentPid:', state.parentPid);
state.parentName = row.name;
state.parentName = row.label;
state.paramsQuery.folderId = row.id;
state.paramsQuery.fileName = '';
getdocumentDataList();
if (row.id === state.selectedNodeId) {
// 如果当前节点已经选中,则取消选中
@ -354,7 +361,6 @@ const handleNodeClick = (row) => {
// 否则选中当前节点 重新赋值
state.selectedNodeId = row.id;
}
console.log('🚀 ~ handleNodeClick ~ state.parentPid:', state.paramsQuery.folderId);
};
// 获取文档列表数据
const getdocumentDataList = () => {
@ -365,9 +371,6 @@ const getdocumentDataList = () => {
listKnowledgeDocument(state.paramsQuery).then((res: any) => {
state.loading = false;
if (res.code == 200) {
// res.data.list.sort((a, b) => {
// return a.name.localeCompare(b.name);
// });
state.infoList = res.rows;
state.total = res.total;
}
@ -385,35 +388,36 @@ const handleDelete = (row) => {
getdocumentDataList();
});
};
//切换tab
const handleCheckMian = (tab, event) => {
state.activeName = tab.name;
if (state.activeName === 'first') {
gettreeStructureData();
} else {
// 回收站
recylingRef.value.getDocumentDataList();
}
};
const onExportView = (row) => {
console.log(row);
proxy.$download.direct(row.fileUrl, row.fileName);
proxy.$download.direct(row.fileUrl, row.originalName);
};
const updateName = (row) => {
// 修改名称
editName(row, '请输入文件名称', 1);
};
const handleView = (row) => {
// getProfileDetail(row.id).then((res: any) => {
// if (res.code == 200) {
// // 查看文档
// state.showDocumentDetail = true;
// nextTick(() => {
// documentDetailRef.value.openDialog(res.data);
// });
// }
// });
state.showDocumentDetail = true;
nextTick(() => {
documentDetailRef.value.openDialog(row);
});
};
// 关闭在线编辑弹框
const onClose = () => {
state.showDocumentDetail = false;
};
// 展开或折叠节点
const handleCheckedTreeExpand = (value: any) => {
for (let i = 0; i < state.arrayList.length; i++) {
treeRef.value.store.nodesMap[state.arrayList[i].id].expanded = value;
}
};
// 关闭修改的在线文档弹框
const onCloseEdit = () => {
state.showdocumentDataEdit = false;
@ -422,58 +426,9 @@ const updataView = (row) => {
// 修改文档
state.showdocumentDataEdit = true;
nextTick(() => {
documentDataEditRef.value.openDialog(row, '/zm/api/v1/system/busConstructionUser/complaintBoxAddTwo');
documentDataEditRef.value.openDialog(row, '/changxie/callback');
});
};
const resizeHandleRight = () => {
// 右侧鼠标移动大小
const resizeHandles = document.getElementsByClassName('resize-handle');
Array.from(resizeHandles).forEach((handle) => {
handle.addEventListener('mousedown', startResize);
});
};
const startResize = (event) => {
event.preventDefault();
let dragElement = document.getElementById('tree_left1') as any;
let dragElementRight = document.getElementById('list_right1');
const currentHandle = event.target;
const direction = currentHandle.className.split(' ')[1];
const startX = event.clientX;
const startY = event.clientY;
// 左侧移动的盒子大小
const startWidth = dragElement.offsetWidth;
const startHeight = dragElement.offsetHeight;
const startLeft = dragElement.offsetLeft;
const startTop = dragElement.offsetTop;
// 右侧移动盒子宽度
const rightWidth = dragElementRight.offsetWidth;
document.addEventListener('mousemove', resize);
document.addEventListener('mouseup', stopResize);
function resize(event) {
const dx = event.clientX - startX;
const dy = event.clientY - startY;
let width = startWidth;
let height = startHeight;
let left = startLeft;
let top = startTop;
let rightWidth1 = rightWidth as any;
if (direction.includes('right')) {
width = startWidth + dx + 'px';
let w = startWidth + dx + 10 + 'px';
rightWidth1 = `calc(100% - ${w})`; //计算右侧盒子的宽度
}
if (parseInt(width) <= 0 || parseInt(height) <= 0) return;
dragElementRight.style.width = rightWidth1;
dragElement.style.width = width;
dragElement.style.height = height;
dragElement.style.left = left;
dragElement.style.top = top;
}
function stopResize() {
document.removeEventListener('mousemove', resize);
document.removeEventListener('mouseup', stopResize);
}
};
// 删除文件及文件夹
const delFile = (msg, data, cb) => {
ElMessageBox.confirm(msg, '提示', {
@ -491,19 +446,6 @@ const delFile = (msg, data, cb) => {
})
.catch(() => {});
};
const onRemove = (node, data) => {
const parent = node.parent;
const children = parent.data.treeStructureDataRes || parent.data;
const index = children.findIndex((d) => d.id === data.id);
let msg = '你确定要删除所选文件夹?';
delFile(msg, data, () => {
children.splice(index, 1);
if (data.folderId == state.paramsQuery.folderId) {
state.infoList = []; //清空文件列表
}
state.treeList = [...state.treeList]; //刷新当前列表数据
});
};
const editName = (data, title, type) => {
ElMessageBox.prompt(title, '温馨提示', {
confirmButtonText: '确定',
@ -534,28 +476,11 @@ const editName = (data, title, type) => {
})
.catch(() => {});
};
const onUpdateName = (node, data) => {
editName(data, '请输入文件夹名称', 2);
};
const getdocumentDataListFileType = (fileType) => {
if (fileType == 2) {
getdocumentDataList();
} else {
gettreeStructureData();
}
};
const getfileOnlineType = (fileType) => {
if (fileType == 1) {
getdocumentDataList();
} else {
gettreeStructureData();
}
};
const onExport = () => {
uniFolderDownload(state.parentRow.filenPath).then((res: any) => {
if (res.code == 0) {
let fileUrl = res.data.RelativePath;
window.open(fileUrl, '_self');
getUniFolderDownloadList(state.paramsQuery.folderId).then((res: any) => {
if (res.code == 200) {
console.log(state.paramsQuery.fileName);
proxy.$download.downloadFilesAsZip(res.data, { urlKey: 'fileUrl', nameKey: 'originalName', zipName: state.parentName + '.zip' });
}
});
};
@ -568,52 +493,7 @@ const onMoveFile = () => {
// 移动文件
// moveFileRef.value.openDialog();
};
// 拖拽移动
// const handleDragEnd = (draggingNode, dropNode, dropType, ev) => {
// // TemplateId 被移动 DataId位置
// let obj = { type: draggingNode.data.type, TemplateId: draggingNode.data.id, projectId: state.projectId, DataId: '' };
// let DataId = '';
// if (dropType == 'after' || dropType == 'before') {
// // 获取父级id
// // 通过pid找父级id
// let pid = dropNode.data.pid; //子级pid
// if (state.infoMap.has(pid)) {
// //
// DataId = state.infoMap.get(pid);
// }
// obj.DataId = DataId;
// } else {
// obj.DataId = dropNode.data.id;
// }
// if (!obj.DataId) {
// return false;
// }
// const loading = ElLoading.service({
// lock: true,
// text: '正在加载中……',
// background: 'rgba(0, 0, 0, 0.7)',
// target: '.tree_left1'
// });
// onlineMobile(obj).then((res: any) => {
// loading.close();
// if (res.code == 0) {
// ElMessage.success('移动成功');
// // 重新获取文件接口
// gettreeStructureData();
// } else {
// ElMessage.error(res.message);
// }
// });
// };
const allowDrop = (draggingNode, dropNode, type) => {
// 不可移动
if (dropNode.data.pid == 0 && type != 'inner') {
//不可移动到最外层
return false;
} else {
return true;
}
};
// 查看所有资料
const onBook = () => {
bookFileRef.value.openDialog();
@ -621,7 +501,6 @@ const onBook = () => {
onMounted(() => {
gettreeStructureData();
resizeHandleRight();
});
</script>
@ -679,7 +558,6 @@ onMounted(() => {
padding: 4px;
border-bottom: 1px solid #f1f1f1;
.box_btn {
width: 360px;
margin: 0 10px 0 20px;
position: relative;
> span {