Files
admin-sjzx/src/views/pqs/database/case/index.vue

226 lines
7.8 KiB
Vue
Raw Normal View History

<template>
<div class="default-main">
<!-- 案例库 -->
<TableHeader ref="TableHeaderRef" datePicker>
<template #operation>
2024-09-24 11:21:54 +08:00
<el-button icon="el-icon-Plus" type="primary" @click="addUser" v-if="information">新增</el-button>
2024-09-24 16:23:55 +08:00
<el-button icon="el-icon-View" type="primary" @click="checkOutTheCriteria">查看常见治理措施</el-button>
2024-09-18 15:52:50 +08:00
2024-09-24 11:21:54 +08:00
<!-- <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>
2024-09-18 15:52:50 +08:00
</el-upload>
<el-button icon="el-icon-Download" type="primary" class="ml10" @click="downloadTheReport">
2024-09-24 11:21:54 +08:00
下载常见治理措施
</el-button> -->
</template>
</TableHeader>
<Table ref="tableRef"></Table>
<!-- 弹框 -->
2024-09-12 20:01:17 +08:00
<PopupEdit ref="popupEditRef" @onSubmit="tableStore.index()" />
2024-09-13 11:11:21 +08:00
<!-- 简介详情 -->
<el-dialog v-model="dialogVisible" title="事件简介" width="60%">
<span v-html="summary"></span>
</el-dialog>
<!-- 抽屉 -->
2024-09-18 15:52:50 +08:00
<drawer ref="drawerRef" />
<!-- 文件 -->
<annex ref="annexRef" />
</div>
</template>
<script setup lang="ts">
import { onMounted, ref, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import TableHeader from '@/components/table/header/index.vue'
import Table from '@/components/table/index.vue'
import PopupEdit from './components/form.vue'
2024-09-12 20:01:17 +08:00
import { libcaseBeleteyById } from '@/api/supervision-boot/database/index'
2024-09-13 11:11:21 +08:00
import drawer from './components/drawer.vue'
2024-09-18 15:52:50 +08:00
import annex from './components/annex.vue'
2024-09-12 20:01:17 +08:00
import { ElMessage } from 'element-plus'
2024-09-18 15:52:50 +08:00
import { uploadFile, getFileNameAndFilePath, downloadFile } from '@/api/system-boot/file'
import { addStandardCase, queryStandardCase } from '@/api/supervision-boot/database/index'
2024-09-24 11:21:54 +08:00
import { useAdminInfo } from '@/stores/adminInfo'
const adminInfo = useAdminInfo()
defineOptions({
name: 'database/case'
})
const popupEditRef = ref()
2024-09-13 11:11:21 +08:00
const drawerRef = ref()
const TableHeaderRef = ref()
2024-09-18 15:52:50 +08:00
const annexRef = ref()
2024-09-13 11:11:21 +08:00
const dialogVisible = ref(false)
const summary = ref('')
2024-09-24 11:21:54 +08:00
const information = adminInfo.roleCode.includes('information_info')
const tableStore = new TableStore({
url: '/supervision-boot/libcase/pageQuery',
method: 'POST',
column: [
{ title: '电能质量事件名称', field: 'name' },
{
title: '发生地点',
field: 'location'
},
2024-09-24 11:21:54 +08:00
// {
// title: '发生事件',
// field: 'type'
// },
// {
// title: '事件经过',
// field: 'process'
// },
// {
// title: '处理措施',
// field: 'measures'
// },
// {
// title: '治理效果',
// field: 'effect'
// },
// {
// title: '事件简介',
// width: '140',
// render: 'buttons',
// buttons: [
// {
// name: 'view',
// title: '查看',
// type: 'primary',
// icon: 'el-icon-Plus',
// render: 'basicButton',
// click: row => {
// dialogVisible.value = true
// summary.value = row.summary
// }
// }
// ]
// },
{
2024-09-24 11:21:54 +08:00
title: '操作',
width: '200',
2024-09-13 11:11:21 +08:00
render: 'buttons',
buttons: [
{
name: 'view',
2024-09-24 11:21:54 +08:00
title: '详情',
2024-09-13 11:11:21 +08:00
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
2024-09-24 11:21:54 +08:00
annexRef.value.open(row)
2024-09-13 11:11:21 +08:00
}
2024-09-24 11:21:54 +08:00
},
2024-09-18 15:52:50 +08:00
{
name: 'view',
title: '下载附件',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
annexRef.value.open(row.url)
}
},
2024-09-12 20:01:17 +08:00
{
name: 'edit',
title: '修改',
type: 'primary',
2024-09-24 11:21:54 +08:00
disabled: row => {
return !information
},
2024-09-12 20:01:17 +08:00
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
popupEditRef.value.open('修改案例', row)
}
},
{
name: 'delete',
title: '删除',
type: 'danger',
icon: 'el-icon-Delete',
render: 'confirmButton',
2024-09-24 11:21:54 +08:00
disabled: row => {
return !information
},
2024-09-12 20:01:17 +08:00
popconfirm: {
confirmButtonText: '确认',
cancelButtonText: '取消',
confirmButtonType: 'danger',
title: '确定删除吗?'
},
click: row => {
libcaseBeleteyById({ id: row.id }).then(res => {
ElMessage.success('删除成功')
tableStore.index()
})
}
}
]
}
],
2024-09-24 11:21:54 +08:00
loadCallback: () => { }
})
// 弹框
const addUser = () => {
popupEditRef.value.open('新增案例')
}
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
2024-09-18 15:52:50 +08:00
console.log('🚀 ~ libcaseBeleteyById ~ tableStore:', tableStore)
})
2024-09-18 15:52:50 +08:00
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('上传成功!')
})
})
//
}
2024-09-24 11:21:54 +08:00
const downloadTheReport = () => {
2024-09-18 15:52:50 +08:00
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')
2024-09-24 11:21:54 +08:00
? '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'
: ''
2024-09-18 15:52:50 +08:00
})
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>