master #16
@@ -174,3 +174,29 @@ export const exportGroupBuyIdcInfo = () => {
|
||||
export const setGroupBuyOrder = (groupBuyId) => {
|
||||
return request.post("/api/v1/admin/activity/group_buy/set_order", { group_buy_id: groupBuyId })
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定队伍
|
||||
* @param {string} groupBuyId - 队伍ID
|
||||
* @returns {Promise} 返回删除结果
|
||||
*/
|
||||
export const removeGroupBuy = (groupBuyId) => {
|
||||
return request.delete("/api/v1/admin/activity/group_buy/remove", { params: { group_buy_id: groupBuyId } })
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有队伍
|
||||
* @returns {Promise} 返回清除结果
|
||||
*/
|
||||
export const clearAllGroupBuy = () => {
|
||||
return request.delete("/api/v1/admin/activity/group_buy/clear")
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除指定用户的所有队伍
|
||||
* @param {string} userId - 用户ID
|
||||
* @returns {Promise} 返回清除结果
|
||||
*/
|
||||
export const clearUserGroupBuy = (userId) => {
|
||||
return request.delete("/api/v1/admin/activity/group_buy/user_clear", { params: { user_id: userId } })
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
<el-button type="info" icon="Refresh" @click="fetchGroupList" :loading="loading">
|
||||
刷新列表
|
||||
</el-button>
|
||||
<el-button type="danger" @click="handleClearAll">
|
||||
清除所有队伍
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
@@ -61,6 +64,13 @@
|
||||
>
|
||||
查看详情
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
@click="handleRemoveGroup(row)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -138,7 +148,7 @@ import {
|
||||
exportIdcInfo,
|
||||
setOrder
|
||||
} from '@/api/admin/activity'
|
||||
import { getGroupBuyTypeList,getGroupBuyTypeTags } from '@/api/groupBuy'
|
||||
import { getGroupBuyTypeList, getGroupBuyTypeTags, removeGroupBuy, clearAllGroupBuy, clearUserGroupBuy } from '@/api/groupBuy'
|
||||
|
||||
// 数据状态
|
||||
const loading = ref(false)
|
||||
@@ -451,6 +461,48 @@ const handleExport = async () => {
|
||||
onMounted(() => {
|
||||
fetchGroupList()
|
||||
})
|
||||
|
||||
// 删除指定队伍
|
||||
const handleRemoveGroup = async (row) => {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定要删除该队伍吗?', '确认删除', { type: 'warning' })
|
||||
const res = await removeGroupBuy(row.id)
|
||||
if (res.code === 200) {
|
||||
ElMessage.success('删除成功')
|
||||
fetchGroupList()
|
||||
} else {
|
||||
ElMessage.error(res.message || '删除失败')
|
||||
}
|
||||
} catch { /* 取消 */ }
|
||||
}
|
||||
|
||||
// 清除所有队伍
|
||||
const handleClearAll = async () => {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定要清除所有队伍吗?此操作不可恢复!', '危险操作', { type: 'error', confirmButtonText: '确定清除' })
|
||||
const res = await clearAllGroupBuy()
|
||||
if (res.code === 200) {
|
||||
ElMessage.success('已清除所有队伍')
|
||||
fetchGroupList()
|
||||
} else {
|
||||
ElMessage.error(res.message || '清除失败')
|
||||
}
|
||||
} catch { /* 取消 */ }
|
||||
}
|
||||
|
||||
// 清除指定用户的所有队伍
|
||||
const handleClearUserGroups = async (userId) => {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要清除用户 ${userId} 的所有队伍吗?`, '确认操作', { type: 'warning' })
|
||||
const res = await clearUserGroupBuy(userId)
|
||||
if (res.code === 200) {
|
||||
ElMessage.success('清除成功')
|
||||
fetchGroupList()
|
||||
} else {
|
||||
ElMessage.error(res.message || '清除失败')
|
||||
}
|
||||
} catch { /* 取消 */ }
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -69,37 +69,18 @@
|
||||
<el-form-item label="过期时间" prop="expireTime">
|
||||
<el-date-picker v-model="form.expireTime" type="datetime" placeholder="选择过期时间" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注字段" prop="noteFields">
|
||||
<el-form-item label="备注字段">
|
||||
<div class="note-fields-container">
|
||||
<el-button type="primary" size="small" @click="addNoteField" style="margin-bottom: 10px">+ 添加字段</el-button>
|
||||
<el-table :data="form.noteFields" border size="small" v-if="form.noteFields.length">
|
||||
<el-table-column label="字段Key" width="120">
|
||||
<el-table-column label="名称" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.key" placeholder="key" size="small" />
|
||||
<el-input v-model="row.label" placeholder="如:内存" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="显示名称" width="120">
|
||||
<el-table-column label="默认值" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.label" placeholder="名称" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="默认值" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.defaultValue" placeholder="默认值" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="输入类型" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.type" size="small">
|
||||
<el-option label="文本" value="text" />
|
||||
<el-option label="数字" value="number" />
|
||||
<el-option label="选择" value="select" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="必填" width="60" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-checkbox v-model="row.required" />
|
||||
<el-input v-model="row.defaultValue" placeholder="如:20GB" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="60" align="center">
|
||||
@@ -149,7 +130,7 @@ const rules = {
|
||||
|
||||
// 添加备注字段
|
||||
const addNoteField = () => {
|
||||
form.noteFields.push({ key: '', label: '', defaultValue: '', type: 'text', required: false })
|
||||
form.noteFields.push({ label: '', defaultValue: '' })
|
||||
}
|
||||
|
||||
// 删除备注字段
|
||||
@@ -223,7 +204,7 @@ const handleSubmit = async () => {
|
||||
if (!valid) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const noteJson = JSON.stringify(form.noteFields.filter(f => f.key))
|
||||
const noteJson = JSON.stringify(form.noteFields.filter(f => f.label))
|
||||
const data = {
|
||||
name: form.name,
|
||||
price: String(form.price),
|
||||
|
||||
@@ -562,6 +562,127 @@
|
||||
},
|
||||
"security": []
|
||||
}
|
||||
},
|
||||
"/api/v1/admin/activity/group_buy/remove": {
|
||||
"delete": {
|
||||
"summary": "删除指定队伍",
|
||||
"deprecated": false,
|
||||
"description": "",
|
||||
"tags": [],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "group_buy_id",
|
||||
"in": "query",
|
||||
"description": "队伍id",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"description": "",
|
||||
"example": "Bearer {{token}}",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "Bearer {{token}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"headers": {}
|
||||
}
|
||||
},
|
||||
"security": []
|
||||
}
|
||||
},
|
||||
"/api/v1/admin/activity/group_buy/clear": {
|
||||
"delete": {
|
||||
"summary": "清除所有队伍",
|
||||
"deprecated": false,
|
||||
"description": "",
|
||||
"tags": [],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"description": "",
|
||||
"example": "Bearer {{token}}",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "Bearer {{token}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": []
|
||||
}
|
||||
},
|
||||
"/api/v1/admin/activity/group_buy/user_clear": {
|
||||
"delete": {
|
||||
"summary": "清除指定用户的所有队伍",
|
||||
"deprecated": false,
|
||||
"description": "",
|
||||
"tags": [],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "user_id",
|
||||
"in": "query",
|
||||
"description": "用户ID",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"description": "",
|
||||
"example": "Bearer {{token}}",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "Bearer {{token}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
|
||||
Reference in New Issue
Block a user