This commit is contained in:
GeDashi 2024-12-23 00:16:03 +08:00
parent 27d61cbca7
commit e4e7e20767
9 changed files with 751 additions and 129 deletions

View File

@ -36,7 +36,7 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "5.0.5",
"sass": "1.77.5",
"sass": "^1.77.5",
"unplugin-auto-import": "0.17.6",
"unplugin-vue-setup-extend-plus": "1.0.1",
"vite": "5.3.2",

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询推荐表列表
export function listRecommend(query) {
return request({
url: '/system/recommend/list',
method: 'get',
params: query
})
}
// 查询推荐表详细
export function getRecommend(id) {
return request({
url: '/system/recommend/' + id,
method: 'get'
})
}
// 新增推荐表
export function addRecommend(data) {
return request({
url: '/system/recommend',
method: 'post',
data: data
})
}
// 修改推荐表
export function updateRecommend(data) {
return request({
url: '/system/recommend',
method: 'put',
data: data
})
}
// 删除推荐表
export function delRecommend(id) {
return request({
url: '/system/recommend/' + id,
method: 'delete'
})
}

44
src/api/system/shopcar.js Normal file
View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询购物车列表
export function listShopcar(query) {
return request({
url: '/system/shopcar/list',
method: 'get',
params: query
})
}
// 查询购物车详细
export function getShopcar(id) {
return request({
url: '/system/shopcar/' + id,
method: 'get'
})
}
// 新增购物车
export function addShopcar(data) {
return request({
url: '/system/shopcar',
method: 'post',
data: data
})
}
// 修改购物车
export function updateShopcar(data) {
return request({
url: '/system/shopcar',
method: 'put',
data: data
})
}
// 删除购物车
export function delShopcar(id) {
return request({
url: '/system/shopcar/' + id,
method: 'delete'
})
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -1,73 +1,45 @@
// 基础颜色
$blue: #87ceeb; // 天空蓝
$light-blue: #b3e5fc; // 更浅的天蓝色
$red: #ff69b4; // 草莓红
$pink: #ff87ce; // 樱桃粉
$green: #90ee90; // 淡绿色
$tiffany: #7bf2b3; // 蒂芙尼蓝
$yellow: #f4d03f; // 柠檬黄
$panGreen: #90ee90; // 淡绿色
// base color
$blue: #121c33; // 深空蓝 [ty-reference](20)
$light-blue: #4A69BD; // 稍浅的深空蓝
$red: #D81E5B; // 深空红带有神秘气息
$pink: #FF7CAC; // 深空粉柔和而神秘
$green: #00C851; // 深空绿象征生命与希望
$tiffany: #21D4FD; // 深空青如同星空中闪烁的光芒
$yellow: #FEE440; // 深空黄像是遥远恒星发出的光
$panGreen: #00C851;
// 默认菜单主题风格
$base-menu-color: #f0f0f0; // 非常浅的灰色
$base-menu-color-active: #ffffff; // 活跃时白色
$base-menu-background: #f0f0f0; // 背景浅灰
$base-logo-title-color: #333; // 标题深灰色
// 默认菜单主题风格 - 深空神秘版
$base-menu-color: hsla(0, 0%, 100%, .7); // 浅灰色带透明度模拟星光
$base-menu-color-active: #ffffff;
$base-menu-background: #0f1a2b; // 深空背景
$base-logo-title-color: #e0e0e0; // 类似于银河中的微光
$base-menu-light-color: rgba(0, 0, 0, 0.6); // 深一点的浅灰色
$base-menu-light-background: #ffffff; // 亮背景白色
$base-logo-light-title-color: #333; // 亮标题深灰色
$base-menu-light-color: rgba(255, 255, 255, 0.8);
$base-menu-light-background: #1d2b44;
$base-logo-light-title-color: #e0e0e0;
$base-sub-menu-background: #e0e0e0; // 子菜单背景浅灰色
$base-sub-menu-hover: #d1d1d1; // 子菜单悬停浅灰色
$base-sub-menu-background: #121c33;
$base-sub-menu-hover: #0c192b;
// 字体
$font-stack: '楷体', 'Comic Sans MS', cursive, sans-serif; // 使用楷体或Comic Sans字体增加可爱感
// 字体设置
$body-font-family: 'Roboto', sans-serif; // 选择Roboto作为主要字体因为它既现代又易于阅读
$header-font-family: 'Montserrat', sans-serif; // Montserrat用于标题增加一点优雅感
$font-size-base: 1rem;
$line-height-base: 1.5;
$font-weight-normal: 400;
$font-weight-bold: 700;
// 主题颜色
$--color-primary: #6495ed;
$--color-success: #4CAF50;
$--color-warning: #ffeb3b;
$--color-danger: #ff6347;
$--color-info: #9e9e9e;
// 自定义暗色菜单风格
$--color-primary: #21D4FD; // 主要操作按钮颜色如提交或确认
$--color-success: #00C851; // 成功提示信息的颜色
$--color-warning: #FFAB00; // 警告信息颜色
$--color-danger: #D81E5B; // 错误或危险提示颜色
$--color-info: #90CAF9; // 信息提示颜色
$base-sidebar-width: 200px;
$base-sidebar-width: 220px; // 略增宽侧边栏以适应较大的字体尺寸
// 可爱的动画
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-10px);
}
60% {
transform: translateY(-5px);
}
}
// 可爱的样式
.menu-item {
border-radius: 4px; // 圆角
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); // 轻微的阴影
transition: background-color 0.3s ease; // 平滑的背景颜色变化
&:hover {
background-color: lighten($base-menu-background, 5%); // 悬停时背景色变浅
}
&.active {
background-color: $base-menu-color-active; // 活跃状态的背景色
animation: bounce 0.5s infinite; // 添加可爱的跳动动画
}
}
// 可爱的字体
body {
font-family: $font-stack;
}
// 导出变量供JS使用
// the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
:export {
menuColor: $base-menu-color;
menuLightColor: $base-menu-light-color;
@ -84,4 +56,10 @@ body {
dangerColor: $--color-danger;
infoColor: $--color-info;
warningColor: $--color-warning;
bodyFontFamily: $body-font-family;
headerFontFamily: $header-font-family;
fontSizeBase: $font-size-base;
lineHeightBase: $line-height-base;
fontWeightNormal: $font-weight-normal;
fontWeightBold: $font-weight-bold;
}

View File

@ -7,7 +7,6 @@
<section class="welcome-section">
<h2>今日新鲜事</h2>
<p>查看今日水果销售情况管理订单和库存</p>
<img src="../assets/images/todaynewthing.png" alt="Fresh News Icon" class="fresh-news-icon"/>
</section>
<section class="quick-actions">
<router-link to="/order-management" class="action-item">
@ -42,18 +41,18 @@
<h3>工作计划</h3>
<div class="calendar-content">
<div class="month">11</div>
<div class="event">11月5日订单管理功能验收任务完成订单管理模块的功能测试与修复确保所有关键流程正常运作并通过内部验收成果提交完整的测试报告并获得产品经理批准</div>
<div class="event">11月18日库存管理文档化任务整理并编写库存管理模块功能说明及相关操作指南成果形成技术文档并存档备案为后续开发提供参考</div>
<div class="event">11月5日订单管理功能验收...</div>
<div class="event">11月18日库存管理文档化...</div>
</div>
<div class="calendar-content">
<div class="month">12</div>
<div class="event">12月5日新品上架功能上线任务实现新品上架页面设计及编码优化用户体验成果完成内部验收并准备好市场推广所需资源</div>
<div class="event">12月18日系统性能优化任务实施服务器负载优化措施并进行压力测试成果确保平台稳定运行出具压力测试报告</div>
<div class="event">12月5日新品上架功能上线...</div>
<div class="event">12月18日系统性能优化...</div>
</div>
<div class="calendar-content">
<div class="month">1</div>
<div class="event">1月5日春节特别版规划任务策划春节特别版应用更新内容包括视觉设计和营销策略成果制定详细的更新计划并得到管理层认可</div>
<div class="event">1月18日春节特别版发布任务正式推出春节特别版并启动促销活动成果成功发布更新包监控线上表现确保服务质量和用户参与度</div>
<div class="event">1月5日春节特别版规划...</div>
<div class="event">1月18日春节特别版发布...</div>
</div>
</div>
</section>
@ -69,17 +68,28 @@
</script>
<style lang="scss" scoped>
$primary-color: #d9534f;
$secondary-color: #ffebcc;
$font-family: '楷体', 'Comic Sans MS', cursive, sans-serif;
.dashboard-container {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
background-color: #fffbea; //
font-family: '楷体', 'Comic Sans MS', cursive, sans-serif;
background: linear-gradient(180deg, #fffbea 0%, $secondary-color 100%);
font-family: $font-family;
min-height: 100vh;
.dashboard-header,
.dashboard-footer {
width: 100%;
text-align: center;
}
.dashboard-header {
h1 {
color: #d9534f;
color: $primary-color;
font-size: 2.5em;
margin-bottom: 0.5em;
text-shadow: 2px 2px 5px rgba(255, 204, 203, 0.7);
@ -88,58 +98,59 @@
.dashboard-main {
width: 100%;
max-width: 1200px;
display: flex;
flex-direction: column;
align-items: center;
gap: 2em;
padding: 0 20px;
.welcome-section {
margin-bottom: 2em;
text-align: center;
padding: 20px;
border-radius: 15px;
background-color: #ffebcc;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
h2 {
color: #b94a03;
font-size: 1.5em;
margin-bottom: 0.5em;
}
p {
color: #8c6e3c;
font-size: 1em;
}
.fresh-news-icon {
width: 150px;
height: auto;
margin-top: 1em;
}
}
.quick-actions {
display: flex;
gap: 20px;
section {
width: 100%;
justify-content: center;
.action-item {
display: flex;
flex-direction: column;
align-items: center;
text-decoration: none;
color: #333;
padding: 20px;
border-radius: 15px;
background-color: #fff3cd;
transition: all 0.3s ease;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
background-color: #ffffff;
transition: all 0.3s ease;
&:hover {
transform: translateY(-5px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
}
.welcome-section {
background: url('../assets/images/todaynewthing.png') no-repeat right bottom / contain;
position: relative;
h2 {
color: $primary-color;
font-size: 1.5em;
margin-bottom: 0.5em;
}
p {
color: darken($secondary-color, 20%);
font-size: 1em;
}
}
.quick-actions {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 20px;
.action-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-decoration: none;
color: #333;
padding: 20px;
border-radius: 15px;
background-color: lighten($secondary-color, 5%);
transition: all 0.3s ease;
img {
width: 80px;
@ -151,31 +162,23 @@
font-size: 1.2em;
font-weight: bold;
}
&:hover {
background-color: lighten($secondary-color, 10%);
}
}
}
.statistics-section {
display: flex;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 20px;
width: 100%;
justify-content: center;
.statistic-item {
display: flex;
flex-direction: column;
align-items: center;
text-decoration: none;
color: #333;
padding: 20px;
border-radius: 15px;
background-color: #fff3cd;
background-color: lighten($secondary-color, 5%);
transition: all 0.3s ease;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
&:hover {
transform: translateY(-5px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
h3 {
font-size: 1.2em;
@ -186,22 +189,15 @@
font-size: 1.5em;
font-weight: bold;
}
&:hover {
background-color: lighten($secondary-color, 10%);
}
}
}
.calendar-section {
width: 100%;
margin-top: 2em;
.calendar {
display: flex;
flex-direction: column;
gap: 1em;
padding: 20px;
border-radius: 15px;
background-color: #fff3cd;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
h3 {
font-size: 1.5em;
margin-bottom: 1em;
@ -216,22 +212,38 @@
.month {
font-size: 1.2em;
font-weight: bold;
color: #b94a03;
color: $primary-color;
}
.event {
font-size: 1em;
color: #8c6e3c;
color: darken($secondary-color, 20%);
}
}
}
}
.dashboard-footer {
margin-top: 2em;
margin-top: auto;
padding: 20px 0;
text-align: center;
font-size: 0.8em;
color: #888;
}
}
//
@media (max-width: 768px) {
.dashboard-main section {
padding: 10px;
}
.quick-actions {
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}
.statistics-section {
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}
}
</style>

View File

@ -1,7 +1,7 @@
<template>
<div class="register">
<el-form ref="registerRef" :model="registerForm" :rules="registerRules" class="register-form">
<h3 class="title">若依后台管理系统</h3>
<h3 class="title">社区水果APP管理系统</h3>
<el-form-item prop="username">
<el-input
v-model="registerForm.username"

View File

@ -0,0 +1,265 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="推荐名" prop="tuijianname">
<el-input
v-model="queryParams.tuijianname"
placeholder="请输入推荐名"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="推荐数量" prop="tuijiannumber">
<el-input
v-model="queryParams.tuijiannumber"
placeholder="请输入推荐数量"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="推荐语" prop="tuijianyu">
<el-input
v-model="queryParams.tuijianyu"
placeholder="请输入推荐语"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Plus"
@click="handleAdd"
v-hasPermi="['system:recommend:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:recommend:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:recommend:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
v-hasPermi="['system:recommend:export']"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="recommendList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="id" />
<el-table-column label="推荐名" align="center" prop="tuijianname" />
<el-table-column label="推荐数量" align="center" prop="tuijiannumber" />
<el-table-column label="推荐语" align="center" prop="tuijianyu" />
<el-table-column label="图片展示" align="center" prop="picture" width="100">
<template #default="scope">
<image-preview :src="scope.row.picture" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:recommend:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:recommend:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改推荐表对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="recommendRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="推荐名" prop="tuijianname">
<el-input v-model="form.tuijianname" placeholder="请输入推荐名" />
</el-form-item>
<el-form-item label="推荐数量" prop="tuijiannumber">
<el-input v-model="form.tuijiannumber" placeholder="请输入推荐数量" />
</el-form-item>
<el-form-item label="推荐语" prop="tuijianyu">
<el-input v-model="form.tuijianyu" placeholder="请输入推荐语" />
</el-form-item>
<el-form-item label="图片展示" prop="picture">
<image-upload v-model="form.picture"/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="Recommend">
import { listRecommend, getRecommend, delRecommend, addRecommend, updateRecommend } from "@/api/system/recommend";
const { proxy } = getCurrentInstance();
const recommendList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
tuijianname: null,
tuijiannumber: null,
tuijianyu: null,
picture: null
},
rules: {
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询推荐表列表 */
function getList() {
loading.value = true;
listRecommend(queryParams.value).then(response => {
recommendList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
//
function cancel() {
open.value = false;
reset();
}
//
function reset() {
form.value = {
id: null,
tuijianname: null,
tuijiannumber: null,
tuijianyu: null,
picture: null
};
proxy.resetForm("recommendRef");
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1;
getList();
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef");
handleQuery();
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
reset();
open.value = true;
title.value = "添加推荐表";
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
const _id = row.id || ids.value
getRecommend(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改推荐表";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["recommendRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateRecommend(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addRecommend(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
});
}
}
});
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value;
proxy.$modal.confirm('是否确认删除推荐表编号为"' + _ids + '"的数据项?').then(function() {
return delRecommend(_ids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('system/recommend/export', {
...queryParams.value
}, `recommend_${new Date().getTime()}.xlsx`)
}
getList();
</script>

View File

@ -0,0 +1,279 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="商品名" prop="shopname">
<el-input
v-model="queryParams.shopname"
placeholder="请输入商品名"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="商品规格" prop="shopguige">
<el-input
v-model="queryParams.shopguige"
placeholder="请输入商品规格"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="商品价格" prop="price">
<el-input
v-model="queryParams.price"
placeholder="请输入商品价格"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="商品数量" prop="shopnumber">
<el-input
v-model="queryParams.shopnumber"
placeholder="请输入商品数量"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Plus"
@click="handleAdd"
v-hasPermi="['system:shopcar:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:shopcar:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:shopcar:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
v-hasPermi="['system:shopcar:export']"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="shopcarList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="id" />
<el-table-column label="商品名" align="center" prop="shopname" />
<el-table-column label="商品规格" align="center" prop="shopguige" />
<el-table-column label="商品价格" align="center" prop="price" />
<el-table-column label="商品数量" align="center" prop="shopnumber" />
<el-table-column label="商品图片" align="center" prop="shoppicture" width="100">
<template #default="scope">
<image-preview :src="scope.row.shoppicture" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:shopcar:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:shopcar:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改购物车对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="shopcarRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="商品名" prop="shopname">
<el-input v-model="form.shopname" placeholder="请输入商品名" />
</el-form-item>
<el-form-item label="商品规格" prop="shopguige">
<el-input v-model="form.shopguige" placeholder="请输入商品规格" />
</el-form-item>
<el-form-item label="商品价格" prop="price">
<el-input v-model="form.price" placeholder="请输入商品价格" />
</el-form-item>
<el-form-item label="商品数量" prop="shopnumber">
<el-input v-model="form.shopnumber" placeholder="请输入商品数量" />
</el-form-item>
<el-form-item label="商品图片" prop="shoppicture">
<image-upload v-model="form.shoppicture"/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="Shopcar">
import { listShopcar, getShopcar, delShopcar, addShopcar, updateShopcar } from "@/api/system/shopcar";
const { proxy } = getCurrentInstance();
const shopcarList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
shopname: null,
shopguige: null,
price: null,
shopnumber: null,
shoppicture: null
},
rules: {
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询购物车列表 */
function getList() {
loading.value = true;
listShopcar(queryParams.value).then(response => {
shopcarList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
//
function cancel() {
open.value = false;
reset();
}
//
function reset() {
form.value = {
id: null,
shopname: null,
shopguige: null,
price: null,
shopnumber: null,
shoppicture: null
};
proxy.resetForm("shopcarRef");
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1;
getList();
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef");
handleQuery();
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
reset();
open.value = true;
title.value = "添加购物车";
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
const _id = row.id || ids.value
getShopcar(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改购物车";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["shopcarRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateShopcar(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addShopcar(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
});
}
}
});
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value;
proxy.$modal.confirm('是否确认删除购物车编号为"' + _ids + '"的数据项?').then(function() {
return delShopcar(_ids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('system/shopcar/export', {
...queryParams.value
}, `shopcar_${new Date().getTime()}.xlsx`)
}
getList();
</script>