fix: 修复在编辑项目之前加载数据异常,自动保存导致项目数据清空问题。
This commit is contained in:
parent
bcec26374f
commit
e0d2e8031d
@ -15,6 +15,8 @@ import type { ChartColorsNameType, GlobalThemeJsonType } from '@/settings/chartT
|
|||||||
|
|
||||||
// 项目数据枚举
|
// 项目数据枚举
|
||||||
export enum ProjectInfoEnum {
|
export enum ProjectInfoEnum {
|
||||||
|
// ID
|
||||||
|
PROJECT_ID = "projectId",
|
||||||
// 名称
|
// 名称
|
||||||
PROJECT_NAME = 'projectName',
|
PROJECT_NAME = 'projectName',
|
||||||
// 描述
|
// 描述
|
||||||
@ -27,6 +29,7 @@ export enum ProjectInfoEnum {
|
|||||||
|
|
||||||
// 项目数据
|
// 项目数据
|
||||||
export type ProjectInfoType = {
|
export type ProjectInfoType = {
|
||||||
|
[ProjectInfoEnum.PROJECT_ID]: string,
|
||||||
[ProjectInfoEnum.PROJECT_NAME]: string,
|
[ProjectInfoEnum.PROJECT_NAME]: string,
|
||||||
[ProjectInfoEnum.REMARKS]: string,
|
[ProjectInfoEnum.REMARKS]: string,
|
||||||
[ProjectInfoEnum.THUMBNAIL]: string,
|
[ProjectInfoEnum.THUMBNAIL]: string,
|
||||||
@ -84,6 +87,8 @@ export enum EditCanvasConfigEnum {
|
|||||||
|
|
||||||
// 画布属性(需保存)
|
// 画布属性(需保存)
|
||||||
export type EditCanvasConfigType = {
|
export type EditCanvasConfigType = {
|
||||||
|
// ID
|
||||||
|
[EditCanvasConfigEnum.PROJECT_ID]: string,
|
||||||
// 项目名称
|
// 项目名称
|
||||||
[EditCanvasConfigEnum.PROJECT_NAME]: string,
|
[EditCanvasConfigEnum.PROJECT_NAME]: string,
|
||||||
// 项目描述
|
// 项目描述
|
||||||
|
@ -46,6 +46,7 @@ export const useChartEditStore = defineStore({
|
|||||||
state: (): ChartEditStoreType => ({
|
state: (): ChartEditStoreType => ({
|
||||||
// 项目数据
|
// 项目数据
|
||||||
projectInfo: {
|
projectInfo: {
|
||||||
|
projectId: '',
|
||||||
projectName: '',
|
projectName: '',
|
||||||
remarks: '',
|
remarks: '',
|
||||||
thumbnail: '',
|
thumbnail: '',
|
||||||
|
@ -129,7 +129,9 @@ export const useSync = () => {
|
|||||||
remarks: string,
|
remarks: string,
|
||||||
state: number
|
state: number
|
||||||
}) => {
|
}) => {
|
||||||
const { projectName, remarks, indexImage, state } = projectData
|
const { id, projectName, remarks, indexImage, state } = projectData
|
||||||
|
// ID
|
||||||
|
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_ID, id)
|
||||||
// 名称
|
// 名称
|
||||||
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, projectName)
|
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, projectName)
|
||||||
// 描述
|
// 描述
|
||||||
@ -151,6 +153,8 @@ export const useSync = () => {
|
|||||||
// 更新全局数据
|
// 更新全局数据
|
||||||
await updateComponent(JSON.parse(res.data.content))
|
await updateComponent(JSON.parse(res.data.content))
|
||||||
return
|
return
|
||||||
|
}else {
|
||||||
|
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_ID, fetchRouteParamsLocation())
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.SUCCESS)
|
chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.SUCCESS)
|
||||||
@ -173,6 +177,12 @@ export const useSync = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let projectId = chartEditStore.getProjectInfo[ProjectInfoEnum.PROJECT_ID];
|
||||||
|
if(projectId === null || projectId === ''){
|
||||||
|
window['$message'].error('数据初未始化成功,请刷新页面!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.START)
|
chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.START)
|
||||||
|
|
||||||
// 获取缩略图片
|
// 获取缩略图片
|
||||||
@ -198,7 +208,7 @@ export const useSync = () => {
|
|||||||
|
|
||||||
// 保存数据
|
// 保存数据
|
||||||
let params = new FormData()
|
let params = new FormData()
|
||||||
params.append('projectId', fetchRouteParamsLocation())
|
params.append('projectId', projectId)
|
||||||
params.append('content', JSON.stringify(chartEditStore.getStorageInfo || {}))
|
params.append('content', JSON.stringify(chartEditStore.getStorageInfo || {}))
|
||||||
const res= await saveProjectApi(params) as unknown as MyResponseType
|
const res= await saveProjectApi(params) as unknown as MyResponseType
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user