diff --git a/src/api/PublishApi.ts b/src/api/PublishApi.ts index db1f1c3..dfe60ae 100644 --- a/src/api/PublishApi.ts +++ b/src/api/PublishApi.ts @@ -78,12 +78,8 @@ export async function getPublishLineNet(): Promise { /** * 获取发布地图详细信息 * @param id 发布地图线路ID - * @param type 发布地图线路类型 */ -export async function getPublishMapInfoByLineId( - lineId: number, - type: string -): Promise { - const response = await api.get(`${PublishUriBase}/${type}/${lineId}`); +export async function getPublishMapInfoByLineId(lineId: number): Promise { + const response = await api.get(`${PublishUriBase}/${lineId}`); return response.data; } diff --git a/src/components/SysMenu.vue b/src/components/SysMenu.vue index 269a46a..1f32531 100644 --- a/src/components/SysMenu.vue +++ b/src/components/SysMenu.vue @@ -69,11 +69,11 @@ const list = reactive([ label: '发布管理', icon: 'app_registration', }, - { - path: '/dataManage/lineInfo', - label: '线路信息管理', - icon: 'app_registration', - }, + // { + // path: '/dataManage/lineInfo', + // label: '线路信息管理', + // icon: 'app_registration', + // }, ], }, ]); diff --git a/src/drawApp/lineApp.ts b/src/drawApp/lineApp.ts index 300eb22..792c693 100644 --- a/src/drawApp/lineApp.ts +++ b/src/drawApp/lineApp.ts @@ -104,8 +104,7 @@ export async function loadLineDatas(app: GraphicApp) { return; } const { proto: base64, name: lineName } = await getPublishMapInfoByLineId( - lineId, - 'line' + lineId ); lineStore.setLineName(lineName); if (base64) { diff --git a/src/graphics/logicSection/LogicSection.ts b/src/graphics/logicSection/LogicSection.ts index 18ccec3..9162402 100644 --- a/src/graphics/logicSection/LogicSection.ts +++ b/src/graphics/logicSection/LogicSection.ts @@ -5,6 +5,9 @@ import { JlGraphic, JlGraphicTemplate, VectorText, + calculateLineMidpoint, + getNormalVector, + movePointAlongNormal, } from 'src/jl-graphic'; export interface ILogicSectionData extends GraphicData { @@ -26,24 +29,29 @@ export interface ILogicSectionData extends GraphicData { export const LogicSectionConsts = { lineColor: '0xff0000', lineWidth: 2, + labelColor: '0xFF00FF', + divisionColor: '0xFF00FF', + divisionWidth: 1, }; export class LogicSection extends JlGraphic { static Type = 'LogicSection'; lineGraphic: Graphics; labelGraphic: VectorText; + divisionGraphic: Graphics = new Graphics(); constructor() { super(LogicSection.Type); this.lineGraphic = new Graphics(); this.labelGraphic = new VectorText(); this.labelGraphic.setVectorFontSize(14); this.labelGraphic.anchor.set(0.5); - this.labelGraphic.style.fill = '#0f0'; + this.labelGraphic.style.fill = LogicSectionConsts.labelColor; this.labelGraphic.transformSave = true; this.labelGraphic.name = 'label'; this.transformSave = true; this.addChild(this.lineGraphic); this.addChild(this.labelGraphic); + this.addChild(this.divisionGraphic); } get datas(): ILogicSectionData { @@ -65,6 +73,46 @@ export class LogicSection extends JlGraphic { this.lineGraphic.moveTo(p.x, p.y); } }); + let normalVector = getNormalVector( + this.datas.points[0], + this.datas.points[1] + ); + if (this.datas.points[0].x > this.datas.points[1].x) { + normalVector = getNormalVector( + this.datas.points[1], + this.datas.points[0] + ); + } + this.divisionGraphic.clear(); + this.divisionGraphic.lineStyle( + LogicSectionConsts.divisionWidth, + LogicSectionConsts.divisionColor + ); + const nextP = movePointAlongNormal(this.datas.points[0], normalVector, 5); + const nextP1 = this.datas.points[0]; + this.divisionGraphic.moveTo(nextP1.x, nextP1.y); + this.divisionGraphic.lineTo(nextP.x, nextP.y); + let normalVector2 = getNormalVector( + this.datas.points[this.datas.points.length - 2], + this.datas.points[this.datas.points.length - 1] + ); + if ( + this.datas.points[this.datas.points.length - 2].x > + this.datas.points[this.datas.points.length - 1].x + ) { + normalVector2 = getNormalVector( + this.datas.points[this.datas.points.length - 1], + this.datas.points[this.datas.points.length - 2] + ); + } + const nextP2 = movePointAlongNormal( + this.datas.points[this.datas.points.length - 1], + normalVector2, + 5 + ); + const nextP3 = this.datas.points[this.datas.points.length - 1]; + this.divisionGraphic.moveTo(nextP3.x, nextP3.y); + this.divisionGraphic.lineTo(nextP2.x, nextP2.y); this.labelGraphic.text = this.datas.code; const labelPosition = this.datas.childTransforms?.find( (t) => t.name === this.labelGraphic.name @@ -72,10 +120,11 @@ export class LogicSection extends JlGraphic { if (labelPosition) { this.labelGraphic.position.set(labelPosition.x, labelPosition.y); } else { - this.labelGraphic.position.set( - this.datas.points[0].x, - this.datas.points[0].y + 20 + const centerPos = calculateLineMidpoint( + this.datas.points[0], + this.datas.points[this.datas.points.length - 1] ); + this.labelGraphic.position.set(centerPos.x, centerPos.y + 20); } } get linePoints(): IPointData[] { diff --git a/src/pages/DraftManage.vue b/src/pages/DraftManage.vue index b2b9f1e..73a4ba8 100644 --- a/src/pages/DraftManage.vue +++ b/src/pages/DraftManage.vue @@ -32,7 +32,7 @@ color="primary" :disable="operateDisabled" label="编辑" - :to="`/painting/${props.row.id}/${props.row.type}`" + :to="`/painting/${props.row.id}/Line`" /> - + /> --> @@ -138,7 +138,7 @@ import { ref, reactive, onMounted, computed } from 'vue'; import { useQuasar, type QTableColumn, QForm } from 'quasar'; import { pageQuery, createDraft, deleteDraft } from '../api/DraftApi'; import { publishDraft } from '../api/PublishApi'; -import { getLineList } from '../api/LineInfoApi'; +// import { getLineList } from '../api/LineInfoApi'; import { ApiError } from 'src/boot/axios'; const $q = useQuasar(); @@ -160,35 +160,35 @@ const typeOptions = [ ]; const createType = ref('Line'); -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--'); - }); -} +// 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 } = {}; - typeOptions.forEach((item: { value: string; label: string }) => { - obj[item.value] = item.label; - }); - return obj; -}); +// 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(); - getAllLineList(); + // getAllLineList(); }); const columnDefs: QTableColumn[] = [ @@ -200,14 +200,14 @@ const columnDefs: QTableColumn[] = [ align: 'center', }, // { name: 'creator', label: '创建人', field: 'creator', align: 'center' }, - { - name: 'type', - label: '类型', - field: (row) => { - return typeOptionsMap.value[row.type]; - }, - align: 'center', - }, + // { + // name: 'type', + // label: '类型', + // field: (row) => { + // return typeOptionsMap.value[row.type]; + // }, + // align: 'center', + // }, { name: 'createdAt', label: '创建时间', @@ -299,7 +299,7 @@ const publishForm = reactive({ id: '', draftName: '', pubName: '', - lineId: '', + // lineId: '', type: 'Line', }); function prePublish(row: any) { @@ -307,7 +307,7 @@ function prePublish(row: any) { publishForm.id = row.id; publishForm.draftName = row.name; publishForm.pubName = row.name; - publishForm.lineId = ''; + // publishForm.lineId = ''; publishForm.type = row.type || 'Line'; } @@ -319,9 +319,9 @@ async function publishGraphics() { draftingId: +publishForm.id, name: publishForm.pubName, }; - if (publishForm.type == 'Line') { - params.lineId = +publishForm.lineId; - } + // if (publishForm.type == 'Line') { + // params.lineId = +publishForm.lineId; + // } await publishDraft(params); publishFormShow.value = false; $q.notify({ diff --git a/src/pages/PublishManage.vue b/src/pages/PublishManage.vue index 4faa6d5..317ecf6 100644 --- a/src/pages/PublishManage.vue +++ b/src/pages/PublishManage.vue @@ -31,7 +31,7 @@ color="primary" :disable="operateDisabled" label="预览" - :to="`/linemap/${props.row.lineId}/${props.row.type}`" + :to="`/linemap/${props.row.id}`" /> import('layouts/DrawLayout.vue'), }, { - path: '/linemap/:id/:type', + path: '/linemap/:id/', name: 'linemap', component: () => import('layouts/LineLayout.vue'), },