|
@@ -1,225 +1,223 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <div class="button-box clearflex">
|
|
|
- <el-button @click="dialogFormVisible=true" type="primary">新增题库</el-button>
|
|
|
- </div>
|
|
|
+ <div>
|
|
|
+ <div class="button-box clearflex">
|
|
|
+ <el-button @click="dialogFormVisible=true" type="primary">新增题库</el-button>
|
|
|
+ </div>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-table :data="tableData" border stripe>
|
|
|
+ <el-table-column label="题组Id" prop="examId" width="80"></el-table-column>
|
|
|
+ <el-table-column label="题组名字" prop="name" width="120">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-input v-if="row.edit" class="edit-input" size="small" v-model="row.name" clearable />
|
|
|
+ <span v-else>{{ row.name }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
|
|
|
- <el-table :data="tableData" border stripe>
|
|
|
- <el-table-column label="题组Id" prop="examId"></el-table-column>
|
|
|
- <el-table-column label="题组名字" prop="name">
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <el-input
|
|
|
- v-if="row.edit"
|
|
|
- class="edit-input"
|
|
|
- size="small"
|
|
|
- v-model="row.name"
|
|
|
- clearable
|
|
|
- />
|
|
|
- <span v-else>{{ row.name }}</span>
|
|
|
- </template>
|
|
|
-
|
|
|
-
|
|
|
- </el-table-column>
|
|
|
+ <el-table-column align="center" width="200px" label="操作" class-name="small-padding fixed-width">
|
|
|
+ <template slot-scope="{row, $index}">
|
|
|
+ <el-button v-if="row.edit" type="success" size="small" icon="el-icon-circle-check" @click="confirmEdit(row, $index)">提交</el-button>
|
|
|
+ <el-button v-if="row.edit" class="cancel-btn" size="small" icon="el-icon-refresh" type="warning" @click="cancelEdit(row, $index)">取消</el-button>
|
|
|
+ <el-button v-if="!row.edit" type="primary" size="small" @click="initEdit(row, $index)">编辑</el-button>
|
|
|
+ <el-button v-if="!row.edit" type="warning" size="small" @click="importData(row, $index)">导入</el-button>
|
|
|
+ <el-button v-if="!row.edit" type="success" size="small" @click="showData(row, $index)">查看</el-button>
|
|
|
|
|
|
- <el-table-column
|
|
|
- align="center"
|
|
|
- width="260px"
|
|
|
- label="操作"
|
|
|
- class-name="small-padding fixed-width"
|
|
|
- >
|
|
|
- <template slot-scope="{row, $index}">
|
|
|
- <el-button
|
|
|
- v-if="row.edit"
|
|
|
- type="success"
|
|
|
- size="small"
|
|
|
- icon="el-icon-circle-check"
|
|
|
- @click="confirmEdit(row, $index)"
|
|
|
- >提交</el-button>
|
|
|
- <el-button
|
|
|
- v-if="row.edit"
|
|
|
- class="cancel-btn"
|
|
|
- size="small"
|
|
|
- icon="el-icon-refresh"
|
|
|
- type="warning"
|
|
|
- @click="cancelEdit(row, $index)"
|
|
|
- >取消</el-button>
|
|
|
- <el-button
|
|
|
- v-if="!row.edit"
|
|
|
- type="primary"
|
|
|
- size="small"
|
|
|
- icon="el-icon-edit"
|
|
|
- @click="initEdit(row, $index)"
|
|
|
- >编辑</el-button>
|
|
|
- <el-button
|
|
|
- v-if="!row.edit"
|
|
|
- type="warning"
|
|
|
- size="small"
|
|
|
- icon="el-icon-edit"
|
|
|
- @click="importData(row, $index)"
|
|
|
- >导入题库</el-button>
|
|
|
-
|
|
|
-
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- <el-pagination
|
|
|
- :current-page="page"
|
|
|
- :page-size="pageSize"
|
|
|
- :page-sizes="[10, 30, 50, 100]"
|
|
|
- :style="{float:'right',padding:'20px'}"
|
|
|
- :total="total"
|
|
|
- @current-change="handleCurrentChange"
|
|
|
- @size-change="handleSizeChange"
|
|
|
- layout="total, sizes, prev, pager, next, jumper"
|
|
|
- ></el-pagination>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <el-pagination :current-page="page" :page-size="pageSize" :page-sizes="[10, 30, 50, 100]" :style="{float:'right',padding:'20px'}"
|
|
|
+ :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="18" style="padding-left: 40px;">
|
|
|
+ <IAnswerList :data="answerList" :randId="randId"></IAnswerList>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
|
|
|
- <el-dialog title="新增题库" center :visible.sync="dialogFormVisible" >
|
|
|
- <el-form :model="form" :rules="rules" label-width="120px" ref="elForm">
|
|
|
- <el-form-item label="题库名称" prop="name" >
|
|
|
- <el-input v-model="form.name" type="text" class="user-form-item" clearable></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <div class="dialog-footer" slot="footer">
|
|
|
- <el-button @click="dialogFormVisible=false">取 消</el-button>
|
|
|
- <el-button @click="addGroup" type="primary">确 定</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
-
|
|
|
-
|
|
|
- <el-dialog title="导入题库" center :visible.sync="dialogImport" width="1024px">
|
|
|
- <IUploadAnswer @submit="onSubmit"></IUploadAnswer>
|
|
|
- </el-dialog>
|
|
|
- </div>
|
|
|
+ <el-dialog title="新增题库" center :visible.sync="dialogFormVisible">
|
|
|
+ <el-form :model="form" :rules="rules" label-width="120px" ref="elForm">
|
|
|
+ <el-form-item label="题库名称" prop="name">
|
|
|
+ <el-input v-model="form.name" type="text" class="user-form-item" clearable></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div class="dialog-footer" slot="footer">
|
|
|
+ <el-button @click="dialogFormVisible=false">取 消</el-button>
|
|
|
+ <el-button @click="addGroup" type="primary">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+
|
|
|
+ <el-dialog title="导入题库" center :visible.sync="dialogImport" width="1024px">
|
|
|
+ <IUploadAnswer @submit="onSubmit"></IUploadAnswer>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getWxGroupList, postData} from "@/api/exam.js";
|
|
|
-import {toDatetime} from "@/utils/date"
|
|
|
-import { time2str, str2time} from "@/utils/index.js";
|
|
|
-import DropSearch from '@/components/select/DropSearch.vue';
|
|
|
-import IUploadAnswer from './components/IUploadAnswer.vue';
|
|
|
+ import {
|
|
|
+ getWxGroupList,
|
|
|
+ postData
|
|
|
+ } from "@/api/exam.js";
|
|
|
+ import {
|
|
|
+ toDatetime
|
|
|
+ } from "@/utils/date"
|
|
|
+ import {
|
|
|
+ time2str,
|
|
|
+ str2time
|
|
|
+ } from "@/utils/index.js";
|
|
|
+ import DropSearch from '@/components/select/DropSearch.vue';
|
|
|
+ import IUploadAnswer from './components/IUploadAnswer.vue';
|
|
|
+ import IAnswerList from './components/IAnswerList.vue';
|
|
|
|
|
|
-export default {
|
|
|
- name: "Api",
|
|
|
- data() {
|
|
|
- return {
|
|
|
- dialogFormVisible: false,
|
|
|
- dialogImport: false,
|
|
|
- examId: 0,
|
|
|
- form: {
|
|
|
- name:''
|
|
|
- },
|
|
|
- searchInfo:{},
|
|
|
- page: 1,
|
|
|
- total: 10,
|
|
|
- pageSize: 10,
|
|
|
- tableData: [],
|
|
|
- rules: {
|
|
|
- name: [{ required: true, message: "请输入题库", trigger: "blur" }]
|
|
|
- }
|
|
|
- };
|
|
|
- },
|
|
|
- components:{DropSearch,IUploadAnswer},
|
|
|
- methods: {
|
|
|
- //条件搜索前端看此方法
|
|
|
- onSubmit( list ) {
|
|
|
- let examId = this.examId;
|
|
|
- postData( "addAnswerList", {examId, list}).then( res=>{
|
|
|
- if( res.code == 200){
|
|
|
- this.$message.successMsg("导入成功", 2);
|
|
|
- this.dialogImport = false
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- importData(row){
|
|
|
- this.examId = row.examId;
|
|
|
- this.dialogImport = true;
|
|
|
- },
|
|
|
- cancelEdit(row, index) {
|
|
|
- row = Object.assign(row, row.temp);
|
|
|
- row.edit = false;
|
|
|
- delete( row["temp"] );
|
|
|
- },
|
|
|
- initEdit(row, index) {
|
|
|
- let form = Object.assign({}, row);
|
|
|
- row.edit = true;
|
|
|
- row.temp = form;
|
|
|
- },
|
|
|
- doCreateCategory(){
|
|
|
- this.$refs.addAd.validate(async (valid) => {
|
|
|
- if (!valid) return;
|
|
|
- let param = Object.assign( {}, this.form )
|
|
|
- param.starime = toDatetime( param.end_time)
|
|
|
- param.counter = +param.counter
|
|
|
- param.end_time = param.startTime + (60*param.duration)
|
|
|
- createCategory(param).then(data => {
|
|
|
- this.$message.successMsg("新增成功", 1)
|
|
|
- this.dialogFormVisible = false
|
|
|
- this.getTableData()
|
|
|
- });
|
|
|
- })
|
|
|
- },
|
|
|
- confirmEdit( row ) {
|
|
|
- let param = Object.assign( {}, row )
|
|
|
- postData("addExam", param).then((res) => {
|
|
|
- if( res.code == 200){
|
|
|
- row.edit = false;
|
|
|
- delete( row["temp"] )
|
|
|
- this.$message.successMsg("编辑成功", 1);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- handleSizeChange(val) {
|
|
|
- this.pageSize = val
|
|
|
- },
|
|
|
- handleCurrentChange(val) {
|
|
|
- this.page = val
|
|
|
- },
|
|
|
- getTableData(){
|
|
|
- postData("GetAllExamList", {}).then( res=>{
|
|
|
- if( res.code == 200){
|
|
|
- this.tableData = res.data.map( v=>{
|
|
|
- v.edit = false
|
|
|
- return v
|
|
|
+ export default {
|
|
|
+ name: "Api",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ dialogFormVisible: false,
|
|
|
+ dialogImport: false,
|
|
|
+ examId: 0,
|
|
|
+ form: {
|
|
|
+ name: ''
|
|
|
+ },
|
|
|
+ searchInfo: {},
|
|
|
+ page: 1,
|
|
|
+ total: 10,
|
|
|
+ randId:0,
|
|
|
+ pageSize: 10,
|
|
|
+ tableData: [],
|
|
|
+ answerList:[],
|
|
|
+ rules: {
|
|
|
+ name: [{
|
|
|
+ required: true,
|
|
|
+ message: "请输入题库",
|
|
|
+ trigger: "blur"
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ DropSearch,
|
|
|
+ IUploadAnswer,
|
|
|
+ IAnswerList
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //条件搜索前端看此方法
|
|
|
+ onSubmit(list) {
|
|
|
+ let examId = this.examId;
|
|
|
+ postData("addAnswerList", {
|
|
|
+ examId,
|
|
|
+ list
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$message.successMsg("导入成功", 2);
|
|
|
+ this.dialogImport = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ importData(row) {
|
|
|
+ this.examId = row.examId;
|
|
|
+ this.dialogImport = true;
|
|
|
+ },
|
|
|
+ showData(row) {
|
|
|
+ let examId = row.examId;
|
|
|
+ postData("getExamAnswerList", {examId}).then( res=>{
|
|
|
+ if( res.code == 200){
|
|
|
+ this.answerList = res.data||[];
|
|
|
+ this.randId = Math.random()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ cancelEdit(row, index) {
|
|
|
+ row = Object.assign(row, row.temp);
|
|
|
+ row.edit = false;
|
|
|
+ delete(row["temp"]);
|
|
|
+ },
|
|
|
+ initEdit(row, index) {
|
|
|
+ let form = Object.assign({}, row);
|
|
|
+ row.edit = true;
|
|
|
+ row.temp = form;
|
|
|
+ },
|
|
|
+ doCreateCategory() {
|
|
|
+ this.$refs.addAd.validate(async (valid) => {
|
|
|
+ if (!valid) return;
|
|
|
+ let param = Object.assign({}, this.form)
|
|
|
+ param.starime = toDatetime(param.end_time)
|
|
|
+ param.counter = +param.counter
|
|
|
+ param.end_time = param.startTime + (60 * param.duration)
|
|
|
+ createCategory(param).then(data => {
|
|
|
+ this.$message.successMsg("新增成功", 1)
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.getTableData()
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ confirmEdit(row) {
|
|
|
+ let param = Object.assign({}, row)
|
|
|
+ postData("addExam", param).then((res) => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ row.edit = false;
|
|
|
+ delete(row["temp"])
|
|
|
+ this.$message.successMsg("编辑成功", 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleSizeChange(val) {
|
|
|
+ this.pageSize = val
|
|
|
+ },
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.page = val
|
|
|
+ },
|
|
|
+ getTableData() {
|
|
|
+ postData("GetAllExamList", {}).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.tableData = res.data.map(v => {
|
|
|
+ v.edit = false
|
|
|
+ return v
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ okGroup(item) {
|
|
|
+ console.log("groupName", item)
|
|
|
+ this.form.groupId = item.id
|
|
|
+ this.form.groupName = item.name
|
|
|
+ },
|
|
|
+ gotoPaper(groupId) {
|
|
|
+ this.$router.push({
|
|
|
+ name: 'exam_paper',
|
|
|
+ query: {
|
|
|
+ groupId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addGroup() {
|
|
|
+ this.$refs["elForm"].validate((valid) => {
|
|
|
+ if (!valid) return;
|
|
|
+ let param = Object.assign({}, this.form);
|
|
|
+ postData('addExam', param).then((res) => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.$message.successMsg("新增成功", 1);
|
|
|
+ this.getTableData()
|
|
|
+ }
|
|
|
+ });
|
|
|
})
|
|
|
}
|
|
|
- })
|
|
|
- },
|
|
|
- okGroup( item ){
|
|
|
- console.log("groupName", item)
|
|
|
- this.form.groupId = item.id
|
|
|
- this.form.groupName = item.name
|
|
|
- },
|
|
|
- gotoPaper( groupId ){
|
|
|
- this.$router.push( {name:'exam_paper', query:{groupId}})
|
|
|
- },
|
|
|
- addGroup() {
|
|
|
- this.$refs["elForm"].validate((valid) => {
|
|
|
- if (!valid) return;
|
|
|
- let param = Object.assign({}, this.form);
|
|
|
- postData('addExam', param).then((res) => {
|
|
|
- if( res.code == 200){
|
|
|
- this.dialogFormVisible = false
|
|
|
- this.$message.successMsg("新增成功", 1);
|
|
|
- this.getTableData()
|
|
|
- }
|
|
|
- });
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- filters: {
|
|
|
- toDatetime
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.getTableData();
|
|
|
- }
|
|
|
-};
|
|
|
+ },
|
|
|
+ filters: {
|
|
|
+ toDatetime
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getTableData();
|
|
|
+ }
|
|
|
+ };
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|
|
|
-.el-tag--mini {
|
|
|
- margin-left: 5px;
|
|
|
-}
|
|
|
-.warning {
|
|
|
- color: #dc143c;
|
|
|
-}
|
|
|
+ .el-tag--mini {
|
|
|
+ margin-left: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .warning {
|
|
|
+ color: #dc143c;
|
|
|
+ }
|
|
|
</style>
|