Files
energy_storage/web/src/views/system/station.vue

267 lines
6.2 KiB
Vue
Raw Normal View History

2025-09-05 16:40:35 +08:00
<template>
<div class="station">
<searchBox
:btn-option-list="btnOptionList"
@onSearch="onSearch"
@operateForm="operateForm"
></searchBox>
<div class="content-table">
<ComTable
:columns="columns"
:table-data="tableData"
@handlePagesizeChange="handlePagesizeChange"
ref="comTable"
:table-option="tableOption"
:page-option="pageOption"
>
<template #status="record">
2025-09-12 11:43:32 +08:00
<a-tag :color="record.status == 0 ? 'red' : 'green'">{{
record.status == 0 ? '未投运' : '投运'
}}</a-tag>
<span>{{}}</span>
2025-09-05 16:40:35 +08:00
</template>
2025-09-09 10:00:01 +08:00
<template #work_mode="record">
2025-09-11 19:01:01 +08:00
<span>{{ workModeList.find((item) => record.value == item.value)?.label || '' }}</span>
2025-09-12 11:43:32 +08:00
</template>
<template #policy_id="record">
2025-09-11 19:01:01 +08:00
<span>{{ policyList.find((item) => record.value == item.value)?.label || '' }}</span>
2025-09-12 11:43:32 +08:00
</template>
2025-09-05 16:40:35 +08:00
<template #action="record">
<OperateCom :record="record" :operate-list="operateList" @operateForm="operateForm" />
</template>
</ComTable>
</div>
<a-modal v-model:open="formModal" width="750px" style="top: 20px" :footer="null">
<!-- action:edit add -->
<EditCom
:record="record"
@operateForm="operateForm"
type="station"
:action="formStatus"
></EditCom>
</a-modal>
</div>
</template>
<script>
import { columnList, stationOptions } from '../../../public/config/columnList'
import { getReq, postReq } from '@/request/api.js'
import ComTable from '@/components/ComTable'
import OperateCom from '@/components/OperateCom'
import EditCom from '@/components/EditCom.vue'
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
import { createVNode } from 'vue'
2025-09-05 16:40:35 +08:00
import searchBox from '@/components/SearchBox.vue'
export default {
name: '',
components: {
searchBox,
EditCom,
ComTable,
OperateCom
},
props: {},
data() {
return {
2025-09-11 19:01:01 +08:00
tableOption: {
2025-09-12 11:43:32 +08:00
select: false
2025-09-11 19:01:01 +08:00
},
2025-09-05 16:40:35 +08:00
formModal: false,
formState: {},
formStatus: 'add', //表单状态辑状态 add:新增 edit:编辑
pageOption: {
pageSize: 10,
page: 1
},
btnOptionList: [],
paramsDate: {},
2025-09-11 19:01:01 +08:00
workModeList: [
{
label: '峰谷套利',
value: '1'
},
{
label: '增网配容',
value: '2'
},
{
label: '应急供电',
value: '3'
},
{
label: '并网保电',
value: '4'
},
{
label: '自定时段',
value: '5'
2025-09-11 19:01:01 +08:00
}
],
2025-09-11 19:01:01 +08:00
policyList: [
{
2025-09-11 19:01:01 +08:00
label: '削峰套利',
value: 1
},
{
2025-09-11 19:01:01 +08:00
label: '需求响应',
value: 2
},
{
2025-09-11 19:01:01 +08:00
label: '自发自用',
value: 3
}
]
2025-09-05 16:40:35 +08:00
}
},
computed: {},
created() {
let info = []
let col = columnList.find((i) => i.page == 'station').columns
if (col.length) {
col.forEach((item) => {
info.push(this.$setWidth(item))
})
}
this.columns = info
},
mounted() {
this.operateList = this.$getBtns(['查看', '修改', '删除'])
this.btnOptionList = this.$getBtns(['新增'])
this.getList()
},
methods: {
async getList() {
this.$refs.comTable.loading = true
const { page, pageSize } = this.pageOption
const params = {
...this.paramsDate,
page_size: pageSize,
page
}
try {
const res = await getReq('/queryStationList', params)
if (res.errcode === 0) {
this.$refs.comTable.loading = false
this.tableData = res.data
this.pageOption = {
page: res.page,
pageSize: res.page_size,
count: res.count
}
} else {
const err = { tip: res.errmsg }
throw err
}
} catch (error) {
//统一处理报错提示
2025-09-12 10:58:59 +08:00
this.$refs.comTable.loading = false
2025-09-05 16:40:35 +08:00
}
},
operateForm(type, record = {}) {
this.formStatus = type
switch (type) {
case 'add':
this.formModal = true
this.formState = {}
this.getRuleFormInfo()
break
case 'edit':
case 'read':
this.formModal = true
this.formState = record
this.getRuleFormInfo(record)
break
2025-09-11 19:01:01 +08:00
2025-09-05 16:40:35 +08:00
case 'del':
2025-09-11 19:01:01 +08:00
this.handleDelete([record.station_id], this.getList)
2025-09-05 16:40:35 +08:00
break
case 'back':
this.formModal = false
this.getList()
break
default:
break
}
},
// 删除操作
2025-09-11 19:01:01 +08:00
async handleDelete(id, callback) {
2025-09-05 16:40:35 +08:00
const that = this
Modal.confirm({
title: '你确认删除数据吗?',
icon: createVNode(ExclamationCircleOutlined),
async onOk() {
try {
2025-09-11 19:01:01 +08:00
const res = await getReq('/deleteStation', { station_id: id })
2025-09-05 16:40:35 +08:00
if (res.errcode === 0) {
this.$message.success(res.errmsg)
2025-09-11 19:01:01 +08:00
this.pageOption.page = 1
2025-09-05 16:40:35 +08:00
callback()
} else {
throw res
}
} catch (error) {
callback()
}
},
onCancel() {
},
class: 'test'
})
},
async getRuleFormInfo(record) {
function getInfo(data, url) {
return new Promise((reslove, reject) => {
getReq(data, url).then((res) => {
reslove(res.data)
})
})
}
let row = {}
if (record && record.station_id) {
// row = await getInfo({ station_id: record.station_id},'/queryStationInfo')
2025-09-05 16:40:35 +08:00
this.record = record
row = record
// this.type='edit'
}
stationOptions.forEach((e, index) => {
e.list.forEach((i) => {
e.ruleForm[i.key] = row ? row[i.key] : ''
e.ruleForm.id = row.id
})
})
},
handlePagesizeChange(pageOption) {
this.pageOption.pageSize = pageOption.pageSize
this.pageOption.page = pageOption.page
this.getList()
}
}
}
</script>
<style lang="scss" scoped>
.station {
height: 100%;
.content-table {
height: calc(100% - 70px);
padding: 10px;
}
}
</style>