Merge branch 'master' of git.code.tencent.com:xian-ncc-da/xian-ncc-da-client

This commit is contained in:
Yuan 2023-06-09 15:28:52 +08:00
commit 72ef395221
8 changed files with 132 additions and 247 deletions

View File

@ -47,18 +47,6 @@ export function deleteDraft(id: number) {
return api.delete(`${DraftUriBase}/${id}`);
}
/**
* 稿
* @param id 稿id
*/
export function publishDraft(data: {
name: string;
lineId: number;
draftingId: number;
}) {
return api.post('/api/publishedGi/publish', data);
}
/**
* 稿
* @param params

View File

@ -38,7 +38,7 @@ export async function pageQuery(
export function createLine(data: {
name: string;
lineId: number;
config: string;
config?: string;
}) {
return api.post(`${UriBase}`, data);
}
@ -74,7 +74,7 @@ export async function getLineInfo(id: number): Promise<Item> {
* @param params
* @returns
*/
export async function getLineList(): Promise<Item> {
export async function getLineList(): Promise<Array<Item>> {
const response = await api.get(`${UriBase}/list`);
return response.data;
}

61
src/api/PublishApi.ts Normal file
View 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: {
name: string;
lineId: number;
draftingId: number;
}) {
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}`);
}

View File

@ -4,7 +4,6 @@ import {
JlGraphicTemplate,
VectorText,
} from 'src/jl-graphic';
import { StationDraw } from './StationDrawAssistant';
export interface IStationData extends GraphicData {
get code(): string; // 编号
@ -30,16 +29,13 @@ export class Station extends JlGraphic {
get datas(): IStationData {
return this.getDatas<IStationData>();
}
static draw(station: Station | StationDraw, datas?: IStationData): void {
const codeGraph = station.codeGraph;
codeGraph.text = datas?.code || '车站Station';
doRepaint(): void {
const codeGraph = this.codeGraph;
codeGraph.text = this.datas?.code || '车站Station';
codeGraph.style.fill = stationConsts.codeColor;
codeGraph.setVectorFontSize(stationConsts.codeFontSize);
codeGraph.anchor.set(0.5);
}
doRepaint(): void {
Station.draw(this, this.datas);
}
}
export class StationTemplate extends JlGraphicTemplate<Station> {

View File

@ -1,10 +1,10 @@
import { FederatedPointerEvent, Point } from 'pixi.js';
import {
GraphicData,
GraphicDrawAssistant,
GraphicInteractionPlugin,
JlDrawApp,
JlGraphic,
VectorText,
} from 'src/jl-graphic';
import { IStationData, Station, StationTemplate } from './Station';
@ -17,8 +17,7 @@ export class StationDraw extends GraphicDrawAssistant<
StationTemplate,
IStationData
> {
codeGraph: VectorText = new VectorText('');
codeGraph: Station;
constructor(app: JlDrawApp, createData: () => IStationData) {
super(
app,
@ -27,13 +26,16 @@ export class StationDraw extends GraphicDrawAssistant<
'svguse:../drawIcon.svg#icon-station',
'车站Station'
);
this.codeGraph = this.graphicTemplate.new();
this.container.addChild(this.codeGraph);
stationInteraction.init(app);
}
bind(): void {
super.bind();
Station.draw(this);
const data = { graphicType: 'station' } as GraphicData;
this.codeGraph.loadData(data);
this.codeGraph.doRepaint();
}
unbind(): void {
super.unbind();

View File

@ -123,12 +123,7 @@
</q-card-section>
<q-card-actions align="right">
<q-btn
color="primary"
label="发布"
type="submit"
@click="publishGraphics"
/>
<q-btn color="primary" label="发布" type="submit" />
<q-btn label="取消" v-close-popup />
</q-card-actions>
</q-form>
@ -140,12 +135,9 @@
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue';
import { useQuasar, type QTableColumn, QForm } from 'quasar';
import {
pageQuery,
publishDraft,
createDraft,
deleteDraft,
} from '../api/DraftApi';
import { pageQuery, createDraft, deleteDraft } from '../api/DraftApi';
import { publishDraft } from '../api/PublishApi';
import { getLineList } from '../api/LineInfoApi';
const $q = useQuasar();
@ -165,10 +157,24 @@ const typeOptions = [
{ label: '线网', value: 'LineNetwork' },
];
const createType = ref('Line');
const lineOptions = [
{ label: '线路1', value: 1 },
{ label: '线路2', value: 2 },
];
let lineOptions: Array<{ label: string; value: number }> = [];
function getAllLineList() {
lineOptions = [];
getLineList()
.then((res) => {
res.forEach((item) => {
const obj = {
label: item.name,
value: item.lineId,
};
lineOptions.push(obj);
});
})
.catch((err) => {
console.log(err, '---err--');
});
}
const typeOptionsMap = computed(() => {
const obj: { [k: string]: string } = {};
@ -180,6 +186,7 @@ const typeOptionsMap = computed(() => {
onMounted(() => {
tableRef.value.requestServerInteraction();
getAllLineList();
});
const columnDefs: QTableColumn[] = [

View File

@ -2,7 +2,7 @@
<div class="q-pa-md">
<q-table
ref="tableRef"
title="草稿图"
title="线路信息"
:style="{ height: tableHeight + 'px' }"
:rows="rows"
:columns="columnDefs"
@ -28,18 +28,6 @@
<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"
@ -58,58 +46,31 @@
transition-hide="scale"
>
<q-card style="width: 300px">
<q-card-section>
<div class="text-h6">新建草稿图</div>
<q-form ref="myForm" class="q-gutter-md">
<q-form ref="myForm" @submit="onCreate" class="q-gutter-md">
<q-card-section>
<div class="text-h6">新建线路信息</div>
<q-input
outlined
label="名称"
v-model="draftName"
v-model="LineName"
lazy-rules
:rules="[(val) => val.length > 0 || '请输入名称!']"
/>
<q-select
v-model="createType"
:options="typeOptions"
emit-value
map-options
label="类型"
<q-input
outlined
label="线路ID"
v-model.number="LineId"
type="number"
lazy-rules
:rules="[(val) => val || '请输入线路ID']"
/>
</q-form>
</q-card-section>
</q-card-section>
<q-card-actions align="right">
<q-btn color="primary" label="创建" type="submit" @click="onCreate" />
<q-btn label="取消" v-close-popup />
</q-card-actions>
</q-card>
</q-dialog>
<q-dialog
v-model="publishFormShow"
persistent
transition-show="scale"
transition-hide="scale"
>
<q-card style="width: 300px">
<q-card-section>
<div class="text-h6">草稿发布</div>
</q-card-section>
<q-card-section>
<q-input
outlined
disable
label="草稿名称"
v-model="publishForm.draftName"
/>
<q-input outlined label="发布名称" v-model="publishForm.pubName" />
</q-card-section>
<q-card-actions align="right">
<q-btn color="primary" label="发布" @click="publishGraphics" />
<q-btn label="取消" v-close-popup />
</q-card-actions>
<q-card-actions align="right">
<q-btn color="primary" label="创建" type="submit" />
<q-btn label="取消" v-close-popup />
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</div>
@ -118,12 +79,7 @@
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue';
import { useQuasar, type QTableColumn, QForm } from 'quasar';
import {
pageQuery,
publishDraft,
createDraft,
deleteDraft,
} from '../api/DraftApi';
import { pageQuery, createLine, deleteLine } from '../api/LineInfoApi';
const $q = useQuasar();
@ -138,20 +94,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();
});
@ -164,15 +106,7 @@ const columnDefs: QTableColumn[] = [
required: true,
align: 'center',
},
// { name: 'creator', label: '', field: 'creator', align: 'center' },
{
name: 'type',
label: '类型',
field: (row) => {
return typeOptionsMap.value[row.type];
},
align: 'center',
},
{ name: 'lineId', label: '线路ID', field: 'lineId', align: 'center' },
{
name: 'createdAt',
label: '创建时间',
@ -232,16 +166,17 @@ async function onRequest(props: any) {
}
const createFormShow = ref(false);
const draftName = ref('');
const LineName = ref('');
const LineId = ref(1);
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,
await createLine({
name: LineName.value,
lineId: LineId.value,
});
createFormShow.value = false;
tableRef.value.requestServerInteraction(); //
@ -257,50 +192,16 @@ function onCreate() {
});
}
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 publishGraphics() {
try {
await publishDraft({
draftingId: publishForm.id,
name: publishForm.pubName,
lineId: publishForm.lineId,
});
publishFormShow.value = false;
$q.notify({
type: 'positive',
message: '发布成功',
});
} catch (error: any) {
$q.notify({
type: 'negative',
message: error.message,
});
}
}
async function deleteData(row: any) {
operateDisabled.value = true;
$q.dialog({
title: '确认',
message: `确认删除草稿图 "${row.name}" 吗?`,
message: `确认删除线路 "${row.name}" 吗?`,
cancel: true,
})
.onOk(async () => {
try {
await deleteDraft(row.id);
await deleteLine(row.id);
tableRef.value.requestServerInteraction(); //
} catch (error: any) {
$q.notify({

View File

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