apply-list.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <PageShell>
  3. <div class="apply-page">
  4. <div class="apply-card">
  5. <div class="apply-title">报名列表</div>
  6. <div class="apply-toolbar">
  7. <div class="apply-search-box">
  8. <el-input v-model="queryParams.keyword" placeholder="请输入" clearable @keyup.enter="handleQuery" />
  9. <el-button type="primary" class="apply-search-button" @click="handleQuery">
  10. <el-icon><Search /></el-icon>
  11. </el-button>
  12. </div>
  13. <div class="apply-toolbar-actions">
  14. <el-button type="primary" plain @click="handleBack">返回</el-button>
  15. <el-button type="primary" plain @click="handleAddEmployee">添加员工</el-button>
  16. <el-button type="primary" @click="handleExport">导出列表</el-button>
  17. </div>
  18. </div>
  19. <el-table :data="pagedApplyList" class="apply-list-table" header-row-class-name="apply-table-header">
  20. <el-table-column label="姓名" prop="name" min-width="160">
  21. <template #default="{ row }">
  22. <el-button v-if="row.statusText !== '待测评'" link type="primary" @click="handleOpenDetail(row)">{{ row.name }}</el-button>
  23. <span v-else>{{ row.name }}</span>
  24. </template>
  25. </el-table-column>
  26. <el-table-column label="性别" prop="gender" width="80" align="center" />
  27. <el-table-column label="部门" prop="department" width="100" align="center" />
  28. <el-table-column label="手机号" prop="phone" min-width="160" align="center" />
  29. <el-table-column label="状态" min-width="160" align="center">
  30. <template #default="{ row }">
  31. <span class="apply-status-text">
  32. <span class="apply-status-dot" :class="`is-${row.statusType}`"></span>
  33. {{ row.statusText }}
  34. </span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="测评时间" prop="evaluateTime" min-width="180" align="center" />
  38. <el-table-column label="操作" width="160" align="center">
  39. <template #default="{ row }">
  40. <el-button v-if="row.actionType === 'detail'" link type="primary" @click="handleOpenDetail(row)">测评详情</el-button>
  41. <el-button v-else link type="primary" @click="handleRemove(row)">移除</el-button>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <pagination
  46. v-show="total > 0"
  47. v-model:page="queryParams.pageNum"
  48. v-model:limit="queryParams.pageSize"
  49. :total="total"
  50. @pagination="handlePagination"
  51. />
  52. </div>
  53. <el-dialog v-model="syncDialog.visible" title="同步测评" width="460px" append-to-body>
  54. <div class="sync-dialog-content">
  55. <div class="sync-dialog-row">
  56. <span class="sync-dialog-label">同步员工</span>
  57. <el-select
  58. v-model="syncDialog.employeeIds"
  59. multiple
  60. collapse-tags
  61. collapse-tags-tooltip
  62. placeholder="请选择"
  63. class="sync-dialog-select"
  64. :loading="syncOptionLoading"
  65. >
  66. <el-option v-for="item in employeeOptions" :key="item.id" :label="item.label" :value="item.id" />
  67. </el-select>
  68. </div>
  69. </div>
  70. <template #footer>
  71. <div class="sync-dialog-footer">
  72. <el-button @click="syncDialog.visible = false">取消</el-button>
  73. <el-button type="primary" :loading="syncLoading" @click="handleConfirmSync">确定</el-button>
  74. </div>
  75. </template>
  76. </el-dialog>
  77. </div>
  78. </PageShell>
  79. </template>
  80. <script setup name="EvaluationApplyList" lang="ts">
  81. import { computed, getCurrentInstance, onMounted, reactive, ref, type ComponentInternalInstance } from 'vue';
  82. import { useRoute, useRouter } from 'vue-router';
  83. import PageShell from '@/components/PageShell/index.vue';
  84. import { getEvaluationSyncEmployeeOptions, listEvaluationApply, removeEvaluationApply, syncEvaluationToEmployees } from '@/api/main/evaluation';
  85. import type { EvaluationApplyRow, EvaluationSyncEmployeeOption } from '@/api/main/evaluation/types';
  86. type SyncEmployeeOption = EvaluationSyncEmployeeOption & { label: string };
  87. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  88. const router = useRouter();
  89. const route = useRoute();
  90. const modal = proxy?.$modal as any;
  91. const loading = ref(false);
  92. const syncLoading = ref(false);
  93. const syncOptionLoading = ref(false);
  94. const employeeOptions = ref<SyncEmployeeOption[]>([]);
  95. const syncDialog = reactive({
  96. visible: false,
  97. employeeIds: [] as Array<string | number>
  98. });
  99. const evaluationId = computed(() => String(route.query.evaluationId || ''));
  100. const queryParams = reactive({
  101. pageNum: 1,
  102. pageSize: 10,
  103. keyword: ''
  104. });
  105. const allApplyList = ref<EvaluationApplyRow[]>([]);
  106. const total = ref(0);
  107. const pagedApplyList = computed(() => allApplyList.value);
  108. const loadSyncEmployeeOptions = async () => {
  109. syncOptionLoading.value = true;
  110. try {
  111. const res = await getEvaluationSyncEmployeeOptions();
  112. const rows = res.data || [];
  113. employeeOptions.value = rows.map((item) => ({
  114. ...item,
  115. label: [item.name, item.mobile, item.studentNo].filter(Boolean).join(' / ')
  116. }));
  117. } finally {
  118. syncOptionLoading.value = false;
  119. }
  120. };
  121. const getList = async () => {
  122. if (!evaluationId.value) {
  123. allApplyList.value = [];
  124. total.value = 0;
  125. return;
  126. }
  127. loading.value = true;
  128. try {
  129. const res = await listEvaluationApply({
  130. evaluationId: evaluationId.value,
  131. keyword: queryParams.keyword.trim(),
  132. pageNum: queryParams.pageNum,
  133. pageSize: queryParams.pageSize
  134. });
  135. allApplyList.value = res.rows || [];
  136. total.value = res.total || 0;
  137. } finally {
  138. loading.value = false;
  139. }
  140. };
  141. const handleQuery = () => {
  142. queryParams.pageNum = 1;
  143. getList();
  144. };
  145. const handlePagination = () => {
  146. getList();
  147. };
  148. const handleAddEmployee = () => {
  149. syncDialog.employeeIds = [];
  150. syncDialog.visible = true;
  151. if (!employeeOptions.value.length) {
  152. loadSyncEmployeeOptions();
  153. }
  154. };
  155. const handleExport = () => {
  156. if (!evaluationId.value) {
  157. modal?.msgWarning('测评ID不能为空');
  158. return;
  159. }
  160. proxy?.download(
  161. '/main/examEvaluation/applyList/export',
  162. {
  163. evaluationId: evaluationId.value,
  164. keyword: queryParams.keyword.trim()
  165. },
  166. `evaluation_apply_${new Date().getTime()}.xlsx`
  167. );
  168. };
  169. const handleConfirmSync = async () => {
  170. if (!syncDialog.employeeIds.length) {
  171. modal?.msgWarning('请选择员工');
  172. return;
  173. }
  174. syncLoading.value = true;
  175. try {
  176. await syncEvaluationToEmployees({
  177. evaluationIds: [evaluationId.value],
  178. studentIds: syncDialog.employeeIds
  179. });
  180. syncDialog.visible = false;
  181. modal?.msgSuccess('同步成功');
  182. await getList();
  183. } finally {
  184. syncLoading.value = false;
  185. }
  186. };
  187. const handleRemove = async (row: EvaluationApplyRow) => {
  188. await removeEvaluationApply(row.id);
  189. modal?.msgSuccess('已移除');
  190. await getList();
  191. };
  192. const handleOpenDetail = (row: EvaluationApplyRow) => {
  193. router.push({
  194. path: '/evaluation/evaluation-view',
  195. query: {
  196. applyId: String(row.id),
  197. studentId: String(row.studentId || ''),
  198. name: row.name || '',
  199. evaluationId: String(route.query.evaluationId || '')
  200. }
  201. });
  202. };
  203. const handleBack = () => {
  204. const raw = route.query.backPath;
  205. const backPath = Array.isArray(raw) ? raw[0] : raw || '';
  206. if (!backPath) {
  207. router.back();
  208. return;
  209. }
  210. const url = String(backPath + 'Manage');
  211. // 如果是完整的 http(s) 链接,直接跳转到该地址
  212. if (/^https?:\/\//i.test(url)) {
  213. window.location.href = url;
  214. return;
  215. }
  216. // 否则使用 vue-router 跳转(相对或绝对路径)
  217. try {
  218. router.push({ path: url });
  219. } catch (e) {
  220. router.push(url as any);
  221. }
  222. };
  223. onMounted(() => {
  224. getList();
  225. });
  226. </script>
  227. <style scoped>
  228. .apply-page {
  229. min-height: 100%;
  230. }
  231. .apply-card {
  232. min-height: calc(100vh - 180px);
  233. padding: 18px 18px 12px;
  234. background: #fff;
  235. border-radius: 4px;
  236. display: flex;
  237. flex-direction: column;
  238. box-sizing: border-box;
  239. }
  240. .apply-title {
  241. margin-bottom: 10px;
  242. font-size: 16px;
  243. font-weight: 600;
  244. color: #303133;
  245. }
  246. .apply-toolbar {
  247. display: flex;
  248. align-items: center;
  249. justify-content: space-between;
  250. gap: 16px;
  251. margin-bottom: 14px;
  252. }
  253. .apply-search-box {
  254. display: flex;
  255. align-items: stretch;
  256. width: 290px;
  257. }
  258. .apply-search-box :deep(.el-input__wrapper) {
  259. border-radius: 4px 0 0 4px;
  260. }
  261. .apply-search-button {
  262. width: 36px;
  263. padding: 0;
  264. border-radius: 0 4px 4px 0;
  265. }
  266. .apply-toolbar-actions {
  267. display: flex;
  268. align-items: center;
  269. gap: 14px;
  270. }
  271. .apply-list-table {
  272. flex: 1;
  273. }
  274. .apply-list-table :deep(.apply-table-header th) {
  275. height: 48px;
  276. color: #303133;
  277. font-weight: 600;
  278. background: #eef4ff;
  279. }
  280. .apply-list-table :deep(.el-table__row td) {
  281. height: 46px;
  282. }
  283. .apply-status-text {
  284. display: inline-flex;
  285. align-items: center;
  286. gap: 6px;
  287. }
  288. .apply-status-dot {
  289. width: 6px;
  290. height: 6px;
  291. border-radius: 50%;
  292. background: #c0c4cc;
  293. }
  294. .apply-status-dot.is-success {
  295. background: #67c23a;
  296. }
  297. .apply-status-dot.is-danger {
  298. background: #f56c6c;
  299. }
  300. .apply-status-dot.is-warning {
  301. background: #e6a23c;
  302. }
  303. .apply-status-dot.is-info {
  304. background: #909399;
  305. }
  306. .apply-card :deep(.pagination-container) {
  307. display: flex;
  308. justify-content: flex-end;
  309. margin-top: auto;
  310. padding: 16px 0 0;
  311. }
  312. .sync-dialog-content {
  313. padding: 10px 4px 24px;
  314. }
  315. .sync-dialog-row {
  316. display: flex;
  317. align-items: center;
  318. gap: 16px;
  319. }
  320. .sync-dialog-label {
  321. width: 56px;
  322. color: #303133;
  323. flex-shrink: 0;
  324. }
  325. .sync-dialog-select {
  326. flex: 1;
  327. }
  328. .sync-dialog-footer {
  329. display: flex;
  330. justify-content: flex-end;
  331. gap: 12px;
  332. }
  333. </style>