1.安监部体系文件

pull/9/head
guoyuepeng 2024-12-30 14:07:59 +08:00
parent a51c7e76ac
commit 29b7f71737
1 changed files with 625 additions and 0 deletions

View File

@ -0,0 +1,625 @@
<template>
<div class="app-container">
<el-container>
<el-aside width="300px" style="background-color:#fff">
<el-tree v-loading="treeLoading" ref="tree" :data="treeData" :props="defaultProps" :filter-node-method="filterNode" class="filter-tree" accordion @node-click="handleNodeClick" />
</el-aside>
<el-main>
<div class="filter-container">
<el-button v-show="MFOLDER_ID != '0'" icon="el-icon-arrow-left" @click="getList(PARENT_ID)"></el-button>
</div>
<el-table v-loading="listLoading" ref="multipleTable" :data="varList" :row-key="getRowKey" :header-cell-style="{'font-weight': 'bold','color': '#000'}" tooltip-effect="dark" border fit highlight-current-row>
<el-table-column :reserve-selection="true" type="selection" width="55" align="center" />
<el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column v-if="MFOLDER_ID =='0'" label="目录名" width="220">
<template slot-scope="{row}">
<div class="link-type" @click="getList(row.MFOLDER_ID)">
<svg-icon :icon-class="row.NAME" class-name="disabled" />{{ row.NAME }}<i class="el-icon-arrow-right" />
</div>
</template>
</el-table-column>
<el-table-column v-if="MFOLDER_ID !='0'" label="文件名">
<template slot-scope="{row}">
{{ row.NAME }}
<a v-show="row.extension_name == '.txt'" style="color: #1e9fff" @click="goViewTxt(row.FILEPATH)">[]</a>
<a v-show="row.extension_name == '.pdf'" style="color: #1e9fff" @click="goViewPdf(row.FILEPATH)">[]</a>
<a v-show="row.extension_name == '.mp4'" style="color: #1e9fff" @click="goViewVideo(row.FILEPATH)">[]</a>
<a v-show="row.extension_name == '.doc' || row.extension_name == '.xls' || row.extension_name == '.ppt' || row.extension_name == '.docx' || row.extension_name == '.xlsx' || row.extension_name == '.pptx'" style="color: #1e9fff" @click="goOffice(row.FILEPATH)">[]</a>
</template>
</el-table-column>
<!-- <el-table-column prop="FILESIZE" label="文件大小" />-->
<el-table-column v-if="MFOLDER_ID !='0'" label="文件大小">
<template slot-scope="{row}">
{{ row.FILESIZE > 1024 ? ((((row.FILESIZE)/1024)+'').substring(0,(((row.FILESIZE)/1024)+'').lastIndexOf('.')+3))+' MB' : row.FILESIZE + ' KB' }}
</template>
</el-table-column>
<el-table-column prop="CTIME" label="上传时间" />
<el-table-column prop="UNAME" label="上传者" />
<!-- <el-table-column label="是否共享">-->
<!-- <template slot-scope="{row}">-->
<!-- <span v-if="row.SHARE=='no'"></span>-->
<!-- <span v-else></span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column prop="REMARKS" label="备注说明" show-overflow-tooltip />
<el-table-column label="操作" align="center" width="200">
<template slot-scope="{row}">
<el-button v-show="del && row.UNAME!='init'" type="danger" icon="el-icon-delete" plain @click="handleDelete(row.MFOLDER_ID,row.FILEPATH)"></el-button>
<el-button v-show="MFOLDER_ID !='0'" type="primary" icon="el-icon-edit" size="mini" style="color: white" @click="downloadFile(row.MFOLDER_ID)"></el-button>
</template>
</el-table-column>
</el-table>
<div class="page-btn-group">
<div class="btn-only">
<el-button v-show="MFOLDER_ID == '0' && add" type="primary" icon="el-icon-plus" @click="handleAdd"></el-button>
<el-button v-show="MFOLDER_ID != '0' && add" type="primary" icon="el-icon-plus" @click="handleUpload"></el-button>
<el-button v-show="MFOLDER_ID != '0' && add" type="primary" icon="el-icon-plus" @click="handleBatchUpload"></el-button>
</div>
<pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList(MFOLDER_ID)" />
</div>
</el-main>
</el-container>
<el-dialog :visible.sync="dialogForm" title="新建文件夹" width="600px">
<el-form ref="form" :model="form" :rules="rules" label-width="110px" style="width: 500px;">
<el-form-item label="文件夹名" prop="NAME">
<el-input v-model="form.NAME" placeholder="这里输入文件夹名..." />
</el-form-item>
<el-form-item label="备注">
<el-input :rows="3" v-model="form.REMARKS" type="textarea" placeholder="这里输入备注..." />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogForm = false"> </el-button>
<el-button type="primary" @click="confirm"> </el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="dialogFormUpload" title="上传文件" width="600px">
<el-form ref="uploadForm" :model="form" :rules="rules" label-width="110px" style="width: 500px;">
<el-form-item label="文件名" prop="NAME">
<el-input v-model="form.NAME" placeholder="这里输入名称..." />
</el-form-item>
<el-form-item label="附件">
<span v-if="form.FFILE">{{ form.FFILE.name }}</span>
<el-upload
:before-upload="beforeFileUpload"
:on-change="handleChangePDF"
:auto-upload="false"
class="avatar-uploader"
action="#">
<el-button type="primary">上传</el-button>
</el-upload>
</el-form-item>
<el-form-item label="备注">
<el-input :rows="3" v-model="form.REMARKS" type="textarea" placeholder="这里输入备注..." />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormUpload = false"> </el-button>
<el-button type="primary" @click="upload"> </el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="dialogBatchUpload" title="批量上传文件" width="600px">
<el-form ref="batchUploadForm" :model="form" label-width="110px" style="width: 500px;">
<el-form-item label="附件">
<el-upload
ref="batchUpload"
:on-preview="handlePreview"
:on-remove="handleRemove"
:on-change="handleChangePDF2"
:before-upload = "beforeFileUpload2"
:auto-upload="false"
class="upload-demo"
action="#">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
</el-upload>
<!-- <el-upload :before-upload="beforeFileUpload" class="avatar-uploader" action="#">
<el-button type="primary">上传</el-button>
</el-upload>-->
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogBatchUpload = false"> </el-button>
<el-button type="primary" @click="batchUpload"> </el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="dialogViewTxt" title="文本文档" width="600px">
<el-input :rows="30" v-model="txtPre" readonly type="textarea" placeholder=""/>
</el-dialog>
<el-dialog :visible.sync="dialogViewPdf" title="文档">
<div>
<pdf
:page="pageNum"
:src="pdfUrl"
@progress="loadedRatio = $event"
@num-pages="pageTotalNum=$event"
/>
<div style="text-align: center">
<div style="color: #409EFF;">{{ pageNum }} / {{ pageTotalNum }}</div>
<el-button-group style="padding-top: 10px;">
<el-button type="primary" icon="el-icon-arrow-left" size="mini" @click="prePage"></el-button>
<el-button type="primary" size="mini" @click="nextPage"><i class="el-icon-arrow-right el-icon--right"/></el-button>
</el-button-group>
</div>
</div>
</el-dialog>
<el-dialog :visible.sync="dialogViewVideo" title="视频" width="600px">
<div>
<video-player
ref="videoPlayer"
:playsinline="true"
:options="playerOptions"
class="video-player vjs-custom-skin"/>
</div>
</el-dialog>
</div>
</template>
<script>
import Pagination from '@/components/Pagination' // el-pagination
import { requestFN } from '@/utils/request'
import waves from '@/directive/waves' // waves directive src/utils/src/utils/.js.js
import { upload } from '@/utils/upload'
import pdf from 'vue-pdf'
import { Message } from 'element-ui'
import { videoPlayer } from 'vue-video-player'
import 'video.js/dist/video-js.css'
export default {
components: { Pagination, pdf, videoPlayer },
directives: { waves },
data() {
return {
txtPre: '',
dialogFormUpload: false,
dialogForm: false,
listLoading: true,
treeLoading: false,
dialogBatchUpload: false,
add: false,
del: false,
edit: false,
listQuery: {
page: 1,
limit: 20
},
total: 0,
KEYWORDS: '',
varList: [],
pd: [],
form: {
NAME: '', //
FFILE: [],
REMARKS: ''
},
multipleSelectionAll: [], //
multipleSelection: [], //
dialogFormEdit: false,
rules: {
NAME: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
},
corpInfoId: '',
SHARE: 'no',
treeData: [],
defaultProps: {
children: 'nodes',
label: 'name'
},
MFOLDER_ID: '0', // ID
PARENT_ID: '0', // ID
serverurl: config.fileUrl,
dialogViewTxt: false,
dialogViewVideo: false,
dialogViewPdf: false,
dialogViewUrl: '',
// pdf
pdfUrl: '',
pageNum: 1,
pageTotalNum: 1, //
loadedRatio: 0, // 0-1 1
playerOptions: {
playbackRates: [0.5, 1.0, 1.5, 2.0], //
autoplay: false, // true,
muted: false, //
loop: false, //
preload: 'auto', // <video>auto,
language: 'zh-CN',
aspectRatio: '16:9', // 使 - "16:9""4:3"
fluid: true, // trueVideo.js player
sources: [{
type: 'video/mp4', //
src: 'https://qask.qhdsafety.com/file/uploadFiles/file/13cf0f4ec77e4d98ae8cdd9c3386ae0c/20210625/691910cd81024986a392f6203c4045f8.mp4' // url
}],
poster: '', //
notSupportedMessage: '此视频暂无法播放,请稍后再试', // Video.js
controlBar: {
timeDivider: true, //
durationDisplay: true, //
remainingTimeDisplay: false, //
fullscreenToggle: true //
}
},
fileList: []
}
},
created() {
this.corpInfoId = this.$parent.indexVal
this.getList('0')
this.getDataTree()
this.urlToBlob()
},
methods: {
urlToBlob() {},
//
prePage() {
let page = this.pageNum
page = page > 1 ? page - 1 : this.pageTotalNum
this.pageNum = page
},
//
nextPage() {
let page = this.pageNum
page = page < this.pageTotalNum ? page + 1 : 1
this.pageNum = page
},
getRowKey(row) {
return row.MFOLDER_ID
},
//
getQuery() {
this.$refs.multipleTable.clearSelection()
this.getList('0')
},
//
getList(F_ID) {
this.listLoading = true
this.MFOLDER_ID = F_ID
requestFN(
'/ajFfolder/list?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
{
KEYWORDS: this.KEYWORDS,
CORPINFO_ID: this.corpInfoId,
MFOLDER_ID: this.MFOLDER_ID,
SHARE: this.SHARE
}
).then((data) => {
this.listLoading = false
this.varList = data.varList
this.PARENT_ID = data.PARENT_ID
this.total = data.page.totalResult
this.hasButton()
}).catch((e) => {
this.listLoading = false
})
},
//
handleAdd() {
this.resetForm()
this.dialogForm = true
},
submitUpload() {
this.$refs.upload.submit()
},
handleRemove(file, fileList) {
console.log(1)
console.log(file, fileList)
},
handlePreview(file) {
console.log(file)
},
handleChangePDF(file, fileList) {
// const types = ['application/pdf']
// const isImage = types.includes(file.raw.type)
// if (!isImage) {
// this.$message.error(' PDF !')
// fileList.pop()
// } else {
// this.form.FFILE = file.raw
// }
this.form.FFILE = file.raw
},
handleChangePDF2(file, fileList) {
// const types = ['application/pdf']
// const isImage = types.includes(file.raw.type)
// if (!isImage) {
// this.$message.error(' PDF !')
// fileList.pop()
// }
},
//
handleUpload() {
this.resetForm()
this.dialogFormUpload = true
},
//
handleBatchUpload() {
this.resetForm()
this.dialogBatchUpload = true
},
// beforeFileUpload2(file) {
// console.info(this.fileList)
// this.fileList.push(file)
// this.$forceUpdate()
// return false
// },
beforeFileUpload2(file) {
var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
const extension = testmsg === 'pdf'
if (!extension) {
this.$confirm(`上传文件只能是pdf格式!`)
} else {
this.fileList.push(file)
}
this.$forceUpdate()
return false
},
beforeFileUpload(file) {
var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
const extension = testmsg === 'pdf'
if (!extension) {
this.$confirm(`上传文件只能是pdf格式!`)
} else {
this.form.FFILE = file
}
this.$forceUpdate()
return false
},
//
confirm() {
this.$refs.form.validate(valid => {
if (valid) {
requestFN(
'/ajFfolder/add',
{
PARENT_ID: this.MFOLDER_ID,
NAME: this.form.NAME,
REMARKS: this.form.REMARKS
}
).then((data) => {
this.$message({
message: '操作成功',
type: 'success'
})
this.dialogForm = false
this.getDataTree()
this.getList(this.MFOLDER_ID)
}).catch((e) => {
})
} else {
return false
}
})
},
batchUpload() {
var _this = this
if (_this.$refs.batchUpload.uploadFiles.length < 1) {
Message({
message: '请上传附件',
type: 'error',
duration: 5 * 1000
})
return
}
_this.$refs.batchUpload.submit()
const loading = _this.$loading({
lock: true,
text: '上传中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
_this.form.PARENT_ID = _this.MFOLDER_ID
const formData = new FormData()
Object.keys(_this.form).map(key => {
formData.append(key, _this.form[key])
})
console.info(_this.fileList)
for (var i = 0; i < _this.fileList.length; i++) {
if (_this.fileList[i]) {
formData.append('FFILE', _this.fileList[i])
}
}
upload(
'/ajFfolder/batchUpload',
formData
).then((data) => {
_this.fileList = []
_this.dialogBatchUpload = false
_this.getDataTree()
_this.getList(_this.MFOLDER_ID)
loading.close()
}).catch((e) => {
loading.close()
})
},
//
upload() {
this.$refs.uploadForm.validate(valid => {
if (!this.form.FFILE) {
Message({
message: '请上传附件',
type: 'error',
duration: 5 * 1000
})
return
}
const loading = this.$loading({
lock: true,
text: '上传中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
this.form.PARENT_ID = this.MFOLDER_ID
const formData = new FormData()
Object.keys(this.form).map(key => {
formData.append(key, this.form[key])
})
upload(
'/ajFfolder/upload',
formData
).then((data) => {
this.dialogFormUpload = false
this.getDataTree()
this.getList(this.MFOLDER_ID)
loading.close()
}).catch((e) => {
loading.close()
})
})
},
handleNodeClick(node, data, value) {
this.getList(node.id)
},
handleDelete(id, FILEPATH) {
this.$confirm('确定要删除吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.listLoading = true
requestFN(
'/ajFfolder/delete',
{
MFOLDER_ID: id,
FILEPATH: FILEPATH || ''
}
).then(() => {
this.$message({
message: '删除成功',
type: 'success'
})
this.listLoading = false
this.varList = []
this.listQuery.page = 1
this.getDataTree()
this.getList(this.MFOLDER_ID)
}).catch((e) => {
this.listLoading = false
})
}).catch(() => {
})
},
//
hasButton() {
var keys = 'mfolder:add,mfolder:del,mfolder:edit,toExcel'
requestFN(
'/head/hasButton',
{
keys: keys
}
).then((data) => {
this.add = data.mfolderfhadminadd //
this.del = data.mfolderfhadmindel //
this.edit = data.mfolderfhadminedit //
}).catch((e) => {
this.listLoading = false
})
},
resetForm() {
this.form = {
form: {
NAME: '', //
FFILE: [],
REMARKS: ''
}
}
},
getDataTree() {
this.treeLoading = true
requestFN(
'/ajFfolder/listTree',
{
corpInfoId: this.corpInfoId
}
).then((data) => {
this.treeLoading = false
this.treeData = JSON.parse(data.zTreeNodes)
})
.catch((e) => {
this.treeLoading = false
})
},
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
downloadFile(MFOLDER_ID) {
this.$confirm('确定要下载此文件吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.listLoading = false
// '/ajFfolder/download?MFOLDER_ID=' + MFOLDER_ID,
window.location.href = config.httpurl + 'mfolder/download?MFOLDER_ID=' + MFOLDER_ID
}).catch(() => {
this.listLoading = false
})
this.listLoading = false
},
// pdf
goViewPdf(filePath) {
this.pageNum = 1
this.pdfUrl = this.serverurl + filePath
this.dialogViewPdf = true
},
// txt
goViewTxt(filePath) {
const file_url = 'serverurl' + filePath
// .txtblobweb
const xhr = new XMLHttpRequest()
xhr.open('get', file_url, true)
xhr.responseType = 'blob'
var self = this// onload thiswindow
this.loading = true
xhr.onload = function() {
if (this.status == 200) {
self.loading = false
console.log(this.response)
const reader = new FileReader()
reader.onload = function() {
self.txtPre = reader.result// data
self.dialogvisibleview = true
console.log('reader.result', reader.result)
}
reader.readAsText(this.response)
} else {
this.loading = false
}
}
xhr.send()
this.dialogViewTxt = true
},
goViewVideo(filePath) {
this.playerOptions.sources[0].src = 'serverurl' + filePath
this.playerOptions.sources[0].type = 'video/mp4'
this.dialogViewVideo = true
},
goOffice(filePath) {
window.open(config.fileUrl + filePath, '_blank').document.charset = 'UTF-8'
}
}
}
</script>
<style lang="sass" scoped>
.btn-only
.el-button+.el-button
margin-left: 0px
</style>