sign.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="index">
  3. <el-row>
  4. <el-col :span="24" class="main" v-loading="loading">
  5. <el-col :span="24" class="one">
  6. <el-radio-group size="large" v-model="type">
  7. <el-radio-button label="活动报名" value="1" />
  8. <el-radio-button label="大赛报名" value="2" />
  9. </el-radio-group>
  10. </el-col>
  11. <div v-if="type == '1'">
  12. <el-col :span="24" class="two">
  13. <el-table :data="list" style="width: 100%" size="large" :header-cell-style="{ backgroundColor: '#edf3ff' }">
  14. <template #empty>
  15. <el-empty description="暂无数据" />
  16. </template>
  17. <el-table-column prop="matchInfo.name" align="center" label="活动名称" />
  18. <el-table-column prop="time" align="center" label="报名时间" width="180" />
  19. <el-table-column prop="status" align="center" label="状态" width="180">
  20. <template #default="scope">
  21. <div>{{ getDict(scope.row.status, 'status') }}</div>
  22. </template>
  23. </el-table-column>
  24. <el-table-column align="center" label="操作" width="180">
  25. <template #default="{ row }">
  26. <el-link :underline="false" type="primary" size="mini" @click="toView(row)" style="margin-right: 10px">查看活动</el-link>
  27. <el-link :underline="false" v-if="row.status != '1'" type="warning" size="mini" @click="toEdit(row)" style="margin-right: 10px">修改报名信息</el-link>
  28. </template>
  29. </el-table-column>
  30. </el-table>
  31. </el-col>
  32. <el-col :span="24" class="thr">
  33. <el-pagination background layout="prev, pager, next" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange" />
  34. </el-col>
  35. </div>
  36. <div v-else>
  37. <preliminary :userInfo="user"></preliminary>
  38. </div>
  39. </el-col>
  40. </el-row>
  41. <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose">
  42. <el-row>
  43. <el-col :span="24" v-if="dialog.type == '1'">
  44. <form2 v-if="form.matchInfo && form.matchInfo.form == '3'"></form2>
  45. <form1 v-else></form1>
  46. </el-col>
  47. </el-row>
  48. </el-dialog>
  49. </div>
  50. </template>
  51. <script setup>
  52. // 组件
  53. import form1 from './parts/form-1.vue'
  54. import form2 from './parts/form-2.vue'
  55. import preliminary from './parts/preliminaryUser.vue'
  56. import moment from 'moment'
  57. import { cloneDeep, get } from 'lodash-es'
  58. const $checkRes = inject('$checkRes')
  59. import { UserStore } from '@/store/user'
  60. const userStore = UserStore()
  61. const user = computed(() => userStore.user)
  62. // 接口
  63. import { SignStore } from '@/store/api/platform/sign'
  64. import { DictDataStore } from '@/store/api/system/dictData'
  65. const store = SignStore()
  66. const dictDataStore = DictDataStore()
  67. // 加载中
  68. const loading = ref(false)
  69. // 路由
  70. const router = useRouter()
  71. // 列表
  72. const list = ref([])
  73. let skip = 0
  74. let limit = inject('limit')
  75. const total = ref(0)
  76. const currentPage = ref(1)
  77. const dialog = ref({ type: '1', show: false, title: '修改报名信息' })
  78. const ruleFormRef = ref()
  79. const form = ref({ project_file: [] })
  80. const type = ref('1')
  81. const validatePhoneNumber = (rule, value, callback) => {
  82. const reg = /^1[3-9]\d{9}$/
  83. if (!value) {
  84. return callback(new Error('手机号不能为空'))
  85. }
  86. if (!reg.test(value)) {
  87. return callback(new Error('请输入正确的手机号'))
  88. }
  89. callback()
  90. }
  91. const validateCardNumber = (rule, value, callback) => {
  92. var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  93. if (!value) {
  94. return callback(new Error('证件号码不能为空'))
  95. }
  96. if (!reg.test(value)) {
  97. return callback(new Error('请输入正确的证件号码'))
  98. }
  99. callback()
  100. }
  101. const rules = reactive({
  102. name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
  103. phone: [{ required: true, validator: validatePhoneNumber, trigger: 'blur' }],
  104. cardType: [{ required: true, message: '请选择证件类型', trigger: 'change' }],
  105. card: [{ required: true, validator: validateCardNumber, trigger: 'change' }],
  106. remark: [{ required: true, message: '请输入备注', trigger: 'blur' }]
  107. })
  108. // 字典表
  109. const statusList = ref([])
  110. const cardTypeList = ref([])
  111. const signTypeList = ref([])
  112. const extList = ref([])
  113. const isUseList = ref([])
  114. // 请求
  115. onMounted(async () => {
  116. loading.value = true
  117. await searchOther()
  118. await search()
  119. loading.value = false
  120. })
  121. const search = async (query = { skip, limit }) => {
  122. skip = query.skip
  123. limit = query.limit
  124. const info = {
  125. skip: query.skip,
  126. limit: query.limit,
  127. user: user.value.id
  128. // ...searchForm.value
  129. }
  130. const res = await store.sign(info)
  131. if (res.errcode == '0') {
  132. list.value = res.data
  133. total.value = res.total
  134. }
  135. }
  136. const searchOther = async () => {
  137. let result
  138. // 状态
  139. result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
  140. if ($checkRes(result)) statusList.value = result.data
  141. // 证件类型
  142. result = await dictDataStore.query({ code: 'cardType', is_use: '0' })
  143. if ($checkRes(result)) cardTypeList.value = result.data
  144. // 报名类型
  145. result = await dictDataStore.query({ code: 'signType', is_use: '0' })
  146. if ($checkRes(result)) signTypeList.value = result.data
  147. // 流程状态
  148. result = await dictDataStore.query({ code: 'extStatus', is_use: '0' })
  149. if ($checkRes(result)) extList.value = result.data
  150. // 是否使用
  151. result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
  152. if ($checkRes(result)) isUseList.value = result.data
  153. }
  154. // 字典数据转换
  155. const getDict = (data, model) => {
  156. if (data) {
  157. let res
  158. if (model == 'status') res = statusList.value.find((f) => f.value == data)
  159. return get(res, 'label')
  160. }
  161. }
  162. // 修改
  163. const toEdit = (data) => {
  164. form.value = data
  165. dialog.value = { type: '1', show: true, title: '修改报名信息' }
  166. }
  167. // 查看赛事
  168. const toView = (item) => {
  169. router.push({ path: '/match/detail', query: { id: item.match } })
  170. }
  171. // 报名
  172. const submitForm = async (formEl) => {
  173. if (!formEl) return
  174. await formEl.validate(async (valid, fields) => {
  175. if (valid) {
  176. ElMessageBox.confirm(`您确定修改该数据将会重新审核?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
  177. .then(async () => {
  178. const data = cloneDeep(form.value)
  179. const other = { time: moment().format('YYYY-MM-DD'), status: '0' }
  180. let res = await store.update({ ...data, ...other })
  181. if ($checkRes(res, true)) {
  182. await toClose()
  183. await search()
  184. } else {
  185. ElMessage({ message: `${res.errmsg}`, type: 'error' })
  186. }
  187. })
  188. .catch(() => {})
  189. } else {
  190. console.log('error submit!', fields)
  191. }
  192. })
  193. }
  194. const toClose = () => {
  195. form.value = { project_file: [] }
  196. dialog.value = { show: false }
  197. }
  198. // 分页
  199. const changePage = (page = currentPage.value) => {
  200. search({ skip: (page - 1) * limit, limit: limit })
  201. }
  202. const sizeChange = (limits) => {
  203. limit = limits
  204. currentPage.value = 1
  205. search({ skip: 0, limit: limit })
  206. }
  207. // provide
  208. provide('form', form)
  209. provide('rules', rules)
  210. provide('ruleFormRef', ruleFormRef)
  211. provide('cardTypeList', cardTypeList)
  212. provide('signTypeList', signTypeList)
  213. provide('extList', extList)
  214. provide('isUseList', isUseList)
  215. provide('submitForm', submitForm)
  216. </script>
  217. <style scoped lang="scss">
  218. .main {
  219. .one {
  220. margin: 0 0 10px 0;
  221. }
  222. .thr {
  223. display: flex;
  224. justify-content: center;
  225. margin: 20px 0 0 0;
  226. }
  227. .button {
  228. text-align: center;
  229. }
  230. }
  231. </style>