草稿发布调整+GraphQL的错误信息也在返回的body里面
This commit is contained in:
parent
469222e46f
commit
a7f6fc945d
@ -23,14 +23,14 @@ export interface DraftItem {
|
||||
defaultReleaseDataName: string;
|
||||
}
|
||||
|
||||
interface PagingQueryParams {
|
||||
export interface PagingQueryParams {
|
||||
paging: {
|
||||
page: number;
|
||||
itemsPerPage: number;
|
||||
};
|
||||
query: {
|
||||
userId: number;
|
||||
dataType: DraftDataType;
|
||||
userId?: number;
|
||||
name?: string;
|
||||
isShared?: boolean;
|
||||
};
|
||||
@ -64,6 +64,27 @@ export async function draftPageQuery(
|
||||
return response.data.data.userDraftIscsDataPaging;
|
||||
}
|
||||
|
||||
export async function sharedDraftPageQuery(
|
||||
params: PagingQueryParams
|
||||
): Promise<PageDto<DraftIscsDataDto>> {
|
||||
const query = `
|
||||
query sharedDraftIscsDataPaging($paging: PageQueryDto, $query: SharedDraftIscsDataFilterDto) {
|
||||
sharedDraftIscsDataPaging(paging: $paging, query: $query) {
|
||||
total
|
||||
items {
|
||||
draftData {id name dataType userId defaultReleaseDataId createdAt updatedAt isShared defaultReleaseDataName}
|
||||
options {style}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const response = await api.post('', {
|
||||
query,
|
||||
variables: params,
|
||||
});
|
||||
return response.data.data.sharedDraftIscsDataPaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建草稿
|
||||
* @param params
|
||||
|
@ -2,8 +2,6 @@ import { api } from 'src/boot/axios';
|
||||
import { PageDto } from './ApiCommon';
|
||||
import { DraftDataType, IscsDataOptions } from './DraftApi';
|
||||
|
||||
const PublishUriBase = '/api/v1/publishedGi';
|
||||
|
||||
export interface PublishItem {
|
||||
id: number;
|
||||
name: string;
|
||||
@ -24,8 +22,8 @@ interface PagingQueryParams {
|
||||
itemsPerPage: number;
|
||||
};
|
||||
query: {
|
||||
userId: number;
|
||||
dataType: DraftDataType;
|
||||
userId?: number;
|
||||
name?: string;
|
||||
isPublished?: boolean;
|
||||
};
|
||||
@ -35,6 +33,25 @@ export interface PublishIscsDataDto {
|
||||
options: IscsDataOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 回退发布版本
|
||||
* @param id 发布地图ID
|
||||
*/
|
||||
export function setDefaultPublish(variables: {
|
||||
id: number;
|
||||
releaseDataId: number;
|
||||
}) {
|
||||
const mutation = `
|
||||
mutation setDefaultReleaseDataId($id: Int,$releaseDataId: Int) {
|
||||
setDefaultReleaseDataId(id: $id,releaseDataId: $releaseDataId){id}
|
||||
}
|
||||
`;
|
||||
return api.post('', {
|
||||
query: mutation,
|
||||
variables,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 草稿图发布
|
||||
* @param draftId 草稿id
|
||||
@ -106,54 +123,6 @@ export async function publishPageQuery(
|
||||
return response.data.data.releaseIscsDataPaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除发布图
|
||||
* @param id 发布id
|
||||
*/
|
||||
export function deletePublish(id: number) {
|
||||
return api.delete(`${PublishUriBase}/${id}`);
|
||||
}
|
||||
/**
|
||||
* 获取发布地图详细信息
|
||||
* @param id 发布地图id
|
||||
*/
|
||||
export async function getPublishMapInfoById(id: number): Promise<PublishItem> {
|
||||
const response = await api.get(`${PublishUriBase}/${id}`);
|
||||
return response.data;
|
||||
}
|
||||
/**
|
||||
* 获取发布地图详细信息
|
||||
* @param name 发布地图名称
|
||||
*/
|
||||
export async function getPublishMapInfoByName(params: {
|
||||
name: string;
|
||||
detail: boolean;
|
||||
}): Promise<PublishItem> {
|
||||
const response = await api.get(`${PublishUriBase}/name`, {
|
||||
params: params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已发布的线路地图数据
|
||||
*/
|
||||
export async function getPublishLineNet(): Promise<PublishItem> {
|
||||
const response = await api.get(`${PublishUriBase}/publish/lineNetwork/info`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发布地图详细信息
|
||||
* @param id 发布地图线路ID
|
||||
*/
|
||||
export async function getPublishMapInfoByLineId(
|
||||
lineId: string
|
||||
): Promise<PublishItem> {
|
||||
const response = await api.get(`${PublishUriBase}/${lineId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 另存到草稿
|
||||
* @param id 发布id
|
||||
@ -209,8 +178,16 @@ export async function getPublishHistoryById(variables: {
|
||||
* 回退发布版本
|
||||
* @param id 发布地图ID
|
||||
*/
|
||||
export function fallbackVersion(data: { mapId: number; versionId: number }) {
|
||||
return api.post(`${PublishUriBase}/fallbackVersion`, data);
|
||||
export function fallbackVersion(variables: { id: number; versionId: number }) {
|
||||
const mutation = `
|
||||
mutation updateReleaseDataUsedVersion($id: Int,$versionId: Int) {
|
||||
updateReleaseDataUsedVersion(id: $id,versionId: $versionId){id}
|
||||
}
|
||||
`;
|
||||
return api.post('', {
|
||||
query: mutation,
|
||||
variables,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,11 @@
|
||||
<q-page-container>
|
||||
<q-resize-observer @resize="onResize" />
|
||||
<q-scroll-area :style="{ height: scrollHeight + 'px' }">
|
||||
<router-view :sizeHeight="scrollHeight" :sizeWidth="scrollWidth" />
|
||||
<router-view
|
||||
:sizeHeight="scrollHeight"
|
||||
:sizeWidth="scrollWidth"
|
||||
:key="$route.name"
|
||||
/>
|
||||
</q-scroll-area>
|
||||
</q-page-container>
|
||||
<q-dialog v-model="showInfo">
|
||||
|
@ -22,7 +22,12 @@
|
||||
label="名称"
|
||||
></q-input>
|
||||
<q-btn flat round color="primary" icon="search" />
|
||||
<q-btn color="primary" label="新建" @click="createFormShow = true" />
|
||||
<q-btn
|
||||
color="primary"
|
||||
v-if="route.name == 'iscsDraft'"
|
||||
label="新建"
|
||||
@click="createFormShow = true"
|
||||
/>
|
||||
</template>
|
||||
<template v-slot:header-cell-name="props">
|
||||
<q-th :props="props">
|
||||
@ -82,6 +87,10 @@
|
||||
</q-list>
|
||||
</q-btn-dropdown>
|
||||
<q-btn
|
||||
v-if="
|
||||
route.name == 'iscsDraft' ||
|
||||
props.row.userId == authStore.userId
|
||||
"
|
||||
color="info"
|
||||
style="width: 80px"
|
||||
:disable="operateDisabled"
|
||||
@ -89,6 +98,10 @@
|
||||
@click="sharedDraftData(props.row)"
|
||||
/>
|
||||
<q-btn
|
||||
v-if="
|
||||
route.name == 'iscsDraft' ||
|
||||
props.row.userId == authStore.userId
|
||||
"
|
||||
color="red"
|
||||
:disable="operateDisabled"
|
||||
label="删除"
|
||||
@ -141,7 +154,11 @@
|
||||
>
|
||||
<q-card style="width: 300px">
|
||||
<q-card-section>
|
||||
<q-form ref="pubForm" @submit="publishGraphics" class="q-gutter-md">
|
||||
<q-form
|
||||
ref="pubForm"
|
||||
@submit="publishDraftGraphics"
|
||||
class="q-gutter-md"
|
||||
>
|
||||
<div class="text-h6">草稿发布</div>
|
||||
<q-input
|
||||
outlined
|
||||
@ -167,17 +184,57 @@
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="发布" type="submit" />
|
||||
<q-btn label="取消" v-close-popup />
|
||||
<q-btn label="取消" @click="canclePublish" />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<q-dialog
|
||||
v-model="publishInfoShow"
|
||||
persistent
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<q-card style="width: 1400px; max-width: 80vw">
|
||||
<q-card-section class="row items-center q-pb-none">
|
||||
<div class="text-h6">【{{ draftInfo.name }}】设置默认发布</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-table
|
||||
ref="publishTableRef"
|
||||
:rows="publishRows"
|
||||
:style="{ height: tableHeight * 0.6 + 'px' }"
|
||||
:columns="publishColumnDefs"
|
||||
v-model:pagination="publishPagination"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
:loading="publishLoading"
|
||||
@request="publishOnRequest"
|
||||
>
|
||||
<template v-slot:body-cell-operations="props">
|
||||
<q-td :props="props" style="width: 150px">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-btn
|
||||
v-if="props.row.id !== currentUsedPublishVersionId"
|
||||
color="warning"
|
||||
label="此版本设为默认发布"
|
||||
@click="setDefaultPublishFn(props.row)"
|
||||
/>
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
</q-table>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { ref, reactive, onMounted, computed, nextTick } from 'vue';
|
||||
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
||||
import {
|
||||
createDraft,
|
||||
@ -189,11 +246,20 @@ import {
|
||||
IscsStyle,
|
||||
sharedDraft,
|
||||
setDraftRename,
|
||||
sharedDraftPageQuery,
|
||||
PagingQueryParams,
|
||||
} from '../api/DraftApi';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { publishDraft, publishDraftToDefault } from 'src/api/PublishApi';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
publishDraft,
|
||||
publishDraftToDefault,
|
||||
PublishItem,
|
||||
publishPageQuery,
|
||||
setDefaultPublish,
|
||||
} from 'src/api/PublishApi';
|
||||
import { useAuthStore } from 'src/stores/auth-store';
|
||||
import { PageDto } from 'src/api/ApiCommon';
|
||||
|
||||
const $q = useQuasar();
|
||||
const router = useRouter();
|
||||
@ -204,17 +270,12 @@ const props = withDefaults(
|
||||
{ sizeHeight: 500 }
|
||||
);
|
||||
const authStore = useAuthStore();
|
||||
const route = useRoute();
|
||||
|
||||
const tableHeight = computed(() => {
|
||||
return props.sizeHeight - 32;
|
||||
});
|
||||
|
||||
const publishMenuConfig = [
|
||||
{ label: '新发布', click: prePublish },
|
||||
{ label: '发布到默认', click: publishToDefault },
|
||||
{ label: '设置默认发布', click: setDefaultPublish },
|
||||
];
|
||||
|
||||
onMounted(() => {
|
||||
tableRef.value.requestServerInteraction();
|
||||
});
|
||||
@ -284,19 +345,24 @@ async function onRequest(props: any) {
|
||||
const filter = props.filter;
|
||||
|
||||
loading.value = true;
|
||||
const variables = {
|
||||
const variables: PagingQueryParams = {
|
||||
paging: {
|
||||
page: page,
|
||||
itemsPerPage: rowsPerPage,
|
||||
},
|
||||
query: {
|
||||
userId: authStore.userId,
|
||||
dataType: DraftDataType.ISCS,
|
||||
name: filter.name,
|
||||
},
|
||||
};
|
||||
try {
|
||||
const response = await draftPageQuery(variables);
|
||||
let response: PageDto<DraftIscsDataDto>;
|
||||
if (route.name == 'iscsDraft') {
|
||||
variables.query.userId = authStore.userId;
|
||||
response = await draftPageQuery(variables);
|
||||
} else {
|
||||
response = await sharedDraftPageQuery(variables);
|
||||
}
|
||||
pagination.value.rowsNumber = response.total;
|
||||
pagination.value.page = page;
|
||||
pagination.value.rowsPerPage = rowsPerPage;
|
||||
@ -317,6 +383,7 @@ async function onRequest(props: any) {
|
||||
}
|
||||
}
|
||||
|
||||
//新建相关
|
||||
const createFormShow = ref(false);
|
||||
const createForm = reactive({
|
||||
draftName: '',
|
||||
@ -333,32 +400,44 @@ function onCreate() {
|
||||
myForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
operateDisabled.value = true;
|
||||
try {
|
||||
const variables = {
|
||||
input: {
|
||||
name: createForm.draftName,
|
||||
options: { style: createForm.style },
|
||||
userId: authStore.userId,
|
||||
},
|
||||
};
|
||||
await createDraft(variables);
|
||||
const variables = {
|
||||
input: {
|
||||
name: createForm.draftName,
|
||||
options: { style: createForm.style },
|
||||
userId: authStore.userId,
|
||||
},
|
||||
};
|
||||
const res = await createDraft(variables);
|
||||
operateDisabled.value = false;
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
createFormShow.value = false;
|
||||
createForm.draftName = '';
|
||||
createForm.style = IscsStyle.DA_SHI_ZHI_NENG;
|
||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
} finally {
|
||||
operateDisabled.value = false;
|
||||
tableRef.value.requestServerInteraction();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//编辑
|
||||
function goToPath(row: DraftItem) {
|
||||
let path = `/iscsPainting/${row.id}`;
|
||||
const iscsStyle = allRequestData.find((item) => item.draftData.id == row.id)
|
||||
.options.style;
|
||||
router.push({ path: path, query: { iscsStyle } });
|
||||
}
|
||||
|
||||
//发布相关
|
||||
const publishMenuConfig = [
|
||||
{ label: '新发布', click: newPublish },
|
||||
{ label: '发布到默认', click: publishToDefault },
|
||||
{ label: '设置默认发布', click: showpublishFn },
|
||||
];
|
||||
const pubForm = ref<QForm | null>(null);
|
||||
const publishFormShow = ref(false);
|
||||
const publishForm = reactive({
|
||||
@ -367,7 +446,7 @@ const publishForm = reactive({
|
||||
pubName: '',
|
||||
note: '',
|
||||
});
|
||||
function prePublish(row: DraftItem) {
|
||||
function newPublish(row: DraftItem) {
|
||||
publishFormShow.value = true;
|
||||
publishForm.id = row.id + '';
|
||||
publishForm.draftName = row.name;
|
||||
@ -384,14 +463,11 @@ function publishToDefault(row: DraftItem) {
|
||||
});
|
||||
} else {
|
||||
publishNameDisable.value = true;
|
||||
prePublish(row);
|
||||
newPublish(row);
|
||||
}
|
||||
}
|
||||
function setDefaultPublish(row: DraftItem) {
|
||||
console.log(row);
|
||||
}
|
||||
|
||||
function publishGraphics() {
|
||||
function publishDraftGraphics() {
|
||||
pubForm.value?.validate().then((res) => {
|
||||
if (res) {
|
||||
if (!publishNameDisable.value) {
|
||||
@ -400,87 +476,92 @@ function publishGraphics() {
|
||||
name: publishForm.pubName,
|
||||
description: publishForm.note,
|
||||
};
|
||||
publishDraft(params)
|
||||
.then(() => {
|
||||
publishDraft(params).then((response) => {
|
||||
if (response.data?.errors && response.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: response.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
publishNameDisable.value = false;
|
||||
publishFormShow.value = false;
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: '发布成功',
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const params: { draftId: number; description: string } = {
|
||||
draftId: +publishForm.id,
|
||||
description: publishForm.note,
|
||||
};
|
||||
publishDraftToDefault(params)
|
||||
.then(() => {
|
||||
publishDraftToDefault(params).then((response) => {
|
||||
if (response.data?.errors && response.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: response.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
publishNameDisable.value = false;
|
||||
publishFormShow.value = false;
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: '发布成功',
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteData(row: DraftItem) {
|
||||
function canclePublish() {
|
||||
publishNameDisable.value = false;
|
||||
publishFormShow.value = false;
|
||||
}
|
||||
|
||||
//共享
|
||||
async function sharedDraftData(row: DraftItem) {
|
||||
operateDisabled.value = true;
|
||||
const res = await sharedDraft(row.id, !row.isShared);
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
operateDisabled.value = false;
|
||||
tableRef.value.requestServerInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
//删除
|
||||
function deleteData(row: DraftItem) {
|
||||
operateDisabled.value = true;
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确认删除草稿图 "${row.name}" 吗?`,
|
||||
cancel: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await deleteDraft(row.id);
|
||||
tableRef.value.requestServerInteraction();
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
}
|
||||
.onOk(() => {
|
||||
deleteDraft(row.id).then((res) => {
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
tableRef.value.requestServerInteraction();
|
||||
}
|
||||
});
|
||||
})
|
||||
.onDismiss(() => {
|
||||
operateDisabled.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
async function sharedDraftData(row: DraftItem) {
|
||||
operateDisabled.value = true;
|
||||
try {
|
||||
await sharedDraft(row.id, !row.isShared);
|
||||
operateDisabled.value = false;
|
||||
tableRef.value.requestServerInteraction();
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//编辑草稿图名称相关
|
||||
const errorCalories = ref(false);
|
||||
const errorMessageCalories = ref('');
|
||||
function caloriesRangeValidation(val?: string) {
|
||||
@ -497,26 +578,147 @@ function caloriesRangeValidation(val?: string) {
|
||||
}
|
||||
|
||||
async function saveRowDataName(row: DraftItem) {
|
||||
const params = {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
};
|
||||
const res = await setDraftRename(params);
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
tableRef.value.requestServerInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
//设置默认发布相关
|
||||
const publishInfoShow = ref(false);
|
||||
const draftInfo = ref<DraftItem>({
|
||||
id: 0,
|
||||
name: '',
|
||||
dataType: DraftDataType.ISCS,
|
||||
options: '',
|
||||
data: '',
|
||||
userId: 0,
|
||||
defaultReleaseDataId: 0,
|
||||
isShared: false,
|
||||
createdAt: '',
|
||||
updatedAt: '',
|
||||
defaultReleaseDataName: '',
|
||||
});
|
||||
|
||||
const publishColumnDefs: QTableColumn[] = [
|
||||
{
|
||||
name: 'name',
|
||||
label: '名称',
|
||||
field: 'name',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: '描述',
|
||||
field: 'description',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'userId',
|
||||
label: '发布人',
|
||||
field: 'userId',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'createdAt',
|
||||
label: '发布时间',
|
||||
field: (row) => new Date(row.createdAt).toLocaleString(),
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
|
||||
];
|
||||
|
||||
const publishTableRef = ref();
|
||||
const publishRows = reactive<PublishItem[]>([]);
|
||||
const publishLoading = ref(false);
|
||||
const publishPagination = ref({
|
||||
sortBy: 'desc',
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
rowsNumber: 10,
|
||||
});
|
||||
|
||||
async function publishOnRequest(props: any) {
|
||||
publishLoading.value = true;
|
||||
const { page, rowsPerPage } = props.pagination;
|
||||
const variables = {
|
||||
page: {
|
||||
page: page,
|
||||
itemsPerPage: rowsPerPage,
|
||||
},
|
||||
query: {
|
||||
dataType: DraftDataType.ISCS,
|
||||
name: filter.name,
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const params = {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
};
|
||||
await setDraftRename(params);
|
||||
const response = await publishPageQuery(variables);
|
||||
publishPagination.value.rowsNumber = response.total;
|
||||
publishPagination.value.page = page;
|
||||
publishPagination.value.rowsPerPage = rowsPerPage;
|
||||
publishRows.splice(
|
||||
0,
|
||||
publishRows.length,
|
||||
...(response.items.map((item) => item.releaseData) as [])
|
||||
);
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
tableRef.value.requestServerInteraction();
|
||||
} finally {
|
||||
publishLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function goToPath(row: DraftItem) {
|
||||
let path = `/iscsPainting/${row.id}`;
|
||||
const iscsStyle = allRequestData.find((item) => item.draftData.id == row.id)
|
||||
.options.style;
|
||||
router.push({ path: path, query: { iscsStyle } });
|
||||
const currentUsedPublishVersionId = ref();
|
||||
function showpublishFn(row: DraftItem) {
|
||||
currentUsedPublishVersionId.value = row.defaultReleaseDataId;
|
||||
draftInfo.value = row;
|
||||
publishInfoShow.value = true;
|
||||
nextTick(() => {
|
||||
publishTableRef.value.requestServerInteraction();
|
||||
});
|
||||
}
|
||||
|
||||
function setDefaultPublishFn(row: PublishItem) {
|
||||
if (!draftInfo.value.id || !row.id) return;
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确定把【${draftInfo.value.name}】的默认发布版本设为【${row.name}】吗?`,
|
||||
cancel: true,
|
||||
}).onOk(() => {
|
||||
setDefaultPublish({ id: draftInfo.value.id, releaseDataId: row.id }).then(
|
||||
(res) => {
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: '设置默认发布成功!',
|
||||
});
|
||||
tableRef.value.requestServerInteraction();
|
||||
publishInfoShow.value = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
@ -61,7 +61,7 @@
|
||||
</template>
|
||||
|
||||
<template v-slot:body-cell-operations="props" v-if="!isProject">
|
||||
<q-td :props="props" style="width: 400px">
|
||||
<q-td :props="props" style="width: 320px">
|
||||
<div class="q-gutter-sm row justify-start">
|
||||
<q-btn
|
||||
:color="!props.row.isPublished ? 'primary' : 'amber'"
|
||||
@ -78,12 +78,6 @@
|
||||
label="发布历史"
|
||||
@click="showHistoryFn(props.row)"
|
||||
/>
|
||||
<q-btn
|
||||
color="red"
|
||||
:disable="operateDisabled"
|
||||
label="删除"
|
||||
@click="deleteData(props.row)"
|
||||
/>
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
@ -115,7 +109,7 @@
|
||||
<q-td :props="props" style="width: 150px">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-btn
|
||||
v-if="props.row.current === false"
|
||||
v-if="props.row.id !== currentUsedVersionId"
|
||||
color="warning"
|
||||
label="回退到此版本"
|
||||
@click="backVersion(props.row)"
|
||||
@ -135,7 +129,6 @@ import { ref, reactive, onMounted, computed, watch } from 'vue';
|
||||
import { useQuasar, type QTableColumn } from 'quasar';
|
||||
import {
|
||||
publishPageQuery,
|
||||
deletePublish,
|
||||
saveToDraft,
|
||||
PublishItem,
|
||||
setPublishRename,
|
||||
@ -205,7 +198,6 @@ const columnDefs: QTableColumn[] = [
|
||||
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
|
||||
];
|
||||
|
||||
const operateDisabled = ref(false);
|
||||
const tableRef = ref();
|
||||
const rows = reactive([]);
|
||||
const filter = reactive({
|
||||
@ -258,57 +250,79 @@ async function onRequest(props: any) {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteData(row: PublishItem) {
|
||||
operateDisabled.value = true;
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确认删除发布图 "${row.name}" 吗?`,
|
||||
cancel: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await deletePublish(row.id);
|
||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
}
|
||||
})
|
||||
.onDismiss(() => {
|
||||
operateDisabled.value = false;
|
||||
//上下架
|
||||
function dataReleaseFn(row: PublishItem) {
|
||||
if (row.isPublished) {
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确定下架发布数据【${row.name}】吗?`,
|
||||
cancel: true,
|
||||
}).onOk(() => {
|
||||
setPublishRelease({ id: row.id, isPublished: !row.isPublished }).then(
|
||||
(res) => {
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
tableRef.value.requestServerInteraction();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
setPublishRelease({ id: row.id, isPublished: !row.isPublished }).then(
|
||||
(res) => {
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
tableRef.value.requestServerInteraction();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//另存草稿
|
||||
function saveToDraftFn(row: PublishItem) {
|
||||
saveToDraft({
|
||||
versionId: row.usedVersionId,
|
||||
userId: row.userId,
|
||||
})
|
||||
.then((res) => {
|
||||
}).then((res) => {
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
const draftName =
|
||||
res.data.data.createDraftDataFromReleaseDataVersion.name;
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: `另存草稿成功且草稿图名字为${draftName}`,
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 项目管理相关
|
||||
const emit = defineEmits(['selectsed']);
|
||||
const selected = ref<PublishItem[] | []>([]);
|
||||
watch(
|
||||
() => selected.value,
|
||||
(val) => {
|
||||
if (val != props.selects) {
|
||||
emit('selectsed', val);
|
||||
}
|
||||
}
|
||||
);
|
||||
const isProject = computed(() => {
|
||||
// 项目管理
|
||||
return route.path.includes('dataManage/project');
|
||||
});
|
||||
const selected = ref<PublishItem[] | []>([]);
|
||||
function getSelectedString() {
|
||||
const nameArr = selected.value.map((item) => {
|
||||
return item.name;
|
||||
@ -325,16 +339,7 @@ if (isProject.value) {
|
||||
}
|
||||
}
|
||||
|
||||
const emit = defineEmits(['selectsed']);
|
||||
watch(
|
||||
() => selected.value,
|
||||
(val) => {
|
||||
if (val != props.selects) {
|
||||
emit('selectsed', val);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//修改发布图名字
|
||||
const errorCalories = ref(false);
|
||||
const errorMessageCalories = ref('');
|
||||
function caloriesRangeValidation(val?: string) {
|
||||
@ -351,22 +356,22 @@ function caloriesRangeValidation(val?: string) {
|
||||
}
|
||||
|
||||
async function saveRowDataName(row: PublishItem) {
|
||||
try {
|
||||
const params = {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
};
|
||||
await setPublishRename(params);
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
const params = {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
};
|
||||
const res = await setPublishRename(params);
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
tableRef.value.requestServerInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
//发布历史相关
|
||||
const historyInfoShow = ref(false);
|
||||
const historyInfo = ref<PublishItem>({
|
||||
id: 0,
|
||||
@ -393,13 +398,7 @@ const historyColumnDefs: QTableColumn[] = [
|
||||
{
|
||||
name: 'createdAt',
|
||||
label: '发布时间',
|
||||
field: 'createdAt',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'releaseDataId',
|
||||
label: '版本',
|
||||
field: 'releaseDataId',
|
||||
field: (row) => new Date(row.createdAt).toLocaleString(),
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
@ -433,7 +432,6 @@ async function historyOnRequest(props: any) {
|
||||
itemsPerPage: rowsPerPage,
|
||||
},
|
||||
};
|
||||
console.log(page, rowsPerPage);
|
||||
|
||||
try {
|
||||
const response = await getPublishHistoryById(variables);
|
||||
@ -452,7 +450,9 @@ async function historyOnRequest(props: any) {
|
||||
}
|
||||
}
|
||||
|
||||
const currentUsedVersionId = ref();
|
||||
function showHistoryFn(row: PublishItem) {
|
||||
currentUsedVersionId.value = row.usedVersionId;
|
||||
historyInfo.value = row;
|
||||
historyInfoShow.value = true;
|
||||
nextTick(() => {
|
||||
@ -460,63 +460,30 @@ function showHistoryFn(row: PublishItem) {
|
||||
});
|
||||
}
|
||||
|
||||
function dataReleaseFn(row: PublishItem) {
|
||||
if (row.isPublished) {
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确定下架发布数据【${row.name}】吗?`,
|
||||
cancel: true,
|
||||
}).onOk(() => {
|
||||
setPublishRelease({ id: row.id, isPublished: !row.isPublished })
|
||||
.then(() => {
|
||||
tableRef.value.requestServerInteraction();
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
setPublishRelease({ id: row.id, isPublished: !row.isPublished })
|
||||
.then(() => {
|
||||
tableRef.value.requestServerInteraction();
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function backVersion(row: PublishHistoryItem) {
|
||||
if (!historyInfo.value.id || !row.id) return;
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确定把【${historyInfo.value.name}】回退到【${row.releaseDataId}】版本吗?`,
|
||||
message: `确定把【${historyInfo.value.name}】回退到【${row.description}】版本吗?`,
|
||||
cancel: true,
|
||||
}).onOk(() => {
|
||||
fallbackVersion({ mapId: historyInfo.value.id, versionId: row.id })
|
||||
.then(() => {
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: '回退版本成功!',
|
||||
});
|
||||
tableRef.value.requestServerInteraction();
|
||||
historyInfoShow.value = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
fallbackVersion({ id: historyInfo.value.id, versionId: row.id }).then(
|
||||
(res) => {
|
||||
if (res.data?.errors && res.data?.errors.length) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: res.data.errors[0].message,
|
||||
});
|
||||
} else {
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: '回退版本成功!',
|
||||
});
|
||||
tableRef.value.requestServerInteraction();
|
||||
historyInfoShow.value = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
@ -35,6 +35,15 @@ const routes: RouteRecordRaw[] = [
|
||||
icon: 'app_registration',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'iscsSharedDraft',
|
||||
name: 'iscsSharedDraft',
|
||||
component: () => import('pages/IscsDraftManage.vue'),
|
||||
meta: {
|
||||
label: 'iscs分享草稿管理',
|
||||
icon: 'app_registration',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'iscsPublish',
|
||||
name: 'iscsPublish',
|
||||
|
Loading…
Reference in New Issue
Block a user