附件上传调整

This commit is contained in:
pan 2024-09-05 08:57:44 +08:00
parent e9c7b39f1b
commit 2a933ea8cb
9 changed files with 663 additions and 91 deletions

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询附件列表
export function listAttachment(query) {
return request({
url: '/system/attachment/list',
method: 'get',
params: query
})
}
// 查询附件详细
export function getAttachment(id) {
return request({
url: '/system/attachment/' + id,
method: 'get'
})
}
// 新增附件
export function addAttachment(data) {
return request({
url: '/system/attachment',
method: 'post',
data: data
})
}
// 修改附件
export function updateAttachment(data) {
return request({
url: '/system/attachment',
method: 'put',
data: data
})
}
// 删除附件
export function delAttachment(id) {
return request({
url: '/system/attachment/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,396 @@
<template>
<div>
<el-upload class="upload-demo" ref="upload" action="#"
:before-upload="beforeUpload"
:on-change="onChange"
:on-remove="handleRemove"
:multiple="isMultiple"
:on-exceed="handleExceed"
:accept="acceptType"
:file-list="fileList"
:auto-upload="true"
:http-request="uploadFile"
show-file-list>
<el-button slot="trigger" size="small" type="primary" @click="isFolder = false">选取文件</el-button>
<el-button size="small" type="primary" @click="handleUploadFile" >
上传文件夹
</el-button>
<!-- 上传-->
<input v-show="false" ref="fileRef" id="fileFolder" type="file" @change="handleFolderUpload" webkitdirectory
multiple="multiple" />
<!-- <input v-show="false" type="file" ref="fileRef" webkitdirectory @change="handleFolderUpload">
<el-button slot="trigger" size="small" type="primary">选取文件夹</el-button>-->
</el-upload>
<!-- <div slot="tip" class="el-upload__tip" >只能上传{{acceptType}}文件</div>-->
<div v-show="progressFlag" class="head-img">
<el-progress :text-inside="true" :stroke-width="14" :percentage="progressPercent" status="success"></el-progress>
</div>
</div>
</template>
<script>
import axios from 'axios'
import {
getToken
} from "@/utils/auth";
import JSZip from 'jszip'
export default {
props: {
uploadUrl: {
type: String,
required: false
},
//
isMultiple: {
type: Boolean,
default() {
return false
},
required: false
},
//
type: {
type: Array,
default() {
return []
},
required: false
},
//
acceptType: {
type: String,
required: false
},
//
limit: {
type: Number,
default() {
return 1
},
required: false
},
//
dataFile: {
type: [Object, Array, String],
default() {
return ''
},
required: false
},
isDetail: {
type: Boolean,
default: false
},
},
data() {
return {
fileList: [],
progress: 0,
isUploading: false,
progressFlag: false, //
progressPercent: 0, //
partSize: 5 * 1024 * 1024,
fileDetailName: null,
uploadedNum: 0,
_shardCount: null, //
isFolder: false,
};
},
watch: {
dataFile: {
handler(newValue, oldValue) {
if (newValue && newValue.length > 0) {
this.fileList = Array.isArray(newValue) ? newValue : [newValue]
this.fileDetailName = this.fileList[0].name
} else {
this.fileList = []
}
},
immediate: true
}
},
methods: {
//
beforeUpload(file) {
/* const fileType = file.type.toLowerCase()
console.info("fileType=======", fileType)
const typeFlag = this.type.some(item => {
return fileType.indexOf(item) != -1
})
if (!typeFlag) {
this.$message.error('上传类型有误,请重新上传')
return false
}*/
},
//
onChange(file, fileList) {
this.fileList = fileList;
},
handleRemove(file, fileList) {
this.fileList = fileList;
},
handleExceed(files, fileList) {
/* this.$message.warning(
"最多之能上传"+ this.limit +"个附件"
); */
},
async uploadFile({ data, file }) {
let self = this
//
if (file.size < this.partSize) {
let formData = new FormData()
formData.append("file", file)
self.progressFlag = true;
axios({
url: self.uploadUrl,
method: 'post',
data: formData,
headers: {
'Authorization': 'Bearer ' + getToken(),
'Content-Type': 'multipart/form-data'
},
onUploadProgress: progressEvent => {
// progressEvent.loaded:
// progressEvent.total:
//
self.progressPercent = ((progressEvent.loaded / progressEvent.total) * 100) | 0;
}
}).then(res => {
console.info("11111111uploadFile1111111")
setTimeout(() => {
if (res.data.code == 200) {
setTimeout(function () {
//
if(self.isFolder){
self.fileList.push(file)
}
self.$message({
message: '上传成功!',
type: 'success',
duration: '2000'
});
self.progressFlag = false;
self.progressPercent = 0
self.handleResult(res,file);
}, 500);
} else {
console.info("11111上传失败11111", error)
self.progressFlag = false;
self.$message({
message: '上传失败!',
type: 'error',
duration: '2000'
});
}
}, 1000);
}).catch(error => {
console.info("1111111uploadFile1uploadFile1111111", error)
console.error(error)
self.progressFlag = false;
self.progressPercent = 0
self.$refs.upload.clearFiles();
self.$message({
message: '上传失败!',
type: 'error',
duration: '2000'
});
})
} else {
self.uploadedNum = 0
file._shardCount = Math.ceil(file.size / this.partSize) //
file.uploaded = 0
let formData = new FormData()
formData.append('fileName', file.name)
//,uploadId initUpload(formData)
axios({
url: process.env.VUE_APP_BASE_API + "/common/initUpload",
method: 'post',
data: formData,
headers: {
'Authorization': 'Bearer ' + getToken(),
'Content-Type': 'multipart/form-data'
},
}).then(function (res) {
console.info("222222222upload222")
if (res.status == 200) {
//0
file.uploadId = res.data.uploadId
file.objectKey = res.data
file.chunkId = 0
self.uploadByChunk(file)
} else {
this.progress--
self.$message.error(res.msg)
}
}).catch(error => {
self.progressPercent = 0
self.progressFlag = false;
console.error(error)
})
}
},
//
uploadByChunk(file) {
this._start = file.chunkId * this.partSize
this._end = Math.min(file.size, this._start + this.partSize)// +
let self = this
let fileData = file.slice(this._start, this._end)
//MD5
let reader = new FileReader()
reader.readAsBinaryString(fileData)
let form1 = new FormData()//newform
form1.append('chunkFile', fileData) //slice
form1.append('uploadId', file.uploadId)
form1.append('chunkId', (file.chunkId + 1).toString())
form1.append('shardCount', file._shardCount.toString()) //
self.progressFlag = true;
//Chunk chunkMD5 uploadChunk(form1)
axios({
url: process.env.VUE_APP_BASE_API + "/common/uploadChunk",
method: 'post',
data: form1,
headers: {
'Authorization': 'Bearer ' + getToken(),
'Content-Type': 'multipart/form-data'
},
}).then(response => {
if (response.status == 200) {
//MD5MD5
// self.md5Str[index] === response.msg ||
if (true) {
// this.$message.success('' + (index + 1).toString() + '')
self.uploadedNum++
let percent = Math.floor((self.uploadedNum / file._shardCount) * 100)
self.percentageSend(file, percent)
//
file.chunkId++
if (file.chunkId < file._shardCount) {
this.uploadByChunk(file)
}
} else {
//
this.$message.success('第' + (file.chunkId + 1).toString() + '块文件上传不成功,重新上传')
this.uploadByChunk(file.chunkId)
}
} else {
//
this.progress--
this.$message.error(response.msg)
}
})
},
//
percentageSend(file, perNum) {
let self = this
self.progressPercent = perNum
//
if (perNum === 100) {
let form2 = new FormData()//newform
form2.append('uploadId', file.uploadId)
form2.append('fileName', file.name)
//
// 访URL
axios({
url: process.env.VUE_APP_BASE_API + "/common/mergeFile",
method: 'post',
data: form2,
headers: {
'Authorization': 'Bearer ' + getToken(),
'Content-Type': 'multipart/form-data'
},
}).then(res => {
if (res.status == 200) {
setTimeout(function () {
self.$message({
message: '上传成功!',
type: 'success',
duration: '2000'
});
self.progressFlag = false;
self.progressPercent = 0
self.handleResult(res,file);
}, 500);
//
if(self.isFolder){
self.fileList.push(file)
}
} else {
self.progressFlag = false;
self.$message({
message: '上传失败!',
type: 'error',
duration: '2000'
});
}
})
}
},
resetData() {
this.progress = 0;
},
handleResult(res, file) {
let self = this
const data = {
fileName: file.name,
fileSize: file.size,
fileUrl: res.data.filePath,
filePath: res.data.filePath,
fileOldName: res.data.originalFilename,
fileNewName: res.data.newFileName,
suffixType: res.data.suffixType
}
self.$emit("handleSuccess", data)
self.clearFile()
},
/** 清空文件 **/
clearFile(){
this.progressFlag = false;
if(this.$refs.upload){
this.$refs.upload.clearFiles();
}
this.fileList = []
},
handleUploadFile() {
document.getElementById("fileFolder").value = null;
this.$refs.fileRef.dispatchEvent(new MouseEvent("click"));
},
async handleFolderUpload(event) {
let self = this;
self.isFolder = true
const files = event.target.files;
self.fileslength = files.length;
let filesper = Math.floor( 100 / files.length * 100)/100;
self.progressShow = true;
if (self.fileslength == 0) {
self.progressShow = false;
self.$modal.msg("上传完成0个未完成0个");
}
for (const file of files) {
let temp = {
"data": null,
"file": file
}
await self.uploadFile(temp);
}
/* console.info("files=========", files)
let fileListTemp = []
for(let item of files){
fileListTemp.push(item);
}
self.fileList = fileListTemp; */
/* files.for()
self.onChange(null, files); */
// self.fileList = files;
// this.$refs.fileRef.value = null;
},
}
};
</script>

View File

@ -4,7 +4,9 @@
:visible.sync="visible"
:close-on-click-modal="false"
width="80%"
append-to-body>
append-to-body
:show-close="false"
>
<div class="el-card__body">
<el-form :model="queryParams" ref="queryForm" v-show="showSearch" label-width="68px" :inline="true">
<el-form-item label="工具编号" prop="toolCode">

View File

@ -230,7 +230,7 @@
<i-frame :src="previewUrl" v-if="viewDialogOpen"/>
</el-dialog>
<el-drawer :visible.sync="open" :modal-append-to-body="false" size="75%">
<el-drawer :visible.sync="open" :modal-append-to-body="false" size="75%" :show-close="false">
<template #title>
<span class="title">{{docTitle}}</span>
<div class="drawer-head-btn" v-if="docDetailDisable">
@ -524,6 +524,10 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const docIds = row.docId || this.ids;
if(docIds == null || docIds == undefined || docIds =='' || docIds.length < 0){
this.$modal.msgError(`最少选择一条数据`);
return;
}
this.$modal.confirm('是否确认删除?').then(function() {
return delDocument(docIds);
}).then(() => {
@ -611,9 +615,13 @@ export default {
self.loadingDownload = false
},1000)
},
/** 删除按钮操作 */
/** 发布操作 */
handlePush(row) {
const docIds = row.docId || this.ids;
if(docIds == null || docIds == undefined || docIds =='' || docIds.length < 0){
this.$modal.msgError(`最少选择一条数据`);
return;
}
this.$modal.confirm('是否确认发布?').then(function() {
return pushDoc(docIds);
}).then(() => {

View File

@ -3,23 +3,11 @@
<div class="fl">
<el-tabs v-model="detailActiveName">
<el-tab-pane label="文件信息" name="first">
<el-table :data="docList" style="width: 100%">
<el-table-column label="文档名称" prop="docName" :show-overflow-tooltip="true" />
<el-table-column label="类别" 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="负责人" 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="来源" 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 :data="attachmentList" style="width: 100%">
<el-table-column label="附件名称" prop="fileName" :show-overflow-tooltip="true" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
<span>{{ parseTime(scope.row.createDate) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="180" v-if="toolDetail.downloadStatus">
@ -54,6 +42,7 @@
import editDocument from "../document/editDocument";
import { Base64 } from 'js-base64';
import iFrame from "@/components/iFrame/index"
import { listAttachment } from "@/api/attachment/attachment";
export default {
name: 'toolDetail',
@ -68,7 +57,7 @@
data(){
return{
detailActiveName: 'first',
docList: [],
attachmentList: [],
queryParams: {
pageNum: 1,
pageSize: 10,
@ -91,7 +80,7 @@
}
},
created(){
this.getDocList()
this.getAttachmentList()
this.getDiscussionsList()
},
watch: {
@ -101,11 +90,12 @@
}
},
methods:{
getDocList() {
getAttachmentList() {
this.loading = true;
this.queryParams.toolId = this.toolDetail.toolId
listDocument(this.queryParams).then(response => {
this.docList = response.rows;
this.$set(this.queryParams,'del',"0")
this.$set(this.queryParams,'businessId',this.toolDetail.toolId)
listAttachment(this.queryParams).then(response => {
this.attachmentList = response.rows;
this.total = response.total;
this.loading = false;
}
@ -116,7 +106,7 @@
},
editDocumentSubmit(){
this.open = false
this.getDocList()
this.getAttachmentList()
},
handlePriew(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));
@ -139,12 +129,15 @@
handleDownload(row){
let self = this
self.loadingDownload = true
this.$download.resource(row.docUrl);
this.$download.resource(row.fileUrl);
//
if(this.toolDetail.toolId){
if(row.businessId){
let formData = {
toolId: this.toolDetail.toolId
'businessId': row.businessId,
'businessType': 'tool',
'attId': row.id,
'attName': row.fileOldName
}
addCount(formData).then(res => {
});

View File

@ -614,6 +614,7 @@ export default {
handleDelete(list){
let _this = this
if (!list||list.length<1) {
this.$modal.msgError(`最少选择一条数据`);
return
}
_this.$modal.confirm('删除后,该流程待办任务将会被删除,请谨慎操作。是否确认执行?')

View File

@ -30,9 +30,9 @@
</div><!--el-form-border 表单-->
</el-tab-pane><!--el-tab-pane-->
<el-tab-pane label="关联文件" name="second">
<el-table :data="docList" style="width: 100%">
<el-table-column label="文档名称" prop="docName" :show-overflow-tooltip="true" />
<el-table-column label="类别" prop="docType" :show-overflow-tooltip="true" width="80" >
<el-table :data="attachmentList" style="width: 100%">
<el-table-column label="附件名称" prop="fileName" :show-overflow-tooltip="true" />
<!-- <el-table-column label="类别" prop="docType" :show-overflow-tooltip="true" width="80" >
<template slot-scope="scope">
<dict-tag :options="dict.type.doc_class" :value="scope.row.docType"/>
</template>
@ -43,10 +43,10 @@
<template slot-scope="scope">
<dict-tag :options="dict.type.doc_source" :value="scope.row.docSource"/>
</template>
</el-table-column>
</el-table-column>-->
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
<span>{{ parseTime(scope.row.createDate) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="180" v-if="detailData.downloadStatus">
@ -55,7 +55,8 @@
size="mini"
type="text"
icon="el-icon-view"
@click="handlePriew(scope.row)"
v-if="previewAuth(scope.row)"
@click="handlePreview(scope.row)"
>预览</el-button>
<el-button type="text" icon="el-icon-download" @click="handleDownload(scope.row)" v-loading="loadingDownload">下载</el-button>
</template>
@ -121,7 +122,7 @@
</el-dialog>
<!-- 上传 -->
<AddDoc :show.sync="open" :toolId="detailData.toolId" @callback="getDocList"/>
<AddDoc :show.sync="open" :toolId="detailData.toolId" @callback="getAttachmentList"/>
</div><!--fbox1 左右分栏-->
</template>
@ -135,6 +136,8 @@
import editDocument from "../document/editDocument";
import { Base64 } from 'js-base64';
import iFrame from "@/components/iFrame/index"
import { addCount } from "@/api/tool/downloadCount";
import { listAttachment } from "@/api/attachment/attachment";
export default {
name: 'toolDetail',
@ -150,7 +153,7 @@
data(){
return{
detailActiveName: 'first',
docList: [],
attachmentList: [],
queryParams: {
pageNum: 1,
pageSize: 10,
@ -172,12 +175,13 @@
replyContent: [],
detailLoading: false,
//
detailData:{}
detailData:{},
attFileType: "zip,rar,7z",
}
},
created(){
this.getDetail()
this.getDocList()
this.getAttachmentList()
this.getDiscussionsList()
},
watch: {
@ -187,11 +191,12 @@
}
},
methods:{
getDocList() {
getAttachmentList() {
this.loading = true;
this.queryParams.toolId = this.toolDetail.toolId
listDocument(this.queryParams).then(response => {
this.docList = response.rows;
this.$set(this.queryParams,'del',"0")
this.$set(this.queryParams,'businessId',this.toolDetail.toolId)
listAttachment(this.queryParams).then(response => {
this.attachmentList = response.rows;
this.total = response.total;
this.loading = false;
}
@ -202,9 +207,9 @@
},
editDocumentSubmit(){
this.open = false
this.getDocList()
this.getAttachmentList()
},
handlePriew(row){
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;
@ -225,7 +230,20 @@
handleDownload(row){
let self = this
self.loadingDownload = true
this.$download.resource(row.docUrl);
this.$download.resource(row.fileUrl);
//
if(row.businessId){
let formData = {
'businessId': row.businessId,
'businessType': 'tool',
'attId': row.id,
'attName': row.fileOldName
}
addCount(formData).then(res => {
});
}
setTimeout(()=>{
self.loadingDownload = false
},1000)
@ -391,7 +409,25 @@
}).finally(()=>{
self.detailLoading = false
});
},
previewAuth(row){
if(row.fileUrl == null || row.fileUrl == '' || row.fileUrl == undefined){
return false
}
let extension = this.getExtension(row.fileUrl);
const acceptedExtensions = this.attFileType.toLowerCase().split(',');
if(acceptedExtensions.includes(extension)){
return false
}
return true
},
getExtension(filePath) {
// '.'
const parts = filePath.split('.');
//
const extension = parts.pop();
return extension;
},
}
}
</script>

View File

@ -72,6 +72,25 @@
</el-form-item>
</el-col>
</el-row>
<!-- <el-row>
<el-col :span="12">
<el-form-item label="负责人" prop="toolPrincipals">
<el-input v-if="editStatus" v-model="form.toolPrincipalsName" placeholder="请选择负责人"
maxlength="11" @focus="toolPrincipalsChoose = true"/>
<span v-else>{{form.toolPrincipalsName}}</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="归属部门" prop="toolRespDept">
<treeselect :disabled="!editStatus" v-model="form.toolRespDept" :options="deptOptions"
:multiple="false"
:disable-branch-nodes="true" noOptionsText="暂无数据"
noChildrenText="没有子选项" noResultsText="没有匹配的结果"
@select="handleSelectNode" placeholder="请选择归属部门" />
</el-form-item>
</el-col>
</el-row>-->
<el-row>
<el-col :span="12">
<el-form-item label="工具来源" prop="toolSource">
@ -205,40 +224,37 @@
</div>
<div class="el-form-border">
<div class="operate">
<el-button type="primary" icon="el-icon-upload2" v-if="editStatus" @click="handleDocAdd">上传</el-button>
<!-- <el-form-item label="文件" required>
</el-form-item>
<el-button type="primary" icon="el-icon-upload2" v-if="editStatus" @click="handleDocAdd">上传</el-button>-->
<template v-if="editStatus">
<uploadVue
:display="editStatus"
:uploadUrl="uploadFileUrl"
:type="['.txt','.doc','.docx','.pdf','.mp4','.zip','.rar','.7z','.png','.jpg','.jpeg']"
:acceptType="acceptType"
:isMultiple="true"
:dataFile="dataFile"
:isDetail="detailBoolean"
ref="uploadFile"
@handleSuccess="handleUploadSuccess"
@handleError="handleUploadError"
/>
</template>
<!-- <el-button icon="el-icon-delete">删除</el-button>-->
</div><!--operate 操作按钮-->
<el-table :data="docList" style="width: 100%">
<el-table :data="attachmentList" style="width: 100%">
<!-- <el-table-column type="selection" width="50" align="center"> </el-table-column>-->
<el-table-column label="文档名称" prop="docName" :show-overflow-tooltip="true" />
<el-table-column label="类别" 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="负责人" prop="docPrincipals" :show-overflow-tooltip="true" width="80" />
<el-table-column label="归属部门" prop="docRespDept" :show-overflow-tooltip="true" width="150" >
<template slot-scope="scope">
{{convertDeptName(scope.row)}}
</template>
</el-table-column>
<el-table-column label="来源" 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="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="序号" width="60" type="index"></el-table-column>
<el-table-column label="附件名称" prop="fileName" :show-overflow-tooltip="true" />
<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-view"
v-if="isShowOperation(scope.row)"
v-if="previewAuth(scope.row)"
@click="handlePreview(scope.row)"
>预览</el-button>
<el-button
@ -294,6 +310,7 @@
<script>
import iFrame from "@/components/iFrame/index"
import { listDocument,delDocument } from "@/api/document/document";
import { listAttachment } from "@/api/attachment/attachment";
import processcode from "@/views/workflowList/processcode/index.vue";
import {
workflowprocesskey,
@ -309,6 +326,9 @@ import { addTool, checkToolExist, getInfoByBpmcId, updateTool } from '@/api/tool
import blUserSelector from '@/components/user-selector/src/user-selector.vue'
import ToolSelector from '@/components/tool-selector/index.vue'
import { Base64 } from 'js-base64'
import uploadVue from '@/components/FileUpload/optimizeToolUpload.vue'
import { addCount } from "@/api/tool/downloadCount";
// PDF
export default {
dicts: ['sys_normal_disable','tool_type', 'tool_source', 'tool_status', 'doc_source','doc_class'],
@ -318,7 +338,8 @@ export default {
Treeselect, AddDoc,
WorkflowLogs,
processcode,
iFrame
iFrame,
uploadVue
},
name: "Borrow_doc",
props: ['data'],
@ -339,8 +360,6 @@ export default {
}
return {
toolPrincipalsChoose: false,
//
docList: [],
addDocShow: false,
docQueryParams: {
pageNum: 1,
@ -368,7 +387,9 @@ export default {
userInfo: this.$store.getters.userInfo,
viewShow: false,
monitorDrawerVisible:false,
form: {},
form: {
toolRespDept: this.$store.getters.userInfo.deptId
},
rules: {
toolCode: [
{ required: true, message: "工具编号不能为空", trigger: "blur" },
@ -383,7 +404,7 @@ export default {
{ required: true, message: "负责人不能为空", trigger: "blur" }
],
toolRespDept: [
{ required: true, message: "请选择归属部门", trigger: "change" }
{ required: true, message: "请选择归属部门", trigger: ['blur','change'] }
],
toolSource: [
{ required: true, message: "请选择工具来源", trigger: "change" }
@ -427,6 +448,16 @@ export default {
viewDialogOpen: false,
previewUrl: '',
loadingDownload: false,
//
curDeptId: null,
curDeptName: null,
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", //
acceptType: ".txt,.doc,.docx,.pdf,.mp4,.zip,.rar,.7z,.png,.jpg,.jpeg",
dataFile: [],
detailBoolean: false,
attachmentList: [],
attFileType: "zip,rar,7z",
};
},
computed: {},
@ -438,6 +469,8 @@ export default {
},
},
mounted() {
this.curDeptId = this.$store.getters.userInfo.deptId
this.curDeptName = this.$store.getters.userInfo.dept.deptName
if (this.data) {
this.init(this.data)
}
@ -480,7 +513,7 @@ export default {
getInfoByBpmcId(procInstId).then(async (res) => {
let formData = res.data;
formData.type = _this.form.type
// _this.docList = formData.documentList
// _this.attachmentList = formData.attachmentList
formData.association = JSON.parse(res.data.association)
_this.form = formData
_this.getDocumentList(res.data.toolId)
@ -586,7 +619,7 @@ export default {
formData.association = JSON.stringify(_this.form.association)
formData.toolRespDept = _this.userInfo.dept.deptId
if (formData.toolId) {
this.$set(formData,'documentList',_this.docList)
this.$set(formData,'attachmentList',_this.attachmentList)
updateTool(formData).then((res) => {
if (res.code===200) {
_this.$message({
@ -622,7 +655,7 @@ export default {
review: _this.attributeModelBool('approve'),
};
formData.editStatus = _this.editStatus
this.$set(formData,'documentList',_this.docList)
this.$set(formData,'attachmentList',_this.attachmentList)
addTool(formData).then((res) => {
if (res.code===200) {
_this.form.toolId = res.data.businessKey;
@ -768,7 +801,7 @@ export default {
formData.recordStatus = 'doing'
}
formData.editStatus = _this.editStatus
this.$set(formData,'documentList',_this.docList)
this.$set(formData,'attachmentList',_this.attachmentList)
addTool(formData).then((res) => {
if (res.code===200) {
_this.$message({
@ -792,7 +825,7 @@ export default {
});
},
handleDelete(row){
this.docList.splice(row,1)
this.attachmentList.splice(row,1)
},
/**
* 新增上传附件
@ -805,10 +838,10 @@ export default {
},
getDocumentList(toolId) {
this.loading = true
this.docQueryParams.toolId = toolId
this.$set(this.docQueryParams,'isDeleted',"0")
listDocument(this.docQueryParams).then(res => {
this.docList = res.rows;
this.$set(this.docQueryParams,'del',"0")
this.$set(this.docQueryParams,'businessId',toolId)
listAttachment(this.docQueryParams).then(res => {
this.attachmentList = res.rows;
this.total = res.total;
this.loading = false;
}
@ -822,6 +855,8 @@ export default {
},
handleSelectNode(node){
this.$set(this.form,'toolRespDeptName',node.label)
this.$set(this.form,'toolRespDept',node.id)
this.$refs.eForm.validateField('toolRespDept');
},
toolSelect(){
this.$refs.selectHeadTool.blur();
@ -842,7 +877,7 @@ export default {
/** 添加关联附件数据**/
addFileData(dataInfo){
let document = JSON.parse(JSON.stringify(dataInfo))
this.docList.push(document)
this.attachmentList.push(document)
},
findDeptInTree(tree, id) {
for (const node of tree) {
@ -868,11 +903,29 @@ export default {
},
isShowOperation(row){
let self = this
if(row.docId == null || row.docId == undefined || row.docId == ''){
if(row.businessId == null || row.businessId == undefined || row.businessId == ''){
return false
}
return true
},
previewAuth(row){
if(row.fileUrl == null || row.fileUrl == '' || row.fileUrl == undefined){
return false
}
let extension = this.getExtension(row.fileUrl);
const acceptedExtensions = this.attFileType.toLowerCase().split(',');
if(acceptedExtensions.includes(extension)){
return false
}
return true
},
getExtension(filePath) {
// '.'
const parts = filePath.split('.');
//
const extension = parts.pop();
return extension;
},
handlePreview(row){
this.viewDialogOpen = true;
this.viewDialogTitle = '文档在线预览'
@ -887,15 +940,36 @@ export default {
handleDownload(row){
let self = this
self.loadingDownload = true
this.$download.resource(row.docUrl);
this.$download.resource(row.fileUrl);
//
if(row.businessId){
let formData = {
'businessId': row.businessId,
'businessType': 'tool',
'attId': row.id,
'attName': row.fileOldName
}
addCount(formData).then(res => {
});
}
setTimeout(()=>{
self.loadingDownload = false
},1000)
},
handleBeforeClose() {
this.viewDialogOpen = false
}
},
handleUploadSuccess(res) {
this.attachmentList.push(res)
//
},
handleUploadError(error) {
//
},
},
};
</script>

View File

@ -403,8 +403,26 @@ export default {
this.viewShow = false;
this.$emit("close")
},
//
async saveForm() {
let _this = this
//
_this.activeName = 'info'
if (!_this.procDefKey) {
_this.$message.warning("尚未进行流程设置,将无法发起流程!");
return;
}
let dialogVisible = true
if (!!_this.$refs["eForm"]) {
let valid = await _this.$refs["eForm"].validate()
if (!valid) {
dialogVisible = false
}
}
_this.tempForm()
},
//
saveForm() {
tempForm() {
let _this = this
if (!_this.procDefKey) {
_this.$message.warning("尚未进行流程设置,将无法发起流程!");