提交 06f0cb6a authored 作者: lhh's avatar lhh

赛项配置需求修改

上级 1ffc22ab
......@@ -58,6 +58,8 @@ const form = reactive({
dateRange: undefined,
date: undefined,
datetimeRange: undefined,
datetimeRange2: undefined,
is_switchable_theory_practice: 0,
train_platform_configs: [
{ name: appConfig.xTrainLabel || '1+X理论考试', is_show: '1', type: '1', url: '', platform_key: 'x_exam' },
{
......@@ -75,8 +77,8 @@ const form = reactive({
is_show: '1',
type: '1',
url: '',
platform_key: 'x_exam',
exam_id: ''
exam_id: '',
platform_key: 'x_exam'
},
// {
// name: appConfig.labExamLabel || '商业数据分析实验',
......@@ -97,6 +99,11 @@ watchEffect(() => {
const dateRange = [new Date(props.data.start_range * 1000), new Date(props.data.end_range * 1000)]
const date = new Date(props.data.start_at * 1000)
const datetimeRange = [new Date(props.data.start_at * 1000), new Date(props.data.end_at * 1000)]
const datetimeRange2 = [
new Date(props.data.operational_start_time * 1000),
new Date(props.data.operational_end_time * 1000)
]
const is_switchable_theory_practice = parseInt(props.data.is_switchable_theory_practice)
const apply_expiration_date = props.data.apply_expiration_date * 1000
Object.assign(form, props.data, {
host_unit_id,
......@@ -106,7 +113,9 @@ watchEffect(() => {
dateRange,
date,
datetimeRange,
apply_expiration_date
datetimeRange2,
apply_expiration_date,
is_switchable_theory_practice
})
})
const checkApplyExpirationDate = (rule: any, value: any, callback: any) => {
......@@ -134,10 +143,18 @@ const checkTrainPlatformConfigs = (rule: any, value: any, callback: any) => {
} else {
form.train_platform_configs.forEach((item: any) => {
if (item.is_show === '1') {
if (item.url === '') {
callback(new Error(`请填写${item.name}的链接`))
if (item.type === '1') {
if (item.exam_id === '') {
callback(new Error(`请选择${item.name}`))
} else {
callback()
}
} else {
callback()
if (item.url === '') {
callback(new Error(`请填写${item.name}的链接`))
} else {
callback()
}
}
}
})
......@@ -154,10 +171,18 @@ const checkCompetitionPlatformConfigs = (rule: any, value: any, callback: any) =
} else {
form.competition_platform_configs.forEach((item: any) => {
if (item.is_show === '1') {
if (item.url === '') {
callback(new Error(`请填写${item.name}的链接`))
if (item.type === '1') {
if (item.exam_id === '') {
callback(new Error(`请选择${item.name}`))
} else {
callback()
}
} else {
callback()
if (item.url === '') {
callback(new Error(`请填写${item.name}的链接`))
} else {
callback()
}
}
}
})
......@@ -172,7 +197,8 @@ const rules = ref<FormRules>({
teacher_ids: [{ type: 'array', required: true, message: '请选择指导教师', trigger: 'change' }],
dateRange: [{ type: 'array', required: true, message: '请选择赛项周期', trigger: 'change' }],
date: [{ required: true, message: '请选择正式比赛日期', trigger: 'change' }],
datetimeRange: [{ type: 'array', required: true, message: '请选择正式比赛时间', trigger: 'change' }],
datetimeRange: [{ type: 'array', required: true, message: '正式比赛理论答题时间', trigger: 'change' }],
datetimeRange2: [{ type: 'array', required: true, message: '正式比赛实操答题时间', trigger: 'change' }],
apply_expiration_date: [
{ required: true, message: '请选择报名截止日期' },
{
......@@ -183,6 +209,7 @@ const rules = ref<FormRules>({
// train_platform_uri: [{ required: true, message: '请输入训练平台地址' }],
// competition_uri: [{ required: true, message: '请输入正式比赛地址' }],
status: [{ required: true, message: '请选择有效状态' }],
is_switchable_theory_practice: [{ required: true, message: '请选择' }],
logo: [{ required: true, message: '请上传赛项LOGO' }],
cover: [{ required: true, message: '请上传赛项封面' }],
train_platform_configs: [{ required: true, message: '' }, { validator: checkTrainPlatformConfigs }],
......@@ -208,6 +235,7 @@ function handleSubmit() {
formRef?.validate().then(() => {
const [firstDate, secondDate] = form.dateRange || []
const [firstDatetime, secondDatetime] = form.datetimeRange || []
const [firstDatetime2, secondDatetime2] = form.datetimeRange2 || []
const year = dayjs(form.date).year()
const month = dayjs(form.date).month()
const date = dayjs(form.date).date()
......@@ -219,22 +247,27 @@ function handleSubmit() {
end_range: dayjs(secondDate).endOf('date').unix(),
start_at: dayjs(firstDatetime).year(year).month(month).date(date).unix(),
end_at: dayjs(secondDatetime).year(year).month(month).date(date).unix(),
operational_start_time: dayjs(firstDatetime2).year(year).month(month).date(date).unix(),
operational_end_time: dayjs(secondDatetime2).year(year).month(month).date(date).unix(),
apply_expiration_date: dayjs(form.apply_expiration_date).endOf('date').unix()
}
// 判断正式比赛理论答题时间和选择的考试
const findExam = examList.find(item => item.exam_id === form.competition_platform_configs[0].exam_id)
const examStartTime = new Date(findExam?.start_time || '').getTime()
const examEndTime = new Date(findExam?.start_time || '').getTime()
const examEndTime = new Date(findExam?.end_time || '').getTime()
console.log(containsNumber(examStartTime, mergedForm.start_at), containsNumber(examEndTime, mergedForm.end_at))
if (
containsNumber(examStartTime, mergedForm.start_at) !== true ||
containsNumber(examEndTime, mergedForm.start_at) !== true
containsNumber(examEndTime, mergedForm.end_at) !== true
) {
ElMessage({ message: `正式比赛理论答题时间与${findExam?.name}的考试时间不符`, type: 'warning' })
return false
}
const params: ContestUpdateParams = pick(mergedForm, [
'operational_start_time',
'operational_end_time',
'id',
'name',
'client_id',
......@@ -254,7 +287,8 @@ function handleSubmit() {
// 'competition_uri',
'teacher_ids',
'train_platform_configs',
'competition_platform_configs'
'competition_platform_configs',
'is_switchable_theory_practice'
])
console.log(isUpdate, 'isUpdate')
isUpdate ? handleUpdate(params) : handleCreate(params)
......@@ -373,6 +407,16 @@ onMounted(() => {
style="width: 100%"
/>
</el-form-item>
<el-form-item label="正式比赛实操答题时间" prop="datetimeRange2">
<el-time-picker
is-range
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
v-model="form.datetimeRange2"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="报名截止日期" prop="apply_expiration_date">
<el-date-picker type="date" v-model="form.apply_expiration_date" style="width: 100%" />
</el-form-item>
......@@ -416,6 +460,12 @@ onMounted(() => {
</div>
</el-checkbox>
</el-form-item>
<el-form-item label="是否允许客户端切换" prop="is_switchable_theory_practice">
<el-radio-group v-model="form.is_switchable_theory_practice">
<el-radio :label="0"></el-radio>
<el-radio :label="1"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="有效状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio v-for="item in status" :key="item.id" :label="item.value">{{ item.label }}</el-radio>
......
......@@ -13,6 +13,8 @@ export interface ContestItem {
end_range: number
start_at: number
end_at: number
operational_start_time: number
operational_end_time: number
apply_expiration_date: number
status: string
logo: string
......@@ -32,6 +34,7 @@ export interface ContestItem {
expert_count: number
train_platform_configs: any[]
competition_platform_configs: any[]
is_switchable_theory_practice: string
}
export interface ContestCreateParams {
......
......@@ -165,7 +165,7 @@ async function handleDelete(row: ExperimentItem) {
<el-button type="primary" round :icon="Delete" @click="handleDelete(row)">删除</el-button>
<!-- 功能按钮移入详情里 s v-if="false" -->
<el-dropdown style="margin-left: 12px">
<el-dropdown style="margin-left: 12px" v-if="false">
<el-button type="primary" round :icon="MoreFilled"></el-button>
<template #dropdown>
<el-dropdown-menu>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论