feat: 添加库区规则支持,更新相关接口和组件以处理先进先出和后进先出逻辑

This commit is contained in:
xudan 2025-07-14 14:03:26 +08:00
parent 5d57a8924f
commit cfb04396e2
5 changed files with 38 additions and 4 deletions

View File

@ -44,6 +44,7 @@ export interface MapAreaInfo {
points?: Array<string>; // 绑定点位id集合 points?: Array<string>; // 绑定点位id集合
routes?: Array<string>; // 绑定线路id集合 routes?: Array<string>; // 绑定线路id集合
maxAmr?: number; // 最大可容纳AMR数 maxAmr?: number; // 最大可容纳AMR数
inoutflag?: 1 | 2; // 库区规则
} }
//#endregion //#endregion

View File

@ -67,6 +67,7 @@ export interface StandardSceneArea {
points?: Array<string>; // 绑定点位id集合 points?: Array<string>; // 绑定点位id集合
routes?: Array<string>; // 绑定线路id集合 routes?: Array<string>; // 绑定线路id集合
maxAmr?: number; // 最大可容纳AMR数 maxAmr?: number; // 最大可容纳AMR数
inoutflag?: 1 | 2; // 库区规则
config?: object; // 其它属性配置(可按需增加) config?: object; // 其它属性配置(可按需增加)
properties?: unknown; // 附加数据(前端不做任何处理) properties?: unknown; // 附加数据(前端不做任何处理)
} }

View File

@ -43,6 +43,12 @@ const bindRoute = computed<string>(
.filter((v) => !!v) .filter((v) => !!v)
.join('、') ?? '', .join('、') ?? '',
); );
const ruleText = computed(() => {
if (area.value?.inoutflag === 1) return '先进先出';
if (area.value?.inoutflag === 2) return '后进先出';
return '';
});
</script> </script>
<template> <template>
@ -69,6 +75,12 @@ const bindRoute = computed<string>(
<a-typography-text>{{ pen.area?.maxAmr ?? $t('暂无') }}</a-typography-text> <a-typography-text>{{ pen.area?.maxAmr ?? $t('暂无') }}</a-typography-text>
</a-flex> </a-flex>
</a-list-item> </a-list-item>
<a-list-item v-if="MapAreaType.库区 === area.type">
<a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('库区规则') }}</a-typography-text>
<a-typography-text>{{ ruleText || $t('暂无') }}</a-typography-text>
</a-flex>
</a-list-item>
<a-list-item v-if="MapAreaType.库区 === area.type"> <a-list-item v-if="MapAreaType.库区 === area.type">
<a-flex :gap="8" vertical> <a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('绑定动作点') }}</a-typography-text> <a-typography-text type="secondary">{{ $t('绑定动作点') }}</a-typography-text>

View File

@ -80,6 +80,21 @@ const routes = computed<string[]>(
/> />
</a-col> </a-col>
</a-row> </a-row>
<a-row v-if="area.type === MapAreaType.库区" :gutter="[8, 8]">
<a-col :span="24">
<a-typography-text>{{ $t('库区规则') }}:</a-typography-text>
</a-col>
<a-col :span="24">
<a-select
class="full"
:value="pen.area?.inoutflag"
@change="editor.updateArea(id, { inoutflag: $event as 1 | 2 })"
>
<a-select-option :value="1">{{ $t('先进先出') }}</a-select-option>
<a-select-option :value="2">{{ $t('后进先出') }}</a-select-option>
</a-select>
</a-col>
</a-row>
<a-row :gutter="[8, 8]"> <a-row :gutter="[8, 8]">
<a-col :span="24"> <a-col :span="24">

View File

@ -153,10 +153,10 @@ export class EditorService extends Meta2d {
if (!areas?.length) return; if (!areas?.length) return;
await Promise.all( await Promise.all(
areas.map(async (v) => { areas.map(async (v) => {
const { id, name, desc, x, y, w, h, type, points, routes, maxAmr, properties } = v; const { id, name, desc, x, y, w, h, type, points, routes, maxAmr, inoutflag, properties } = v;
await this.addArea({ x, y }, { x: x + w, y: y + h }, type, id); await this.addArea({ x, y }, { x: x + w, y: y + h }, type, id);
this.setValue( this.setValue(
{ id, label: name, desc, properties, area: { type, points, routes, maxAmr } }, { id, label: name, desc, properties, area: { type, points, routes, maxAmr, inoutflag } },
{ render: false, history: false, doEvent: false }, { render: false, history: false, doEvent: false },
); );
}), }),
@ -232,7 +232,7 @@ export class EditorService extends Meta2d {
#mapSceneArea(pen: MapPen): StandardSceneArea | null { #mapSceneArea(pen: MapPen): StandardSceneArea | null {
if (!pen.id || isEmpty(pen.area)) return null; if (!pen.id || isEmpty(pen.area)) return null;
const { id, label, desc, properties } = pen; const { id, label, desc, properties } = pen;
const { type, points, routes, maxAmr } = pen.area; const { type, points, routes, maxAmr, inoutflag } = pen.area;
const { x, y, width, height } = this.getPenRect(pen); const { x, y, width, height } = this.getPenRect(pen);
// 进行坐标转换:左上角原点 -> 中心点原点同时应用ratio缩放 // 进行坐标转换:左上角原点 -> 中心点原点同时应用ratio缩放
const transformedCoords = this.#transformCoordinate(x, y); const transformedCoords = this.#transformCoordinate(x, y);
@ -253,6 +253,7 @@ export class EditorService extends Meta2d {
} }
if (MapAreaType. === type) { if (MapAreaType. === type) {
area.points = points?.filter((v) => this.getPenById(v)?.point?.type === MapPointType.); area.points = points?.filter((v) => this.getPenById(v)?.point?.type === MapPointType.);
area.inoutflag = inoutflag;
} }
if ([MapAreaType., MapAreaType., MapAreaType.].includes(type)) { if ([MapAreaType., MapAreaType., MapAreaType.].includes(type)) {
area.points = points?.filter((v) => { area.points = points?.filter((v) => {
@ -809,6 +810,10 @@ export class EditorService extends Meta2d {
break; break;
} }
} }
const areaInfo: MapAreaInfo = { type, points, routes };
if (type === MapAreaType.) {
areaInfo.inoutflag = 1;
}
const pen: MapPen = { const pen: MapPen = {
id, id,
name: 'area', name: 'area',
@ -819,7 +824,7 @@ export class EditorService extends Meta2d {
width: w, width: w,
height: h, height: h,
lineWidth: 1, lineWidth: 1,
area: { type, points, routes }, area: areaInfo,
locked: LockState.None, locked: LockState.None,
}; };
const area = await this.addPen(pen, true, true, true); const area = await this.addPen(pen, true, true, true);