修改资料库

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

@@ -29,6 +29,7 @@
>
新增
</el-button>
<el-button icon="el-icon-Delete" type="primary" @click="deletes">删除</el-button>
</div>
</div>
@@ -64,11 +65,11 @@
<template #default="{ row }">
<el-button type="primary" link @click="edit(row)">修改</el-button>
<!-- <el-button type="danger" link @click="del(row)">删除</el-button> -->
<el-popconfirm title="确定删除吗?" confirm-button-type='danger' @confirm="del(row)">
<!-- <el-popconfirm title="确定删除吗?" confirm-button-type='danger' @confirm="del(row)">
<template #reference>
<el-button type="danger" link>删除</el-button>
</template>
</el-popconfirm>
</el-popconfirm> -->
</template>
</vxe-column>
</vxe-table>
@@ -79,6 +80,24 @@
<addTree ref="addTreeRef" @getTree="treeRef.loadData(dotList.id)" />
<!-- 弹框 -->
<PopupEdit ref="popupEditRef" @getTree="treeRef.loadData(dotList.id)" />
<!-- 删除 -->
<el-dialog v-model="dialogVisible" title="请选择需要删除的数据" width="400">
<el-tree-select
v-model="TreeValue"
:data="TreeData"
filterable
check-strictly
:props="defaultProps"
:render-after-expand="false"
/>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="del">删除</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
@@ -94,6 +113,7 @@ import PopupEdit from './components/form.vue'
import { useMonitoringPoint } from '@/stores/monitoringPoint'
import { ElMessage, ElMessageBox } from 'element-plus'
import { deleteyById } from '@/api/supervision-boot/database/index'
import { queryAllAlgorithmLibrary } from '@/api/supervision-boot/database/index'
defineOptions({
name: 'database/algorithm'
})
@@ -102,10 +122,16 @@ const height = mainHeight(20)
const heightTab = mainHeight(82)
const size = ref(0)
const addTreeRef = ref()
const dialogVisible = ref(false)
const treeRef = ref()
const popupEditRef = ref()
const TreeData = ref([])
const TreeValue = ref([])
const TableHeaderRef = ref()
const defaultProps = {
label: 'name',
value: 'id'
}
const dotList: any = ref()
const templatePolicy: any = ref([])
@@ -175,12 +201,33 @@ const handleNodeClick = (data: any, node: any) => {
const onAddTree = () => {
addTreeRef.value.open('新增')
}
// 删除
const del = (row: any) => {
deleteyById({ id: row.id }).then(res => {
ElMessage.success('删除成功')
treeRef.value.loadData()
const deletes = () => {
queryAllAlgorithmLibrary().then(res => {
TreeData.value = res.data
})
dialogVisible.value = true
}
// 删除
const del = () => {
if (TreeValue.value.length == 0) {
return ElMessage.warning('请选择数据')
}
ElMessageBox.confirm('此操作将永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteyById({ id: TreeValue.value }).then(res => {
ElMessage.success('删除成功')
dialogVisible.value = false
treeRef.value.loadData()
})
})
// if (TreeValue.value.length > 0) {
// ElMessage.warning('请选择数据')
// return
// }
}
// 修改
const edit = (row: any) => {

View File

@@ -0,0 +1,69 @@
<template>
<el-dialog v-model="dialogVisible" title="附件" width="600">
<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>
</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'
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)
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) => {
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></style>

View File

@@ -2,34 +2,75 @@
<div>
<el-drawer v-model="drawer" size="1000px">
<el-collapse v-model="activeName" accordion>
<el-collapse-item title="典型电能质量干扰源" name="1"></el-collapse-item>
<el-collapse-item title="典型干扰源电能质量治理措施" name="2">
<iframe
src="http://192.168.1.22:9009/excelreport//supervision/%E5%86%80%E5%8C%97%E8%B5%84%E6%96%99%E5%BA%93%E9%9C%80%E6%B1%82%E6%95%B4%E7%90%86-%E6%89%B9%E6%B3%A8.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minio%2F20240913%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240913T013952Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=9f8dc2ccb166d7c5508ecd4e9a94b9af907009a962b1eae299cd08636b9fa3ce"
frameborder="0"
></iframe>
<!-- <el-collapse-item title="典型电能质量干扰源" name="1"></el-collapse-item> -->
<el-collapse-item title="国家电网有限公司企业标准" name="2">
<!-- <el-empty description="暂无数据" class="custom-empty iframe" /> -->
<div :style="`overflow: auto;`" class="iframe">
<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"
/>
</div>
</el-collapse-item>
</el-collapse>
</el-drawer>
</div>
</template>
<script setup lang="ts">
//引入相关样式
import '@vue-office/excel/lib/index.css'
//引入VueOfficeDocx组件
import VueOfficeDocx from '@vue-office/docx'
import VueOfficeExcel from '@vue-office/excel'
//引入VueOfficePdf组件
import VueOfficePdf from '@vue-office/pdf'
import { ref, reactive } from 'vue'
const drawer = ref(false)
const activeName = ref('2')
const open = () => {
const num = ref(0)
import { getFileNameAndFilePath, downloadFile } from '@/api/system-boot/file'
const url = ref('')
const open = (row: any) => {
// console.log('🚀 ~ open ~ row:', row)
// url.value = row
drawer.value = true
getFileNameAndFilePath({ filePath: row }).then(res => {
url.value = res.data.url
})
}
defineExpose({ open })
</script>
<style lang="scss" scoped>
/* 设置iframe的样式 */
iframe {
.iframe {
width: 100%; /* 宽度设置为父容器的100% */
height: calc(100vh - 210px); /* 高度根据需要设置 */
height: calc(100vh - 110px); /* 高度根据需要设置 */
border: none; /* 移除边框 */
transform: scale(1); /* 放大200% */
}
/* 自定义 el-empty 的样式 */
:deep(.custom-empty) {
display: flex;
justify-content: center;
align-items: center;
height: 100%; /* 调整高度 */
padding: 20px; /* 调整内边距 */
.el-empty__image {
display: none; /* 隐藏默认图片 */
}
.el-empty__description {
font-size: 14px; /* 调整字体大小 */
color: var(--vxe-font-color);
}
}
</style>

View File

@@ -58,11 +58,6 @@
<el-button type="primary">上传</el-button>
</el-upload>
</el-form-item>
<el-form-item label="案例">
<el-upload v-model:file-list="caseList" action="" :limit="1" :auto-upload="false" multiple>
<el-button type="primary">上传</el-button>
</el-upload>
</el-form-item>
</el-form>
<div style="display: flex">
@@ -91,7 +86,6 @@ const dialogVisible = ref(false)
const title = ref('')
const formRef = ref()
const fileList: any = ref([])
const caseList: any = ref([])
// 注意不要和表单ref的命名冲突
const form = reactive<anyObj>({
type: '',
@@ -119,7 +113,6 @@ const open = (text: string, data?: anyObj) => {
dialogVisible.value = true
if (data) {
fileList.value = []
caseList.value = []
// 表单赋值
for (let key in form) {
form[key] = data[key]
@@ -135,15 +128,6 @@ const open = (text: string, data?: anyObj) => {
})
})
}
if (data.caseUrl.length > 0) {
getFileNameAndFilePath({ filePath: data.caseUrl }).then(res => {
caseList.value.push({
name: res.data.fileName,
url: res.data.name
})
})
}
} else {
// 在此处恢复默认表单
for (let key in form) {
@@ -180,32 +164,6 @@ const submit = () => {
form.url = ''
}
if (caseList.value.length > 0) {
const promises = caseList.value.map(async item => {
if (caseList.value[0].raw) {
return new Promise((resolve, reject) => {
uploadFile(item.raw, '/supervision/')
.then((res: any) => {
resolve(res.data.name)
})
.catch(reject)
})
} else {
return item.url
}
})
try {
const fileNames = await Promise.all(promises)
form.caseUrl = fileNames.join(',') + ''
} catch (error) {
console.error('上传文件出错', error)
return
}
} else {
form.caseUrl = ''
}
setTimeout(() => {
if (title.value === '新增案例') {
libcaseAdd(form).then(res => {

View File

@@ -4,6 +4,14 @@
<TableHeader ref="TableHeaderRef" datePicker>
<template #operation>
<el-button icon="el-icon-Plus" type="primary" @click="addUser">新增</el-button>
<el-button icon="el-icon-View" type="primary" @click="checkOutTheCriteria">查看标准</el-button>
<el-upload :show-file-list="false" action="" :auto-upload="false" class="ml10" :on-change="choose">
<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>
</template>
</TableHeader>
<Table ref="tableRef"></Table>
@@ -14,7 +22,9 @@
<span v-html="summary"></span>
</el-dialog>
<!-- 抽屉 -->
<drawer ref="drawerRef"/>
<drawer ref="drawerRef" />
<!-- 文件 -->
<annex ref="annexRef" />
</div>
</template>
<script setup lang="ts">
@@ -25,7 +35,10 @@ import Table from '@/components/table/index.vue'
import PopupEdit from './components/form.vue'
import { libcaseBeleteyById } from '@/api/supervision-boot/database/index'
import drawer from './components/drawer.vue'
import annex from './components/annex.vue'
import { ElMessage } from 'element-plus'
import { uploadFile, getFileNameAndFilePath, downloadFile } from '@/api/system-boot/file'
import { addStandardCase, queryStandardCase } from '@/api/supervision-boot/database/index'
defineOptions({
name: 'database/case'
})
@@ -33,6 +46,7 @@ defineOptions({
const popupEditRef = ref()
const drawerRef = ref()
const TableHeaderRef = ref()
const annexRef = ref()
const dialogVisible = ref(false)
const summary = ref('')
@@ -62,10 +76,6 @@ const tableStore = new TableStore({
title: '治理效果',
field: 'effect'
},
// {
// title: '事件简介',
// field: 'summary'
// },
{
title: '事件简介',
width: '140',
@@ -81,24 +91,24 @@ const tableStore = new TableStore({
dialogVisible.value = true
summary.value = row.summary
}
},
{
name: 'view',
title: '抽屉',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
drawerRef.value.open(row)
}
}
]
},
{
title: '操作',
width: '140',
width: '200',
render: 'buttons',
buttons: [
{
name: 'view',
title: '下载附件',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
annexRef.value.open(row.url)
}
},
{
name: 'edit',
title: '修改',
@@ -143,6 +153,56 @@ const addUser = () => {
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
console.log('🚀 ~ libcaseBeleteyById ~ tableStore:', tableStore)
})
const checkOutTheCriteria = () => {
queryStandardCase().then(res => {
drawerRef.value.open(res.data)
})
}
// 上传
const choose = (e: any) => {
ElMessage.info('上传中,请稍等...')
uploadFile(e.raw, '/supervision/').then((row: any) => {
addStandardCase({ caseUrl: row.data.name }).then(res => {
ElMessage.success('上传成功!')
})
})
//
}
const downloadTheReport = (url: string) => {
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()
})
})
}
</script>
<style lang="scss"></style>

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 {

View File

@@ -19,7 +19,7 @@ import TableHeader from '@/components/table/header/index.vue'
import { libtemplateDel } from '@/api/supervision-boot/database/index'
import { ElMessage } from 'element-plus'
import Table from '@/components/table/index.vue'
import { getFileNameAndFilePath } from '@/api/system-boot/file'
import { getFileNameAndFilePath, downloadFile } from '@/api/system-boot/file'
import PopupEdit from './components/form.vue'
defineOptions({
name: 'database/stencil'
@@ -50,7 +50,7 @@ const tableStore = new TableStore({
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
window.open(window.location.origin + '/#/previewFile?' + row.name)
window.open(window.location.origin + '/#/previewFile?' + row.url)
}
},
{
@@ -101,16 +101,27 @@ const tableStore = new TableStore({
const addUser = () => {
popupEditRef.value.open('新增模版')
}
// 下载报告
const downloadTheReport = (url: string) => {
// getFileNameAndFilePath({ filePath: url }).then((res: any) => {
// const link = document.createElement('a')
// link.href = res.data.url
// link.download = res.data.name
// document.body.appendChild(link)
// link.click()
// document.body.removeChild(link)
// })
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'
: ''
})
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()
})
}
provide('tableStore', tableStore)