|
|
|
|
@ -51,7 +51,7 @@
|
|
|
|
|
|
|
|
|
|
<el-col :span="12" :offset="0">
|
|
|
|
|
<el-form-item prop="password" label="密码">
|
|
|
|
|
<el-input v-model="addModel.password"></el-input>
|
|
|
|
|
<el-input type="password" v-model="addModel.password"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
@ -73,8 +73,11 @@ import useDialog from '@/hooks/useDialog';
|
|
|
|
|
import { ref, reactive } from 'vue';
|
|
|
|
|
|
|
|
|
|
// 引入UserModel获取表单数据类型
|
|
|
|
|
import { UserModel } from '@/api/user/userModel';
|
|
|
|
|
import { FormInstance } from 'element-plus';
|
|
|
|
|
import type { UserModel } from '@/api/user/userModel';
|
|
|
|
|
import type { FormInstance } from 'element-plus';
|
|
|
|
|
|
|
|
|
|
// 引入post的新增接口
|
|
|
|
|
import { addUserApi } from '../../api/user/index';
|
|
|
|
|
|
|
|
|
|
// 获取弹窗组件属性
|
|
|
|
|
const { dialog, onClose, onConfirm, onShow } = useDialog()
|
|
|
|
|
@ -85,7 +88,7 @@ const show = (title: string, width: number, height: number) => {
|
|
|
|
|
onShow(title, width, height)
|
|
|
|
|
// dialog.visible = true;
|
|
|
|
|
// 清空表单
|
|
|
|
|
addFormRef.value.resetFields()
|
|
|
|
|
addFormRef.value?.resetFields()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 将显示弹框方法暴露给父组件
|
|
|
|
|
@ -138,9 +141,14 @@ const rules = reactive({
|
|
|
|
|
|
|
|
|
|
// 表单提交
|
|
|
|
|
const commit = () => {
|
|
|
|
|
addFormRef.value.validate((valid) => {
|
|
|
|
|
addFormRef.value?.validate(async(valid) => {
|
|
|
|
|
if(valid){
|
|
|
|
|
onConfirm()
|
|
|
|
|
// 调用addUserApi,将前端表单收集到的数据提交给数据库
|
|
|
|
|
let res = await addUserApi(addModel)
|
|
|
|
|
if(res && res.code == 200){
|
|
|
|
|
onConfirm()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|