|
@@ -1,16 +1,10 @@
|
|
<template>
|
|
<template>
|
|
<div class="task-main">
|
|
<div class="task-main">
|
|
- <div class="task-main-left">
|
|
|
|
- <div
|
|
|
|
- v-for="{ type, name } in taskTypeArray"
|
|
|
|
- :key="type"
|
|
|
|
- :class="[`${type}-task`, curTaskType === type ? 'active' : '']"
|
|
|
|
- @click="handleChangeTaskType(type)"
|
|
|
|
- >
|
|
|
|
- <span>{{ name }}</span>
|
|
|
|
- <span v-if="type !== TASK_EXPLAIN">0</span>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <LeftSidebar
|
|
|
|
+ :handle-change-task-type="handleChangeTaskType"
|
|
|
|
+ :cur-task-type="curTaskType"
|
|
|
|
+ :cur-task-type-obj="curTaskTypeObj"
|
|
|
|
+ />
|
|
|
|
|
|
<div ref="center" class="task-main-center" :style="{ cursor: mainCursorDisplayStyle }">
|
|
<div ref="center" class="task-main-center" :style="{ cursor: mainCursorDisplayStyle }">
|
|
<template v-if="!isTaskExplain">
|
|
<template v-if="!isTaskExplain">
|
|
@@ -19,7 +13,12 @@
|
|
<span>{{ (scale * 100).toFixed(0) }}%</span>
|
|
<span>{{ (scale * 100).toFixed(0) }}%</span>
|
|
<svg-icon icon-class="add" class-name="zoom-display-add" />
|
|
<svg-icon icon-class="add" class-name="zoom-display-add" />
|
|
</span>
|
|
</span>
|
|
- <div class="task-main-center-container" :style="{ transform: `scale(${scale})` }">
|
|
|
|
|
|
+ <div
|
|
|
|
+ class="task-main-center-container"
|
|
|
|
+ :style="{ transform: `scale(${scale})` }"
|
|
|
|
+ @dragover="dragover"
|
|
|
|
+ @drop="drop"
|
|
|
|
+ >
|
|
<div class="create-task">
|
|
<div class="create-task">
|
|
<svg-icon icon-class="add" class-name="create-task-add" />
|
|
<svg-icon icon-class="add" class-name="create-task-add" />
|
|
<span>创建{{ curTaskTypeObj.name }}</span>
|
|
<span>创建{{ curTaskTypeObj.name }}</span>
|
|
@@ -32,43 +31,46 @@
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div v-show="!isTaskExplain" class="task-main-right">
|
|
<div v-show="!isTaskExplain" class="task-main-right">
|
|
- <div v-for="{ type, name, image } in taskClassify" :key="type" class="task-classify-item">
|
|
|
|
|
|
+ <div
|
|
|
|
+ v-for="{ type, name, image } in taskClassify"
|
|
|
|
+ :key="type"
|
|
|
|
+ :style="{ cursor: type !== MORE_NAME ? 'pointer' : 'default' }"
|
|
|
|
+ class="task-classify-item"
|
|
|
|
+ >
|
|
<span class="task-classify-item-name">{{ name }}</span>
|
|
<span class="task-classify-item-name">{{ name }}</span>
|
|
- <img :src="image" :alt="name" />
|
|
|
|
|
|
+ <img
|
|
|
|
+ :src="image"
|
|
|
|
+ :alt="name"
|
|
|
|
+ :draggable="type !== MORE_NAME"
|
|
|
|
+ @dragstart="dragstart($event, type)"
|
|
|
|
+ @dragend="dragend"
|
|
|
|
+ />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import { ref, onMounted, onUnmounted } from 'vue';
|
|
|
|
|
|
+import { ref } from 'vue';
|
|
import { useTaskType, useTaskClassify } from './taskType.js';
|
|
import { useTaskType, useTaskClassify } from './taskType.js';
|
|
-import TaskExplain from './TaskExplain.vue';
|
|
|
|
import { mouseEvent } from './mouseEvent.js';
|
|
import { mouseEvent } from './mouseEvent.js';
|
|
|
|
+import { handleWheel } from './wheel.js';
|
|
|
|
+import { handleDrag } from './drag.js';
|
|
|
|
|
|
-const { curTaskType, curTaskTypeObj, taskTypeArray, isTaskExplain, TASK_EXPLAIN, handleChangeTaskType } = useTaskType();
|
|
|
|
|
|
+import TaskExplain from './TaskExplain/index.vue';
|
|
|
|
+import LeftSidebar from './LeftSidebar.vue';
|
|
|
|
|
|
-const { taskClassify } = useTaskClassify();
|
|
|
|
|
|
+const center = ref(); // vue3 获取 refs 写法,需要同名,且传空
|
|
|
|
|
|
-const scale = ref(1); // 缩放比例
|
|
|
|
-const { mainCursorDisplayStyle, center } = mouseEvent();
|
|
|
|
|
|
+const { curTaskType, curTaskTypeObj, isTaskExplain, handleChangeTaskType } = useTaskType();
|
|
|
|
|
|
-// 处理 ctrl + 滚轮事件
|
|
|
|
-function handleCtrlAndWheel(e) {
|
|
|
|
- if (e.ctrlKey) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- scale.value = e.deltaY > 0 ? Math.max(0.5, scale.value - 0.1) : Math.min(2, scale.value + 0.1);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+const { taskClassify, MORE_NAME } = useTaskClassify();
|
|
|
|
+
|
|
|
|
+const { mainCursorDisplayStyle } = mouseEvent(center);
|
|
|
|
|
|
-onMounted(() => {
|
|
|
|
- // ctrl + 滚轮事件
|
|
|
|
- center.value.addEventListener('wheel', handleCtrlAndWheel);
|
|
|
|
-});
|
|
|
|
|
|
+const { scale } = handleWheel(center);
|
|
|
|
|
|
-onUnmounted(() => {
|
|
|
|
- center.value.removeEventListener('wheel', handleCtrlAndWheel);
|
|
|
|
-});
|
|
|
|
|
|
+const { dragstart, dragover, dragend, drop } = handleDrag();
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
@@ -79,54 +81,6 @@ $basic-background-color: #f7f7f7;
|
|
min-height: calc(100% - 98px);
|
|
min-height: calc(100% - 98px);
|
|
letter-spacing: 0.01em;
|
|
letter-spacing: 0.01em;
|
|
|
|
|
|
- &-left {
|
|
|
|
- width: 154px;
|
|
|
|
- padding: 16px 0 16px 8px;
|
|
|
|
- background-color: $basic-background-color;
|
|
|
|
-
|
|
|
|
- .explain-task {
|
|
|
|
- width: 138px;
|
|
|
|
- height: 28px;
|
|
|
|
- padding: 2px 16px;
|
|
|
|
- margin-bottom: 14px;
|
|
|
|
- font-weight: bold;
|
|
|
|
- line-height: 22px;
|
|
|
|
- text-align: center;
|
|
|
|
- cursor: pointer;
|
|
|
|
- background-color: #fff;
|
|
|
|
- border: 1px solid $border-color;
|
|
|
|
- border-radius: 20px;
|
|
|
|
-
|
|
|
|
- &.active {
|
|
|
|
- color: #fff;
|
|
|
|
- background-color: v-bind('curTaskTypeObj.active_color');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- .pre-task,
|
|
|
|
- .mid-task,
|
|
|
|
- .after-task {
|
|
|
|
- display: flex;
|
|
|
|
- justify-content: space-between;
|
|
|
|
- width: 146px;
|
|
|
|
- height: 28px;
|
|
|
|
- padding: 2px 8px;
|
|
|
|
- margin-top: 8px;
|
|
|
|
- font-weight: bold;
|
|
|
|
- line-height: 22px;
|
|
|
|
- color: #fff;
|
|
|
|
- text-transform: uppercase;
|
|
|
|
- cursor: pointer;
|
|
|
|
- background-color: #cfcfcf;
|
|
|
|
- border: 1px solid $border-color;
|
|
|
|
- border-radius: 4px 0 0 4px;
|
|
|
|
-
|
|
|
|
- &.active {
|
|
|
|
- background-color: v-bind('curTaskTypeObj.active_color');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
&-center {
|
|
&-center {
|
|
flex: 1;
|
|
flex: 1;
|
|
overflow: auto;
|
|
overflow: auto;
|