Commit 0f55b6f8 authored by jingnan's avatar jingnan 👀

删除doc下多余的文件

parent 48744718
/**
* @Description: 流程历史记录
* @author wx
* @date 2020/12/28
*/
<template>
<div class="porcess-history-record-com">
<dee-table
:options="optionsTree"
:data="historyRecordData"
:columns="historyColumns"
/>
</div>
</template>
<script>
import { getWFInsts, instDetail } from '@/api/workflow'
export default {
name: 'DxDocumentProcessHistory',
// displayName: '流程历史记录',
// modelRelationObjs: ['DxDocument', 'DxPart', 'DxBaseline', 'DxAbstractChangeIssue',
// 'DxChangeItem', 'DxProcessExecutor', 'ExtECM', 'DxCADDocument'],
props: {
basicData: {
type: Object,
required: true,
defalut: () => {}
},
modelName: {
type: String,
default: () => ''
}
},
data() {
return {
historyRecordData: [],
historyColumns: [
{ title: '流程名称', key: 'name', minWidth: 150, align: 'center' },
{ title: '任务名称', key: 'taskName', minWidth: 100, align: 'center' },
{ title: '状态', key: 'status', width: 80, align: 'center' },
{ title: '工作责任人', key: 'assigneeName', width: 120, align: 'center' },
{ title: '角色', key: 'participantInfo.pluginShowContent', minWidth: 80, align: 'center', formatter: function(row, column) {
return row.participantInfo ? row.participantInfo.pluginName === 'authOrg' ? '授权部门' : row.participantInfo.pluginShowContent : '/'
} },
{ title: '开始时间', key: 'startTime', width: 150, align: 'center' },
{ title: '完成时间', key: 'endTime', width: 150, align: 'center' },
{ title: '处理结果', key: 'result', minWidth: 100, align: 'center' },
{ title: '备注', key: 'comments', align: 'center', minWidth: 100, formatter: function(row, column) {
return row.comments ? row.comments.join('\n') : ''
} }
],
optionsTree: {
fit: true,
defaultExpandAll: true,
highlightCurrentRow: true,
rowKey: 'id'
},
pagination: {
currentPage: 1,
pageSize: 10,
total: 0,
pageSizes: [10, 20, 50]
}
}
},
computed: {
},
watch: {
basicData: {
immediate: true,
deep: true,
handler: function(val) {
if (val && val.dxClassname) {
this.getWFInsts()
}
}
}
},
mounted() {
},
methods: {
translateStatus(status) {
let str = ''
switch (status) {
case 'COMPLETE':
str = '已完成'
break
case 'BE_RESOLVED':
str = '待处理'
break
case 'PENDING':
str = '被委托人待处理'
break
case 'RUNNING':
str = '进行中'
}
return str
},
getWFInsts() {
getWFInsts({ pboClass: this.basicData.dxClassname, pboId: this.basicData.versionId || this.basicData.id }).then(res => {
if (res.items.content && res.items.content.length) {
this.historyRecordData = []
res.items.content.forEach((item, index) => {
instDetail(item.id).then(data => {
const findItem = this.historyRecordData.find(r => r.id === item.id)
if (findItem) { return }
this.historyRecordData.push({
id: item.id,
name: item.name,
status: item.status
})
if (data.items && data.items.historyInfo && data.items.historyInfo.length) {
const historyInfo = data.items.historyInfo.map(x => {
const y = JSON.parse(JSON.stringify(x))
y.status = this.translateStatus(x.state)
y.taskName = x.aliasName || x.name
delete y.name
return y
})
this.$set(this.historyRecordData[index], 'children', historyInfo)
}
})
})
}
})
}
}
}
</script>
<style lang='scss'>
</style>
/**
* @Description:
* @author cxg
* @date 2020/07/23
*/
<template>
<div ref="scanFile" class="scan-file-com">
<iframe
v-show="convertSuccess"
frameborder="0"
:src="pdfUrl"
allowfullscreen="true"
webkitallowfullscreen="true"
mozallowfullscreen="true"
oallowfullscreen="true"
msallowfullscreen="true"
style="height:100%;flex:1;width:100%"
/>
<div
v-show="!convertSuccess"
class="full-info"
>
<div class="title">
<span v-show="code==='error'">{{ errorMessage }}</span>
<span v-show="code==='loading'">努力加载中</span>
<span v-show="code==='noFiles'">无浏览文件</span>
<span v-show="code==='noMasterFile'">无合适主文件</span>
<span v-show="code==='noCheckIn'">文件尚未检入</span>
<div v-show="code==='converttings'">
<img class="wait-img" src="/images/waitting.gif">
<div>{{ `正在转换 请等待!!!!!${time}秒后 ` }}<el-button type="text" @click="refresh">刷新</el-button></div>
</div>
<span v-show="code==='convertError'">转换失败 <el-button type="text" @click="reconvert">再次转换</el-button><el-button type="text" @click="refresh">刷新</el-button></span>
</div>
</div>
<div v-show="showOtherFiles" class="show-files-btn">
<el-button type="text" title="查看其他PDF" icon="el-icon-more" @click="drawer=true" />
</div>
<transition name="slideFade">
<div v-if="drawer" transiton="slideFade" class="slideFade">
<div class="el-dialog__header">
<span class="el-dialog__title">文件列表</span>
<button type="button" aria-label="Close" class="el-dialog__headerbtn" @click="()=>{drawer=false}"><i class="el-dialog__close el-icon el-icon-d-arrow-left" /></button>
</div>
<ul class="files-list">
<li v-for="file in filesList" :key="file.id" :class="[fileId===file.fileId?'active':'']" :title="file.name" @click="showFile(file)">
{{ file.name }}
</li>
</ul>
</div>
</transition>
</div>
</template>
<script>
import { get, post } from '@/utils/http'
export default {
name: 'DxDocumentScanFile',
displayName: '浏览',
modelRelationObjs: ['DxPart', 'DxDocument', 'DxProcessPlan', 'DxProcessOperation'],
props: {
basicData: {
type: Object,
required: true,
defalut: () => {}
},
modelName: {
type: String,
default: () => ''
},
permissions: {
type: [Object, Array],
defalut: () => null
},
cmpOptions: {
type: Object,
default: () => null
}
},
data() {
return {
convertSuccess: false,
code: '',
errorMessage: '',
pdfUrl: '',
time: 0,
loadTime: 0,
timer: null,
fileId: '',
taskId: '',
taskStatus: '',
converted: false,
showOtherFiles: false,
filesList: [],
deactivated: false,
drawer: false
}
},
computed: {
contentType() {
if (this.cmpOptions && this.cmpOptions.linksFilter && this.cmpOptions.linksFilter.filter[0]) {
const attr = this.cmpOptions.linksFilter.filter[0].formItems.find(r => r.attrName === 'contentType')
if (attr) {
return attr.attrInput
}
}
return 'SECONDARY'
},
IntervalTime() {
if (this.cmpOptions && this.cmpOptions.linksFilter && this.cmpOptions.linksFilter.filter[0]) {
const attr = this.cmpOptions.linksFilter.filter[0].formItems.find(r => r.attrName === 'IntervalTime')
if (attr) {
return attr.attrInput
}
}
return 15
},
noMainFile() {
if (this.cmpOptions && this.cmpOptions.linksFilter && this.cmpOptions.linksFilter.filter[0]) {
const attr = this.cmpOptions.linksFilter.filter[0].formItems.find(r => r.attrName === 'noMainFile')
if (attr) {
return attr.attrInput === 'true'
}
}
return false
},
funKey() {
if (this.cmpOptions && this.cmpOptions.linksFilter && this.cmpOptions.linksFilter.filter[0]) {
const attr = this.cmpOptions.linksFilter.filter[0].formItems.find(r => r.attrName === 'funKey')
if (attr) {
return attr.attrInput
}
}
return 'docConvert'
}
},
watch: {
basicData: {
immediate: true,
deep: true,
handler: function(val) {
this.getFileId()
}
},
'$store.state.scanFile.reLoadFile': {
handler: function(val) {
if (val && this.basicData) {
this.getFileId()
}
}
}
},
mounted() {
this.$utils.setFullPanel(this.$el)
},
deactivated() {
this.deactivated = true
this.timer && clearTimeout(this.timer)
},
activated() {
this.deactivated = false
},
destroyed() {
this.timer && clearTimeout(this.timer)
},
methods: {
showFile(file) {
if (file && file.fileId) {
this.getPdf(file.fileId)
} else {
this.convertSuccess = false
}
},
reconvert() {
post(`/DxTaskMessage/reAction?taskId=${this.taskId}`).then(res => {
this.refresh()
})
},
refresh() {
this.code = 'converttings'
clearTimeout(this.timer)
this.time = this.IntervalTime
this.wait()
},
getFileId() {
if (!this.basicData || !this.basicData.id) {
return
}
if (!this.modelName) {
return
}
this.getDetailWithRecursion({ id: this.basicData.id, openProps: ['objFileLinks.target'], url: `/${this.modelName}/find/recursion` }).then(res => {
if (res.items && res.items.content[0] && res.items.content[0].objFileLinks) {
const files = this.filterFile(res.items.content[0].objFileLinks)
if (files) {
if (files.length > 1) {
this.showOtherFiles = true
this.filesList = files.map(r => {
return {
fileId: r.target.id,
name: r.target.originalFileName
}
})
}
if (this.noMainFile) { // 没有设置主文件
if (files.length) {
this.getPdf(files[0].target.id)
} else {
this.code = 'noFiles'
}
return
}
const masterFile = files.find(file => file.contentType === 'DOC_PDF_FILE')
if (!masterFile) {
this.getConvertState()
this.showOtherFiles = true
this.filesList = files.map(r => {
return {
fileId: r.target.id,
name: r.target.originalFileName
}
})
this.filesList.unshift({
fileId: '',
name: '主文件'
})
} else {
this.getPdf(masterFile.target.id)
}
return
}
}
this.getConvertState()
}).catch(err => {
this.code = 'error'
this.errorMessage = err.mesage
})
},
filterFile(list) {
// 只显示配置类型中的dpf文档
return list.filter(r => r.target && r.target.fileExtension === 'pdf' && (this.contentType.includes(r.contentType)))
},
getDetailWithRecursion({ id, openProps = [], url = '' }) {
const params = {
'openProps': [],
'pageFrom': 1,
'pageSize': 10,
'searchItems': {
'children': [],
'items': [
{
'fieldName': 'id',
'operator': 'EQ',
'value': parseInt(id)
}
],
'operator': 'AND'
}
}
params.openProps = this.$utils.getOpenPropsByLists(openProps)
return post(url, params)
},
getPdf(fileId) {
if (!fileId) {
return
}
if (this.fileId === fileId) {
return
}
this.fileId = fileId
this.code = 'loading'
this.convertSuccess = false
get('/dfs/fileManager/download', { fileId: fileId }).then(res => {
this.convertSuccess = true
if (res.items.fileBase64) {
// this.pdfUrl = 'pdf/web/viewer.html?file=/test.pdf'
this.pdfUrl = `pdf/web/viewer.html?file=${window.URL.createObjectURL(new Blob([this.base64ToUint8Array(res.items.fileBase64)]))}`
this.$store.dispatch('scanFile/setReLoadFile', false)
}
}).catch(err => {
this.code = 'error'
this.errorMessage = err.message
})
},
base64ToUint8Array(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4)
const base64 = (base64String + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/')
const rawData = window.atob(base64)
const outputArray = new Uint8Array(rawData.length)
for (var i = 0; i < rawData.length; ++i) {
outputArray[i] = rawData.charCodeAt(i)
}
return outputArray
},
waitLoadPDF() {
if (!this.loadTime) {
return
}
this.loadTime--
setTimeout(() => {
this.getFileId()
}, this.IntervalTime * 1000)
},
getConvertState() {
// 状态已显示转换
if (this.converted) {
this.waitLoadPDF()
return
}
get(`/DxTaskMessage/query/lastedByPBO?funKey=${this.funKey}&pboClass=${this.basicData.dxClassname.split('.').slice(-1)[0]}&pboId=${this.basicData.id}`).then(res => {
if (!res.items) {
this.code = 'noMasterFile'
this.timer && clearTimeout(this.timer)
return
}
// 还在转换
if (res.items.taskStatus === 'START') {
this.code = 'converttings'
this.converted = false
this.time = this.IntervalTime
this.wait()
return
}
this.timer && clearTimeout(this.timer)
this.taskId = res.items.id
// 转换成功 读取文件
if (res.items.taskStatus === 'FINISHED') {
this.converted = true
this.loadTime = 5
this.getFileId()
return
}
// 转换失败
if (res.items.taskStatus === 'ERROR') {
this.error()
return
}
// 转换暂停
if (res.items.taskStatus === 'STOP') {
this.error()
return
}
}).catch((err) => {
this.code = 'error'
this.timer && clearTimeout(this.timer)
this.errorMessage = err.mesage
})
},
error() {
this.code = 'convertError'
},
wait() {
this.timer && clearTimeout(this.timer)
this.timer = setTimeout(() => {
this.time--
if (this.deactivated) {
return
} else if (this.time === 0) {
this.getConvertState()
clearTimeout(this.timer)
} else {
this.wait()
}
}, 1000)
}
}
}
</script>
<style lang='scss'>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment