<template>
|
<div>
|
<el-dialog
|
v-model="dialogVisible"
|
:title="title"
|
width="600"
|
:close-on-click-modal="false"
|
:before-close="handleClose"
|
>
|
<el-form
|
ref="formRef"
|
style="max-width: 400px; margin: 0 auto"
|
:model="formData"
|
:rules="rules"
|
label-width="auto"
|
>
|
<el-form-item label="字段名称" prop="fieldName">
|
<el-input
|
v-model="formData.fieldName"
|
placeholder="请输入字段名称"
|
/>
|
</el-form-item>
|
<el-form-item label="Activity form" props="dielDescription">
|
<el-input v-model="formData.fieldDescription" type="textarea" placeholder="请输入字段描述" />
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="submitForm"> 确定 </el-button>
|
<el-button v-if="addOrEdit === 'edit'" @click="resetForm"
|
>重置</el-button
|
>
|
<el-button v-if="addOrEdit === 'add'" @click="cancelForm"
|
>取消</el-button
|
>
|
</el-form-item>
|
</el-form>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup>
|
import { ref, watch, defineProps, onMounted } from "vue";
|
import addressList from "@/api/jsonApi/areaList.json";
|
const props = defineProps({
|
beforeClose: {
|
type: Function,
|
default: () => {},
|
},
|
form: {
|
type: Object,
|
default: () => ({}),
|
},
|
addOrEdit: {
|
type: String,
|
default: "add",
|
},
|
title: {
|
type: String,
|
default: "",
|
},
|
});
|
|
const emit = defineEmits(["submit", "handleBeforeClose"]);
|
// 表单数据
|
const formData = ref({ ...props.form });
|
// 弹窗可见性
|
const dialogVisible = defineModel("coalMaintenanceFieldDialogVisible", {
|
required: true,
|
type: Boolean,
|
});
|
// 提交表单
|
const submitForm = async () => {
|
if (!formRef.value) return;
|
await formRef.value.validate(async (valid, fields) => {
|
if (valid) {
|
}
|
});
|
};
|
// 取消表单
|
const cancelForm = () => {
|
emit("update:coalMaintenanceFieldDialogVisible", false);
|
formData.value = {};
|
};
|
// 重置表单
|
const resetForm = () => {
|
|
|
};
|
// 关闭弹窗
|
const handleClose = () => {
|
// 触发父组件的关闭函数
|
emit("handleBeforeClose");
|
emit("update:coalMaintenanceFieldDialogVisible", false);
|
};
|
const rules = reactive({
|
coal: [
|
{ required: true, message: "请输入煤种名称", trigger: "blur" },
|
],
|
});
|
</script>
|
<style lang="sass" scoped>
|
</style>
|