Vue进阶之Vue无代码可视化项目(七)

右侧栏配置——配置面板

右侧栏配置主要是表单相关的内容,表单处理是开发中用的特别多的场景;今天从架构师的视角来看下这个表单怎么设计,动态表单、复杂表单、表单联动。

  • src
    • components
    • RightPanel.vue

components/RightPanel.vue

先将左侧栏复制一份粘到右侧栏上

<script setup lang="ts">
import {
     Lightning, Share } from '@icon-park/vue-next'
import {
      ref } from 'vue';

import {
     SmoothDndContainer} from '@/components/SmoothDnd/SmoothDndContainer'
import {
     SmoothDndDraggable} from '@/components/SmoothDnd/SmoothDndDraggable'

type Mode = 'outline'|'blocks'|null
const mode = ref<Mode>(null)

const toggleMode = (newMode:Mode) => {
     
  if(newMode === mode.value){
     
    mode.value = null
  }else{
     
    mode.value = newMode
  }
}
</script>

<template>
  <div class="left-panel-wrapper">
    <div class="left-panel-left">
      <div class="btn" :class="{active:mode==='outline'}" @click="()=>toggleMode('outline')">
        <Lightning />
      </div>
      <div class="btn" :class="{active:mode==='blocks'}" @click="()=>toggleMode('blocks')">
        <Share />
      </div>
    </div>
    <!-- 接入动画 -->
    <transition name="app-left-panel-drawer">
      <div class="left-panel-content" v-show="mode">
          {
  {mode}}
          <!-- 面板中使用SmoothDnd -->
          <SmoothDndContainer class="block-group" 
          behaviour="copy"
          tag="div"  group-name="blocks" 
          @drag-start="(e,v)=>console.log(e,v)" 
          @drag-leave="(e,v)=>console.log(e,v)"
          @drop="(e)=>console.log('drop',e)"
          :get-child-payload="(index:number)=>index+1"
          >
            <SmoothDndDraggable v-for="i in 10" :key="i">
              <div class="block-item">{
  {i}}</div>
            </SmoothDndDraggable>
          </SmoothDndContainer>
       </div>
    </transition>
  </div>
</template>

<style scoped>
.left-panel-wrapper {
     
  display: flex;
  height: 100%;
  background-color: #f5f5f5;
  border: 1px solid #e8e8e8;
}
.left-panel-left{
     
  display: flex;
  padding:0 10px;
  flex-direction: column;
  align-items: center;
  width: 50px;
  height: 100%;
  background-color: #e8e8e8;
}
.btn{
     
  width: 32px;
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border-radius: 6px;
  margin-top:20px;
  /* &:hover{
    background-color: #f5f5f5;
  } */
}
.btn:hover{
     
  background-color: #f5f5f5;
}
/* 被激活时候的特定样式 */
.btn.active{
     
  background-color: rgb(0,196,83);
  color: #fff;
}
.left-panel-content{
     
  flex: 1;
  width: 280px;
  height: 100%;
  background-color: #f5f5f5;
  overflow: hidden;
}

/* 下面我们会解释这些 class 是做什么的 */
.app-left-panel-drawer-enter-active,
.app-left-panel-drawer-leave-active {
     
  transition: width 0.1s cubic-bezier(0.3, 0.1, 0.3, 1);
}

.app-left-panel-drawer-enter-from,
.app-left-panel-drawer-leave-to {
     
  width: 0;
}

.app-left-panel-drawer-content {
     
  width: calc(var(--panel-width) - 60px);
  height: 100%;
  padding: 16px;
}

.block-item{
     
  width: 40px;
  height: 40px;
  background-color: #fff;
  border: 1px solid #e8e8e8;
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  transition:background-color 0.3s

相关推荐

  1. VueVue代码项目

    2024-07-19 16:20:05       20 阅读
  2. VueVue代码项目(六)

    2024-07-19 16:20:05       20 阅读
  3. R:Venn图版本

    2024-07-19 16:20:05       28 阅读
  4. Pandas —— 数据转换、聚合与

    2024-07-19 16:20:05       25 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 16:20:05       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 16:20:05       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 16:20:05       58 阅读
  4. Python语言-面向对象

    2024-07-19 16:20:05       69 阅读

热门阅读

  1. Gmsh教程

    2024-07-19 16:20:05       20 阅读
  2. 在 Ubuntu Server 22.04 上安装 Docker 的详细步骤

    2024-07-19 16:20:05       20 阅读
  3. 航班管理系统【C语言版】单文件编写

    2024-07-19 16:20:05       18 阅读