Files
tool-tech-front/src/views/document/index.vue
pan 4920b41620 1、新增评论、回复功能
2、工具发布权限完善一部分
2024-08-30 19:48:44 +08:00

604 lines
22 KiB
Vue

<template>
<div class="app-container">
<el-card>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<div class="search">
<div class="sl">
<el-form-item label="文档编号" prop="docCode">
<el-input
v-model="queryParams.docCode"
placeholder="请输入文档名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="文档名称" prop="docName">
<el-input
v-model="queryParams.docName"
placeholder="请输入文档名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类别" prop="docType">
<el-select v-model="queryParams.docType" placeholder="请选择">
<el-option
v-for="dict in dict.type.doc_class"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="负责人" prop="docPrincipals">
<el-input
v-model="queryParams.docPrincipals"
placeholder="请输入负责人"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="归属单位" prop="docRespDept">
<treeselect v-model="queryParams.docRespDept" :options="deptOptions"
placeholder="请选择归属单位"
:show-count="true" style="width: 150px"/>
</el-form-item>-->
<el-form-item label="来源" prop="docSource">
<el-select v-model="queryParams.docSource" placeholder="请选择" >
<el-option
v-for="dict in dict.type.doc_source"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="docStatus">
<el-select v-model="queryParams.docStatus" placeholder="请选择" >
<el-option
v-for="dict in dict.type.doc_upload_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
</div>
<div class="sr">
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</div>
</div>
</el-form>
</el-card>
<el-card class="lrtt">
<div class="lt">
<el-input placeholder="请输入..." prefix-icon="el-icon-search"></el-input>
<div class="divide"></div><!--divide 分隔-->
<el-tree :data="docCategory" :props="docCategoryProps" @node-click="handleNodeClick">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>{{ node.label }}</span>
<el-dropdown>
<span class="el-dropdown-link"><i class="el-icon-more"></i></span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="handleDocCategoryAdd(data)"><i class="el-icon-plus"></i>添加</el-dropdown-item>
<el-dropdown-item v-if="data.types != 'system'" @@click.native="handleDocCategoryUpdate(data)"><i class="el-icon-edit"></i>编辑</el-dropdown-item>
<el-dropdown-item v-if="data.types != 'system'" @@click.native="handleDocCategoryDelete(data)"><i class="el-icon-delete"></i>删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</span>
</el-tree>
</div><!--lt -->
<div class="rt">
<div class="operate">
<el-button
type="primary"
plain
icon="el-icon-upload2"
size="mini"
@click="handleAdd"
v-hasPermi="['document:add']"
>上传文档</el-button>
<el-button type="primary" icon="el-icon-position" @click="handlePush" v-hasPermi="['document:push']">发布</el-button>
<el-button icon="el-icon-delete" @click="handleDelete" v-hasPermi="['document:batch:remove']">批量删除</el-button>
<el-button icon="el-icon-download" @click="handleOpenExport()" v-hasPermi="['document:export']">导出</el-button>
</div><!--operate 操作按钮-->
<el-table v-loading="loading" :data="docList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" :selectable="isSelectable"/>
<el-table-column label="文档编号" align="center" prop="docCode" width="120" />
<el-table-column label="文档名称" align="center" prop="docName" :show-overflow-tooltip="true" />
<el-table-column label="类别" align="center" prop="docType" :show-overflow-tooltip="true" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.doc_class" :value="scope.row.docType"/>
</template>
</el-table-column>·
<el-table-column label="负责人" align="center" prop="docPrincipals" :show-overflow-tooltip="true" width="80" />
<el-table-column label="归属单位" align="center" prop="docRespDeptName" :show-overflow-tooltip="true" width="80" />
<el-table-column label="来源" align="center" prop="docSource" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.doc_source" :value="scope.row.docSource"/>
</template>
</el-table-column>
<el-table-column label="关联工具" align="center" prop="toolName" width="100" />
<el-table-column label="上传状态" align="center" prop="docStatus" width="100" >
<template slot-scope="scope">
<dict-tag :options="dict.type.doc_upload_status" :value="scope.row.docStatus"/>
</template>
<!--
<template slot-scope="scope">
<el-tag type="info" v-if="scope.row.docStatus == 'ysc'">已上传</el-tag>
<el-tag type="success" v-else-if="scope.row.docStatus == 'yfb'">已发布</el-tag>
<el-tag type="warning" v-else-if="scope.row.docStatus == 'shz'">审核中</el-tag>
</template>-->
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="180">
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
v-if="scope.row.docStatus != 'yfb' && scope.row.docStatus != 'shz'"
@click="handleEdit(scope.row)"
v-hasPermi="['document:edit']"
>编辑</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-view"
v-if="previewAuth(scope.row)"
@click="handlePreview(scope.row)"
v-hasPermi="['document:preview']"
>预览</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
v-if="scope.row.docStatus != 'yfb' && scope.row.docStatus != 'shz'"
@click="handleDelete(scope.row)"
v-hasPermi="['document:remove']"
>删除</el-button>
<el-button type="text" icon="el-icon-download" @click="handleDownload(scope.row)"
v-hasPermi="['document:batch:remove']"
v-loading="loadingDownload">下载</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</el-card>
<el-dialog :title="docCategoryTitle" :visible.sync="docCategoryOpen" width="50%" append-to-body>
<el-form ref="docCategoryForm" :model="docCategoryForm" :rules="docCategoryRules" label-width="80px">
<el-form-item label="父分类" prop="parentId">
<treeselect v-model="docCategoryForm.parentId" :options="docCategory" :show-count="true" placeholder="如果不选择,默认为顶级节点" />
</el-form-item>
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="docCategoryForm.categoryName" placeholder="请输入分类名称" maxlength="50" show-word-limit/>
</el-form-item>
<el-form-item label="分类描述" prop="categoryDescription">
<el-input v-model="docCategoryForm.categoryDescription"
type="textarea" :rows="3" maxlength="500" show-word-limit
placeholder="请输入分类描述" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="docCategorySubmitForm"> </el-button>
<el-button @click="docCategoryCancel"> </el-button>
</span>
</el-dialog>
<el-dialog :title="viewDialogTitle" :visible.sync="viewDialogOpen" fullscreen width="500px" append-to-body>
<i-frame :src="previewUrl" />
</el-dialog>
<el-drawer :visible.sync="open" :modal-append-to-body="false" size="75%">
<template #title>
<span class="title">新增文档资源</span>
<div class="drawer-head-btn">
<el-button type="primary" @click="$refs.editDocumentRef.submitForm()"> </el-button>
<el-button @click="docCancel()"> </el-button>
</div><!--drawer-head-btn 抽屉顶部按钮区域-->
</template>
<edit-document ref="editDocumentRef" @submit="editDocumentSubmit"/>
</el-drawer>
<!-- 工具导出对话框 -->
<el-drawer :visible.sync="exportDrawerOpen" size="75%" :show-close="false">
<template #title>
<span class="title">导出</span>
<div class="drawer-head-btn">
<el-button type="primary" @click="handleExport">提交</el-button>
<el-button @click="exportDrawerOpen=false">取消</el-button>
</div><!--drawer-head-btn 抽屉顶部按钮区域-->
</template>
<div class="el-form-border">
<el-form ref="form" label-width="200px">
<el-row>
<el-col :span="24">
<el-form-item label="选择需要导出的字段信息">
<el-checkbox-group v-model="checkList">
<el-checkbox label="docCode">文档编号</el-checkbox>
<el-checkbox label="docName">文档名称</el-checkbox>
<el-checkbox label="docType">类别</el-checkbox>
<el-checkbox label="docPrincipals">负责人</el-checkbox>
<el-checkbox label="docRespDeptName">归属单位</el-checkbox>
<el-checkbox label="docSource">来源</el-checkbox>
<el-checkbox label="toolName">关联工具</el-checkbox>
<el-checkbox label="docStatus">上传状态</el-checkbox>
<el-checkbox label="createTime">创建时间</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-col>
</el-row>
</el-form><!--el-form-->
</div><!--el-form-border 表单-->
</el-drawer><!--el-drawer 导出抽屉-->
<!-- <upload-progress/>-->
</div>
</template>
<script>
import { listDocument, getDocument, delDocument, addDocument, updateDocument,pushDoc } from "@/api/document/document";
import { deptTreeSelect } from "@/api/system/user";
import { documentTree,addCategory,updateCategory,delCategory,getCategory } from "@/api/documentCategory/documentCategory.js";
import { Base64 } from 'js-base64';
import iFrame from "@/components/iFrame/index"
import editDocument from "./editDocument";
import uploadProgress from "./uploadProgress";
import { w3cwebsocket as WebSocket } from 'websocket';
import Treeselect from "@riophae/vue-treeselect";
export default {
name: "Document",
components: { iFrame, editDocument, uploadProgress, Treeselect},
dicts:['doc_class','doc_source','doc_upload_status'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 部门名称
deptName: undefined,
// 部门树选项
deptOptions: undefined,
defaultProps: {
children: "children",
label: "label"
},
// 文档树
docCategory: undefined,
docCategoryProps: {
children: "children",
label: "label"
},
// 总条数
total: 0,
// 表格数据
docList: [],
// 弹出层标题
title: "",
viewDialogTitle: "",
viewDialogOpen: false,
open: false,
// 日期范围
dateRange: [],
previewUrl: '',
progress: 0,
fileList: [],
websocket: null,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
docName: '',
docCode: '',
docType: '',
docPrincipals: '',
docSource: '',
docStatus: '',
docCategoryId: '',
},
// 表单参数
form: {
docName: '',
docType: '',
docPrincipals: '',
docRespDept: '',
docSource: ''
},
// 表单校验
rules: {
docType: [
{ required: true, message: "类别不能为空", trigger: "blur" }
],
docSource: [
{ required: true, message: "文档来源不能为空", trigger: "blur" }
]
},
docCategoryRules: {
categoryName: [
{ required: true, message: "分类名称不能为空", trigger: "blur" }
],
createBy: [
{ required: true, message: "创建人名称不能为空", trigger: "blur" }
],
createById: [
{ required: true, message: "创建人id不能为空", trigger: "blur" }
],
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
],
},
docCategoryTitle: "",
docCategoryOpen: false,
// 文档资源参数
docCategoryForm: {
categoryName: null,
categoryDescription: null,
parentId: null
},
loadingDownload: false,
acceptType: "zip,rar,7z",
//导出属性
columnList: ['docCode', 'docName', 'docType', 'docPrincipals', 'docRespDeptName', 'docSource', 'toolName', 'docStatus', 'createTime'],
checkList: [],
exportDrawerOpen: false,
};
},
created() {
this.getList();
this.getDeptTree();
this.getDocumentTree();
},
methods: {
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then(response => {
this.deptOptions = response.data;
});
},
/** 查询树形下拉树结构 */
getDocumentTree() {
documentTree().then(response => {
this.docCategory = response.data;
});
},
// 筛选节点
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
// 节点单击事件
handleNodeClick(data) {
this.queryParams.docCategoryId = data.id;
this.handleQuery();
},
/** 查询列表 */
getList() {
let self = this
self.loading = true;
listDocument(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
self.docList = response.rows;
self.total = response.total;
self.loading = false;
}
).catch(err=>{
console.error("getList=======", err)
self.loading = false;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.queryParams.docCategoryId = '';
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.open = true
this.$nextTick(()=>{
this.$refs.editDocumentRef.resetForm();
})
},
handleEdit(row){
this.open = true
this.$nextTick(()=>{
this.$refs.editDocumentRef.editInit(row.docId, "edit");
})
},
handlePreview(row){
this.previewUrl = process.env.VUE_APP_TOOL_TECH_FILE_VIEW_API + '/onlinePreview?url=' + encodeURIComponent(Base64.encode(process.env.VUE_APP_BASE_API + row.docUrl));
this.viewDialogTitle = '文档在线预览'
this.viewDialogOpen = true;
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.docId)
this.single = selection.length!=1
this.multiple = !selection.length
},
editDocumentSubmit: function() {
this.open = false;
this.getList();
},
/** 删除按钮操作 */
handleDelete(row) {
const docIds = row.docId || this.ids;
this.$modal.confirm('是否确认删除?').then(function() {
return delDocument(docIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch((err) => {console.error(err)});
},
/** 新增按钮操作 */
handleDocCategoryAdd(data) {
this.docCategoryOpen = true;
// this.docCategoryForm.parentId = data.id;
this.$nextTick(() => {
this.resetDocCategoryForm();
this.docCategoryForm.parentId = data.id;
})
this.docCategoryTitle = "添加文档资源分类";
},
/** 删除按钮操作 */
handleDocCategoryDelete(row) {
this.$modal.confirm('是否删除该项数据?').then(function() {
return delCategory(row.id);
}).then(() => {
this.getDocumentTree();
this.$modal.msgSuccess("删除成功");
}).catch((err) => {
console.error("err============", err)
});
},
/** 修改按钮操作 */
handleDocCategoryUpdate(row) {
this.resetDocCategoryForm();
const id = row.id;
getCategory(id).then(response => {
this.docCategoryForm = response.data;
this.docCategoryOpen = true;
this.docCategoryTitle = "修改文档资源分类";
});
},
/** 提交按钮 */
docCategorySubmitForm() {
this.$refs["docCategoryForm"].validate(valid => {
if (valid) {
if (this.docCategoryForm.id != null) {
updateCategory(this.docCategoryForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.docCategoryOpen = false;
this.getDocumentTree();
});
} else {
this.$set(this.docCategoryForm, "type", "user")
addCategory(this.docCategoryForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.docCategoryOpen = false;
this.getDocumentTree();
});
}
}
});
},
// 取消按钮
docCategoryCancel() {
this.docCategoryOpen = false;
this.resetDocCategoryForm();
},
/** 重置 **/
resetDocCategoryForm(){
this.$refs.docCategoryForm.resetFields();
},
/**
* 处理下载
* **/
handleDownload(row){
let self = this
self.loadingDownload = true
this.$download.resource(row.docUrl);
setTimeout(()=>{
self.loadingDownload = false
},1000)
},
/** 删除按钮操作 */
handlePush(row) {
const docIds = row.docId || this.ids;
this.$modal.confirm('是否确认发布?').then(function() {
return pushDoc(docIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("发布成功");
}).catch((err) => {
console.error(err)
});
},
docCancel(){
this.$refs.editDocumentRef.resetForm();
this.open = false
},
previewAuth(row){
if(row.docUrl == null || row.docUrl == '' || row.docUrl == undefined){
return false
}
let extension = this.getExtension(row.docUrl);
const acceptedExtensions = this.acceptType.toLowerCase().split(',');
if(acceptedExtensions.includes(extension)){
return false
}
return true
},
getExtension(filePath) {
// 分割字符串,以 '.' 为分隔符
const parts = filePath.split('.');
// 取最后一个部分作为后缀名
const extension = parts.pop();
return extension;
},
isSelectable(row) {
return row.docStatus !== 'yfb' && row.docStatus !== 'shz';
},
/** 导出按钮操作 */
handleOpenExport() {
if (this.checkList.length<1) {
this.checkList = JSON.parse(JSON.stringify(this.columnList))
}
this.exportDrawerOpen = true
},
/** 导出按钮操作 */
handleExport() {
let excludeFields = this.columnList.filter(item=>!this.checkList.includes(item))
this.download('/document/export', {
...this.queryParams,
downloadCheck:false,
excludeFields:excludeFields,
}, `文档资源信息数据_${new Date().getTime()}.xlsx`)
},
}
};
</script>