业务流程添加重新发起&取消

This commit is contained in:
zhujiyan
2024-06-04 16:54:33 +08:00
parent ed9bce09b3
commit a0c64a4232
19 changed files with 532 additions and 226 deletions

View File

@@ -1,77 +1,70 @@
<template>
<el-dialog
draggable
class='cn-operate-dialog'
v-model='dialogVisible'
:title='title'
width='450px'
top='30vh'
>
<el-dialog draggable class="cn-operate-dialog" v-model="dialogVisible" :title="title" width="450px" top="30vh">
<el-scrollbar>
<el-form :inline='false' :model='formData' label-width='120px' :rules='rules' ref='formRef'>
<el-form-item label='问题详情:'>
<el-form :inline="false" :model="form" label-width="120px" :rules="rules" ref="formRef">
<el-form-item label="问题详情:">
<el-input
v-model='formData.issueDetail'
autocomplete='off'
type='textarea'
:autosize='{minRows:2,maxRows:6}'
v-model="form.issueDetail"
autocomplete="off"
type="textarea"
:autosize="{ minRows: 2, maxRows: 6 }"
readonly
/>
</el-form-item>
<el-form-item label='问题附件:' v-if='showFile'>
<el-form-item label="问题附件:" v-if="showFile">
<el-icon>
<Link />
</el-icon>
<a :href='problemDetail.problemPath' target='_blank'>{{ problemDetail.problemName }}</a>
<a :href="problemDetail.problemPath" target="_blank">{{ problemDetail.problemName }}</a>
</el-form-item>
<el-form-item label='采取的措施:' prop='takeStep'>
<el-form-item label="采取的措施:" prop="takeStep">
<el-input
v-model='formData.takeStep'
autocomplete='off'
placeholder='请输入采取的措施'
type='textarea'
v-model="form.takeStep"
autocomplete="off"
placeholder="请输入采取的措施"
type="textarea"
/>
</el-form-item>
<el-form-item label='反馈报告:' prop='reportPath'>
<el-form-item label="反馈报告:" class="uploadFile" prop="reportPath">
<el-upload
ref='uploadRef'
action=''
accept='.doc,.docx,.xlsx,.xls,.pdf'
:limit='1'
:on-exceed='handleExceed'
:on-change='choose'
:auto-upload='false'
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"
>
<template #trigger>
<el-button type='primary'>上传文件</el-button>
<el-button type="primary">上传文件</el-button>
</template>
</el-upload>
</el-form-item>
</el-form>
</el-scrollbar>
<template #footer>
<span class='dialog-footer'>
<el-button @click='dialogVisible = false'>取消</el-button>
<el-button type='primary' @click='submit'>确认</el-button>
<span class="dialog-footer">
<el-button @click="close">取消</el-button>
<el-button type="primary" @click="submit">确认</el-button>
</span>
</template>
</el-dialog>
</template>
<script lang='ts' setup>
<script lang="ts" setup>
import { ref, inject, reactive, nextTick } from 'vue'
import { ElMessage, genFileId, UploadProps, UploadRawFile } from 'element-plus'
import TableStore from '@/utils/tableStore' // 若不是列表页面弹框可删除
import { getFileNameAndFilePath, uploadFile } from '@/api/system-boot/file'
import { addFeedback } from '@/api/supervision-boot/leaflet'
import { addFeedback, updateFeedback } from '@/api/supervision-boot/leaflet'
import { Link } from '@element-plus/icons-vue'
//.doc,.docx,.xlsx,.xls,.pdf
const acceptType = ref('')
//下拉数据源
const title = ref('')
const tableStore = inject('tableStore') as TableStore
@@ -80,12 +73,12 @@ const formRef = ref()
const uploadRef = ref()
const dialogVisible = ref(false)
// 注意不要和表单ref的命名冲突
const formData = reactive({
const form = ref({
id: '',
status: '',
issueDetail: '',
takeStep: '',
reportPath: ''
reportPath: []
})
//附件是否显示
const showFile = ref(false)
@@ -96,11 +89,12 @@ const problemDetail = reactive({
})
//处理成效报告
const reportPath = ref('')
const reportFilePath: any = ref('')
//form表单校验规则
const rules = {
takeStep: [{ required: true, message: '请输入采取的措施', trigger: 'blur' }]
takeStep: [{ required: true, message: '请输入采取的措施', trigger: 'blur' }],
reportPath: [{ required: true, message: '请上传处理成效报告', trigger: 'blur' }]
}
const resetForm = () => {
if (formRef.value) {
@@ -108,19 +102,35 @@ const resetForm = () => {
}
}
const open = async (text: string, id: string, status: any, issueDetail: string, problemPath?: string, takeStep?: string, reportPath?: string) => {
const open = async (
text: string,
id: string,
status: any,
issueDetail: string,
problemPath?: string,
takeStep?: string,
reportPath?: string
) => {
title.value = text
resetForm()
console.log(66666,reportPath);
if (takeStep) {
formData.takeStep = takeStep
form.value.takeStep = takeStep
}
uploadRef.value?.clearFiles()
// uploadRef.value?.clearFiles()
if (reportPath) {
formData.reportPath = reportPath
form.value.reportPath = JSON.parse(
JSON.stringify([
{
name: reportPath?.split('/')[2]
}
])
)
}
formData.id = id
formData.status = status
formData.issueDetail = issueDetail
form.value.id = id
form.value.status = status
form.value.issueDetail = issueDetail
reportFilePath.value = reportPath
//判断附件是否存在,如果存在则回显出让用户可以点击下载
if (problemPath) {
let arrPath = problemPath.split(',')
@@ -129,33 +139,52 @@ const open = async (text: string, id: string, status: any, issueDetail: string,
problemDetail.problemName = res.data.fileName
})
showFile.value = true
}else{
} else {
showFile.value = false
}
dialogVisible.value = true
}
//移除文件上传
const removeFile = (file: any, uploadFiles: any) => {
console.log(file, uploadFiles)
}
const close = () => {
dialogVisible.value = false
form.value = {
id: '',
status: '',
issueDetail: '',
takeStep: '',
reportPath: []
}
resetForm()
}
/**
* 提交用户表单数据
*/
const submit = () => {
formRef.value.validate(async (valid: any) => {
if (valid) {
if (!reportPath.value) {
let subForm = JSON.parse(JSON.stringify(form.value))
subForm = {
...subForm,
reportPath: reportFilePath.value
}
if (!reportFilePath.value) {
return ElMessage({
message: '请上传处理成效报告',
type: 'warning'
})
}
if (formData.status == '3') {
// await quitRunningDeviceUpdate(formData)
if (form.value.status == '3') {
await updateFeedback(subForm)
ElMessage.success('重新发起成功')
tableStore.index()
dialogVisible.value = false
} else {
//此时该告警单处于待反馈状态
await addFeedback(formData)
await addFeedback(subForm)
//查询进线数据避免一直处于loading状态
ElMessage.success('申请成功')
tableStore.index()
@@ -167,16 +196,14 @@ const submit = () => {
defineExpose({ open })
let uploadName = ref('')
const choose = (e: any) => {
uploadFile(e.raw, '/supervision/').then(res => {
reportPath.value = res.data.name
formData.reportPath = res.data.name
reportFilePath.value = res.data.name
form.value.reportPath = res.data.name
})
}
const handleExceed: UploadProps['onExceed'] = files => {
uploadRef.value!.clearFiles()
const file = files[0] as UploadRawFile
@@ -190,7 +217,7 @@ const uploadFileName = val => {
}
</script>
<style scoped lang='scss'>
<style scoped lang="scss">
.el-upload-list__item {
transition: none !important;
}
@@ -198,6 +225,4 @@ const uploadFileName = val => {
.el-select {
min-width: 180px;
}
</style>