|
@@ -12,7 +12,11 @@
|
|
|
>
|
|
|
<el-steps :active="currentStep" finish-status="success">
|
|
|
<el-step title="设置规则" />
|
|
|
- <el-step title="选择试题" />
|
|
|
+ <el-step
|
|
|
+ v-for="(step, index) in ruleFormData.selectiveCount"
|
|
|
+ :key="index"
|
|
|
+ :title="`选择试题组${index + 1}`"
|
|
|
+ />
|
|
|
</el-steps>
|
|
|
|
|
|
<div style="margin-top: 20px">
|
|
@@ -21,12 +25,17 @@
|
|
|
<OptionalRuleForm ref="ruleFormRef" v-model="ruleFormData" />
|
|
|
</div>
|
|
|
|
|
|
- <!-- 第二步:选择试题 -->
|
|
|
- <div v-if="currentStep === 1">
|
|
|
+ <!-- 选择试题步骤 -->
|
|
|
+ <div v-if="currentStep > 0">
|
|
|
+ <div style="margin-bottom: 16px; font-weight: bold">
|
|
|
+ 选择试题组{{ currentStep }}(第{{ currentStep }}个选做题区)
|
|
|
+ </div>
|
|
|
<OptionalQuestionSelect
|
|
|
ref="questionSelectRef"
|
|
|
- v-model="selectedQuestions"
|
|
|
- :subject-id="props.rowData?.subjectCode"
|
|
|
+ v-model="currentStepSelection"
|
|
|
+ :subject-code="props.rowData?.subjectCode"
|
|
|
+ :current-step="currentStep"
|
|
|
+ :selected-parts="selectedParts"
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -35,11 +44,15 @@
|
|
|
<div class="dialog-footer">
|
|
|
<el-button @click="close">取消</el-button>
|
|
|
<el-button v-if="currentStep > 0" @click="prevStep">上一步</el-button>
|
|
|
- <el-button v-if="currentStep < 1" type="primary" @click="nextStep">
|
|
|
+ <el-button
|
|
|
+ v-if="currentStep < ruleFormData.selectiveCount"
|
|
|
+ type="primary"
|
|
|
+ @click="nextStep"
|
|
|
+ >
|
|
|
下一步
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
- v-if="currentStep === 1"
|
|
|
+ v-if="currentStep === ruleFormData.selectiveCount"
|
|
|
type="primary"
|
|
|
:loading="loading"
|
|
|
@click="confirm"
|
|
@@ -58,6 +71,7 @@
|
|
|
import type {
|
|
|
OptionalRuleItem,
|
|
|
OptionalRuleUpdateParam,
|
|
|
+ OptionalRulePart,
|
|
|
} from '@/api/types/subject';
|
|
|
import useModal from '@/hooks/modal';
|
|
|
import useLoading from '@/hooks/loading';
|
|
@@ -92,19 +106,22 @@
|
|
|
|
|
|
// 规则表单数据
|
|
|
const initialRuleFormData = {
|
|
|
- ruleSelecCount: 1,
|
|
|
- ruleTotalCount: 1,
|
|
|
- scoreRule: 'MAX_SCORE' as const,
|
|
|
+ selectivePart: 1,
|
|
|
+ selectiveCount: 1,
|
|
|
+ scorePolicy: 2 as const,
|
|
|
};
|
|
|
const ruleFormData = reactive({ ...initialRuleFormData });
|
|
|
|
|
|
- // 选中的试题
|
|
|
- const selectedQuestions = ref<number[]>([]);
|
|
|
+ // 选中的结构
|
|
|
+ const selectedParts = ref<OptionalRulePart[]>([]);
|
|
|
+ // 当前步骤选择的试题
|
|
|
+ const currentStepSelection = ref<number[]>([]);
|
|
|
|
|
|
const handleClose = () => {
|
|
|
currentStep.value = 0;
|
|
|
objModifyAssign(ruleFormData, initialRuleFormData);
|
|
|
- selectedQuestions.value = [];
|
|
|
+ selectedParts.value = [];
|
|
|
+ currentStepSelection.value = [];
|
|
|
};
|
|
|
|
|
|
// 下一步
|
|
@@ -113,26 +130,55 @@
|
|
|
// 验证第一步表单
|
|
|
const valid = await ruleFormRef.value?.validate().catch(() => false);
|
|
|
if (!valid) return;
|
|
|
+ } else {
|
|
|
+ // 验证当前步骤的试题选择
|
|
|
+ const valid = await questionSelectRef.value
|
|
|
+ ?.validate()
|
|
|
+ .catch(() => false);
|
|
|
+ if (!valid) return;
|
|
|
+
|
|
|
+ // 构建当前步骤的OptionalRulePart数据
|
|
|
+ const currentPart: OptionalRulePart = {
|
|
|
+ selectivePart: currentStep.value.toString(),
|
|
|
+ mainNumbers: currentStepSelection.value,
|
|
|
+ };
|
|
|
+ selectedParts.value.push(currentPart);
|
|
|
}
|
|
|
+
|
|
|
currentStep.value++;
|
|
|
+ currentStepSelection.value = [];
|
|
|
};
|
|
|
|
|
|
// 上一步
|
|
|
const prevStep = () => {
|
|
|
+ if (currentStep.value > 1) {
|
|
|
+ // 清除当前步骤的OptionalRulePart数据
|
|
|
+ selectedParts.value.pop();
|
|
|
+ currentStepSelection.value = selectedParts.value.slice(-1)[0].mainNumbers;
|
|
|
+ } else {
|
|
|
+ currentStepSelection.value = [];
|
|
|
+ }
|
|
|
currentStep.value--;
|
|
|
};
|
|
|
|
|
|
// 提交
|
|
|
const { loading, setLoading } = useLoading();
|
|
|
const confirm = async () => {
|
|
|
- // 验证第二步
|
|
|
+ // 验证最后一步
|
|
|
const valid = await questionSelectRef.value?.validate().catch(() => false);
|
|
|
if (!valid) return;
|
|
|
|
|
|
+ // 构建最后一步的OptionalRulePart数据
|
|
|
+ const lastPart: OptionalRulePart = {
|
|
|
+ selectivePart: currentStep.value.toString(),
|
|
|
+ mainNumbers: currentStepSelection.value,
|
|
|
+ };
|
|
|
+ selectedParts.value.push(lastPart);
|
|
|
+
|
|
|
setLoading(true);
|
|
|
const params: OptionalRuleUpdateParam = {
|
|
|
...ruleFormData,
|
|
|
- questionStructureIds: selectedQuestions.value,
|
|
|
+ parts: selectedParts.value,
|
|
|
};
|
|
|
|
|
|
if (props.rowData?.id) {
|
|
@@ -156,16 +202,17 @@
|
|
|
if (props.rowData?.id) {
|
|
|
// 编辑模式
|
|
|
objModifyAssign(ruleFormData, {
|
|
|
- ruleSelecCount: props.rowData.ruleSelecCount,
|
|
|
- ruleTotalCount: props.rowData.ruleTotalCount,
|
|
|
- scoreRule: props.rowData.scoreRule,
|
|
|
+ selectivePart: props.rowData.selectivePart || 1,
|
|
|
+ selectiveCount: props.rowData.selectiveCount || 1,
|
|
|
+ scorePolicy: props.rowData.scorePolicy || 2,
|
|
|
});
|
|
|
- selectedQuestions.value = props.rowData.questionStructureIds || [];
|
|
|
+ selectedParts.value = props.rowData.parts || [];
|
|
|
} else {
|
|
|
// 新增模式
|
|
|
objModifyAssign(ruleFormData, initialRuleFormData);
|
|
|
- selectedQuestions.value = [];
|
|
|
+ selectedParts.value = [];
|
|
|
}
|
|
|
currentStep.value = 0;
|
|
|
+ currentStepSelection.value = [];
|
|
|
}
|
|
|
</script>
|