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