From e989421722e522f4879a354a15ba14912d7acaaa Mon Sep 17 00:00:00 2001 From: Your Name <123456> Date: 星期五, 24 二月 2023 16:49:38 +0800 Subject: [PATCH] Merge branch 'master' of https://sinanoaq.cn:8888/r/scienceexperimentweb --- src/views/analyse/plan/components/planDialog.vue | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 230 insertions(+), 0 deletions(-) diff --git a/src/views/analyse/plan/components/planDialog.vue b/src/views/analyse/plan/components/planDialog.vue new file mode 100644 index 0000000..2ee4fe9 --- /dev/null +++ b/src/views/analyse/plan/components/planDialog.vue @@ -0,0 +1,230 @@ +<template> + <div class="system-menu-dialog-container"> + <el-dialog :title="planDialogState.title" v-model="planDialogState.planDialogVisible" width="600px"> + <el-form ref="planFormRef" :rules="planDialogState.planFormRules" :model="planDialogState.planForm" size="default" label-width="120px"> + <el-row :gutter="35"> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="风险分析单元" prop="riskUnitId"> + <el-select :disabled="planDialogState.disabled" v-model="planDialogState.planForm.riskUnitId" style="width:100%" placeholder="风险分析单元" clearable> + <el-option v-for="item in planDialogState.riskUnitList" :key="item.id" :label="item.riskName" :value="item.id"></el-option> + </el-select> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="评估计划名称" prop="assessPlanName"> + <el-input :disabled="planDialogState.disabled" v-model="planDialogState.planForm.assessPlanName" placeholder="评估计划名称" clearable></el-input> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="计划制定人" prop="planUserId"> + <el-select :disabled="planDialogState.disabled" v-model="planDialogState.planForm.planUserId" style="width:100%" placeholder="计划制定人" clearable> + <el-option v-for="item in planDialogState.personList" :key="item.id" :label="item.realName" :value="item.id"></el-option> + </el-select> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="评估时间" prop="assessPlanName"> + <el-date-picker + :disabled="planDialogState.disabled" + type="datetimerange" + v-model="planDialogState.time" + start-placeholder="开始时间" + end-placeholder="结束时间" + format="YYYY-MM-DD HH:mm:ss" + value-format="YYYY-MM-DD HH:mm:ss" + @change="formatTime"> + </el-date-picker> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="辨识方法" prop="identificationMethod"> + <el-select :disabled="planDialogState.disabled" v-model="planDialogState.planForm.identificationMethod" style="width:100%" placeholder="辨识方法" clearable> + <el-option v-for="item in planDialogState.identificationMethodList" :key="item.id" :label="item.name" :value="item.id"></el-option> + </el-select> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="负责人" prop="identificationUserId"> + <el-select :disabled="planDialogState.disabled" v-model="planDialogState.planForm.identificationUserId" style="width:100%" placeholder="负责人" clearable> + <el-option v-for="item in planDialogState.personList" :key="item.id" :label="item.realName" :value="item.id"></el-option> + </el-select> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="推荐评价方法" prop="evaluateMethod"> + <el-select :disabled="planDialogState.disabled" v-model="planDialogState.planForm.evaluateMethod" style="width:100%" placeholder="推荐评价方法" clearable> + <el-option v-for="item in planDialogState.evaluateMethodList" :key="item.id" :label="item.name" :value="item.id"></el-option> + </el-select> + </el-form-item> + </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="评价专家" prop="evaluateUserId"> + <el-select :disabled="planDialogState.disabled" v-model="planDialogState.planForm.evaluateUserId" style="width:100%" placeholder="评价专家" clearable> + <el-option v-for="item in planDialogState.personList" :key="item.id" :label="item.realName" :value="item.id"></el-option> + </el-select> + </el-form-item> + </el-col> + </el-row> + </el-form> + <template #footer> + <span class="dialog-footer"> + <el-button @click="planDialogState.planDialogVisible = !planDialogState.planDialogVisible" size="default">取 消</el-button> + <el-button v-if="!planDialogState.disabled" type="primary" @click="onSubmitPlan" size="default">确定</el-button> + </span> + </template> + </el-dialog> + </div> +</template> + +<script setup lang="ts"> +import { reactive, ref } from "vue"; +import {ElMessage} from "element-plus"; +import {planApi} from "/@/api/analyse/plan"; +import {isValidKey} from "/@/utils/methods"; + +const planFormRef = ref() + +const planDialogState = reactive<PlanDialogType>({ + title: '', + time:[], + disabled: false, + planDialogVisible: false, + planForm: { + riskUnitId: null, + planUserId: null, + assessPlanName: '', + assessStartTime: '', + assessEndTime: '', + identificationMethod: null, + identificationUserId: null, + evaluateMethod: null, + evaluateUserId: null, + }, + planFormRules: { + deviceCode: [{ required: true, message: '请填写设备编号', trigger: 'blur' }], + deviceName: [{ required: true, message: '请填写设备名称', trigger: 'blur' }], + devicePower: [{ required: true, message: '请填写设备功率', trigger: 'blur' }], + riskUnitId: [{ required: true, message: '请选择风险分析单元', trigger: 'change' }], + planUserId: [{ required: true, message: '请选择计划制定人', trigger: 'change' }], + identificationMethod: [{ required: true, message: '请选择辨识方法', trigger: 'change' }], + identificationUserId: [{ required: true, message: '请选择负责人', trigger: 'change' }], + evaluateMethod: [{ required: true, message: '请选择推荐评价方法', trigger: 'change' }], + evaluateUserId: [{ required: true, message: '请选择评价专家', trigger: 'change' }], + }, + riskUnitList: [], + personList: [], + identificationMethodList: [ + {id:1, name: 'PHA'}, + {id:2, name: 'JHA'}, + {id:3, name: 'SCL'}, + {id:4, name: 'HAZOP'}, + {id:5, name: '类比法'}, + ], + evaluateMethodList: [ + {id:1, name: 'LEC'}, + {id:2, name: 'LS'}, + {id:3, name: 'MES'}, + {id:4, name: 'RS'}, + ] +}) + +const showPlanDialog = (title: string, value: PlanType, riskUnitList: RiskUnitType [], personList: SystemPersonType []) => { + planDialogState.planDialogVisible = true; + planDialogState.riskUnitList = riskUnitList; + planDialogState.personList = personList; + planDialogState.disabled = false + setTimeout(() => { + planFormRef.value.clearValidate(); + }); + if(title === '新增'){ + planDialogState.title = '新增'; + planDialogState.planForm = { + riskUnitId: null, + planUserId: null, + assessPlanName: '', + assessStartTime: '', + assessEndTime: '', + identificationMethod: null, + identificationUserId: null, + evaluateMethod: null, + evaluateUserId: null, + }; + }else if(title === '查看'){ + planDialogState.title = '查看'; + planDialogState.disabled = true + planDialogState.time = [value.assessStartTime, value.assessEndTime] + for(let i in planDialogState.planForm){ + if(isValidKey(i, planDialogState.planForm)){ + planDialogState.planForm[i] = value[i] + } + } + }else{ + planDialogState.title = '编辑'; + planDialogState.planForm.id = value.id + planDialogState.time = [value.assessStartTime, value.assessEndTime] + for(let i in planDialogState.planForm){ + if(isValidKey(i, planDialogState.planForm)){ + planDialogState.planForm[i] = value[i] + } + } + } +}; + +const formatTime = () => { + planDialogState.planForm.assessStartTime = planDialogState.time === null ? '' : planDialogState.time[0] + planDialogState.planForm.assessEndTime = planDialogState.time === null ? '' : planDialogState.time[1] +}; + +const onSubmitPlan = () => { + planFormRef.value.validate(async(valid: boolean) => { + if(valid){ + if(planDialogState.title === '新增'){ + let res = await planApi().addPlan(planDialogState.planForm); + if(res.data.code === 100){ + emit('refresh') + planDialogState.planDialogVisible = false; + ElMessage({ + type: 'success', + message: '新增成功' + }) + }else{ + ElMessage({ + type: 'warning', + message: res.data.msg, + }); + } + }else{ + let res = await planApi().modPlan(planDialogState.planForm) + if(res.data.code === 100){ + emit('refresh') + planDialogState.planDialogVisible = false; + ElMessage({ + type: 'success', + message: '编辑成功' + }) + }else{ + ElMessage({ + type: 'warning', + message: res.data.msg, + }); + } + } + }else{ + ElMessage({ + type: 'warning', + message: '请完善基本信息', + }); + } + }) +} + +const emit = defineEmits(['refresh']) + +defineExpose({ + showPlanDialog +}) +</script> + +<style scoped> + +</style> -- Gitblit v1.9.2