草稿发布调整+GraphQL的错误信息也在返回的body里面

This commit is contained in:
joylink_zhaoerwei 2024-09-23 14:15:27 +08:00
parent 469222e46f
commit a7f6fc945d
6 changed files with 454 additions and 274 deletions

View File

@ -23,14 +23,14 @@ export interface DraftItem {
defaultReleaseDataName: string; defaultReleaseDataName: string;
} }
interface PagingQueryParams { export interface PagingQueryParams {
paging: { paging: {
page: number; page: number;
itemsPerPage: number; itemsPerPage: number;
}; };
query: { query: {
userId: number;
dataType: DraftDataType; dataType: DraftDataType;
userId?: number;
name?: string; name?: string;
isShared?: boolean; isShared?: boolean;
}; };
@ -64,6 +64,27 @@ export async function draftPageQuery(
return response.data.data.userDraftIscsDataPaging; 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 * @param params

View File

@ -2,8 +2,6 @@ import { api } from 'src/boot/axios';
import { PageDto } from './ApiCommon'; import { PageDto } from './ApiCommon';
import { DraftDataType, IscsDataOptions } from './DraftApi'; import { DraftDataType, IscsDataOptions } from './DraftApi';
const PublishUriBase = '/api/v1/publishedGi';
export interface PublishItem { export interface PublishItem {
id: number; id: number;
name: string; name: string;
@ -24,8 +22,8 @@ interface PagingQueryParams {
itemsPerPage: number; itemsPerPage: number;
}; };
query: { query: {
userId: number;
dataType: DraftDataType; dataType: DraftDataType;
userId?: number;
name?: string; name?: string;
isPublished?: boolean; isPublished?: boolean;
}; };
@ -35,6 +33,25 @@ export interface PublishIscsDataDto {
options: IscsDataOptions; 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 * @param draftId 稿id
@ -106,54 +123,6 @@ export async function publishPageQuery(
return response.data.data.releaseIscsDataPaging; 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 * @param id id
@ -209,8 +178,16 @@ export async function getPublishHistoryById(variables: {
* 退 * 退
* @param id ID * @param id ID
*/ */
export function fallbackVersion(data: { mapId: number; versionId: number }) { export function fallbackVersion(variables: { id: number; versionId: number }) {
return api.post(`${PublishUriBase}/fallbackVersion`, data); const mutation = `
mutation updateReleaseDataUsedVersion($id: Int,$versionId: Int) {
updateReleaseDataUsedVersion(id: $id,versionId: $versionId){id}
}
`;
return api.post('', {
query: mutation,
variables,
});
} }
/** /**

View File

@ -52,7 +52,11 @@
<q-page-container> <q-page-container>
<q-resize-observer @resize="onResize" /> <q-resize-observer @resize="onResize" />
<q-scroll-area :style="{ height: scrollHeight + 'px' }"> <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-scroll-area>
</q-page-container> </q-page-container>
<q-dialog v-model="showInfo"> <q-dialog v-model="showInfo">

View File

@ -22,7 +22,12 @@
label="名称" label="名称"
></q-input> ></q-input>
<q-btn flat round color="primary" icon="search" /> <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>
<template v-slot:header-cell-name="props"> <template v-slot:header-cell-name="props">
<q-th :props="props"> <q-th :props="props">
@ -82,6 +87,10 @@
</q-list> </q-list>
</q-btn-dropdown> </q-btn-dropdown>
<q-btn <q-btn
v-if="
route.name == 'iscsDraft' ||
props.row.userId == authStore.userId
"
color="info" color="info"
style="width: 80px" style="width: 80px"
:disable="operateDisabled" :disable="operateDisabled"
@ -89,6 +98,10 @@
@click="sharedDraftData(props.row)" @click="sharedDraftData(props.row)"
/> />
<q-btn <q-btn
v-if="
route.name == 'iscsDraft' ||
props.row.userId == authStore.userId
"
color="red" color="red"
:disable="operateDisabled" :disable="operateDisabled"
label="删除" label="删除"
@ -141,7 +154,11 @@
> >
<q-card style="width: 300px"> <q-card style="width: 300px">
<q-card-section> <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> <div class="text-h6">草稿发布</div>
<q-input <q-input
outlined outlined
@ -167,17 +184,57 @@
<q-card-actions align="right"> <q-card-actions align="right">
<q-btn color="primary" label="发布" type="submit" /> <q-btn color="primary" label="发布" type="submit" />
<q-btn label="取消" v-close-popup /> <q-btn label="取消" @click="canclePublish" />
</q-card-actions> </q-card-actions>
</q-form> </q-form>
</q-card-section> </q-card-section>
</q-card> </q-card>
</q-dialog> </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> </div>
</template> </template>
<script setup lang="ts"> <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 { useQuasar, type QTableColumn, QForm } from 'quasar';
import { import {
createDraft, createDraft,
@ -189,11 +246,20 @@ import {
IscsStyle, IscsStyle,
sharedDraft, sharedDraft,
setDraftRename, setDraftRename,
sharedDraftPageQuery,
PagingQueryParams,
} from '../api/DraftApi'; } from '../api/DraftApi';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { publishDraft, publishDraftToDefault } from 'src/api/PublishApi'; import {
publishDraft,
publishDraftToDefault,
PublishItem,
publishPageQuery,
setDefaultPublish,
} from 'src/api/PublishApi';
import { useAuthStore } from 'src/stores/auth-store'; import { useAuthStore } from 'src/stores/auth-store';
import { PageDto } from 'src/api/ApiCommon';
const $q = useQuasar(); const $q = useQuasar();
const router = useRouter(); const router = useRouter();
@ -204,17 +270,12 @@ const props = withDefaults(
{ sizeHeight: 500 } { sizeHeight: 500 }
); );
const authStore = useAuthStore(); const authStore = useAuthStore();
const route = useRoute();
const tableHeight = computed(() => { const tableHeight = computed(() => {
return props.sizeHeight - 32; return props.sizeHeight - 32;
}); });
const publishMenuConfig = [
{ label: '新发布', click: prePublish },
{ label: '发布到默认', click: publishToDefault },
{ label: '设置默认发布', click: setDefaultPublish },
];
onMounted(() => { onMounted(() => {
tableRef.value.requestServerInteraction(); tableRef.value.requestServerInteraction();
}); });
@ -284,19 +345,24 @@ async function onRequest(props: any) {
const filter = props.filter; const filter = props.filter;
loading.value = true; loading.value = true;
const variables = { const variables: PagingQueryParams = {
paging: { paging: {
page: page, page: page,
itemsPerPage: rowsPerPage, itemsPerPage: rowsPerPage,
}, },
query: { query: {
userId: authStore.userId,
dataType: DraftDataType.ISCS, dataType: DraftDataType.ISCS,
name: filter.name, name: filter.name,
}, },
}; };
try { 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.rowsNumber = response.total;
pagination.value.page = page; pagination.value.page = page;
pagination.value.rowsPerPage = rowsPerPage; pagination.value.rowsPerPage = rowsPerPage;
@ -317,6 +383,7 @@ async function onRequest(props: any) {
} }
} }
//
const createFormShow = ref(false); const createFormShow = ref(false);
const createForm = reactive({ const createForm = reactive({
draftName: '', draftName: '',
@ -333,32 +400,44 @@ function onCreate() {
myForm.value?.validate().then(async (res) => { myForm.value?.validate().then(async (res) => {
if (res) { if (res) {
operateDisabled.value = true; operateDisabled.value = true;
try { const variables = {
const variables = { input: {
input: { name: createForm.draftName,
name: createForm.draftName, options: { style: createForm.style },
options: { style: createForm.style }, userId: authStore.userId,
userId: authStore.userId, },
}, };
}; const res = await createDraft(variables);
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; createFormShow.value = false;
createForm.draftName = ''; createForm.draftName = '';
createForm.style = IscsStyle.DA_SHI_ZHI_NENG; createForm.style = IscsStyle.DA_SHI_ZHI_NENG;
tableRef.value.requestServerInteraction(); // tableRef.value.requestServerInteraction();
} catch (err) {
const error = err as ApiError;
$q.notify({
type: 'negative',
message: error.title,
});
} finally {
operateDisabled.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 publishMenuConfig = [
{ label: '新发布', click: newPublish },
{ label: '发布到默认', click: publishToDefault },
{ label: '设置默认发布', click: showpublishFn },
];
const pubForm = ref<QForm | null>(null); const pubForm = ref<QForm | null>(null);
const publishFormShow = ref(false); const publishFormShow = ref(false);
const publishForm = reactive({ const publishForm = reactive({
@ -367,7 +446,7 @@ const publishForm = reactive({
pubName: '', pubName: '',
note: '', note: '',
}); });
function prePublish(row: DraftItem) { function newPublish(row: DraftItem) {
publishFormShow.value = true; publishFormShow.value = true;
publishForm.id = row.id + ''; publishForm.id = row.id + '';
publishForm.draftName = row.name; publishForm.draftName = row.name;
@ -384,14 +463,11 @@ function publishToDefault(row: DraftItem) {
}); });
} else { } else {
publishNameDisable.value = true; publishNameDisable.value = true;
prePublish(row); newPublish(row);
} }
} }
function setDefaultPublish(row: DraftItem) {
console.log(row);
}
function publishGraphics() { function publishDraftGraphics() {
pubForm.value?.validate().then((res) => { pubForm.value?.validate().then((res) => {
if (res) { if (res) {
if (!publishNameDisable.value) { if (!publishNameDisable.value) {
@ -400,87 +476,92 @@ function publishGraphics() {
name: publishForm.pubName, name: publishForm.pubName,
description: publishForm.note, description: publishForm.note,
}; };
publishDraft(params) publishDraft(params).then((response) => {
.then(() => { if (response.data?.errors && response.data?.errors.length) {
$q.notify({
type: 'negative',
message: response.data.errors[0].message,
});
} else {
publishNameDisable.value = false; publishNameDisable.value = false;
publishFormShow.value = false; publishFormShow.value = false;
$q.notify({ $q.notify({
type: 'positive', type: 'positive',
message: '发布成功', message: '发布成功',
}); });
}) }
.catch((err) => { });
const error = err as ApiError;
$q.notify({
type: 'negative',
message: error.title,
});
});
} else { } else {
const params: { draftId: number; description: string } = { const params: { draftId: number; description: string } = {
draftId: +publishForm.id, draftId: +publishForm.id,
description: publishForm.note, description: publishForm.note,
}; };
publishDraftToDefault(params) publishDraftToDefault(params).then((response) => {
.then(() => { if (response.data?.errors && response.data?.errors.length) {
$q.notify({
type: 'negative',
message: response.data.errors[0].message,
});
} else {
publishNameDisable.value = false; publishNameDisable.value = false;
publishFormShow.value = false; publishFormShow.value = false;
$q.notify({ $q.notify({
type: 'positive', type: 'positive',
message: '发布成功', 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; operateDisabled.value = true;
$q.dialog({ $q.dialog({
title: '确认', title: '确认',
message: `确认删除草稿图 "${row.name}" 吗?`, message: `确认删除草稿图 "${row.name}" 吗?`,
cancel: true, cancel: true,
}) })
.onOk(async () => { .onOk(() => {
try { deleteDraft(row.id).then((res) => {
await deleteDraft(row.id); if (res.data?.errors && res.data?.errors.length) {
tableRef.value.requestServerInteraction(); $q.notify({
} catch (err) { type: 'negative',
const error = err as ApiError; message: res.data.errors[0].message,
$q.notify({ });
type: 'negative', } else {
message: error.title, tableRef.value.requestServerInteraction();
}); }
} });
}) })
.onDismiss(() => { .onDismiss(() => {
operateDisabled.value = false; 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 errorCalories = ref(false);
const errorMessageCalories = ref(''); const errorMessageCalories = ref('');
function caloriesRangeValidation(val?: string) { function caloriesRangeValidation(val?: string) {
@ -497,26 +578,147 @@ function caloriesRangeValidation(val?: string) {
} }
async function saveRowDataName(row: DraftItem) { 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 { try {
const params = { const response = await publishPageQuery(variables);
id: row.id, publishPagination.value.rowsNumber = response.total;
name: row.name, publishPagination.value.page = page;
}; publishPagination.value.rowsPerPage = rowsPerPage;
await setDraftRename(params); publishRows.splice(
0,
publishRows.length,
...(response.items.map((item) => item.releaseData) as [])
);
} catch (err) { } catch (err) {
const error = err as ApiError; const error = err as ApiError;
$q.notify({ $q.notify({
type: 'negative', type: 'negative',
message: error.title, message: error.title,
}); });
tableRef.value.requestServerInteraction(); } finally {
publishLoading.value = false;
} }
} }
function goToPath(row: DraftItem) { const currentUsedPublishVersionId = ref();
let path = `/iscsPainting/${row.id}`; function showpublishFn(row: DraftItem) {
const iscsStyle = allRequestData.find((item) => item.draftData.id == row.id) currentUsedPublishVersionId.value = row.defaultReleaseDataId;
.options.style; draftInfo.value = row;
router.push({ path: path, query: { iscsStyle } }); 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> </script>

View File

@ -61,7 +61,7 @@
</template> </template>
<template v-slot:body-cell-operations="props" v-if="!isProject"> <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"> <div class="q-gutter-sm row justify-start">
<q-btn <q-btn
:color="!props.row.isPublished ? 'primary' : 'amber'" :color="!props.row.isPublished ? 'primary' : 'amber'"
@ -78,12 +78,6 @@
label="发布历史" label="发布历史"
@click="showHistoryFn(props.row)" @click="showHistoryFn(props.row)"
/> />
<q-btn
color="red"
:disable="operateDisabled"
label="删除"
@click="deleteData(props.row)"
/>
</div> </div>
</q-td> </q-td>
</template> </template>
@ -115,7 +109,7 @@
<q-td :props="props" style="width: 150px"> <q-td :props="props" style="width: 150px">
<div class="q-gutter-sm row justify-center"> <div class="q-gutter-sm row justify-center">
<q-btn <q-btn
v-if="props.row.current === false" v-if="props.row.id !== currentUsedVersionId"
color="warning" color="warning"
label="回退到此版本" label="回退到此版本"
@click="backVersion(props.row)" @click="backVersion(props.row)"
@ -135,7 +129,6 @@ import { ref, reactive, onMounted, computed, watch } from 'vue';
import { useQuasar, type QTableColumn } from 'quasar'; import { useQuasar, type QTableColumn } from 'quasar';
import { import {
publishPageQuery, publishPageQuery,
deletePublish,
saveToDraft, saveToDraft,
PublishItem, PublishItem,
setPublishRename, setPublishRename,
@ -205,7 +198,6 @@ const columnDefs: QTableColumn[] = [
{ name: 'operations', label: '操作', field: 'operations', align: 'center' }, { name: 'operations', label: '操作', field: 'operations', align: 'center' },
]; ];
const operateDisabled = ref(false);
const tableRef = ref(); const tableRef = ref();
const rows = reactive([]); const rows = reactive([]);
const filter = reactive({ const filter = reactive({
@ -258,57 +250,79 @@ async function onRequest(props: any) {
} }
} }
async function deleteData(row: PublishItem) { //
operateDisabled.value = true; function dataReleaseFn(row: PublishItem) {
$q.dialog({ if (row.isPublished) {
title: '确认', $q.dialog({
message: `确认删除发布图 "${row.name}" 吗?`, title: '确认',
cancel: true, message: `确定下架发布数据【${row.name}】吗?`,
}) cancel: true,
.onOk(async () => { }).onOk(() => {
try { setPublishRelease({ id: row.id, isPublished: !row.isPublished }).then(
await deletePublish(row.id); (res) => {
tableRef.value.requestServerInteraction(); // if (res.data?.errors && res.data?.errors.length) {
} catch (err) { $q.notify({
const error = err as ApiError; type: 'negative',
$q.notify({ message: res.data.errors[0].message,
type: 'negative', });
message: error.title, } else {
}); tableRef.value.requestServerInteraction();
} }
}) }
.onDismiss(() => { );
operateDisabled.value = false;
}); });
} 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) { function saveToDraftFn(row: PublishItem) {
saveToDraft({ saveToDraft({
versionId: row.usedVersionId, versionId: row.usedVersionId,
userId: row.userId, 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 = const draftName =
res.data.data.createDraftDataFromReleaseDataVersion.name; res.data.data.createDraftDataFromReleaseDataVersion.name;
$q.notify({ $q.notify({
type: 'positive', type: 'positive',
message: `另存草稿成功且草稿图名字为${draftName}`, 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(() => { const isProject = computed(() => {
//
return route.path.includes('dataManage/project'); return route.path.includes('dataManage/project');
}); });
const selected = ref<PublishItem[] | []>([]);
function getSelectedString() { function getSelectedString() {
const nameArr = selected.value.map((item) => { const nameArr = selected.value.map((item) => {
return item.name; 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 errorCalories = ref(false);
const errorMessageCalories = ref(''); const errorMessageCalories = ref('');
function caloriesRangeValidation(val?: string) { function caloriesRangeValidation(val?: string) {
@ -351,22 +356,22 @@ function caloriesRangeValidation(val?: string) {
} }
async function saveRowDataName(row: PublishItem) { async function saveRowDataName(row: PublishItem) {
try { const params = {
const params = { id: row.id,
id: row.id, name: row.name,
name: row.name, };
}; const res = await setPublishRename(params);
await setPublishRename(params); if (res.data?.errors && res.data?.errors.length) {
} catch (err) {
const error = err as ApiError;
$q.notify({ $q.notify({
type: 'negative', type: 'negative',
message: error.title, message: res.data.errors[0].message,
}); });
} else {
tableRef.value.requestServerInteraction(); tableRef.value.requestServerInteraction();
} }
} }
//
const historyInfoShow = ref(false); const historyInfoShow = ref(false);
const historyInfo = ref<PublishItem>({ const historyInfo = ref<PublishItem>({
id: 0, id: 0,
@ -393,13 +398,7 @@ const historyColumnDefs: QTableColumn[] = [
{ {
name: 'createdAt', name: 'createdAt',
label: '发布时间', label: '发布时间',
field: 'createdAt', field: (row) => new Date(row.createdAt).toLocaleString(),
align: 'center',
},
{
name: 'releaseDataId',
label: '版本',
field: 'releaseDataId',
align: 'center', align: 'center',
}, },
{ {
@ -433,7 +432,6 @@ async function historyOnRequest(props: any) {
itemsPerPage: rowsPerPage, itemsPerPage: rowsPerPage,
}, },
}; };
console.log(page, rowsPerPage);
try { try {
const response = await getPublishHistoryById(variables); const response = await getPublishHistoryById(variables);
@ -452,7 +450,9 @@ async function historyOnRequest(props: any) {
} }
} }
const currentUsedVersionId = ref();
function showHistoryFn(row: PublishItem) { function showHistoryFn(row: PublishItem) {
currentUsedVersionId.value = row.usedVersionId;
historyInfo.value = row; historyInfo.value = row;
historyInfoShow.value = true; historyInfoShow.value = true;
nextTick(() => { 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) { function backVersion(row: PublishHistoryItem) {
if (!historyInfo.value.id || !row.id) return; if (!historyInfo.value.id || !row.id) return;
$q.dialog({ $q.dialog({
title: '确认', title: '确认',
message: `确定把【${historyInfo.value.name}】回退到【${row.releaseDataId}】版本吗?`, message: `确定把【${historyInfo.value.name}】回退到【${row.description}】版本吗?`,
cancel: true, cancel: true,
}).onOk(() => { }).onOk(() => {
fallbackVersion({ mapId: historyInfo.value.id, versionId: row.id }) fallbackVersion({ id: historyInfo.value.id, versionId: row.id }).then(
.then(() => { (res) => {
$q.notify({ if (res.data?.errors && res.data?.errors.length) {
type: 'positive', $q.notify({
message: '回退版本成功!', type: 'negative',
}); message: res.data.errors[0].message,
tableRef.value.requestServerInteraction(); });
historyInfoShow.value = false; } else {
}) $q.notify({
.catch((err) => { type: 'positive',
const error = err as ApiError; message: '回退版本成功!',
$q.notify({ });
type: 'negative', tableRef.value.requestServerInteraction();
message: error.title, historyInfoShow.value = false;
}); }
}); }
);
}); });
} }
</script> </script>

View File

@ -35,6 +35,15 @@ const routes: RouteRecordRaw[] = [
icon: 'app_registration', icon: 'app_registration',
}, },
}, },
{
path: 'iscsSharedDraft',
name: 'iscsSharedDraft',
component: () => import('pages/IscsDraftManage.vue'),
meta: {
label: 'iscs分享草稿管理',
icon: 'app_registration',
},
},
{ {
path: 'iscsPublish', path: 'iscsPublish',
name: 'iscsPublish', name: 'iscsPublish',