Files
admin-sjzx/src/views/pqs/supervise/technology/feedbackPopup.vue

282 lines
9.6 KiB
Vue
Raw Normal View History

2024-05-22 16:05:51 +08:00
<template>
2024-06-04 16:54:33 +08:00
<el-dialog draggable class="cn-operate-dialog" v-model="dialogVisible" :title="title" width="450px" top="30vh">
2024-05-29 19:01:34 +08:00
<el-scrollbar>
2024-06-04 16:54:33 +08:00
<el-form :inline="false" :model="form" label-width="120px" :rules="rules" ref="formRef">
<el-form-item label="问题详情:">
2024-10-30 09:29:39 +08:00
<el-input v-model="form.issueDetail" disabled autocomplete="off" type="textarea"
:autosize="{ minRows: 2, maxRows: 6 }" readonly />
2024-05-29 19:01:34 +08:00
</el-form-item>
2024-06-20 16:54:19 +08:00
<el-form-item label="整改意见:">
2024-10-30 09:29:39 +08:00
<el-input v-model="form.reformAdvice" autocomplete="off" disabled type="textarea"
:autosize="{ minRows: 2, maxRows: 6 }" readonly />
2024-06-20 16:54:19 +08:00
</el-form-item>
2024-05-29 19:01:34 +08:00
<el-form-item label="技术监督报告:" v-if="showFile1">
<el-icon class="elView" v-if="supervisionReportDetail?.supervisionReportName">
<View @click="openFile(supervisionReportDetail?.supervisionReportName)" />
</el-icon>
2025-12-19 11:58:26 +08:00
<span class="aLoad" @click="download(supervisionReportDetail.keyName)" target="_blank">
{{ supervisionReportDetail.supervisionReportName }}
2025-12-19 11:58:26 +08:00
</span >
</el-form-item>
2024-06-04 16:54:33 +08:00
<el-form-item label="问题附件:" v-if="showFile">
2024-06-14 10:26:35 +08:00
<el-icon class="elView" v-if="problemDetail?.problemName">
<View @click="openFile(problemDetail?.problemName)" />
2024-05-29 19:01:34 +08:00
</el-icon>
2025-12-19 11:58:26 +08:00
<span class="aLoad" @click="download(supervisionReportDetail.keyName)" target="_blank">{{ problemDetail.problemName }}</a>
2024-05-29 19:01:34 +08:00
</el-form-item>
2024-06-04 16:54:33 +08:00
<el-form-item label="采取的措施:" prop="takeStep">
2024-10-30 09:29:39 +08:00
<el-input v-model="form.takeStep" autocomplete="off" placeholder="请输入采取的措施" type="textarea" />
2024-05-29 19:01:34 +08:00
</el-form-item>
2024-06-04 16:54:33 +08:00
<el-form-item label="反馈报告:" class="uploadFile" prop="reportPath">
2024-10-30 09:29:39 +08:00
<el-upload v-model:file-list="form.reportPath" ref="uploadRef" action="" :accept="acceptType"
:limit="1" :on-exceed="handleExceed" :on-change="choose" :auto-upload="false"
:on-progress="uploadFileName('reportPath')" :on-remove="removeFile">
2024-05-29 19:01:34 +08:00
<template #trigger>
2024-06-04 16:54:33 +08:00
<el-button type="primary">上传文件</el-button>
2024-05-29 19:01:34 +08:00
</template>
</el-upload>
</el-form-item>
</el-form>
</el-scrollbar>
<template #footer>
2024-06-04 16:54:33 +08:00
<span class="dialog-footer">
<el-button @click="close">取消</el-button>
2024-06-19 19:37:39 +08:00
<!-- <el-button type="primary" @click="submit">确认</el-button> -->
2024-10-30 09:29:39 +08:00
<el-button type="primary" @click="submit(true)" :loading="loading">保存</el-button>
<el-button type="primary" @click="submit(false)" :loading="loading">提交审批</el-button>
2024-05-22 16:05:51 +08:00
</span>
2024-05-29 19:01:34 +08:00
</template>
</el-dialog>
2024-05-22 16:05:51 +08:00
</template>
2024-06-04 16:54:33 +08:00
<script lang="ts" setup>
2024-05-22 16:05:51 +08:00
import { ref, inject, reactive, nextTick } from 'vue'
import { ElMessage, genFileId, UploadProps, UploadRawFile } from 'element-plus'
import TableStore from '@/utils/tableStore' // 若不是列表页面弹框可删除
2024-05-29 19:01:34 +08:00
import { getFileNameAndFilePath, uploadFile } from '@/api/system-boot/file'
2024-06-04 16:54:33 +08:00
import { addFeedback, updateFeedback } from '@/api/supervision-boot/leaflet'
2025-12-19 10:56:30 +08:00
import {download} from '@/utils/fileDownLoad'
2024-06-14 10:26:35 +08:00
import { Link, View } from '@element-plus/icons-vue'
2024-06-06 22:14:20 +08:00
const openFile = (name: any) => {
2024-08-07 11:13:46 +08:00
window.open(window.location.origin + '/#/previewFile?/supervision/' + name)
2024-06-06 22:14:20 +08:00
}
2024-06-04 16:54:33 +08:00
//.doc,.docx,.xlsx,.xls,.pdf
const acceptType = ref('')
2024-05-22 16:05:51 +08:00
//下拉数据源
const title = ref('')
2024-10-16 17:54:55 +08:00
const loading = ref(false)
2024-05-22 16:05:51 +08:00
const tableStore = inject('tableStore') as TableStore
const formRef = ref()
// 上传报告
const uploadRef = ref()
const dialogVisible = ref(false)
// 注意不要和表单ref的命名冲突
2024-06-04 16:54:33 +08:00
const form = ref({
2024-05-29 19:01:34 +08:00
id: '',
status: '',
issueDetail: '',
2024-06-20 16:54:19 +08:00
reformAdvice: '',
2024-05-29 19:01:34 +08:00
takeStep: '',
2024-06-04 16:54:33 +08:00
reportPath: []
2024-05-29 19:01:34 +08:00
})
//附件是否显示
const showFile = ref(false)
const showFile1 = ref(false)
2024-05-29 19:01:34 +08:00
const problemDetail = reactive({
problemPath: '',
problemName: '',
keyName: ''
2024-05-22 16:05:51 +08:00
})
const supervisionReportDetail = reactive({
supervisionReportPath: '',
supervisionReportName: '',
keyName: ''
})
2024-05-22 16:05:51 +08:00
//处理成效报告
2024-06-04 16:54:33 +08:00
const reportFilePath: any = ref('')
2024-05-22 16:05:51 +08:00
//form表单校验规则
const rules = {
2024-06-04 16:54:33 +08:00
takeStep: [{ required: true, message: '请输入采取的措施', trigger: 'blur' }],
reportPath: [{ required: true, message: '请上传处理成效报告', trigger: 'blur' }]
2024-05-22 16:05:51 +08:00
}
const resetForm = () => {
2024-05-29 19:01:34 +08:00
if (formRef.value) {
formRef.value.resetFields()
}
2024-05-22 16:05:51 +08:00
}
2024-06-04 16:54:33 +08:00
const open = async (
text: string,
id: string,
status: any,
issueDetail: string,
problemPath?: string,
supervisionReport?: string,
2024-06-20 16:54:19 +08:00
reformAdvice?: string,
2024-06-04 16:54:33 +08:00
takeStep?: string,
reportPath?: string
) => {
2024-05-29 19:01:34 +08:00
title.value = text
resetForm()
if (takeStep) {
2024-06-04 16:54:33 +08:00
form.value.takeStep = takeStep
2024-05-29 19:01:34 +08:00
}
2024-06-04 16:54:33 +08:00
// uploadRef.value?.clearFiles()
2024-05-29 19:01:34 +08:00
if (reportPath) {
2024-06-04 16:54:33 +08:00
form.value.reportPath = JSON.parse(
JSON.stringify([
{
name: reportPath?.split('/')[2]
}
])
)
2024-05-29 19:01:34 +08:00
}
2024-06-04 16:54:33 +08:00
form.value.id = id
form.value.status = status
2024-10-30 09:29:39 +08:00
form.value.issueDetail = issueDetail || ''
form.value.reformAdvice = reformAdvice || ''
2024-06-04 16:54:33 +08:00
reportFilePath.value = reportPath
2024-05-29 19:01:34 +08:00
//判断附件是否存在,如果存在则回显出让用户可以点击下载
if (problemPath) {
let arrPath = problemPath.split(',')
await getFileNameAndFilePath({ filePath: arrPath[0] }).then(res => {
problemDetail.keyName = res.data.name
2024-05-29 19:01:34 +08:00
problemDetail.problemPath = res.data.url
problemDetail.problemName = res.data.fileName
})
showFile.value = true
2024-06-04 16:54:33 +08:00
} else {
2024-05-29 19:01:34 +08:00
showFile.value = false
}
if (supervisionReport) {
let arrPath = supervisionReport.split(',')
2024-08-07 11:13:46 +08:00
console.log('🚀 ~ arrPath:', arrPath)
await getFileNameAndFilePath({ filePath: arrPath[0] }).then(res => {
supervisionReportDetail.keyName = res.data.name
supervisionReportDetail.supervisionReportPath = res.data.url
supervisionReportDetail.supervisionReportName = res.data.fileName
})
showFile1.value = true
} else {
showFile1.value = false
}
2024-05-29 19:01:34 +08:00
dialogVisible.value = true
2024-05-22 16:05:51 +08:00
}
2024-06-04 16:54:33 +08:00
//移除文件上传
const removeFile = (file: any, uploadFiles: any) => {
console.log(file, uploadFiles)
}
const close = () => {
dialogVisible.value = false
form.value = {
id: '',
status: '',
issueDetail: '',
2024-06-20 16:54:19 +08:00
reformAdvice: '',
2024-06-04 16:54:33 +08:00
takeStep: '',
reportPath: []
}
resetForm()
}
2024-05-22 16:05:51 +08:00
/**
* 提交用户表单数据
*/
2024-10-30 09:29:39 +08:00
const submit = async (flag: boolean) => {
2024-10-16 17:54:55 +08:00
loading.value = true
2024-06-19 19:37:39 +08:00
if (flag) {
let subForm = JSON.parse(JSON.stringify(form.value))
subForm = {
...subForm,
2024-06-20 16:54:19 +08:00
reportPath: form.value.reportPath.length > 0 ? reportFilePath.value : null
2024-05-29 19:01:34 +08:00
}
2024-06-19 19:37:39 +08:00
subForm.saveOrCheckflag = '1'
//此时该告警单处于待反馈状态
2024-10-16 17:54:55 +08:00
await addFeedback(subForm).then(res => {
2024-06-19 19:37:39 +08:00
//查询进线数据避免一直处于loading状态
2024-06-21 10:15:25 +08:00
ElMessage.success('保存成功!')
2024-06-19 19:37:39 +08:00
tableStore.index()
dialogVisible.value = false
})
} else {
formRef.value.validate(async (valid: any) => {
if (valid) {
let subForm = JSON.parse(JSON.stringify(form.value))
subForm = {
...subForm,
2024-06-20 16:54:19 +08:00
reportPath: form.value.reportPath.length > 0 ? reportFilePath.value : null
2024-06-19 19:37:39 +08:00
}
if (!reportFilePath.value) {
return ElMessage({
message: '请上传处理成效报告',
type: 'warning'
})
}
subForm.saveOrCheckflag = '2'
if (form.value.status == '3') {
await updateFeedback(subForm).then(res => {
ElMessage.success('重新发起成功')
tableStore.index()
dialogVisible.value = false
})
2024-06-19 19:37:39 +08:00
} else {
//此时该告警单处于待反馈状态
await addFeedback(subForm).then(res => {
//查询进线数据避免一直处于loading状态
ElMessage.success('申请成功')
tableStore.index()
dialogVisible.value = false
})
2024-06-19 19:37:39 +08:00
}
}
})
}
2024-10-16 17:54:55 +08:00
await setTimeout(() => {
loading.value = false
}, 0)
2024-05-22 16:05:51 +08:00
}
defineExpose({ open })
let uploadName = ref('')
const choose = (e: any) => {
uploadFile(e.raw, '/supervision/').then(res => {
reportFilePath.value = res.data.name
// form.value.reportPath = res.data.name
})
2024-05-22 16:05:51 +08:00
}
const handleExceed: UploadProps['onExceed'] = files => {
2024-05-29 19:01:34 +08:00
uploadRef.value!.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
uploadRef.value!.handleStart(file)
2024-05-22 16:05:51 +08:00
}
//上传报告改变
const uploadFileName = val => {
2024-05-29 19:01:34 +08:00
uploadName.value = val
2024-05-22 16:05:51 +08:00
}
</script>
2024-06-04 16:54:33 +08:00
<style scoped lang="scss">
2024-05-22 16:05:51 +08:00
.el-upload-list__item {
2024-05-29 19:01:34 +08:00
transition: none !important;
2024-05-22 16:05:51 +08:00
}
.el-select {
2024-05-29 19:01:34 +08:00
min-width: 180px;
2024-05-22 16:05:51 +08:00
}
2024-10-30 09:29:39 +08:00
2024-06-14 10:26:35 +08:00
.elView {
cursor: pointer;
2024-06-18 09:03:53 +08:00
margin-right: 10px;
2024-06-14 10:26:35 +08:00
}
2024-05-22 16:05:51 +08:00
</style>