Commit 9fd7e861 authored by xuke's avatar xuke

bug修改

parent 77dba683
......@@ -151,7 +151,7 @@
<div>
<div class="btngrounp">
<el-button type="primary" @click="onSave">保存</el-button>
<el-button type="primary" style="margin: 0 0 0 5px">关闭</el-button>
<el-button type="primary" style="margin: 0 0 0 5px" @click="onCancel">关闭</el-button>
</div>
</div>
</th>
......@@ -163,7 +163,7 @@
</div>
</template>
<script setup>
import { ref, reactive, onMounted, onUnmounted, onBeforeMount } from "vue";
import { ref, reactive, onMounted, onUnmounted, onBeforeMount,watch } from "vue";
import { postConfigBoilerUpdate } from "@/api/scheduling.js";
import http from "../../api/http";
import { ElMessage } from "element-plus";
......@@ -171,6 +171,7 @@ const options = reactive([]);
import store from "../../store/index";
import { vFloatNumber } from "@/utils/directives.js";
import { nextTick } from "vue";
import { useRoute } from 'vue-router'
const loading = ref(false)
const form = ref({
types: [],
......@@ -294,16 +295,35 @@ function getSupplys() {
const clearFormValidation = () => {
nextTick(() => {
formRef.value?.clearValidate()
})
if (formRef.value && formRef.value.clearValidate) {
formRef.value.clearValidate()
}
}
const route = useRoute()
watch(
() => route.path, // 只监听路径变化
() => {
// 路由变化,执行相应操作
clearFormValidation()
getListData()
},
{ immediate: true } // 只在路径变化时触发
)
onMounted(() => {
getListData();
// getListData();
getSupplys();
clearFormValidation()
onCancel()
});
// 点击关闭按钮,再次调用接口
const onCancel = () => {
formRef.value.clearValidate()
getListData()
}
</script>
<style lang="less" scoped>
.contentBlock {
......
<script setup>
import { ref, onMounted, getCurrentInstance, reactive, nextTick } from "vue";
import { useRoute } from 'vue-router'
import { ElMessageBox, ElMessage } from "element-plus";
import axios from "axios";
import { Search, Minus, Document } from "@element-plus/icons-vue";
......@@ -32,6 +33,7 @@ const reset = () => {
"energyName": ''
}
}
const formRef = ref()
const addSaveBtnLoading = ref(false)
const loading = ref(false)
const energyForm = ref()
......@@ -103,6 +105,12 @@ const handleSearch = () => {
getEnergyData()
};
// 重置按钮
const handleReset = () => {
formInline.keyWord = ""
config.supplyType = ["0", "1", "2", "3", "4"]
getEnergyData()
}
const timeFormat = (time) => {
var time = new Date(time);
......@@ -117,7 +125,9 @@ const timeFormat = (time) => {
//表单校验规则
const rules = reactive({
supplyId: [{ required: true, message: "名称是必填项", trigger: "blur" }],
supplyName: [
{ required: true, message: "供热站是必填项", trigger: "blur" }
],
energyType: [
{ required: true, message: "能源类型是必填项", trigger: "blur" }
],
......@@ -179,23 +189,25 @@ const getCurrentDateTime = () => {
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
// return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
recordDate.value = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds
recordDate.value = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds
};
const openDialog = () => {
// 清除之前的校验信息
clearFormValidation()
getCurrentDateTime()
// formEnergy.recordDate = ref(getCurrentDateTime())
formEnergy.recordDate = recordDate.value
console.log("formEnergy.recordDate",formEnergy.recordDate);
console.log("formEnergy.recordDate", formEnergy.recordDate);
}
const handleAdd = () => {
action.value = "add",
dialogVisible.value = true;
dialogVisible.value = true;
addSaveBtnLoading.value = false
reset()
formEnergy.value.recordDate = recordDate.value
console.log('formEnergy.recordDate',formEnergy.value.recordDate);
console.log('formEnergy.recordDate', formEnergy.value.recordDate);
}
// 编辑
const handleEdit = (val) => {
......@@ -298,6 +310,17 @@ function getOrganizationStructure() {
ElMessage.error('接口异常,获取数据失败.')
})
}
// 清除表单校验
const clearFormValidation = () => {
if (energyForm.value && energyForm.value.clearValidate) {
energyForm.value.clearValidate()
} else {
}
}
onMounted(() => {
getOrganizationStructure()
getEnergyData()
......@@ -335,6 +358,10 @@ onMounted(() => {
<Search style="width: 1em; height: 1em; margin-right: 8px" />
查询
</el-button>
<el-button type="primary" @click="handleReset">
<Minus style="width: 1em; height: 1em; margin-right: 8px" />
重置
</el-button>
<el-button type="primary" @click="handleAdd">
<Document style="width: 1em; height: 1em; margin-right: 8px" />
新增
......@@ -375,8 +402,10 @@ onMounted(() => {
</template>
</el-table>
</div>
<el-dialog v-model="dialogVisible" @open="openDialog" :title="action == 'add' ? '数据新增' : '数据修改'" width="50%" :before-close="handleClose">
<el-form :inline="true" :model="formEnergy" :rules="rules" ref="energyForm" :hide-required-asterisk="true" :inline-message="true">
<el-dialog v-model="dialogVisible" @open="openDialog" :title="action == 'add' ? '数据新增' : '数据修改'" width="50%"
:before-close="handleClose">
<el-form :inline="true" :model="formEnergy" :rules="rules" ref="energyForm" :hide-required-asterisk="true"
:inline-message="true">
<table cellpadding="0" cellspacing="1" style="background-color: #99bbe8 ; height: 50px;">
<tr>
<th style="width: 25%">供热站</th>
......@@ -535,6 +564,7 @@ table td {
.el-cascader-menu {
width: 100%;
}
// 校验时样式
.el-form-item__content {
margin-left: 0 !important;
......
......@@ -14,7 +14,7 @@
<tr>
<td style="text-align: left">
<el-form-item prop="planName" style="padding: 0;margin: 0;">
<el-input maxlength="20" style="width: 80%" v-model="List.planName"></el-input>
<el-input maxlength="30" style="width: 80%" v-model="List.planName"></el-input>
</el-form-item>
</td>
</tr>
......@@ -90,11 +90,12 @@
</template>
<script setup>
import { ref, reactive, onMounted, onUnmounted } from "vue";
import { ref, reactive, onMounted, onUnmounted, watch } from "vue";
import { postInstantHeat, postInstantHeatUpdate } from "@/api/scheduling"
import { ElMessage } from "element-plus";
import http from "../../api/http";
import { vFloatNumber } from "@/utils/directives.js";
import { useRoute } from 'vue-router'
const loading = ref(false)
const formRef = ref()
......@@ -154,10 +155,35 @@ const onSave = async () => {
console.log(error)
})
}
const clearFormValidation = () => {
if (formRef.value && formRef.value.clearValidate) {
formRef.value.clearValidate()
}
}
const route = useRoute()
watch(
() => route.path, // 只监听路径变化
() => {
// 路由变化,执行相应操作
clearFormValidation()
getInstanceHeat()
},
{ immediate: true } // 只在路径变化时触发
)
onMounted(() => {
getInstanceHeat()
})
// 点击关闭按钮,再次调用接口
const onCancel = () => {
formRef.value.clearValidate()
getInstanceHeat()
}
</script>
<style lang="less" scoped>
.card-contianer {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment