Merge branch 'master' of git.code.tencent.com:xian-ncc-da/xian-ncc-da-client
This commit is contained in:
commit
72ef395221
@ -47,18 +47,6 @@ export function deleteDraft(id: number) {
|
|||||||
return api.delete(`${DraftUriBase}/${id}`);
|
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
|
* @param params
|
||||||
|
@ -38,7 +38,7 @@ export async function pageQuery(
|
|||||||
export function createLine(data: {
|
export function createLine(data: {
|
||||||
name: string;
|
name: string;
|
||||||
lineId: number;
|
lineId: number;
|
||||||
config: string;
|
config?: string;
|
||||||
}) {
|
}) {
|
||||||
return api.post(`${UriBase}`, data);
|
return api.post(`${UriBase}`, data);
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ export async function getLineInfo(id: number): Promise<Item> {
|
|||||||
* @param params
|
* @param params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function getLineList(): Promise<Item> {
|
export async function getLineList(): Promise<Array<Item>> {
|
||||||
const response = await api.get(`${UriBase}/list`);
|
const response = await api.get(`${UriBase}/list`);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
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: {
|
||||||
|
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}`);
|
||||||
|
}
|
@ -4,7 +4,6 @@ import {
|
|||||||
JlGraphicTemplate,
|
JlGraphicTemplate,
|
||||||
VectorText,
|
VectorText,
|
||||||
} from 'src/jl-graphic';
|
} from 'src/jl-graphic';
|
||||||
import { StationDraw } from './StationDrawAssistant';
|
|
||||||
|
|
||||||
export interface IStationData extends GraphicData {
|
export interface IStationData extends GraphicData {
|
||||||
get code(): string; // 编号
|
get code(): string; // 编号
|
||||||
@ -30,16 +29,13 @@ export class Station extends JlGraphic {
|
|||||||
get datas(): IStationData {
|
get datas(): IStationData {
|
||||||
return this.getDatas<IStationData>();
|
return this.getDatas<IStationData>();
|
||||||
}
|
}
|
||||||
static draw(station: Station | StationDraw, datas?: IStationData): void {
|
doRepaint(): void {
|
||||||
const codeGraph = station.codeGraph;
|
const codeGraph = this.codeGraph;
|
||||||
codeGraph.text = datas?.code || '车站Station';
|
codeGraph.text = this.datas?.code || '车站Station';
|
||||||
codeGraph.style.fill = stationConsts.codeColor;
|
codeGraph.style.fill = stationConsts.codeColor;
|
||||||
codeGraph.setVectorFontSize(stationConsts.codeFontSize);
|
codeGraph.setVectorFontSize(stationConsts.codeFontSize);
|
||||||
codeGraph.anchor.set(0.5);
|
codeGraph.anchor.set(0.5);
|
||||||
}
|
}
|
||||||
doRepaint(): void {
|
|
||||||
Station.draw(this, this.datas);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StationTemplate extends JlGraphicTemplate<Station> {
|
export class StationTemplate extends JlGraphicTemplate<Station> {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { FederatedPointerEvent, Point } from 'pixi.js';
|
import { FederatedPointerEvent, Point } from 'pixi.js';
|
||||||
import {
|
import {
|
||||||
|
GraphicData,
|
||||||
GraphicDrawAssistant,
|
GraphicDrawAssistant,
|
||||||
GraphicInteractionPlugin,
|
GraphicInteractionPlugin,
|
||||||
JlDrawApp,
|
JlDrawApp,
|
||||||
JlGraphic,
|
JlGraphic,
|
||||||
VectorText,
|
|
||||||
} from 'src/jl-graphic';
|
} from 'src/jl-graphic';
|
||||||
|
|
||||||
import { IStationData, Station, StationTemplate } from './Station';
|
import { IStationData, Station, StationTemplate } from './Station';
|
||||||
@ -17,8 +17,7 @@ export class StationDraw extends GraphicDrawAssistant<
|
|||||||
StationTemplate,
|
StationTemplate,
|
||||||
IStationData
|
IStationData
|
||||||
> {
|
> {
|
||||||
codeGraph: VectorText = new VectorText('');
|
codeGraph: Station;
|
||||||
|
|
||||||
constructor(app: JlDrawApp, createData: () => IStationData) {
|
constructor(app: JlDrawApp, createData: () => IStationData) {
|
||||||
super(
|
super(
|
||||||
app,
|
app,
|
||||||
@ -27,13 +26,16 @@ export class StationDraw extends GraphicDrawAssistant<
|
|||||||
'svguse:../drawIcon.svg#icon-station',
|
'svguse:../drawIcon.svg#icon-station',
|
||||||
'车站Station'
|
'车站Station'
|
||||||
);
|
);
|
||||||
|
this.codeGraph = this.graphicTemplate.new();
|
||||||
this.container.addChild(this.codeGraph);
|
this.container.addChild(this.codeGraph);
|
||||||
stationInteraction.init(app);
|
stationInteraction.init(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
bind(): void {
|
bind(): void {
|
||||||
super.bind();
|
super.bind();
|
||||||
Station.draw(this);
|
const data = { graphicType: 'station' } as GraphicData;
|
||||||
|
this.codeGraph.loadData(data);
|
||||||
|
this.codeGraph.doRepaint();
|
||||||
}
|
}
|
||||||
unbind(): void {
|
unbind(): void {
|
||||||
super.unbind();
|
super.unbind();
|
||||||
|
@ -123,12 +123,7 @@
|
|||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
<q-card-actions align="right">
|
<q-card-actions align="right">
|
||||||
<q-btn
|
<q-btn color="primary" label="发布" type="submit" />
|
||||||
color="primary"
|
|
||||||
label="发布"
|
|
||||||
type="submit"
|
|
||||||
@click="publishGraphics"
|
|
||||||
/>
|
|
||||||
<q-btn label="取消" v-close-popup />
|
<q-btn label="取消" v-close-popup />
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-form>
|
</q-form>
|
||||||
@ -140,12 +135,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, computed } from 'vue';
|
import { ref, reactive, onMounted, computed } from 'vue';
|
||||||
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
||||||
import {
|
import { pageQuery, createDraft, deleteDraft } from '../api/DraftApi';
|
||||||
pageQuery,
|
import { publishDraft } from '../api/PublishApi';
|
||||||
publishDraft,
|
import { getLineList } from '../api/LineInfoApi';
|
||||||
createDraft,
|
|
||||||
deleteDraft,
|
|
||||||
} from '../api/DraftApi';
|
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
|
||||||
@ -165,10 +157,24 @@ const typeOptions = [
|
|||||||
{ label: '线网', value: 'LineNetwork' },
|
{ label: '线网', value: 'LineNetwork' },
|
||||||
];
|
];
|
||||||
const createType = ref('Line');
|
const createType = ref('Line');
|
||||||
const lineOptions = [
|
|
||||||
{ label: '线路1', value: 1 },
|
let lineOptions: Array<{ label: string; value: number }> = [];
|
||||||
{ label: '线路2', value: 2 },
|
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 typeOptionsMap = computed(() => {
|
||||||
const obj: { [k: string]: string } = {};
|
const obj: { [k: string]: string } = {};
|
||||||
@ -180,6 +186,7 @@ const typeOptionsMap = computed(() => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
tableRef.value.requestServerInteraction();
|
tableRef.value.requestServerInteraction();
|
||||||
|
getAllLineList();
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnDefs: QTableColumn[] = [
|
const columnDefs: QTableColumn[] = [
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<q-table
|
<q-table
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
title="草稿图"
|
title="线路信息"
|
||||||
:style="{ height: tableHeight + 'px' }"
|
:style="{ height: tableHeight + 'px' }"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
:columns="columnDefs"
|
:columns="columnDefs"
|
||||||
@ -28,18 +28,6 @@
|
|||||||
<template v-slot:body-cell-operations="props">
|
<template v-slot:body-cell-operations="props">
|
||||||
<q-td :props="props">
|
<q-td :props="props">
|
||||||
<div class="q-gutter-sm row justify-center">
|
<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
|
<q-btn
|
||||||
color="red"
|
color="red"
|
||||||
:disable="operateDisabled"
|
:disable="operateDisabled"
|
||||||
@ -58,58 +46,31 @@
|
|||||||
transition-hide="scale"
|
transition-hide="scale"
|
||||||
>
|
>
|
||||||
<q-card style="width: 300px">
|
<q-card style="width: 300px">
|
||||||
<q-card-section>
|
<q-form ref="myForm" @submit="onCreate" class="q-gutter-md">
|
||||||
<div class="text-h6">新建草稿图</div>
|
<q-card-section>
|
||||||
<q-form ref="myForm" class="q-gutter-md">
|
<div class="text-h6">新建线路信息</div>
|
||||||
<q-input
|
<q-input
|
||||||
outlined
|
outlined
|
||||||
label="名称"
|
label="名称"
|
||||||
v-model="draftName"
|
v-model="LineName"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
:rules="[(val) => val.length > 0 || '请输入名称!']"
|
:rules="[(val) => val.length > 0 || '请输入名称!']"
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-input
|
||||||
v-model="createType"
|
outlined
|
||||||
:options="typeOptions"
|
label="线路ID"
|
||||||
emit-value
|
v-model.number="LineId"
|
||||||
map-options
|
type="number"
|
||||||
label="类型"
|
lazy-rules
|
||||||
|
:rules="[(val) => val || '请输入线路ID!']"
|
||||||
/>
|
/>
|
||||||
</q-form>
|
</q-card-section>
|
||||||
</q-card-section>
|
|
||||||
|
|
||||||
<q-card-actions align="right">
|
<q-card-actions align="right">
|
||||||
<q-btn color="primary" label="创建" type="submit" @click="onCreate" />
|
<q-btn color="primary" label="创建" type="submit" />
|
||||||
<q-btn label="取消" v-close-popup />
|
<q-btn label="取消" v-close-popup />
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-card>
|
</q-form>
|
||||||
</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>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
</div>
|
</div>
|
||||||
@ -118,12 +79,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, computed } from 'vue';
|
import { ref, reactive, onMounted, computed } from 'vue';
|
||||||
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
||||||
import {
|
import { pageQuery, createLine, deleteLine } from '../api/LineInfoApi';
|
||||||
pageQuery,
|
|
||||||
publishDraft,
|
|
||||||
createDraft,
|
|
||||||
deleteDraft,
|
|
||||||
} from '../api/DraftApi';
|
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
|
||||||
@ -138,20 +94,6 @@ const tableHeight = computed(() => {
|
|||||||
return props.sizeHeight - 32;
|
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(() => {
|
onMounted(() => {
|
||||||
tableRef.value.requestServerInteraction();
|
tableRef.value.requestServerInteraction();
|
||||||
});
|
});
|
||||||
@ -164,15 +106,7 @@ const columnDefs: QTableColumn[] = [
|
|||||||
required: true,
|
required: true,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
},
|
},
|
||||||
// { name: 'creator', label: '创建人', field: 'creator', align: 'center' },
|
{ name: 'lineId', label: '线路ID', field: 'lineId', align: 'center' },
|
||||||
{
|
|
||||||
name: 'type',
|
|
||||||
label: '类型',
|
|
||||||
field: (row) => {
|
|
||||||
return typeOptionsMap.value[row.type];
|
|
||||||
},
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'createdAt',
|
name: 'createdAt',
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
@ -232,16 +166,17 @@ async function onRequest(props: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createFormShow = ref(false);
|
const createFormShow = ref(false);
|
||||||
const draftName = ref('');
|
const LineName = ref('');
|
||||||
|
const LineId = ref(1);
|
||||||
const myForm = ref<QForm | null>(null);
|
const myForm = ref<QForm | null>(null);
|
||||||
function onCreate() {
|
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 {
|
try {
|
||||||
await createDraft({
|
await createLine({
|
||||||
name: draftName.value,
|
name: LineName.value,
|
||||||
type: createType.value,
|
lineId: LineId.value,
|
||||||
});
|
});
|
||||||
createFormShow.value = false;
|
createFormShow.value = false;
|
||||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
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) {
|
async function deleteData(row: any) {
|
||||||
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(async () => {
|
||||||
try {
|
try {
|
||||||
await deleteDraft(row.id);
|
await deleteLine(row.id);
|
||||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
$q.notify({
|
$q.notify({
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<q-table
|
<q-table
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
title="草稿图"
|
title="发布图"
|
||||||
:style="{ height: tableHeight + 'px' }"
|
:style="{ height: tableHeight + 'px' }"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
:columns="columnDefs"
|
:columns="columnDefs"
|
||||||
@ -22,24 +22,11 @@
|
|||||||
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" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:body-cell-operations="props">
|
<template v-slot:body-cell-operations="props">
|
||||||
<q-td :props="props">
|
<q-td :props="props">
|
||||||
<div class="q-gutter-sm row justify-center">
|
<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
|
<q-btn
|
||||||
color="red"
|
color="red"
|
||||||
:disable="operateDisabled"
|
:disable="operateDisabled"
|
||||||
@ -56,7 +43,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, computed } from 'vue';
|
import { ref, reactive, onMounted, computed } from 'vue';
|
||||||
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
||||||
import { pageQuery, createDraft, deleteDraft } from '../api/DraftApi';
|
import { pageQuery, deletePublish } from '../api/PublishApi';
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
|
||||||
@ -71,20 +58,6 @@ const tableHeight = computed(() => {
|
|||||||
return props.sizeHeight - 32;
|
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(() => {
|
onMounted(() => {
|
||||||
tableRef.value.requestServerInteraction();
|
tableRef.value.requestServerInteraction();
|
||||||
});
|
});
|
||||||
@ -97,25 +70,22 @@ const columnDefs: QTableColumn[] = [
|
|||||||
required: true,
|
required: true,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
},
|
},
|
||||||
// { name: 'creator', label: '创建人', field: 'creator', align: 'center' },
|
|
||||||
{
|
{
|
||||||
name: 'type',
|
name: 'type',
|
||||||
label: '类型',
|
label: '类型',
|
||||||
field: (row) => {
|
field: 'type',
|
||||||
return typeOptionsMap.value[row.type];
|
|
||||||
},
|
|
||||||
align: 'center',
|
align: 'center',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'createdAt',
|
name: 'lineId',
|
||||||
label: '创建时间',
|
label: '线路Id',
|
||||||
field: 'createdAt',
|
field: 'lineId',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'updateAt',
|
name: 'publishAt',
|
||||||
label: '更新时间',
|
label: '发布时间',
|
||||||
field: 'updateAt',
|
field: 'publishAt',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
},
|
},
|
||||||
{ name: 'operations', label: '操作', field: 'operations', 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) {
|
async function deleteData(row: any) {
|
||||||
operateDisabled.value = true;
|
operateDisabled.value = true;
|
||||||
$q.dialog({
|
$q.dialog({
|
||||||
@ -213,7 +143,7 @@ async function deleteData(row: any) {
|
|||||||
})
|
})
|
||||||
.onOk(async () => {
|
.onOk(async () => {
|
||||||
try {
|
try {
|
||||||
await deleteDraft(row.id);
|
await deletePublish(row.id);
|
||||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
$q.notify({
|
$q.notify({
|
||||||
|
Loading…
Reference in New Issue
Block a user