UPDATE: VERSION-20260317
This commit is contained in:
@@ -83,8 +83,8 @@
|
||||
<div class="ks-sidebar-list-param-item" v-for="(item,index) in selectedFireRule.conditionsArray">
|
||||
<a-row :gutter="15">
|
||||
<a-col :span="21">
|
||||
<PlatformSelect @update="(payload: PlatformComponentPayload)=> handleUpdateCondition(payload, index)"
|
||||
:platform="item.platform" :component="item.component"/>
|
||||
<PlatformSelect @change="(payload: PlatformComponentPayload)=> handleUpdateCondition(payload, index)"
|
||||
:payload="item"/>
|
||||
</a-col>
|
||||
<a-col :span="3">
|
||||
<a-space class="ks-sidebar-list-param-actions">
|
||||
@@ -108,8 +108,8 @@
|
||||
<div class="ks-sidebar-list-param-item" v-for="(item,index) in selectedFireRule.actionsArray">
|
||||
<a-row :gutter="15">
|
||||
<a-col :span="21">
|
||||
<PlatformSelect @update="(payload: PlatformComponentPayload)=> handleUpdateAction(payload, index)"
|
||||
:platform="item.platform" :component="item.component"/>
|
||||
<PlatformSelect @change="(payload: PlatformComponentPayload)=> handleUpdateAction(payload, index)"
|
||||
:payload="item"/>
|
||||
</a-col>
|
||||
<a-col :span="3">
|
||||
<a-space class="ks-sidebar-list-param-actions">
|
||||
@@ -168,7 +168,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { onMounted, ref, nextTick } from 'vue';
|
||||
import { type FormInstance, message } from 'ant-design-vue';
|
||||
import { MinusCircleOutlined, PlusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue';
|
||||
import Layout from '../layout.vue';
|
||||
@@ -222,11 +222,15 @@ const getSceneTypeName = (item: FireRule): string => {
|
||||
};
|
||||
|
||||
const resolveItem = (item: FireRule) => {
|
||||
let newItem = JSON.parse(JSON.stringify(item)) as FireRule;
|
||||
try{
|
||||
newItem.conditionsArray = JSON.parse(newItem.conditions as string);
|
||||
} catch(e: any){
|
||||
let newItem: FireRule = JSON.parse(JSON.stringify(item)) as FireRule;
|
||||
if (typeof item.conditions === 'string') {
|
||||
try{
|
||||
newItem.conditionsArray = JSON.parse(item.conditions as string);
|
||||
} catch(e: any){
|
||||
newItem.conditionsArray = []
|
||||
}
|
||||
}
|
||||
|
||||
if(!newItem.conditionsArray) {
|
||||
newItem.conditionsArray = []
|
||||
}
|
||||
@@ -237,10 +241,14 @@ const resolveItem = (item: FireRule) => {
|
||||
})
|
||||
}
|
||||
|
||||
try{
|
||||
newItem.actionsArray = JSON.parse(newItem.actions as string);
|
||||
} catch(e: any){
|
||||
if (typeof item.actions === 'string') {
|
||||
try{
|
||||
newItem.actionsArray = JSON.parse(item.actions as string);
|
||||
} catch(e: any){
|
||||
newItem.actionsArray = []
|
||||
}
|
||||
}
|
||||
|
||||
if(!newItem.actionsArray){
|
||||
newItem.actionsArray = []
|
||||
}
|
||||
@@ -250,6 +258,7 @@ const resolveItem = (item: FireRule) => {
|
||||
component: null,
|
||||
})
|
||||
}
|
||||
|
||||
return newItem;
|
||||
};
|
||||
|
||||
@@ -276,8 +285,12 @@ const handleCreate = () => {
|
||||
};
|
||||
|
||||
const handleSelect = (item: FireRule) => {
|
||||
selectedFireRule.value = resolveItem(item);
|
||||
// 1. 先重置表单
|
||||
formRef.value?.resetFields();
|
||||
// 2. 再赋值(使用nextTick确保DOM更新完成)
|
||||
nextTick(() => {
|
||||
selectedFireRule.value = resolveItem(item);
|
||||
});
|
||||
};
|
||||
|
||||
const handleDelete = () => {
|
||||
@@ -368,6 +381,7 @@ const handleAddAction = (_index: number)=> {
|
||||
}
|
||||
|
||||
const handleUpdateCondition = (payload: PlatformComponentPayload, index: number)=> {
|
||||
console.error('handleUpdateCondition', payload)
|
||||
if(selectedFireRule.value && selectedFireRule.value.conditionsArray[index]){
|
||||
selectedFireRule.value.conditionsArray[index] = payload;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user