发布图api和页面
This commit is contained in:
parent
b76a7f1092
commit
360829d661
61
src/api/PublishApi.ts
Normal file
61
src/api/PublishApi.ts
Normal file
@ -0,0 +1,61 @@
|
||||
import { api } from 'src/boot/axios';
|
||||
import { PageDto, PageQueryDto } from './ApiCommon';
|
||||
|
||||
const PublishUriBase = '/api/publishedGi';
|
||||
|
||||
interface Item {
|
||||
id: number;
|
||||
name: string;
|
||||
proto: string;
|
||||
createdAt: string;
|
||||
updateAt: string;
|
||||
creatorId?: number;
|
||||
}
|
||||
|
||||
export class PagingQueryParams extends PageQueryDto {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 草稿图发布
|
||||
* @param id 草稿id
|
||||
*/
|
||||
export function publishDraft(data: {
|
||||
layoutId: string;
|
||||
name: string;
|
||||
overwrite?: boolean;
|
||||
}) {
|
||||
return api.post(`${PublishUriBase}/publish`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发布图形数据列表
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export async function getDraft(id: number): Promise<Item> {
|
||||
const response = await api.get(`${PublishUriBase}/list`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export async function pageQuery(
|
||||
params: PagingQueryParams
|
||||
): Promise<PageDto<Item>> {
|
||||
const response = await api.get(`${PublishUriBase}/paging`, {
|
||||
params: params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除发布图
|
||||
* @param id 草稿id
|
||||
*/
|
||||
export function deletePublish(id: number) {
|
||||
return api.delete(`${PublishUriBase}/${id}`);
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
<div class="q-pa-md">
|
||||
<q-table
|
||||
ref="tableRef"
|
||||
title="草稿图"
|
||||
title="发布图"
|
||||
:style="{ height: tableHeight + 'px' }"
|
||||
:rows="rows"
|
||||
:columns="columnDefs"
|
||||
@ -22,24 +22,11 @@
|
||||
label="名称"
|
||||
></q-input>
|
||||
<q-btn flat round color="primary" icon="search" />
|
||||
<q-btn color="primary" label="新建" @click="createFormShow = true" />
|
||||
</template>
|
||||
|
||||
<template v-slot:body-cell-operations="props">
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-btn
|
||||
color="primary"
|
||||
:disable="operateDisabled"
|
||||
label="编辑"
|
||||
:to="`/painting/${props.row.id}`"
|
||||
/>
|
||||
<q-btn
|
||||
color="primary"
|
||||
:disable="operateDisabled"
|
||||
label="发布"
|
||||
@click="prePublish(props.row)"
|
||||
/>
|
||||
<q-btn
|
||||
color="red"
|
||||
:disable="operateDisabled"
|
||||
@ -56,7 +43,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
||||
import { pageQuery, createDraft, deleteDraft } from '../api/DraftApi';
|
||||
import { pageQuery, deletePublish } from '../api/PublishApi';
|
||||
|
||||
const $q = useQuasar();
|
||||
|
||||
@ -71,20 +58,6 @@ const tableHeight = computed(() => {
|
||||
return props.sizeHeight - 32;
|
||||
});
|
||||
|
||||
const typeOptions = [
|
||||
{ label: '线路', value: 'Line' },
|
||||
{ label: '线网', value: 'LineNetwork' },
|
||||
];
|
||||
const createType = ref('Line');
|
||||
|
||||
const typeOptionsMap = computed(() => {
|
||||
const obj: { [k: string]: string } = {};
|
||||
typeOptions.forEach((item: { value: string; label: string }) => {
|
||||
obj[item.value] = item.label;
|
||||
});
|
||||
return obj;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
tableRef.value.requestServerInteraction();
|
||||
});
|
||||
@ -97,25 +70,22 @@ const columnDefs: QTableColumn[] = [
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
// { name: 'creator', label: '创建人', field: 'creator', align: 'center' },
|
||||
{
|
||||
name: 'type',
|
||||
label: '类型',
|
||||
field: (row) => {
|
||||
return typeOptionsMap.value[row.type];
|
||||
},
|
||||
field: 'type',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'createdAt',
|
||||
label: '创建时间',
|
||||
field: 'createdAt',
|
||||
name: 'lineId',
|
||||
label: '线路Id',
|
||||
field: 'lineId',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'updateAt',
|
||||
label: '更新时间',
|
||||
field: 'updateAt',
|
||||
name: 'publishAt',
|
||||
label: '发布时间',
|
||||
field: 'publishAt',
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
|
||||
@ -164,46 +134,6 @@ async function onRequest(props: any) {
|
||||
}
|
||||
}
|
||||
|
||||
const createFormShow = ref(false);
|
||||
const draftName = ref('');
|
||||
const myForm = ref<QForm | null>(null);
|
||||
function onCreate() {
|
||||
myForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
operateDisabled.value = true;
|
||||
try {
|
||||
await createDraft({
|
||||
name: draftName.value,
|
||||
type: createType.value,
|
||||
});
|
||||
createFormShow.value = false;
|
||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (error: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.message,
|
||||
});
|
||||
} finally {
|
||||
operateDisabled.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const publishFormShow = ref(false);
|
||||
const publishForm = reactive({
|
||||
id: '',
|
||||
draftName: '',
|
||||
pubName: '',
|
||||
lineId: '',
|
||||
});
|
||||
function prePublish(row: any) {
|
||||
publishFormShow.value = true;
|
||||
publishForm.id = row.id;
|
||||
publishForm.draftName = row.name;
|
||||
publishForm.pubName = row.name;
|
||||
}
|
||||
|
||||
async function deleteData(row: any) {
|
||||
operateDisabled.value = true;
|
||||
$q.dialog({
|
||||
@ -213,7 +143,7 @@ async function deleteData(row: any) {
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await deleteDraft(row.id);
|
||||
await deletePublish(row.id);
|
||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (error: any) {
|
||||
$q.notify({
|
||||
|
Loading…
Reference in New Issue
Block a user