添加积分模块

This commit is contained in:
2023-02-24 14:45:02 +08:00
parent 309eccc116
commit c0fd22bd3f
5 changed files with 520 additions and 6 deletions

View File

@@ -0,0 +1,294 @@
<script setup>
// 引入依赖
import api from '@/api/order'
import capi from '@/api/course'
import custom from '@/utils/custom'
import {formatDate} from '@/utils/format'
// import { toSQLLine } from '@/utils/stringFun'
// import WarningBar from '@/components/warningBar/warningBar.vue'
// import coursePool from './components/coursePool.vue'
// import exercisesPool from '@/view/course/components/exercisesPool.vue'
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 typeList = custom.getExercisesTypeList()
const queryParams = ref({
teacherId:0,
page:1,
pageSize:10,
status:'',
province:''
})
const tableData = ref([])
const deleteVisible = ref(false)
const total = ref(0)
const dialogFormVisible = ref(false)
const dialogTitle = ref('')
const form =ref({})
const rules = ref({
name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }]
})
const content = ref(null)
// const options = ref([]) // 答案选项数组
const exam_types = ref([])
const exam_ids = ref([])
import cityList from '@/utils/city.json';
// const cityList = ref([])
// 生命周期
onMounted(() => {
getIntegralList()
})
const stateList = ref([
{
name:'正常',
value:1
},
{
name:'冻结',
value:2
}
])
// 方法
async function getIntegralList() {
const res = await api.getIntegralList(queryParams.value)
if(res.code === 0) {
tableData.value = res.data.records
total.value = res.data.total
}
}
function onSubmit() {
getIntegralList()
}
const onReset = () => {
queryParams.value = {
pageIndex:1,
pageSize:10,
name:'',
status:'',
subject:''
}
}
function openDialog(type) {
// let params = {}
switch (type){
case 'add':
dialogTitle.value = '新增试卷'
form.value = {}
break;
case 'edit':
// params.question_id = question_id.value
dialogTitle.value = '编辑试卷'
break;
}
dialogFormVisible.value = true
// router.push({name:'addCourse',params})
}
async function onDelete() {
const ids = exam_ids.value
const res = await api.delExamination({ exam_ids:ids })
if (res.code === 0) {
ElMessage({
type: 'success',
message: res.msg
})
deleteVisible.value = false
getIntegralList()
}
}
const handleSelectionChange = (val) => {
exam_ids.value = val.map((item) => {
return item.exam_id
})
}
function deleteExamFunc(row) {
ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async() => {
const res = await api.delExamination({
exam_ids:[row.exam_id]
})
if (res.code === 0) {
ElMessage({
type: 'success',
message: '删除成功!'
})
getIntegralList()
}
},() => {
})
}
function handleCurrentChange(val) {
queryParams.value.pageIndex = val
getIntegralList()
}
function handleSizeChange(val) {
queryParams.value.pageSize = val
getIntegralList()
}
function closeDialog(){
dialogFormVisible.value = false
exam_types.value = []
form.value = {}
}
async function enterDialog() { // 提交
form.value.teacher_id = 0
form.value.exam_type = exam_types.value.map((item) => {
return item = parseInt(item)
})
form.value.duration = parseInt(form.value.duration)
// return
const params = {
...form.value
}
params.question_ids = JSON.stringify(form.value.question_ids)
params.course_ids = JSON.stringify(form.value.course_ids)
let func_name = 'addExamination'
if(form.value.exam_id) { // 编辑
func_name = 'editExamination'
}
const res = await api[func_name](params)
if(res.code === 0) {
ElMessage({
type: 'success',
message: res.msg
})
closeDialog()
getIntegralList()
}
}
function viewOrderFunc(row) { // 查看订单
router.push({name:'viewOrder',params:{order_id:row.order_id}})
}
function getStateName(state) {
let str = ''
switch (state){
case 1:
str = '正常'
break;
case 2:
str = '冻结'
break;
}
return str
}
</script>
<template>
<div>
<!-- 搜索框-->
<div class="gva-search-box">
<el-form ref="searchForm" :inline="true" :model="queryParams">
<el-form-item label="状态">
<el-select v-model="queryParams.status" filterable placeholder="请选择">
<el-option
v-for="item in stateList"
:key="item.value"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="所属区域">
<el-select v-model="queryParams.province" filterable placeholder="请选择">
<el-option
v-for="item in cityList"
:key="item.ProID"
:label="item.name"
:value="item.ProID"
/>
</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">
<!-- 数据列表-->
<el-table :data="tableData" @selection-change="handleSelectionChange">
<el-table-column align="center" label="ID" prop="order_id" sortable="custom" />
<el-table-column align="center" label="姓名" min-width="150" prop="nickname" />
<el-table-column align="center" label="手机号" min-width="150" prop="phone" />
<el-table-column align="center" label="所属区域" min-width="150" prop="phone" />
<el-table-column align="center" label="剩余积分" min-width="150" prop="phone" />
<el-table-column align="center" label="累计积分" min-width="150" prop="phone" />
<el-table-column align="center" label="邀请好友(分)" min-width="150" prop="phone" />
<el-table-column align="center" label="购买课程(分)" min-width="150" prop="phone" />
<el-table-column align="center" label="累计消费(分)" min-width="150" prop="phone" />
<el-table-column align="center" label="抽奖(分)" min-width="150" prop="phone" />
<el-table-column align="center" label="竞拍(分)" min-width="150" prop="phone" />
<el-table-column align="center" label="状态" >
<template #default="scope">
<div>{{getStateName(scope.row.status)}}</div>
</template>
</el-table-column>
<el-table-column align="center" label="提交时间" min-width="150" >
<template #default="scope">
{{formatDate(scope.row.CreatedAt)}}
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="200">
<template #default="scope">
<el-button
icon="edit"
size="small"
type="primary"
link
@click="viewOrderFunc(scope.row)"
>冻结</el-button>
<el-button
icon="delete"
size="small"
type="danger"
link
@click="deleteExamFunc(scope.row)"
>解冻</el-button>
</template>
</el-table-column>
</el-table>
<div class="gva-pagination">
<el-pagination
:current-page="queryParams.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>
</div>
</template>
<style scoped lang="scss">
.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>