123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <script setup lang="ts">
- import { computed, onMounted, onUnmounted, ref } from "vue";
- import { deepClone } from "@meta2d/core";
- import { monitorRoomData } from "./pens/monitorRoom";
- import { monitorNoRoomData } from "./pens/monitorNoRoom";
- import { monitorPointData } from "./pens/monitorPoint";
- type AssetsType = "space" | "monitor";
- const activeAssets = ref<AssetsType>("space");
- const monitorPoints = ref([
- { name: "3F-R1", disabled: true },
- { name: "3F-R2", data: monitorPointData },
- ]);
- const roomList = [
- {
- id: 1,
- name: "有监测点房间",
- cssClass: "space-item-has-monitor",
- data: monitorRoomData,
- },
- {
- id: 2,
- name: "无监测点房间",
- cssClass: "space-item-no-monitor",
- data: monitorNoRoomData,
- },
- ];
- const isSpacePanel = computed(() => {
- return activeAssets.value === "space";
- });
- const isMonitorPanel = computed(() => {
- return activeAssets.value === "monitor";
- });
- onMounted(() => {
- document.addEventListener("dragstart", dragstart, false);
- document.addEventListener("dragend", dragend, false);
- });
- onUnmounted(() => {
- document.removeEventListener("dragstart", dragstart);
- document.removeEventListener("dragend", dragend);
- });
- const dragstart = (event: any) => {
- event.target.style.opacity = 0.5;
- };
- const dragend = (event: any) => {
- event.target.style.opacity = 1;
- };
- const handleDragStart = async (item: any) => {
- if (!item) {
- return;
- }
- let { data } = item;
- if (!Array.isArray(data)) {
- data = deepClone([data]);
- }
- meta2d.canvas.addCaches = data;
- };
- const assetsChange = () => {
- return;
- };
- </script>
- <template>
- <div class="graphics">
- <div class="group-asset">
- <t-radio-group
- v-model="activeAssets"
- @change="assetsChange"
- variant="primary-filled"
- >
- <t-radio-button value="space">{{ $t("空间组件") }}</t-radio-button>
- <t-radio-button value="monitor">{{ $t("监测点") }}</t-radio-button>
- </t-radio-group>
- </div>
- <div :class="['groups-panel', { 'groups-panel-monitor': isMonitorPanel }]">
- <div v-show="isSpacePanel">
- <div class="space-item" v-for="item in roomList" :key="item.id">
- <div class="space-item-title">{{ $t(item.name) }}</div>
- <div
- :class="item.cssClass"
- :draggable="true"
- @dragstart="handleDragStart(item)"
- @click.stop="handleDragStart(item)"
- @touchstart.passive="handleDragStart(item)"
- ></div>
- </div>
- </div>
- <div v-show="isMonitorPanel">
- <div
- :class="['monitor-item', { 'monitor-item-disabled': item.disabled }]"
- v-for="(item, index) in monitorPoints"
- :key="index"
- :draggable="!item.disabled"
- @dragstart="handleDragStart(item)"
- @click.stop="handleDragStart(item)"
- @touchstart.passive="handleDragStart(item)"
- >
- <div class="monitor-item-circle"></div>
- <div class="monitor-item-title">{{ item.name }}</div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <style lang="postcss" scoped>
- .graphics {
- display: flex;
- flex-direction: column;
- background-color: #f5f7fa;
- .group-asset {
- height: 48px;
- align-items: center;
- display: flex;
- padding: 8px 16px;
- background-color: #fff;
- border-bottom: 1px solid #e4e7ed;
- .t-radio-group.t-radio-group--filled {
- padding: 0px;
- height: 32px;
- background-color: #fff;
- .t-radio-button::before {
- content: none;
- }
- }
- :deep(.t-radio-button__label) {
- margin: auto;
- }
- .t-radio-button {
- width: 88px;
- height: 32px;
- border-radius: 4px;
- padding: 0px;
- color: #000;
- &:hover {
- color: var(--color-primary);
- }
- &.t-is-checked {
- background-color: var(--color-primary) !important;
- color: #fff !important;
- }
- }
- }
- .groups-panel {
- flex: 1;
- overflow-y: auto;
- padding: 24px 16px;
- .space-item {
- .space-item-title {
- font-weight: 500;
- font-size: 12px;
- color: rgba(0, 0, 0, 0.65);
- line-height: 22px;
- margin-bottom: 8px;
- }
- .space-item-has-monitor {
- height: 140px;
- background: #fff;
- border-radius: 12px;
- cursor: pointer;
- }
- .space-item-no-monitor {
- height: 140px;
- background: repeating-linear-gradient(
- -60deg,
- #f1f1f1,
- #f1f1f1 7px,
- #d4d8d7 7px,
- #d4d8d7 14px
- );
- border-radius: 12px;
- cursor: pointer;
- }
- & + .space-item {
- margin-top: 24px;
- }
- }
- .monitor-item {
- height: 56px;
- background-color: #fff;
- border-radius: 8px;
- padding: 16px;
- display: flex;
- align-items: center;
- cursor: pointer;
- .monitor-item-circle {
- position: relative;
- width: 24px;
- height: 24px;
- background-color: rgba(103, 194, 58, 0.3);
- border-radius: 50%;
- margin-right: 12px;
- &::before {
- position: absolute;
- top: 6px;
- left: 6px;
- display: block;
- content: "";
- width: 12px;
- height: 12px;
- background-color: rgba(103, 194, 58, 0.6);
- border-radius: 50%;
- }
- &::after {
- position: absolute;
- top: 9px;
- left: 9px;
- display: block;
- content: "";
- width: 6px;
- height: 6px;
- background-color: rgba(103, 194, 58, 1);
- border-radius: 50%;
- }
- }
- .monitor-item-title {
- font-weight: 500;
- font-size: 12px;
- color: rgba(0, 0, 0, 0.65);
- line-height: 22px;
- user-select: none;
- }
- & + .monitor-item {
- margin-top: 8px;
- }
- }
- .monitor-item-disabled {
- background-color: initial;
- cursor: not-allowed;
- .monitor-item-title {
- color: rgba(0, 0, 0, 0.25);
- }
- }
- }
- .groups-panel-monitor {
- padding: 8px;
- }
- }
- </style>
|