Commit e78f8f67 authored by xuke's avatar xuke
parents ff08c5c5 7ed9fbec
<script setup> <script setup>
import {computed, onMounted, reactive, ref} from "vue"; import {computed, onMounted, reactive, ref} from "vue";
import {zhCn} from "element-plus/es/locale/index"; import {zhCn} from "element-plus/es/locale/index";
import {getAnnualParam,alterAnnualParam,addAnnualParam,deleteAnnualParam} from '@/api/scheduling.js' import {getAnnualParam, alterAnnualParam, addAnnualParam, deleteAnnualParam} from '@/api/scheduling.js'
import {ElMessageBox} from "element-plus"; import {ElMessageBox} from "element-plus";
const data = ref() const data = ref()
const dataBackup = ref([])
const tableHeaderClass = data => { // 表头样式 const tableHeaderClass = data => { // 表头样式
return 'table-header-class' return 'table-header-class'
} }
...@@ -16,23 +17,23 @@ const reviseWindowOpen = ref(false) ...@@ -16,23 +17,23 @@ const reviseWindowOpen = ref(false)
const addWindowOpen = ref(false) const addWindowOpen = ref(false)
const reviseForm = ref({}) const reviseForm = ref({})
const addForm = ref({ const addForm = ref({
supplyId:"00000000-0000-0000-0000-000000000000", supplyId: "00000000-0000-0000-0000-000000000000",
energyType:'', energyType: '',
year:'', year: '',
standard:'', standard: '',
degreeStandard:'', degreeStandard: '',
indoorTemperature:'', indoorTemperature: '',
outdoorTemperature:'', outdoorTemperature: '',
backWaterTemperature:'' backWaterTemperature: ''
}) })
const energyTypeList = ref(['一步节能','二步节能','三步节能','四步节能','非节能']) // 节能等级列表 const energyTypeList = ref(['一步节能', '二步节能', '三步节能', '四步节能', '非节能']) // 节能等级列表
const currentMonth = ref(0) const currentMonth = ref(0)
const currentYear = ref(0) const currentYear = ref(0)
const selectYearValue = computed(()=>{ const selectYearValue = computed(() => {
if (currentMonth.value >= 7){ if (currentMonth.value >= 7) {
return currentYear.value + "年-" + (currentYear.value+1) + "年" return currentYear.value + "年-" + (currentYear.value + 1) + "年"
}else { } else {
return (currentYear.value-1) + "年-" + currentYear.value + "年" return (currentYear.value - 1) + "年-" + currentYear.value + "年"
} }
}) })
...@@ -47,15 +48,18 @@ function handleDelete(val) { ...@@ -47,15 +48,18 @@ function handleDelete(val) {
'点击确定后,该条数据将删除,是否继续?', '点击确定后,该条数据将删除,是否继续?',
'Warning', 'Warning',
{ {
confirmButtonText:'确定', confirmButtonText: '确定',
cancelButtonText:'取消', cancelButtonText: '取消',
type:'warning' type: 'warning'
} }
).then(()=>{ ).then(() => {
deleteAnnualParam(val.paramId).then(res=>{ deleteAnnualParam(val.paramId).then(res => {
if(res.success){getData()} if (res.success) {
getData()
}
})
}).catch(err => {
}) })
}).catch(err=>{})
} // 处理删除 } // 处理删除
function handleAdd() { function handleAdd() {
currentYear.value = new Date().getFullYear() currentYear.value = new Date().getFullYear()
...@@ -63,23 +67,28 @@ function handleAdd() { ...@@ -63,23 +67,28 @@ function handleAdd() {
addWindowOpen.value = true addWindowOpen.value = true
} // 处理新增 } // 处理新增
function handleSearch() { function handleSearch() {
if (!searchKey.value) {
getData()
} else {
data.value = dataBackup.value.filter(item => item.year.includes(searchKey.value))
}
} // 处理查询 } // 处理查询
function onSubmit() { function onSubmit() {
alterAnnualParam(reviseForm.value).then(res =>{ alterAnnualParam(reviseForm.value).then(res => {
if(res.success){ if (res.success) {
getData() getData()
handleClose() handleClose()
} }
}) })
} // 提交修改 } // 提交修改
function onAddSubmit(){ // 提交新增 function onAddSubmit() { // 提交新增
data.value.forEach((item,index,array) =>{ data.value.forEach((item, index, array) => {
if(item.energyType === addForm.energyType && item.year === addForm.year){ if (item.energyType === addForm.energyType && item.year === addForm.year) {
alert("该类型年度已存在") alert("该类型年度已存在")
return return
} }
}) })
addAnnualParam(addForm.value).then(res=>{ addAnnualParam(addForm.value).then(res => {
getData() getData()
handleClose() handleClose()
}) })
...@@ -89,24 +98,26 @@ function handleClose() { ...@@ -89,24 +98,26 @@ function handleClose() {
addWindowOpen.value = false addWindowOpen.value = false
resetInput() resetInput()
} // 关闭弹窗 } // 关闭弹窗
onMounted(()=>{ onMounted(() => {
getData() getData()
}) })
function getData(){ function getData() {
getAnnualParam().then(res =>{ getAnnualParam().then(res => {
data.value = res.data data.value = res.data
dataBackup.value = [...data.value]
}) })
} }
function resetInput(){
function resetInput() {
addForm.value = { addForm.value = {
energyType:'', energyType: '',
year:'', year: '',
standard:'', standard: '',
degreeStandard:'', degreeStandard: '',
indoorTemperature:'', indoorTemperature: '',
outdoorTemperature:'', outdoorTemperature: '',
backWaterTemperature:'' backWaterTemperature: ''
} }
} }
</script> </script>
...@@ -117,7 +128,7 @@ function resetInput(){ ...@@ -117,7 +128,7 @@ function resetInput(){
<el-row> <el-row>
<el-col :span="8" label>年度:</el-col> <el-col :span="8" label>年度:</el-col>
<el-col :span="16"> <el-col :span="16">
<el-input v-model="searchKey"/> <el-input clearable v-model="searchKey"/>
</el-col> </el-col>
</el-row> </el-row>
<el-button type="primary" class="add-search-btn" @click="handleAdd">新增</el-button> <el-button type="primary" class="add-search-btn" @click="handleAdd">新增</el-button>
...@@ -346,10 +357,12 @@ function resetInput(){ ...@@ -346,10 +357,12 @@ function resetInput(){
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
} }
.el-row[first]{
.el-row[first] {
border-top: 1px solid #a6c3e9; border-top: 1px solid #a6c3e9;
} }
.el-row{
.el-row {
border-left: 1px solid #a6c3e9; border-left: 1px solid #a6c3e9;
border-right: 1px solid #a6c3e9; border-right: 1px solid #a6c3e9;
border-bottom: 1px solid #a6c3e9; border-bottom: 1px solid #a6c3e9;
...@@ -357,7 +370,8 @@ function resetInput(){ ...@@ -357,7 +370,8 @@ function resetInput(){
height: 35px; height: 35px;
color: #124362; color: #124362;
} }
.el-col[col-label]{
.el-col[col-label] {
display: flex; display: flex;
justify-content: end; justify-content: end;
align-items: center; align-items: center;
...@@ -365,13 +379,15 @@ function resetInput(){ ...@@ -365,13 +379,15 @@ function resetInput(){
background-color: #f2f6f8; background-color: #f2f6f8;
padding-right: 5px; padding-right: 5px;
} }
.el-col[col-value]{
.el-col[col-value] {
display: flex; display: flex;
justify-content: start; justify-content: start;
align-items: center; align-items: center;
padding-left: 5px; padding-left: 5px;
} }
.el-input{
.el-input {
color: black; color: black;
height: 24px; height: 24px;
} }
......
...@@ -4,6 +4,7 @@ import {ElMessageBox} from "element-plus"; ...@@ -4,6 +4,7 @@ import {ElMessageBox} from "element-plus";
import {getPhenomenon,addPhenomenon,alterPhenomenon,deletePhenomenon} from "@/api/scheduling.js" import {getPhenomenon,addPhenomenon,alterPhenomenon,deletePhenomenon} from "@/api/scheduling.js"
const data = ref() const data = ref()
const dataBackup = ref([])
const searchKey = ref('') // 查询参数 const searchKey = ref('') // 查询参数
const reviseWindowOpen = ref(false) const reviseWindowOpen = ref(false)
const addWindowOpen = ref(false) const addWindowOpen = ref(false)
...@@ -39,6 +40,13 @@ function omit(val){ ...@@ -39,6 +40,13 @@ function omit(val){
}) })
}).catch(err=>{}) }).catch(err=>{})
} // 删除按钮单击事件 } // 删除按钮单击事件
function search(){
if(!searchKey.value){
getData()
}else {
data.value = dataBackup.value.filter(item => item.phenomenonName.includes(searchKey.value) )
}
}
function handleClose(){ function handleClose(){
reviseWindowOpen.value = false reviseWindowOpen.value = false
addWindowOpen.value = false addWindowOpen.value = false
...@@ -72,6 +80,7 @@ onMounted(()=>{ ...@@ -72,6 +80,7 @@ onMounted(()=>{
function getData(){ function getData(){
getPhenomenon().then(res => { getPhenomenon().then(res => {
data.value = res.data data.value = res.data
dataBackup.value = [...data.value]
}) })
} }
</script> </script>
...@@ -81,10 +90,10 @@ function getData(){ ...@@ -81,10 +90,10 @@ function getData(){
<el-row> <el-row>
<el-col :span="8" label>名称:</el-col> <el-col :span="8" label>名称:</el-col>
<el-col :span="16"> <el-col :span="16">
<el-input v-model="searchKey"/> <el-input clearable v-model="searchKey"/>
</el-col> </el-col>
</el-row> </el-row>
<el-button type="primary" class="add-search-btn">查询</el-button> <el-button type="primary" @click="search" class="add-search-btn">查询</el-button>
<el-button type="primary" @click="add" class="add-search-btn">新增</el-button> <el-button type="primary" @click="add" class="add-search-btn">新增</el-button>
</div> </div>
<div class="table-wrapper"> <div class="table-wrapper">
......
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