462 lines
14 KiB
Vue
462 lines
14 KiB
Vue
<template>
|
|
<div class="fullHeight">
|
|
<div class="searchBox whiteBlock">
|
|
<el-form
|
|
:inline="true"
|
|
size="medium"
|
|
:model="searchForm"
|
|
ref="searchForm"
|
|
>
|
|
<el-form-item
|
|
:label="$t('message.docManage.fileName')"
|
|
prop="fileName"
|
|
class="last"
|
|
>
|
|
<el-input
|
|
v-model="searchForm.fileName"
|
|
:placeholder="$t('message.docManage.placeholder')"
|
|
clearable
|
|
></el-input>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" plain @click="getListData"
|
|
>{{ $t('message.docManage.query') }}
|
|
</el-button>
|
|
<el-button type="warning" plain @click="resetForm">{{
|
|
$t('message.docManage.refresh')
|
|
}}</el-button>
|
|
<el-button
|
|
type="primary"
|
|
@click="
|
|
authorizedDialog = true
|
|
fileList = []
|
|
"
|
|
>
|
|
{{ $t('message.docManage.upload') }}
|
|
</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div class="rightBox">
|
|
<p class="operationText">
|
|
<!--当前已有文件(个):-->
|
|
{{ $t('message.docManage.currentlyExistingFiles') }}
|
|
<span>{{ totalInfo.fileNum }}</span>
|
|
</p>
|
|
<p class="operationText">
|
|
<!--累计下载次数(次):-->
|
|
{{ $t('message.docManage.cumulativeDownloads') }}
|
|
<span>{{ totalInfo.downloadNum }}</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="table_wrap whiteBlock">
|
|
<el-table class="tables" :data="tableData">
|
|
<el-table-column
|
|
type="index"
|
|
width="50"
|
|
align="center"
|
|
:label="$t('message.docManage.table.index')"
|
|
></el-table-column>
|
|
<el-table-column
|
|
prop="fileName"
|
|
:label="$t('message.docManage.table.fileName')"
|
|
align="center"
|
|
>
|
|
<template slot-scope="scope">
|
|
<div class="fileBox">
|
|
<img
|
|
class="fileImg-small"
|
|
:src="parseFileImgFn(scope.row.filePath)"
|
|
alt=""
|
|
srcset=""
|
|
/>
|
|
{{ scope.row.fileName }}
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
prop="companyName"
|
|
:label="$t('message.docManage.table.companyName')"
|
|
align="center"
|
|
></el-table-column>
|
|
<el-table-column
|
|
prop="createTime"
|
|
:label="$t('message.docManage.table.createTime')"
|
|
align="center"
|
|
></el-table-column>
|
|
<el-table-column
|
|
prop="downloadNum"
|
|
:label="$t('message.docManage.table.downloadNum')"
|
|
align="center"
|
|
></el-table-column>
|
|
<el-table-column
|
|
:label="$t('message.docManage.table.operation')"
|
|
align="center"
|
|
width="270"
|
|
>
|
|
<template slot-scope="scope">
|
|
<div class="tableBtns">
|
|
<el-button
|
|
class="operationText"
|
|
@click="downFn(scope.row)"
|
|
type="text"
|
|
size="small"
|
|
>下载附件</el-button
|
|
>
|
|
<!-- <div @click="downFn(scope.row)" class="operationText">
|
|
<a :href="downloadUrl" class="downfn">下载</a>
|
|
</div> -->
|
|
<div @click="editFn(scope.row)" class="operationText">
|
|
<img
|
|
src="@/assets/images/icon-edit.png"
|
|
width="15px"
|
|
height="15px"
|
|
/>
|
|
<span>{{ $t('message.docManage.table.rename') }}</span>
|
|
</div>
|
|
<div @click="deleteFn(scope.row)" class="operationText">
|
|
<img
|
|
src="@/assets/images/icon-delete.png"
|
|
width="15px"
|
|
height="15px"
|
|
/>
|
|
<span>{{ $t('message.docManage.table.delete') }}</span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
<div slot="empty">{{ $t('message.docManage.table.empty') }}</div>
|
|
</el-table>
|
|
<el-pagination
|
|
class="pagerBox"
|
|
@size-change="handleSizeChange"
|
|
@current-change="handleCurrentChange"
|
|
:current-page="pageNo"
|
|
:page-sizes="$store.state.PAGESIZRS"
|
|
:page-size="pageSize"
|
|
layout="total, sizes, prev, pager, next"
|
|
:total="Number(total)"
|
|
background
|
|
></el-pagination>
|
|
</div>
|
|
<el-dialog
|
|
:title="$t('message.docManage.dialog_upload_files.title')"
|
|
:modal-append-to-body="false"
|
|
:visible.sync="authorizedDialog"
|
|
width="667px"
|
|
>
|
|
<div class="dialog_content">
|
|
<el-upload
|
|
class="upload-demo"
|
|
name="files"
|
|
:action="$store.state.UPLOADURL"
|
|
:on-remove="handleRemove"
|
|
:multiple="false"
|
|
:on-exceed="handleExceed"
|
|
:on-success="handleSuccess"
|
|
:file-list="fileList"
|
|
accept=".doc, .docx, .xls, .xlsx, .ppt, .pptx, .pdf"
|
|
>
|
|
<el-button size="medium" type="primary">
|
|
{{ $t('message.docManage.dialog_upload_files.click_upload') }}
|
|
</el-button>
|
|
<div slot="tip" class="el-upload__tip">
|
|
{{ $t('message.docManage.dialog_upload_files.upload_msg') }}
|
|
</div>
|
|
</el-upload>
|
|
<!-- <div class="dialog-footer">
|
|
<el-button class="cancleBtn"
|
|
@click="authorizedDialog = false"
|
|
icon="el-icon-circle-close"
|
|
size="medium"
|
|
>取 消</el-button>
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-circle-check"
|
|
@click="saveFn"
|
|
size="medium"
|
|
>确 定</el-button>
|
|
</div>-->
|
|
</div>
|
|
</el-dialog>
|
|
<el-dialog
|
|
:modal-append-to-body="false"
|
|
:title="$t('message.docManage.dialog_file_renaming.title')"
|
|
:visible.sync="editDialog"
|
|
width="667px"
|
|
>
|
|
<div class="dialog_content">
|
|
<el-form
|
|
size="medium"
|
|
label-width="80px"
|
|
:model="editForm"
|
|
ref="editForm"
|
|
:rules="editFormRules"
|
|
>
|
|
<el-form-item
|
|
:label="$t('message.docManage.dialog_file_renaming.fileName')"
|
|
prop="fileName"
|
|
>
|
|
<el-input
|
|
v-model="editForm.fileName"
|
|
:placeholder="
|
|
$t('message.docManage.dialog_file_renaming.placeholder')
|
|
"
|
|
></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div class="dialog-footer">
|
|
<el-button
|
|
class="cancleBtn"
|
|
@click="editDialog = false"
|
|
icon="el-icon-circle-close"
|
|
size="medium"
|
|
>{{ $t('message.docManage.dialog_file_renaming.cancel') }}
|
|
</el-button>
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-circle-check"
|
|
@click="saveFn"
|
|
size="medium"
|
|
>
|
|
{{ $t('message.docManage.dialog_file_renaming.determine') }}
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import {
|
|
getCompanyFileListApi,
|
|
addCompanyFileApi,
|
|
deleteCompanyFileApi,
|
|
editCompanyFileApi,
|
|
updateFileDownloadNumApi,
|
|
updateFileDownloadReNameApi
|
|
} from '@/assets/js/api/doc.js'
|
|
|
|
export default {
|
|
name: 'registerAudit',
|
|
data() {
|
|
return {
|
|
downloadUrl: '',
|
|
searchForm: {
|
|
fileName: ''
|
|
},
|
|
total: 0,
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
tableData: [],
|
|
authorizedDialog: false,
|
|
detail: {},
|
|
totalInfo: {
|
|
downloadNum: 0,
|
|
fileNum: 0
|
|
},
|
|
fileList: [],
|
|
editForm: {},
|
|
editDialog: false,
|
|
editFormRules: {
|
|
fileName: [
|
|
{
|
|
required: true,
|
|
message: this.$t('message.docManage.dialog_file_renaming.message'),
|
|
trigger: 'blur'
|
|
}
|
|
] //必填
|
|
},
|
|
fileImg1: require('../../assets/images/ppt.png'),
|
|
fileImg2: require('../../assets/images/excel.png'),
|
|
fileImg3: require('../../assets/images/pdf.png'),
|
|
fileImg4: require('../../assets/images/word.png')
|
|
}
|
|
},
|
|
created() {
|
|
this.getListData()
|
|
},
|
|
methods: {
|
|
parseFileImgFn(url) {
|
|
var type = url.split('.')[1]
|
|
if (type == 'ppt' || type == 'pptx') {
|
|
return this.fileImg1
|
|
}
|
|
if (type == 'xls' || type == 'xlsx') {
|
|
return this.fileImg2
|
|
}
|
|
if (type == 'pdf') {
|
|
return this.fileImg3
|
|
}
|
|
if (type == 'doc' || type == 'docx') {
|
|
return this.fileImg4
|
|
}
|
|
},
|
|
deleteFn(item) {
|
|
this.$confirm(
|
|
this.$t('message.docManage.table.confirmMsg') +
|
|
'【' +
|
|
item.fileName +
|
|
'】?',
|
|
this.$t('message.docManage.table.Tips'),
|
|
{
|
|
//确定删除文件 提示
|
|
confirmButtonText: this.$t(
|
|
'message.docManage.table.confirmButtonText'
|
|
),
|
|
cancelButtonText: this.$t('message.docManage.table.cancelButtonText'),
|
|
type: 'warning'
|
|
}
|
|
).then(() => {
|
|
deleteCompanyFileApi({ id: item.id }).then((res) => {
|
|
this.getListData()
|
|
this.$message.success(
|
|
this.$t('message.docManage.table.deleteSuccess')
|
|
)
|
|
})
|
|
})
|
|
},
|
|
handleRemove(file, fileList) {
|
|
console.log(file, fileList)
|
|
},
|
|
handleExceed(files, fileList) {
|
|
/*this.$message.warning(
|
|
`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
|
|
files.length + fileList.length
|
|
} 个文件`
|
|
);*/
|
|
this.$message.warning(
|
|
this.$t('message.docManage.dialog_upload_files.limitingChoice')
|
|
) //当前限制选择 1 个文件
|
|
},
|
|
handleSuccess(res) {
|
|
console.log(res)
|
|
var json = {
|
|
companySn: this.$store.state.userInfo.sn,
|
|
// fileName: res.data[0].filename,
|
|
fileName: res.data[0].fileInfo.originalFilename,
|
|
filePath: res.data[0].imageUrl,
|
|
userId: this.$store.state.userInfo.userId
|
|
}
|
|
addCompanyFileApi(json).then((res) => {
|
|
this.authorizedDialog = false
|
|
this.getListData()
|
|
this.$message.success(
|
|
this.$t('message.docManage.dialog_upload_files.uploadSuccess')
|
|
) //上传成功!
|
|
})
|
|
},
|
|
editFn(item) {
|
|
this.editDialog = true
|
|
this.editForm = JSON.parse(JSON.stringify(item))
|
|
},
|
|
saveFn() {
|
|
this.$refs['editForm'].validate((valid) => {
|
|
if (valid) {
|
|
console.log(this.editForm)
|
|
editCompanyFileApi(this.editForm).then((res) => {
|
|
// updateFileDownloadReNameApi({ fileUrl: this.$store.state.FILEURL + this.editForm.filePath,fileName: this.editForm.fileName}).then((res) => {
|
|
// })
|
|
this.editDialog = false
|
|
this.getListData()
|
|
this.$message.success(
|
|
this.$t('message.docManage.dialog_upload_files.modifySuccess')
|
|
)
|
|
})
|
|
} else {
|
|
console.log('error submit!!')
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
//获取列表数据
|
|
getListData() {
|
|
let data = this.searchForm
|
|
data.pageNo = this.pageNo
|
|
data.pageSize = this.pageSize
|
|
data.companySn = this.$store.state.userInfo.sn
|
|
getCompanyFileListApi(data).then((res) => {
|
|
console.log(res)
|
|
this.tableData = res.result.page.records
|
|
this.total = res.result.page.total
|
|
this.totalInfo = res.result.totalNum
|
|
})
|
|
},
|
|
resetForm() {
|
|
this.$refs['searchForm'].resetFields()
|
|
this.getListData()
|
|
},
|
|
//下载文件
|
|
async downFn(item) {
|
|
// console.log('http://182.90.224.147:30262/image/'+item.id);
|
|
// console.log(item)
|
|
|
|
let url = this.$http.defaults.baseURL + 'xmgl/upload/getRenameFile?fileUrl='+this.$store.state.FILEURL+item.filePath + '&fileName=' + item.fileName
|
|
// window.location.href
|
|
window.open(url)
|
|
// await updateFileDownloadReNameApi(
|
|
// { fileUrl: this.$store.state.FILEURL+item.filePath,fileName: item.fileName}
|
|
// ).then((res) => {
|
|
// console.log('更名后下载',res)
|
|
// })
|
|
|
|
// console.log(this.$store.state.FILEURL+item.filePath,'下载')
|
|
// window.location.href = this.$store.state.FILEURL+item.filePath;
|
|
// if (item) {
|
|
// let arr = []
|
|
// arr = JSON.parse(item)
|
|
// arr.forEach(element => {
|
|
// });
|
|
// } else {
|
|
// this.$message.success('未查询到附件')
|
|
// }
|
|
await updateFileDownloadNumApi({ id: item.id }).then((res) => {
|
|
// window.open(this.$store.state.FILEURL+item.filePath)
|
|
// var a = document.createElement("a");
|
|
// a.href = this.$store.state.FILEURL + item.filePath
|
|
// a.download = item.fileName;
|
|
// a.click();
|
|
// this.$message.succe(res.message);
|
|
this.downloadUrl = this.$store.state.FILEURL + item.filePath
|
|
this.getListData()
|
|
|
|
})
|
|
},
|
|
//查看条数
|
|
handleSizeChange(val) {
|
|
this.pageSize = val
|
|
this.getListData()
|
|
},
|
|
//查看页
|
|
handleCurrentChange(val) {
|
|
this.pageNo = val
|
|
this.getListData()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="less" scoped>
|
|
.downfn {
|
|
text-decoration: none;
|
|
}
|
|
.searchBox {
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.rightBox {
|
|
margin-right: 20px;
|
|
|
|
p {
|
|
display: inline-flex;
|
|
|
|
span {
|
|
color: @--color-primary;
|
|
font-size: 23px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
&:first-child {
|
|
margin-right: 100px;
|
|
}
|
|
}
|
|
}
|
|
</style> |