Commit de4055bb30c87b0cadf1a83d3172135a99749753
1 parent
02391826
fix: reset layout on create component && copy component
Showing
3 changed files
with
8 additions
and
23 deletions
| ... | ... | @@ -2,6 +2,7 @@ import { EChartsOption } from 'echarts'; |
| 2 | 2 | import { fontSize } from '../../detail/config/util'; |
| 3 | 3 | import { Gradient, visualOptionField } from '../../detail/config/visualOptions'; |
| 4 | 4 | import { DataComponentRecord, DataSource, GradientInfo } from '/@/api/dataBoard/model'; |
| 5 | +import { isArray } from '/@/utils/is'; | |
| 5 | 6 | import { buildUUID } from '/@/utils/uuid'; |
| 6 | 7 | |
| 7 | 8 | export type InstrumentComponentType = 'instrument-component-1' | 'instrument-component-2'; |
| ... | ... | @@ -179,12 +180,9 @@ export const instrumentComponent2 = (params?: { |
| 179 | 180 | lineStyle: { |
| 180 | 181 | width: 20, |
| 181 | 182 | color: [ |
| 182 | - [firstGradient, (getGradientValue(Gradient.FIRST, gradient) as string) || '#67e0e3'], | |
| 183 | - [ | |
| 184 | - secondGradient, | |
| 185 | - (getGradientValue(Gradient.SECOND, gradient) as string) || '#37a2da', | |
| 186 | - ], | |
| 187 | - [1, (getGradientValue(Gradient.THIRD, gradient) as string) || '#fd666d'], | |
| 183 | + [firstGradient, firstRecord?.color || '#67e0e3'], | |
| 184 | + [secondGradient, secondRecord?.color || '#37a2da'], | |
| 185 | + [1, thirdRecord?.color || '#fd666d'], | |
| 188 | 186 | ], |
| 189 | 187 | }, |
| 190 | 188 | }, |
| ... | ... | @@ -231,11 +229,8 @@ export const instrumentComponent2 = (params?: { |
| 231 | 229 | }; |
| 232 | 230 | }; |
| 233 | 231 | |
| 234 | -export const getGradientValue = (key: Gradient, record: GradientInfo[]) => { | |
| 235 | - return record.find((item) => item.key === key)?.color; | |
| 236 | -}; | |
| 237 | - | |
| 238 | -export const getGradient = (key: Gradient, record: GradientInfo[]) => { | |
| 232 | +export const getGradient = (key: Gradient, record: GradientInfo[] = []) => { | |
| 233 | + if (!isArray(record)) return; | |
| 239 | 234 | return record.find((item) => item.key === key); |
| 240 | 235 | }; |
| 241 | 236 | ... | ... |
| ... | ... | @@ -51,16 +51,11 @@ |
| 51 | 51 | |
| 52 | 52 | const handleAddComponent = async (value: Recordable) => { |
| 53 | 53 | try { |
| 54 | - const data = await addDataComponent({ | |
| 54 | + await addDataComponent({ | |
| 55 | 55 | boardId: unref(boardId), |
| 56 | 56 | record: { dataBoardId: unref(boardId), frontId: unref(frontId), ...value }, |
| 57 | 57 | }); |
| 58 | 58 | createMessage.success('创建成功'); |
| 59 | - const id = data.data.id; | |
| 60 | - await updateDataBoardLayout({ | |
| 61 | - boardId: unref(boardId), | |
| 62 | - layout: [{ id, w: DEFAULT_WIDGET_WIDTH, h: DEFAULT_WIDGET_HEIGHT, x: 0, y: 0 }], | |
| 63 | - }); | |
| 64 | 59 | closeModal(); |
| 65 | 60 | emit('submit'); |
| 66 | 61 | } catch (error) { | ... | ... |
| ... | ... | @@ -214,7 +214,7 @@ |
| 214 | 214 | const handleCopy = async (id: string) => { |
| 215 | 215 | const record = unref(dataBoardList).find((item) => item.i === id); |
| 216 | 216 | try { |
| 217 | - const data = await addDataComponent({ | |
| 217 | + await addDataComponent({ | |
| 218 | 218 | boardId: unref(getBoardId), |
| 219 | 219 | record: { |
| 220 | 220 | dataBoardId: unref(getBoardId), |
| ... | ... | @@ -223,11 +223,6 @@ |
| 223 | 223 | }, |
| 224 | 224 | }); |
| 225 | 225 | createMessage.success('复制成功'); |
| 226 | - const id = data.data.id; | |
| 227 | - await updateDataBoardLayout({ | |
| 228 | - boardId: unref(getBoardId), | |
| 229 | - layout: [{ id, w: DEFAULT_WIDGET_WIDTH, h: DEFAULT_WIDGET_HEIGHT, x: 0, y: 0 }], | |
| 230 | - }); | |
| 231 | 226 | getDataBoardComponent(); |
| 232 | 227 | } catch (error) {} |
| 233 | 228 | }; | ... | ... |