liuyu
21 小时以前 93c133349a5ccd7a328371fa113dce69d5611f21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { ref } from 'vue';
 
import { useBaseStore } from '#/store';
import { TMS_DIC, labelOfDic, loadTmsDic, type TmsDicOpt } from '#/views/x/tms/shared/dic';
 
/** 我的试卷「未开始」为前端态,字典 tmsExamStatus 不含该项 */
const NOT_STARTED: TmsDicOpt = { id: 'notStarted', enCode: 'notStarted', fullName: '未开始' };
 
const STATUS_COLOR: Record<string, string> = {
  notStarted: '#8c8c8c',
  doing: '#1890ff',
  submitted: '#52c41a',
  cancelled: '#ff4d4f',
};
 
export const MY_PAPER_STATUS_OPTIONS = ref<TmsDicOpt[]>([NOT_STARTED]);
export const PASS_FLAG_OPTIONS = ref<TmsDicOpt[]>([]);
 
export async function loadOnlineExamDics() {
  const baseStore = useBaseStore();
  const [examStatus, passFlag] = await Promise.all([
    loadTmsDic(baseStore, TMS_DIC.examStatus),
    loadTmsDic(baseStore, TMS_DIC.passFlag),
  ]);
  const rest = examStatus.filter((x) => (x.enCode || x.id) !== 'notStarted');
  MY_PAPER_STATUS_OPTIONS.value = [NOT_STARTED, ...rest];
  PASS_FLAG_OPTIONS.value = passFlag;
}
 
export function labelOfMyPaperStatus(v?: string) {
  return labelOfDic(MY_PAPER_STATUS_OPTIONS.value, v);
}
 
export function colorOfMyPaperStatus(v?: string) {
  return (v && STATUS_COLOR[v]) || undefined;
}
 
export function labelOfPassFlag(v?: string | null) {
  if (v == null || v === '') return '-';
  const code = String(v);
  if (code === '1') return '合格';
  if (code === '0') return '不合格';
  return labelOfDic(PASS_FLAG_OPTIONS.value, code);
}
 
export function colorOfPassFlag(v?: string | null) {
  if (v === '1') return '#52c41a';
  if (v === '0') return '#ff4d4f';
  return undefined;
}
 
export function labelOfGradeStatus(v?: string | null) {
  if (!v) return '-';
  if (v === 'auto') return '自动阅卷';
  if (v === 'pending') return '待阅卷';
  if (v === 'graded') return '已阅卷';
  return v;
}