sign.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <el-col :span="24" class="one">
  6. <div class="one_right">
  7. <el-input v-model="searchForm.name" style="width: 250px" size="large" placeholder="搜索" @change="search" :suffix-icon="Search" />
  8. </div>
  9. </el-col>
  10. <el-col :span="24" class="two">
  11. <el-table :data="list" style="width: 100%" size="large" :header-cell-style="{ backgroundColor: '#edf3ff' }">
  12. <template #empty>
  13. <el-empty description="暂无数据" />
  14. </template>
  15. <el-table-column prop="name" align="center" label="姓名" />
  16. <el-table-column prop="phone" align="center" label="手机号" width="180" />
  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 v-if="row.status == '0'" :underline="false" type="warning" size="mini" @click="toExam(row)" style="margin-right: 10px">审核</el-link>
  26. <el-link :underline="false" type="primary" size="mini" @click="toView(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. <custom-form v-model="form" :fields="formFields" :useSave="false">
  40. <template #cardType>
  41. <el-option v-for="i in cardTypeList" :key="i.id" :label="i.label" :value="i.value"></el-option>
  42. </template>
  43. </custom-form>
  44. </el-col>
  45. <el-col :span="24" v-if="dialog.type == '2'">
  46. <custom-form v-model="examForm" :fields="examFormFields" :rules="examRules" @save="toExamSave" :DraftSave="false" submitText="保存">
  47. <template #status>
  48. <el-option v-for="i in statusList" :key="i.id" :label="i.label" :value="i.value"></el-option>
  49. </template>
  50. </custom-form>
  51. </el-col>
  52. </el-row>
  53. </el-dialog>
  54. </div>
  55. </template>
  56. <script setup>
  57. import { Search } from '@element-plus/icons-vue'
  58. import { cloneDeep, get } from 'lodash-es'
  59. const $checkRes = inject('$checkRes')
  60. import { UserStore } from '@/store/user'
  61. const userStore = UserStore()
  62. const user = computed(() => userStore.user)
  63. // 接口
  64. import { SignStore } from '@/store/api/platform/sign'
  65. import { DictDataStore } from '@/store/api/system/dictData'
  66. const store = SignStore()
  67. const dictDataStore = DictDataStore()
  68. // 加载中
  69. const loading = ref(false)
  70. const searchForm = ref({})
  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 props = defineProps({
  78. matchForm: { type: Object, default: () => {} }
  79. })
  80. const { matchForm } = toRefs(props)
  81. // 字典表
  82. const cardTypeList = ref([])
  83. const statusList = ref([])
  84. const form = ref({})
  85. const dialog = ref({ type: '1', show: false, title: '报名管理' })
  86. const formFields = ref([
  87. { label: '姓名', model: 'name' },
  88. { label: '手机号', model: 'phone' },
  89. { label: '证件类型', model: 'cardType', type: 'select' },
  90. { label: '证件号码', model: 'card' },
  91. { label: '报名时间', model: 'time' },
  92. { label: '微信/QQ', model: 'communication' },
  93. { label: '电子邮箱', model: 'email' },
  94. { label: '备注', model: 'remark', type: 'textarea' }
  95. ])
  96. // 审核
  97. const examFormFields = [{ label: '状态', model: 'status', type: 'select' }]
  98. const examRules = reactive({
  99. status: [{ required: true, message: '请选项状态', trigger: 'blur' }]
  100. })
  101. const examForm = ref({})
  102. // 请求
  103. onMounted(async () => {
  104. loading.value = true
  105. await searchOther()
  106. await search()
  107. loading.value = false
  108. })
  109. const search = async (query = { skip, limit }) => {
  110. skip = query.skip
  111. limit = query.limit
  112. const info = {
  113. skip: query.skip,
  114. limit: query.limit,
  115. match: matchForm.value.id,
  116. ...searchForm.value
  117. }
  118. const res = await store.query(info)
  119. if (res.errcode == '0') {
  120. list.value = res.data
  121. total.value = res.total
  122. }
  123. }
  124. const searchOther = async () => {
  125. let result
  126. // 证件类型
  127. result = await dictDataStore.query({ code: 'cardType', is_use: '0' })
  128. if ($checkRes(result)) cardTypeList.value = result.data
  129. // 状态
  130. result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
  131. if ($checkRes(result)) statusList.value = result.data
  132. }
  133. // 字典数据转换
  134. const getDict = (data, model) => {
  135. if (data) {
  136. let res
  137. if (model == 'status') res = statusList.value.find((f) => f.value == data)
  138. return get(res, 'label')
  139. }
  140. }
  141. // 查看
  142. const toView = (data) => {
  143. form.value = data
  144. dialog.value = { type: '1', show: true, title: '查看报名' }
  145. }
  146. // 审核
  147. const toExam = (data) => {
  148. examForm.value = data
  149. dialog.value = { type: '2', show: true, title: '报名审核' }
  150. }
  151. // 审核保存
  152. const toExamSave = async () => {
  153. const data = cloneDeep(examForm.value)
  154. let res = await store.update({ id: data.id, status: data.status })
  155. if ($checkRes(res, true)) {
  156. search({ skip, limit })
  157. toClose()
  158. }
  159. }
  160. const toClose = () => {
  161. form.value = {}
  162. dialog.value = { show: false }
  163. }
  164. // 分页
  165. const changePage = (page = currentPage.value) => {
  166. search({ skip: (page - 1) * limit, limit: limit })
  167. }
  168. const sizeChange = (limits) => {
  169. limit = limits
  170. currentPage.value = 1
  171. search({ skip: 0, limit: limit })
  172. }
  173. </script>
  174. <style scoped lang="scss">
  175. .main {
  176. .one {
  177. height: 50px;
  178. display: flex;
  179. justify-content: space-between;
  180. align-items: center;
  181. margin: 0 0 10px 0;
  182. .one_left {
  183. background: #1875df;
  184. padding: 0 10px;
  185. height: 30px;
  186. color: #fff;
  187. line-height: 30px;
  188. text-align: center;
  189. font-size: 16px;
  190. cursor: default;
  191. }
  192. }
  193. .thr {
  194. display: flex;
  195. justify-content: center;
  196. margin: 20px 0 0 0;
  197. }
  198. }
  199. </style>