(window.webpackJsonp=window.webpackJsonp||[]).push([[336],{MpZi:function(t,s,e){"use strict";e.r(s);var i={data:function(){return{isUploadDisabled:!1,progress:0,file:"",items:[],isUploaded:!1,columns:[],uuid:"",options:[]}},mounted:function(){},directives:{uploader:{bind:function(t,s,e){t.addEventListener("change",(function(t){e.context.file=t.target.files[0]}))}}},watch:{file:function(t){var s=this;if("csv"!=t.name.substr(t.name.lastIndexOf(".")+1))toastr.error(i18n.general.file_not_allowed),this.isUploadDisabled=!1;else if(t.size>helper.getConfig("post_max_size"))toastr.error(i18n.general.file_too_large),this.isUploadDisabled=!1;else{var e=new FormData;e.append("file",t),axios.post("/api/student/import/start",e).then((function(t){s.isUploaded=!0,s.items=t.items,s.uuid=t.uuid,s.options=t.options,s.options.forEach((function(t,e){s.columns.push({name:t.value})}))})).catch((function(t){413==t.response.status?toastr.error(i18n.general.file_too_large):helper.showErrorMsg(t),s.progress=0,s.isUploadDisabled=!1})),this.$refs.file.value=""}}},methods:{launchFilePicker:function(){this.isUploadDisabled=!0,this.$refs.file.click()},submit:function(){var t=this,s=this.$loading.show();axios.post("/api/student/import/finish",{uuid:this.uuid,columns:this.columns}).then((function(e){s.hide(),toastr.success(e.message),t.$router.push("/student/list")})).catch((function(t){s.hide(),helper.showErrorMsg(t)}))}},computed:{getSession:function(){return helper.getDefaultAcademicSession().name}}},n=e("KHd+"),a=Object(n.a)(i,(function(){var t=this,s=t.$createElement,e=t._self._c||s;return e("div",[e("div",{staticClass:"page-titles"},[e("div",{staticClass:"row"},[e("div",{staticClass:"col-12 col-sm-6"},[e("h3",{staticClass:"text-themecolor"},[t._v(t._s(t.trans("student.import"))+" ("+t._s(t.getSession)+")")])]),t._v(" "),t._m(0)])]),t._v(" "),e("div",{staticClass:"container-fluid"},[e("div",{staticClass:"card"},[e("div",{staticClass:"card-body"},[e("div",{staticClass:"p-4"},[e("show-tip",{attrs:{module:"student",tip:"import_tip"}})],1),t._v(" "),t.items.length?t._e():e("div",{staticClass:"p-4 d-flex justify-content-center"},[e("button",{staticClass:"btn btn-lg btn-info",attrs:{type:"button",disabled:t.isUploadDisabled},on:{click:t.launchFilePicker}},[e("i",{staticClass:"fas fa-upload"}),t._v(" "+t._s(t.trans("general.upload")))]),t._v(" "),e("input",{directives:[{name:"uploader",rawName:"v-uploader"}],ref:"file",staticStyle:{display:"none"},attrs:{type:"file"}})]),t._v(" "),t.items.length?[e("div",{staticClass:"table-responsive"},[e("table",{staticClass:"table table-sm"},[e("thead",[e("tr",t._l(t.columns,(function(s,i){return e("th",[t._v(t._s(t.trans("general.column_number",{number:i+1})))])})),0)]),t._v(" "),e("tbody",t._l(t.items,(function(s){return e("tr",t._l(s,(function(s){return e("td",{domProps:{textContent:t._s(s)}})})),0)})),0)])]),t._v(" "),e("div",{staticClass:"p-4"},[e("h4",{staticClass:"card-title"},[t._v(t._s(t.trans("student.column_selector")))]),t._v(" "),e("div",{staticClass:"row"},t._l(t.columns,(function(s,i){return e("div",{staticClass:"col-12 col-sm-3"},[e("div",{staticClass:"form-group"},[e("label",{attrs:{for:""}},[t._v(t._s(t.trans("general.column_number",{number:i+1})))]),t._v(" "),e("select",{directives:[{name:"model",rawName:"v-model",value:s.name,expression:"column.name"}],staticClass:"custom-select col-12",attrs:{name:"columns"},on:{change:function(e){var i=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(s,"name",e.target.multiple?i:i[0])}}},[e("option",{attrs:{value:"null"}},[t._v(t._s(t.trans("general.select_one")))]),t._v(" "),t._l(t.options,(function(s){return e("option",{domProps:{value:s.value}},[t._v("\n    \t\t                                "+t._s(s.text)+"\n    \t\t                              ")])}))],2)])])})),0),t._v(" "),e("button",{staticClass:"btn btn-info",attrs:{type:"button"},on:{click:t.submit}},[t._v(t._s(t.trans("general.submit")))])])]:t._e()],2)])])])}),[function(){var t=this.$createElement,s=this._self._c||t;return s("div",{staticClass:"col-12 col-sm-6"},[s("div",{staticClass:"action-buttons pull-right"})])}],!1,null,null,null);s.default=a.exports}}]);
//# sourceMappingURL=index.js.map?id=393ffefc6626b5edca09