Commit 280549fe authored by 李苏's avatar 李苏 💬

试题管理

parent a40007f4
......@@ -89,6 +89,23 @@ export function doInitXtms(query) {
})
}
/* 新查询细节 */
export function donDtlQuery(query) {
return request({
url: '/aqgl/pxgl/pxsj/query/detail',
method: 'post',
data: query||{}
})
}
/* 新报存 */
export function donDtlSave(query) {
return request({
url: '/aqgl/pxgl/pxsj/save',
method: 'post',
data: query||{}
})
}
......
<template>
<DefaultDialog :app='app'>
<div class="min_full" slot='form' style="height: 80vh;border: 0px;">
<!-- 查询条件-->
<div class="search" v-condition>
<SearchButton :app='this'></SearchButton>
<el-row :gutter="20" class="search-row-1">
<el-col :span="12" class="search-col">
<div class="search-item">
<span class="search-span">名称:</span>
<el-input v-model="queryParams.info"></el-input>
</div>
</el-col>
</el-row>
</div>
<div class="min_full" slot='form' style="height: 550px;border: 0px;">
<DtlEdit :app='this' v-if="showDialog" ></DtlEdit>
<!-- 按钮操作-->
<el-row class="tool-bar">
<ViewButton ref="view" :app='this'></ViewButton>
<!-- <ViewButton ref="view" :app='this'></ViewButton>
<AddButton ref="add" :app='this'></AddButton>
<CopyButton ref="copy" :app='this'></CopyButton>
<EditButton ref="edit" :app='this'></EditButton>
<EditButton ref="edit" :app='this'></EditButton> -->
<el-button @click="drst" size='mini' style="margin-left: 0px;" type="primary">导入试题</el-button>
<!-- 额外按钮-->
<!-- 表头设置 -->
<!-- 权限-->
</el-row>
<!-- 表格-->
<div class="tablePagers">
<TablePager @getData='getData' :ref="'TablePager'" :app='this' :query='query' @selectItem='selectItem'
<div class="tablePagers" style="height: 380px;">
<TablePager :showPagination='false' @getData='getData' :ref="'TablePager'" :app='this' :query='query' @selectItem='selectItem' :delParams="'mxid'"
@getRow='getRow'>
</TablePager>
......@@ -38,13 +29,13 @@
<script>
/* 引入需要的接口*/
import {
doDtlQuery,
doDtlAdd,
doDtlUpdate,
donDtlQuery,
// doDtlAdd,
// doDtlUpdate,
doDtlDelete
} from '@/api/train/examination.js';
/* edit页面*/
import Edit from './dtlEdit.vue'
import DtlEdit from './dtlEdit.vue'
import {
tableMixin_noapp
} from 'common'
......@@ -55,17 +46,32 @@
/* 初始额外赋值*/
async mounted() {
this.queryParams.mid=this.app.singleItem.id
this.queryParams.xmid=this.app.singleItem.xmid
this.$refs['TablePager'].pageQuery()
/* 存储试卷数据*/
this.sjdata=this.app.singleItem
this.queryParams.mid=this.app.singleItem.id
this.queryParams.xmid=this.app.singleItem.xmid
this.$nextTick(()=>{
this.$refs['TablePager'].pageQuery()
})
},
data() {
return {
typeObj:{
'M':'多选题',
'S':'单选题',
'J':'判断题',
'F':'填空题'
},
sjdata:{},
/*需要的额外参数 */
showDialog: false,
DialogName: '',
type: '',
DialogTitle: '',
DialogWidth:'85%',
DialogTitle:'导入试题',
/* 基础url*/
baseUrl: '/aqgl/pxgl/pxsjmx',
/* 查询参数*/
......@@ -75,20 +81,27 @@
/* 表格标题对应参数*/
tableTitle: [
// {label: "试卷ID", prop: "mid", fieldType: "ftString",width:192},
{label: "试题", prop: "stid", fieldType: "ftString",width:192},
{label: "序号", prop: "xh", fieldType: "int"},
{label: "序号", prop: "xh", fieldType: "int",width:60},
{label: "试题", prop: "cont", fieldType: "ftString",width:850},
{label: "类型", prop: "type", formatter:(a,b,c)=>{
let val=this.typeObj[c]
return val
},width:200},
]
}
},
methods: {
drst(){
this.showDialog=true
},
/* 基础查询*/
query: doDtlQuery,
query: donDtlQuery,
/* 基础增*/
apiAdd: doDtlAdd,
/* 基础更新*/
apiUpdate: doDtlUpdate,
/* 删除操作*/
// apiAdd: doDtlAdd,
// /* 基础更新*/
// apiUpdate: doDtlUpdate,
// /* 删除操作*/
apiDelete: doDtlDelete,
/* 初始化赋值操作*/
init() {
......@@ -96,7 +109,7 @@
}
},
components: {
Edit,
DtlEdit,
}
......
<template>
<RelDialog :type='type' :editApp='editApp' :app='app' :buttonApp='buttonApp'>
<!-- 填写表单内容,slot=form必写-->
<el-form slot="form" ref="form" :model="form" label-width="80px" :rules="rules">
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="类型" >
<RelSelect style="width: 100%;" src='aqgl/pxgl/pxsj/init/stlx' :match="{value:'id',label:'name'}" v-model='type_copy' ></RelSelect>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="试题" ref="stid" prop="stid">
<RelSelect linkage :linkParams="{type:type_copy}" style="width: 100%;" src='aqgl/pxgl/pxst/query' :match="{value:'id',label:'cont'}" v-model='form.stid' ></RelSelect>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="序号" ref="xh" prop="xh">
<el-input :readonly="readonly" v-model="form.xh" ></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</RelDialog>
<DefaultDialog :app='app'>
<div slot='form'class="min_full" style="height: 70vh;border: 0px;">
<div class="search" v-condition>
<SearchButton @click.native='search' ></SearchButton>
<el-row :gutter="20" class="search-row-1">
<el-col :span="6" class="search-col">
<div class="search-item">
<span class="search-span">类型:</span>
<RelSelect filterable style="width: 100%;" clearable src='aqgl/pxgl/pxst/init/type'
:match="{value:'id',label:'name'}" v-model='type'></RelSelect>
</div>
</el-col>
<el-col :span="18" class="search-col" >
<div style="height: 50px;line-height: 50px;font-size: 12px;width: 450px;">
填空题({{fcount}}/{{sjdata.fcount}}) 单选题({{scount}}/{{sjdata.scount}})多选题({{mcount}}/{{sjdata.mcount}})判断题({{jcount}}/{{sjdata.jcount}}
</div>
</el-col>
</el-row>
</div>
<div class="tablePagers">
<el-table
height='50vh'
v-loading="loading"
ref="multipleTable"
:data="tableData"
@select="selectChange"
@select-all="selectAllChange"
>
<el-table-column type="selection" width="55" align="center">
</el-table-column>
<el-table-column prop="cont" label="题目" align="center" > </el-table-column>
<el-table-column prop="type" label="类型" align="center" :formatter="transType" > </el-table-column>
</el-table>
<el-row type="flex" class="pageBanner" style="padding-top: 20px;" justify="center">
<el-pagination
background
:total="total"
:page-size="pageSize"
@size-change="pageSizeChange"
@current-change="currentPageChange"
:current-page="currentPage"
:page-sizes="[10, 20, 30]"
layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination>
</el-row>
</div>
</div>
<div slot="reFooter" class="refooter" >
<span slot="footer" class="dialog-footer" >
<el-button type="primary" @click="save()">导 入</el-button>
</span>
</div>
</DefaultDialog>
</template>
<script>
import {editMixin} from 'common'
export default {
mixins: [editMixin],
/* 存放index页面传递的额外参数*/
mounted() {
this.$nextTick(()=>{
this.form.mid=this.app.queryParams.mid
})
},
/* 组件名称*/
name: "aqgl.pxglPxsjmxEdit",
/* 传递props模式一样必填,用于index,button,REdialog之间的组件通信*/
data() {
return {
type_copy:'S',
xmid:'',
/* 额外初始化,根据需求*/
systemType: [],
bmList: [],
/* 当前表单初始值,默认由RelDialog查询indexQuery赋值,copy时不赋值id,初始化时所有query的值都会赋值给form*/
form: {
//ID
id:'',
//试卷ID
mid:'',
//试题ID
stid:'',
//序号
xh:'',
},
/* form提交时的规则,具体规则参考官网*/
rules: {
}
}
},
methods: {
import {
doQuery,
doAdd,
doUpdate,
doDelete,
pxxmQuery,
excelimport
} from '@/api/train/questionManage';
import {
donDtlSave
} from '@/api/train/examination';
}
export default {
props:['app'],
data() {
return {
typeObj:{
'M':'多选题',
'S':'单选题',
'J':'判断题',
'F':'填空题'
},
type:'',
pageSize: 10,
// 唯一标识符
id: "id",
loading: false,
total: 0,
currentPage: 1,
selectedList: [
],
tableData: [],
};
},
created() {
this.sjdata=this.app.sjdata
this.selectedList=_.cloneDeep(this.app.tabData)
console.log(this.selectedList,'传入已选')
/* 试题定量*/
/* 单选题*/
/* 多选题*/
/* 判断题*/
/* 填空题*/
},
mounted() {
this.$nextTick(()=>{
this.getData(this.currentPage, this.pageSize);
})
// 页面初始化时,首次加载数据
},
computed:{
scount(){
/* 单选数量*/
let num=0
this.selectedList.forEach(item=>{
item.type=='S'&&num++
})
return num
},
mcount(){
let num=0
this.selectedList.forEach(item=>{
item.type=='M'&&num++
})
/* 多选数量*/
return num
},
jcount(){
let num=0
this.selectedList.forEach(item=>{
item.type=='J'&&num++
})
/* 判断题数量*/
return num
},
fcount(){
let num=0
this.selectedList.forEach(item=>{
item.type=='F'&&num++})
/* 填空题*/
return num
}
</script>
},
methods: {
transType(a,b,c){
let val=this.typeObj[c]
return val
},
save(){
/* 判断*/
if(this.scount>this.sjdata.scount){
this.$warning('单选题超出试卷允许设置范围')
return
}
if(this.mcount>this.sjdata.mcount){
this.$warning('多选题超出试卷允许设置范围')
return
}
if(this.jcount>this.sjdata.jcount){
this.$warning('判断题超出试卷允许设置范围')
return
}
if(this.fcount>this.sjdata.fcount){
this.$warning('填空题超出试卷允许设置范围')
return
}
let params={
id:this.sjdata.id,
datas:this.selectedList
}
donDtlSave(params).then(res=>{
if(res.success){
this.$success('导入成功')
this.app.showDialog=false
this.app.$refs['TablePager'].pageQuery()
}
})
<style scoped lang="scss">
},
search(event){
event.preventDefault();
this.getData(this.currentPage, this.pageSize);
},
// 单行前的勾选状态切换
selectChange(selectedRows, row) {
// true为选中, 0或false为取消选中
let selected = selectedRows.length && selectedRows.indexOf(row) !== -1;
if (selected) {
this.addItem(row);
} else {
this.removeItem(row);
}
},
// 全选/取消全选
selectAllChange(selectedRows) {
let selectedMarkList = this.selectedList.map((item) => item[this.id]);
// 当前页选中行的标记列表
let pageSelectedMarkList = Array.isArray(selectedRows)
? selectedRows.map((item) => item[this.id])
: [];
this.tableData.forEach((row) => {
if (pageSelectedMarkList.includes(row[this.id])) {
if (!selectedMarkList.includes(row[this.id])) {
this.addItem(row);
}
} else if (selectedMarkList.includes(row[this.id])) {
this.removeItem(row);
}
});
},
// 切换每页显示条数
pageSizeChange(newPageSize) {
this.pageSize = newPageSize;
this.getData(this.currentPage, this.pageSize);
},
// 切换页码--翻页
currentPageChange(newPage) {
this.currentPage = newPage;
this.getData(this.currentPage, this.pageSize);
},
// 更新勾选标记
updateMark() {
let selectedMarkList = this.selectedList.map((item) => item[this.id]);
this.tableData.forEach((row) => {
if (selectedMarkList.includes(row[this.id])) {
// toggleRowSelection 需在$nextTick中使用!
this.$nextTick(() => {
this.$refs.multipleTable.toggleRowSelection(row);
});
}
});
},
// 模拟访问接口获取数据
getData(page, pageSize) {
this.loading = true;
let params={
xmid:this.sjdata.xmid,
type:this.type,
pageSize:pageSize,
pageNo:page
}
doQuery(params).then(res=>{
this.loading = false;
this.tableData=res.data.records||[]
this.total = res.data.total
this.updateMark();
})
},
// 新增选中项
addItem(item) {
this.selectedList.push(item);
},
// 移除选中项
removeItem(item) {
for (let [index, itemTemp] of this.selectedList.entries()) {
if (itemTemp[this.id] === item[this.id]) {
this.removeItemByIndex(index);
break;
}
}
},
// 根据下标移除选中项
removeItemByIndex(index, item) {
this.selectedList.splice(index, 1);
// 若有item,则是点击标签上的关闭按钮,移除选中项
if (item) {
this.$nextTick(() => {
this.$refs.multipleTable.toggleRowSelection(
// 此处必须在 tableData 中查找对应的数据,否则 toggleRowSelection 会失效
this.tableData.find((row) => {
return row[this.id] === item[this.id];
}),
false
);
});
}
},
},
};
</script>
<style scoped>
.mainBox {
margin: 10px;
}
.el-tag {
margin: 10px;
}
.pageBanner {
margin: 10px;
margin-bottom: 0px;
}
</style>
......@@ -65,7 +65,7 @@
return {
/*需要的额外参数 */
showDialog: false,
DialogWidth:'80%',
DialogWidth:'85%',
DialogName: '',
type: '',
DialogTitle:'',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment