修改技术监督删除功能

This commit is contained in:
GGJ
2024-09-13 11:11:21 +08:00
parent fe6bae1bdc
commit 8c8eaa11be
11 changed files with 312 additions and 42 deletions

View File

@@ -0,0 +1,35 @@
<template>
<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>
</el-collapse>
</el-drawer>
</div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
const drawer = ref(false)
const activeName = ref('2')
const open = () => {
drawer.value = true
}
defineExpose({ open })
</script>
<style lang="scss" scoped>
/* 设置iframe的样式 */
iframe {
width: 100%; /* 宽度设置为父容器的100% */
height: calc(100vh - 210px); /* 高度根据需要设置 */
border: none; /* 移除边框 */
transform: scale(1); /* 放大200% */
}
</style>

View File

@@ -1,5 +1,12 @@
<template>
<el-dialog draggable class="cn-operate-dialog" v-model="dialogVisible" :title="title" width="1200px">
<el-dialog
draggable
class="cn-operate-dialog"
v-model="dialogVisible"
:title="title"
:before-close="handleClose"
width="1200px"
>
<el-scrollbar>
<el-form :inline="false" :model="form" class="form-two" label-width="auto" :rules="rules" ref="formRef">
<el-form-item label="事件名称" prop="name">
@@ -51,6 +58,11 @@
<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">
@@ -60,7 +72,7 @@
</el-scrollbar>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="submit">确认</el-button>
</span>
</template>
@@ -73,12 +85,13 @@ import { ElMessage } from 'element-plus'
import TableStore from '@/utils/tableStore' // 若不是列表页面弹框可删除
import editor from '@/components/wangEditor/index.vue'
import { uploadFile, getFileNameAndFilePath } from '@/api/system-boot/file'
import { libcaseAdd } from '@/api/supervision-boot/database/index'
import { libcaseAdd, updateCaseLibrary } from '@/api/supervision-boot/database/index'
const emit = defineEmits(['onSubmit'])
const dialogVisible = ref(false)
const title = ref('')
const formRef = ref()
const fileList: any = ref([])
const caseList: any = ref([])
// 注意不要和表单ref的命名冲突
const form = reactive<anyObj>({
type: '',
@@ -86,6 +99,8 @@ const form = reactive<anyObj>({
location: '',
process: '',
measures: '',
summary: '',
caseUrl: '',
effect: '',
url: ''
})
@@ -104,19 +119,31 @@ const open = (text: string, data?: anyObj) => {
dialogVisible.value = true
if (data) {
fileList.value = []
caseList.value = []
// 表单赋值
for (let key in form) {
form[key] = data[key]
}
data.url.split(',').forEach((item: string) => {
console.log('🚀 ~ data.url.split ~ item:', item)
getFileNameAndFilePath({ filePath: item }).then(res => {
fileList.value.push({
form.id = data.id
if (data.url.length > 0) {
data.url.split(',').forEach((item: string) => {
getFileNameAndFilePath({ filePath: item }).then(res => {
fileList.value.push({
name: res.data.fileName,
url: res.data.name
})
})
})
}
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) {
@@ -125,19 +152,21 @@ const open = (text: string, data?: anyObj) => {
}
}
const submit = () => {
console.log(`1111`, fileList.value)
formRef.value.validate(async (valid: boolean) => {
if (valid) {
if (fileList.value.length > 0) {
const promises = fileList.value.map(async item => {
return new Promise((resolve, reject) => {
uploadFile(item.raw, '/supervision/')
.then((res: any) => {
resolve(res.data.name)
})
.catch(reject)
})
if (item.raw) {
return new Promise((resolve, reject) => {
uploadFile(item.raw, '/supervision/')
.then((res: any) => {
resolve(res.data.name)
})
.catch(reject)
})
} else {
return item.url
}
})
try {
@@ -147,17 +176,47 @@ const submit = () => {
console.error('上传文件出错', error)
return
}
} else {
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 === '新增案例') {
console.log('🚀 ~ libcaseAdd ~ form:', form)
libcaseAdd(form).then(res => {
ElMessage.success(title.value + '成功!')
handleClose()
})
} else {
// 其他逻辑
ElMessage.success(title.value + '成功!')
updateCaseLibrary(form).then(res => {
handleClose()
})
}
}, 100)
}
@@ -165,7 +224,7 @@ const submit = () => {
}
const handleClose = () => {
ElMessage.success(title.value + '成功!')
fileList.value = []
emit('onSubmit')
dialogVisible.value = false
}

View File

@@ -9,6 +9,12 @@
<Table ref="tableRef"></Table>
<!-- 弹框 -->
<PopupEdit ref="popupEditRef" @onSubmit="tableStore.index()" />
<!-- 简介详情 -->
<el-dialog v-model="dialogVisible" title="事件简介" width="60%">
<span v-html="summary"></span>
</el-dialog>
<!-- 抽屉 -->
<drawer ref="drawerRef"/>
</div>
</template>
<script setup lang="ts">
@@ -18,14 +24,17 @@ import TableHeader from '@/components/table/header/index.vue'
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 { ElMessage } from 'element-plus'
defineOptions({
name: 'database/case'
})
const popupEditRef = ref()
const drawerRef = ref()
const TableHeaderRef = ref()
const dialogVisible = ref(false)
const summary = ref('')
const tableStore = new TableStore({
url: '/supervision-boot/libcase/pageQuery',
@@ -36,10 +45,7 @@ const tableStore = new TableStore({
title: '发生事件',
field: 'type'
},
{
title: '事件简介',
field: 'summary'
},
{
title: '事件经过',
field: 'process'
@@ -56,6 +62,38 @@ const tableStore = new TableStore({
title: '治理效果',
field: 'effect'
},
// {
// title: '事件简介',
// field: 'summary'
// },
{
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
}
},
{
name: 'view',
title: '抽屉',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
drawerRef.value.open(row)
}
}
]
},
{
title: '操作',
width: '140',