This commit is contained in:
2024-09-14 10:20:49 +08:00
parent cb9a0fe5e4
commit b870839d39
7 changed files with 244 additions and 176 deletions

View File

@@ -1,59 +1,76 @@
<template>
<el-dialog draggable class="cn-operate-dialog" v-model="dialogVisible" :title="title" width="550px" top="20vh">
<el-form :inline="false" :model="form" label-width="120px" :rules="rules" ref="formRef">
<el-form-item for="-" label="本次定检时间:" prop="nowCheckTime">
<el-date-picker
v-model="form.nowCheckTime"
placeholder="选择日期"
format="YYYY-MM-DD"
style="width: 100%"
value-format="YYYY-MM-DD"
type="date"
/>
</el-form-item>
<el-dialog draggable class='cn-operate-dialog' v-model='dialogVisible' :title='title' width='550px' top='20vh'>
<el-form :inline='false' :model='form' label-width='120px' :rules='rules' ref='formRef'>
<el-form-item for="-" label="报告文件:" class="uploadFile" prop="reportPath">
<el-upload
v-model:file-list="form.reportPath"
ref="uploadRef"
action=""
accept=""
:limit="1"
:on-exceed="handleExceed"
:on-change="choose"
:auto-upload="false"
:on-remove="removeFile"
>
<template #trigger>
<el-button type="primary">上传文件</el-button>
</template>
</el-upload>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
type="textarea"
clearable
:autosize="{ minRows: 2, maxRows: 4 }"
placeholder="请输入描述"
v-model="form.description"
></el-input>
</el-form-item>
</el-form>
<el-form-item label='所属供电公司' >
<el-input
readonly
v-model='form.dept'
></el-input>
</el-form-item>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submit">确认</el-button>
<el-form-item label='终端名称' >
<el-input
readonly
v-model='form.deviceName'
></el-input>
</el-form-item>
<el-form-item for='-' label='本次定检时间:' prop='nowCheckTime'>
<el-date-picker
v-model='form.nowCheckTime'
placeholder='选择日期'
format='YYYY-MM-DD'
style='width: 100%'
value-format='YYYY-MM-DD'
type='date'
/>
</el-form-item>
<el-form-item for='-' label='报告文件:' class='uploadFile' prop='reportPath'>
<el-upload
v-model:file-list='form.reportPath'
ref='uploadRef'
action=''
accept=''
:limit='1'
:on-exceed='handleExceed'
:on-change='choose'
:auto-upload='false'
:on-remove='removeFile'
>
<template #trigger>
<el-button type='primary'>上传文件</el-button>
</template>
</el-upload>
</el-form-item>
<el-form-item label='描述' prop='description'>
<el-input
type='textarea'
clearable
:autosize='{ minRows: 2, maxRows: 4 }'
placeholder='请输入描述'
v-model='form.description'
></el-input>
</el-form-item>
</el-form>
<template #footer>
<span class='dialog-footer'>
<el-button @click='dialogVisible = false'>取消</el-button>
<el-button type='primary' @click='submit'>确认</el-button>
</span>
</template>
</el-dialog>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
<script lang='ts' setup>
import { ref, inject } from 'vue'
import { genFileId, ElMessage } from 'element-plus'
import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus'
import { uploadFile } from '@/api/system-boot/file'
import { reload, submitDevice } from '@/api/supervision-boot/cycleDetection/index'
const emits = defineEmits(['onSubmit'])
//下拉数据源
@@ -65,98 +82,102 @@ const dialogVisible = ref(false)
// 注意不要和表单ref的命名冲突
const form: any = ref({
id: '',
reportPath: [],
description: '',
nowCheckTime: ''
id: '',
reportPath: [],
description: '',
nowCheckTime: '',
dept: '',
deviceName: ''
})
//form表单校验规则
const rules = {
reportPath: [{ required: true, message: '请上传文件', trigger: 'change' }],
nowCheckTime: [{ required: true, message: '请选择定检时间', trigger: 'change' }],
description: [{ required: true, message: '请输入描述', trigger: 'blur' }]
reportPath: [{ required: true, message: '请上传文件', trigger: 'change' }],
nowCheckTime: [{ required: true, message: '请选择定检时间', trigger: 'change' }],
description: [{ required: true, message: '请输入描述', trigger: 'blur' }]
}
const open = async (text: string, tempData?: any) => {
title.value = text
if (tempData) {
form.value.id = tempData.id
form.value.status = tempData.status
if (tempData.status == null) {
form.value.reportPath = []
form.value.description = ''
} else {
form.value.reportPath = [{ name: tempData.checkFilePath.split('/')[2] }]
form.value.description = tempData.description
form.value.nowCheckTime = tempData.nowCheckTime
}
title.value = text
if (tempData) {
form.value.id = tempData.id
form.value.dept = tempData.dept
form.value.deviceName = tempData.deviceName
form.value.status = tempData.status
if (tempData.status == null) {
form.value.reportPath = []
form.value.description = ''
} else {
form.value.reportPath = [{ name: tempData.checkFilePath.split('/')[2] }]
form.value.description = tempData.description
form.value.nowCheckTime = tempData.nowCheckTime
}
}
dialogVisible.value = true
dialogVisible.value = true
}
/**
* 提交用户表单数据
*/
const submit = () => {
formRef.value.validate(async (valid: any) => {
if (valid) {
if (form.value.status == null) {
submitDevice({ ...form.value, reportPath: reportPath.value }).then(res => {
ElMessage({
message: '提交成功!',
type: 'success'
})
dialogVisible.value = false
emits('onSubmit')
})
} else {
reload({ ...form.value, reportPath: reportPath.value }).then(res => {
ElMessage({
message: '提交成功!',
type: 'success'
})
dialogVisible.value = false
emits('onSubmit')
})
}
}
})
formRef.value.validate(async (valid: any) => {
if (valid) {
if (form.value.status == null) {
submitDevice({ ...form.value, reportPath: reportPath.value }).then(res => {
ElMessage({
message: '提交成功!',
type: 'success'
})
dialogVisible.value = false
emits('onSubmit')
})
} else {
reload({ ...form.value, reportPath: reportPath.value }).then(res => {
ElMessage({
message: '提交成功!',
type: 'success'
})
dialogVisible.value = false
emits('onSubmit')
})
}
}
})
}
// 上传报告
const uploadRef = ref()
const handleExceed: UploadProps['onExceed'] = files => {
uploadRef.value!.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
uploadRef.value!.handleStart(file)
uploadRef.value!.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
uploadRef.value!.handleStart(file)
}
const choose = (e: any) => {
uploadFile(e.raw, '/supervision/').then(res => {
reportPath.value = res.data.name
// reportPath.value = '测试aaa'
})
uploadFile(e.raw, '/supervision/').then(res => {
reportPath.value = res.data.name
// reportPath.value = '测试aaa'
})
}
//移除文件上传
const removeFile = (file: any, uploadFiles: any) => {
console.log(file, uploadFiles)
console.log(file, uploadFiles)
}
defineExpose({ open })
</script>
<style scoped lang="scss">
<style scoped lang='scss'>
.el-upload-list__item {
transition: none !important;
transition: none !important;
}
.el-select {
min-width: 180px;
min-width: 180px;
}
::v-deep .el-tree-node__children > div {
display: block !important;
display: block !important;
}
</style>

View File

@@ -1,54 +1,54 @@
<!---终端入网检测-->
<template>
<TableHeader area ref="TableHeaderRef">
<TableHeader area ref='TableHeaderRef'>
<template #select>
<el-form-item label="搜索">
<el-form-item label='搜索'>
<el-input
v-model="tableStore.table.params.searchValue"
placeholder="输入变电站.终端名称"
v-model='tableStore.table.params.searchValue'
placeholder='输入变电站.终端名称'
clearable
></el-input>
</el-form-item>
<el-form-item label="流程状态">
<el-select v-model="tableStore.table.params.status" clearable placeholder="请选择流程状态">
<el-form-item label='流程状态'>
<el-select v-model='tableStore.table.params.status' clearable placeholder='请选择流程状态'>
<el-option
v-for="item in statusSelect"
:key="item.id"
:label="item.name"
:value="item.id"
v-for='item in statusSelect'
:key='item.id'
:label='item.name'
:value='item.id'
></el-option>
</el-select>
</el-form-item>
<el-form-item label="处理状态">
<el-select v-model="tableStore.table.params.state" clearable placeholder="请选处理状态">
<el-form-item label='处理状态'>
<el-select v-model='tableStore.table.params.state' clearable placeholder='请选处理状态'>
<el-option
v-for="item in stateSelect"
:key="item.id"
:label="item.name"
:value="item.id"
v-for='item in stateSelect'
:key='item.id'
:label='item.name'
:value='item.id'
></el-option>
</el-select>
</el-form-item>
</template>
</TableHeader>
<Table ref="tableRef"/>
<Form ref="FormRef" @onSubmit="tableStore.index()"/>
<Table ref='tableRef' />
<Form ref='FormRef' @onSubmit='tableStore.index()' />
</template>
<script setup lang="ts">
import {ref, onMounted, provide, watch} from 'vue'
<script setup lang='ts'>
import { ref, onMounted, provide, watch } from 'vue'
import TableStore from '@/utils/tableStore'
import {ElMessage, ElMessageBox} from 'element-plus'
import { ElMessage, ElMessageBox } from 'element-plus'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import {useRouter} from 'vue-router'
import {useDictData} from '@/stores/dictData'
import { useRouter } from 'vue-router'
import { useDictData } from '@/stores/dictData'
import Form from './form.vue'
import {cancel, getInfoById} from '@/api/supervision-boot/cycleDetection/index'
import {useAdminInfo} from '@/stores/adminInfo'
import { cancel, getInfoById } from '@/api/supervision-boot/cycleDetection/index'
import { useAdminInfo } from '@/stores/adminInfo'
//获取登陆用户姓名和部门
const adminInfo = useAdminInfo()
const dictData = useDictData()
const {push, options, currentRoute} = useRouter()
const { push, options, currentRoute } = useRouter()
const flag = ref(false)
const TableHeaderRef = ref()
const tableRef = ref()
@@ -75,10 +75,10 @@ const tableStore = new TableStore({
publicHeight: 65,
method: 'POST',
column: [
{title: '序号', type: 'seq', width: 80},
{field: 'substation', title: '变电站'},
{ title: '序号', type: 'seq', width: 80 },
{ field: 'substation', title: '变电站' },
{field: 'dept', title: '供电公司'},
{ field: 'dept', title: '供电公司' },
{
field: 'deviceName',
title: '终端名称'
@@ -188,7 +188,7 @@ const tableStore = new TableStore({
},
click: async row => {
// cancelLeave(row)
const {value} = await ElMessageBox.prompt('请输入取消原因', '取消流程', {
const { value } = await ElMessageBox.prompt('请输入取消原因', '取消流程', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputType: 'textarea',
@@ -253,22 +253,27 @@ watch(
deep: true
}
)
const props = defineProps({id: {type: String, default: 'null'}})
const props = defineProps(['id', 'businessKey'])
watch(() => props.id, async (newValue, oldValue) => {
if (newValue === 'null') return // 直接返回,避免后续逻辑执行
const fullId = newValue.split('@')[0]
let nowTime = Date.now()
const routeTime = Number(newValue.split('@')[1])
if (isNaN(routeTime) || nowTime - routeTime > import.meta.env.VITE_ROUTE_TIME_OUT) return // 路由时间超过500ms则不执行
await getInfoById({id:fullId}).then(res => {
await getInfoById({ id: fullId }).then(res => {
if (res && res.code == 'A0000') {
FormRef.value.open('重新发起', res.data)
if (props.businessKey == '3') {
FormRef.value.open('报告上传', res.data)
} else {
FormRef.value.open('重新发起', res.data)
}
}
})
}, {immediate: true})
}, { immediate: true })
</script>
<style scoped lang="scss">
<style scoped lang='scss'>
:deep(.el-upload-list__item) {
width: 400px;
}