mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 13:04:57 +08:00
139 lines
4.3 KiB
Vue
139 lines
4.3 KiB
Vue
![]() |
<template>
|
||
|
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100">
|
||
|
<el-form-item label="类型" prop="type">
|
||
|
<el-radio-group v-model="formData.type" :disabled="type === 'edit'">
|
||
|
<el-radio label="菜单" border>菜单</el-radio>
|
||
|
<el-radio label="按钮" border>按钮</el-radio>
|
||
|
</el-radio-group>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="上级菜单" prop="fatherMenu">
|
||
|
<el-select v-model="formData.fatherMenu" placeholder="请选择上级菜单" clearable>
|
||
|
<el-option v-for="item in fatherMenuOption" :key="item.value" :label="item.label" :value="item.value" />
|
||
|
</el-select>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="菜单名称" prop="menuName">
|
||
|
<el-input v-model="formData.menuName" placeholder="请输入菜单名称"></el-input>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="图标" prop="icon">
|
||
|
<el-input v-model="formData.menuName" placeholder="请输入菜单名称"></el-input>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="路由" prop="route">
|
||
|
<el-input v-model="formData.route" placeholder="请输入路由"></el-input>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="排序" prop="order">
|
||
|
<el-input class="number-input" v-model="formData.order" type="number" input-style="text-align: center;" @change="numberInputChange">
|
||
|
<template #prepend>
|
||
|
<el-button text icon="Minus" :disabled="formData.order <= 1" @click="formData.order--" />
|
||
|
</template>
|
||
|
<template #append>
|
||
|
<el-button text icon="Plus" @click="formData.order++" />
|
||
|
</template>
|
||
|
</el-input>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="是否显示" prop="isShow">
|
||
|
<el-radio-group v-model="formData.isShow">
|
||
|
<el-radio :label="true" border>是</el-radio>
|
||
|
<el-radio :label="false" border>否</el-radio>
|
||
|
</el-radio-group>
|
||
|
</el-form-item>
|
||
|
|
||
|
<div style="text-align: right;padding-top: 0;">
|
||
|
<el-button class="f18" @click="close">取消</el-button>
|
||
|
<el-button class="f18" type="primary" @click="saveData">确认</el-button>
|
||
|
</div>
|
||
|
</el-form>
|
||
|
|
||
|
<el-dialog v-model="isIconDialog" title="选择图标" width="30%">
|
||
|
<div class="iconfont-box">
|
||
|
<div class="iconfont-item" v-for="item in iconfont.glyphs" :key="item.font_class">
|
||
|
<i :class="'icon-' + item.font_class"></i>
|
||
|
</div>
|
||
|
</div>
|
||
|
</el-dialog>
|
||
|
</template>
|
||
|
|
||
|
<script lang='ts' setup>
|
||
|
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
|
||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
|
import iconfont from "@/assets/font/iconfont.json";
|
||
|
|
||
|
const emit = defineEmits(['close'])
|
||
|
|
||
|
const props = defineProps({
|
||
|
type: String
|
||
|
})
|
||
|
|
||
|
const fatherMenuOption = [
|
||
|
{ label: '权限管理', value: '权限管理' },
|
||
|
{ label: '患者管理', value: '患者管理' },
|
||
|
]
|
||
|
const rules = reactive({
|
||
|
menuName: [
|
||
|
{ required: true, message: '请输入菜单名称', trigger: ['blur', 'change'] },
|
||
|
],
|
||
|
route: [
|
||
|
{ required: true, message: '请输入路由地址', trigger: ['blur', 'change'] },
|
||
|
]
|
||
|
})
|
||
|
|
||
|
const formRef = ref()
|
||
|
const isIconDialog = ref(false)
|
||
|
const formData = ref({} as any)
|
||
|
|
||
|
|
||
|
onMounted(() => {
|
||
|
resetData()
|
||
|
console.log(iconfont.glyphs)
|
||
|
})
|
||
|
|
||
|
defineExpose({
|
||
|
formData,
|
||
|
resetData,
|
||
|
})
|
||
|
function close() {
|
||
|
emit('close')
|
||
|
}
|
||
|
function resetData() {
|
||
|
formData.value = {
|
||
|
id: '',
|
||
|
type: '菜单',
|
||
|
fatherMenu: '',
|
||
|
menuName: '',
|
||
|
route: '',
|
||
|
order: 1,
|
||
|
isShow: true
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const numberInputChange = (e: any) => {
|
||
|
if(!Number(e)) {
|
||
|
formData.value.order = 1
|
||
|
}
|
||
|
}
|
||
|
const saveData = async () => {
|
||
|
await formRef.value.validate((valid: any, fields: any) => {
|
||
|
if (valid) {
|
||
|
ElMessage.success('保存成功!')
|
||
|
close()
|
||
|
} else {
|
||
|
console.log('error submit!', fields)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style lang='scss' scoped>
|
||
|
:deep(.el-form-item) {
|
||
|
.el-form-item__label {
|
||
|
display: block;
|
||
|
// text-align: justify;
|
||
|
// text-align-last: justify;
|
||
|
padding: 0 10px 0 20px;
|
||
|
|
||
|
&:before {
|
||
|
display: none;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</style>
|