<template>
|
<!-- 文件清单 -->
|
<div class="file-list" style="height: 100%;">
|
<div class="search">
|
<div class="search_thing">
|
<div class="search_label">文件名称:</div>
|
<div class="search_input"><el-input size="small" placeholder="请输入" clearable v-model="componentData.entity.name"
|
@keyup.enter.native="refreshTable()"></el-input></div>
|
</div>
|
<div class="search_thing">
|
<div class="search_label">文件状态:</div>
|
<div class="search_input">
|
<el-select v-model="componentData.entity.state" size="small" @change="refreshTable()">
|
<el-option :label="item.label" :value="item.value" v-for="(item,index) in fileState" :key="index"></el-option>
|
</el-select>
|
</div>
|
</div>
|
<div class="search_thing" style="padding-left: 30px;">
|
<el-button size="small" @click="refresh()">重 置</el-button>
|
<el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
|
</div>
|
<div class="btns" style="padding-left: 30px;">
|
<el-upload :action="action" :multiple="false"
|
accept='.xls,.xlsx' :headers="headers" :on-change="beforeUpload"
|
:on-error="onError" ref='upload' v-if="addPower" :on-success="handleSuccessUp" :show-file-list="false">
|
<el-button size="small" type="primary" :loading="upLoading">导入</el-button></el-upload>
|
</div>
|
</div>
|
<div class="table">
|
<ValueTable ref="ValueTable" :url="$api.manageDocumentList.pageManageDocumentList"
|
:componentData="componentData" :upUrl="$api.manageDocumentList.doManageDocumentList" :delUrl="$api.manageDocumentList.delManageDocumentList" :key="upIndex"/>
|
</div>
|
<el-dialog
|
title="上传"
|
:visible.sync="addDialogVisible"
|
width="1000px" top="3vh">
|
<UpPdfStamp ref="UpPdfStamp" v-if="addDialogVisible" @uploadPDF="uploadPDF" :isUpFile="true" @uploadPDFErr="uploadPDFErr" style="max-height: 85vh;overflow-y: auto;"></UpPdfStamp>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="addDialogVisible = false">取 消</el-button>
|
<el-button type="primary" @click="handleAdd" v-loading="addLoading">确 定</el-button>
|
</span>
|
</el-dialog>
|
<el-dialog
|
title="查看附件"
|
:visible.sync="lookDialogVisible"
|
width="800px" top="5vh" fullscreen>
|
<filePreview v-if="lookDialogVisible" :fileUrl="javaApi+'/word/'+currentInfo.url"
|
:currentFile="{}" style="height: 90vh;overflow-y: auto;"/>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import ValueTable from '../../tool/value-table.vue'
|
import UpPdfStamp from '../../tool/upPdfStamp.vue'
|
import filePreview from '../../tool/file-preview.vue'
|
export default {
|
components: {
|
ValueTable,
|
UpPdfStamp,
|
filePreview,
|
},
|
data() {
|
return {
|
addDialogVisible:false,
|
lookDialogVisible:false,
|
addPower:false,
|
upLoading:false,
|
addLoading:false,
|
componentData: {
|
entity: {
|
name: null,
|
state: null,
|
orderBy: {
|
field: 'createTime',
|
order: 'desc'
|
}
|
},
|
isIndex: true,
|
showSelect: false,
|
select: false,
|
do: [{
|
id: 'update',
|
font: '编辑',
|
type: 'text',
|
method: 'doDiy',
|
field:[]
|
},
|
{
|
id: 'handleUp',
|
font: '上传',
|
type: 'text',
|
method: 'handleUp'
|
},
|
{
|
id: 'handleDown',
|
font: '下载',
|
type: 'text',
|
method: 'handleDown'
|
},
|
{
|
id: 'handleLook',
|
font: '查看附件',
|
type: 'text',
|
method: 'handleLook'
|
}, {
|
id: 'delete',
|
font: '删除',
|
type: 'text',
|
method: 'doDiy'
|
},],
|
tagField: {
|
state:{
|
select: []
|
},
|
type:{
|
select: []
|
},
|
},
|
selectField: {
|
state:{
|
select: []
|
},
|
type:{
|
select: []
|
},
|
},
|
datePicker:['effectiveDate'],
|
addUpload:['signatoryUrl'],
|
requiredAdd: ['documentCode'],
|
requiredUp: ['documentCode'],
|
needSort: [],
|
inputType: ''
|
},
|
entityCopy: {},
|
upIndex: 0,
|
currentInfo:{},
|
fileType:[],
|
fileState:[],
|
}
|
},
|
// 用于上传文件的信息
|
computed: {
|
headers() {
|
return {
|
'token': sessionStorage.getItem('token')
|
}
|
},
|
action() {
|
return this.javaApi +this.$api.manageDocumentList.exportManageDocumentList
|
}
|
},
|
mounted() {
|
this.entityCopy = this.HaveJson(this.componentData.entity);
|
this.getPower()
|
this.selectEnumByCategory()
|
},
|
methods: {
|
// 下载文件
|
handleDown(row) {
|
if(!row.url) return this.$message.warning('文件未上传')
|
let url = this.javaApi+'/word/'+row.url
|
const link = document.createElement('a');
|
link.href = url;
|
link.click();
|
},
|
// 查看文件
|
handleLook(row){
|
if(!row.url) return this.$message.warning('文件未上传')
|
this.currentInfo = row
|
this.lookDialogVisible = true
|
},
|
getPower(){
|
let power = JSON.parse(sessionStorage.getItem('power'))
|
let up = false
|
let upFile = false
|
let add = false
|
for (var i = 0; i < power.length; i++) {
|
if (power[i].menuMethod == 'doManageDocumentList') {
|
up = true
|
}
|
if (power[i].menuMethod == 'exportManageDocumentList') {
|
add = true
|
}
|
if (power[i].menuMethod == 'uploadFileManageDocumentList') {
|
upFile = true
|
}
|
}
|
if (!upFile) {
|
this.componentData.do.splice(1, 1)
|
}
|
if (!up) {
|
this.componentData.do.splice(0, 1)
|
}
|
this.addPower = add
|
},
|
refreshTable() {
|
this.$refs['ValueTable'].selectList()
|
},
|
refresh() {
|
this.componentData.entity = this.HaveJson(this.entityCopy)
|
this.upIndex++
|
this.refreshTable()
|
},
|
// 上传文件
|
handleUp(row) {
|
this.currentInfo = row
|
this.addDialogVisible = true;
|
},
|
// 提交上传
|
handleAdd(){
|
this.addLoading = true
|
this.$refs['UpPdfStamp'].generatePDF()
|
},
|
uploadPDFErr(){
|
this.addLoading = false
|
},
|
beforeUpload(file) {
|
if (file.size > 1024 * 1024 * 10) {
|
this.$message.error('上传文件不超过10M');
|
this.$refs.upload.clearFiles()
|
return false;
|
} else {
|
// this.upLoading = true;
|
return true;
|
}
|
},
|
onError(err, file, fileList) {
|
this.$message.error('上传失败')
|
this.$refs.upload.clearFiles()
|
},
|
handleSuccessUp(response) {
|
this.upLoading = false;
|
if (response.code == 200) {
|
this.$message.success('上传成功');
|
this.refreshTable()
|
}
|
},
|
selectEnumByCategory() {
|
this.$axios.post(this.$api.enums.selectEnumByCategory, {
|
category: "文件类别"
|
}).then(res => {
|
this.fileType = res.data
|
this.componentData.tagField.type.select = this.fileType
|
this.componentData.selectField.type.select = this.fileType
|
})
|
this.$axios.post(this.$api.enums.selectEnumByCategory, {
|
category: "文件状态"
|
}).then(res => {
|
this.fileState = res.data
|
this.componentData.tagField.state.select = res.data
|
this.componentData.selectField.state.select = res.data
|
})
|
},
|
async uploadPDF(pdfBlob) {
|
const formData = new FormData();
|
formData.append('file', pdfBlob, this.fileName+'.pdf'); // 文件字段
|
formData.append('id', this.currentInfo.id); // 文件名字段
|
|
let res = await this.$axios.post(this.$api.manageDocumentList.uploadFileManageDocumentList, formData,{
|
headers: {
|
'Content-Type': 'multipart/form-data;'
|
},
|
noQs: true
|
})
|
this.addLoading = false
|
if(res.code==200){
|
this.$message({ message: '上传成功', type: 'success' });
|
this.addDialogVisible = false;
|
this.refreshTable()
|
return true
|
}else{
|
this.$message({ message: '上传失败', type: 'error' });
|
return false
|
}
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.title {
|
height: 60px;
|
line-height: 60px;
|
}
|
.search {
|
background-color: #fff;
|
height: 40px;
|
display: flex;
|
align-items: center;
|
position: relative;
|
}
|
|
.search_thing {
|
width: 350px;
|
display: flex;
|
align-items: center;
|
}
|
|
.search_label {
|
width: 110px;
|
font-size: 14px;
|
text-align: right;
|
}
|
|
.search_input {
|
width: calc(100% - 110px);
|
}
|
|
.table {
|
background-color: #fff;
|
width: calc(100% - 40px);
|
height: calc(100% - 60px - 80px);
|
padding: 20px;
|
}
|
.btns{
|
position: absolute;
|
right: 20px;
|
top: 5px;
|
}
|
</style>
|