vue使用拖拽功能实现仓库存放货物的需求

news2024/11/17 11:45:42

效果:
在这里插入图片描述
代码

<template>
  <div>
    <div class="bigTitle">xxxxxxxxxxxxxx仓库拖拽系统</div>

    <div class="container2 flex-j-space-between">
      <div class="product-list">
        <div class="leftTree head">
          <div class="left">物品清单</div>
        </div>
        <div class="product-container">
          <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item
              class="list"
              v-for="(item,index) in products"
              :title="(index + 1) + '、' + item.name"
              :name="index"
              :key="index"
            >
              <div :draggable="true" @dragstart="onDragStart(item)">
                <span>长度:</span>
                <span>{{ item.x }}</span>
                <span></span>
                <span>宽度:</span>
                <span>{{ item.y }}</span>
                <span></span>
                <span>高度:</span>
                <span>{{ item.h }}</span>
                <span></span>
              </div>
            </el-collapse-item>
          </el-collapse>
        </div>
      </div>

      <div class="delivery-cabinet">
        <div class="leftTree head">
          <div class="left">仓库</div>
        </div>
        <div style="padding-left:48px;">
          <span class="display-inline t-center" style="width:27.6%;"></span>
          <span class="display-inline t-center" style="margin-left:2%;width:18.4%;"></span>
          <span class="display-inline t-center" style="margin-left:2%;width:27.6%;"></span>
          <span class="display-inline t-center" style="margin-left:2%;width:18.4%;"></span>
        </div>
        <div class="flex-j-space-between height100">
          <div class="regionSet">
            <div>D</div>
            <div>C</div>
            <div>B</div>
            <div>A</div>
          </div>
          <div class="bigBox">
            <div
              v-for="(item,index) in cabinets"
              :key="index"
              :style="{width:item.x,height:item.y,marginRight:item.mr}"
              @drop="onDrop(item.id)"
              @dragover.prevent
              :draggable="false"
              class="smallBox"
            >
              <div
                v-for="product in item.products"
                :key="product.id"
                class="product"
                :draggable="false"
              >{{ JSON.parse(product).name }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import draggable from "vuedraggable";

export default {
  components: {
    // draggable
  },
  data() {
    return {
      products: [
        { id: 1, name: "苹果", x: 30, y: 34, h: 25 },
        { id: 2, name: "香蕉", x: 12, y: 10, h: 21 },
        { id: 3, name: "西瓜", x: 30, y: 50, h: 23 },
        { id: 4, name: "荔枝", x: 57, y: 12, h: 24 },
        { id: 5, name: "哈密瓜", x: 45, y: 53, h: 32 },
        { id: 6, name: "菠萝", x: 11, y: 5, h: 54 },
        { id: 7, name: "葡萄", x: 4, y: 34, h: 6 }
      ],
      cabinets: [
        {
          id: 1,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          location: [
            { name: "手表", width: 28, height: 50, x: 0, y: 0, bgClor: "red" },
            {
              name: "背包",
              width: 28,
              height: 16,
              x: 40,
              y: 40,
              bgClor: "#ff33ff"
            },
            {
              name: "缆索",
              width: 10,
              height: 80,
              x: 29,
              y: 0,
              bgClor: "yellow"
            },
            {
              name: "头盔",
              width: 28,
              height: 40,
              x: 40,
              y: 0,
              bgClor: "green"
            },
            { name: "面包", width: 33, height: 70, x: 68, y: 0, bgClor: "blue" }
          ],
          products: []
        },
        {
          id: 2,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 3,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 4,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 5,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 6,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 7,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 8,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 9,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 10,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 11,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 12,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 13,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 14,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 15,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 16,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 17,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 18,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 19,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 20,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 21,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 22,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 23,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 24,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 25,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 26,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 27,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 28,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 29,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 30,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 31,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 32,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 33,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 34,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 35,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 36,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 37,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 38,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: "2%",
          name: 1,
          products: []
        },
        {
          id: 39,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        },
        {
          id: 40,
          x: "9.2%",
          y: "24%",
          mt: 0,
          mb: 0,
          mr: 0,
          name: 1,
          products: []
        }
        // 其他柜子...
      ],
      activeNames: ["1"]
    };
  },
  methods: {
    onDragStart(product) {
      console.log("1111111", product);
      event.dataTransfer.setData("text/plain", JSON.stringify(product));
    },
    onDrop(cabinetId) {
      const productData = event.dataTransfer.getData("text/plain");
      console.log("22222222222", productData);
      const cabinet = this.cabinets.find(cabinet => cabinet.id === cabinetId);
      cabinet.products.push(productData);
      console.log("111", cabinet);
    },
    handleChange(val) {
      console.log(val);
    }
  }
};
</script>

<style scoped>
.bigTitle {
  height: 40px;
  line-height: 40px;
  font-size: 24px;
  text-align: center;
  padding-top: 5px;
}
.container2 {
  width: 100%;
  height: calc(100vh - 40px);
  padding: 10px;
  overflow: hidden;
}
.head {
  border: 0px solid black;
  width: 100%;
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 0 15px;

  border-bottom: #eff4fa 1px solid;
  .left {
    font-weight: bold;
    font-size: 16px;
    border-left: 4px blue solid;
    display: flex;
    align-items: center;
    height: 18px;
    padding-left: 10px;
  }
}
.product-list {
  width: 400px;
  border: 1px solid #f0f0f0;
  height: 100%;
}
.delivery-cabinet {
  height: 100%;
  flex: 1;
}

.product-list h2,
.delivery-cabinet h2 {
  font-size: 24px;
  margin-bottom: 10px;
}

.product-container {
  /* 
  padding: 10px;
  border-radius: 4px; */
}

.product {
  padding: 10px;
  margin-bottom: 8px;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: move;
}

.cabinet-container {
  background-color: #f2f2f2;
  padding: 10px;
  border-radius: 4px;
}

.cabinet-slot {
  padding: 10px;
  margin-bottom: 8px;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.slot-number {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 5px;
}

.slot-content {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.slot-content .product {
  padding: 6px 8px;
  background-color: #eee;
}
.regionSet {
  width: 45px;
  height: 100%;
  margin-top: 10px;
}
.regionSet div {
  height: 23%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bigBox {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  height: calc(100% - 40px);
  width: calc(100% - 50px);
  padding: 10px 10px;
  padding-left: 0px;
}
.smallBox {
  border: 1px solid green;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/838082.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Python入门【​try和except结构、常见异常、with上下文管理 、traceback模块和生成异常日志、自定义异常类】(十八)

&#x1f44f;作者简介&#xff1a;大家好&#xff0c;我是爱敲代码的小王&#xff0c;CSDN博客博主,Python小白 &#x1f4d5;系列专栏&#xff1a;python入门到实战、Python爬虫开发、Python办公自动化、Python数据分析、Python前后端开发 &#x1f4e7;如果文章知识点有错误…

【C++】STL——stack和queue的模拟实现、空间适配器、deque的介绍、增删查改函数的简单实现

文章目录 1.deque的简单介绍2.模拟实现stack3.模拟实现queue 1.deque的简单介绍 deque的介绍文档 deque(双端队列)&#xff1a;是一种双开口的"连续"空间的数据结构&#xff0c;双开口的含义是&#xff1a;可以在头尾两端进行插入和删除操作&#xff0c;且时间复杂度…

实现多线程的三种方式

1. 继承Thread 类实现多线程 想要实现多线程&#xff0c;第一种方法就是通过继承Thread类实现多线程&#xff0c;有以下几步 &#xff08;1&#xff09;我们要先自定义一个类然后继承Thread类&#xff1b; &#xff08;2&#xff09;在继承Trread的类中重写 run 方法&#x…

成功了!|| Poetry安装pytorch || 整理自github项目Poetry下的issue

在使用Poetry安装pytorch的时候&#xff0c;常常会遇到各种问题&#xff1a;首先是使用add添加时&#xff0c;会说只有torch没有什么pytorch&#xff0c;很显然&#xff0c;它是直接针对包的&#xff0c;第二点是&#xff0c;如果是一台没有nvidia显卡的机器&#xff0c;由于po…

CISA《网络安全事件和漏洞响应手册》提到的SSVC是什么?

2021年11月16日&#xff0c;美国网络安全和基础设施安全局(CISA)根据行政命令EO 14028的要求发布了《网络安全事件和漏洞响应手册》。手册规定的漏洞响应过程包括识别、评估、修复、报告通知4个步骤&#xff0c;其中评估部分的第一句话提到“使用特定相关者漏洞分类法(Stakehol…

C++ 动态内存分配

在C中动态内存的分配技术可以保证程序在允许过程中按照实际需要申请适量的内存&#xff0c;使用结束后还可以释放&#xff0c;这种在程序运行过程中申请和释放的存储单元也称为堆。 申请和释放过程一般称为建立和删除。 在C程序中&#xff0c;建立和删除堆对象使用两个运算符&…

html页面input设置日期和时分秒组件方法

html <input class"form-control" type"datetime-local" step"01">效果图

Java根据坐标经纬度计算两点距离(5种方法)、校验经纬度是否在圆/多边形区域内的算法推荐

目录 前言 一、根据坐标经纬度计算两点距离&#xff08;5种方法&#xff09; 1.方法一 2.方法二 3.方法三 4.方法四 5.方法五 5.1 POM引入第三方依赖 5.2 代码 6.测试结果对比 二、校验经纬度是否在制定区域内 1.判断一个坐标是否在圆形区域内 2.判断一个坐标是否…

安防监控国标GB28181平台EasyGBS视频快照无法显示是什么原因?如何解决?

安防视频监控国标视频云服务EasyGBS支持设备/平台通过国标GB28181协议注册接入&#xff0c;并能实现视频的实时监控直播、录像、检索与回看、语音对讲、云存储、告警、平台级联等功能。平台部署简单、可拓展性强&#xff0c;支持将接入的视频流进行全终端、全平台分发&#xff…

【Leetcode刷题】模拟

本篇文章为 LeetCode 模拟模块的刷题笔记&#xff0c;仅供参考。 目录 一. 字符串Leetcode43.字符串相乘Leetcode592.分数加减运算Leetcode68.文本左右对齐 二. 矩阵Leetcode54.螺旋矩阵Leetcode885.螺旋矩阵 IIILeetcode498.对角线遍历Leetcode874.模拟行走机器人 三. 数组Lee…

Aligning Large Language Models with Human: A Survey

本文也是LLM相关的综述文章&#xff0c;针对《Aligning Large Language Models with Human: A Survey》的翻译。 对齐人类与大语言模型&#xff1a;综述 摘要1 引言2 对齐数据收集2.1 来自人类的指令2.1.1 NLP基准2.1.2 人工构造指令 2.2 来自强大LLM的指令2.2.1 自指令2.2.2 …

JavaSE【抽象类和接口】(抽象类、接口、实现多个接口、接口的继承)

一、抽象类 在 Java 中&#xff0c;一个类如果被 abstract 修饰称为抽象类&#xff0c;抽象类中被 abstract 修饰的方法称为抽象方法&#xff0c;抽象方法不用 给出具体的实现体。 1.语法 // 抽象类&#xff1a;被 abstract 修饰的类 public abstract class Shape { …

AI.com的命运之战:马斯克如何从OpenAI手中夺走这个价值千万的域名

一、AI.COM AI.com是一个极具价值的域名&#xff0c;它于1993年5月注册&#xff0c;距今已有近30年的历史。2021年2月&#xff0c;人工智能研究机构OpenAI以至少1100万美元&#xff08;约合人民币7535万元&#xff09;的高价&#xff0c;拿下了这个域名。OpenAI是马斯克在2015…

微信小程序中的分包使用介绍

一、分包的好处 可以优化小程序首次启动的下载时间 在多团队共同开发时可以更好的解耦协作 主包&#xff1a;放置默认启动页面/TabBar 页面&#xff0c;公共资源/JS 脚本 分包&#xff1a;根据开发者的配置进行划分 限制&#xff1a;所有分包大小不超过 20M&#xff0c;单…

私有化部署企业IM即时通讯:提升效率、防止泄密、高效协同办公

随着科技的飞速发展和智能手机的普及&#xff0c;即时通讯&#xff08;IM&#xff09;应用在我们的生活和工作中变得越来越重要。在企业中&#xff0c;IM已成为员工之间交流沟通的主要方式之一。然而&#xff0c;对于大多数企业来说&#xff0c;选择私有化部署企业IM即时通讯软…

Pytorch Tutorial【Chapter 2. Autograd】

Pytorch Tutorial 文章目录 Pytorch TutorialChapter 2. Autograd1. Review Matrix Calculus1.1 Definition向量对向量求导1.2 Definition标量对向量求导1.3 Definition标量对矩阵求导 2.关于autograd的说明3. grad的计算3.1 Manual手动计算3.2 backward()自动计算 Reference C…

解决在mybatis中使用class属性绑定映射文件出现的异常问题~

如下所示&#xff0c;当我在XML文件中通过class属性配置其mapper文件时&#xff0c;出现下述错误 <mappers><mapper class"mappers.userMapper"/> </mappers>错误描述&#xff1a; 解决方法如下所示&#xff1a;在pom.xml文件中添加下述代码 <…

【腾讯云Cloud Studio实战训练营】使用React快速构建点餐H5

文章目录 前言一、Cloud Studio是什么二、Cloud Studio特点三、Cloud Studio使用1.访问官网2.账号注册3.模板选择4.模板初始化5.H5开发安装 antd-mobile安装 Less安装 normalize&#xff1a;上传项目需要的素材&#xff1a;替换App.js主文件&#xff1a;项目启动、展示 6.发布仓…

zookeeper安装教程及其基本使用

目录 zookeeper下载&#xff1a; zookeeper下载官网&#xff1a; 本地安装配置&#xff1a; 启动zookeeper&#xff1a; 开启服务端&#xff1a; 启动客户端&#xff1a; 查看zookeeper的状态&#xff1a; zoo.cfg文件解读&#xff1a; zookeeper的集群安装&#xff1a…