<template>
|
<ProDialog
|
:title="form.title"
|
v-model="visible"
|
@close="onDialogClose"
|
destroy-on-close
|
draggable
|
:width="800"
|
>
|
<ProForm :model="form" ref="dialogForm" label-width="120px">
|
<ProFormItemV2 label="账号:" prop="userName" :check-rules="[{ message: '请输入账号' }]">
|
<ProFormText
|
placeholder="请输入账号"
|
v-model.trim="form.userName"
|
:maxlength="30"
|
></ProFormText>
|
</ProFormItemV2>
|
<ProFormItemV2 label="姓名:" prop="name" :check-rules="[{ message: '请输入姓名' }]">
|
<ProFormText
|
placeholder="请输入姓名"
|
v-model.trim="form.name"
|
:maxlength="30"
|
></ProFormText>
|
</ProFormItemV2>
|
<ProFormItemV2
|
label="手机号:"
|
prop="phoneNumber"
|
:check-rules="[{ message: '请输入手机号', type: 'phone' }]"
|
>
|
<ProFormText placeholder="请输入手机号" v-model.trim="form.phoneNumber"></ProFormText>
|
</ProFormItemV2>
|
<ProFormItemV2
|
v-if="!isEdit"
|
label="密码:"
|
prop="password"
|
:check-rules="[{ message: '请输入密码', required: !form.id }]"
|
>
|
<ProFormText
|
placeholder="请输入密码"
|
v-model.trim="form.password"
|
:maxlength="30"
|
></ProFormText>
|
</ProFormItemV2>
|
|
<ProFormItemV2 label="备注:" prop="remark">
|
<ProFormTextArea
|
v-model="form.remark"
|
placeholder="请输入备注"
|
:maxlength="2000"
|
></ProFormTextArea>
|
</ProFormItemV2>
|
</ProForm>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="emit('onCancel')">取 消</el-button>
|
<el-button type="primary" @click="handleConfirm">确 定</el-button>
|
</span>
|
</template>
|
</ProDialog>
|
</template>
|
|
<script setup lang="ts">
|
import { FormInstance } from 'element-plus';
|
import {
|
ProDialog,
|
ProForm,
|
ProFormItemV2,
|
ProFormText,
|
ProFormTextArea,
|
} from '@bole-core/components';
|
import { BooleanOptions } from '@/constants';
|
|
defineOptions({
|
name: 'AddOrEditAccountDialog',
|
});
|
|
// type Props = {};
|
|
// const props = withDefaults(defineProps<Props>(), {});
|
|
const visible = defineModel({ type: Boolean });
|
|
type Form = {
|
title?: string;
|
id: string;
|
userName: string;
|
name: string;
|
phoneNumber: string;
|
password: string;
|
remark: string;
|
};
|
|
const form = defineModel<Form>('form');
|
const isEdit = computed(() => !!form.value?.id);
|
const emit = defineEmits<{
|
(e: 'onConfirm'): void;
|
(e: 'onCancel'): void;
|
}>();
|
|
const dialogForm = ref<FormInstance>();
|
|
function onDialogClose() {
|
if (!dialogForm.value) return;
|
dialogForm.value.resetFields();
|
}
|
|
function handleConfirm() {
|
if (!dialogForm.value) return;
|
dialogForm.value.validate((valid) => {
|
if (valid) {
|
emit('onConfirm');
|
} else {
|
return;
|
}
|
});
|
}
|
</script>
|