master
qsh 8 months ago
parent fc92668bd1
commit c66b8f227e
  1. 2
      src/api/question.js
  2. 65
      src/views/question/components/QuestionAddForm.vue
  3. 32
      src/views/question/components/QuestionForm.vue
  4. 29
      src/views/question/index.vue
  5. 6
      vue.config.js

@ -31,5 +31,3 @@ export function addQuestion(data) {
data: data data: data
}); });
} }

@ -1,7 +1,14 @@
<template> <template>
<el-dialog title="试题" :close-on-click-modal="false" append-to-body :visible.sync="visible" width="900px" @close="closeDialog"> <el-dialog title="试题" :close-on-click-modal="false" append-to-body :visible.sync="visible" width="900px" @close="closeDialog">
<div> <div>
<el-form ref="dialogForm" :model="dialogForm" :rules="dataRule" label-position="left" @keyup.enter.native="dialogFormSubmit()"> <el-form
ref="dialogForm"
:model="dialogForm"
:rules="dataRule"
label-width="80px"
label-position="left"
@keyup.enter.native="dialogFormSubmit()"
>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="题目" prop="question"> <el-form-item label="题目" prop="question">
@ -9,7 +16,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="选项A" prop="question"> <el-form-item label="选项A" prop="question">
<el-input v-model="dialogForm.chooseA" maxlength="200" placeholder="请输入" clearable /> <el-input v-model="dialogForm.chooseA" maxlength="200" placeholder="请输入" clearable />
@ -21,7 +28,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="选项C" prop="question"> <el-form-item label="选项C" prop="question">
<el-input v-model="dialogForm.chooseC" maxlength="200" placeholder="请输入" clearable /> <el-input v-model="dialogForm.chooseC" maxlength="200" placeholder="请输入" clearable />
@ -33,7 +40,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="选项E" prop="question"> <el-form-item label="选项E" prop="question">
<el-input v-model="dialogForm.chooseE" maxlength="200" placeholder="请输入" clearable /> <el-input v-model="dialogForm.chooseE" maxlength="200" placeholder="请输入" clearable />
@ -45,7 +52,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="选项G" prop="question"> <el-form-item label="选项G" prop="question">
<el-input v-model="dialogForm.chooseG" maxlength="200" placeholder="请输入" clearable /> <el-input v-model="dialogForm.chooseG" maxlength="200" placeholder="请输入" clearable />
@ -63,11 +70,11 @@
<el-col :span="24"> <el-col :span="24">
<el-form-item label="科目" prop="subject"> <el-form-item label="科目" prop="subject">
<span v-if="dialogForm.subject == 1">科一</span> <span v-if="dialogForm.subject == 1">科一</span>
<span v-if="dialogForm.subject == 4">科四</span> <span v-else-if="dialogForm.subject == 4">科四</span>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row :gutter="20">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="精选500题" prop="isVip"> <el-form-item label="精选500题" prop="isVip">
<el-radio-group v-model="dialogForm.isVip" size="small"> <el-radio-group v-model="dialogForm.isVip" size="small">
@ -132,11 +139,25 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </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="dialogForm.imageUrl" :src="dialogForm.imageUrl" style="width: 200px;">
<i v-else class="el-icon-plus" />
</el-upload>
</el-form-item>
</el-row>
</el-form> </el-form>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button plain @click="(visible=false)">取消</el-button> <el-button plain @click="visible = false">取消</el-button>
<el-button v-jclick type="primary" :disabled="!canSubmit" @click="dialogFormSubmit()">确定</el-button> <el-button v-jclick type="primary" :disabled="!canSubmit" @click="dialogFormSubmit()">确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
@ -146,7 +167,7 @@
import { addQuestion } from '@/api/question'; import { addQuestion } from '@/api/question';
export default { export default {
data () { data() {
return { return {
visible: false, visible: false,
canSubmit: true, canSubmit: true,
@ -167,7 +188,7 @@ export default {
}; };
}, },
methods: { methods: {
init (info = undefined) { init(info = undefined) {
// debugger // debugger
this.visible = true; this.visible = true;
this.$nextTick(() => { this.$nextTick(() => {
@ -178,7 +199,7 @@ export default {
} }
}); });
}, },
resetDialogForm () { resetDialogForm() {
this.dialogForm = { this.dialogForm = {
questionId: undefined, questionId: undefined,
isVip: 0, isVip: 0,
@ -190,14 +211,14 @@ export default {
examKeys: undefined examKeys: undefined
}; };
}, },
closeDialog () { closeDialog() {
this.$emit('update:dialogVisible', false); this.$emit('update:dialogVisible', false);
}, },
// //
dialogFormSubmit () { dialogFormSubmit() {
this.$refs.dialogForm.validate((valid) => { this.$refs.dialogForm.validate((valid) => {
if (valid) { if (valid) {
updateQuestion(this.dialogForm).then(response => { addQuestion(this.dialogForm).then((response) => {
if (response.code == 200) { if (response.code == 200) {
this.$modal.msgSuccess('修改成功'); this.$modal.msgSuccess('修改成功');
// this.visible = true; // this.visible = true;
@ -205,6 +226,20 @@ export default {
}); });
} }
}); });
},
handleImport(opt) {
const data = new FormData();
data.append('file', opt.file);
//
// api.upload(data).then(resp => {
// if (resp.code == 200) {
// this.$modal.msgSuccess('');
// this.dialogForm.imageUrl = resp.data;
// }
// });
},
handleExceed(files) {
this.handleImport({ file: files[0] });
} }
} }
}; };

@ -6,10 +6,25 @@
<el-col :span="24"> <el-col :span="24">
<el-form-item label="题目" prop="question"> <el-form-item label="题目" prop="question">
<div>{{ dialogForm.question }}</div> <div>{{ dialogForm.question }}</div>
<img v-if="dialogForm.imageUrl" :src="dialogForm.imageUrl" width="100" alt=""> <img v-if="dialogForm.imageUrl" :src="dialogForm.imageUrl" width="200" alt="">
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-form-item label="替换图片">
<el-upload
action="#"
accept=".png,.jpg,.jpeg,.gif"
:limit="1"
:http-request="handleImport"
:on-exceed="handleExceed"
:show-file-list="false"
>
<img v-if="dialogForm.imageUrl" :src="dialogForm.imageUrl" style="width: 300px;">
<i v-else class="el-icon-plus" />
</el-upload>
</el-form-item>
</el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="选项" prop="question"> <el-form-item label="选项" prop="question">
@ -146,6 +161,7 @@ export default {
// this.$refs['dialogForm'].resetFields(); // this.$refs['dialogForm'].resetFields();
if (info) { if (info) {
this.dialogForm = this.deepClone(info); this.dialogForm = this.deepClone(info);
this.fileUrl = info.imageUrl;
} }
}); });
}, },
@ -177,6 +193,20 @@ export default {
}); });
} }
}); });
},
handleImport(opt) {
const data = new FormData();
data.append('file', opt.file);
//
// api.upload(data).then(resp => {
// if (resp.code == 200) {
// this.$modal.msgSuccess('');
// this.dialogForm.imageUrl = resp.data;
// }
// });
},
handleExceed(files) {
this.handleImport({ file: files[0] });
} }
} }
}; };

@ -1,5 +1,5 @@
<template> <template>
<div class="app-container" style="text-align:center"> <div class="app-container" style="text-align: center">
<el-form size="small" :inline="true" label-width="68px" @submit.native.prevent> <el-form size="small" :inline="true" label-width="68px" @submit.native.prevent>
<el-row :gutter="20"> <el-row :gutter="20">
<el-form-item label="车型"> <el-form-item label="车型">
@ -16,22 +16,24 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-row> </el-row>
<el-form-item>
<el-checkbox v-model="queryParams.isWatermark" :label="true">是否有水印</el-checkbox>
</el-form-item>
<el-form-item label="题目"> <el-form-item label="题目">
<el-input v-model="queryParams.question" placeholder="请输入题目" clearable style="width:400px" @keyup.enter.native="handleQuery" /> <el-input v-model="queryParams.question" placeholder="请输入题目" clearable style="width: 400px" @keyup.enter.native="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <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> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button> <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-loading="loading" :data="tableList" style="width:80%;margin:auto" @row-click="handleEdit"> <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 type="index" width="55" align="center" />
<el-table-column label="题目" align="center" prop="question" min-width="140" /> <el-table-column label="题目" align="center" prop="question" min-width="140" />
<el-table-column label="选项" align="center" min-width="140"> <el-table-column label="选项" align="center" min-width="140">
<template slot-scope="{row}"> <template slot-scope="{ row }">
<p v-if="row.chooseA">A:{{ row.chooseA }}</p> <p v-if="row.chooseA">A:{{ row.chooseA }}</p>
<p v-if="row.chooseB">B:{{ row.chooseB }}</p> <p v-if="row.chooseB">B:{{ row.chooseB }}</p>
<p v-if="row.chooseC">C:{{ row.chooseC }}</p> <p v-if="row.chooseC">C:{{ row.chooseC }}</p>
@ -43,18 +45,18 @@
</el-table-column> </el-table-column>
<el-table-column label="答案" align="center" prop="trueAnswer" min-width="100" /> <el-table-column label="答案" align="center" prop="trueAnswer" min-width="100" />
<el-table-column label="科目" align="center" prop="subject" min-width="100"> <el-table-column label="科目" align="center" prop="subject" min-width="100">
<template slot-scope="{row}"> <template slot-scope="{ row }">
<p v-if="row.subject == 1">科一</p> <p v-if="row.subject == 1">科一</p>
<p v-if="row.subject == 4">科四</p> <p v-if="row.subject == 4">科四</p>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="是否新规" align="center" min-width="100"> <el-table-column label="是否新规" align="center" min-width="100">
<template slot-scope="{row}"> <template slot-scope="{ row }">
{{ row.isNew ? '是' : '' }} {{ row.isNew ? '是' : '' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="车型" align="center" min-width="100"> <el-table-column label="车型" align="center" min-width="100">
<template slot-scope="{row}"> <template slot-scope="{ row }">
{{ row.carTypeId == 1001 ? '小车' : '摩托车' }} {{ row.carTypeId == 1001 ? '小车' : '摩托车' }}
</template> </template>
</el-table-column> </el-table-column>
@ -68,7 +70,6 @@
<!-- <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> --> <!-- <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> -->
<QuestionForm v-if="dialogVisible" ref="dialogForm" :dialog-visible="dialogVisible" @update="getList" /> <QuestionForm v-if="dialogVisible" ref="dialogForm" :dialog-visible="dialogVisible" @update="getList" />
<QuestionAddForm v-if="dialogAddVisible" ref="dialogAddForm" :dialog-visible="dialogAddVisible" @update="getList" /> <QuestionAddForm v-if="dialogAddVisible" ref="dialogAddForm" :dialog-visible="dialogAddVisible" @update="getList" />
</div> </div>
</template> </template>
@ -80,7 +81,8 @@ import QuestionAddForm from './components/QuestionAddForm.vue';
export default { export default {
name: 'Question', name: 'Question',
components: { components: {
QuestionForm, QuestionAddForm QuestionForm,
QuestionAddForm
}, },
data() { data() {
return { return {
@ -106,7 +108,7 @@ export default {
/** 查询文件列表 */ /** 查询文件列表 */
getList() { getList() {
this.loading = true; this.loading = true;
searchQuestion(this.queryParams).then(response => { searchQuestion(this.queryParams).then((response) => {
this.tableList = response.data; this.tableList = response.data;
// this.total = response.total; // this.total = response.total;
this.loading = false; this.loading = false;
@ -135,7 +137,10 @@ export default {
handleAdd(item) { handleAdd(item) {
this.dialogAddVisible = true; this.dialogAddVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.dialogAddForm.init(item); this.$refs.dialogAddForm.init({
subject: this.queryParams.subject,
carTypeId: this.queryParams.carTypeId
});
}); });
} }
} }

@ -35,7 +35,7 @@ module.exports = {
proxy: { proxy: {
[process.env.VUE_APP_BASE_API + '/driver-api']: { [process.env.VUE_APP_BASE_API + '/driver-api']: {
// target: `http://118.31.23.45:8888/driver-api/`, // target: `http://118.31.23.45:8888/driver-api/`,
target: `http://localhost:8888/driver-api/`, target: `https://xueche.ahduima.com/duima/driver-api/`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API + '/driver-api']: '' ['^' + process.env.VUE_APP_BASE_API + '/driver-api']: ''
@ -43,8 +43,8 @@ module.exports = {
}, },
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
// target: `https://xueche.ahduima.com/duima/`, target: `https://xueche.ahduima.com/duima/`,
target: `http://localhost:8086`, // target: `http://localhost:8086`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''

Loading…
Cancel
Save