Commit e639ce6f authored by xuke's avatar xuke

能源消耗接口-第四次提交

parent e78f8f67
...@@ -5,7 +5,6 @@ import axios from 'axios' ...@@ -5,7 +5,6 @@ import axios from 'axios'
import { Search, Document } from "@element-plus/icons-vue" import { Search, Document } from "@element-plus/icons-vue"
import { postEnergyManage, postEnergyDel, postEnergyUpdate } from "@/api/scheduling" import { postEnergyManage, postEnergyDel, postEnergyUpdate } from "@/api/scheduling"
import http from '../../api/http' import http from '../../api/http'
// const formEnergy = ref({})
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const tableData = ref([{}]) const tableData = ref([{}])
const formEnergy = ref({ const formEnergy = ref({
...@@ -18,23 +17,17 @@ const formEnergy = ref({ ...@@ -18,23 +17,17 @@ const formEnergy = ref({
const energyForm = ref() const energyForm = ref()
const dialogVisible = ref(false) const dialogVisible = ref(false)
const getEnergyData = async () => { const getEnergyData = async () => {
await http.post("/api/energy/getData", tableData.energyType = ["0", "1", "2", "3", "4"]).then(res => { await http.post("/api/energy/getData", config.supplyType).then(res => {
console.log("res:", res); console.log("res:", res);
tableData.value = res.data tableData.value = res.data
}).catch(err => { }).catch(err => {
console.log(error) console.log(error)
}) })
ElMessage.success('查询成功') ElMessage.success('获取数据成功')
console.log("tableData:", tableData.value);
// config.total = data.count
} }
const tableLabel = reactive([ const tableLabel = reactive([
{ {
prop: 'allowPagingId', prop: 'allowPagingId',
...@@ -67,15 +60,15 @@ const formInline = reactive({ ...@@ -67,15 +60,15 @@ const formInline = reactive({
}) })
const config = reactive({ const config = reactive({
total: 0, supplyType: ["0","1","2","3","4"],
page: 1,
supplyName: "",
}) })
const handleSearch = () => { const handleSearch = () => {
config.supplyName, config.supplyType = formInline.keyWord
config.supplyType = [`${config.supplyType}`]
getEnergyData(), getEnergyData(),
config.supplyName = '' tableData.energyType = '',
ElMessage.success('获取数据成功')
} }
const timeFormat = (time) => { const timeFormat = (time) => {
...@@ -101,11 +94,6 @@ const rules = reactive({ ...@@ -101,11 +94,6 @@ const rules = reactive({
recordDate: [{ required: true, message: "日期是必选项" }] recordDate: [{ required: true, message: "日期是必选项" }]
}) })
//
// const handleChange = (page) => { // const handleChange = (page) => {
// config.page = page, // config.page = page,
// getEnergyData() // getEnergyData()
...@@ -141,8 +129,7 @@ const handleDelete = async (row) => { ...@@ -141,8 +129,7 @@ const handleDelete = async (row) => {
type: 'warning', type: 'warning',
confirmButtonClass: 'ExitConfirmButton' confirmButtonClass: 'ExitConfirmButton'
}) })
await http.post("api/energy/Delete",EnergyId='"' + row.energyId + '"',false ).then(res => { await http.post("api/energy/Delete", EnergyId = '"' + row.energyId + '"', false).then(res => {
console.log(res);
}).then(res => { }).then(res => {
ElMessage({ ElMessage({
type: 'success', message: '删除成功' type: 'success', message: '删除成功'
...@@ -176,7 +163,6 @@ const handleAdd = () => { ...@@ -176,7 +163,6 @@ const handleAdd = () => {
const handleEdit = (val) => { const handleEdit = (val) => {
action.value = "edit" action.value = "edit"
dialogVisible.value = true dialogVisible.value = true
console.log(val);
nextTick(() => { nextTick(() => {
Object.assign(formEnergy.value, { ...val }) Object.assign(formEnergy.value, { ...val })
}) })
...@@ -192,7 +178,6 @@ const onSubmit = () => { ...@@ -192,7 +178,6 @@ const onSubmit = () => {
formEnergy.recordDate = /^\d{4}-\d{2}-\d{2}$/.test(formEnergy.recordDate) ? formEnergy.recordDate : timeFormat(formEnergy.recordDate) formEnergy.recordDate = /^\d{4}-\d{2}-\d{2}$/.test(formEnergy.recordDate) ? formEnergy.recordDate : timeFormat(formEnergy.recordDate)
if (action.value === 'add') { if (action.value === 'add') {
await http.post("api/energy/Save", { ...formEnergy.value }, false).then(res => { await http.post("api/energy/Save", { ...formEnergy.value }, false).then(res => {
console.log(res);
}).then(res => { }).then(res => {
ElMessage({ ElMessage({
type: 'success', message: '新增成功' type: 'success', message: '新增成功'
...@@ -205,7 +190,6 @@ const onSubmit = () => { ...@@ -205,7 +190,6 @@ const onSubmit = () => {
} }
} else { } else {
res = postEnergyUpdate(formEnergy.value) res = postEnergyUpdate(formEnergy.value)
console.log(res);
proxy.$refs['energyForm'].resetFields() proxy.$refs['energyForm'].resetFields()
dialogVisible.value = false dialogVisible.value = false
...@@ -240,11 +224,13 @@ onMounted(() => { ...@@ -240,11 +224,13 @@ onMounted(() => {
<div class="th_div"> <div class="th_div">
<el-form ref="formRef" :model="formInline" :inline="true" <el-form ref="formRef" :model="formInline" :inline="true"
style="display: flex; justify-content: center; align-items: center; margin: 0;"> style="display: flex; justify-content: center; align-items: center; margin: 0;">
<el-form-item class="select-clean" prop="supplyName" label-width="280px" style="margin: 0;"> <el-form-item class="select-clean" prop="supplyType" label-width="280px" style="margin: 0;">
<el-select v-model="config.supplyId" placeholder="请选择" style="width:360px; margin-left: 20px;"> <el-select v-model="formInline.keyWord" placeholder="请选择" style="width:360px; margin-left: 20px;">
<el-option label="东部供热站" value="DFA20074-8731-457F-B63F-4E1858CFE266" /> <el-option label="非节能" value="0" />
<el-option label="行政区供热站" value="行政区供热站" /> <el-option label="一步节能" value="1" />
<el-option label="福宛里供热站" value="福宛里供热站" /> <el-option label="二步节能" value="2" />
<el-option label="三步节能" value="3" />
<el-option label="四步节能" value="4" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -280,6 +266,9 @@ onMounted(() => { ...@@ -280,6 +266,9 @@ onMounted(() => {
<el-button link type="primary" size="small" @click="handleDelete(scope.row)">删除</el-button> <el-button link type="primary" size="small" @click="handleDelete(scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
<template #empty>
<el-empty description="暂无数据,快去添加数据吧.."></el-empty>
</template>
</el-table> </el-table>
<!-- <div class="bottom"> <!-- <div class="bottom">
...@@ -455,5 +444,4 @@ table td { ...@@ -455,5 +444,4 @@ table td {
// .pager { // .pager {
// display: flex; // display: flex;
// } // }
// } // }</style>
</style>
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