123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <template>
- <div class="index">
- <el-row>
- <el-col :span="24" class="main" v-loading="loading">
- <el-col :span="24" class="one">
- <el-radio-group size="large" v-model="type">
- <el-radio-button label="活动报名" value="1" />
- <el-radio-button label="大赛报名" value="2" />
- </el-radio-group>
- </el-col>
- <div v-if="type == '1'">
- <el-col :span="24" class="two">
- <el-table :data="list" style="width: 100%" size="large" :header-cell-style="{ backgroundColor: '#edf3ff' }">
- <template #empty>
- <el-empty description="暂无数据" />
- </template>
- <el-table-column prop="matchInfo.name" align="center" label="活动名称" />
- <el-table-column prop="time" align="center" label="报名时间" width="180" />
- <el-table-column prop="status" align="center" label="状态" width="180">
- <template #default="scope">
- <div>{{ getDict(scope.row.status, 'status') }}</div>
- </template>
- </el-table-column>
- <el-table-column align="center" label="操作" width="180">
- <template #default="{ row }">
- <el-link :underline="false" type="primary" size="mini" @click="toView(row)" style="margin-right: 10px">查看活动</el-link>
- <el-link :underline="false" v-if="row.status != '1'" type="warning" size="mini" @click="toEdit(row)" style="margin-right: 10px">修改报名信息</el-link>
- </template>
- </el-table-column>
- </el-table>
- </el-col>
- <el-col :span="24" class="thr">
- <el-pagination background layout="prev, pager, next" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange" />
- </el-col>
- </div>
- <div v-else>
- <preliminary :userInfo="user"></preliminary>
- </div>
- </el-col>
- </el-row>
- <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose">
- <el-row>
- <el-col :span="24" v-if="dialog.type == '1'">
- <form2 v-if="form.matchInfo && form.matchInfo.form == '3'"></form2>
- <form1 v-else></form1>
- </el-col>
- </el-row>
- </el-dialog>
- </div>
- </template>
- <script setup>
- // 组件
- import form1 from './parts/form-1.vue'
- import form2 from './parts/form-2.vue'
- import preliminary from './parts/preliminaryUser.vue'
- import moment from 'moment'
- import { cloneDeep, get } from 'lodash-es'
- const $checkRes = inject('$checkRes')
- import { UserStore } from '@/store/user'
- const userStore = UserStore()
- const user = computed(() => userStore.user)
- // 接口
- import { SignStore } from '@/store/api/platform/sign'
- import { DictDataStore } from '@/store/api/system/dictData'
- const store = SignStore()
- const dictDataStore = DictDataStore()
- // 加载中
- const loading = ref(false)
- // 路由
- const router = useRouter()
- // 列表
- const list = ref([])
- let skip = 0
- let limit = inject('limit')
- const total = ref(0)
- const currentPage = ref(1)
- const dialog = ref({ type: '1', show: false, title: '修改报名信息' })
- const ruleFormRef = ref()
- const form = ref({ project_file: [] })
- const type = ref('1')
- const validatePhoneNumber = (rule, value, callback) => {
- const reg = /^1[3-9]\d{9}$/
- if (!value) {
- return callback(new Error('手机号不能为空'))
- }
- if (!reg.test(value)) {
- return callback(new Error('请输入正确的手机号'))
- }
- callback()
- }
- const validateCardNumber = (rule, value, callback) => {
- var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
- if (!value) {
- return callback(new Error('证件号码不能为空'))
- }
- if (!reg.test(value)) {
- return callback(new Error('请输入正确的证件号码'))
- }
- callback()
- }
- const rules = reactive({
- name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
- phone: [{ required: true, validator: validatePhoneNumber, trigger: 'blur' }],
- cardType: [{ required: true, message: '请选择证件类型', trigger: 'change' }],
- card: [{ required: true, validator: validateCardNumber, trigger: 'change' }],
- remark: [{ required: true, message: '请输入备注', trigger: 'blur' }]
- })
- // 字典表
- const statusList = ref([])
- const cardTypeList = ref([])
- const signTypeList = ref([])
- // 请求
- onMounted(async () => {
- loading.value = true
- await searchOther()
- await search()
- loading.value = false
- })
- const search = async (query = { skip, limit }) => {
- skip = query.skip
- limit = query.limit
- const info = {
- skip: query.skip,
- limit: query.limit,
- user: user.value.id
- // ...searchForm.value
- }
- const res = await store.sign(info)
- if (res.errcode == '0') {
- list.value = res.data
- total.value = res.total
- }
- }
- const searchOther = async () => {
- let result
- // 状态
- result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
- if ($checkRes(result)) statusList.value = result.data
- // 证件类型
- result = await dictDataStore.query({ code: 'cardType', is_use: '0' })
- if ($checkRes(result)) cardTypeList.value = result.data
- // 报名类型
- result = await dictDataStore.query({ code: 'signType', is_use: '0' })
- if ($checkRes(result)) signTypeList.value = result.data
- }
- // 字典数据转换
- const getDict = (data, model) => {
- if (data) {
- let res
- if (model == 'status') res = statusList.value.find((f) => f.value == data)
- return get(res, 'label')
- }
- }
- // 修改
- const toEdit = (data) => {
- form.value = data
- dialog.value = { type: '1', show: true, title: '修改报名信息' }
- }
- // 查看赛事
- const toView = (item) => {
- router.push({ path: '/match/detail', query: { id: item.match } })
- }
- // 报名
- const submitForm = async (formEl) => {
- if (!formEl) return
- await formEl.validate(async (valid, fields) => {
- if (valid) {
- ElMessageBox.confirm(`您确定修改该数据将会重新审核?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
- .then(async () => {
- const data = cloneDeep(form.value)
- const other = { time: moment().format('YYYY-MM-DD'), status: '0' }
- let res = await store.update({ ...data, ...other })
- if ($checkRes(res, true)) {
- await toClose()
- await search()
- } else {
- ElMessage({ message: `${res.errmsg}`, type: 'error' })
- }
- })
- .catch(() => {})
- } else {
- console.log('error submit!', fields)
- }
- })
- }
- const toClose = () => {
- form.value = { project_file: [] }
- dialog.value = { show: false }
- }
- // 分页
- const changePage = (page = currentPage.value) => {
- search({ skip: (page - 1) * limit, limit: limit })
- }
- const sizeChange = (limits) => {
- limit = limits
- currentPage.value = 1
- search({ skip: 0, limit: limit })
- }
- // provide
- provide('form', form)
- provide('rules', rules)
- provide('ruleFormRef', ruleFormRef)
- provide('cardTypeList', cardTypeList)
- provide('signTypeList', signTypeList)
- provide('submitForm', submitForm)
- </script>
- <style scoped lang="scss">
- .main {
- .one {
- margin: 0 0 10px 0;
- }
- .thr {
- display: flex;
- justify-content: center;
- margin: 20px 0 0 0;
- }
- .button {
- text-align: center;
- }
- }
- </style>
|