Commit 9fd7e861 authored by xuke's avatar xuke

bug修改

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