|
|
@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
|
|
<SysDialog :title="dialog.title" :visible="dialog.visible" :width="dialog.width" :height="dialog.height"
|
|
|
|
|
|
|
|
@onClose="onClose" @onConfirm="commit">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 通过插槽名称输入内容 -->
|
|
|
|
|
|
|
|
<template #content>
|
|
|
|
|
|
|
|
<el-form :model="addModel" ref="addFormRef" :rules="rules" label-width="80px" :inline="false" size="default">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 创建el-row容器,将姓名,性别放入一行美化页面 -->
|
|
|
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
|
|
|
<el-col :span="12" :offset="0">
|
|
|
|
|
|
|
|
<el-form-item prop="name" label="姓名">
|
|
|
|
|
|
|
|
<el-input v-model="addModel.name"></el-input>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-col :span="12" :offset="0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 通过单选框实现性别选择 -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item prop="sex" label="性别">
|
|
|
|
|
|
|
|
<el-radio-group v-model="addModel.sex">
|
|
|
|
|
|
|
|
<el-radio :value="'0'">男</el-radio>
|
|
|
|
|
|
|
|
<el-radio :value="'1'">女</el-radio>
|
|
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
|
|
|
<el-col :span="12" :offset="0">
|
|
|
|
|
|
|
|
<el-form-item prop="phone" label="电话">
|
|
|
|
|
|
|
|
<el-input v-model="addModel.phone"></el-input>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-col :span="12" :offset="0">
|
|
|
|
|
|
|
|
<el-form-item prop="email" label="邮箱">
|
|
|
|
|
|
|
|
<el-input v-model="addModel.email"></el-input>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
|
|
|
<el-col :span="12" :offset="0">
|
|
|
|
|
|
|
|
<el-form-item prop="username" label="账户">
|
|
|
|
|
|
|
|
<el-input v-model="addModel.username"></el-input>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-col :span="12" :offset="0">
|
|
|
|
|
|
|
|
<el-form-item prop="password" label="密码">
|
|
|
|
|
|
|
|
<el-input v-model="addModel.password"></el-input>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</SysDialog>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
|
|
// 引入弹窗组件
|
|
|
|
|
|
|
|
import SysDialog from '@/components/SysDialog.vue';
|
|
|
|
|
|
|
|
// 引入弹窗组件相关方法
|
|
|
|
|
|
|
|
import useDialog from '@/hooks/useDialog';
|
|
|
|
|
|
|
|
import { ref, reactive } from 'vue';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 引入UserModel获取表单数据类型
|
|
|
|
|
|
|
|
import { UserModel } from '@/api/user/userModel';
|
|
|
|
|
|
|
|
import { FormInstance } from 'element-plus';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取弹窗组件属性
|
|
|
|
|
|
|
|
const { dialog, onClose, onConfirm, onShow } = useDialog()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 显示弹框,改写属性
|
|
|
|
|
|
|
|
const show = (title: string, width: number, height: number) => {
|
|
|
|
|
|
|
|
// dialog.title:
|
|
|
|
|
|
|
|
onShow(title, width, height)
|
|
|
|
|
|
|
|
// dialog.visible = true;
|
|
|
|
|
|
|
|
// 清空表单
|
|
|
|
|
|
|
|
addFormRef.value.resetFields()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将显示弹框方法暴露给父组件
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
|
|
|
|
show
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 表单绑定对象
|
|
|
|
|
|
|
|
const addModel = reactive<UserModel>({
|
|
|
|
|
|
|
|
userId: "",
|
|
|
|
|
|
|
|
username: "",
|
|
|
|
|
|
|
|
password: "",
|
|
|
|
|
|
|
|
phone: "",
|
|
|
|
|
|
|
|
email: "",
|
|
|
|
|
|
|
|
sex: "",
|
|
|
|
|
|
|
|
name: "",
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 表单ref属性
|
|
|
|
|
|
|
|
const addFormRef = ref<FormInstance>()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 定义表单验证规则
|
|
|
|
|
|
|
|
const rules = reactive({
|
|
|
|
|
|
|
|
name: [{
|
|
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
|
|
message: '请输入姓名',
|
|
|
|
|
|
|
|
trigger: 'blur'
|
|
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
sex: [{
|
|
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
|
|
message: '请选择性别',
|
|
|
|
|
|
|
|
trigger: 'blur'
|
|
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
phone: [{
|
|
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
|
|
message: '请输入电话',
|
|
|
|
|
|
|
|
trigger: 'blur'
|
|
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
username: [{
|
|
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
|
|
message: '请输入用户名',
|
|
|
|
|
|
|
|
trigger: 'blur'
|
|
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
password: [{
|
|
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
|
|
message: '请输入密码',
|
|
|
|
|
|
|
|
trigger: 'blur'
|
|
|
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 表单提交
|
|
|
|
|
|
|
|
const commit = () => {
|
|
|
|
|
|
|
|
addFormRef.value.validate((valid) => {
|
|
|
|
|
|
|
|
if(valid){
|
|
|
|
|
|
|
|
onConfirm()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style></style>
|