<template>
|
<ProDialog
|
:title="`${title}类别`"
|
v-model="visible"
|
@close="onDialogClose"
|
destroy-on-close
|
draggable
|
>
|
<ProForm :model="form" ref="dialogForm" label-width="90px">
|
<ProFormItemV2 label="名称:" prop="name" :check-rules="[{ message: '请输入名称' }]">
|
<ProFormText
|
placeholder="请输入名称"
|
v-model.trim="form.name"
|
:maxlength="15"
|
></ProFormText>
|
</ProFormItemV2>
|
<ProFormItemV2 label="编号:" prop="code">
|
<ProFormText placeholder="请输入编号" v-model.trim="form.code"></ProFormText>
|
</ProFormItemV2>
|
<ProFormItemV2 label="字段名:" prop="fieldNames">
|
<ProFormText placeholder="请输入编号" v-model.trim="form.fieldNames"></ProFormText>
|
</ProFormItemV2>
|
<ProFormItemV2 label="排序:" prop="sort">
|
<ProFormInputNumber
|
v-model="form.sort"
|
:controls="false"
|
:min="0"
|
:max="999999"
|
></ProFormInputNumber>
|
</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,
|
ProFormInputNumber,
|
} from '@bole-core/components';
|
|
defineOptions({
|
name: 'AddOrEditDictionaryCategory',
|
});
|
|
type Form = {
|
id?: string;
|
name: string;
|
sort: number;
|
code: string;
|
fieldNames: string;
|
};
|
|
const form = defineModel<Form>('form');
|
const visible = defineModel<boolean>('modelValue');
|
|
const title = 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>
|