mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
exam
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
<el-menu-item index="/swiper"><i class="el-icon-picture" />轮播图配置</el-menu-item>
|
<el-menu-item index="/swiper"><i class="el-icon-picture" />轮播图配置</el-menu-item>
|
||||||
<el-menu-item index="/agent-allow"><i class="el-icon-picture" />允许客户端</el-menu-item>
|
<el-menu-item index="/agent-allow"><i class="el-icon-picture" />允许客户端</el-menu-item>
|
||||||
<el-menu-item index="/user"><i class="el-icon-user" />用户</el-menu-item>
|
<el-menu-item index="/user"><i class="el-icon-user" />用户</el-menu-item>
|
||||||
|
<el-menu-item index="/exam"><i class="el-icon-s-check" />考核</el-menu-item>
|
||||||
<el-menu-item index="/hot"><i class="el-icon-star-on" />热销商品配置</el-menu-item>
|
<el-menu-item index="/hot"><i class="el-icon-star-on" />热销商品配置</el-menu-item>
|
||||||
<el-menu-item index="/new"><i class="el-icon-sell" />新品上线配置</el-menu-item>
|
<el-menu-item index="/new"><i class="el-icon-sell" />新品上线配置</el-menu-item>
|
||||||
<el-menu-item index="/recommend"><i class="el-icon-thumb" />为你推荐配置</el-menu-item>
|
<el-menu-item index="/recommend"><i class="el-icon-thumb" />为你推荐配置</el-menu-item>
|
||||||
|
|||||||
Vendored
+87
-3
@@ -1,14 +1,98 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import { ElButton, ElContainer, ElAside, ElHeader, ElMain, ElFooter, ElMenu, ElSubmenu, ElMenuItemGroup, ElMenuItem, ElForm, ElFormItem, ElInput, ElPopover, ElTag, ElCard, ElTable, ElTableColumn, ElPagination, ElDialog, ElPopconfirm, ElUpload, ElLoading, ElSelect, ElOption, ElRadioGroup, ElRadio, ElCascader, ElCheckbox, ElInputNumber } from 'element-plus'
|
import {
|
||||||
|
ElAlert,
|
||||||
|
ElAside,
|
||||||
|
ElAutocomplete,
|
||||||
|
ElAvatar,
|
||||||
|
ElBacktop,
|
||||||
|
ElBadge,
|
||||||
|
ElBreadcrumb,
|
||||||
|
ElBreadcrumbItem,
|
||||||
|
ElButton,
|
||||||
|
ElButtonGroup,
|
||||||
|
ElCalendar,
|
||||||
|
ElCard,
|
||||||
|
ElCarousel,
|
||||||
|
ElCarouselItem,
|
||||||
|
ElCascader,
|
||||||
|
ElCascaderPanel,
|
||||||
|
ElCheckbox,
|
||||||
|
ElCheckboxButton,
|
||||||
|
ElCheckboxGroup,
|
||||||
|
ElCol,
|
||||||
|
ElCollapse,
|
||||||
|
ElCollapseItem,
|
||||||
|
ElCollapseTransition,
|
||||||
|
ElColorPicker,
|
||||||
|
ElContainer,
|
||||||
|
ElDatePicker,
|
||||||
|
ElDialog,
|
||||||
|
ElDivider,
|
||||||
|
ElDrawer,
|
||||||
|
ElDropdown,
|
||||||
|
ElDropdownItem,
|
||||||
|
ElDropdownMenu,
|
||||||
|
ElFooter,
|
||||||
|
ElForm,
|
||||||
|
ElFormItem,
|
||||||
|
ElHeader,
|
||||||
|
ElIcon,
|
||||||
|
ElImage,
|
||||||
|
ElInput,
|
||||||
|
ElInputNumber,
|
||||||
|
ElLink,
|
||||||
|
ElMain,
|
||||||
|
ElMenu,
|
||||||
|
ElMenuItem,
|
||||||
|
ElMenuItemGroup,
|
||||||
|
ElOption,
|
||||||
|
ElOptionGroup,
|
||||||
|
ElPageHeader,
|
||||||
|
ElPagination,
|
||||||
|
ElPopconfirm,
|
||||||
|
ElPopover,
|
||||||
|
ElPopper,
|
||||||
|
ElProgress,
|
||||||
|
ElRadio,
|
||||||
|
ElRadioButton,
|
||||||
|
ElRadioGroup,
|
||||||
|
ElRate,
|
||||||
|
ElRow,
|
||||||
|
ElScrollbar,
|
||||||
|
ElSelect,
|
||||||
|
ElSlider,
|
||||||
|
ElStep,
|
||||||
|
ElSteps,
|
||||||
|
ElSubmenu,
|
||||||
|
ElSwitch,
|
||||||
|
ElTabPane,
|
||||||
|
ElTable,
|
||||||
|
ElTableColumn,
|
||||||
|
ElTabs,
|
||||||
|
ElTag,
|
||||||
|
ElTimePicker,
|
||||||
|
ElTimeSelect,
|
||||||
|
ElTimeline,
|
||||||
|
ElTimelineItem,
|
||||||
|
ElTooltip,
|
||||||
|
ElTransfer,
|
||||||
|
ElTree,
|
||||||
|
ElUpload,
|
||||||
|
ElInfiniteScroll,
|
||||||
|
ElLoading,
|
||||||
|
ElMessage,
|
||||||
|
ElMessageBox,
|
||||||
|
ElNotification
|
||||||
|
} from 'element-plus'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router/index'
|
import router from './router/index'
|
||||||
import 'dayjs/locale/zh-cn'
|
import 'dayjs/locale/zh-cn'
|
||||||
import locale from 'element-plus/lib/locale/lang/zh-cn'
|
import locale from 'element-plus/lib/locale/lang/zh-cn'
|
||||||
|
|
||||||
// import 'element-plus/lib/theme-chalk/index.css'
|
import 'element-plus/lib/theme-chalk/index.css'
|
||||||
|
|
||||||
// 修改后的主题样式必须放在最后面
|
// 修改后的主题样式必须放在最后面
|
||||||
import '../theme/index.css'
|
// import '../theme/index.css'
|
||||||
|
|
||||||
const orderStatus = {
|
const orderStatus = {
|
||||||
0: '待支付',
|
0: '待支付',
|
||||||
|
|||||||
Vendored
+16
-2
@@ -108,8 +108,22 @@ const router = createRouter({
|
|||||||
path: '/user-form',
|
path: '/user-form',
|
||||||
name: 'user-form',
|
name: 'user-form',
|
||||||
component: () => import(/* webpackChunkName: "account" */ '../views/user/form.vue'),
|
component: () => import(/* webpackChunkName: "account" */ '../views/user/form.vue'),
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
path: '/user-detail',
|
||||||
|
name: 'user-detail',
|
||||||
|
component: () => import(/* webpackChunkName: "account" */ '../views/user/detail.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/exam',
|
||||||
|
name: 'exam',
|
||||||
|
component: () => import(/* webpackChunkName: "account" */ '../views/exam/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/exam-form',
|
||||||
|
name: 'exam-form',
|
||||||
|
component: () => import(/* webpackChunkName: "account" */ '../views/exam/form.vue'),
|
||||||
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
Vendored
+19
@@ -26,6 +26,25 @@ const api = {
|
|||||||
storeUser: (params = {}) => {
|
storeUser: (params = {}) => {
|
||||||
return axios.post(baseUrl + 'user', params);
|
return axios.post(baseUrl + 'user', params);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
listExam: (params = {}) => {
|
||||||
|
return axios.get(baseUrl + 'exam', {params: params});
|
||||||
|
},
|
||||||
|
storeExam: (params = {}) => {
|
||||||
|
return axios.post(baseUrl + 'exam', params);
|
||||||
|
},
|
||||||
|
updateExam: (id, params = {}) => {
|
||||||
|
return axios.put(baseUrl + 'exam/' + id, params);
|
||||||
|
},
|
||||||
|
getExam: (id) => {
|
||||||
|
return axios.get(baseUrl + 'exam/' + id);
|
||||||
|
},
|
||||||
|
deleteExam: (id) => {
|
||||||
|
return axios.delete(baseUrl + 'exam/' + id);
|
||||||
|
},
|
||||||
|
listClass: (params = {}) => {
|
||||||
|
return axios.get(baseUrl + 'class', {params: params});
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default api
|
export default api
|
||||||
|
|||||||
Vendored
+3
-1
@@ -46,5 +46,7 @@ export const pathMap = {
|
|||||||
"agent-allow": "允许客户端",
|
"agent-allow": "允许客户端",
|
||||||
"agent-allow-form": "允许客户端表单",
|
"agent-allow-form": "允许客户端表单",
|
||||||
"user": "用户",
|
"user": "用户",
|
||||||
"user-form": "用户表单"
|
"user-form": "用户表单",
|
||||||
|
"exam": "考核",
|
||||||
|
"exam-form": "考核表单",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
<template>
|
||||||
|
<div class="add">
|
||||||
|
<el-card class="add-container">
|
||||||
|
<el-form :model="goodForm" :rules="rules" ref="goodRef" class="goodForm" label-width="180px" style="width: 50%">
|
||||||
|
<el-form-item label="名称" prop="name">
|
||||||
|
<el-input type="text" v-model="goodForm.name" placeholder=""></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="考核用户组" prop="classes">
|
||||||
|
<el-checkbox-group v-model="goodForm.classes">
|
||||||
|
<el-checkbox v-for="(value, key) in classes" :label="key" :key="key">{{value}}</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="submitAdd()">{{ id ? '立即修改' : '立即创建' }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { reactive, ref, toRefs, onMounted, onBeforeUnmount, getCurrentInstance } from 'vue'
|
||||||
|
import api from '@/utils/api'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { localGet, hasEmoji } from '@/utils'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
console.log('proxy', proxy)
|
||||||
|
const goodRef = ref(null)
|
||||||
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
const { id } = route.query
|
||||||
|
const state = reactive({
|
||||||
|
token: localGet('token') || '',
|
||||||
|
id: id,
|
||||||
|
defaultCate: '',
|
||||||
|
classes: [],
|
||||||
|
goodForm: {
|
||||||
|
name: '',
|
||||||
|
description: '',
|
||||||
|
begin: '',
|
||||||
|
end: '',
|
||||||
|
classes: [],
|
||||||
|
filters: {
|
||||||
|
classes: [],
|
||||||
|
register_time_begin: '',
|
||||||
|
register_time_end: '',
|
||||||
|
},
|
||||||
|
requires: {}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
username: [
|
||||||
|
{ required: 'true' }
|
||||||
|
],
|
||||||
|
email: [
|
||||||
|
{ required: 'true'}
|
||||||
|
],
|
||||||
|
password: [
|
||||||
|
{ required: 'true' }
|
||||||
|
],
|
||||||
|
password_confirmation: [
|
||||||
|
{ required: 'true' }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
onMounted(() => {
|
||||||
|
listClass()
|
||||||
|
if (id) {
|
||||||
|
getAgentAllow(id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
|
||||||
|
})
|
||||||
|
const getAgentAllow = (id) => {
|
||||||
|
api.getAllowAgent(id).then(res => {
|
||||||
|
state.goodForm = res
|
||||||
|
console.log(res, state.goodForm)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const listClass = () => {
|
||||||
|
api.listClass().then(res => {
|
||||||
|
state.classes = res
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const submitAdd = () => {
|
||||||
|
goodRef.value.validate((vaild) => {
|
||||||
|
console.log("valid", vaild)
|
||||||
|
if (vaild) {
|
||||||
|
// 默认新增用 post 方法
|
||||||
|
let params = state.goodForm
|
||||||
|
let res
|
||||||
|
console.log('params', params)
|
||||||
|
api.storeUser(params).then(res => {
|
||||||
|
ElMessage.success(id ? '修改成功' : '添加成功')
|
||||||
|
router.push({ path: '/user' })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const handleBeforeUpload = (file) => {
|
||||||
|
const sufix = file.name.split('.')[1] || ''
|
||||||
|
if (!['jpg', 'jpeg', 'png'].includes(sufix)) {
|
||||||
|
ElMessage.error('请上传 jpg、jpeg、png 格式的图片')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const handleUrlSuccess = (val) => {
|
||||||
|
state.goodForm.goodsCoverImg = val.data || ''
|
||||||
|
}
|
||||||
|
const handleChangeCate = (val) => {
|
||||||
|
state.categoryId = val[2] || 0
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
goodRef,
|
||||||
|
submitAdd,
|
||||||
|
handleBeforeUpload,
|
||||||
|
handleUrlSuccess,
|
||||||
|
handleChangeCate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.add {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.add-container {
|
||||||
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.avatar-uploader {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
color: #ddd;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
.avatar-uploader-icon {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border: 1px solid #e9e9e9;
|
||||||
|
padding: 32px 17px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,245 @@
|
|||||||
|
<template>
|
||||||
|
<el-card class="swiper-container">
|
||||||
|
<template #header>
|
||||||
|
<div class="header">
|
||||||
|
<el-button type="primary" size="small" icon="el-icon-plus" @click="handleAdd">增加</el-button>
|
||||||
|
<!-- <el-popconfirm-->
|
||||||
|
<!-- title="确定删除吗?"-->
|
||||||
|
<!-- @confirm="handleDelete"-->
|
||||||
|
<!-- >-->
|
||||||
|
<!-- <template #reference>-->
|
||||||
|
<!-- <el-button type="danger" size="small" icon="el-icon-delete">批量删除</el-button>-->
|
||||||
|
<!-- </template>-->
|
||||||
|
<!-- </el-popconfirm>-->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
ref="multipleTable"
|
||||||
|
:data="tableData"
|
||||||
|
tooltip-effect="dark"
|
||||||
|
style="width: 100%"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
|
@sort-change="handleSortChange"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
type="selection"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="ID"
|
||||||
|
prop="id"
|
||||||
|
width="60"
|
||||||
|
sortable="custom"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="名称"
|
||||||
|
prop="name"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="开始时间"
|
||||||
|
prop="begin"
|
||||||
|
sortable="custom"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="结束时间"
|
||||||
|
prop="end"
|
||||||
|
sortable="custom"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="filters"
|
||||||
|
label="适用用户"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="requires"
|
||||||
|
label="考核标准"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="状态"
|
||||||
|
prop="status_text"
|
||||||
|
sortable="custom"
|
||||||
|
></el-table-column>
|
||||||
|
|
||||||
|
<el-table-column
|
||||||
|
label="操作"
|
||||||
|
width="100"
|
||||||
|
>
|
||||||
|
<template #default="scope">
|
||||||
|
<a style="cursor: pointer; margin-right: 10px" @click="handleDetail(scope.row.id)">详情</a>
|
||||||
|
<!-- <el-popconfirm-->
|
||||||
|
<!-- title="确定删除吗?"-->
|
||||||
|
<!-- @confirm="handleDeleteOne(scope.row.id)"-->
|
||||||
|
<!-- >-->
|
||||||
|
<!-- <template #reference>-->
|
||||||
|
<!-- <a style="cursor: pointer">删除</a>-->
|
||||||
|
<!-- </template>-->
|
||||||
|
<!-- </el-popconfirm>-->
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!--总数超过一页,再展示分页器-->
|
||||||
|
<el-pagination
|
||||||
|
background
|
||||||
|
layout="prev, pager, next"
|
||||||
|
:total="total"
|
||||||
|
:page-size="pageSize"
|
||||||
|
:current-page="currentPage"
|
||||||
|
@current-change="changePage"
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { onMounted, reactive, ref, toRefs } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import AgentAllowForm from './form.vue'
|
||||||
|
import axios from '@/utils/axios'
|
||||||
|
import api from '@/utils/api'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Swiper',
|
||||||
|
components: {
|
||||||
|
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const router = useRouter()
|
||||||
|
const multipleTable = ref(null)
|
||||||
|
const addGood = ref(null)
|
||||||
|
const state = reactive({
|
||||||
|
loading: false,
|
||||||
|
tableData: [], // 数据列表
|
||||||
|
multipleSelection: [], // 选中项
|
||||||
|
total: 0, // 总条数
|
||||||
|
currentPage: 1, // 当前页
|
||||||
|
pageSize: 10, // 分页大小
|
||||||
|
type: 'add', // 操作类型
|
||||||
|
sortField: 'id',
|
||||||
|
sortType: 'desc'
|
||||||
|
})
|
||||||
|
onMounted(() => {
|
||||||
|
// getCarousels()
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
// 获取轮播图列表
|
||||||
|
const getCarousels = () => {
|
||||||
|
// state.loading = true
|
||||||
|
// axios.get('/carousels', {
|
||||||
|
// params: {
|
||||||
|
// pageNumber: state.currentPage,
|
||||||
|
// pageSize: state.pageSize
|
||||||
|
// }
|
||||||
|
// }).then(res => {
|
||||||
|
// state.tableData = res.list
|
||||||
|
// state.total = res.totalCount
|
||||||
|
// state.currentPage = res.currPage
|
||||||
|
// state.loading = false
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
||||||
|
const getList = () => {
|
||||||
|
state.loading = true
|
||||||
|
let params = {
|
||||||
|
page: state.currentPage,
|
||||||
|
sort_field: state.sortField,
|
||||||
|
sort_type: state.sortType
|
||||||
|
}
|
||||||
|
api.listExam(params).then(res => {
|
||||||
|
state.tableData = res.data
|
||||||
|
state.total = res.meta.total
|
||||||
|
state.currentPage = res.meta.current_page
|
||||||
|
state.pageSize = res.meta.per_page
|
||||||
|
state.loading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const handleSortChange = (sort) => {
|
||||||
|
console.log(sort)
|
||||||
|
state.sortField = sort.prop
|
||||||
|
state.sortType = sort.order
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
// 添加轮播项
|
||||||
|
const handleAdd = () => {
|
||||||
|
state.type = 'add'
|
||||||
|
// addGood.value.open()
|
||||||
|
router.push({
|
||||||
|
name: "exam-form"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 修改轮播图
|
||||||
|
const handleEdit = (id) => {
|
||||||
|
console.log("id", id)
|
||||||
|
router.push({
|
||||||
|
name: "agent-allow-form",
|
||||||
|
query: {id: id}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 修改轮播图
|
||||||
|
const handleDetail = (id) => {
|
||||||
|
console.log("id", id)
|
||||||
|
router.push({
|
||||||
|
name: "user-detail",
|
||||||
|
query: {id: id}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 选择项
|
||||||
|
const handleSelectionChange = (val) => {
|
||||||
|
state.multipleSelection = val
|
||||||
|
}
|
||||||
|
// 批量删除
|
||||||
|
const handleDelete = () => {
|
||||||
|
if (!state.multipleSelection.length) {
|
||||||
|
ElMessage.error('请选择项')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
axios.delete('/carousels', {
|
||||||
|
data: {
|
||||||
|
ids: state.multipleSelection.map(i => i.carouselId)
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
ElMessage.success('删除成功')
|
||||||
|
getCarousels()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 单个删除
|
||||||
|
const handleDeleteOne = (id) => {
|
||||||
|
api.deleteAllowAgent(id).then(() => {
|
||||||
|
ElMessage.success('删除成功')
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const changePage = (val) => {
|
||||||
|
state.currentPage = val
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
multipleTable,
|
||||||
|
handleSelectionChange,
|
||||||
|
handleSortChange,
|
||||||
|
addGood,
|
||||||
|
handleAdd,
|
||||||
|
handleEdit,
|
||||||
|
handleDetail,
|
||||||
|
handleDelete,
|
||||||
|
handleDeleteOne,
|
||||||
|
getCarousels,
|
||||||
|
changePage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.swiper-container {
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
.el-card.is-always-shadow {
|
||||||
|
min-height: 100%!important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
<template>
|
||||||
|
<el-row :gutter="10" type="flex" start="start">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-card class="box-card">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<span>卡片名称</span>
|
||||||
|
<el-button class="button" type="text">操作按钮</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div v-for="o in 4" :key="o" class="text item">
|
||||||
|
{{'列表内容 ' + o }}
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-card class="box-card">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<span>卡片名称</span>
|
||||||
|
<el-button class="button" type="text">操作按钮</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div v-for="o in 4" :key="o" class="text item">
|
||||||
|
{{'列表内容 ' + o }}
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { onMounted, reactive, ref, toRefs } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import AgentAllowForm from './form.vue'
|
||||||
|
import axios from '@/utils/axios'
|
||||||
|
import api from '@/utils/api'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Swiper',
|
||||||
|
components: {
|
||||||
|
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const router = useRouter()
|
||||||
|
const multipleTable = ref(null)
|
||||||
|
const addGood = ref(null)
|
||||||
|
const state = reactive({
|
||||||
|
loading: false,
|
||||||
|
tableData: [], // 数据列表
|
||||||
|
multipleSelection: [], // 选中项
|
||||||
|
total: 0, // 总条数
|
||||||
|
currentPage: 1, // 当前页
|
||||||
|
pageSize: 10, // 分页大小
|
||||||
|
type: 'add', // 操作类型
|
||||||
|
sortField: 'id',
|
||||||
|
sortType: 'desc'
|
||||||
|
})
|
||||||
|
onMounted(() => {
|
||||||
|
// getCarousels()
|
||||||
|
listUser()
|
||||||
|
})
|
||||||
|
// 获取轮播图列表
|
||||||
|
const getCarousels = () => {
|
||||||
|
// state.loading = true
|
||||||
|
// axios.get('/carousels', {
|
||||||
|
// params: {
|
||||||
|
// pageNumber: state.currentPage,
|
||||||
|
// pageSize: state.pageSize
|
||||||
|
// }
|
||||||
|
// }).then(res => {
|
||||||
|
// state.tableData = res.list
|
||||||
|
// state.total = res.totalCount
|
||||||
|
// state.currentPage = res.currPage
|
||||||
|
// state.loading = false
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
||||||
|
const listUser = () => {
|
||||||
|
state.loading = true
|
||||||
|
let params = {
|
||||||
|
page: state.currentPage,
|
||||||
|
sort_field: state.sortField,
|
||||||
|
sort_type: state.sortType
|
||||||
|
}
|
||||||
|
api.listUser(params).then(res => {
|
||||||
|
state.tableData = res.data
|
||||||
|
state.total = res.meta.total
|
||||||
|
state.currentPage = res.meta.current_page
|
||||||
|
state.pageSize = res.meta.per_page
|
||||||
|
state.loading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const handleSortChange = (sort) => {
|
||||||
|
console.log(sort)
|
||||||
|
state.sortField = sort.prop
|
||||||
|
state.sortType = sort.order
|
||||||
|
listUser()
|
||||||
|
}
|
||||||
|
// 添加轮播项
|
||||||
|
const handleAdd = () => {
|
||||||
|
state.type = 'add'
|
||||||
|
// addGood.value.open()
|
||||||
|
router.push({
|
||||||
|
name: "user-form"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 修改轮播图
|
||||||
|
const handleEdit = (id) => {
|
||||||
|
console.log("id", id)
|
||||||
|
router.push({
|
||||||
|
name: "agent-allow-form",
|
||||||
|
query: {id: id}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 选择项
|
||||||
|
const handleSelectionChange = (val) => {
|
||||||
|
state.multipleSelection = val
|
||||||
|
}
|
||||||
|
// 批量删除
|
||||||
|
const handleDelete = () => {
|
||||||
|
if (!state.multipleSelection.length) {
|
||||||
|
ElMessage.error('请选择项')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
axios.delete('/carousels', {
|
||||||
|
data: {
|
||||||
|
ids: state.multipleSelection.map(i => i.carouselId)
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
ElMessage.success('删除成功')
|
||||||
|
getCarousels()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 单个删除
|
||||||
|
const handleDeleteOne = (id) => {
|
||||||
|
api.deleteAllowAgent(id).then(() => {
|
||||||
|
ElMessage.success('删除成功')
|
||||||
|
listUser()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const changePage = (val) => {
|
||||||
|
state.currentPage = val
|
||||||
|
listUser()
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
multipleTable,
|
||||||
|
handleSelectionChange,
|
||||||
|
handleSortChange,
|
||||||
|
addGood,
|
||||||
|
handleAdd,
|
||||||
|
handleEdit,
|
||||||
|
handleDelete,
|
||||||
|
handleDeleteOne,
|
||||||
|
getCarousels,
|
||||||
|
changePage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.swiper-container {
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
.el-card.is-always-shadow {
|
||||||
|
min-height: 100%!important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
width="100"
|
width="100"
|
||||||
>
|
>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<!-- <a style="cursor: pointer; margin-right: 10px" @click="handleEdit(scope.row.id)">修改</a>-->
|
<a style="cursor: pointer; margin-right: 10px" @click="handleDetail(scope.row.id)">详情</a>
|
||||||
<!-- <el-popconfirm-->
|
<!-- <el-popconfirm-->
|
||||||
<!-- title="确定删除吗?"-->
|
<!-- title="确定删除吗?"-->
|
||||||
<!-- @confirm="handleDeleteOne(scope.row.id)"-->
|
<!-- @confirm="handleDeleteOne(scope.row.id)"-->
|
||||||
@@ -193,6 +193,14 @@ export default {
|
|||||||
query: {id: id}
|
query: {id: id}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 修改轮播图
|
||||||
|
const handleDetail = (id) => {
|
||||||
|
console.log("id", id)
|
||||||
|
router.push({
|
||||||
|
name: "user-detail",
|
||||||
|
query: {id: id}
|
||||||
|
})
|
||||||
|
}
|
||||||
// 选择项
|
// 选择项
|
||||||
const handleSelectionChange = (val) => {
|
const handleSelectionChange = (val) => {
|
||||||
state.multipleSelection = val
|
state.multipleSelection = val
|
||||||
@@ -231,6 +239,7 @@ export default {
|
|||||||
addGood,
|
addGood,
|
||||||
handleAdd,
|
handleAdd,
|
||||||
handleEdit,
|
handleEdit,
|
||||||
|
handleDetail,
|
||||||
handleDelete,
|
handleDelete,
|
||||||
handleDeleteOne,
|
handleDeleteOne,
|
||||||
getCarousels,
|
getCarousels,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class AgentAllowController extends Controller
|
|||||||
{
|
{
|
||||||
$result = AgentAllow::query()->orderBy('id', 'desc')->paginate();
|
$result = AgentAllow::query()->orderBy('id', 'desc')->paginate();
|
||||||
$resource = AgentAllowResource::collection($result);
|
$resource = AgentAllowResource::collection($result);
|
||||||
return success('agent allow list', $resource);
|
return $this->success($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +41,7 @@ class AgentAllowController extends Controller
|
|||||||
{
|
{
|
||||||
$result = AgentAllow::query()->findOrFail($id);
|
$result = AgentAllow::query()->findOrFail($id);
|
||||||
$resource = new AgentAllowResource($result);
|
$resource = new AgentAllowResource($result);
|
||||||
return success('agent allow detail', $resource);
|
return $this->success($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,7 +56,7 @@ class AgentAllowController extends Controller
|
|||||||
$result = AgentAllow::query()->findOrFail($id);
|
$result = AgentAllow::query()->findOrFail($id);
|
||||||
$result->update($request->all());
|
$result->update($request->all());
|
||||||
$resource = new AgentAllowResource($result);
|
$resource = new AgentAllowResource($result);
|
||||||
return success('agent allow update', $resource);
|
return $this->success($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,6 +69,6 @@ class AgentAllowController extends Controller
|
|||||||
{
|
{
|
||||||
$result = AgentAllow::query()->findOrFail($id);
|
$result = AgentAllow::query()->findOrFail($id);
|
||||||
$deleted = $result->delete();
|
$deleted = $result->delete();
|
||||||
return success('agent allow delete', [$deleted]);
|
return $this->success([$deleted]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,51 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
use Illuminate\Routing\Controller as BaseController;
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Controller extends BaseController
|
class Controller extends BaseController
|
||||||
{
|
{
|
||||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||||
|
|
||||||
|
public function success($data, $msg = null)
|
||||||
|
{
|
||||||
|
if (is_null($msg)) {
|
||||||
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
||||||
|
$caller = $backtrace[1];
|
||||||
|
$msg = $this->getReturnMsg($caller);
|
||||||
|
}
|
||||||
|
return success($msg, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fail($data, $msg = null)
|
||||||
|
{
|
||||||
|
if (is_null($msg)) {
|
||||||
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
||||||
|
$caller = $backtrace[1];
|
||||||
|
$msg = $this->getReturnMsg($caller);
|
||||||
|
}
|
||||||
|
return fail($msg, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getReturnMsg(array $backtrace)
|
||||||
|
{
|
||||||
|
$title = $this->title ?? '';
|
||||||
|
if (empty($title)) {
|
||||||
|
$title = $backtrace['class'];
|
||||||
|
$pos = strripos($title, '\\');
|
||||||
|
$title = substr($title, $pos + 1);
|
||||||
|
$title = str_replace('Controller', '', $title);
|
||||||
|
}
|
||||||
|
$action = $backtrace['function'];
|
||||||
|
$map = [
|
||||||
|
'index' => 'list',
|
||||||
|
'show' => 'detail',
|
||||||
|
'update' => 'update',
|
||||||
|
'destroy' => 'delete',
|
||||||
|
];
|
||||||
|
if (isset($map[$action])) {
|
||||||
|
$action = $map[$action];
|
||||||
|
}
|
||||||
|
return Str::slug("$title.$action", '.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Resources\ExamResource;
|
||||||
|
use App\Http\Resources\UserResource;
|
||||||
|
use App\Repositories\ExamRepository;
|
||||||
|
use App\Repositories\UserRepository;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ExamController extends Controller
|
||||||
|
{
|
||||||
|
private $repository;
|
||||||
|
|
||||||
|
public function __construct(ExamRepository $repository)
|
||||||
|
{
|
||||||
|
$this->repository = $repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$result = $this->repository->getList($request->all());
|
||||||
|
$resource = ExamResource::collection($result);
|
||||||
|
return $this->success($resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|string',
|
||||||
|
'begin' => 'required|date_format:Y-m-d H:i:s',
|
||||||
|
'end' => 'required|date_format:Y-m-d H:i:s',
|
||||||
|
'requires' => 'required|array|min:1',
|
||||||
|
'filters' => 'required|array|min:1',
|
||||||
|
];
|
||||||
|
$request->validate($rules);
|
||||||
|
$result = $this->repository->store($request->all());
|
||||||
|
$resource = new ExamResource($result);
|
||||||
|
return $this->success($resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|string',
|
||||||
|
'begin' => 'required|date_format:Y-m-d H:i:s',
|
||||||
|
'end' => 'required|date_format:Y-m-d H:i:s',
|
||||||
|
'requires' => 'required|array|min:1',
|
||||||
|
'filters' => 'required|array|min:1',
|
||||||
|
];
|
||||||
|
$request->validate($rules);
|
||||||
|
$result = $this->repository->update($request->all(), $id);
|
||||||
|
$resource = new ExamResource($result);
|
||||||
|
return $this->success($resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,11 +8,11 @@ use Illuminate\Http\Request;
|
|||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
private $user;
|
private $repository;
|
||||||
|
|
||||||
public function __construct(UserRepository $user)
|
public function __construct(UserRepository $repository)
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->repository = $repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,9 +23,9 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$result = $this->user->getList($request->all());
|
$result = $this->repository->getList($request->all());
|
||||||
$resource = UserResource::collection($result);
|
$resource = UserResource::collection($result);
|
||||||
return success('user list', $resource);
|
return $this->success($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,9 +43,9 @@ class UserController extends Controller
|
|||||||
'password_confirmation' => 'required|string|same:password'
|
'password_confirmation' => 'required|string|same:password'
|
||||||
];
|
];
|
||||||
$request->validate($rules);
|
$request->validate($rules);
|
||||||
$result = $this->user->store($request->all());
|
$result = $this->repository->store($request->all());
|
||||||
$resource = new UserResource($result);
|
$resource = new UserResource($result);
|
||||||
return success('user store', $resource);
|
return $this->success($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,8 +90,14 @@ class UserController extends Controller
|
|||||||
'password_confirmation' => 'required|same:password',
|
'password_confirmation' => 'required|same:password',
|
||||||
];
|
];
|
||||||
$request->validate($rules);
|
$request->validate($rules);
|
||||||
$result = $this->user->resetPassword($request->username, $request->password, $request->password_confirmation);
|
$result = $this->repository->resetPassword($request->repositoryname, $request->password, $request->password_confirmation);
|
||||||
$resource = new UserResource($result);
|
$resource = new UserResource($result);
|
||||||
return success('user reset password', $resource);
|
return $this->success($resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function classes()
|
||||||
|
{
|
||||||
|
$result = $this->repository->listClass();
|
||||||
|
return $this->success($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ExamResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'description' => $this->description,
|
||||||
|
'begin' => $this->begin,
|
||||||
|
'end' => $this->end,
|
||||||
|
'filters' => $this->filters,
|
||||||
|
'requires' => $this->requires,
|
||||||
|
'status' => $this->status,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Exam extends NexusModel
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = ['name', 'description', 'begin', 'end', 'status'];
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExamProgress extends NexusModel
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = ['exam_id', 'uid', 'type_id', 'value'];
|
||||||
|
}
|
||||||
+46
-1
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
@@ -16,6 +15,52 @@ class User extends Authenticatable
|
|||||||
const STATUS_CONFIRMED = 'confirmed';
|
const STATUS_CONFIRMED = 'confirmed';
|
||||||
const STATUS_PENDING = 'pending';
|
const STATUS_PENDING = 'pending';
|
||||||
|
|
||||||
|
const CLASS_PEASANT = "0";
|
||||||
|
const CLASS_USER = "1";
|
||||||
|
const CLASS_POWER_USER = "2";
|
||||||
|
const CLASS_ELITE_USER = "3";
|
||||||
|
const CLASS_CRAZY_USER = "4";
|
||||||
|
const CLASS_INSANE_USER = "5";
|
||||||
|
const CLASS_VETERAN_USER = "6";
|
||||||
|
const CLASS_EXTREME_USER = "7";
|
||||||
|
const CLASS_ULTIMATE_USER = "8";
|
||||||
|
const CLASS_NEXUS_MASTER = "9";
|
||||||
|
const CLASS_VIP = "10";
|
||||||
|
const CLASS_RETIREE = "11";
|
||||||
|
const CLASS_UPLOADER = "12";
|
||||||
|
const CLASS_FORUM_MODERATOR = "12.1";
|
||||||
|
const CLASS_MODERATOR = "13";
|
||||||
|
const CLASS_ADMINISTRATOR = "14";
|
||||||
|
const CLASS_SYSOP = "15";
|
||||||
|
const CLASS_STAFFLEADER = "16";
|
||||||
|
|
||||||
|
public static $classes = [
|
||||||
|
self::CLASS_PEASANT => ['text' => 'Peasant'],
|
||||||
|
self::CLASS_USER => ['text' => 'User'],
|
||||||
|
self::CLASS_POWER_USER => ['text' => 'Power User'],
|
||||||
|
self::CLASS_ELITE_USER => ['text' => 'Elite User'],
|
||||||
|
self::CLASS_CRAZY_USER => ['text' => 'Crazy User'],
|
||||||
|
self::CLASS_INSANE_USER => ['text' => 'Insane User'],
|
||||||
|
self::CLASS_VETERAN_USER => ['text' => 'Veteran User'],
|
||||||
|
self::CLASS_EXTREME_USER => ['text' => 'Extreme User'],
|
||||||
|
self::CLASS_ULTIMATE_USER => ['text' => 'Eltimate User'],
|
||||||
|
self::CLASS_NEXUS_MASTER => ['text' => 'Nexus Master'],
|
||||||
|
self::CLASS_VIP => ['text' => 'Vip'],
|
||||||
|
self::CLASS_RETIREE => ['text' => 'Retiree'],
|
||||||
|
self::CLASS_UPLOADER => ['text' => 'Uploader'],
|
||||||
|
self::CLASS_FORUM_MODERATOR => ['text' => 'Forum Moderator'],
|
||||||
|
self::CLASS_MODERATOR => ['text' => 'Moderator'],
|
||||||
|
self::CLASS_ADMINISTRATOR => ['text' => 'Administrator'],
|
||||||
|
self::CLASS_SYSOP => ['text' => 'Sysop'],
|
||||||
|
self::CLASS_STAFFLEADER => ['text' => 'Staff Leader'],
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getClassTextAttribute()
|
||||||
|
{
|
||||||
|
return self::$classes[$this->class]['text'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 为数组 / JSON 序列化准备日期。
|
* 为数组 / JSON 序列化准备日期。
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use App\Models\Exam;
|
||||||
|
use App\Models\Setting;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class ExamRepository extends BaseRepository
|
||||||
|
{
|
||||||
|
public function getList(array $params)
|
||||||
|
{
|
||||||
|
$query = Exam::query();
|
||||||
|
list($sortField, $sortType) = $this->getSortFieldAndType($params);
|
||||||
|
$query->orderBy($sortField, $sortType);
|
||||||
|
return $query->paginate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(array $params)
|
||||||
|
{
|
||||||
|
$exam = Exam::query()->create($params);
|
||||||
|
return $exam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(array $params, $id)
|
||||||
|
{
|
||||||
|
$exam = Exam::query()->findOrFail($id);
|
||||||
|
$exam->update($params);
|
||||||
|
return $exam;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -53,4 +53,13 @@ class UserRepository extends BaseRepository
|
|||||||
$user->update($update);
|
$user->update($update);
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function listClass()
|
||||||
|
{
|
||||||
|
$out = [];
|
||||||
|
foreach(User::$classes as $key => $value) {
|
||||||
|
$out[(string)$key] = $value['text'];
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreatePasswordResetsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('password_resets', function (Blueprint $table) {
|
|
||||||
$table->string('email')->index();
|
|
||||||
$table->string('token');
|
|
||||||
$table->timestamp('created_at')->nullable();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('password_resets');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+9
-7
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class CreateUsersTable extends Migration
|
class CreateExamsTable extends Migration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
@@ -13,13 +13,15 @@ class CreateUsersTable extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('users', function (Blueprint $table) {
|
Schema::create('exams', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('email')->unique();
|
$table->text('description')->nullable();
|
||||||
$table->timestamp('email_verified_at')->nullable();
|
$table->dateTime('begin');
|
||||||
$table->string('password');
|
$table->dateTime('end');
|
||||||
$table->rememberToken();
|
$table->text('filters');
|
||||||
|
$table->text('requires');
|
||||||
|
$table->tinyInteger('status')->default(0);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -31,6 +33,6 @@ class CreateUsersTable extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('users');
|
Schema::dropIfExists('exams');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateExamProgressTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('exam_progress', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->integer('exam_id')->index();
|
||||||
|
$table->integer('uid')->index();
|
||||||
|
$table->integer('type_id');
|
||||||
|
$table->integer('value');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->index('created_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('exam_progress');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,4 +16,7 @@ use Illuminate\Support\Facades\Route;
|
|||||||
|
|
||||||
Route::group([], function () {
|
Route::group([], function () {
|
||||||
Route::resource('agent-allow', \App\Http\Controllers\AgentAllowController::class);
|
Route::resource('agent-allow', \App\Http\Controllers\AgentAllowController::class);
|
||||||
|
Route::resource('user', \App\Http\Controllers\UserController::class);
|
||||||
|
Route::resource('exam', \App\Http\Controllers\ExamController::class);
|
||||||
|
Route::get('class', [\App\Http\Controllers\UserController::class, 'classes']);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user