开发竞拍模块
This commit is contained in:
parent
92657ea736
commit
fa767f00de
@ -7,6 +7,35 @@ const api = {
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
},
|
||||
// 竞拍
|
||||
getAuctionList : data => { // 竞拍列表
|
||||
return service({
|
||||
url: '/auction',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
},
|
||||
addAucitonData: data => { // 创建竞拍
|
||||
return service({
|
||||
url: '/auction',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
},
|
||||
editAucitonData: data => { // 编辑竞拍
|
||||
return service({
|
||||
url: '/auction',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
},
|
||||
delAucitonData: data => { // 删除竞拍
|
||||
return service({
|
||||
url: '/auction',
|
||||
method: 'delete',
|
||||
data
|
||||
})
|
||||
}
|
||||
}
|
||||
export default api
|
||||
|
445
src/view/auctionManage/index.vue
Normal file
445
src/view/auctionManage/index.vue
Normal file
@ -0,0 +1,445 @@
|
||||
|
||||
<script setup>
|
||||
// 引入依赖
|
||||
import api from '@/api/integral'
|
||||
import custom from '@/utils/custom'
|
||||
import {formatDate} from '@/utils/format'
|
||||
import cityList from '@/utils/city.json'
|
||||
import {ref,onMounted,provide } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
// store
|
||||
import { useUserStore } from '@/pinia/modules/user'
|
||||
const userStore = useUserStore()
|
||||
// 变量
|
||||
const path = ref(import.meta.env.VITE_BASE_API)
|
||||
const queryParams = ref({
|
||||
page:1,
|
||||
pageSize:10,
|
||||
key:'',
|
||||
status:'',
|
||||
sort:'',
|
||||
current_page:1
|
||||
})
|
||||
// const subjectParams = ref({
|
||||
// pageIndex:1,
|
||||
// pageSize:100,
|
||||
// })
|
||||
const state_arr = ref([
|
||||
{
|
||||
name:'报名中',
|
||||
value:1
|
||||
},
|
||||
{
|
||||
name:'取消',
|
||||
value:2
|
||||
},
|
||||
{
|
||||
name:'结束',
|
||||
value:3
|
||||
}
|
||||
])
|
||||
const tableData = ref([])
|
||||
const deleteVisible = ref(false)
|
||||
const total = ref(0)
|
||||
const auction_ids = ref([])
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
getAuctionList()
|
||||
})
|
||||
// 方法
|
||||
async function getAuctionList() {
|
||||
const res = await api.getAuctionList(queryParams.value)
|
||||
if(res.code === 0) {
|
||||
tableData.value = res.data.list
|
||||
total.value = res.data.total
|
||||
}
|
||||
}
|
||||
function onSubmit() {
|
||||
getAuctionList()
|
||||
}
|
||||
const onReset = () => {
|
||||
queryParams.value = {
|
||||
page:1,
|
||||
pageSize:10,
|
||||
key:'',
|
||||
status:'',
|
||||
sort:'',
|
||||
current_page:1
|
||||
}
|
||||
}
|
||||
async function onDelete() {
|
||||
const ids = auction_ids.value
|
||||
const res = await api.delAucitonData({ ids:auction_ids.value })
|
||||
if (res.code === 0) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: res.msg
|
||||
})
|
||||
deleteVisible.value = false
|
||||
getAuctionList()
|
||||
}
|
||||
}
|
||||
const handleSelectionChange = (val) => {
|
||||
auction_ids.value = val.map((item) => {
|
||||
return item.id
|
||||
})
|
||||
}
|
||||
function handleCurrentChange(val) {
|
||||
queryParams.value.current_page = val
|
||||
getAuctionList()
|
||||
}
|
||||
function handleSizeChange(val) {
|
||||
queryParams.value.pageSize = val
|
||||
getAuctionList()
|
||||
}
|
||||
// function viewTeacherFunc(row) { // 查看详情
|
||||
// router.push({name:'teacherDetail',params:{id:row.teacher_info_id}})
|
||||
// }
|
||||
function getStateName(row) {
|
||||
let name = ''
|
||||
switch(row.status) {
|
||||
case 1:
|
||||
// 检查是否过期
|
||||
if(row.end_time < (Date.parse(new Date()))) { // 已过期
|
||||
name = '已结束';
|
||||
}
|
||||
else{
|
||||
name = '报名中';
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
name = '已取消';
|
||||
break;
|
||||
case 0:
|
||||
name = '已取消';
|
||||
break;
|
||||
case 3:
|
||||
name = '已结束';
|
||||
break;
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
// 新增 & 编辑相关 ================
|
||||
const popupVisible = ref(false)
|
||||
const popupTitle = ref('')
|
||||
const auctionForm = ref({})
|
||||
const auctionFormRules = ref({
|
||||
product_name: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
|
||||
market_value:[{ required: true, message: '请输入市场价格', trigger: 'blur'},
|
||||
{ type: 'number', message: '请输入正确的格式',trigger: 'blur' }],
|
||||
in_point:[{ required: true, message: '请输入门票积分', trigger: 'blur'},
|
||||
{ type: 'number', message: '请输入正确的格式' }],
|
||||
full_member:[{ required: true, message: '请输入满员人数', trigger: 'blur'},
|
||||
{ type: 'number', message: '请输入正确的格式' }],
|
||||
end_time:[{ required: true, message: '请输入截止时间', trigger: 'blur' }],
|
||||
begin_time:[{ required: true, message: '请输入开始时间', trigger: 'blur' }],
|
||||
product_cover:[{ required: true, message: '请选择商品封面', trigger: 'blur' }],
|
||||
})
|
||||
const auctionFormRef = ref(null)
|
||||
function openDialog() {
|
||||
auctionForm.value = {}
|
||||
popupTitle.value = '新增竞拍'
|
||||
popupVisible.value = true
|
||||
}
|
||||
function editAuctionFunc(row) {
|
||||
popupTitle.value = '编辑竞拍'
|
||||
popupVisible.value = true
|
||||
auctionForm.value = row
|
||||
}
|
||||
function delFunc(row) {
|
||||
ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(async() => {
|
||||
console.log(1)
|
||||
const res = await api.delAucitonData({
|
||||
ids:[row.id]
|
||||
})
|
||||
if (res.code === 0) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功!'
|
||||
})
|
||||
getAuctionList()
|
||||
}
|
||||
},() => {
|
||||
})
|
||||
}
|
||||
function cancelClick() {
|
||||
popupVisible.value = false
|
||||
}
|
||||
async function confirmClick() { //提交竞拍
|
||||
submitForm(auctionFormRef.value)
|
||||
}
|
||||
async function submitForm(formEl) {
|
||||
if (!formEl) return
|
||||
await formEl.validate((valid, fields) => {
|
||||
if (valid) { // 验证通过
|
||||
// console.log('submit!')
|
||||
saveData()
|
||||
} else {
|
||||
// console.log('请填写完整信息!', fields)
|
||||
}
|
||||
})
|
||||
}
|
||||
async function saveData() {
|
||||
const params = {
|
||||
...auctionForm.value
|
||||
}
|
||||
// console.log(params);return
|
||||
const res = await api.addAucitonData(params)
|
||||
if(res.code === 0) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: res.msg
|
||||
})
|
||||
getAuctionList()
|
||||
cancelClick()
|
||||
}
|
||||
}
|
||||
function handleAvatarSuccess(res) { // 图片上传回调
|
||||
console.log(res)
|
||||
auctionForm.value[file_type.value[file_type_index]] = res.data.file.url
|
||||
|
||||
}
|
||||
function beforeAvatarUpload(file) {
|
||||
const isLt05M = file.size / 1024 / 1024 < 20
|
||||
const isJPG = file.type.indexOf('image/') === -1
|
||||
if (isJPG) {
|
||||
ElMessage.error('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件')
|
||||
}
|
||||
if (!isLt05M) {
|
||||
ElMessage.error('上传头像图片大小不能超过 2M!')
|
||||
}
|
||||
return !isJPG && isLt05M
|
||||
}
|
||||
const file_type = ref(['product_cover','product_introduce'])
|
||||
let file_type_index = 0
|
||||
function fileChange(index) {
|
||||
console.log(index)
|
||||
file_type_index = index
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<!-- 搜索框-->
|
||||
<div class="gva-search-box">
|
||||
<el-form ref="searchForm" :inline="true" :model="queryParams">
|
||||
<el-form-item label="关键字">
|
||||
<el-input v-model="queryParams.key" placeholder="根据关键字进行查询" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="queryParams.status" clearable placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in state_arr"
|
||||
:key="item.value"
|
||||
:label="item.name"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button>
|
||||
<el-button size="small" icon="refresh" @click="onReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<!-- 表格数据-->
|
||||
<div class="gva-table-box">
|
||||
<!-- 批量操作-->
|
||||
<div class="gva-btn-list">
|
||||
<el-button size="small" type="primary" icon="plus" @click="openDialog('add')">新增</el-button>
|
||||
<el-popover v-model="deleteVisible" placement="top" width="160">
|
||||
<p>确定要删除吗?</p>
|
||||
<div style="text-align: right; margin-top: 8px;">
|
||||
<el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button>
|
||||
<el-button size="small" type="primary" @click="onDelete">确定</el-button>
|
||||
</div>
|
||||
<template #reference>
|
||||
<el-button icon="delete" size="small" type="danger" :disabled="!auction_ids.length" style="margin-left: 10px;" @click="deleteVisible = true">删除</el-button>
|
||||
</template>
|
||||
</el-popover>
|
||||
</div>
|
||||
<!-- 数据列表-->
|
||||
<el-table :data="tableData" @selection-change="handleSelectionChange">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
width="55"
|
||||
/>
|
||||
<el-table-column align="center" label="ID" prop="id" sortable="custom" />
|
||||
<el-table-column align="center" label="商品名称" prop="product_name" />
|
||||
<el-table-column align="center" label="商品图片">
|
||||
<template #default="scope">
|
||||
<img class="avatar-box" :src="scope.row.product_cover" alt="">
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="市场价值(元)" min-width="150" prop="market_value" />
|
||||
<el-table-column align="center" label="门票积分" prop="in_point" />
|
||||
<el-table-column align="center" label="满员人数" prop="full_member" />
|
||||
<el-table-column align="center" label="发布日期" min-width="150" >
|
||||
<template #default="scope">
|
||||
{{custom.timestampToDate(scope.row.begin_time)}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="截止日期" min-width="150" >
|
||||
<template #default="scope">
|
||||
{{custom.timestampToDate(scope.row.end_time)}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="已参与人数" min-width="150" prop="in_member" />
|
||||
<el-table-column align="center" label="最高积分" prop="most_point" />
|
||||
<el-table-column align="center" label="状态">
|
||||
<template #default="scope">
|
||||
<div>{{getStateName(scope.row)}}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" fixed="right" label="操作" width="200">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
icon="view"
|
||||
size="small"
|
||||
type="primary"
|
||||
link
|
||||
@click="editAuctionFunc(scope.row)"
|
||||
>编辑</el-button>
|
||||
<el-button
|
||||
icon="delete"
|
||||
size="small"
|
||||
type="danger"
|
||||
link
|
||||
@click="delFunc(scope.row)"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="gva-pagination">
|
||||
<el-pagination
|
||||
:current-page="queryParams.current_page"
|
||||
:page-size="queryParams.pageSize"
|
||||
:page-sizes="[10, 30, 50, 100]"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@current-change="handleCurrentChange"
|
||||
@size-change="handleSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 新增&编辑 窗口-->
|
||||
<el-drawer
|
||||
v-model="popupVisible"
|
||||
:title="popupTitle"
|
||||
direction="rtl"
|
||||
size="50%"
|
||||
>
|
||||
<el-form ref="auctionFormRef" class="form-box" :model="auctionForm" :rules="auctionFormRules" label-width="80px">
|
||||
<el-form-item label="商品名称" prop="product_name">
|
||||
<el-input v-model="auctionForm.product_name" placeholder="请输入商品名称" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="奖品封面" prop="product_cover">
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
:action="`${path}/fileUploadAndDownload/upload`"
|
||||
:headers="{ 'x-token': userStore.token }"
|
||||
:show-file-list="false"
|
||||
:on-success="handleAvatarSuccess"
|
||||
@click="fileChange(0)"
|
||||
:before-upload="beforeAvatarUpload"
|
||||
>
|
||||
<img v-if="auctionForm.product_cover" :src="auctionForm.product_cover" class="img-container" />
|
||||
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="市场价格" prop="market_value">
|
||||
<el-input v-model.number="auctionForm.market_value" placeholder="请输入市场价格" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="in_point" label="门票积分" >
|
||||
<el-input v-model.number="auctionForm.in_point" placeholder="请输入门票积分" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="full_member" label="满员人数" >
|
||||
<el-input v-model.number="auctionForm.full_member" placeholder="请输入满员人数" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="开始日期" prop="begin_time" >
|
||||
<el-date-picker
|
||||
v-model="auctionForm.begin_time"
|
||||
type="datetime"
|
||||
placeholder="开始日期"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="x"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="截止日期" prop="end_time" >
|
||||
<el-date-picker
|
||||
v-model="auctionForm.end_time"
|
||||
type="datetime"
|
||||
placeholder="截止日期"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="x"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="奖品详情" prop="product_introduce">
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
:action="`${path}/fileUploadAndDownload/upload`"
|
||||
:headers="{ 'x-token': userStore.token }"
|
||||
:show-file-list="false"
|
||||
:on-success="handleAvatarSuccess"
|
||||
@click="fileChange(1)"
|
||||
:before-upload="beforeAvatarUpload"
|
||||
>
|
||||
<img v-if="auctionForm.product_introduce" :src="auctionForm.product_introduce" class="img-container" />
|
||||
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="启用状态" prop="status">
|
||||
<el-switch v-model="auctionForm.status" :active-value="1" :inactive-value="2" active-text="启用" inactive-text="禁用" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div style="flex: auto">
|
||||
<el-button @click="cancelClick">取消</el-button>
|
||||
<el-button type="primary" @click="confirmClick">立即添加</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped lang="scss">
|
||||
.form-box{
|
||||
padding: 10px;
|
||||
}
|
||||
.img-container{
|
||||
width: 200px;
|
||||
height: 150px;
|
||||
}
|
||||
.avatar-box{
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid #dbdbdb;
|
||||
}
|
||||
.e-img{
|
||||
width: 150px;
|
||||
height: 100px;
|
||||
}
|
||||
.option-item{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.button-box {
|
||||
padding: 10px 20px;
|
||||
.el-button {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
.warning {
|
||||
color: #dc143c;
|
||||
}
|
||||
</style>
|
@ -87,6 +87,7 @@ async function saveStep1() {
|
||||
form.value.course_category_id = subjectList.value.filter((item,i) => {
|
||||
return item.name === form.value.subject
|
||||
})[0].id
|
||||
form.value.price = parseFloat(form.value.price)<0?0:form.value.price
|
||||
let params = {
|
||||
step1:{
|
||||
...form.value
|
||||
@ -219,7 +220,7 @@ function handlerChange(e) {
|
||||
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="价格" prop="price">
|
||||
<el-form-item label="价格(元)" prop="price">
|
||||
<el-input @change="handlerChange" placeholder="请输入课程价格" type="number" v-model="form.price" />
|
||||
</el-form-item>
|
||||
<el-form-item label="课程简介">
|
||||
|
@ -265,7 +265,7 @@ function handleSizeChange(val) {
|
||||
<el-input v-model="form.lbtIntroduction" placeholder="说明" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="链接状态" prop="method">
|
||||
<el-switch v-model="form.lbtSkipUrlType" active-value="1" inactive-value="2" active-text="外链" inactive-text="内链" />
|
||||
<el-switch v-model="form.lbtSkipUrlType" :active-value="1" :inactive-value="2" active-text="外链" inactive-text="内链" />
|
||||
</el-form-item>
|
||||
<el-form-item label="链接地址" prop="lbtSkipUrl">
|
||||
<el-input v-model="form.lbtSkipUrl" placeholder="链接地址" autocomplete="off" />
|
||||
|
Loading…
Reference in New Issue
Block a user