feat: add removing order button in admin order list page

This commit is contained in:
RockYang 2024-03-03 19:27:22 +08:00
parent 3f856afec8
commit 33de83f2ac
4 changed files with 24 additions and 16 deletions

View File

@ -46,7 +46,7 @@ WeChatBot = false
Active = "local" # 默认使用本地文件存储引擎 Active = "local" # 默认使用本地文件存储引擎
[OSS.Local] [OSS.Local]
BasePath = "./static/upload" # 本地文件上传根路径 BasePath = "./static/upload" # 本地文件上传根路径
BaseURL = "/static/upload" # 本地上传文件根 URL 如果是线上,则直接设置为 /static/upload 即可 BaseURL = "http://localhost:5678/static/upload" # 本地上传文件前缀 URL线上需要把 localhost 替换成自己的实际域名或者IP
[OSS.Minio] [OSS.Minio]
Endpoint = "" # 如 172.22.11.200:9000 Endpoint = "" # 如 172.22.11.200:9000
AccessKey = "" # 自己去 Minio 控制台去创建一个 Access Key AccessKey = "" # 自己去 Minio 控制台去创建一个 Access Key

View File

@ -8,6 +8,7 @@ import (
"chatplus/store/vo" "chatplus/store/vo"
"chatplus/utils" "chatplus/utils"
"chatplus/utils/resp" "chatplus/utils/resp"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -26,6 +27,7 @@ func NewOrderHandler(app *core.AppServer, db *gorm.DB) *OrderHandler {
func (h *OrderHandler) List(c *gin.Context) { func (h *OrderHandler) List(c *gin.Context) {
var data struct { var data struct {
OrderNo string `json:"order_no"` OrderNo string `json:"order_no"`
Status int `json:"status"`
PayTime []string `json:"pay_time"` PayTime []string `json:"pay_time"`
Page int `json:"page"` Page int `json:"page"`
PageSize int `json:"page_size"` PageSize int `json:"page_size"`
@ -44,8 +46,9 @@ func (h *OrderHandler) List(c *gin.Context) {
end := utils.Str2stamp(data.PayTime[1] + " 00:00:00") end := utils.Str2stamp(data.PayTime[1] + " 00:00:00")
session = session.Where("pay_time >= ? AND pay_time <= ?", start, end) session = session.Where("pay_time >= ? AND pay_time <= ?", start, end)
} }
session = session.Where("status = ?", types.OrderPaidSuccess) if data.Status >= 0 {
session = session.Where("status", data.Status)
}
var total int64 var total int64
session.Model(&model.Order{}).Count(&total) session.Model(&model.Order{}).Count(&total)
var items []model.Order var items []model.Order
@ -85,7 +88,7 @@ func (h *OrderHandler) Remove(c *gin.Context) {
return return
} }
res = h.db.Where("id = ?", id).Delete(&model.Order{}) res = h.db.Unscoped().Where("id = ?", id).Delete(&model.Order{})
if res.Error != nil { if res.Error != nil {
resp.ERROR(c, "更新数据库失败!") resp.ERROR(c, "更新数据库失败!")
return return

View File

@ -249,7 +249,7 @@ import {
ArrowDown, ArrowDown,
Check, Check,
Close, Close,
Delete, Document, Delete,
Edit, Edit,
Plus, Plus,
Promotion, Promotion,
@ -259,15 +259,7 @@ import {
VideoPause VideoPause
} from '@element-plus/icons-vue' } from '@element-plus/icons-vue'
import 'highlight.js/styles/a11y-dark.css' import 'highlight.js/styles/a11y-dark.css'
import { import {dateFormat, escapeHTML, isMobile, processContent, randString, removeArrayItem, UUID} from "@/utils/libs";
dateFormat,
escapeHTML,
isMobile,
processContent,
randString,
removeArrayItem,
UUID
} from "@/utils/libs";
import {ElMessage, ElMessageBox} from "element-plus"; import {ElMessage, ElMessageBox} from "element-plus";
import hl from "highlight.js"; import hl from "highlight.js";
import {getSessionId, getUserToken, removeUserToken} from "@/store/session"; import {getSessionId, getUserToken, removeUserToken} from "@/store/session";
@ -361,7 +353,7 @@ onMounted(() => {
notice.value = md.render(res.data['content']) notice.value = md.render(res.data['content'])
const oldNotice = localStorage.getItem(noticeKey.value); const oldNotice = localStorage.getItem(noticeKey.value);
// //
if (oldNotice !== notice.value) { if (oldNotice !== notice.value && notice.value.length > 10) {
showNotice.value = true showNotice.value = true
} }
}).catch(e => { }).catch(e => {

View File

@ -2,6 +2,14 @@
<div class="container order" v-loading="loading"> <div class="container order" v-loading="loading">
<div class="handle-box"> <div class="handle-box">
<el-input v-model="query.order_no" placeholder="订单号" class="handle-input mr10"></el-input> <el-input v-model="query.order_no" placeholder="订单号" class="handle-input mr10"></el-input>
<el-select v-model="query.status" placeholder="订单状态" style="width: 100px">
<el-option
v-for="item in orderStatus"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<el-date-picker <el-date-picker
v-model="query.pay_time" v-model="query.pay_time"
type="daterange" type="daterange"
@ -74,11 +82,16 @@ import {Search} from "@element-plus/icons-vue";
// //
const items = ref([]) const items = ref([])
const query = ref({order_no: "", pay_time: []}) const query = ref({order_no: "", pay_time: [], status: -1})
const total = ref(0) const total = ref(0)
const page = ref(1) const page = ref(1)
const pageSize = ref(15) const pageSize = ref(15)
const loading = ref(true) const loading = ref(true)
const orderStatus = ref([
{value: -1, label: "全部"},
{value: 0, label: "未支付"},
{value: 2, label: "已支付"},
])
onMounted(() => { onMounted(() => {
fetchData() fetchData()