main
parent
119aab5e3f
commit
cbaaec207b
@ -0,0 +1,322 @@ |
||||
<template> |
||||
<el-dialog |
||||
title="无人机试题" |
||||
:close-on-click-modal="false" |
||||
append-to-body |
||||
v-model="visible" |
||||
width="900px" |
||||
> |
||||
<div> |
||||
<el-form |
||||
ref="dialogFormRef" |
||||
:model="dialogForm" |
||||
:rules="dataRule" |
||||
label-width="auto" |
||||
label-position="right" |
||||
@keyup.enter="dialogFormSubmit()" |
||||
> |
||||
<el-row> |
||||
<el-col :span="24"> |
||||
<el-form-item label="题目" prop="question"> |
||||
<el-input |
||||
v-model="dialogForm.question" |
||||
maxlength="200" |
||||
placeholder="请输入题目" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row> |
||||
<el-col :span="24"> |
||||
<el-form-item label="题目关键字" prop="titleWords"> |
||||
<el-input |
||||
v-model="dialogForm.titleWords" |
||||
maxlength="1000" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row :gutter="20"> |
||||
<el-col :span="12"> |
||||
<el-form-item label="章节" prop="chapter"> |
||||
<el-select v-model="dialogForm.chapter" style="width: 100%"> |
||||
<el-option |
||||
v-for="dict in chapterOptions" |
||||
:key="dict.chapterId" |
||||
:label="dict.chapterName" |
||||
:value="dict.chapterId" |
||||
/> |
||||
</el-select> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="12"> |
||||
<el-form-item label="题型" prop="type"> |
||||
<el-radio-group v-model="dialogForm.type"> |
||||
<el-radio label="1" value="1">判断题</el-radio> |
||||
<el-radio label="2" value="2">单选题</el-radio> |
||||
<el-radio label="3" value="3">多选题</el-radio> |
||||
</el-radio-group> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
|
||||
<el-row :gutter="20"> |
||||
<el-col :span="12"> |
||||
<el-form-item label="排序" prop="showOrder"> |
||||
<el-input |
||||
v-model="dialogForm.showOrder" |
||||
maxlength="20" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row :gutter="20"> |
||||
<el-col :span="12"> |
||||
<el-form-item label="选项A" prop="chooseA"> |
||||
<el-input |
||||
v-model="dialogForm.chooseA" |
||||
maxlength="200" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="12"> |
||||
<el-form-item label="选项B" prop="chooseB"> |
||||
<el-input |
||||
v-model="dialogForm.chooseB" |
||||
maxlength="200" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row :gutter="20"> |
||||
<el-col :span="12"> |
||||
<el-form-item label="选项C" prop="chooseC"> |
||||
<el-input |
||||
v-model="dialogForm.chooseC" |
||||
maxlength="200" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="12"> |
||||
<el-form-item label="选项D" prop="chooseD"> |
||||
<el-input |
||||
v-model="dialogForm.chooseD" |
||||
maxlength="200" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row> |
||||
<el-col :span="24"> |
||||
<el-form-item label="答案" prop="trueAnswer"> |
||||
<el-input |
||||
v-model="dialogForm.trueAnswer" |
||||
maxlength="200" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row> |
||||
<el-col :span="24"> |
||||
<el-form-item label="答案解析" prop="bestAnswer"> |
||||
<el-input |
||||
v-model="dialogForm.bestAnswer" |
||||
maxlength="1000" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row> |
||||
<el-col :span="24"> |
||||
<el-form-item label="答题技巧" prop="skillInfo"> |
||||
<el-input |
||||
v-model="dialogForm.skillInfo" |
||||
maxlength="1000" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
|
||||
<el-row> |
||||
<el-col :span="24"> |
||||
<el-form-item label="技巧关键字" prop="skillWords"> |
||||
<el-input |
||||
v-model="dialogForm.skillWords" |
||||
maxlength="1000" |
||||
placeholder="请输入" |
||||
clearable |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row :gutter="20"> |
||||
<el-form-item label="题目图片" prop="imageUrl"> |
||||
<el-upload |
||||
action="#" |
||||
accept=".png,.jpg,.jpeg,.gif" |
||||
:limit="1" |
||||
:http-request="handleImport" |
||||
:on-exceed="handleExceed" |
||||
:show-file-list="false" |
||||
> |
||||
<img v-if="imgUrl" :src="imgUrl" style="width: 200px" /> |
||||
<i v-else class="el-icon-plus"></i> |
||||
</el-upload> |
||||
</el-form-item> |
||||
</el-row> |
||||
</el-form> |
||||
</div> |
||||
<template #footer> |
||||
<span class="dialog-footer"> |
||||
<el-button plain @click="visible = false">取消</el-button> |
||||
<el-button type="primary" :disabled="!canSubmit" @click="dialogFormSubmit()"> |
||||
确定 |
||||
</el-button> |
||||
</span> |
||||
</template> |
||||
</el-dialog> |
||||
</template> |
||||
|
||||
<script setup name="QuesAddForm"> |
||||
import { addQuestion, updateQuestion, uploadFile } from '@/api/xjapplet/xjdatabase' |
||||
|
||||
const message = useMessage() // 消息弹窗 |
||||
|
||||
const emit = defineEmits(['update']) |
||||
|
||||
const visible = ref(false) |
||||
const canSubmit = ref(true) |
||||
const imgUrl = ref(undefined) |
||||
const chapterOptions = ref([]) |
||||
const dialogForm = ref({ |
||||
id: undefined, |
||||
showOrder: 0, |
||||
categoryTitle: undefined, |
||||
question: undefined, |
||||
bestAnswer: undefined, |
||||
chooseA: undefined, |
||||
chooseB: undefined, |
||||
chooseC: undefined, |
||||
chooseD: undefined, |
||||
imageUrl: undefined, |
||||
type: undefined, |
||||
trueAnswer: undefined, |
||||
carTypeId: undefined, |
||||
skillInfoPic: undefined, |
||||
chapter: undefined, |
||||
skillInfo: undefined, |
||||
skillWords: undefined |
||||
}) |
||||
|
||||
const dataRule = { |
||||
schoolName: [{ required: true, message: '驾校名称不能为空', trigger: 'blur' }], |
||||
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }] |
||||
} |
||||
|
||||
const open = (info = undefined, opts) => { |
||||
visible.value = true |
||||
chapterOptions.value = opts |
||||
resetDialogForm() |
||||
dialogForm.value.driveTypeName = info.driveTypeName |
||||
dialogForm.value.carTypeName = info.carTypeName |
||||
if (info) { |
||||
dialogForm.value = { ...info, chapter: info.chapter } |
||||
if (dialogForm.value.imageUrl) { |
||||
imgUrl.value = dialogForm.value.imageUrl.includes('http') |
||||
? dialogForm.value.imageUrl |
||||
: 'https://ss-cloud.ahduima.com/xjxc/pic/' + dialogForm.value.imageUrl |
||||
} |
||||
} |
||||
} |
||||
|
||||
defineExpose({ |
||||
open |
||||
}) |
||||
|
||||
const resetDialogForm = () => { |
||||
dialogForm.value = { |
||||
id: undefined, |
||||
showOrder: 0, |
||||
question: undefined, |
||||
bestAnswer: undefined, |
||||
chooseA: undefined, |
||||
chooseB: undefined, |
||||
chooseC: undefined, |
||||
chooseD: undefined, |
||||
imageUrl: undefined, |
||||
type: undefined, |
||||
trueAnswer: undefined, |
||||
carTypeId: undefined, |
||||
skillInfoPic: undefined, |
||||
skillInfo: undefined, |
||||
jqtp: undefined, |
||||
biaoji: undefined, |
||||
titleWords: undefined, |
||||
skillWords: undefined, |
||||
optaWords: undefined, |
||||
optbWords: undefined, |
||||
optcWords: undefined, |
||||
optdWords: undefined, |
||||
carTypeId: undefined, |
||||
chapter: '1' |
||||
} |
||||
} |
||||
const dialogFormRef = ref(null) |
||||
// 表单提交 |
||||
const dialogFormSubmit = async () => { |
||||
if (!dialogFormRef.value) return |
||||
const valid = await dialogFormRef.value.validate() |
||||
if (!valid) return |
||||
|
||||
if (dialogForm.value.questionId) { |
||||
updateQuestion(dialogForm.value).then((response) => { |
||||
if (response) { |
||||
message.success('修改成功') |
||||
emit('update') |
||||
visible.value = false |
||||
} |
||||
}) |
||||
} else { |
||||
addQuestion(dialogForm.value).then((response) => { |
||||
if (response) { |
||||
message.success('新增成功') |
||||
visible.value = false |
||||
emit('update') |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
const handleImport = (opt) => { |
||||
const data = new FormData() |
||||
data.append('file', opt.file) |
||||
uploadFile(data).then((resp) => { |
||||
if (resp.code == 200) { |
||||
message.success('文件上传成功') |
||||
dialogForm.value.imageUrl = resp.data |
||||
imgUrl.value = 'https://ss-cloud.ahduima.com/xjxc/pic/' + dialogForm.value.imageUrl |
||||
} |
||||
}) |
||||
} |
||||
const handleExceed = (files) => { |
||||
handleImport({ file: files[0] }) |
||||
} |
||||
</script> |
@ -1,7 +1,259 @@ |
||||
<template> |
||||
<div> 无人机题库 </div> |
||||
<div class="app-container"> |
||||
<el-form :inline="true" label-width="100px" @submit.prevent> |
||||
<el-row :gutter="20"> |
||||
<el-col :span="12" :offset="0"> |
||||
<el-form-item label="无人机类型"> |
||||
<el-radio-group v-model="queryParams.carTypeId" @change="getQuestionChapter"> |
||||
<el-radio label="10001" value="10001">多旋翼</el-radio> |
||||
<el-radio label="10002" value="10002">垂直起降固定翼</el-radio> |
||||
<el-radio label="10003" value="10003">直升机</el-radio> |
||||
<el-radio label="10004" value="10004">固定翼</el-radio> |
||||
</el-radio-group> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="12" :offset="0"> |
||||
<el-form-item label="驾驶员类型"> |
||||
<el-radio-group v-model="queryParams.driveType" @change="getQuestionChapter"> |
||||
<el-radio label="1" value="1">视距内驾驶员</el-radio> |
||||
<el-radio label="2" value="2">超视距驾驶员</el-radio> |
||||
<el-radio label="3" value="3">教员</el-radio> |
||||
</el-radio-group> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row :gutter="20"> |
||||
<el-form-item label="章节"> |
||||
<el-select |
||||
v-model="queryParams.chapterId" |
||||
@change="getList" |
||||
placeholder="选择章节" |
||||
clearable |
||||
filterable |
||||
> |
||||
<el-option |
||||
v-for="item in chapterOptions" |
||||
:key="item.chapterId" |
||||
:label="item.chapterName" |
||||
:value="item.chapterId" |
||||
/> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item label="图片"> |
||||
<el-radio-group v-model="queryParams.isPic"> |
||||
<el-radio :label="true" :value="true">有</el-radio> |
||||
<el-radio :label="false" :value="false">无</el-radio> |
||||
</el-radio-group> |
||||
</el-form-item> |
||||
<el-form-item label="题目"> |
||||
<el-input |
||||
v-model="queryParams.question" |
||||
placeholder="请输入题目" |
||||
clearable |
||||
style="width: 400px" |
||||
@keyup.enter="handleQuery" |
||||
/> |
||||
</el-form-item> |
||||
<el-form-item> |
||||
<el-button type="primary" @click="handleQuery" v-hasPermi="['question:database:search']"> |
||||
搜索 |
||||
</el-button> |
||||
<el-button type="primary" @click="handleAdd" v-hasPermi="['question:database:add']"> |
||||
新增 |
||||
</el-button> |
||||
</el-form-item> |
||||
</el-row> |
||||
</el-form> |
||||
|
||||
<el-table |
||||
v-loading="loading" |
||||
:data="tableList" |
||||
highlight-current-row |
||||
max-height="calc(100vh - 320px)" |
||||
> |
||||
<el-table-column type="index" width="55" align="center" /> |
||||
<el-table-column label="题目" align="left" prop="question" min-width="140" /> |
||||
<el-table-column label="选项" align="left" min-width="140"> |
||||
<template #default="{ row }"> |
||||
<p v-if="row.chooseA">A:{{ row.chooseA }}</p> |
||||
<p v-if="row.chooseB">B:{{ row.chooseB }}</p> |
||||
<p v-if="row.chooseC">C:{{ row.chooseC }}</p> |
||||
<p v-if="row.chooseD">D:{{ row.chooseD }}</p> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="答案" align="center" prop="trueAnswer" width="100" /> |
||||
<el-table-column label="科目" align="center" prop="subject" width="100"> |
||||
<template #default="{ row }"> |
||||
<span v-if="row.subject == '1'">科一</span> |
||||
<span v-if="row.subject == '4'">科四</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="章节" align="center" prop="chapterName" min-width="100" /> |
||||
<el-table-column label="图片" align="center" width="100"> |
||||
<template #default="{ row }"> |
||||
<el-image |
||||
v-if="row.imageUrl" |
||||
:src="getShowImg(row)" |
||||
:preview-src-list="[getShowImg(row)]" |
||||
:lazy="true" |
||||
style="width: 90px" |
||||
preview-teleported |
||||
/> |
||||
</template> |
||||
</el-table-column> |
||||
<!-- <el-table-column label="状态" width="100"> |
||||
<template #default="{ row }"> |
||||
<el-tag v-if="row.isActive == 0" type="success">使用中</el-tag> |
||||
<el-tag v-else type="danger">已删除</el-tag> |
||||
</template> |
||||
</el-table-column> --> |
||||
|
||||
<el-table-column label="操作" align="center" width="140"> |
||||
<template #default="scope"> |
||||
<el-button |
||||
type="primary" |
||||
link |
||||
@click="handleEdit(scope.row)" |
||||
v-hasPermi="['question:database:edit']" |
||||
> |
||||
修改 |
||||
</el-button> |
||||
<el-button |
||||
type="primary" |
||||
link |
||||
@click="handleDelete(scope.row)" |
||||
v-hasPermi="['question:database:remove']" |
||||
> |
||||
删除 |
||||
</el-button> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
|
||||
<pagination |
||||
style="margin-bottom: 0" |
||||
v-show="total > 0" |
||||
:total="total" |
||||
v-model:page="queryParams.pageNo" |
||||
v-model:limit="queryParams.pageSize" |
||||
@pagination="getList" |
||||
/> |
||||
<QuestionAddForm ref="dialogAddForm" @update="getList" /> |
||||
</div> |
||||
</template> |
||||
|
||||
<script setup name="UAV"></script> |
||||
<script setup name="UAV"> |
||||
import QuestionAddForm from './components/QuestionAddForm.vue' |
||||
|
||||
const message = useMessage() |
||||
|
||||
const loading = ref(false) |
||||
const total = ref(0) |
||||
const tableList = ref([]) |
||||
const queryParams = ref({ |
||||
question: '', |
||||
carTypeId: '10001', |
||||
driveType: '1', |
||||
isPic: undefined, |
||||
chapterId: undefined, |
||||
pageNo: 1, |
||||
pageSize: 100 |
||||
}) |
||||
|
||||
onMounted(() => { |
||||
getQuestionChapter() |
||||
}) |
||||
|
||||
const chapterOptions = ref([]) |
||||
const getQuestionChapter = () => { |
||||
chapterOptions.value = [ |
||||
{ chapterId: '1', chapterName: '概述' }, |
||||
{ chapterId: '2', chapterName: '无人机基础知识' }, |
||||
{ chapterId: '3', chapterName: '飞行原理' }, |
||||
{ chapterId: '4', chapterName: '飞行技术' }, |
||||
{ chapterId: '5', chapterName: '飞行安全' }, |
||||
{ chapterId: '6', chapterName: '飞行技能' } |
||||
] |
||||
} |
||||
|
||||
function getShowImg(row) { |
||||
return row.imageUrl.includes('http') |
||||
? row.imageUrl |
||||
: `https://ss-cloud.ahduima.com/xjxc/pic/${row.imageUrl}` |
||||
} |
||||
|
||||
function getList() { |
||||
// loading.value = true |
||||
tableList.value = [ |
||||
{ |
||||
question: '近程无人机活动半径在', |
||||
chooseA: '小于15km', |
||||
chooseB: '15-50km', |
||||
chooseC: '200-800km', |
||||
chooseD: '', |
||||
trueAnswer: 'B', |
||||
chapterId: '1', |
||||
chapterName: '概述', |
||||
isActive: 1, |
||||
questionId: '1', |
||||
createTime: '2023-05-05 09:05:05' |
||||
}, |
||||
{ |
||||
question: '无人机驾驶员考试科目一的考试内容包括', |
||||
chooseA: '无人机基础知识', |
||||
chooseB: '航空法规', |
||||
chooseC: '气象学', |
||||
chooseD: '飞行原理', |
||||
trueAnswer: 'A', |
||||
chapterId: '2', |
||||
chapterName: '无人机基础知识', |
||||
isActive: 1, |
||||
questionId: '2', |
||||
createTime: '2023-05-05 09:05:05' |
||||
} |
||||
] |
||||
// searchQuestion(queryParams.value).then((response) => { |
||||
// tableList.value = response.list |
||||
// total.value = response.total |
||||
// loading.value = false |
||||
// }) |
||||
} |
||||
|
||||
function handleQuery() { |
||||
getList() |
||||
} |
||||
|
||||
const dialogAddForm = ref(null) |
||||
function handleEdit(item) { |
||||
dialogAddForm.value.open(item, chapterOptions.value) |
||||
} |
||||
|
||||
function handleAdd() { |
||||
dialogAddForm.value.open( |
||||
{ |
||||
driveTypeName: '视距内驾驶员', |
||||
carTypeName: '多旋翼', |
||||
chapter: queryParams.value.chapterId |
||||
}, |
||||
chapterOptions.value |
||||
) |
||||
} |
||||
|
||||
function handleDelete(row) { |
||||
message |
||||
.confirm('是否确认删除该题?') |
||||
.then(function () { |
||||
console.log(row) |
||||
|
||||
// deleteQuestion(row.questionId).then(() => { |
||||
// getList() |
||||
message.success('删除题目成功') |
||||
// }) |
||||
}) |
||||
.catch((err) => { |
||||
console.log(err) |
||||
}) |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" scoped></style> |
||||
|
Loading…
Reference in new issue