This commit is contained in:
yj 2024-12-22 12:32:59 +08:00
parent 07d7ea0af2
commit 0d3dd7e43f
8 changed files with 797 additions and 84 deletions

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

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询评论信息列表
export function listComment(query) {
return request({
url: '/system/comment/list',
method: 'get',
params: query
})
}
// 查询评论信息详细
export function getComment(id) {
return request({
url: '/system/comment/' + id,
method: 'get'
})
}
// 新增评论信息
export function addComment(data) {
return request({
url: '/system/comment',
method: 'post',
data: data
})
}
// 修改评论信息
export function updateComment(data) {
return request({
url: '/system/comment',
method: 'put',
data: data
})
}
// 删除评论信息
export function delComment(id) {
return request({
url: '/system/comment/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询商品信息列表
export function listCommodity(query) {
return request({
url: '/system/commodity/list',
method: 'get',
params: query
})
}
// 查询商品信息详细
export function getCommodity(id) {
return request({
url: '/system/commodity/' + id,
method: 'get'
})
}
// 新增商品信息
export function addCommodity(data) {
return request({
url: '/system/commodity',
method: 'post',
data: data
})
}
// 修改商品信息
export function updateCommodity(data) {
return request({
url: '/system/commodity',
method: 'put',
data: data
})
}
// 删除商品信息
export function delCommodity(id) {
return request({
url: '/system/commodity/' + id,
method: 'delete'
})
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -1,103 +1,124 @@
<template>
<div class="app-container home">
<h2>校园二手交易后台管理框架 {{ version }}</h2>
<el-row :gutter="20">
<el-col :sm="24" :lg="24">
<el-row :gutter="20">
<el-col :sm="24" :lg="12">
<div id="ring - chart - container" style="width: 100%; height: 400px;"></div>
</el-col>
<el-col :sm="24" :lg="12">
<el-calendar v-model="value" />
</el-col>
</el-row>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :sm="24" :lg="12" style="padding - left:20px">
</el-col>
</el-row>
<h2>校园二手交易后台管理框架</h2>
<!-- 整体页面布局容器 -->
<div class="main-content">
<!-- 数据统计区域 -->
<div class="stats-container">
<div class="stat-box">
<span>商品数量</span>
<p>50</p>
</div>
<div class="stat-box">
<span>商品销量</span>
<p>120</p>
</div>
<div class="stat-box">
<span>订单数量</span>
<p>30</p>
</div>
</div>
<!-- 商品公告栏 -->
<div class="notice-board">
<h3>商品公告</h3>
<ul>
<li>近期将对二手电子产品进行质量审核</li>
<li>新上架一批优质二手教材</li>
<li>校园内交易地点调整请留意</li>
</ul>
</div>
<!-- 日期时间显示区域右上角 -->
<div class="datetime-display" :class="timeColorClass" style="position: absolute; right: 20px; top: 20px;">
<p class="datetime-text">{{ currentDateTime }}</p>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import * as echarts from 'echarts';
//
const version = ref('3.8.8');
// value
<script setup>
import { ref, onMounted } from 'vue';
import dayjs from 'dayjs';
function goTarget(url) {
window.open(url, '__blank');
}
//
const currentDateTime = ref('');
//
const timeColorClass = ref('');
onMounted(() => {
//
updateDateTimeAndColor();
//
setInterval(() => {
updateDateTimeAndColor();
}, 1000);
});
const updateDateTimeAndColor = () => {
const now = dayjs();
currentDateTime.value = now.format('YYYY-MM-DD HH:mm:ss');
const hour = now.hour();
if (hour >= 6 && hour < 18) {
timeColorClass.value = 'day-time';
} else {
timeColorClass.value = 'night-time';
}
};
</script>
<style scoped lang="scss">
.home {
blockquote {
padding: 10px 20px;
margin: 0 0 20px;
font-size: 17.5px;
border-left: 5px solid #eee;
}
hr {
margin-top: 20px;
margin-bottom: 20px;
border: 0;
border-top: 1px solid #eee;
}
.col-item {
margin-bottom: 20px;
}
.app-container {
padding: 20px;
position: relative;
}
ul {
padding: 0;
margin: 0;
}
.main-content {
display: flex;
flex-direction: column;
}
font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 13px;
color: #676a6c;
overflow-x: hidden;
.stats-container {
display: flex;
justify-content: space-around;
margin-bottom: 20px;
}
ul {
list-style-type: none;
}
.stat-box {
text-align: center;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
flex: 1;
}
h4 {
margin-top: 0px;
}
.notice-board {
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
}
h2 {
margin-top: 10px;
font-size: 26px;
font-weight: 100;
}
.notice-board h3 {
margin-top: 0;
}
p {
margin-top: 10px;
.datetime-display {
border: 1px solid #ccc;
border-radius: 5px;
padding: 5px 10px;
}
b {
font-weight: 700;
}
}
.day-time {
background-color: #f0f8ff;
color: #333;
}
.update-log {
ol {
display: block;
list-style-type: decimal;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0;
margin-inline-end: 0;
padding-inline-start: 40px;
}
}
/* 可根据实际需求添加针对日历控件所在列的样式微调 */
.el-col:last-child {
padding: 10px;
}
.night-time {
background-color: #333;
color: white;
}
.datetime-text {
margin: 0;
font-size: 14px;
}
</style>

View File

@ -0,0 +1,270 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="用户id" prop="personid">
<el-input
v-model="queryParams.personid"
placeholder="请输入用户id"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="商品id" prop="commodityid">
<el-input
v-model="queryParams.commodityid"
placeholder="请输入商品id"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="评论时间" prop="time">
<el-date-picker clearable
v-model="queryParams.time"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择评论时间">
</el-date-picker>
</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:comment:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:comment:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:comment:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
v-hasPermi="['system:comment:export']"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="commentList" @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="用户id" align="center" prop="personid" />
<el-table-column label="商品id" align="center" prop="commodityid" />
<el-table-column label="评论内容" align="center" prop="content" />
<el-table-column label="评论时间" align="center" prop="time" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.time, '{y}-{m}-{d}') }}</span>
</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:comment:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:comment: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="commentRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="用户id" prop="personid">
<el-input v-model="form.personid" placeholder="请输入用户id" />
</el-form-item>
<el-form-item label="商品id" prop="commodityid">
<el-input v-model="form.commodityid" placeholder="请输入商品id" />
</el-form-item>
<el-form-item label="评论内容">
<editor v-model="form.content" :min-height="192"/>
</el-form-item>
<el-form-item label="评论时间" prop="time">
<el-date-picker clearable
v-model="form.time"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择评论时间">
</el-date-picker>
</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="Comment">
import { listComment, getComment, delComment, addComment, updateComment } from "@/api/system/comment";
const { proxy } = getCurrentInstance();
const commentList = 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,
personid: null,
commodityid: null,
content: null,
time: null
},
rules: {
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询评论信息列表 */
function getList() {
loading.value = true;
listComment(queryParams.value).then(response => {
commentList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
//
function cancel() {
open.value = false;
reset();
}
//
function reset() {
form.value = {
id: null,
personid: null,
commodityid: null,
content: null,
time: null
};
proxy.resetForm("commentRef");
}
/** 搜索按钮操作 */
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
getComment(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改评论信息";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["commentRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateComment(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addComment(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 delComment(_ids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('system/comment/export', {
...queryParams.value
}, `comment_${new Date().getTime()}.xlsx`)
}
getList();
</script>

View File

@ -0,0 +1,334 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="商品名" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入商品名"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="卖家id" prop="sellerid">
<el-input
v-model="queryParams.sellerid"
placeholder="请输入卖家id"
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="classification">
<el-input
v-model="queryParams.classification"
placeholder="请输入分类"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
v-model="queryParams.description"
placeholder="请输入描述"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="图片" prop="picture">
<el-input
v-model="queryParams.picture"
placeholder="请输入图片"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="state">
<el-input
v-model="queryParams.state"
placeholder="请输入状态"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="上架时间" prop="time">
<el-date-picker clearable
v-model="queryParams.time"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择上架时间">
</el-date-picker>
</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:commodity:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:commodity:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:commodity:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
v-hasPermi="['system:commodity:export']"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="commodityList" @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="name" />
<el-table-column label="卖家id" align="center" prop="sellerid" />
<el-table-column label="价格" align="center" prop="price" />
<el-table-column label="分类" align="center" prop="classification" />
<el-table-column label="描述" align="center" prop="description" />
<el-table-column label="图片" align="center" prop="picture" />
<el-table-column label="状态" align="center" prop="state" />
<el-table-column label="上架时间" align="center" prop="time" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.time, '{y}-{m}-{d}') }}</span>
</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:commodity:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:commodity: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="commodityRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="商品名" prop="name">
<el-input v-model="form.name" placeholder="请输入商品名" />
</el-form-item>
<el-form-item label="卖家id" prop="sellerid">
<el-input v-model="form.sellerid" placeholder="请输入卖家id" />
</el-form-item>
<el-form-item label="价格" prop="price">
<el-input v-model="form.price" placeholder="请输入价格" />
</el-form-item>
<el-form-item label="分类" prop="classification">
<el-input v-model="form.classification" placeholder="请输入分类" />
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input v-model="form.description" placeholder="请输入描述" />
</el-form-item>
<el-form-item label="图片" prop="picture">
<el-input v-model="form.picture" placeholder="请输入图片" />
</el-form-item>
<el-form-item label="状态" prop="state">
<el-input v-model="form.state" placeholder="请输入状态" />
</el-form-item>
<el-form-item label="上架时间" prop="time">
<el-date-picker clearable
v-model="form.time"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择上架时间">
</el-date-picker>
</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="Commodity">
import { listCommodity, getCommodity, delCommodity, addCommodity, updateCommodity } from "@/api/system/commodity";
const { proxy } = getCurrentInstance();
const commodityList = 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,
name: null,
sellerid: null,
price: null,
classification: null,
description: null,
picture: null,
state: null,
time: null
},
rules: {
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询商品信息列表 */
function getList() {
loading.value = true;
listCommodity(queryParams.value).then(response => {
commodityList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
//
function cancel() {
open.value = false;
reset();
}
//
function reset() {
form.value = {
id: null,
name: null,
sellerid: null,
price: null,
classification: null,
description: null,
picture: null,
state: null,
time: null
};
proxy.resetForm("commodityRef");
}
/** 搜索按钮操作 */
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
getCommodity(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改商品信息";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["commodityRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateCommodity(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addCommodity(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 delCommodity(_ids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('system/commodity/export', {
...queryParams.value
}, `commodity_${new Date().getTime()}.xlsx`)
}
getList();
</script>