Files
dm-manage-web/src/views/question/index.vue

143 lines
5.0 KiB
Vue
Raw Normal View History

2023-08-19 23:52:47 +08:00
<template>
<div class="app-container" style="text-align:center">
2023-08-29 10:34:48 +08:00
<el-form size="small" :inline="true" label-width="68px" @submit.native.prevent>
2023-09-13 15:11:48 +08:00
<el-row :gutter="20">
<el-form-item label="车型">
<el-radio-group v-model="queryParams.carTypeId">
<el-radio :label="1001">小车</el-radio>
<el-radio :label="1002">摩托车</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="科目">
<el-radio-group v-model="queryParams.subject">
<el-radio :label="1">科一</el-radio>
<el-radio :label="4">科四</el-radio>
</el-radio-group>
</el-form-item>
</el-row>
2023-08-19 23:52:47 +08:00
<el-form-item label="题目">
<el-input v-model="queryParams.question" placeholder="请输入题目" clearable style="width:400px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
2023-09-18 10:11:04 +08:00
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
2023-08-19 23:52:47 +08:00
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="tableList" style="width:80%;margin:auto" @row-click="handleEdit">
<el-table-column type="index" width="55" align="center" />
<el-table-column label="题目" align="center" prop="question" min-width="140" />
<el-table-column label="选项" align="center" min-width="140">
<template slot-scope="{row}">
2023-08-29 10:34:48 +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>
<p v-if="row.chooseE">E:{{ row.chooseE }}</p>
<p v-if="row.chooseF">F:{{ row.chooseF }}</p>
<p v-if="row.chooseG">G:{{ row.chooseG }}</p>
2023-08-19 23:52:47 +08:00
</template>
</el-table-column>
<el-table-column label="答案" align="center" prop="trueAnswer" min-width="100" />
<el-table-column label="科目" align="center" prop="subject" min-width="100">
<template slot-scope="{row}">
<p v-if="row.subject == 1">科一</p>
<p v-if="row.subject == 4">科四</p>
</template>
</el-table-column>
2023-08-29 10:34:48 +08:00
<el-table-column label="是否新规" align="center" min-width="100">
<template slot-scope="{row}">
{{ row.isNew ? '是' : '' }}
</template>
</el-table-column>
2023-09-13 15:11:48 +08:00
<el-table-column label="车型" align="center" min-width="100">
<template slot-scope="{row}">
{{ row.carTypeId == 1001 ? '小车' : '摩托车' }}
</template>
</el-table-column>
2023-08-19 23:52:47 +08:00
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-download" @click="handleEdit(scope.row)">编辑</el-button>
</template>
</el-table-column>
</el-table>
<!-- <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> -->
2023-09-14 15:44:51 +08:00
<QuestionForm v-if="dialogVisible" ref="dialogForm" :dialog-visible="dialogVisible" @update="getList" />
<QuestionAddForm v-if="dialogAddVisible" ref="dialogAddForm" :dialog-visible="dialogAddVisible" @update="getList" />
2023-09-13 15:25:02 +08:00
2023-08-19 23:52:47 +08:00
</div>
</template>
<script>
import { searchQuestion } from '@/api/question';
import QuestionForm from './components/QuestionForm.vue';
2023-09-13 15:25:02 +08:00
import QuestionAddForm from './components/QuestionAddForm.vue';
2023-08-19 23:52:47 +08:00
export default {
name: 'Question',
components: {
2023-09-13 15:31:45 +08:00
QuestionForm, QuestionAddForm
2023-08-19 23:52:47 +08:00
},
2023-10-09 19:47:09 +08:00
data () {
2023-08-19 23:52:47 +08:00
return {
// 遮罩层
loading: false,
// 总条数
total: 0,
tableList: [],
// 查询参数
queryParams: {
2023-09-13 15:31:45 +08:00
question: '',
carTypeId: 1001,
subject: 1
2023-08-19 23:52:47 +08:00
},
2023-09-13 15:25:02 +08:00
dialogVisible: false,
dialogAddVisible: false
2023-08-19 23:52:47 +08:00
};
},
2023-10-09 19:47:09 +08:00
created () {
2023-08-19 23:52:47 +08:00
// this.getList();
},
methods: {
/** 查询文件列表 */
2023-10-09 19:47:09 +08:00
getList () {
2023-08-19 23:52:47 +08:00
this.loading = true;
searchQuestion(this.queryParams).then(response => {
this.tableList = response.data;
// this.total = response.total;
this.loading = false;
});
},
/** 搜索按钮操作 */
2023-10-09 19:47:09 +08:00
handleQuery () {
2023-08-29 10:34:48 +08:00
if (this.queryParams.question) {
this.getList();
} else {
this.$modal.msgWarning('请输入题目');
}
2023-08-19 23:52:47 +08:00
},
/** 重置按钮操作 */
2023-10-09 19:47:09 +08:00
resetQuery () {
2023-08-19 23:52:47 +08:00
this.queryParams.question = '';
this.handleQuery();
},
2023-10-09 19:47:09 +08:00
handleEdit (item) {
2023-08-19 23:52:47 +08:00
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs.dialogForm.init(item);
});
2023-09-13 15:25:02 +08:00
},
2023-10-09 19:47:09 +08:00
handleAdd (item) {
2023-09-13 15:25:02 +08:00
this.dialogAddVisible = true;
this.$nextTick(() => {
this.$refs.dialogAddForm.init(item);
});
2023-08-19 23:52:47 +08:00
}
}
};
</script>