Files
ss-crm-manage-web/src/views/XjApplet/XjDatabase/index.vue

184 lines
5.3 KiB
Vue
Raw Normal View History

2025-02-28 19:09:18 +08:00
<template>
<div class="app-container" style="text-align: center">
2025-03-02 13:25:35 +08:00
<el-form :inline="true" label-width="68px" @submit.prevent>
2025-02-28 19:09:18 +08:00
<el-row :gutter="20">
<el-form-item label="车型">
2025-03-02 13:25:35 +08:00
<el-radio-group v-model="queryParams.carTypeId" @change="getQuestionChapter">
<el-radio label="1001">小车</el-radio>
<el-radio label="1002">摩托车</el-radio>
2025-02-28 19:09:18 +08:00
</el-radio-group>
</el-form-item>
<el-form-item label="科目">
2025-03-02 13:25:35 +08:00
<el-radio-group v-model="queryParams.subject" @change="getQuestionChapter">
2025-02-28 19:09:18 +08:00
<el-radio label="1">科一</el-radio>
<el-radio label="4">科四</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="有图片">
<el-radio-group v-model="queryParams.isPic">
<el-radio :label="true"></el-radio>
<el-radio :label="false"></el-radio>
</el-radio-group>
</el-form-item>
</el-row>
<el-row :gutter="20">
<el-form-item label="题目">
<el-input
2025-03-02 13:25:35 +08:00
v-model="queryParams.question"
2025-02-28 19:09:18 +08:00
placeholder="请输入题目"
clearable
style="width: 400px"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
2025-03-03 17:44:39 +08:00
<el-button
type="primary"
@click="handleQuery"
v-hasPermi="['xj-applet:xj-database:search']"
>搜索</el-button
>
<el-button type="primary" @click="handleAdd" v-hasPermi="['xj-applet:xj-database:add']"
>新增</el-button
>
2025-02-28 19:09:18 +08:00
</el-form-item>
</el-row>
</el-form>
2025-03-02 13:25:35 +08:00
<el-table
v-loading="loading"
:data="tableList"
highlight-current-row
max-height="calc(100vh - 260px)"
>
2025-02-28 19:09:18 +08:00
<el-table-column type="index" width="55" align="center" />
2025-03-02 13:25:35 +08:00
<el-table-column label="题目" align="left" prop="question" min-width="140" />
2025-02-28 19:09:18 +08:00
<el-table-column label="选项" align="left" min-width="140">
<template #default="{ row }">
2025-03-02 13:25:35 +08:00
<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>
2025-02-28 19:09:18 +08:00
</template>
</el-table-column>
2025-03-02 13:25:35 +08:00
<el-table-column label="答案" align="center" prop="trueAnswer" width="100" />
<el-table-column label="科目" align="center" prop="subject" width="100">
2025-02-28 19:09:18 +08:00
<template #default="{ row }">
2025-03-02 13:25:35 +08:00
<span v-if="row.subject == '1'">科一</span>
<span v-if="row.subject == '4'">科四</span>
2025-02-28 19:09:18 +08:00
</template>
</el-table-column>
2025-03-02 13:25:35 +08:00
<el-table-column label="章节" align="center" prop="chapterName" min-width="100" />
2025-02-28 19:09:18 +08:00
<el-table-column label="图片" align="center" width="100">
<template #default="{ row }">
<el-image
2025-03-02 13:25:35 +08:00
v-if="row.imageUrl"
:src="`https://ss-cloud.ahduima.com/xjxc/pic/${row.imageUrl}`"
:preview-src-list="[`https://ss-cloud.ahduima.com/xjxc/pic/${row.imageUrl}`]"
2025-02-28 19:09:18 +08:00
:lazy="true"
style="width: 80px"
/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="140">
<template #default="scope">
2025-03-03 17:44:39 +08:00
<el-button
type="primary"
link
@click="handleEdit(scope.row)"
v-hasPermi="['xj-applet:xj-database:edit']"
>
编辑
</el-button>
<el-button
type="primary"
link
@click="handleDelete(scope.row.id)"
v-hasPermi="['xj-applet:xj-database:remove']"
>
删除
</el-button>
2025-02-28 19:09:18 +08:00
</template>
</el-table-column>
</el-table>
<pagination
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="XjDatabase">
2025-03-02 13:25:35 +08:00
import { searchQuestion, deleteQuestion, getQuestionSort } from '@/api/xjapplet/xjdatabase'
2025-02-28 19:09:18 +08:00
import QuestionAddForm from './components/QuestionAddForm.vue'
const loading = ref(false)
const total = ref(0)
const tableList = ref([])
2025-03-02 13:25:35 +08:00
const queryParams = ref({
question: '',
carTypeId: '1001',
subject: '1',
2025-02-28 19:09:18 +08:00
isPic: undefined,
pageNo: 1,
pageSize: 100
})
2025-03-02 13:25:35 +08:00
onMounted(() => {
getQuestionChapter()
})
const chapterOptions = ref([])
const getQuestionChapter = () => {
getQuestionSort({
carTypeId: queryParams.value.carTypeId,
subject: queryParams.value.subject
}).then((data) => {
chapterOptions.value = data
})
}
2025-02-28 19:09:18 +08:00
function getList() {
loading.value = true
2025-03-02 13:25:35 +08:00
searchQuestion(queryParams.value).then((response) => {
2025-02-28 19:09:18 +08:00
tableList.value = response.list
total.value = response.total
loading.value = false
})
}
function handleQuery() {
getList()
}
const dialogAddForm = ref(null)
function handleEdit(item) {
2025-03-02 13:25:35 +08:00
dialogAddForm.value.open(item, chapterOptions.value)
2025-02-28 19:09:18 +08:00
}
function handleAdd() {
2025-03-02 13:25:35 +08:00
dialogAddForm.value.open(
{
subject: queryParams.value.subject,
carTypeId: queryParams.value.carTypeId
},
chapterOptions.value
)
2025-02-28 19:09:18 +08:00
}
function handleDelete(id) {
deleteQuestion(id).then(() => {
getList()
})
}
</script>
<style lang="scss" scoped></style>