Files
admin-sjzx/src/views/pqs/supervise/harmonicSurvey/components/planAdd.vue

373 lines
13 KiB
Vue
Raw Normal View History

2024-03-19 16:38:02 +08:00
<template>
<el-dialog draggable :title="title" v-model="planAddition" width="500px" :before-close="cancelFn">
<el-form
:model="form"
ref="formRef"
:rules="rules"
label-width="auto"
scroll-to-error
:validate-on-rule-change="false"
class="form-one"
>
<el-form-item for="-" label="计划负责单位:">
2024-06-18 16:38:33 +08:00
<Area v-model="form.deptId" @change="changeArea" />
2024-05-24 11:24:18 +08:00
</el-form-item>
<el-form-item for="-" label="计划名称:" prop="planName">
<el-input v-model="form.planName" placeholder="请输入计划名称"></el-input>
2024-05-24 11:24:18 +08:00
</el-form-item>
<el-form-item label="监督类型:" prop="supvType">
2024-06-20 11:32:49 +08:00
<el-select v-model="form.supvType" placeholder="请选择监督类型" style="width: 100%" @change="++key">
<el-option
v-for="item in supvTypeOptionList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item for="-" label="监督对象名称:" prop="supvObjectName">
<el-input v-model="form.supvObjectName" placeholder="请输入监督对象名称"></el-input>
</el-form-item>
<el-form-item for="-" label="计划开始时间:" prop="planStartTime">
2024-05-24 11:24:18 +08:00
<el-date-picker
v-model="form.planStartTime"
2024-05-24 11:24:18 +08:00
type="date"
placeholder="选择计划开始时间"
value-format="YYYY-MM-DD"
:disabled-date="disableStartDate"
2024-05-24 11:24:18 +08:00
></el-date-picker>
</el-form-item>
<el-form-item for="-" label="计划结束时间:" prop="planEndTime">
2024-05-24 11:24:18 +08:00
<el-date-picker
v-model="form.planEndTime"
2024-05-24 11:24:18 +08:00
type="date"
placeholder="选择计划结束时间"
:disabled-date="disableEndDate"
2024-05-24 11:24:18 +08:00
value-format="YYYY-MM-DD"
></el-date-picker>
</el-form-item>
<!-- <el-form-item for="-" label="实际完成时间:" prop="planComplateTime">
2024-05-24 11:24:18 +08:00
<el-date-picker
v-model="form.planComplateTime"
2024-05-24 11:24:18 +08:00
type="date"
placeholder="选择实际完成时间"
value-format="YYYY-MM-DD"
></el-date-picker>
</el-form-item> -->
<!-- <el-form-item for="-" label="测试负责人:" prop="leader">
<el-input v-model="form.leader" placeholder="请输入测试负责人"></el-input>
</el-form-item> -->
<el-form-item for="-" label="系统电站:" prop="customSubstationFlag">
<!-- 默认值 开启 -->
<el-radio-group v-model="form.customSubstationFlag" @change="changeSubstationFlag">
2024-06-04 14:45:35 +08:00
<el-radio :value="0"></el-radio>
<el-radio :value="1"></el-radio>
</el-radio-group>
2024-05-24 11:24:18 +08:00
</el-form-item>
<el-form-item
2024-06-20 11:32:49 +08:00
:key="key"
label="关联电站:"
2024-06-04 14:45:35 +08:00
v-if="form.customSubstationFlag == 0"
2024-06-19 19:37:39 +08:00
:prop="dynamicProp"
style="display: flex; align-items: center"
>
<el-cascader
v-model="form.substation"
2024-06-18 16:38:33 +08:00
:options="treeData"
:props="defaultProps"
clearable
filterable
collapse-tags
collapse-tags-tooltip
placeholder="请选择关联电站"
/>
2024-05-24 11:24:18 +08:00
<!-- <el-tree-select
accordion
ref="treeRef"
:default-expand-all="false"
show-checkbox
check-strictly
:highlight-current="true"
readonly
node-key="id"
:props="defaultProps"
v-model="form.substation"
2024-05-24 11:24:18 +08:00
:data="treeList"
:render-after-expand="false"
/> -->
</el-form-item>
2024-06-19 19:37:39 +08:00
2024-06-20 11:32:49 +08:00
<el-form-item
for="-"
label="关联电站:"
:key="key"
v-if="form.customSubstationFlag == 1"
:prop="dynamicProp"
>
<el-input v-model="form.substation" placeholder="请输入关联电站"></el-input>
</el-form-item>
<!-- <el-form :model="form" label-width="auto"> -->
<!-- <el-form-item for="-" class="uploadFile" label="普测报告:" prop="fileList">
2024-05-24 11:24:18 +08:00
<el-upload
v-model:file-list="form.fileList"
2024-05-24 11:24:18 +08:00
ref="upload"
action=""
:limit="5"
:on-exceed="handleExceed"
:auto-upload="false"
:on-remove="removeFile"
2024-05-24 11:24:18 +08:00
>
<template #trigger>
<el-button type="primary">上传文件</el-button>
</template>
</el-upload>
</el-form-item> -->
2024-05-24 11:24:18 +08:00
<!-- </el-form> -->
</el-form>
<!-- <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">添加电站</el-divider> -->
<!-- <generalTestTree ref="treeRef" /> -->
2024-05-15 12:27:13 +08:00
<!-- <div
v-if="
(title == '查看计划' || title == '计划审核') &&
(title == '计划审核' || form.status == 1 || form.status == 3 || form.status == 4)
"
2024-03-19 16:38:02 +08:00
>
<el-divider content-position="left" style="font-size: 18px; font-weight: bolder">审核意见</el-divider>
<el-input
:disabled="title != '计划审核'"
type="textarea"
:autosize="{ minRows: 2, maxRows: 4 }"
v-model="form.checkComment"
></el-input>
2024-05-15 12:27:13 +08:00
</div> -->
2024-05-14 18:17:53 +08:00
<template #footer v-if="title != '查看计划'">
<div class="dialog-footer">
2024-05-14 18:17:53 +08:00
<el-button @click="cancelFn">取消</el-button>
2024-06-19 19:37:39 +08:00
<el-button type="primary" @click="submitFn(true)">保存</el-button>
<el-button type="primary" @click="submitFn(false)">提交审批</el-button>
</div>
</template>
2024-03-19 16:38:02 +08:00
</el-dialog>
</template>
<script setup lang="ts">
2024-06-19 19:37:39 +08:00
import { ref, computed, nextTick } from 'vue'
import {
addSurvey,
auditSurvey,
addSurveyPlan,
getById,
initDetpStataionTree,
updateSurveyPlan
} from '@/api/process-boot/generalTest'
import Area from '@/components/form/area/index.vue'
2024-05-14 18:17:53 +08:00
import { ElMessage, UploadProps } from 'element-plus'
2024-06-04 14:45:35 +08:00
import { useDictData } from '@/stores/dictData'
2024-06-04 14:45:35 +08:00
const emit = defineEmits(['onsubmit'])
2024-06-04 14:45:35 +08:00
const dictData = useDictData()
const supvTypeOptionList = dictData.getBasicData('supv_type')
2024-03-19 16:38:02 +08:00
const title = ref('')
const planAddition = ref(false)
2024-06-20 11:32:49 +08:00
const key: any = ref(0)
2024-06-19 19:37:39 +08:00
const dynamicProp = computed(() => {
return supvTypeOptionList.filter(item => item.id === form.value.supvType)[0]?.code == 'Technical_Super'
? ''
: 'substation'
})
2024-05-24 11:24:18 +08:00
const defaultProps = ref({
label: 'name',
value: 'id',
checkStrictly: true,
emitPath: false,
expandTrigger: 'hover' as const,
multiple: true
2024-05-24 11:24:18 +08:00
})
//开始时间不能大于结束时间
const disableStartDate = (time: any) => {
if (time && form.value.planEndTime) {
return time.getTime() > new Date(form.value.planEndTime).getTime()
} else {
return false
}
}
//结束时间不能小于开始时间
const disableEndDate = (time: any) => {
if (time && form.value.planStartTime) {
2024-06-18 16:38:33 +08:00
return time.getTime() <= new Date(form.value.planStartTime).getTime() - 8.64e7
} else {
return false
}
}
const form: any = ref({
// orgName: '',
deptId: dictData.state.area[0].id,
2024-03-19 16:38:02 +08:00
planStartTime: '',
planEndTime: '',
planName: '',
// fileList: [],
// checkComment: '',
// filePath: '',
substation: '', //关联电站
2024-06-04 14:45:35 +08:00
customSubstationFlag: 0 //电站类型
2024-03-19 16:38:02 +08:00
})
2024-05-24 11:24:18 +08:00
const props = {
expandTrigger: 'hover' as const
2024-05-24 11:24:18 +08:00
}
const formRef = ref()
const treeRef = ref()
const rules = ref({
planStartTime: [{ required: true, message: '选择计划开始时间', trigger: 'change' }],
planEndTime: [{ required: true, message: '选择计划结束时间', trigger: 'change' }],
supvType: [{ required: true, message: '请选择监督类型', trigger: 'change' }],
2024-05-14 18:17:53 +08:00
planComplateTime: [{ required: true, message: '选择实际完成时间 ', trigger: 'change' }],
supvObjectName: [{ required: true, message: '请输入计划名称', trigger: 'blur' }],
planName: [{ required: true, message: '请输入计划名称', trigger: 'blur' }],
2024-05-24 11:24:18 +08:00
leader: [{ required: true, message: '请输入测试负责人', trigger: 'blur' }],
2024-06-20 11:32:49 +08:00
substation: [{ required: true, message: '请选择关联电站', trigger: 'blur' }]
// fileList: [{ required: true, message: '请上传文件', trigger: 'change' }],
})
const changeSubstationFlag = () => {
console.log(form.value.customSubstationFlag)
//处理所属变电站手都输入1/下拉数据0
2024-06-21 10:15:25 +08:00
key.value += 1
2024-06-04 14:45:35 +08:00
if (form.value.customSubstationFlag == 0) {
rules.value.substation[0].message = '请选择关联电站'
2024-06-20 11:32:49 +08:00
form.value.substation = []
} else {
rules.value.substation[0].message = '请输入关联电站'
2024-06-20 11:32:49 +08:00
form.value.substation = ''
}
}
2024-03-19 16:38:02 +08:00
const cancelFn = () => {
2024-06-04 14:45:35 +08:00
formRef.value?.resetFields()
2024-05-24 11:24:18 +08:00
// treeRef.value.setKey([])
2024-03-19 16:38:02 +08:00
planAddition.value = false
}
2024-05-24 11:24:18 +08:00
const treeList = ref()
const treeListCgy = ref()
2024-06-18 16:38:33 +08:00
const treeData = ref()
2024-05-24 11:24:18 +08:00
const loadData = () => {
initDetpStataionTree({ orgId: dictData.state.area[0].id }).then(res => {
treeList.value = res.data
initDetpStataionTree({ orgId: 'a3069759b0b6072c99cf9a7af6c162e9' }).then(res => {
treeListCgy.value = res.data
setTimeout(() => {
changeArea()
}, 10)
})
2024-05-24 11:24:18 +08:00
})
}
2024-06-04 14:45:35 +08:00
const detailById = (id: any) => {
2024-06-04 14:45:35 +08:00
getById(id).then(res => {
form.value = res.data
2024-06-21 10:15:25 +08:00
form.value.substation =
res.data.customSubstationFlag == 0 ? res.data.substation.split(',') : res.data.substation
key.value += 1
2024-06-04 14:45:35 +08:00
})
}
2024-03-19 16:38:02 +08:00
// 提交
2024-06-19 19:37:39 +08:00
const submitFn = (flag: boolean) => {
if (flag) {
const addForm = JSON.parse(JSON.stringify(form.value))
if (form.value.customSubstationFlag == 0) {
2024-06-20 11:32:49 +08:00
addForm.substation = addForm.substation.length == 0 ? '' : addForm.substation.join(',')
}
2024-06-19 19:37:39 +08:00
addForm.saveOrCheckflag = '1'
2024-06-20 11:32:49 +08:00
addSurveyPlan(addForm).then(res => {
cancelFn()
2024-06-21 10:15:25 +08:00
ElMessage.success('保存成功!')
2024-06-20 11:32:49 +08:00
emit('onsubmit')
})
2024-06-19 19:37:39 +08:00
} else {
formRef.value.validate(async (valid: any) => {
if (valid) {
//选择系统变电站
const addForm = JSON.parse(JSON.stringify(form.value))
if (form.value.customSubstationFlag == 0) {
2024-06-20 11:32:49 +08:00
addForm.substation = addForm.substation.length == 0 ? '' : addForm.substation.join(',')
2024-06-19 19:37:39 +08:00
}
addForm.saveOrCheckflag = '2'
if (title.value == '计划新增') {
addSurveyPlan(addForm).then(res => {
cancelFn()
2024-06-21 10:15:25 +08:00
ElMessage.success('计划新增成功!')
2024-06-19 19:37:39 +08:00
emit('onsubmit')
})
} else {
updateSurveyPlan(addForm).then(res => {
cancelFn()
2024-06-21 10:15:25 +08:00
ElMessage.success('重新发起成功!')
2024-06-19 19:37:39 +08:00
emit('onsubmit')
})
}
}
})
}
}
2024-06-18 16:38:33 +08:00
// 修改关联电站
const changeArea = () => {
let list: any = []
2024-06-18 16:38:33 +08:00
treeList.value.forEach((item: any) => {
if (item.id == form.value.deptId) {
list.push(item)
if (item.id != treeListCgy.value[0].id && item.name != '冀北电力有限公司' && item.name != '超高压') {
list.push(...treeListCgy.value)
}
2024-06-18 16:38:33 +08:00
} else {
list.push(item.children.filter((v: any) => v.id == form.value.deptId)[0])
if (form.value.deptId != treeListCgy.value[0].id) {
list.push(...treeListCgy.value)
}
2024-06-18 16:38:33 +08:00
}
})
treeData.value = list
}
const audit = (filePath: any) => {
return
}
2024-05-14 18:17:53 +08:00
// 上传文件
// 文件数超出提示
const handleExceed: UploadProps['onExceed'] = (): void => {
ElMessage.error(`上传文件数量不能超过5个!`)
}
//移除文件上传
const removeFile = (file: any, uploadFiles: any) => {
console.log(file, uploadFiles)
}
2024-06-04 14:45:35 +08:00
const open = (text: string, id: any) => {
loadData()
form.value = Object.assign({
// orgName: '',
deptId: dictData.state.area[0].id,
planStartTime: '',
planEndTime: '',
planName: '',
substation: '', //关联电站
2024-06-04 14:45:35 +08:00
customSubstationFlag: 0 //电站类型
})
2024-03-19 16:38:02 +08:00
title.value = text
planAddition.value = true
2024-06-20 11:32:49 +08:00
setTimeout(() => {
2024-06-21 10:15:25 +08:00
key.value += 1
2024-06-20 11:32:49 +08:00
}, 10)
if (id) {
2024-06-04 14:45:35 +08:00
detailById(id)
}
2024-03-19 16:38:02 +08:00
}
defineExpose({ open })
</script>
2024-05-14 18:17:53 +08:00
<style lang="scss" scoped>
// :deep(.el-upload-list__item-info) {
// width: 250px;
// }
2024-05-14 18:17:53 +08:00
</style>