修改资料库

This commit is contained in:
GGJ
2024-09-18 15:52:50 +08:00
parent 5cf6144763
commit 1a8e5e88a4
11 changed files with 588 additions and 330 deletions

View File

@@ -17,6 +17,7 @@
<el-button icon="el-icon-Plus" type="primary" @click="addUser">新增</el-button>
<el-button icon="el-icon-Edit" type="primary" @click="editUser">修改</el-button>
<el-button icon="el-icon-Delete" type="primary" @click="deleteEven">删除</el-button>
<el-button icon="el-icon-Download" type="primary" @click="download" v-if="flag">下载</el-button>
</div>
<el-empty
v-if="url.length == 0"
@@ -51,7 +52,7 @@ import { mainHeight } from '@/utils/layout'
import addTree from './components/addTree.vue'
import { useMonitoringPoint } from '@/stores/monitoringPoint'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getFileNameAndFilePath } from '@/api/system-boot/file'
import { getFileNameAndFilePath, downloadFile } from '@/api/system-boot/file'
//引入相关样式
import '@vue-office/excel/lib/index.css'
//引入VueOfficeDocx组件
@@ -71,7 +72,7 @@ const treeRef = ref()
const addTreeRef = ref()
const url = ref('')
const dotList: any = ref({})
const flag: any = ref(false)
onMounted(() => {
const dom = document.getElementById('navigation-splitpanes')
if (dom) {
@@ -82,7 +83,9 @@ onMounted(() => {
const handleNodeClick = (data: any, node: any) => {
dotList.value = data
url.value = ''
flag.value = false
if (data?.url != null && data?.url != '') {
flag.value = true
getFileNameAndFilePath({ filePath: data.url }).then(res => {
url.value = res.data.url
})
@@ -110,6 +113,38 @@ const addUser = () => {
const editUser = () => {
addTreeRef.value.open('修改', dotList.value)
}
// 下载
const download = () => {
let url = dotList.value.url
let urls = url
let name = url.match(/\/([^/]+)\.(\w+)$/)[1]
downloadFile({ filePath: url }).then((res: any) => {
let blob = new Blob([res], {
type: urls.includes('.pdf')
? 'application/pdf'
: urls.includes('.docx')
? 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
: urls.includes('.xls')
? 'application/vnd.ms-excel'
: urls.includes('.xlsx')
? 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
: urls.includes('.png')
? 'image/png'
: urls.includes('.jpeg')
? 'image/jpeg'
: urls.includes('.jpg')
? 'image/jpg'
: ''
})
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = name
document.body.appendChild(link)
link.click()
link.remove()
})
}
</script>
<style lang="scss" scoped>
.splitpanes.default-theme .splitpanes__pane {