修改资料库

This commit is contained in:
GGJ
2024-09-24 11:21:54 +08:00
parent 5e0307e3a9
commit b1a88a7cda
8 changed files with 323 additions and 163 deletions

View File

@@ -1,40 +1,73 @@
<template>
<el-dialog v-model="dialogVisible" title="附件" width="600">
<vxe-table v-bind="defaultAttribute" ref="vxeRef" height="500px" :data="tableData">
<el-dialog v-model="dialogVisible" draggable title="详情" width="1300">
<el-descriptions :column="2" border>
<el-descriptions-item label="电能质量事件名称">{{ tableData.name }}</el-descriptions-item>
<el-descriptions-item label="事件经过">{{ tableData.process }}</el-descriptions-item>
<el-descriptions-item label="处理措施">{{ tableData.measures }}</el-descriptions-item>
<el-descriptions-item label="治理效果">{{ tableData.effect }}</el-descriptions-item>
<el-descriptions-item label="附件" :span="3">
<div v-for="item in tableData.urlList">
<div style="display: flex;align-items: center;">
<div>{{ item.name }}</div>
<el-icon class="elView" v-if="item.name" @click="view(item)">
<View />
</el-icon>
<el-icon class="elView" v-if="item.name" @click="download(item)">
<Download />
</el-icon>
</div>
</div>
</el-descriptions-item>]
<div>
<el-descriptions-item label="事件简介">
<div v-html="tableData.summary"></div>
</el-descriptions-item>
</div>
</el-descriptions>
<!-- <vxe-table v-bind="defaultAttribute" ref="vxeRef" height="500px" :data="tableData">
<vxe-column field="name" title="名称"></vxe-column>
<vxe-column title="操作" width="150">
<template #default="{ row }">
<el-button type="primary" link @click="view(row)">查看</el-button>
<el-button type="primary" link @click="download(row)">下载</el-button>
</template>
</vxe-column>
</vxe-table>
</vxe-column>
</vxe-table> -->
</el-dialog>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { defaultAttribute } from '@/components/table/defaultAttribute'
import { getFileNameAndFilePath, downloadFile } from '@/api/system-boot/file'
import { Download, View } from '@element-plus/icons-vue'
const dialogVisible = ref(false)
const tableData: any = ref([])
const open = (row: any) => {
tableData.value = []
row.split(',').map((v: any) => {
tableData.value.push({ name: v.split('/supervision/')[1], url: v })
})
console.log('🚀 ~ row.split ~ tableData.value:', tableData.value)
const tableData: any = ref({
})
const open = (row: any) => {
tableData.value = {}
tableData.value = row
tableData.value.urlList = []
row.url.split(',').map((v: any) => {
tableData.value.urlList.push({ name: v.split('/supervision/')[1], url: v })
})
dialogVisible.value = true
// console.log('🚀 ~ open ~ row:', row)
// url.value = row
}
const view = (row: any) => {
window.open(window.location.origin + '/#/previewFile?' + row.url)
}
const download = (row: any) => {
let url = row.url
let urls = url
let name = url.match(/\/([^/]+)\.(\w+)$/)[1]
downloadFile({ filePath: url }).then((res: any) => {
@@ -42,18 +75,18 @@ const download = (row: any) => {
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'
: ''
? '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')
@@ -66,4 +99,14 @@ const download = (row: any) => {
}
defineExpose({ open })
</script>
<style lang="scss" scoped></style>
<style lang="scss" scoped>
:deep(.el-descriptions__label) {
width: 160px;
}
.elView {
cursor: pointer;
margin-left: 10px;
color: #0000EE;
}
</style>

View File

@@ -1,6 +1,15 @@
<template>
<div>
<el-drawer v-model="drawer" size="1000px">
<div class="box mt20">
<el-upload :show-file-list="false" action="" :auto-upload="false" class="ml10" :on-change="choose"
v-if="information">
<el-button icon="el-icon-Top" type="primary">上传常见治理措施</el-button>
</el-upload>
<el-button icon="el-icon-Download" type="primary" class="ml10" @click="downloadTheReport">
下载常见治理措施
</el-button>
</div>
<el-collapse v-model="activeName" accordion>
<!-- <el-collapse-item title="典型电能质量干扰源" name="1"></el-collapse-item> -->
<el-collapse-item title="国家电网有限公司企业标准" name="2">
@@ -9,15 +18,12 @@
<vue-office-docx v-if="url.includes('.doc') || url.includes('.docx')" :src="url" />
<vue-office-excel v-if="url.includes('.xls') || url.includes('.xlsx')" :src="url" />
<vue-office-pdf v-if="url.includes('.pdf')" :src="url" />
<img
v-if="
url.includes('.png') ||
url.includes('.jpg') ||
url.includes('.gif') ||
url.includes('.bmp')
"
:src="url"
/>
<img v-if="
url.includes('.png') ||
url.includes('.jpg') ||
url.includes('.gif') ||
url.includes('.bmp')
" :src="url" />
</div>
</el-collapse-item>
</el-collapse>
@@ -33,11 +39,16 @@ import VueOfficeExcel from '@vue-office/excel'
//引入VueOfficePdf组件
import VueOfficePdf from '@vue-office/pdf'
import { ref, reactive } from 'vue'
import { useAdminInfo } from '@/stores/adminInfo'
import { ElMessage } from 'element-plus'
import { uploadFile, getFileNameAndFilePath, downloadFile } from '@/api/system-boot/file'
import { addStandardCase, queryStandardCase } from '@/api/supervision-boot/database/index'
const adminInfo = useAdminInfo()
const drawer = ref(false)
const activeName = ref('2')
const num = ref(0)
import { getFileNameAndFilePath, downloadFile } from '@/api/system-boot/file'
const url = ref('')
const information = adminInfo.roleCode.includes('information_info')
const open = (row: any) => {
// console.log('🚀 ~ open ~ row:', row)
// url.value = row
@@ -47,30 +58,93 @@ const open = (row: any) => {
url.value = res.data.url
})
}
// 上传
const choose = (e: any) => {
ElMessage.info('上传中,请稍等...')
uploadFile(e.raw, '/supervision/').then((row: any) => {
addStandardCase({ caseUrl: row.data.name }).then(res => {
ElMessage.success('上传成功!')
queryStandardCase().then(res => {
open(res.data)
})
})
})
//
}
const downloadTheReport = () => {
queryStandardCase().then(res => {
let urls = res.data
let name = urls.match(/\/([^/]+)\.(\w+)$/)[1]
ElMessage.info('下载中,请稍等...')
downloadFile({ filePath: urls }).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()
})
})
}
defineExpose({ open })
</script>
<style lang="scss" scoped>
/* 设置iframe的样式 */
.iframe {
width: 100%; /* 宽度设置为父容器的100% */
height: calc(100vh - 110px); /* 高度根据需要设置 */
border: none; /* 移除边框 */
transform: scale(1); /* 放大200% */
width: 100%;
/* 宽度设置为父容器的100% */
height: calc(100vh - 160px);
/* 高度根据需要设置 */
border: none;
/* 移除边框 */
transform: scale(1);
/* 放大200% */
}
/* 自定义 el-empty 的样式 */
:deep(.custom-empty) {
display: flex;
justify-content: center;
align-items: center;
height: 100%; /* 调整高度 */
padding: 20px; /* 调整内边距 */
height: 100%;
/* 调整高度 */
padding: 20px;
/* 调整内边距 */
.el-empty__image {
display: none; /* 隐藏默认图片 */
display: none;
/* 隐藏默认图片 */
}
.el-empty__description {
font-size: 14px; /* 调整字体大小 */
font-size: 14px;
/* 调整字体大小 */
color: var(--vxe-font-color);
}
}
.box {
position: absolute;
top: 0;
display: flex;
}
</style>

View File

@@ -12,18 +12,18 @@
<el-form-item label="事件名称" prop="name">
<el-input v-model="form.name" placeholder="请输入事件名称" />
</el-form-item>
<el-form-item label="发生事件" prop="type">
<!-- <el-form-item label="发生事件" prop="type">
<el-input
v-model="form.type"
placeholder="请输入治理效果"
:autosize="{ minRows: 2, maxRows: 4 }"
type="textarea"
/>
</el-form-item>
</el-form-item> -->
<el-form-item label="发生地点" prop="location">
<el-input
v-model="form.location"
placeholder="请输入治理效果"
placeholder="请输入发生地点"
:autosize="{ minRows: 2, maxRows: 4 }"
type="textarea"
/>
@@ -32,7 +32,7 @@
<el-form-item label="事件经过" prop="process">
<el-input
v-model="form.process"
placeholder="请输入治理效果"
placeholder="请输入事件经过"
:autosize="{ minRows: 2, maxRows: 4 }"
type="textarea"
/>
@@ -88,7 +88,7 @@ const formRef = ref()
const fileList: any = ref([])
// 注意不要和表单ref的命名冲突
const form = reactive<anyObj>({
type: '',
// type: '',
name: '',
location: '',
process: '',
@@ -100,12 +100,12 @@ const form = reactive<anyObj>({
})
const rules = {
name: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
type: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }],
location: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }],
process: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }],
measures: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }],
effect: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }]
name: [{ required: true, message: '请输入事件名称', trigger: 'blur' }],
// type: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }],
location: [{ required: true, message: '请输入发生地点', trigger: 'blur' }],
process: [{ required: true, message: '请输入事件经过', trigger: 'blur' }],
measures: [{ required: true, message: '请输入处理措施', trigger: 'blur' }],
effect: [{ required: true, message: '请输入治理效果', trigger: 'blur' }]
}
const open = (text: string, data?: anyObj) => {