2025-09-01 16:55:44 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="policy">
|
2025-09-04 13:42:48 +08:00
|
|
|
|
<searchBox :btn-option-list="btnOptionList" @onSearch="onSearch" @operateForm="operateForm" />
|
|
|
|
|
|
<div class="content-table">
|
|
|
|
|
|
<ComTable
|
|
|
|
|
|
:columns="columns"
|
|
|
|
|
|
:table-data="tableData"
|
|
|
|
|
|
@handlePagesizeChange="handlePagesizeChange"
|
|
|
|
|
|
ref="comTable"
|
|
|
|
|
|
:table-option="tableOption"
|
|
|
|
|
|
:page-option="pageOption"
|
|
|
|
|
|
:table-h="tableH"
|
|
|
|
|
|
>
|
2025-09-05 09:28:00 +08:00
|
|
|
|
<template #type="record">
|
|
|
|
|
|
<div>{{ getPolicyType(record.type) }}</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #isOpen="record">
|
|
|
|
|
|
<a-tag :color="record.is_open == 1 ? '#2db7f5' : '#f50'">{{
|
|
|
|
|
|
record.is_open == 1 ? '启用' : '禁用'
|
|
|
|
|
|
}}</a-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #action="record">
|
|
|
|
|
|
<a-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="operateForm('read', record)"
|
|
|
|
|
|
style="margin-left: 10px"
|
|
|
|
|
|
>查看</a-button
|
|
|
|
|
|
>
|
|
|
|
|
|
<a-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="operateForm('edit', record)"
|
|
|
|
|
|
class="btn-edit"
|
|
|
|
|
|
style="margin-left: 10px"
|
|
|
|
|
|
>修改</a-button
|
|
|
|
|
|
>
|
|
|
|
|
|
<a-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="operateForm('del', record)"
|
|
|
|
|
|
class="btn-del"
|
|
|
|
|
|
style="margin-left: 10px"
|
|
|
|
|
|
>删除</a-button
|
|
|
|
|
|
>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</ComTable>
|
2025-09-04 13:42:48 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
2025-09-05 09:28:00 +08:00
|
|
|
|
<a-modal v-model:open="formModal" width="70%" style="top: 20px" :footer="null">
|
|
|
|
|
|
<policyForm :form-state="formState" :form-status="formStatus" @closeModal="closeModal"/>
|
2025-09-04 13:42:48 +08:00
|
|
|
|
</a-modal>
|
2025-09-01 16:55:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-09-04 13:42:48 +08:00
|
|
|
|
import policyForm from '@/components/system/policyForm.vue'
|
2025-09-05 09:28:00 +08:00
|
|
|
|
import { getReq } from '@/request/api'
|
|
|
|
|
|
import { policyTypes } from '@/utils/config'
|
2025-09-01 16:55:44 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: '',
|
2025-09-04 13:42:48 +08:00
|
|
|
|
components: { policyForm },
|
|
|
|
|
|
props: {},
|
|
|
|
|
|
data() {
|
2025-09-01 16:55:44 +08:00
|
|
|
|
return {
|
2025-09-05 09:28:00 +08:00
|
|
|
|
formModal: false,
|
2025-09-04 13:42:48 +08:00
|
|
|
|
btnOptionList: [
|
|
|
|
|
|
{ label: '新增', icon: 'icon-tianjia', type: 'add' },
|
|
|
|
|
|
{ label: '删除', icon: 'icon-tianjia', type: 'del' }
|
|
|
|
|
|
],
|
|
|
|
|
|
columns: [
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '策略ID',
|
2025-09-05 09:28:00 +08:00
|
|
|
|
dataIndex: 'policy_id',
|
2025-09-04 13:42:48 +08:00
|
|
|
|
key: 'policyId',
|
|
|
|
|
|
width: 120,
|
|
|
|
|
|
ellipsis: true
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '策略名称',
|
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
|
key: 'name',
|
|
|
|
|
|
width: 120,
|
|
|
|
|
|
ellipsis: true
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '策略类型',
|
2025-09-05 09:28:00 +08:00
|
|
|
|
dataIndex: 'type', //策略类型:1:削峰套利;2:需求响应;3:自发自用
|
2025-09-04 13:42:48 +08:00
|
|
|
|
key: 'type',
|
|
|
|
|
|
width: 120,
|
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
|
scopedSlots: { customRender: 'type' }
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '策略描述',
|
|
|
|
|
|
dataIndex: 'describe',
|
|
|
|
|
|
key: 'describe',
|
|
|
|
|
|
width: 120,
|
|
|
|
|
|
ellipsis: true
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '策略参数',
|
|
|
|
|
|
dataIndex: 'value',
|
|
|
|
|
|
key: 'value',
|
2025-09-05 09:28:00 +08:00
|
|
|
|
width: 200,
|
2025-09-04 13:42:48 +08:00
|
|
|
|
ellipsis: true
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '是否启用',
|
2025-09-05 09:28:00 +08:00
|
|
|
|
dataIndex: 'is_open',
|
2025-09-04 13:42:48 +08:00
|
|
|
|
key: 'isOpen',
|
|
|
|
|
|
width: 120,
|
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
|
scopedSlots: { customRender: 'isOpen' }
|
|
|
|
|
|
},
|
2025-09-05 09:28:00 +08:00
|
|
|
|
|
2025-09-04 13:42:48 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: '操作',
|
|
|
|
|
|
dataIndex: 'action',
|
|
|
|
|
|
key: 'action',
|
|
|
|
|
|
width: 150,
|
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
|
scopedSlots: { customRender: 'action' }
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
2025-09-05 09:28:00 +08:00
|
|
|
|
tableData: [],
|
|
|
|
|
|
tableOption: {},
|
|
|
|
|
|
pageOption: {
|
|
|
|
|
|
page: 0,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
total: 0
|
2025-09-04 13:42:48 +08:00
|
|
|
|
},
|
2025-09-05 09:28:00 +08:00
|
|
|
|
tableH: '',
|
|
|
|
|
|
formState: {},
|
|
|
|
|
|
formStatus:'add',//表单状态辑状态 add:新增 edit:编辑
|
2025-09-01 16:55:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
2025-09-04 13:42:48 +08:00
|
|
|
|
this.getTableList()
|
2025-09-01 16:55:44 +08:00
|
|
|
|
},
|
2025-09-04 13:42:48 +08:00
|
|
|
|
methods: {
|
2025-09-05 09:28:00 +08:00
|
|
|
|
async getTableList() {
|
2025-09-04 13:42:48 +08:00
|
|
|
|
try {
|
|
|
|
|
|
const res = await getReq('/queryPolicyList', {
|
|
|
|
|
|
page: this.pageOption.page,
|
2025-09-05 09:28:00 +08:00
|
|
|
|
page_size: this.pageOption.pageSize
|
2025-09-04 13:42:48 +08:00
|
|
|
|
})
|
2025-09-05 09:28:00 +08:00
|
|
|
|
console.log(res)
|
|
|
|
|
|
this.tableData = res.data
|
|
|
|
|
|
this.total = res.count
|
2025-09-04 13:42:48 +08:00
|
|
|
|
} catch (error) {
|
2025-09-05 09:28:00 +08:00
|
|
|
|
console.log(error)
|
2025-09-04 13:42:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-09-05 09:28:00 +08:00
|
|
|
|
getPolicyType(type) {
|
|
|
|
|
|
|
|
|
|
|
|
return policyTypes.find((item) => item.value == type)?.label || ''
|
2025-09-04 13:42:48 +08:00
|
|
|
|
},
|
2025-09-05 09:28:00 +08:00
|
|
|
|
|
2025-09-04 13:42:48 +08:00
|
|
|
|
onSearch(data) {
|
2025-09-01 16:55:44 +08:00
|
|
|
|
console.log(data)
|
|
|
|
|
|
},
|
2025-09-05 09:28:00 +08:00
|
|
|
|
operateForm(type, record = {}) {
|
2025-09-04 13:42:48 +08:00
|
|
|
|
|
2025-09-05 09:28:00 +08:00
|
|
|
|
this.formStatus = type
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
case 'add':
|
|
|
|
|
|
this.formModal = true
|
|
|
|
|
|
this.formState = {}
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'read':
|
|
|
|
|
|
this.formModal = true
|
|
|
|
|
|
this.formState = record
|
|
|
|
|
|
break
|
|
|
|
|
|
|
2025-09-04 13:42:48 +08:00
|
|
|
|
default:
|
2025-09-05 09:28:00 +08:00
|
|
|
|
break
|
2025-09-04 13:42:48 +08:00
|
|
|
|
}
|
2025-09-05 09:28:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
closeModal(){
|
|
|
|
|
|
this.formModal = false
|
2025-09-01 16:55:44 +08:00
|
|
|
|
},
|
2025-09-04 13:42:48 +08:00
|
|
|
|
handlePagesizeChange(data) {
|
|
|
|
|
|
console.log(data)
|
|
|
|
|
|
}
|
2025-09-01 16:55:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2025-09-04 13:42:48 +08:00
|
|
|
|
.policy {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
padding: 0 15px;
|
|
|
|
|
|
.content-table {
|
2025-09-05 09:28:00 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: calc(100% - 92px);
|
|
|
|
|
|
}
|
2025-09-01 16:55:44 +08:00
|
|
|
|
}
|
2025-09-04 13:42:48 +08:00
|
|
|
|
</style>
|