Commit 6ce66876e7d10a39909c70b55cdfe48bd10378de
1 parent
3d7ab5e9
fix(paramsTable.vue): 修复参数表格不能同步删除数据
Showing
2 changed files
with
8 additions
and
9 deletions
... | ... | @@ -124,7 +124,7 @@ const props = withDefaults( |
124 | 124 | maxRow: 50, |
125 | 125 | } |
126 | 126 | ) |
127 | - | |
127 | + | |
128 | 128 | |
129 | 129 | const emit = defineEmits(['update:value']) |
130 | 130 | |
... | ... | @@ -143,7 +143,7 @@ watch( |
143 | 143 | dataSource.value = Object.keys(props.value || {}).map(keyName => ({ ...createNewRow(), keyName, value: Reflect.get(props.value || {}, keyName) })) |
144 | 144 | } else { |
145 | 145 | dataSource.value = [createNewRow()] |
146 | - } | |
146 | + } | |
147 | 147 | }, |
148 | 148 | { |
149 | 149 | immediate: true, |
... | ... | @@ -167,11 +167,11 @@ const handleAddRow = (record: DataSource) => { |
167 | 167 | const handleSubtractRow = (record: DataSource) => { |
168 | 168 | const index = unref(dataSource).findIndex(item => item.id === record.id) |
169 | 169 | if (unref(dataSource).length === 1) { |
170 | - unref(dataSource)[index].keyName = '' | |
171 | - unref(dataSource)[index].value = '' | |
172 | - return | |
170 | + emit('update:value', {}) | |
171 | + } else { | |
172 | + unref(dataSource).splice(index, 1) | |
173 | + emit('update:value', getHeaderConfiguration()) | |
173 | 174 | } |
174 | - unref(dataSource).splice(index, 1) | |
175 | 175 | } |
176 | 176 | |
177 | 177 | |
... | ... | @@ -194,5 +194,5 @@ const getHeaderConfiguration = () => { |
194 | 194 | </script> |
195 | 195 | |
196 | 196 | <template> |
197 | - <NDataTable size="small" :columns="columns" :data="dataSource" max-height="300" /> | |
197 | + <NDataTable size="small" :columns="columns" :row-key="rowData => rowData.id" :data="dataSource" max-height="300" /> | |
198 | 198 | </template> | ... | ... |
... | ... | @@ -69,8 +69,7 @@ const getResult = () => { |
69 | 69 | |
70 | 70 | const handleSaveAction = async () => { |
71 | 71 | if (!(await validate())) return |
72 | - const value = getResult() | |
73 | - console.log(value) | |
72 | + const value = getResult() | |
74 | 73 | if (unref(selectTarget)) { |
75 | 74 | chartEditStore.updateComponentList(chartEditStore.fetchTargetIndex(), { |
76 | 75 | ...unref(selectTarget)!, | ... | ... |