Browse Source

Merge remote-tracking branch 'origin/master'

master
修宁 6 months ago
parent
commit
7a84b4bece
  1. 313
      src/editor/propEditors/BayEditor.vue
  2. 4
      src/editor/widgets/property/PropertyPanel.vue
  3. 2
      src/editor/widgets/property/PropertyPanelConstant.ts
  4. 11
      src/modules/rack/RackPropertySetter.ts

313
src/editor/propEditors/BayEditor.vue

@ -0,0 +1,313 @@
<script setup lang="ts">
import { computed, reactive } from "vue";
import { ElButton, ElDivider, ElFormItem, ElIcon, ElInputNumber, useFormItem } from "element-plus";
import { CopyDocument, Delete } from "@element-plus/icons-vue";
import { Typeof } from "@ease-forge/shared";
defineOptions({
name: 'BayEditor',
});
interface DtBay {
/** 列的宽度 */
bayWidth: number;
/** 列偏移 */
offset: number;
/** 每层的高度 */
levelHeight: Array<number>;
}
type DtBays = Array<DtBay>;
//
const emit = defineEmits<{
/** 更新内联表格数据 */
"update:modelValue": [value: DtBays];
}>();
// Props
interface BayEditorProps {
modelValue: DtBays;
}
// props
const props = withDefaults(defineProps<BayEditorProps>(), {});
// State
interface BayEditorState {
numberOfBays: number;
numberOfLevels: number;
widthOfBays: number;
heightOfLevels: number;
selectIdx?: number;
}
// state
const state = reactive<BayEditorState>({
numberOfBays: props.modelValue?.length ?? 1,
numberOfLevels: props.modelValue?.[0]?.levelHeight?.length ?? 1,
widthOfBays: props.modelValue?.[0]?.bayWidth ?? 1,
heightOfLevels: props.modelValue?.[0]?.levelHeight?.length ?? 1,
});
// Data
interface BayEditorData {
labelWidth: number;
}
//
const data: BayEditorData = {
labelWidth: 110,
};
const { formItem } = useFormItem();
const list = computed(() => props.modelValue ?? []);
const selectDay = computed(() => {
if (Typeof.noValue(state.selectIdx)) return;
return props.modelValue?.[state.selectIdx];
});
function setSelectIdx(idx: number) {
state.selectIdx = idx;
}
function applyBasicSettings() {
}
function deleteBay() {
}
function copyBay() {
}
interface BayEditorExpose {
state: BayEditorState;
data: BayEditorData;
}
const expose: BayEditorExpose = {
state,
data,
};
//
defineExpose(expose);
export type {
BayEditorProps,
BayEditorState,
}
</script>
<template>
<div class="bay-editor">
<ElDivider class="bay-editor-title" contentPosition="left">Basic</ElDivider>
<div class="flex-column-container bay-editor-basic" style="gap: 8px;">
<div class="flex-row-container">
<ElFormItem label="Number of Bays" :labelWidth="data.labelWidth">
<ElInputNumber :controls="false" v-model="state.numberOfBays"/>
</ElFormItem>
<ElFormItem label="Number of Levels" :labelWidth="data.labelWidth">
<ElInputNumber :controls="false" v-model="state.numberOfLevels"/>
</ElFormItem>
</div>
<div class="flex-row-container">
<ElFormItem label="Width of Bays" :labelWidth="data.labelWidth">
<ElInputNumber :controls="false" v-model="state.widthOfBays"/>
</ElFormItem>
<ElFormItem label="Height of Levels" :labelWidth="data.labelWidth">
<ElInputNumber :controls="false" v-model="state.heightOfLevels"/>
</ElFormItem>
</div>
<div class="flex-row-container">
<div style="width: 248px;"/>
<ElButton size="small" @click="applyBasicSettings">Apply Basic Settings</ElButton>
</div>
</div>
<ElDivider class="bay-editor-title" contentPosition="left">Advanced</ElDivider>
<div class="flex-row-container bay-editor-advanced">
<div class="flex-item-fixed flex-column-container bay-editor-bay-list">
<div class="flex-item-fixed tools-button-container">
<ElIcon :class="['tools-button-icon', { 'tools-button-disabled': false }]" @click="copyBay">
<CopyDocument/>
</ElIcon>
<ElIcon :class="['tools-button-icon', { 'tools-button-disabled': false }]" @click="deleteBay">
<Delete/>
</ElIcon>
</div>
<div class="flex-item-fill bay-editor-bay-list-name">
<div
v-for="(item, idx) in list"
:class="[
'list-item',
{
'list-item-select': state.selectIdx === idx,
},
]"
@click="setSelectIdx(idx)"
>
{{ `Bay ${idx + 1}` }}
</div>
</div>
</div>
<div v-if="selectDay" class="flex-item-fill flex-column-container bay-editor-bay-info">
<div class="flex-item-fixed">
<ElFormItem label="Bay Width" :labelWidth="80">
<ElInputNumber :controls="false" :modelValue="selectDay.bayWidth"/>
</ElFormItem>
<div style="height: 8px;"/>
<ElFormItem label="Bay Offset" :labelWidth="80">
<ElInputNumber :controls="false" :modelValue="selectDay.offset"/>
</ElFormItem>
</div>
<div>Level Heights</div>
<div class="flex-item-fill bay-editor-bay-info-level-height">
<ElFormItem
v-for="(levelHeight, idx) in selectDay.levelHeight"
:label="`Level ${idx+1}`"
:labelWidth="64"
>
<ElInputNumber :controls="false" :modelValue="levelHeight"/>
</ElFormItem>
</div>
</div>
<div v-else class="flex-item-fill bay-editor-bay-empty">
Select One Bay
</div>
</div>
</div>
</template>
<style scoped>
.bay-editor {
width: 100%;
}
.bay-editor-title {
height: 12px;
user-select: none;
}
.bay-editor-basic :deep(.el-input-number) {
width: 80px;
}
.bay-editor-advanced {
height: 256px;
}
.bay-editor-bay-list {
width: 72px;
}
.bay-editor-bay-list-name {
border: 1px solid #dddddd;
}
.tools-button-container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
gap: 4px;
cursor: pointer;
width: 100%;
}
.tools-button-container > .tools-button-icon {
color: #8c8c8c;
padding: 4px;
font-size: 22px;
border-radius: 2px;
}
.tools-button-container > .tools-button-icon:hover {
color: #595959;
background-color: #d9d9d9;
}
.tools-button-container > .tools-button-icon:active {
color: #434343;
background-color: #bfbfbf;
}
.tools-button-container > .tools-button-disabled {
cursor: not-allowed;
}
.tools-button-container > .tools-button-disabled.tools-button-icon,
.tools-button-container > .tools-button-disabled.tools-button-icon:hover,
.tools-button-container > .tools-button-disabled.tools-button-icon:active {
color: #d9d9d9;
background-color: unset;
pointer-events: none;
}
.list-item {
padding: 4px 0 4px 2px;
cursor: pointer;
border-bottom: 1px solid #f0f0f0;
user-select: none;
color: #262626;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.list-item:hover {
background-color: #f0f0f0;
}
.list-item:active {
background-color: #dddddd;
}
.list-item.list-item-select,
.list-item.list-item-select:hover,
.list-item.list-item-select:active {
background-color: #d9d9d9;
}
.bay-editor-bay-info {
padding-left: 6px;
}
.bay-editor-bay-info-level-height {
border: 1px solid #dddddd;
}
.bay-editor-bay-info-level-height :deep(.el-input__wrapper) {
border: none;
outline: none;
box-shadow: none;
}
.bay-editor-bay-info-level-height :deep(.el-form-item) {
border-bottom: 1px solid #dddddd;
}
.bay-editor-bay-info-level-height :deep(.el-form-item > .el-form-item__label) {
border-right: 1px solid #dddddd;
}
.bay-editor-bay-info-level-height :deep(.el-input-number) {
width: 100%;
}
.bay-editor-bay-info-level-height :deep(input[type=number].el-input__inner) {
text-align: left;
}
.bay-editor-bay-empty {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
color: #595959;
background: #f5f5f5;
margin-left: 8px;
}
</style>

4
src/editor/widgets/property/PropertyPanel.vue

@ -77,9 +77,9 @@ function onDataChange(newData: any) {
if (!viewport) return
viewport.stateManager.update(({ getEntity, putEntity }) => {
const data = getEntity(props.data.id)
lodash.merge(data, newData)
lodash.assign(data, newData)
// console.log('onDataChange@1', JSON.stringify(data.dt))
putEntity(data)
console.log('onDataChange@1', JSON.stringify(data.tf))
})
}

2
src/editor/widgets/property/PropertyPanelConstant.ts

@ -4,6 +4,7 @@ import type { PropertyFieldSetter } from "@/core/base/PropertyTypes.ts";
import { dataFormInputComponents } from "@/components/data-form/DataFormConstant.ts";
import TransformEditor from "@/editor/propEditors/TransformEditor.vue";
import InOutCenterEditor from "@/editor/propEditors/InOutCenterEditor.vue";
import BayEditor from "@/editor/propEditors/BayEditor.vue";
const defDataFormProps: DataFormProps = {
columnCount: 1,
@ -14,6 +15,7 @@ const defDataFormProps: DataFormProps = {
dataFormInputComponents.TransformEditor = markRaw<any>(TransformEditor);
dataFormInputComponents.InOutCenterEditor = markRaw<any>(InOutCenterEditor);
dataFormInputComponents.BayEditor = markRaw<any>(BayEditor);
const basicFieldsSetter: Array<PropertyFieldSetter> = [
{

11
src/modules/rack/RackPropertySetter.ts

@ -29,11 +29,11 @@ const propertySetter: PropertySetter = {
dataPath: 'dt.columnSpacing', label: '支脚跨越', input: 'InputNumber',
inputProps: {},
},
// {
// dataPath: 'dt.bays', input: 'BayEditor',
// inputProps: {
// },
// },
{
dataPath: 'dt.bays', input: 'BayEditor',
inputProps: {
},
},
/**
* dt.bays 53
* {
@ -47,6 +47,7 @@ const propertySetter: PropertySetter = {
* bays: [ // 每列的配置
* {
* bayWidth: 1.6, // 列的宽度
* offset: // 列偏移
* levelHeight: [ 1.4, 1.4, 1.4 ] // 每层的高度
* },
* {bayWidth: 1.6, levelHeight: [ 1.4, 1.4, 1.4 ]},

Loading…
Cancel
Save