mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
feat(system): 优化电价策略功能
- 添加删除策略功能 - 修复编辑策略时表单数据绑定问题 - 优化策略列表展示逻辑 - 调整策略表单验证方式 - 修改策略列表分页配置
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="policy">
|
||||
<div class="policy" ref="policy">
|
||||
<searchBox :btn-option-list="btnOptionList" @onSearch="onSearch" @operateForm="operateForm" />
|
||||
<div class="content-table">
|
||||
<ComTable
|
||||
@@ -35,21 +35,30 @@
|
||||
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
|
||||
<a-popconfirm
|
||||
title="确认要删除数据吗?"
|
||||
ok-text="确认"
|
||||
cancel-text="取消"
|
||||
@confirm="operateForm('del', record)"
|
||||
@cancel="() => {}"
|
||||
>
|
||||
<a-button type="primary" size="small" class="btn-del" style="margin-left: 10px"
|
||||
>删除</a-button
|
||||
>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</ComTable>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<a-modal v-model:open="formModal" width="70%" style="top: 20px" :footer="null">
|
||||
<policyForm :form-state="formState" :form-status="formStatus" @closeModal="closeModal"/>
|
||||
<a-modal
|
||||
v-model:open="formModal"
|
||||
width="70%"
|
||||
style="top: 20px"
|
||||
:footer="null"
|
||||
:get-container="() => $refs.policy"
|
||||
>
|
||||
<policyForm :form-state="formState" :form-status="formStatus" @closeModal="closeModal" />
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
@@ -66,8 +75,8 @@ export default {
|
||||
return {
|
||||
formModal: false,
|
||||
btnOptionList: [
|
||||
{ label: '新增', icon: 'icon-tianjia', type: 'add' },
|
||||
{ label: '删除', icon: 'icon-tianjia', type: 'del' }
|
||||
{ label: '新增', icon: 'icon-tianjia', type: 'add' }
|
||||
// { label: '删除', icon: 'icon-tianjia', type: 'del' }
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
@@ -125,15 +134,17 @@ export default {
|
||||
}
|
||||
],
|
||||
tableData: [],
|
||||
tableOption: {},
|
||||
tableOption: {
|
||||
select:false
|
||||
},
|
||||
pageOption: {
|
||||
page: 0,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
count: 0
|
||||
},
|
||||
tableH: '',
|
||||
formState: {},
|
||||
formStatus:'add',//表单状态辑状态 add:新增 edit:编辑
|
||||
formStatus: 'add' //表单状态辑状态 add:新增 edit:编辑
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@@ -148,13 +159,12 @@ export default {
|
||||
})
|
||||
console.log(res)
|
||||
this.tableData = res.data
|
||||
this.total = res.count
|
||||
this.pageOption.count = res.count
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
getPolicyType(type) {
|
||||
|
||||
return policyTypes.find((item) => item.value == type)?.label || ''
|
||||
},
|
||||
|
||||
@@ -162,7 +172,8 @@ export default {
|
||||
console.log(data)
|
||||
},
|
||||
operateForm(type, record = {}) {
|
||||
|
||||
console.log(type, record)
|
||||
|
||||
this.formStatus = type
|
||||
switch (type) {
|
||||
case 'add':
|
||||
@@ -173,16 +184,45 @@ export default {
|
||||
this.formModal = true
|
||||
this.formState = record
|
||||
break
|
||||
|
||||
case 'del':
|
||||
this.handleDelete(record)
|
||||
break
|
||||
case 'edit':
|
||||
this.formModal = true
|
||||
this.formState = record
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
},
|
||||
closeModal(){
|
||||
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)
|
||||
}
|
||||
},
|
||||
closeModal(flag = false) {
|
||||
this.formModal = false
|
||||
if (flag) {
|
||||
this.pageOption.page = 1
|
||||
this.getTableList()
|
||||
}
|
||||
},
|
||||
handlePagesizeChange(data) {
|
||||
console.log(data)
|
||||
if (data.pageSize !== this.pageOption.pageSize) {
|
||||
this.pageOption.page = 1
|
||||
} else {
|
||||
this.pageOption.page = data.page
|
||||
}
|
||||
this.pageOption.pageSize = data.pageSize
|
||||
this.getTableList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user