diff --git a/src/api/DraftApi.ts b/src/api/DraftApi.ts index 1563f95..29cb8d1 100644 --- a/src/api/DraftApi.ts +++ b/src/api/DraftApi.ts @@ -9,6 +9,18 @@ export enum DraftDataType { ISCS = 'ISCS', } +export enum IscsStyle { + UNKNOWN, + DA_SHI_ZHI_NENG = 'DA_SHI_ZHI_NENG', +} + +export const iscsStyleOption = [ + { + label: '达实智能', + value: IscsStyle.DA_SHI_ZHI_NENG, + }, +]; + export interface DraftItem { id: number; name: string; @@ -90,15 +102,10 @@ export async function sharedDraftPageQuery( * @param params * @returns */ -export enum IscsStyle { - UNKNOWN, - DA_SHI_ZHI_NENG = 'DA_SHI_ZHI_NENG', -} interface CreateDraftIscsDto { input: { name: string; options: IscsDataOptions; - userId: number; }; } export function createDraft(params: CreateDraftIscsDto) { @@ -204,11 +211,10 @@ export function saveDraft(variables: { id: number; data: string }) { export async function saveAsDraft(variables: { id: number; name: string; - userId: number; -}): Promise { +}) { const mutation = ` - mutation saveAsNewDraftData($id: Int,$name: String,$userId: Int) { - saveAsNewDraftData(id: $id,name: $name,userId: $userId){ + mutation saveAsNewDraftData($id: Int,$name: String) { + saveAsNewDraftData(id: $id,name: $name){ id } } diff --git a/src/api/PublishApi.ts b/src/api/PublishApi.ts index d1acc32..fe4d46a 100644 --- a/src/api/PublishApi.ts +++ b/src/api/PublishApi.ts @@ -127,10 +127,10 @@ export async function publishPageQuery( * 另存到草稿 * @param id 发布id */ -export function saveToDraft(variables: { versionId: number; userId: number }) { +export function saveToDraft(variables: { versionId: number }) { const mutation = ` - mutation createDraftDataFromReleaseDataVersion($versionId: Int,$userId: Int) { - createDraftDataFromReleaseDataVersion(versionId: $versionId,userId: $userId){name} + mutation createDraftDataFromReleaseDataVersion($versionId: Int) { + createDraftDataFromReleaseDataVersion(versionId: $versionId){name} } `; return api.post('', { diff --git a/src/boot/axios.ts b/src/boot/axios.ts index 30dc28d..07cf502 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -68,15 +68,17 @@ export class ApiError { const api = axios.create({ baseURL: getHttpBase() }); let isOpenDialog = false; // 认证弹窗是否打开 -//const CancelToken = axios.CancelToken; -//const source = CancelToken.source(); +const CancelToken = axios.CancelToken; +const source = CancelToken.source(); export default boot(({ app, router }) => { // for use inside Vue files (Options API) through this.$axios and this.$api // 拦截请求,添加 - /* api.interceptors.request.use( + api.interceptors.request.use( (config) => { - config.headers.Authorization = getJwtToken(); + //config.headers.Authorization = getJwtToken(); + config.headers.Authorization = 'Bearer 1e2d0d5d96034f4a0805af6512051ddc'; + config.headers['Token'] = '1e2d0d5d96034f4a0805af6512051ddc'; config.cancelToken = source.token; if (isOpenDialog) { source.cancel(); @@ -86,7 +88,7 @@ export default boot(({ app, router }) => { (err: AxiosError) => { return Promise.reject(ApiError.from(err)); } - ); */ + ); api.interceptors.response.use( (response) => { diff --git a/src/layouts/IscsDrawLayout.vue b/src/layouts/IscsDrawLayout.vue index 2b7857b..0c9566a 100644 --- a/src/layouts/IscsDrawLayout.vue +++ b/src/layouts/IscsDrawLayout.vue @@ -143,18 +143,17 @@ import { Rect } from 'src/graphics/rect/Rect'; import { getIscsStyleConfig } from 'src/configs/iscsStyleConfig'; import { IscsStyle, saveAsDraft } from 'src/api/DraftApi'; import DraggableDialog from 'src/components/common/DraggableDialog.vue'; -import { ApiError } from 'src/boot/axios'; -import { useAuthStore } from 'src/stores/auth-store'; import { successNotify } from 'src/utils/CommonNotify'; +import { saveDrawDatas } from 'src/drawApp/iscsApp'; +import { saveDrawToServer } from 'src/drawApp/commonApp'; const $q = useQuasar(); const route = useRoute(); const router = useRouter(); const searchId = ref(0); - const drawStore = useDrawStore(); -const authStore = useAuthStore(); const showDrawTool = ref(true); + watch( () => drawStore.drawMode, (drawMode) => { @@ -281,37 +280,40 @@ function onResize() { } } -function saveAllDrawDatas() { - // const drawApp = drawStore.getDrawApp(); -} - function backConfirm() { router.go(-1); } +function saveAllDrawDatas() { + const drawApp = drawStore.getDrawApp(); + saveDrawToServer(saveDrawDatas(drawApp)); +} + const saveAsDialog = ref(false); const saveAsName = ref(''); async function saveAs(name: string) { - try { - await saveAsDraft({ - id: +route.params.id as number, - name, - userId: authStore.userId, - }); - successNotify('另存为草稿成功'); - saveAsDialog.value = false; - } catch (err) { - const error = err as ApiError; + const res = await saveAsDraft({ + id: +route.params.id as number, + name, + }); + if (res.data?.errors && res.data?.errors.length) { $q.notify({ type: 'negative', - message: error.title, + message: res.data.errors[0].message, }); + } else { + successNotify('另存为草稿成功'); + saveAsDialog.value = false; } } -function onTopMenuClick() { +function onTopMenuClick(name: string) { + console.log(name); + drawStore.clickSubmenuName = name; const drawApp = drawStore.getDrawApp(); + const graphics = drawApp.queryStore.getAllGraphics(); + graphics.forEach((graphic) => (graphic.visible = false)); drawApp.forceReload(); } diff --git a/src/pages/IscsDraftManage.vue b/src/pages/IscsDraftManage.vue index 077d631..feeba99 100644 --- a/src/pages/IscsDraftManage.vue +++ b/src/pages/IscsDraftManage.vue @@ -248,6 +248,7 @@ import { setDraftRename, sharedDraftPageQuery, PagingQueryParams, + iscsStyleOption, } from '../api/DraftApi'; import { ApiError } from 'src/boot/axios'; import { useRoute, useRouter } from 'vue-router'; @@ -260,6 +261,7 @@ import { } from 'src/api/PublishApi'; import { useAuthStore } from 'src/stores/auth-store'; import { PageDto } from 'src/api/ApiCommon'; +import { useDrawStore } from 'src/stores/draw-store'; const $q = useQuasar(); const router = useRouter(); @@ -270,6 +272,7 @@ const props = withDefaults( { sizeHeight: 500 } ); const authStore = useAuthStore(); +const drawStore = useDrawStore(); const route = useRoute(); const tableHeight = computed(() => { @@ -288,6 +291,14 @@ const columnDefs: QTableColumn[] = [ required: true, align: 'center', }, + { + name: 'type', + label: '类型', + field: (row) => { + return getTypeName(row); + }, + align: 'center', + }, { name: 'userId', label: '创建人', @@ -383,18 +394,22 @@ async function onRequest(props: any) { } } +function getTypeName(row: DraftItem) { + const iscsStyle = allRequestData.find((item) => item.draftData.id == row.id) + .options.style; + const iscsStyleName = iscsStyleOption.find( + (item) => item.value == iscsStyle + ).label; + return iscsStyleName || ''; +} + //新建相关 const createFormShow = ref(false); const createForm = reactive({ draftName: '', style: IscsStyle.DA_SHI_ZHI_NENG, }); -const iscsStyleOption = [ - { - label: '达实智能', - value: IscsStyle.DA_SHI_ZHI_NENG, - }, -]; + const myForm = ref(null); function onCreate() { myForm.value?.validate().then(async (res) => { @@ -404,7 +419,6 @@ function onCreate() { input: { name: createForm.draftName, options: { style: createForm.style }, - userId: authStore.userId, }, }; const res = await createDraft(variables); @@ -426,6 +440,7 @@ function onCreate() { //编辑 function goToPath(row: DraftItem) { + drawStore.clickSubmenuName = '车站控制'; let path = `/iscsPainting/${row.id}`; const iscsStyle = allRequestData.find((item) => item.draftData.id == row.id) .options.style; diff --git a/src/pages/IscsPublishManage.vue b/src/pages/IscsPublishManage.vue index 6c28670..2b12cbf 100644 --- a/src/pages/IscsPublishManage.vue +++ b/src/pages/IscsPublishManage.vue @@ -136,12 +136,13 @@ import { setPublishRelease, PublishHistoryItem, fallbackVersion, + PublishIscsDataDto, } from '../api/PublishApi'; import { useRoute } from 'vue-router'; import { ApiError } from 'src/boot/axios'; import { nextTick } from 'process'; -import { DraftDataType } from 'src/api/DraftApi'; -import { useAuthStore } from 'src/stores/auth-store'; +import { DraftDataType, iscsStyleOption } from 'src/api/DraftApi'; + const route = useRoute(); const $q = useQuasar(); @@ -152,7 +153,6 @@ const props = withDefaults( }>(), { sizeHeight: 500, selects: () => [] } ); -const authStore = useAuthStore(); const tableHeight = computed(() => { return props.sizeHeight - 32; }); @@ -170,6 +170,14 @@ const columnDefs: QTableColumn[] = [ required: true, align: 'center', }, + { + name: 'type', + label: '类型', + field: (row) => { + return getTypeName(row); + }, + align: 'center', + }, { name: 'description', label: '描述', @@ -213,6 +221,7 @@ const pagination = ref({ }); // eslint-disable-next-line +let allRequestData: PublishIscsDataDto[] = []; async function onRequest(props: any) { const { page, rowsPerPage } = props.pagination; const filter = props.filter; @@ -224,7 +233,6 @@ async function onRequest(props: any) { itemsPerPage: rowsPerPage, }, query: { - userId: authStore.userId, dataType: DraftDataType.ISCS, name: filter.name, }, @@ -239,6 +247,7 @@ async function onRequest(props: any) { rows.length, ...(response.items.map((item) => item.releaseData) as []) ); + allRequestData = response.items; } catch (err) { const error = err as ApiError; $q.notify({ @@ -250,6 +259,15 @@ async function onRequest(props: any) { } } +function getTypeName(row: PublishItem) { + const iscsStyle = allRequestData.find((item) => item.releaseData.id == row.id) + .options.style; + const iscsStyleName = iscsStyleOption.find( + (item) => item.value == iscsStyle + ).label; + return iscsStyleName || ''; +} + //上下架 function dataReleaseFn(row: PublishItem) { if (row.isPublished) { @@ -291,7 +309,6 @@ function dataReleaseFn(row: PublishItem) { function saveToDraftFn(row: PublishItem) { saveToDraft({ versionId: row.usedVersionId, - userId: row.userId, }).then((res) => { if (res.data?.errors && res.data?.errors.length) { $q.notify({ diff --git a/src/stores/auth-store.ts b/src/stores/auth-store.ts index a1971bc..8a8d132 100644 --- a/src/stores/auth-store.ts +++ b/src/stores/auth-store.ts @@ -2,7 +2,7 @@ import { defineStore } from 'pinia'; export const useAuthStore = defineStore('auth', { state: () => ({ - userId: 1 as number | null, + userId: 8160 as number | null, }), actions: { setUserId(id: number | null) { diff --git a/src/stores/draw-store.ts b/src/stores/draw-store.ts index be8abcf..df79556 100644 --- a/src/stores/draw-store.ts +++ b/src/stores/draw-store.ts @@ -20,6 +20,7 @@ export const useDrawStore = defineStore('draw', { selectedGraphics: null as JlGraphic[] | null, draftId: null as number | null, drawPictureType: null as PictureType | null, + clickSubmenuName: '车站控制', }), getters: { drawMode: (state) => state.drawAssistant != null,