2025-09-01 16:55:44 +08:00
|
|
|
|
<template>
|
2025-09-05 16:41:50 +08:00
|
|
|
|
<div class="policy" ref="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"
|
|
|
|
|
|
>
|
2025-09-05 09:28:00 +08:00
|
|
|
|
<template #type="record">
|
|
|
|
|
|
<div>{{ getPolicyType(record.type) }}</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #isOpen="record">
|
2025-09-11 16:14:55 +08:00
|
|
|
|
<a-tag :color="record.is_open == 1 ? 'green' : 'red'">{{
|
2025-09-05 09:28:00 +08:00
|
|
|
|
record.is_open == 1 ? '启用' : '禁用'
|
|
|
|
|
|
}}</a-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #action="record">
|
2025-09-09 09:39:15 +08:00
|
|
|
|
<OperateCom :record="record" :operate-list="operateList" @operateForm="operateForm" />
|
2025-09-05 09:28:00 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</ComTable>
|
2025-09-04 13:42:48 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-09-12 16:34:29 +08:00
|
|
|
|
<!-- <div> -->
|
2025-09-05 16:41:50 +08:00
|
|
|
|
<a-modal
|
|
|
|
|
|
v-model:open="formModal"
|
2025-09-12 16:34:29 +08:00
|
|
|
|
width="800px"
|
|
|
|
|
|
style="top: 80px;height: 600px;"
|
2025-09-05 16:41:50 +08:00
|
|
|
|
:footer="null"
|
|
|
|
|
|
:get-container="() => $refs.policy"
|
|
|
|
|
|
>
|
2025-09-12 16:34:29 +08:00
|
|
|
|
<policyForm v-if="formModal" :form-state="formState" :form-status="formStatus" @closeModal="closeModal" />
|
2025-09-04 13:42:48 +08:00
|
|
|
|
</a-modal>
|
2025-09-12 16:34:29 +08:00
|
|
|
|
<!-- </div> -->
|
2025-09-01 16:55:44 +08:00
|
|
|
|
</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-09 09:39:15 +08:00
|
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
|
|
|
|
|
|
import { createVNode } from 'vue'
|
2025-09-01 16:55:44 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: '',
|
2025-09-04 13:42:48 +08:00
|
|
|
|
components: { policyForm },
|
|
|
|
|
|
props: {},
|
2025-09-11 16:14:55 +08:00
|
|
|
|
|
2025-09-04 13:42:48 +08:00
|
|
|
|
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: [
|
|
|
|
|
|
],
|
|
|
|
|
|
columns: [
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '策略ID',
|
2025-09-05 09:28:00 +08:00
|
|
|
|
dataIndex: 'policy_id',
|
2025-09-04 13:42:48 +08:00
|
|
|
|
key: 'policyId',
|
|
|
|
|
|
ellipsis: true
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '策略名称',
|
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
|
key: 'name',
|
|
|
|
|
|
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',
|
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
|
scopedSlots: { customRender: 'type' }
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '策略描述',
|
|
|
|
|
|
dataIndex: 'describe',
|
|
|
|
|
|
key: 'describe',
|
|
|
|
|
|
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',
|
|
|
|
|
|
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',
|
|
|
|
|
|
ellipsis: true,
|
2025-09-11 16:14:55 +08:00
|
|
|
|
fixed:'right',
|
2025-09-04 13:42:48 +08:00
|
|
|
|
scopedSlots: { customRender: 'action' }
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
2025-09-05 09:28:00 +08:00
|
|
|
|
tableData: [],
|
2025-09-05 16:41:50 +08:00
|
|
|
|
tableOption: {
|
|
|
|
|
|
select:false
|
|
|
|
|
|
},
|
2025-09-05 09:28:00 +08:00
|
|
|
|
pageOption: {
|
2025-09-05 16:41:50 +08:00
|
|
|
|
page: 1,
|
2025-09-05 09:28:00 +08:00
|
|
|
|
pageSize: 10,
|
2025-09-05 16:41:50 +08:00
|
|
|
|
count: 0
|
2025-09-04 13:42:48 +08:00
|
|
|
|
},
|
2025-09-05 09:28:00 +08:00
|
|
|
|
formState: {},
|
2025-09-09 09:39:15 +08:00
|
|
|
|
formStatus: 'add', //表单状态辑状态 add:新增 edit:编辑
|
|
|
|
|
|
operateList:[]
|
2025-09-01 16:55:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
2025-09-09 09:39:15 +08:00
|
|
|
|
this.operateList = this.$getBtns(['查看', '修改', '删除'])
|
|
|
|
|
|
this.btnOptionList = this.$getBtns(['新增'])
|
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-11 16:14:55 +08:00
|
|
|
|
this.$refs.comTable.loading = true
|
2025-09-04 13:42:48 +08:00
|
|
|
|
try {
|
2025-09-11 16:14:55 +08:00
|
|
|
|
this.$refs.comTable.loading = false
|
2025-09-04 13:42:48 +08:00
|
|
|
|
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
|
|
|
|
this.tableData = res.data
|
2025-09-05 16:41:50 +08:00
|
|
|
|
this.pageOption.count = 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-11 16:14:55 +08:00
|
|
|
|
this.$refs.comTable.loading = false
|
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-05 16:41:50 +08:00
|
|
|
|
console.log(type, record)
|
|
|
|
|
|
|
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-05 16:41:50 +08:00
|
|
|
|
case 'del':
|
2025-09-09 09:39:15 +08:00
|
|
|
|
this.handleDelete(record.policy_id)
|
2025-09-05 16:41:50 +08:00
|
|
|
|
break
|
|
|
|
|
|
case 'edit':
|
|
|
|
|
|
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
|
|
|
|
},
|
2025-09-09 09:39:15 +08:00
|
|
|
|
// async handleDelete(record) {
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// const res = await getReq('/deletePolicy', {
|
|
|
|
|
|
// policy_id: record['policy_id']
|
|
|
|
|
|
// })
|
|
|
|
|
|
// if (res.errcode == 0) {
|
|
|
|
|
|
// this.$message.success('删除成功')
|
|
|
|
|
|
// this.getTableList()
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
|
// this.$message.success(error)
|
|
|
|
|
|
// }
|
|
|
|
|
|
// },
|
|
|
|
|
|
// 删除操作
|
|
|
|
|
|
async handleDelete(id) {
|
|
|
|
|
|
const that = this
|
|
|
|
|
|
this.$Modal.confirm({
|
|
|
|
|
|
title: '你确认删除数据吗?',
|
|
|
|
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
|
|
|
|
|
|
|
|
|
|
async onOk() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getReq('/deletePolicy', {
|
|
|
|
|
|
policy_id: id
|
|
|
|
|
|
})
|
|
|
|
|
|
if (res.errcode == 0) {
|
|
|
|
|
|
that.$message.success('删除成功')
|
|
|
|
|
|
that.getTableList()
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
that.$message.success(error)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onCancel() {
|
|
|
|
|
|
// console.log("Cancel");
|
|
|
|
|
|
},
|
|
|
|
|
|
class: 'test'
|
|
|
|
|
|
})
|
2025-09-05 16:41:50 +08:00
|
|
|
|
},
|
|
|
|
|
|
closeModal(flag = false) {
|
2025-09-05 09:28:00 +08:00
|
|
|
|
this.formModal = false
|
2025-09-05 16:41:50 +08:00
|
|
|
|
if (flag) {
|
|
|
|
|
|
this.pageOption.page = 1
|
|
|
|
|
|
this.getTableList()
|
|
|
|
|
|
}
|
2025-09-01 16:55:44 +08:00
|
|
|
|
},
|
2025-09-04 13:42:48 +08:00
|
|
|
|
handlePagesizeChange(data) {
|
2025-09-05 16:41:50 +08:00
|
|
|
|
if (data.pageSize !== this.pageOption.pageSize) {
|
|
|
|
|
|
this.pageOption.page = 1
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.pageOption.page = data.page
|
|
|
|
|
|
}
|
|
|
|
|
|
this.pageOption.pageSize = data.pageSize
|
|
|
|
|
|
this.getTableList()
|
2025-09-04 13:42:48 +08:00
|
|
|
|
}
|
2025-09-01 16:55:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2025-09-04 13:42:48 +08:00
|
|
|
|
.policy {
|
2025-09-10 09:23:47 +08:00
|
|
|
|
// width: 100%;
|
2025-09-04 13:42:48 +08:00
|
|
|
|
height: 100%;
|
2025-09-11 16:14:55 +08:00
|
|
|
|
padding: 0 10px;
|
2025-09-04 13:42:48 +08:00
|
|
|
|
.content-table {
|
2025-09-05 09:28:00 +08:00
|
|
|
|
width: 100%;
|
2025-09-09 09:39:15 +08:00
|
|
|
|
height: calc(100% - 90px);
|
2025-09-05 09:28:00 +08:00
|
|
|
|
}
|
2025-09-01 16:55:44 +08:00
|
|
|
|
}
|
2025-09-04 13:42:48 +08:00
|
|
|
|
</style>
|