|
@@ -2,27 +2,34 @@
|
|
<el-dialog title="选择试题" v-model="dialogVisible" draggable append-to-body destroy-on-close width="800px">
|
|
<el-dialog title="选择试题" v-model="dialogVisible" draggable append-to-body destroy-on-close width="800px">
|
|
<el-form :model="state.queryParams" ref="ruleDialogFormRef" inline @submit.native.prevent :disabled="state.loading" class="ruleDialogForm">
|
|
<el-form :model="state.queryParams" ref="ruleDialogFormRef" inline @submit.native.prevent :disabled="state.loading" class="ruleDialogForm">
|
|
<el-form-item label="标签" prop="tagIds">
|
|
<el-form-item label="标签" prop="tagIds">
|
|
- <el-tree-select
|
|
|
|
- v-model="state.queryParams.tagIds"
|
|
|
|
- :data="state.tagData"
|
|
|
|
- node-key="id"
|
|
|
|
- :props="{ label: 'name' }"
|
|
|
|
- multiple
|
|
|
|
- collapse-tags
|
|
|
|
- collapse-tags-tooltip
|
|
|
|
- :render-after-expand="false"
|
|
|
|
- style="width: 200px;"
|
|
|
|
- @change="handleQuery"
|
|
|
|
- />
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="难易程度" prop="difficultyLevel">
|
|
|
|
- <el-select v-model="state.queryParams.difficultyLevel" clearable placeholder="请选择" @change="handleQuery" :disabled="state.loading" style="width: 150px">
|
|
|
|
- <el-option key='0' label="容易" :value="0" />
|
|
|
|
- <el-option key='1' label="适中" :value="1" />
|
|
|
|
- <el-option key='2' label="困难" :value="2" />
|
|
|
|
- </el-select>
|
|
|
|
- </el-form-item>
|
|
|
|
- <!-- <el-form-item label="难易程度" prop="questionType">
|
|
|
|
|
|
+ <el-tree-select
|
|
|
|
+ v-model="state.queryParams.tagIds"
|
|
|
|
+ :data="state.tagData"
|
|
|
|
+ node-key="id"
|
|
|
|
+ :props="{ label: 'name' }"
|
|
|
|
+ multiple
|
|
|
|
+ collapse-tags
|
|
|
|
+ collapse-tags-tooltip
|
|
|
|
+ :render-after-expand="false"
|
|
|
|
+ style="width: 200px"
|
|
|
|
+ @change="handleQuery"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="难易程度" prop="difficultyLevel">
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="state.queryParams.difficultyLevel"
|
|
|
|
+ clearable
|
|
|
|
+ placeholder="请选择"
|
|
|
|
+ @change="handleQuery"
|
|
|
|
+ :disabled="state.loading"
|
|
|
|
+ style="width: 150px"
|
|
|
|
+ >
|
|
|
|
+ <el-option key="0" label="容易" :value="0" />
|
|
|
|
+ <el-option key="1" label="适中" :value="1" />
|
|
|
|
+ <el-option key="2" label="困难" :value="2" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <!-- <el-form-item label="难易程度" prop="questionType">
|
|
<el-select v-model="state.queryParams.questionType" clearable placeholder="请选择" @change="handleQuery" :disabled="state.tableLoading">
|
|
<el-select v-model="state.queryParams.questionType" clearable placeholder="请选择" @change="handleQuery" :disabled="state.tableLoading">
|
|
<el-option key='0' label="单选题" :value="0" />
|
|
<el-option key='0' label="单选题" :value="0" />
|
|
<el-option key='1' label="多选题" :value="1" />
|
|
<el-option key='1' label="多选题" :value="1" />
|
|
@@ -53,8 +60,8 @@
|
|
>
|
|
>
|
|
<vxe-column type="checkbox" fixed="left" width="70" align="center"></vxe-column>
|
|
<vxe-column type="checkbox" fixed="left" width="70" align="center"></vxe-column>
|
|
<vxe-column field="questionTypeDesc" title="题型" width="100"></vxe-column>
|
|
<vxe-column field="questionTypeDesc" title="题型" width="100"></vxe-column>
|
|
- <vxe-column field="difficultyLevelDesc" title="难度" width="100"></vxe-column>
|
|
|
|
- <vxe-column field="title" title="标题" min-width="150"></vxe-column>
|
|
|
|
|
|
+ <vxe-column field="difficultyLevelDesc" title="难度" width="100"></vxe-column>
|
|
|
|
+ <vxe-column field="title" title="标题" min-width="150"></vxe-column>
|
|
</vxe-table>
|
|
</vxe-table>
|
|
<pagination
|
|
<pagination
|
|
@pagination="queryList"
|
|
@pagination="queryList"
|
|
@@ -75,10 +82,9 @@
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
import { defineAsyncComponent, reactive, ref } from 'vue';
|
|
import { defineAsyncComponent, reactive, ref } from 'vue';
|
|
import { FormInstance } from 'element-plus';
|
|
import { FormInstance } from 'element-plus';
|
|
-import { formatDate } from '@/utils/formatTime';
|
|
|
|
import other from '@/utils/other';
|
|
import other from '@/utils/other';
|
|
-import {getQuestionData} from '@/api/examTrain/questionBank';
|
|
|
|
-import { examTagTreeList} from '@/api/examTrain/tag';
|
|
|
|
|
|
+import { getQuestionData } from '@/api/examTrain/questionBank';
|
|
|
|
+import { examTagTreeList } from '@/api/examTrain/tag';
|
|
|
|
|
|
const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
|
|
const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
|
|
|
|
|
|
@@ -94,10 +100,10 @@ const state = reactive({
|
|
PageIndex: 1, // 当前页
|
|
PageIndex: 1, // 当前页
|
|
PageSize: 20, // 每页条数
|
|
PageSize: 20, // 每页条数
|
|
tagIds: null, // 标签id集合
|
|
tagIds: null, // 标签id集合
|
|
- difficultyLevel: null, // 难易程度
|
|
|
|
- knowladgeIds: [] as any [] // 关联的知识库id
|
|
|
|
|
|
+ difficultyLevel: null, // 难易程度
|
|
|
|
+ knowladgeIds: [] as any[], // 关联的知识库id
|
|
},
|
|
},
|
|
- tableCheckbox: [] as any [], // 已选择的试题
|
|
|
|
|
|
+ tableCheckbox: [] as any[], // 已选择的试题
|
|
tagData: [], // 标签数据
|
|
tagData: [], // 标签数据
|
|
});
|
|
});
|
|
const ruleDialogFormRef = ref<FormInstance>(); // 表单
|
|
const ruleDialogFormRef = ref<FormInstance>(); // 表单
|
|
@@ -108,24 +114,23 @@ const getTagData = async () => {
|
|
try {
|
|
try {
|
|
const { result } = await examTagTreeList();
|
|
const { result } = await examTagTreeList();
|
|
state.tagData = result ?? [];
|
|
state.tagData = result ?? [];
|
|
- } catch (error) {
|
|
|
|
- }
|
|
|
|
|
|
+ } catch (error) {}
|
|
};
|
|
};
|
|
// 打开弹窗
|
|
// 打开弹窗
|
|
const openDialog = async (knowladgesData: any[], selData: any[]) => {
|
|
const openDialog = async (knowladgesData: any[], selData: any[]) => {
|
|
dialogVisible.value = true;
|
|
dialogVisible.value = true;
|
|
try {
|
|
try {
|
|
- if (knowladgesData) {
|
|
|
|
- state.queryParams.knowladgeIds = knowladgesData.map(it => it.knowladgeId);
|
|
|
|
|
|
+ if (knowladgesData) {
|
|
|
|
+ state.queryParams.knowladgeIds = knowladgesData.map((it) => it.knowladgeId);
|
|
} else {
|
|
} else {
|
|
state.queryParams.knowladgeIds = [];
|
|
state.queryParams.knowladgeIds = [];
|
|
}
|
|
}
|
|
- if (selData) {
|
|
|
|
|
|
+ if (selData) {
|
|
state.tableCheckbox = other.deepClone(selData);
|
|
state.tableCheckbox = other.deepClone(selData);
|
|
} else {
|
|
} else {
|
|
state.tableCheckbox = [];
|
|
state.tableCheckbox = [];
|
|
}
|
|
}
|
|
- getTagData();
|
|
|
|
|
|
+ getTagData();
|
|
queryList();
|
|
queryList();
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.log(error);
|
|
console.log(error);
|
|
@@ -145,11 +150,11 @@ const queryList = () => {
|
|
state.tableData = res.result?.items ?? [];
|
|
state.tableData = res.result?.items ?? [];
|
|
state.total = res.result?.pagination.totalCount ?? 0;
|
|
state.total = res.result?.pagination.totalCount ?? 0;
|
|
state.loading = false;
|
|
state.loading = false;
|
|
- const rows = [] as any[];
|
|
|
|
- state.tableCheckbox.forEach(item => {
|
|
|
|
- rows.push(state.tableData.find(it => it.id === item.questionId));
|
|
|
|
- })
|
|
|
|
- tableRef.value.setCheckboxRow(rows, true);
|
|
|
|
|
|
+ const rows = [] as any[];
|
|
|
|
+ state.tableCheckbox.forEach((item) => {
|
|
|
|
+ rows.push(state.tableData.find((it) => it.id === item.questionId));
|
|
|
|
+ });
|
|
|
|
+ tableRef.value.setCheckboxRow(rows, true);
|
|
})
|
|
})
|
|
.catch(() => {
|
|
.catch(() => {
|
|
state.loading = false;
|
|
state.loading = false;
|
|
@@ -161,22 +166,22 @@ const resetQuery = (formEl: FormInstance | undefined) => {
|
|
handleQuery();
|
|
handleQuery();
|
|
};
|
|
};
|
|
// 单个复选框点击
|
|
// 单个复选框点击
|
|
-const checkboxChangeEvent = ({row}) => {
|
|
|
|
- let blog = 'add';
|
|
|
|
- state.tableCheckbox.forEach(item => {
|
|
|
|
- if(item.questionId == row.id){
|
|
|
|
- blog = 'delete'
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- if (blog == 'add'){
|
|
|
|
- const rowObj = other.deepClone(row);
|
|
|
|
- rowObj.questionId = rowObj.id;
|
|
|
|
- Reflect.deleteProperty(rowObj, 'id');
|
|
|
|
- state.tableCheckbox.push(rowObj)
|
|
|
|
- }else {
|
|
|
|
- state.tableCheckbox = state.tableCheckbox.filter(it => it.questionId !== row.id )
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+const checkboxChangeEvent = ({ row }) => {
|
|
|
|
+ let blog = 'add';
|
|
|
|
+ state.tableCheckbox.forEach((item) => {
|
|
|
|
+ if (item.questionId == row.id) {
|
|
|
|
+ blog = 'delete';
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (blog == 'add') {
|
|
|
|
+ const rowObj = other.deepClone(row);
|
|
|
|
+ rowObj.questionId = rowObj.id;
|
|
|
|
+ Reflect.deleteProperty(rowObj, 'id');
|
|
|
|
+ state.tableCheckbox.push(rowObj);
|
|
|
|
+ } else {
|
|
|
|
+ state.tableCheckbox = state.tableCheckbox.filter((it) => it.questionId !== row.id);
|
|
|
|
+ }
|
|
|
|
+};
|
|
// 关闭弹窗
|
|
// 关闭弹窗
|
|
const closeDialog = () => {
|
|
const closeDialog = () => {
|
|
dialogVisible.value = false;
|
|
dialogVisible.value = false;
|
|
@@ -191,6 +196,6 @@ defineExpose({ closeDialog, openDialog });
|
|
</script>
|
|
</script>
|
|
<style>
|
|
<style>
|
|
.el-form--inline.ruleDialogForm .el-form-item .el-select {
|
|
.el-form--inline.ruleDialogForm .el-form-item .el-select {
|
|
- min-width: 100px;
|
|
|
|
|
|
+ min-width: 100px;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|