Browse Source

Merge remote-tracking branch 'origin/master'

master
修宁 6 months ago
parent
commit
b1d47c0700
  1. 15
      src/core/manager/EntityManager.ts
  2. 7
      src/core/script/ModelManager.ts
  3. 6
      src/modules/cl2/Cl23dObject.ts
  4. 2
      src/modules/cl2/Cl2Entity.ts
  5. 7
      src/types/ScriptSupport.d.ts
  6. 129
      src/views/user/roles.vue
  7. 130
      src/views/user/users.vue

15
src/core/manager/EntityManager.ts

@ -504,6 +504,21 @@ export default class EntityManager {
return this.___entityMap.get(linkStartPointId) return this.___entityMap.get(linkStartPointId)
} }
findItemByLogicXY(logicX: number, logicY: number): ItemJson | undefined {
if (logicX < 0 || logicY < 0) {
return
}
let item: ItemJson | undefined = undefined
this.___entityMap.forEach((value) => {
if (value.logicX === logicX && value.logicY === logicY) {
item = value
return
}
})
return item
}
getObjectByCanvasMouse(event: MouseEvent): Object3DLike[] { getObjectByCanvasMouse(event: MouseEvent): Object3DLike[] {
const _domElement = this.viewport.renderer.domElement const _domElement = this.viewport.renderer.domElement
const rect = _domElement.getBoundingClientRect() const rect = _domElement.getBoundingClientRect()

7
src/core/script/ModelManager.ts

@ -81,6 +81,13 @@ export default class ModelManager implements IControls, Model {
matrix.decompose(position, new THREE.Quaternion(), new THREE.Vector3()) matrix.decompose(position, new THREE.Quaternion(), new THREE.Vector3())
return position return position
} }
getPositionByLogicXY(logicX: number, logicY: number): THREE.Vector3 {
const item = this.viewport.entityManager.findItemByLogicXY(logicX, logicY)
const matrix = getMatrixFromTf(item.tf)
const position = new THREE.Vector3()
matrix.decompose(position, new THREE.Quaternion(), new THREE.Vector3())
return position
}
dispose() { dispose() {
this.viewport = null as any this.viewport = null as any

6
src/modules/cl2/Cl23dObject.ts

@ -516,8 +516,12 @@ export default class Cl23dObject extends THREE.Object3D {
if (data.id === 10010) { if (data.id === 10010) {
const cl2: Cl2Entity = Model.getCl2("10") as Cl2Entity const cl2: Cl2Entity = Model.getCl2("10") as Cl2Entity
cl2.addRobotTask(data) cl2.addRobotTask(data)
cl2.taskStartRun() this.fn(cl2)
} }
} }
fn = _.debounce((cl2: Cl2Entity) => {
cl2.taskStartRun()
}, 2000)
} }

2
src/modules/cl2/Cl2Entity.ts

@ -47,7 +47,7 @@ export default class Cl2Entity extends BaseEntity {
() => this.cl2Object.addRotation(moveDirection * Math.PI/2) () => this.cl2Object.addRotation(moveDirection * Math.PI/2)
)) ))
this.taskQueue.add(this.createTask('TRAVEL', this.taskQueue.add(this.createTask('TRAVEL',
() => this.cl2Object.addTravel(Model.getPositionByEntityId(link.id) ,Math.abs(link.Speed/1000)) () => this.cl2Object.addTravel(Model.getPositionByLogicXY(link.X, link.Y) ,Math.abs(link.Speed/1000))
)) ))
startX = link.X startX = link.X
startY = link.Y startY = link.Y

7
src/types/ScriptSupport.d.ts

@ -1,3 +1,5 @@
import * as THREE from "three";
/** /**
* API * API
*/ */
@ -14,6 +16,11 @@ declare interface Model {
getPositionByEntityId(entityId: string): Vector3IF getPositionByEntityId(entityId: string): Vector3IF
/** /**
*
*/
getPositionByLogicXY(logicX: number, logicY: number): THREE.Vector3
/**
* ID获取 CL2 * ID获取 CL2
*/ */
getCl2(id: string): Cl2If getCl2(id: string): Cl2If

129
src/views/user/roles.vue

@ -1,12 +1,127 @@
<script setup lang="ts">
import { reactive } from "vue";
import { ElButton } from "element-plus";
import { Delete, Plus, Search } from "@element-plus/icons-vue";
import DataForm from "@/components/data-form/DataForm.vue";
import type { FormField } from "@/components/data-form/DataFormTypes.ts";
import { AgGridVue } from "ag-grid-vue3";
import type { GridOptions } from "ag-grid-enterprise";
import type { GridApi, GridReadyEvent } from "ag-grid-community";
import { localeText as localeTextCn } from "@/components/yvTable/yv-aggrid-cn.locale";
// Props
interface ComponentProps {
}
// props
const props = withDefaults(defineProps<ComponentProps>(), {});
// State
interface ComponentState {
queryData: any;
grid1Data: Array<any>;
}
// state
const state = reactive<ComponentState>({
queryData: {},
grid1Data: [],
});
// Data
interface ComponentData {
formFields?: Array<FormField>;
gridSetting: Partial<GridOptions>;
api?: GridApi;
}
//
const data: ComponentData = {
formFields: [
{
dataPath: 'roleCode', label: '角色编号', input: 'Input',
inputProps: {
placeholder: '角色编号',
clearable: true,
}
},
{
dataPath: 'isEnable', label: '是否启用', input: 'SelectV2',
inputProps: {
placeholder: "是否启用",
clearable: true,
options: [
{ value: "0", label: "禁用" },
{ value: "1", label: "启用" },
],
}
},
],
gridSetting: {
localeText: localeTextCn,
// suppressNoRowsOverlay: true,
// suppressLoadingOverlay: true,
//
rowSelection: "single",
columnDefs: [
{ field: 'id', headerName: 'id', editable: false, hide: true },
{ field: 'roleCode', headerName: '角色编号', editable: false },
{ field: 'roleName', headerName: '角色名称', editable: false },
{ field: 'isEnable', headerName: '是否启用', editable: false },
{ field: 'createAt', headerName: '创建时间', editable: false },
{ field: 'createBy', headerName: '创建人', editable: false },
{ field: 'updateAt', headerName: '最后更新时间', editable: false },
{ field: 'updateBy', headerName: '更新人', editable: false },
],
pagination: true,
paginationPageSize: 50,
// suppressPaginationPanel
onGridReady(event: GridReadyEvent) {
data.api = event.api
},
},
};
</script>
<template> <template>
<div class="roles"> <div class="dashboard flex-column-container">
roles <div class="tools flex-item-fixed">
</div> <ElButton :icon="Search">查询</ElButton>
<ElButton :icon="Plus">新增</ElButton>
<ElButton :icon="Delete" type="danger" :plain="true">删除</ElButton>
</div>
<DataForm
class="query-form flex-item-fixed"
style="width: 500px;"
:data="state.queryData"
:formFields="data.formFields"
:columnCount="2"
layout="bothFixed"
labelWidth="85px"
inputWidth="200px"
/>
<AgGridVue
ref="gridRef"
:class="['ag-theme-alpine', 'yv-table', 'hi-light-selected-row','allow-vertical-line', 'flex-item-fill']"
v-bind="{...data.gridSetting}"
:modelValue="state.grid1Data"
>
</AgGridVue>
</div>
</template> </template>
<script setup>
</script>
<style lang="less">
.dashboard{
<style scoped>
.dashboard {
height: 100%;
}
.tools {
margin-bottom: 8px;
}
.query-form {
height: unset;
} }
</style> </style>

130
src/views/user/users.vue

@ -1,12 +1,128 @@
<script setup lang="ts">
import { reactive } from "vue";
import { ElButton } from "element-plus";
import { Delete, Plus, Search } from "@element-plus/icons-vue";
import DataForm from "@/components/data-form/DataForm.vue";
import type { FormField } from "@/components/data-form/DataFormTypes.ts";
import { AgGridVue } from "ag-grid-vue3";
import type { GridOptions } from "ag-grid-enterprise";
import type { GridApi, GridReadyEvent } from "ag-grid-community";
import { localeText as localeTextCn } from "@/components/yvTable/yv-aggrid-cn.locale";
// Props
interface ComponentProps {
}
// props
const props = withDefaults(defineProps<ComponentProps>(), {});
// State
interface ComponentState {
queryData: any;
grid1Data: Array<any>;
}
// state
const state = reactive<ComponentState>({
queryData: {},
grid1Data: [],
});
// Data
interface ComponentData {
formFields?: Array<FormField>;
gridSetting: Partial<GridOptions>;
api?: GridApi;
}
//
const data: ComponentData = {
formFields: [
{
dataPath: 'loginName', label: '用户登录名', input: 'Input',
inputProps: {
placeholder: '用户登录名',
clearable: true,
}
},
{
dataPath: 'isEnable', label: '是否启用', input: 'SelectV2',
inputProps: {
placeholder: "是否启用",
clearable: true,
options: [
{ value: "0", label: "禁用" },
{ value: "1", label: "启用" },
],
}
},
],
gridSetting: {
localeText: localeTextCn,
// suppressNoRowsOverlay: true,
// suppressLoadingOverlay: true,
//
rowSelection: "single",
columnDefs: [
{ field: 'id', headerName: 'id', editable: false, hide: true },
{ field: 'loginName', headerName: '登录名', editable: false },
{ field: 'password', headerName: '密码', editable: false, hide: true },
{ field: 'userName', headerName: '用户名', editable: false },
{ field: 'isEnable', headerName: '是否启用', editable: false },
{ field: 'createAt', headerName: '创建时间', editable: false },
{ field: 'createBy', headerName: '创建人', editable: false },
{ field: 'updateAt', headerName: '最后更新时间', editable: false },
{ field: 'updateBy', headerName: '更新人', editable: false },
],
pagination: true,
paginationPageSize: 50,
// suppressPaginationPanel
onGridReady(event: GridReadyEvent) {
data.api = event.api
},
},
};
</script>
<template> <template>
<div class="dashboard"> <div class="dashboard flex-column-container">
users <div class="tools flex-item-fixed">
</div> <ElButton :icon="Search">查询</ElButton>
<ElButton :icon="Plus">新增</ElButton>
<ElButton :icon="Delete" type="danger" :plain="true">删除</ElButton>
</div>
<DataForm
class="query-form flex-item-fixed"
style="width: 500px;"
:data="state.queryData"
:formFields="data.formFields"
:columnCount="2"
layout="bothFixed"
labelWidth="85px"
inputWidth="200px"
/>
<AgGridVue
ref="gridRef"
:class="['ag-theme-alpine', 'yv-table', 'hi-light-selected-row','allow-vertical-line', 'flex-item-fill']"
v-bind="{...data.gridSetting}"
:modelValue="state.grid1Data"
>
</AgGridVue>
</div>
</template> </template>
<script setup>
</script>
<style lang="less">
.dashboard{
<style scoped>
.dashboard {
height: 100%;
}
.tools {
margin-bottom: 8px;
}
.query-form {
height: unset;
} }
</style> </style>

Loading…
Cancel
Save