| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="dialogVisible" |
| | | :title="title" |
| | | width="600" |
| | | :close-on-click-modal="false" |
| | | :before-close="handleClose" |
| | | 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" |
| | | 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="请输入字段名称" |
| | | v-model="formData.fieldName" |
| | | placeholder="请输入字段名称" |
| | | /> |
| | | </el-form-item> <el-form-item label="字段描述" prop="fieldDescription"> |
| | | <el-input v-model="formData.fieldDescription" type="textarea" placeholder="请输入字段描述" /> |
| | | </el-form-item> |
| | | <el-form-item label="字段描述" prop="fieldDescription"> |
| | | <el-input v-model="formData.fieldDescription" type="textarea" placeholder="请输入字段描述"/> |
| | | </el-form-item> |
| | | <el-form-item class="dialog-footer"> |
| | | <el-button v-if="addOrEdit === 'edit'" @click="resetForm" |
| | | >重置</el-button |
| | | >重置 |
| | | </el-button |
| | | > |
| | | <el-button v-if="addOrEdit === 'add'" @click="cancelForm" |
| | | >取消</el-button |
| | | >取消 |
| | | </el-button |
| | | > |
| | | <el-button type="primary" @click="submitForm"> 确定 </el-button> |
| | | <el-button type="primary" @click="submitForm"> 确定</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive, watch, defineProps } from "vue"; |
| | | import { addOrEditCoalField } from "@/api/basicInformation/coalFieldMaintenance.js"; |
| | | import {ref, reactive, watch, defineProps} from "vue"; |
| | | import {addOrEditCoalField} from "@/api/basicInformation/coalFieldMaintenance.js"; |
| | | |
| | | const props = defineProps({ |
| | | form: { |
| | | type: Object, |
| | |
| | | const formRef = ref(); |
| | | const emit = defineEmits(["submit", "handleBeforeClose"]); |
| | | // 表单数据 |
| | | const formData = ref({ ...props.form }); |
| | | const formData = ref({...props.form}); |
| | | |
| | | // 监听props.form的变化,更新formData |
| | | watch(() => props.form, (newForm) => { |
| | | formData.value = { ...newForm }; |
| | | }, { deep: true, immediate: true }); |
| | | formData.value = {...newForm}; |
| | | }, {deep: true, immediate: true}); |
| | | // 弹窗可见性 |
| | | const dialogVisible = defineModel("coalMaintenanceFieldDialogVisible", { |
| | | required: true, |
| | |
| | | console.log("提交表单", formData.value); |
| | | if (props.title.includes('新增')) { |
| | | let result = await addOrEditCoalField( |
| | | {...formData.value} |
| | | ,) |
| | | {...formData.value} |
| | | ,) |
| | | console.log(result); |
| | | obj.value = { |
| | | title: "新增", |
| | |
| | | }; |
| | | // 重置表单 |
| | | const resetForm = () => { |
| | | if (!formRef.value) return |
| | | if (!formRef.value) return |
| | | formData.value = JSON.parse(JSON.stringify(copyForm.value)); |
| | | } |
| | | // 关闭弹窗 |
| | |
| | | }; |
| | | const rules = reactive({ |
| | | fieldName: [ |
| | | { required: true, message: "请输入煤种名称", trigger: "blur" }, |
| | | {required: true, message: "请输入煤种名称", trigger: "blur"}, |
| | | ], |
| | | }); |
| | | </script> |