feat 添加订单管理的界面
This commit is contained in:
parent
403afa9ba8
commit
4c9bc37771
@ -6,6 +6,7 @@ import Test from '../views/Test.vue'
|
||||
import AdminLayout from '../views/layout/AdminLayout.vue'
|
||||
import UserIndex from '../views/user/index.vue'
|
||||
import GoodsIndex from '../views/goods/index.vue'
|
||||
import OrderIndex from '../views/goods/Order.vue'
|
||||
|
||||
export const AdminRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
@ -32,6 +33,14 @@ export const AdminRoutes: RouteRecordRaw[] = [
|
||||
title: '商品管理'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'order',
|
||||
name: 'OrderIndex',
|
||||
component: OrderIndex,
|
||||
meta: {
|
||||
title: '订单管理'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'test',
|
||||
name: 'TestIndex',
|
||||
|
13
admin-fe/src/service/types.d.ts
vendored
13
admin-fe/src/service/types.d.ts
vendored
@ -45,3 +45,16 @@ type GoodsModel = {
|
||||
updateTime?: string;
|
||||
status?: number;
|
||||
}
|
||||
type OrderInfoModel = {
|
||||
id?: string;
|
||||
gid?: number;
|
||||
orderTitle?: string;
|
||||
price?: number;
|
||||
count?: number;
|
||||
uid?: number;
|
||||
data?: any;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
status?: number;
|
||||
owner?: UserInfoModel;
|
||||
}
|
140
admin-fe/src/views/goods/Order.vue
Normal file
140
admin-fe/src/views/goods/Order.vue
Normal file
@ -0,0 +1,140 @@
|
||||
<template>
|
||||
|
||||
<div class="table-wrapper">
|
||||
<div class="table-toolbar">
|
||||
<div class="search-form">
|
||||
<span>订单编号:<PInput style="width:200px" v-model="param.id" placeholder="要查询的订单编号"/></span>
|
||||
<span>标题:<PInput style="width:200px" v-model="param.title" placeholder="要查询的订单标题"/></span>
|
||||
<span>订单开始:<PInput style="width:200px" v-model="param.createTimeStart" placeholder="要查询的订单开始时间"/></span>
|
||||
<span>订单结束:<PInput style="width:200px" v-model="param.createTimeEnd" placeholder="要查询的订单结束时间"/></span>
|
||||
|
||||
<span>
|
||||
<PButton type="default" @click="onReset">重置</PButton>
|
||||
</span>
|
||||
<span><PButton :loading="searching" @click="onSearch">搜索</PButton></span>
|
||||
</div>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th>订单编号</th>
|
||||
<th>标题</th>
|
||||
<th>价格</th>
|
||||
<th>数量</th>
|
||||
<th>状态</th>
|
||||
<th>用户</th>
|
||||
<th>创建时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
<tr v-for="it in goodsList" :key="it.id">
|
||||
<td>{{ it.id }}</td>
|
||||
<td>{{ it.orderTitle }}</td>
|
||||
<td>{{ it.price }}</td>
|
||||
<td>{{ it.count }}</td>
|
||||
<td>{{ StatusEnum[it.status] || '未知' }}</td>
|
||||
<td>{{ it.owner?.nickname }}</td>
|
||||
<td>{{ it.createTime }}</td>
|
||||
<td width="160">
|
||||
<PButton v-if="it.status == 1" type="link" @click="updateStatus(it.id,2)">确认</PButton>
|
||||
<PButton v-if="it.status < 3" type="link" @click="updateStatus(it.id,3)">取消</PButton>
|
||||
<PButton v-if="it.status < 3" type="link" @click="updateStatus(it.id,4)">完成</PButton>
|
||||
<PButton type="link" @click="removeData(it.id)">删除</PButton>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<Pager :total="totalCount" show-refresh @refresh="loadDataList" @page-change="onPageChange"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {onMounted, reactive, ref} from "vue";
|
||||
import http, {DataListModel} from "../../util/http";
|
||||
import message from "../../components/message";
|
||||
import Pager from "../../components/pager/Pager.vue";
|
||||
import PButton from "../../components/button/Index.vue";
|
||||
|
||||
const StatusEnum = {
|
||||
1: '待确认',
|
||||
2: '已确认',
|
||||
3: '已取消',
|
||||
4: '已完成',
|
||||
0: '已删除'
|
||||
}
|
||||
const param = reactive({
|
||||
id: null,
|
||||
title: null,
|
||||
createTimeStart: null,
|
||||
createTimeEnd: null,
|
||||
page: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
|
||||
const goodsList = ref<OrderInfoModel[]>([]);
|
||||
const totalCount = ref(0)
|
||||
const searching = ref(false)
|
||||
|
||||
function onPageChange(currentPage: number) {
|
||||
param.page = currentPage;
|
||||
loadDataList();
|
||||
}
|
||||
|
||||
function onReset() {
|
||||
param.page = 1;
|
||||
param.title = null;
|
||||
param.id = null
|
||||
param.createTimeStart = null
|
||||
param.createTimeEnd = null
|
||||
loadDataList();
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
param.page = 1;
|
||||
loadDataList();
|
||||
}
|
||||
|
||||
function loadDataList() {
|
||||
searching.value = true
|
||||
http.post<DataListModel<OrderInfoModel>>('/admin/order/list', param).then(res => {
|
||||
goodsList.value = res.items
|
||||
totalCount.value = res.total
|
||||
}).finally(() => searching.value = false)
|
||||
}
|
||||
|
||||
async function updateStatus(id: string, status: number) {
|
||||
if (!confirm('是否继续操作?')) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await http.put(`/admin/order/${id}/status?status=${status}`);
|
||||
message.toast('操作成功');
|
||||
loadDataList();
|
||||
} catch (e) {
|
||||
message.toast(e.message || '操作失败')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
* @param id 要删除的用户id
|
||||
*/
|
||||
async function removeData(id: string) {
|
||||
if (!confirm('是否删除?')) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await http.delete(`/admin/order/${id}`);
|
||||
message.toast('删除成功');
|
||||
loadDataList();
|
||||
} catch (e) {
|
||||
message.toast(e.message || '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadDataList)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.search-form span {
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/order")
|
||||
public class OrderAdminController {
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
@ -51,4 +52,15 @@ public class OrderAdminController {
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/status")
|
||||
public boolean setStatus(@PathVariable("id") String id, int status) {
|
||||
if (!StringUtils.hasText(id)) throw BizException.paramError();
|
||||
return orderInfoService.updateById(
|
||||
OrderInfo.builder()
|
||||
.id(id)
|
||||
.status(status)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import me.xiaoyan.point.api.pojo.dto.OrderStatus;
|
||||
import me.xiaoyan.point.api.pojo.vo.CreateOrderData;
|
||||
import me.xiaoyan.point.api.pojo.vo.OrderQueryParam;
|
||||
import me.xiaoyan.point.api.service.*;
|
||||
import me.xiaoyan.point.api.util.DataStatus;
|
||||
import me.xiaoyan.point.api.util.OrderIdGenerator;
|
||||
import me.xiaoyan.point.api.util.QueryWrapperUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -89,6 +90,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
.eq("order_title", param.getTitle())
|
||||
.ge("create_time", param.getCreateTimeStart())
|
||||
.le("create_time", param.getCreateTimeEnd())
|
||||
.ne("status", DataStatus.DELETE)
|
||||
.build();
|
||||
final Page<OrderInfo> page = getBaseMapper().selectPage(param.getPage(), q);
|
||||
page.getRecords().forEach(o -> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user