From 00ef76a2e286e338fa3c648ce183e3533ce006ad Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期一, 09 六月 2025 17:48:23 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue | 71 +++++++++++++++++++++++++++-------- 1 files changed, 54 insertions(+), 17 deletions(-) diff --git a/src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue b/src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue index 22d4448..a7dcbdb 100644 --- a/src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue +++ b/src/views/basicInformation/mould/coalMeiZhiZiDuanWeiHu.vue @@ -19,18 +19,17 @@ 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="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-form-item class="dialog-footer"> <el-button v-if="addOrEdit === 'edit'" @click="resetForm" >閲嶇疆</el-button > <el-button v-if="addOrEdit === 'add'" @click="cancelForm" >鍙栨秷</el-button > + <el-button type="primary" @click="submitForm"> 纭畾 </el-button> </el-form-item> </el-form> </el-dialog> @@ -38,13 +37,9 @@ </template> <script setup> -import { ref, watch, defineProps, onMounted } from "vue"; -import addressList from "@/api/jsonApi/areaList.json"; +import { ref, reactive, watch, defineProps } from "vue"; +import { addOrEditCoalField } from "@/api/basicInformation/coalFieldMaintenance.js"; const props = defineProps({ - beforeClose: { - type: Function, - default: () => {}, - }, form: { type: Object, default: () => ({}), @@ -58,10 +53,20 @@ default: "", }, }); - +const copyForm = defineModel("copyForm", { + required: true, + type: Object, +}); +// 琛ㄥ崟寮曠敤 +const formRef = ref(); const emit = defineEmits(["submit", "handleBeforeClose"]); // 琛ㄥ崟鏁版嵁 const formData = ref({ ...props.form }); + +// 鐩戝惉props.form鐨勫彉鍖栵紝鏇存柊formData +watch(() => props.form, (newForm) => { + formData.value = { ...newForm }; +}, { deep: true, immediate: true }); // 寮圭獥鍙鎬� const dialogVisible = defineModel("coalMaintenanceFieldDialogVisible", { required: true, @@ -72,6 +77,32 @@ if (!formRef.value) return; await formRef.value.validate(async (valid, fields) => { if (valid) { + const obj = ref({}); + + console.log("鎻愪氦琛ㄥ崟", formData.value); + if (props.title.includes('鏂板')) { + let result = await addOrEditCoalField( + {...formData.value} + ,) + console.log(result); + obj.value = { + title: "鏂板", + ...formData.value, + result + }; + } else { + delete formData.value.createTime + delete formData.value.updateTime + let result = await addOrEditCoalField({ + ...formData.value, + }) + obj.value = { + title: "缂栬緫", + ...formData.value, + result + }; + } + emit("submit", obj.value); } }); }; @@ -82,9 +113,9 @@ }; // 閲嶇疆琛ㄥ崟 const resetForm = () => { - - -}; + if (!formRef.value) return + formData.value = JSON.parse(JSON.stringify(copyForm.value)); +} // 鍏抽棴寮圭獥 const handleClose = () => { // 瑙﹀彂鐖剁粍浠剁殑鍏抽棴鍑芥暟 @@ -92,10 +123,16 @@ emit("update:coalMaintenanceFieldDialogVisible", false); }; const rules = reactive({ - coal: [ + fieldName: [ { required: true, message: "璇疯緭鍏ョ叅绉嶅悕绉�", trigger: "blur" }, ], }); </script> -<style lang="sass" scoped> +<style lang="scss" scoped> +.dialog-footer { + display: flex; + justify-content: flex-end; + margin-top: 20px; + flex-direction: column; +} </style> \ No newline at end of file -- Gitblit v1.9.3