Commit 91d71fa7caea6a4cb39b1be62ab415682b80b193
1 parent
c01f8c0e
fix: DEFECT-693 copy component panel not copy component layout info
Showing
2 changed files
with
36 additions
and
18 deletions
| ... | ... | @@ -122,11 +122,11 @@ export const addDataComponent = (params: AddDataComponentParams) => { |
| 122 | 122 | * @param params |
| 123 | 123 | * @returns |
| 124 | 124 | */ |
| 125 | -export const deleteDataComponent = (params: string[]) => { | |
| 125 | +export const deleteDataComponent = (params: string) => { | |
| 126 | 126 | return defHttp.delete({ |
| 127 | - url: DataComponentUrl.DELETE_DATA_COMPONENT, | |
| 127 | + url: `${DataComponentUrl.DELETE_DATA_COMPONENT}/${params}`, | |
| 128 | 128 | params: { |
| 129 | - ids: params, | |
| 129 | + ids: [params], | |
| 130 | 130 | }, |
| 131 | 131 | }); |
| 132 | 132 | }; | ... | ... |
| ... | ... | @@ -177,21 +177,23 @@ |
| 177 | 177 | openModal(true, { isEdit: false }); |
| 178 | 178 | }; |
| 179 | 179 | |
| 180 | + const getLayoutInfo = () => { | |
| 181 | + return unref(dataBoardList).map((item) => { | |
| 182 | + return { | |
| 183 | + id: item.i, | |
| 184 | + h: item.h, | |
| 185 | + w: item.w, | |
| 186 | + x: item.x, | |
| 187 | + y: item.y, | |
| 188 | + } as Layout; | |
| 189 | + }); | |
| 190 | + }; | |
| 191 | + | |
| 180 | 192 | const handleSaveLayoutInfo = async () => { |
| 181 | 193 | try { |
| 182 | - const layoutInfo = unref(dataBoardList).map((item) => { | |
| 183 | - return { | |
| 184 | - id: item.i, | |
| 185 | - h: item.h, | |
| 186 | - w: item.w, | |
| 187 | - x: item.x, | |
| 188 | - y: item.y, | |
| 189 | - } as Layout; | |
| 190 | - }); | |
| 191 | - | |
| 192 | 194 | await updateDataBoardLayout({ |
| 193 | 195 | boardId: unref(getBoardId), |
| 194 | - layout: layoutInfo, | |
| 196 | + layout: getLayoutInfo(), | |
| 195 | 197 | }); |
| 196 | 198 | } catch (error) {} |
| 197 | 199 | }; |
| ... | ... | @@ -231,7 +233,6 @@ |
| 231 | 233 | |
| 232 | 234 | if (!data.data.componentData) { |
| 233 | 235 | dataBoardList.value = []; |
| 234 | - console.log(unref(dataBoardList)); | |
| 235 | 236 | return; |
| 236 | 237 | } |
| 237 | 238 | dataBoardList.value = data.data.componentData.map((item) => { |
| ... | ... | @@ -311,7 +312,7 @@ |
| 311 | 312 | const handleCopy = async (id: string) => { |
| 312 | 313 | const record = unref(dataBoardList).find((item) => item.i === id); |
| 313 | 314 | try { |
| 314 | - await addDataComponent({ | |
| 315 | + const data = await addDataComponent({ | |
| 315 | 316 | boardId: unref(getBoardId), |
| 316 | 317 | record: { |
| 317 | 318 | dataBoardId: unref(getBoardId), |
| ... | ... | @@ -320,14 +321,31 @@ |
| 320 | 321 | }, |
| 321 | 322 | }); |
| 322 | 323 | createMessage.success('复制成功'); |
| 323 | - getDataBoardComponent(); | |
| 324 | + const _id = data.data.id; | |
| 325 | + const layoutInfo = getLayoutInfo(); | |
| 326 | + | |
| 327 | + layoutInfo.push({ | |
| 328 | + id: _id, | |
| 329 | + h: record?.h, | |
| 330 | + w: record?.w, | |
| 331 | + x: record?.x, | |
| 332 | + y: record?.y, | |
| 333 | + } as Layout); | |
| 334 | + | |
| 335 | + await updateDataBoardLayout({ | |
| 336 | + boardId: unref(getBoardId), | |
| 337 | + layout: layoutInfo, | |
| 338 | + }); | |
| 339 | + | |
| 340 | + await getDataBoardComponent(); | |
| 324 | 341 | } catch (error) {} |
| 325 | 342 | }; |
| 326 | 343 | |
| 327 | 344 | const handleDelete = async (id: string) => { |
| 328 | 345 | try { |
| 329 | - await deleteDataComponent([id]); | |
| 346 | + await deleteDataComponent(id); | |
| 330 | 347 | createMessage.success('删除成功'); |
| 348 | + await handleSaveLayoutInfo(); | |
| 331 | 349 | await getDataBoardComponent(); |
| 332 | 350 | } catch (error) { |
| 333 | 351 | // createMessage.error('删除失败'); | ... | ... |