【Vue】快餐店收银系统

本文介绍了如何使用Vue.js、Axios和Element UI开发一个快餐店收银系统,包括订单管理、商品列表操作和结算流程。通过表格展示订单,允许用户添加商品、调整数量并计算总价,提供清空和结算功能。
摘要由CSDN通过智能技术生成

功能介绍

在这里插入图片描述
在这里插入图片描述
点击商品列表中的商品可以将该商品添加到订单,再次点击,可以增加数量,也可以在订单列表中,点击加号增加数量,点击减号减少数量
在这里插入图片描述
提供了计算总数和总价的功能,点击清空按钮,可以清空订单列表,点击结算按钮,可以提交订单

代码

<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>快餐店收银系统</title>
    <link rel="shortcut icon" href="./images/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="./css/style.css">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">

<body>
    <div id="app" v-cloak>
        <el-row>
            <el-col :span="7" id="left-col">
                <div class="left-container">
                    <el-table :data="tableData">
                        <el-table-column prop="name" label="商品名称"> </el-table-column>
                        <el-table-column prop="count" label="数量"> </el-table-column>
                        <el-table-column prop="price" label="价格"> </el-table-column>
                        <el-table-column label="操作" fixed="right">
                            <template slot-scope="scope">
                                <el-button type="text" size="medium" @click="add(scope.row)"><i
                                        class="el-icon-circle-plus-outline"></i>
                                </el-button>
                                <el-button type="text" size="medium" @click="minus(scope.row)"><i
                                        class="el-icon-remove-outline"></i>
                                </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="info" v-show="tableData.length!==0">
                        <span>总数:{{totalCount}}</span>
                        <span>合计:¥{{totalPrice}}</span>
                    </div>
                    <div class="btn">
                        <el-button type="success" round @click="buy">结算</el-button>
                        <el-button type="danger" round @click="clear">清空</el-button>
                    </div>
                </div>
            </el-col>
            <el-col :span="17" id="right-col">
                <el-tabs type="card">
                    <el-tab-pane label="汉堡">
                        <div class="items">
                            <ul>
                                <li v-for="item in type0Items" @click="addItem(item)">
                                    <el-card style="height: 200px; width: 210px;">
                                        <img :src="item.image_src" alt="image" class="image"
                                            style="height: 100px; width: 100px; text-align: center;">
                                        <div style="padding: 5px; text-align: center;">
                                            <span style="color: #999;">{{item.name}}</span>
                                            <div class="bottom clearfix">
                                                <span style="color: red;">¥{{item.price}}</span>
                                            </div>
                                        </div>
                                    </el-card>
                                </li>
                            </ul>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label="饮料">
                        <div class="items">
                            <ul>
                                <li v-for="item in type1Items" @click="addItem(item)">
                                    <el-card style="height: 200px; width: 210px;">
                                        <img :src="item.image_src" alt="image" class="image"
                                            style="height: 100px; width: 100px; text-align: center;">
                                        <div style="padding: 5px; text-align: center;">
                                            <span style="color: #999;">{{item.name}}</span>
                                            <div class="bottom clearfix">
                                                <span style="color: red;">¥{{item.price}}</span>
                                            </div>
                                        </div>
                                    </el-card>
                                </li>
                            </ul>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label="全家桶">
                        <div class="items">
                            <ul>
                                <li v-for="item in type2Items" @click="addItem(item)">
                                    <el-card style="height: 200px; width: 210px;">
                                        <img :src="item.image_src" alt="image" class="image"
                                            style="height: 100px; width: 100px; text-align: center;">
                                        <div style="padding: 5px; text-align: center;">
                                            <span style="color: #999;">{{item.name}}</span>
                                            <div class="bottom clearfix">
                                                <span style="color: red;">¥{{item.price}}</span>
                                            </div>
                                        </div>
                                    </el-card>
                                </li>
                            </ul>
                        </div>
                    </el-tab-pane>
                </el-tabs>
            </el-col>
        </el-row>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="./js/main.js"></script>
    </head>
</body>

</html>

点击获取完整代码

设计思路

Vue+Axios+ElementUI

布局分为左右两栏,左边是订单列表,右边是商品列表

订单列表使用table表格实现,商品列表使用了Tabs标签页

具体使用方法,可以查看ElementUI的官方文档

官方文档

添加商品到订单列表的实现方法:

    addItem: function (item) {
      var flag = false;
      for (var i = 0; i < this.tableData.length; i++) {
        if (item.id === this.tableData[i].id) {
          flag = true;
          this.tableData[i].count++;
          break;
        }
      }
      if (flag === false) {
        this.tableData.push({
          id: item.id,
          name: item.name,
          price: item.price,
          count: 1,
        });
      }
      this.calcTotal();
    }

函数的参数是商品信息,首先,遍历table,判断该商品是否已经在table中了,如果在table中,就将该商品的数量加一,如果不在table中,就将该商品添加到table中,并将数量设置为1,以上操作完成后,重新计算table中商品的总数和总价格

这是一个基于SSM(Spring + Spring MVC + MyBatis)框架和Vue.js的在线收银系统项目。该项目包含了源代码、部署说明、系统介绍以及数据库设计。以下是关于这个项目的简要介绍:源码:本项目提供了完整的源代码,包括前端Vue.js应用和后端SSM框架。这使得开发者可以轻松地理解和修改代码,以满足自己的需求。部署说明:项目中提供了详细的部署说明,指导开发者如何将项目部署到服务器上。部署过程中需要配置数据库连接信息、调整服务器环境等。通过阅读部署说明,开发者可以顺利完成项目的部署工作。系统介绍:项目简介部分详细介绍了在线收银系统的功能和特点。该系统支持多种支付方式,如微信支付、支付宝支付等,同时具备商品管理、订单管理、用户管理等功能。此外,系统还具有一定的安全性和稳定性,能够满足企业级的应用需求。数据库设计:项目中的数据库设计文件详细描述了数据库表结构和关系。这些表包括用户表、商品表、订单表等,用于存储系统中的各种数据。通过对数据库的设计,开发者可以更好地理解系统的架构和数据流程。总之,这个基于SSM+Vue的在线收银系统项目为开发者提供了一个完整的解决方案,可以帮助他们快速搭建一个功能丰富、性能稳定的在线收银系统。通过阅读源码、部署说明和数据库设计文件,开发者可以深入了解项目的实现细节,从而提高自己的开发能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值