|
@@ -0,0 +1,248 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <a-form :model="form" :style="{ width: '100%' }" @submit="handleSubmit">
|
|
|
|
|
+ <a-form-item field="difficulty" :label="$t('wendangchujuan.dificulty')">
|
|
|
|
|
+ <a-select
|
|
|
|
|
+ v-model="form.difficulty"
|
|
|
|
|
+ :placeholder="$t('wendangchujuan.dificulty') + $t('wendangchujuan.optional')"
|
|
|
|
|
+ allow-clear
|
|
|
|
|
+ >
|
|
|
|
|
+ <a-option :value="1">{{ $t('wendangchujuan.type_easy') }}</a-option>
|
|
|
|
|
+ <a-option :value="2">{{ $t('wendangchujuan.type_difficulty') }}</a-option>
|
|
|
|
|
+ </a-select>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <a-form-item field="gen_paper" :label="$t('wendangchujuan.should_generate_paper')">
|
|
|
|
|
+ <a-select
|
|
|
|
|
+ v-model="form.gen_paper"
|
|
|
|
|
+ :placeholder="$t('wendangchujuan.should_generate_paper') + $t('wendangchujuan.optional')"
|
|
|
|
|
+ allow-clear
|
|
|
|
|
+ >
|
|
|
|
|
+ <a-option :value="1">{{ $t('wendangchujuan.type_yes') }}</a-option>
|
|
|
|
|
+ <a-option :value="0">{{ $t('wendangchujuan.type_no') }}</a-option>
|
|
|
|
|
+ </a-select>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <a-form-item field="count_select_single" :label="$t('wendangchujuan.count_q_single_choice')">
|
|
|
|
|
+ <a-input
|
|
|
|
|
+ v-model="form.count_select_single"
|
|
|
|
|
+ :placeholder="$t('wendangchujuan.count_q_single_choice') + $t('wendangchujuan.optional')"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="0"
|
|
|
|
|
+ :max="100"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <a-form-item field="count_fill_blank" :label="$t('wendangchujuan.count_q_fill_blank')">
|
|
|
|
|
+ <a-input
|
|
|
|
|
+ v-model="form.count_fill_blank"
|
|
|
|
|
+ :placeholder="$t('wendangchujuan.count_q_fill_blank') + $t('wendangchujuan.optional')"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="0"
|
|
|
|
|
+ :max="100"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <a-form-item field="count_judge" :label="$t('wendangchujuan.count_q_judge')">
|
|
|
|
|
+ <a-input
|
|
|
|
|
+ v-model="form.count_judge"
|
|
|
|
|
+ :placeholder="$t('wendangchujuan.count_q_judge') + $t('wendangchujuan.optional')"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="0"
|
|
|
|
|
+ :max="100"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <a-form-item field="count_select_muilty" :label="$t('wendangchujuan.count_q_muilty_choice')">
|
|
|
|
|
+ <a-input
|
|
|
|
|
+ v-model="form.count_select_muilty"
|
|
|
|
|
+ :placeholder="$t('wendangchujuan.count_q_muilty_choice') + $t('wendangchujuan.optional')"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="0"
|
|
|
|
|
+ :max="100"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <a-form-item field="count_ask" :label="$t('wendangchujuan.count_q_ask')">
|
|
|
|
|
+ <a-input
|
|
|
|
|
+ v-model="form.count_ask"
|
|
|
|
|
+ :placeholder="$t('wendangchujuan.count_q_ask') + $t('wendangchujuan.optional')"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="0"
|
|
|
|
|
+ :max="100"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <a-form-item field="count_example_case" :label="$t('wendangchujuan.count_q_case')">
|
|
|
|
|
+ <a-input
|
|
|
|
|
+ v-model="form.count_example_case"
|
|
|
|
|
+ :placeholder="$t('wendangchujuan.count_q_case') + $t('wendangchujuan.optional')"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="0"
|
|
|
|
|
+ :max="100"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <a-form-item field="count_keywords" :label="$t('wendangchujuan.keywords')">
|
|
|
|
|
+ <a-textarea
|
|
|
|
|
+ v-model="form.count_keywords"
|
|
|
|
|
+ :placeholder="$t('wendangchujuan.keywords') + $t('wendangchujuan.optional')"
|
|
|
|
|
+ :auto-size="text_area_autosize"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ </a-form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script setup>
|
|
|
|
|
+import { ref, reactive, onMounted } from 'vue';
|
|
|
|
|
+
|
|
|
|
|
+const text_area_autosize = {
|
|
|
|
|
+ minRows: 2,
|
|
|
|
|
+ maxRows: 5
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const form = reactive({
|
|
|
|
|
+ // 难度
|
|
|
|
|
+ difficulty: '',
|
|
|
|
|
+ // 是否生成试卷
|
|
|
|
|
+ gen_paper: '',
|
|
|
|
|
+ // 单选数量
|
|
|
|
|
+ count_select_single: '',
|
|
|
|
|
+ // 填空数量
|
|
|
|
|
+ count_fill_blank: '',
|
|
|
|
|
+ // 判断题数量
|
|
|
|
|
+ count_judge: '',
|
|
|
|
|
+ // 多选数量
|
|
|
|
|
+ count_select_muilty: '',
|
|
|
|
|
+ // 简答数量
|
|
|
|
|
+ count_ask: '',
|
|
|
|
|
+ // 案例题数量
|
|
|
|
|
+ count_example_case: '',
|
|
|
|
|
+ // 关键字或者出题方向
|
|
|
|
|
+ count_keywords: ''
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const handleSubmit = (data) => {
|
|
|
|
|
+ console.log(data);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 获取表单里的所有数据
|
|
|
|
|
+ */
|
|
|
|
|
+const getFormFiledValues = () => {
|
|
|
|
|
+ const obj = {
|
|
|
|
|
+ // // 难度
|
|
|
|
|
+ // difficulty: form.difficulty, // 0/1
|
|
|
|
|
+ // // 是否生成试卷
|
|
|
|
|
+ // is_paper: form.gen_paper, // 0/1
|
|
|
|
|
+ // // 单选数量
|
|
|
|
|
+ // single_choice: form.count_select_single, // 数量
|
|
|
|
|
+ // // 填空数量
|
|
|
|
|
+ // gap_filling: form.count_fill_blank,
|
|
|
|
|
+ // // 判断题数量
|
|
|
|
|
+ // true_or_false: form.count_judge,
|
|
|
|
|
+ // // 多选数量
|
|
|
|
|
+ // multiple_choice: form.count_select_muilty,
|
|
|
|
|
+ // // 简答数量
|
|
|
|
|
+ // easy_question: form.count_ask,
|
|
|
|
|
+ // // 案例题数量
|
|
|
|
|
+ // case_questions: form.count_example_case,
|
|
|
|
|
+ // // 关键字或者出题方向
|
|
|
|
|
+ // key_words: form.count_keywords
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ if (form.difficulty === 0 || form.difficulty === 1) {
|
|
|
|
|
+ obj.difficulty = form.difficulty;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (form.gen_paper === 0 || form.gen_paper === 1) {
|
|
|
|
|
+ obj.is_paper = form.gen_paper;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 单选数量
|
|
|
|
|
+ if (form.count_select_single.length !== 0) {
|
|
|
|
|
+ if (form.count_select_single / 1 > 0) {
|
|
|
|
|
+ obj.single_choice = form.count_select_single / 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 填空数量
|
|
|
|
|
+ if (form.count_fill_blank.length !== 0) {
|
|
|
|
|
+ if (form.count_fill_blank / 1 > 0) {
|
|
|
|
|
+ obj.gap_filling = form.count_fill_blank / 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 判断题数量
|
|
|
|
|
+ if (form.count_judge.length !== 0) {
|
|
|
|
|
+ if (form.count_judge / 1 > 0) {
|
|
|
|
|
+ obj.true_or_false = form.count_judge / 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 多选数量
|
|
|
|
|
+ if (form.count_select_muilty.length !== 0) {
|
|
|
|
|
+ if (form.count_select_muilty / 1 > 0) {
|
|
|
|
|
+ obj.multiple_choice = form.count_select_muilty / 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 简答数量
|
|
|
|
|
+ if (form.count_ask.length !== 0) {
|
|
|
|
|
+ if (form.count_ask / 1 > 0) {
|
|
|
|
|
+ obj.easy_question = form.count_ask / 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 案例题数量
|
|
|
|
|
+ if (form.count_example_case.length !== 0) {
|
|
|
|
|
+ if (form.count_example_case / 1 > 0) {
|
|
|
|
|
+ obj.case_questions = form.count_example_case / 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 关键字或者出题方向
|
|
|
|
|
+ if (form.count_keywords.length !== 0) {
|
|
|
|
|
+ obj.key_words = form.count_keywords;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return obj;
|
|
|
|
|
+};
|
|
|
|
|
+/**
|
|
|
|
|
+ * 清空表单
|
|
|
|
|
+ */
|
|
|
|
|
+const clearFormFiledValues = () => {
|
|
|
|
|
+ // 难度
|
|
|
|
|
+ form.difficulty = '';
|
|
|
|
|
+ // 是否生成试卷
|
|
|
|
|
+ form.gen_paper = '';
|
|
|
|
|
+ // 单选数量
|
|
|
|
|
+ form.count_select_single = '';
|
|
|
|
|
+ // 填空数量
|
|
|
|
|
+ form.count_fill_blank = '';
|
|
|
|
|
+ // 判断题数量
|
|
|
|
|
+ form.count_judge = '';
|
|
|
|
|
+ // 多选数量
|
|
|
|
|
+ form.count_select_muilty = '';
|
|
|
|
|
+ // 简答数量
|
|
|
|
|
+ form.count_ask = '';
|
|
|
|
|
+ // 案例题数量
|
|
|
|
|
+ form.count_example_case = '';
|
|
|
|
|
+ // 关键字或者出题方向
|
|
|
|
|
+ form.count_keywords = '';
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+defineExpose({
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 父组件通过ref,调用getValues方法,可以获取到表单里的所有数据
|
|
|
|
|
+ */
|
|
|
|
|
+ getValues: getFormFiledValues,
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 父组件通过ref,调用clear方法,可以将表单里数据清空
|
|
|
|
|
+ */
|
|
|
|
|
+ clear: clearFormFiledValues
|
|
|
|
|
+});
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped></style>
|