api+页面调整

This commit is contained in:
joylink_zhaoerwei 2024-09-24 09:31:28 +08:00
parent a7f6fc945d
commit a476abc7a4
8 changed files with 93 additions and 50 deletions

View File

@ -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<DraftItem> {
}) {
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
}
}

View File

@ -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('', {

View File

@ -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) => {

View File

@ -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({
const res = await saveAsDraft({
id: +route.params.id as number,
name,
userId: authStore.userId,
});
successNotify('另存为草稿成功');
saveAsDialog.value = false;
} catch (err) {
const error = err as ApiError;
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();
}
</script>

View File

@ -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<QForm | null>(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;

View File

@ -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({

View File

@ -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) {

View File

@ -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,