| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532 |
- <!-- 固定选题 Drawer 内容 -->
- <template>
- <div class="drawerItem-container">
- <div class="left-max-big-box">
- <div class="left-title-p">{{titleName}}</div>
- <div class="page-form-title-box">
- <el-form :model="leftQueryParams" class="form-box" ref="queryForm"
- :inline="true" style="width:100%;">
- <el-form-item label="" prop="deptId">
- <el-cascader
- style="width: 180px"
- v-model="leftQueryParams.deptId"
- :options="optionListA"
- :props="{
- emitPath:false,
- checkStrictly: true,
- value: 'deptId',
- label: 'deptName',
- children: 'child',
- }"
- :show-all-levels="false"
- filterable
- placeholder="来源"
- ></el-cascader>
- </el-form-item>
- <el-form-item label="" prop="questionType">
- <el-select v-model="leftQueryParams.questionType" placeholder="题型" style="width: 140px">
- <el-option
- v-for="dict in optionListB"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="" prop="difficulty">
- <el-select v-model="leftQueryParams.difficulty" placeholder="难度" style="width: 140px">
- <el-option
- v-for="dict in optionListC"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="" prop="questionContent">
- <el-input
- maxLength="30"
- v-model="leftQueryParams.questionContent"
- placeholder="搜索试题"
- style="width: 140px"
- />
- </el-form-item>
- <p class="page-inquire-common-style-button" @click="leftHandleQuery">查询</p>
- <p class="page-reset-common-style-button" @click="leftResetQuery">重置</p>
- </el-form>
- </div>
- <div class="page-content-box">
- <el-table class="table-box" border :data="leftDataList"
- ref="leftMultipleTable" :row-key="leftGetRowKey" @selection-change="leftHandleSelectionChange">
- <el-table-column type="selection" width="55" :reserve-selection="true"></el-table-column>
- <el-table-column label="题干" prop="questionContent" show-overflow-tooltip>
- <template slot-scope="scope">
- <span style="color:#0183fa;cursor: pointer;" @click="tableButton(2,scope.row)">{{ cleanRichText(scope.row.questionContent) }}</span>
- </template>
- </el-table-column>
- <el-table-column label="题型" prop="questionType" width="140" show-overflow-tooltip>
- <template slot-scope="scope">
- <span>{{ scope.row.questionType == 1?'单选题':(scope.row.questionType == 2?'多选题':(scope.row.questionType == 3?'判断题':'')) }}</span>
- </template>
- </el-table-column>
- <el-table-column label="难度" prop="content" width="140" show-overflow-tooltip>
- <template slot-scope="scope">
- <span>{{ scope.row.difficulty == 1?'简单':(scope.row.difficulty == 2?'一般':(scope.row.difficulty == 3?'较难':(scope.row.difficulty == 4?'极难':''))) }}</span>
- </template>
- </el-table-column>
- </el-table>
- <pagination :page-sizes="[20, 30, 40, 50]"
- v-show="leftTotal>0"
- :total="leftTotal"
- :page.sync="leftQueryParams.page"
- :limit.sync="leftQueryParams.pageSize"
- @pagination="leftGetList"
- />
- </div>
- </div>
- <div class="center-max-big-box">
- <p></p>
- <p class="el-icon-arrow-right" @click="addButton()"></p>
- <p class="el-icon-arrow-left" @click="delButton()"></p>
- <p></p>
- </div>
- <div class="right-max-big-box">
- <div class="right-title-box">
- <p>总题目数:{{maxNum}}</p>
- <p>总分:{{maxScore}}</p>
- <!--<p>还需设置 {{gapScore}} 分的题目</p>-->
- </div>
- <div class="page-form-title-box">
- <el-form :model="rightQueryParams" class="form-box" ref="queryForm"
- :inline="true" style="width:100%;">
- <el-form-item label="" prop="deptId">
- <el-cascader
- style="width: 180px"
- v-model="rightQueryParams.deptId"
- :options="optionListA"
- :props="{
- emitPath:false,
- checkStrictly: true,
- value: 'deptId',
- label: 'deptName',
- children: 'child',
- }"
- :show-all-levels="false"
- filterable
- placeholder="来源"
- ></el-cascader>
- </el-form-item>
- <el-form-item label="" prop="questionType">
- <el-select v-model="rightQueryParams.questionType" placeholder="题型" style="width: 140px">
- <el-option
- v-for="dict in optionListB"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="" prop="difficulty">
- <el-select v-model="rightQueryParams.difficulty" placeholder="难度" style="width: 140px">
- <el-option
- v-for="dict in optionListC"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="" prop="questionContent">
- <el-input
- maxLength="30"
- v-model="rightQueryParams.questionContent"
- placeholder="搜索试题"
- style="width: 140px"
- />
- </el-form-item>
- <p class="page-inquire-common-style-button" @click="rightHandleQuery">查询</p>
- <p class="page-reset-common-style-button" @click="rightResetQuery">重置</p>
- </el-form>
- </div>
- <div class="page-content-box">
- <el-table class="table-box" border :data="rightDataList"
- ref="rightMultipleTable" :row-key="rightGetRowKey" @selection-change="rightHandleSelectionChange">
- <el-table-column type="selection" width="55" :reserve-selection="true"></el-table-column>
- <el-table-column label="题干" prop="questionContent" show-overflow-tooltip>
- <template slot-scope="scope">
- <span style="color:#0183fa;cursor: pointer;" @click="tableButton(2,scope.row)">{{ cleanRichText(scope.row.questionContent) }}</span>
- </template>
- </el-table-column>
- <el-table-column label="题型" prop="questionType" width="140" show-overflow-tooltip>
- <template slot-scope="scope">
- <span>{{ scope.row.questionType == 1?'单选题':(scope.row.questionType == 2?'多选题':(scope.row.questionType == 3?'判断题':'')) }}</span>
- </template>
- </el-table-column>
- <el-table-column label="难度" prop="content" width="140" show-overflow-tooltip>
- <template slot-scope="scope">
- <span>{{ scope.row.difficulty == 1?'简单':(scope.row.difficulty == 2?'一般':(scope.row.difficulty == 3?'较难':(scope.row.difficulty == 4?'极难':''))) }}</span>
- </template>
- </el-table-column>
- </el-table>
- <pagination :page-sizes="[20, 30, 40, 50]"
- v-show="rightTotal>0"
- :total="rightTotal"
- :page.sync="rightQueryParams.page"
- :limit.sync="rightQueryParams.pageSize"
- @pagination="rightGetList"
- />
- </div>
- </div>
- <div class="button-position-box">
- <p class="button-1" @click="outButton()">返回</p>
- <p class="button-2" @click="resetButton()">重置</p>
- <p class="button-3" @click="saveButton()">保存</p>
- </div>
- </div>
- </template>
- <script>
- import {
- systemDeptCurrentDept,examElQuestionBankList,
- } from "@/api/safetyEducationExaminationNew/index";
- export default {
- name: 'drawerItem',
- props: {
- drawerPropsData:{},
- },
- data() {
- return {
- titleName:'',
- knowledgePointId:'',
- maxNum:0,
- maxScore:0,
- questionScore:0,
- checkIndex:null,
- // gapScore:0,
- optionListA:[],
- optionListB:[{value:1,label:'单选'},{value:2,label:'多选'},{value:3,label:'判断'}],
- optionListC:[{value:1,label:'简单'},{value:2,label:'一般'},{value:3,label:'较难'},{value:4,label:'极难'}],
- leftQueryParams:{
- page:1,
- pageSize:20,
- questionContent:'',
- difficulty:null,
- questionType:null,
- deptId:null,
- },
- leftDataList:[],
- leftTotal:0,
- rightQueryParams:{
- page:1,
- pageSize:20,
- questionContent:'',
- difficulty:null,
- questionType:null,
- deptId:null,
- },
- rightDataList:[],
- rightTotal:0,
- //过滤/显示的题目ids
- questionIds:[],
- leftMultipleSelection:[],
- rightMultipleSelection:[],
- }
- },
- mounted() {
- this.$set(this,'titleName',this.drawerPropsData.name);
- this.$set(this,'knowledgePointId',this.drawerPropsData.knowledgePointId);
- this.$set(this,'questionScore',this.drawerPropsData.questionScore);
- this.$set(this,'checkIndex',this.drawerPropsData.index);
- this.$set(this,'questionIds',this.drawerPropsData.questionIds?this.drawerPropsData.questionIds:[]);
- this.$set(this,'maxScore',this.accMul(this.drawerPropsData.questionScore,this.drawerPropsData.questionIds.length));
- this.leftGetList()
- this.rightGetList()
- this.systemDeptCurrentDept()
- },
- methods: {
- addButton(){
- let self = this;
- if(!self.leftMultipleSelection[0]){
- this.msgError('请勾选左侧题目')
- return
- }
- if(self.leftMultipleSelection.length + this.questionIds.length > 1000){
- this.msgError('最多添加1000道题目')
- return
- }
- let list = [];
- for(let i=0;i<self.leftMultipleSelection.length;i++){
- list.push(self.leftMultipleSelection[i].id)
- }
- this.$set(this,'questionIds',JSON.parse(JSON.stringify([...this.questionIds,...list])));
- this.$set(this,'leftMultipleSelection',[]);
- this.$set(this,'rightMultipleSelection',[]);
- this.$refs.leftMultipleTable.clearSelection();
- this.$refs.rightMultipleTable.clearSelection();
- this.leftHandleQuery();
- this.rightHandleQuery();
- },
- delButton(){
- let self = this;
- if(!self.rightMultipleSelection[0]){
- this.msgError('请勾选右侧题目')
- return
- }
- let list = [];
- for(let i=0;i<self.rightMultipleSelection.length;i++){
- list.push(self.rightMultipleSelection[i].id)
- }
- this.$set(this,'questionIds',JSON.parse(JSON.stringify(this.questionIds.filter(item => !list.includes(item)))));
- this.$set(this,'leftMultipleSelection',[]);
- this.$set(this,'rightMultipleSelection',[]);
- this.$refs.leftMultipleTable.clearSelection();
- this.$refs.rightMultipleTable.clearSelection();
- this.leftHandleQuery();
- this.rightHandleQuery();
- },
- //查询按钮
- leftHandleQuery(){
- this.$set(this.leftQueryParams,'page',1);
- this.leftGetList();
- },
- //重置按钮
- leftResetQuery(){
- this.$set(this,'leftQueryParams',{
- page:1,
- pageSize:20,
- questionContent:'',
- difficulty:null,
- questionType:null,
- deptId:null,
- });
- this.leftGetList();
- },
- leftGetList(){
- let obj = JSON.parse(JSON.stringify(this.leftQueryParams))
- obj.knowledgePointId = this.knowledgePointId;
- obj.excludeQuestionIds = this.questionIds;
- examElQuestionBankList(obj).then(response => {
- this.$set(this,'leftDataList',response.data.records);
- this.$set(this,'leftTotal',response.data.total);
- });
- },
- leftGetRowKey(row) {
- return row.id;
- },
- leftHandleSelectionChange(val) {
- this.leftMultipleSelection = val;
- },
- //查询按钮
- rightHandleQuery(){
- this.$set(this.rightQueryParams,'page',1);
- this.rightGetList();
- },
- //重置按钮
- rightResetQuery(){
- this.$set(this,'rightQueryParams',{
- page:1,
- pageSize:20,
- questionContent:'',
- difficulty:null,
- questionType:null,
- deptId:null,
- });
- this.rightGetList();
- },
- rightGetList(){
- if(!this.questionIds[0]){
- this.$set(this,'rightDataList',[]);
- this.$set(this,'rightTotal',0);
- this.$set(this,'maxScore',0);
- return
- }
- let obj = JSON.parse(JSON.stringify(this.rightQueryParams))
- obj.knowledgePointId = this.knowledgePointId;
- obj.includeQuestionIds = this.questionIds;
- examElQuestionBankList(obj).then(response => {
- this.$set(this,'rightDataList',response.data.records);
- this.$set(this,'rightTotal',response.data.total);
- this.$set(this,'maxNum',response.data.total);
- console.log('this.drawerPropsData.questionScore',this.drawerPropsData.questionScore)
- console.log('response.data.total',response.data.total)
- this.$set(this,'maxScore',this.accMul(this.drawerPropsData.questionScore,response.data.total));
- });
- },
- rightGetRowKey(row) {
- return row.id;
- },
- rightHandleSelectionChange(val) {
- this.rightMultipleSelection = val;
- },
- //学院列表
- systemDeptCurrentDept(){
- systemDeptCurrentDept({}).then(response => {
- const list = response.data || [];
- this.formatTreeData(list);
- this.$set(this,'optionListA',list);
- });
- },
- //清洗富文本
- cleanRichText(htmlStr, maxLength = 50) {
- if (!htmlStr) return '';
- const tempDiv = document.createElement('div');
- tempDiv.innerHTML = htmlStr;
- let text = tempDiv.textContent || tempDiv.innerText || '';
- text = text.replace(/\s+/g, ' ').trim();
- if (maxLength && text.length > maxLength) {
- return text.substring(0, maxLength) + '...';
- }
- return text;
- },
- //返回
- outButton(){
- this.$parent.$parent.drawerReturnButton();
- },
- //重置
- resetButton(){
- },
- //保存
- saveButton(){
- if(!this.questionIds[0]){
- this.msgError('请选择题目')
- return
- }
- let obj = {
- index:this.checkIndex,
- questionIds:this.questionIds
- }
- this.$parent.$parent.drawerConfirmButton(JSON.parse(JSON.stringify(obj)))
- },
- //乘法
- accMul(arg1,arg2){
- var m=0,s1=arg1.toString(),s2=arg2.toString();
- try{m+=s1.split(".")[1].length}catch(e){}
- try{m+=s2.split(".")[1].length}catch(e){}
- return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
- },
- },
- }
- </script>
- <style scoped lang="scss">
- .drawerItem-container {
- flex:1;
- display: flex;
- overflow: hidden;
- .left-max-big-box{
- flex:1;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- border-right:1px solid #dedede;
- .left-title-p{
- height:50px;
- border-bottom:1px solid #dedede;
- line-height:50px;
- padding: 0 20px;
- color:#0183fa;
- font-size:16px;
- }
- }
- .center-max-big-box{
- width:60px;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- p:nth-child(1){
- flex: 1;
- }
- p:nth-child(2){
- width:40px;
- height:40px;
- line-height:40px;
- text-align: center;
- background-color: #0183fa;
- color:#fff;
- border-radius:50%;
- margin:0 0 0 10px;
- cursor: pointer;
- }
- p:nth-child(3){
- width:40px;
- height:40px;
- line-height:40px;
- text-align: center;
- background-color: #0183fa;
- color:#fff;
- border-radius:50%;
- margin:40px 0 0 10px;
- cursor: pointer;
- }
- p:nth-child(4){
- flex: 1;
- }
- }
- .right-max-big-box{
- flex:1;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- border-left:1px solid #dedede;
- .right-title-box{
- display: flex;
- height:50px;
- border-bottom:1px solid #dedede;
- line-height:50px;
- padding: 0 20px;
- p{
- margin-right:40px;
- color:#0183fa;
- font-size:14px;
- font-weight:700;
- }
- }
- }
- .button-position-box{
- position: absolute;
- top:0;
- right:10px;
- display: flex;
- .button-1{
- border:1px solid #999;
- color:#999;
- font-size:14px;
- text-align: center;
- line-height:40px;
- height:40px;
- width:80px;
- border-radius:4px;
- margin:10px 10px 0 0;
- cursor: pointer;
- }
- .button-2{
- border:1px solid #999;
- background-color: #999;
- color:#fff;
- font-size:14px;
- text-align: center;
- line-height:40px;
- height:40px;
- width:80px;
- border-radius:4px;
- margin:10px 10px 0 0;
- cursor: pointer;
- }
- .button-3{
- border:1px solid #0183fa;
- background-color: #0183fa;
- color:#fff;
- font-size:14px;
- text-align: center;
- line-height:40px;
- height:40px;
- width:80px;
- border-radius:4px;
- margin:10px 0 0 0;
- cursor: pointer;
- }
- }
- }
- </style>
|