2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
/* empty css */import{p as h,h as m,i as g,j as v}from"./questions.7b4fcf73.js";import{Q as u,a as _}from"./QuestionDifficultyLevelSelector.9fe5a513.js";/* empty css */import{n as l}from"./vueComponentNormalizer.9ef17bb1.js";/* empty css */import{T as y}from"./TableLayout.05a39499.js";import{D as f}from"./DialogLayout.e3af3567.js";/* empty css */import{Q as p}from"./QuestionListPreview.baa07396.js";/* empty css */var x=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",[e("DialogLayout",{staticClass:"gy-dialog-layout",attrs:{title:"\u56FA\u5B9A\u9009\u9898",width:"680px",visible:!0},on:{onCancel:function(s){return t.$emit("onCancel")},onConfirm:t.onFixedConfirm}},[e("div",[e("div",{staticClass:"gy-form inline",staticStyle:{"--fix":"77px"}},[e("div",{staticClass:"gy-form-item"},[e("div",{staticClass:"gy-label middle"},[t._v("\u8BD5\u9898\u5206\u7C7B:")]),e("QuestionClassifySelector",{attrs:{mountedLoad:!0},model:{value:t.form.classifyId,callback:function(s){t.$set(t.form,"classifyId",s)},expression:"form.classifyId"}})],1),e("div",{staticClass:"gy-form-item"},[e("div",{staticClass:"gy-label middle"},[t._v("\u9009\u9898\u9650\u5236:")]),e("QuestionDifficultyLevelSelector",{attrs:{mountedLoad:!0},model:{value:t.form.difficultyLevel,callback:function(s){t.$set(t.form,"difficultyLevel",s)},expression:"form.difficultyLevel"}})],1),e("div",{staticClass:"gy-form-item mb",staticStyle:{margin:"10px 0"}},[e("div",{staticClass:"gy-label middle"},[t._v("\u8FC7\u6EE4\uFF1A")]),e("el-input",{staticStyle:{width:"350px"},attrs:{placeholder:"\u8BF7\u8F93\u5165\u5173\u952E\u5B57\u8FC7\u6EE4"},model:{value:t.form.title,callback:function(s){t.$set(t.form,"title",s)},expression:"form.title"}}),e("el-button",{staticStyle:{"margin-left":"10px"},attrs:{round:"",type:"primary"},on:{click:t.pagingFindList}},[t._v("\u67E5\u8BE2")])],1)]),e("div",{staticClass:"gy-form",staticStyle:{"--fix":"80px",margin:"10px 0"}},[e("div",{staticClass:"gy-form-item mb"},[e("div",{staticClass:"gy-label middle"},[t._v("\u9898\u76EE\u603B\u6570\uFF1A")]),e("div",[t._v(t._s(t.page_info.total))])])]),e("TableLayout",{ref:"tableRef",staticClass:"gy-el-table",attrs:{column:t.column,data:t.table_data,pageInfo:t.page_info,selection:""},on:{"current-change":function(s){return t.pagingChange({currentPage:s})},"size-change":function(s){return t.pagingChange({pageSize:s})},select:t.userSelectItem,"select-all":t.allSelectHandler}}),e("p",{staticStyle:{"padding-left":"10px"}},[t._v(" \u5DF2\u9009\uFF1A"+t._s(t.table_selections_list.length)+" \u9898 "),e("el-button",{attrs:{type:"text",icon:"i-j-fbks-yulan"},on:{click:function(s){t.preview_dialog_show=!0}}},[t._v("\u9884\u89C8")])],1)],1)]),t.preview_dialog_show?e("QuestionListPreview",{attrs:{questionList:t.table_selections_list},on:{onCancel:function(s){t.preview_dialog_show=!1}}}):t._e()],1)},b=[];const S={components:{TableLayout:y,QuestionClassifySelector:u,DialogLayout:f,QuestionListPreview:p,QuestionDifficultyLevelSelector:_},data:()=>({table_data:[],page_info:{currentPage:1,pageSize:10,total:0},form:{title:"",type:null,difficultyLevel:null},table_selections_list:[],old_selections_list:[],preview_dialog_show:!1}),props:{questionType:{default:null},oldSelection:{default:[]},excludeIds:{type:Array,default:null}},watch:{table_selections_list:{immediate:!0,deep:!0,handler(t){}},oldSelection:{immediate:!0,deep:!0,handler(t){this.old_selections_list=t,this.initTableSelection()}},questionType:{immediate:!0,handler(t){this.form.type=t,this.pagingFindList()}}},created(){this.column=[{prop:"title",label:"\u9898\u76EE",width:150,align:"center","show-overflow-tooltip":!0},{prop:"type",label:"\u8BD5\u9898\u7C7B\u578B",align:"center","show-overflow-tooltip":!0},{prop:"classify",label:"\u8BD5\u9898\u5206\u7C7B",align:"center","show-overflow-tooltip":!0},{prop:"difficultyLevel",label:"\u96BE\u5EA6",width:60,align:"center","show-overflow-tooltip":!0},{prop:"knowledgePoint",label:"\u77E5\u8BC6\u70B9",align:"center","show-overflow-tooltip":!0},{prop:"creator",label:"\u521B\u5EFA\u4EBA",align:"center","show-overflow-tooltip":!0}],this.pagingFindList(),this.table_selections_list=this.old_selections_list},methods:{onFixedConfirm(){this.$emit("current-change",this.table_selections_list)},initTableSelection(){this.table_data.forEach(t=>{this.old_selections_list.findIndex(e=>e.id===t.id)!==-1&&this.$nextTick(()=>{this.$refs.tableRef.$refs.tableRef.toggleRowSelection(t,!0)})})},allSelectHandler(t){t.length>0?t.forEach(i=>{this.table_selections_list.findIndex(s=>s.id===i.id)===-1&&this.table_selections_list.push(i)}):this.table_data.forEach(i=>{const e=this.table_selections_list.findIndex(s=>s.id===i.id);e!==-1&&this.table_selections_list.splice(e,1)})},userSelectItem(t,i){if(t.includes(i))this.table_selections_list.push(i);else{const s=this.table_selections_list.findIndex(n=>n.id===i.id);this.table_selections_list.splice(s,1)}},pagingChange(t){typeof t.currentPage!="number"&&typeof t.pageSize!="number"||(this.page_info={...this.page_info,...t},this.pagingFindList())},initPageInfo(){this.page_info={currentPage:1,pageSize:this.page_info.pageSize,total:0}},pagingFindList(t){t instanceof PointerEvent&&this.initPageInfo();let i=this.current_classify_id;i==="system"&&(i=null),this.questions_list_loading=!0,this.excludeIds&&(this.form.excludeIds=this.excludeIds),parseInt(this.$store.user.baseRole)===3&&(this.form.student=1),h({...this.page_info,classifyId:i,...this.form}).then(e=>{const{currentPage:s,pageSize:n,total:o}=e.data;this.table_data=e.data.data,this.table_data.length===0&&this.page_info.currentPage!=1&&(this.initPageInfo(),this.pagingFindList()),this.page_info={currentPage:s,pageSize:n,total:o},this.$nextTick(()=>{this.initTableSelection()})}).finally(e=>{this.questions_list_loading=!1})}}},r={};var C=l(S,x,b,!1,Q,null,null,null);function Q(t){for(let i in r)this[i]=r[i]}const w=function(){return C.exports}();var q=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",[e("DialogLayout",{attrs:{title:"\u968F\u673A\u9009\u9898",width:"710px",visible:!0},on:{onCancel:function(s){return t.$emit("onCancel")},onConfirm:t.onRandConfirm}},[e("div",[e("div",{staticClass:"gy-form inline",staticStyle:{"--fix":"80px"}},[e("div",{staticClass:"gy-form-item"},[e("div",{staticClass:"gy-label middle"},[t._v("\u8BD5\u9898\u5206\u7C7B\uFF1A")]),e("QuestionClassifySelector",{attrs:{mountedLoad:!0},model:{value:t.form.classifyId,callback:function(s){t.$set(t.form,"classifyId",s)},expression:"form.classifyId"}})],1),e("div",{staticClass:"gy-form-item"},[e("div",{staticClass:"gy-label middle"},[t._v("\u96BE\u6613\u7A0B\u5EA6\uFF1A")]),e("QuestionDifficultyLevelSelector",{attrs:{mountedLoad:!0},model:{value:t.form.difficultyLevel,callback:function(s){t.$set(t.form,"difficultyLevel",s)},expression:"form.difficultyLevel"}})],1),e("div",{staticClass:"gy-form-item",staticStyle:{margin:"5px 0",height:"24px"}},[e("div",{staticClass:"gy-label middle"},[t._v("\u9898\u76EE\u603B\u6570\uFF1A")]),e("div",{staticClass:"gy-label middle",staticStyle:{"justify-content":"flex-start"}},[t._v(t._s(t.question_total))])])]),e("div",{staticClass:"gy-form"},[e("div",{staticClass:"gy-form-item",staticStyle:{margin:"10px 0","align-items":"center","--fix":"80px"}},[e("div",{staticClass:"gy-label middle"},[t._v("\u6570\u91CF\uFF1A")]),e("el-input-number",{staticStyle:{width:"120px"},attrs:{size:"mini",min:0,max:+t.question_total},model:{value:t.ranCount,callback:function(s){t.ranCount=s},expression:"ranCount"}}),t._v(" \xA0/ "+t._s(t.question_total)+" "),e("el-button",{staticStyle:{"margin-left":"10px"},attrs:{round:"",type:"primary"},on:{click:t.getRandQuestions}},[t._v("\u62BD\u9898")])],1),e("div",{staticClass:"gy-form-item",staticStyle:{margin:"5px 0",height:"30px","align-items":"center","--fix":"80px"}},[e("div",{staticClass:"gy-label middle"},[t._v("\u5DF2\u9009\uFF1A")]),e("div",[t._v(" "+t._s(t.table_selections_list.length)+"\u9898 "),e("el-button",{staticStyle:{padding:"0 5px"},attrs:{type:"text",icon:"i-j-fbks-yulan"},on:{click:function(s){t.preview_dialog_show=!0}}},[t._v("\u9884\u89C8")])],1)])])])]),t.preview_dialog_show?e("QuestionListPreview",{attrs:{questionList:t.table_selections_list},on:{onCancel:function(s){t.preview_dialog_show=!1}}}):t._e()],1)},$=[];const I={components:{QuestionClassifySelector:u,QuestionDifficultyLevelSelector:_,DialogLayout:f,QuestionListPreview:p},data:()=>({form:{type:null,difficultyLevel:null,classifyId:null},table_selections_list:[],question_total:0,ranCount:0,preview_dialog_show:!1}),props:{questionType:{default:null,require:!0},oldSelection:{default:[]},excludeIds:{type:Array,default:null}},watch:{form:{deep:!0,immediate:!0,handler(t){this.getCountByType(t)}},questionType:{immediate:!0,handler(t){this.form.type=t}}},created(){this.getCountByType(),this.table_selections_list=this.oldSelection},methods:{onRandConfirm(){this.$emit("current-change",this.table_selections_list)},getRandQuestions(){if(this.ranCount>this.question_total)return this.$message.error("\u62BD\u9898\u6570\u4E0D\u80FD\u6BD4\u603B\u63D0\u6570\u5927");const t={count:this.ranCount,...this.form};this.excludeIds&&(t.excludeIds=this.excludeIds),m(t).then(i=>{this.table_selections_list=i.data})},getCountByType(){!this.form.type||(this.excludeIds&&(this.form.excludeIds=this.excludeIds),parseInt(this.$store.user.baseRole)===3&&(this.form.student=1),g(this.form).then(t=>{this.question_total=t.data}))}}},d={};var T=l(I,q,$,!1,L,"297718f3",null,null);function L(t){for(let i in d)this[i]=d[i]}const k=function(){return T.exports}();var R=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",{directives:[{name:"loading",rawName:"v-loading",value:t.is_loading,expression:"is_loading"}],staticClass:"selector"},[e("div",{staticClass:"gy-table"},[e("table",[t._m(0),t._m(1),e("tbody",t._l(t.table_data,function(s){return e("tr",{key:s.type},[e("td",[t._v(t._s(s.type))]),e("td",[e("el-button",{attrs:{type:"text"},on:{click:function(n){t.current_question_type=s.typeId,t.fixed_questions_show=!0}}},[t._v("\u56FA\u5B9A\u9009\u9898 ")])],1),e("td",[t._v(t._s(s.fixdQuestions.length))]),e("td",[e("el-button",{attrs:{type:"text"},on:{click:function(n){t.current_question_type=s.typeId,t.rand_questions_show=!0}}},[t._v("\u968F\u673A\u9009\u9898 ")])],1),e("td",[t._v(t._s(s.randQuestions.length))]),e("td",[e("el-input-number",{staticStyle:{width:"120px"},attrs:{size:"mini",min:1,label:"\u63CF\u8FF0\u6587\u5B57"},on:{change:function(n,o){typeof n!="number"&&t.$nextTick(function(){s.itemScore=o})}},model:{value:s.itemScore,callback:function(n){t.$set(s,"itemScore",n)},expression:"item.itemScore"}})],1),e("td",[t._v(t._s(s.fixdQuestions.length+s.randQuestions.length))]),e("td",[t._v(" "+t._s((s.fixdQuestions.length+s.randQuestions.length)*s.itemScore)+" ")]),e("td",[e("div",[e("el-button",{staticStyle:{color:"red"},attrs:{type:"text"},on:{click:function(n){return t.deleteThisType(s)}}},[t._v("\u5220\u9664 ")])],1)])])}),0),e("tfoot",[e("tr",{staticClass:"blod"},[e("td",[t._v("\u603B\u5206")]),e("td",{attrs:{colspan:"6"}},[t._v(t._s(t.totalScore))])])])])]),t.fixed_questions_show?e("FixedQuestionSelectTable",{attrs:{questionType:t.current_question_type,oldSelection:t.getOldSelection("fixed"),excludeIds:t.getExclude("fixed")},on:{onCancel:function(s){t.fixed_questions_show=!1},"current-change":t.fixedChange}}):t._e(),t.rand_questions_show?e("RandQuestionSelecter",{attrs:{questionType:t.current_question_type,oldSelection:t.getOldSelection("rand"),excludeIds:t.getExclude("rand")},on:{onCancel:function(s){t.rand_questions_show=!1},"current-change":t.randChange}}):t._e()],1)},F=[function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("thead",[e("tr",{staticClass:"blod"},[e("td",[t._v("\u7EC4\u6210")]),t._v(" "),e("td",{attrs:{colspan:"2"}},[t._v("\u56FA\u5B9A\u9898")]),t._v(" "),e("td",{attrs:{colspan:"2"}},[t._v("\u968F\u673A\u9898")]),t._v(" "),e("td",{attrs:{colspan:"5"}})])])},function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("tr",{staticClass:"blod"},[e("td",[t._v("\u9898\u578B")]),t._v(" "),e("td",[t._v("\u9009\u62E9\u8BD5\u9898")]),t._v(" "),e("td",[t._v("\u8BD5\u9898\u6570")]),t._v(" "),e("td",[t._v("\u9009\u62E9\u8BD5\u9898")]),t._v(" "),e("td",[t._v("\u8BD5\u9898\u6570")]),t._v(" "),e("td",[t._v("\u6BCF\u9898\u5206\u503C")]),t._v(" "),e("td",[t._v("\u603B\u9898\u6570")]),t._v(" "),e("td",[t._v("\u5206\u503C")]),t._v(" "),e("td",{attrs:{rowspan:"4"}},[t._v("\u64CD\u4F5C")])])}];const P={components:{FixedQuestionSelectTable:w,RandQuestionSelecter:k},data:()=>({column:[],table_data:[],is_loading:!1,fixed_questions_show:!1,rand_questions_show:!1,question_type_options:[],current_question_type:null}),props:{questionData:{require:!1,default:null},isMounted:{default:!1}},watch:{table_data:{deep:!0,handler(t){const i=this.dataFormat();this.$emit("current-change",i)}},questionData:{deep:!0,immediate:!0,handler(t){this.questionDataFormat(t)}}},computed:{totalScore(){return this.table_data.length>0?this.table_data.reduce((t,i,e)=>t+(i.fixdQuestions.length+i.randQuestions.length)*i.itemScore,0):0}},mounted(){this.isMounted&&this.getQuestionTypeOptions()},activated(){this.getQuestionTypeOptions()},methods:{deleteThisType(t){t.fixdQuestions=[],t.randQuestions=[]},questionDataFormat(t){t!=null&&Object.keys(t).includes("fixdQuestions")&&(this.table_data=this.question_type_options.map(i=>{const e=t.fixdQuestions.filter(n=>n.typeId===i.id),s=t.randQuestions.filter(n=>n.typeId===i.id);return{type:i.name,typeId:i.id,fixdQuestions:e,randQuestions:s,itemScore:e.length>0?e[0].itemScore:s.length>0?s[0].itemScore:1}}))},dataFormat(){return this.table_data.reduce((i,e,s)=>{let n=e.fixdQuestions,o=e.randQuestions;return n=n.map(a=>({...a,itemScore:e.itemScore})),o=o.map(a=>({...a,itemScore:e.itemScore})),i.fixdQuestions=i.fixdQuestions.concat(n),i.randQuestions=i.randQuestions.concat(o),i.totalScore+=(n.length+o.length)*e.itemScore,i.questionCount+=n.length+o.length,i},{fixdQuestions:[],randQuestions:[],totalScore:0,questionCount:0})},fixedChange(t){const i=this.table_data.find(e=>e.typeId===this.current_question_type);i.fixdQuestions=JSON.parse(JSON.stringify(t)),this.fixed_questions_show=!1},randChange(t){const i=this.table_data.find(e=>e.typeId===this.current_question_type);i.randQuestions=JSON.parse(JSON.stringify(t)),this.rand_questions_show=!1},getOldSelection(t="fixed"){const i=this.table_data.find(e=>e.typeId===this.current_question_type);return t==="fixed"?i.fixdQuestions:i.randQuestions},getExclude(t="fixed"){if(!this.current_question_type)return null;const i=this.table_data.find(e=>e.typeId===this.current_question_type);return t==="fixed"?i.randQuestions.map(e=>e.id):i.fixdQuestions.map(e=>e.id)},getQuestionTypeOptions(){v().then(({data:t})=>{if(this.question_type_options=t,Object.keys(this.questionData).includes("fixdQuestions")){this.questionDataFormat(this.questionData);return}this.table_data=this.question_type_options.map(i=>({type:i.name,typeId:i.id,fixdQuestions:[],randQuestions:[],itemScore:1}))}).catch(t=>{console.info(t)}).finally(t=>{this.is_loading=!1})}}},c={};var D=l(P,R,F,!1,O,"f683b770",null,null);function O(t){for(let i in c)this[i]=c[i]}const U=function(){return D.exports}();export{U as P};
|