sign.vue 8.8 KB

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