<!-- 设备台账新增或编辑页面 --> <script lang="ts" setup name="measureDevice"> import type { FormInstance, FormRules } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus' import type { menuType } from '../standingBook-interface' import baseInfo from './baseInfo.vue' // 基本信息 import table from './templateTable.vue' const emits = defineEmits(['resetData']) const title = ref('') const name = ref('') const menu = shallowRef<menuType[]>([ { name: '基本信息', comp: baseInfo }, { name: '周检记录', comp: table }, { name: '状态变更记录', comp: table }, { name: '使用记录', comp: table }, { name: '检定证书', comp: table }, ]) const currentCompRef = ref() const current = ref('基本信息') const currentComp = shallowRef(baseInfo) watch(current, (newValue) => { currentComp.value = menu.value.filter(item => item.name === newValue)[0].comp }) // 取消 const resetForm = () => { emits('resetData') } // 提交 const submitForm = async () => { ElMessageBox.confirm( '确认提交吗?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ).then((res) => { // 提交 emits('resetData') }) } // 弹窗初始化 const initDialog = (row: any) => { title.value = row.title name.value = row.name // 初始化基本信息页面 // console.log(baseInfo, 'baseInfo') currentCompRef.value.initDialog({ title: row.title, }) } defineExpose({ initDialog }) </script> <template> <app-container style="overflow: hidden;"> <div class="body-container"> <div class="header"> <div class="title"> {{ name }} -{{ title }} </div> <span class="btns"> <el-button v-if="title !== '详情'" type="primary" @click="submitForm"> 保存 </el-button> <el-button type="info" @click="resetForm"> 关闭 </el-button> </span> </div> <div class="body"> <!-- 三级菜单 --> <el-radio-group v-model="current"> <el-radio-button v-for="item in menu" :key="item.name" :label="item.name"> {{ item.name }} </el-radio-button> </el-radio-group> </div> <!-- 展示区域 --> <component :is="currentComp" ref="currentCompRef" :name="current" /> </div> </app-container> </template> <style lang="scss" scoped> .body-container { .form { border-radius: 8px; background-color: #fff; margin-top: 10px; padding-top: 10px; } .header { background-color: #fff; height: 40px; border-radius: 8px; align-items: center; flex-direction: column; justify-content: center; display: flex; .title { font-weight: 700; } .btns { position: absolute; right: 40px; top: 14px; } } .body { background-color: #fff; margin-top: 10px; } } .marg { margin-top: 5px; } .isDetail { ::v-deep { .el-form-item.is-required:not(.is-no-asterisk) .el-form-item__label-wrap > .el-form-item__label::before, .el-form-item.is-required:not(.is-no-asterisk) > .el-form-item__label::before { display: none; } } } </style>