2 lines
8.2 KiB
JavaScript
2 lines
8.2 KiB
JavaScript
import{u,w as p,r as _}from"./xlsx.db07aefa.js";import{g as f}from"./index.51e15757.js";import{f as b}from"./org.c2b47d31.js";import{f as v}from"./role.e124e505.js";import{f as y,e as L}from"./user.529e3486.js";import{n as x}from"./vueComponentNormalizer.9ef17bb1.js";var C=function(){var e=this,r=e.$createElement,s=e._self._c||r;return s("div",{staticClass:"batch-add-box"},[s("h2",[e._v("\u5BFC\u5165\u4FE1\u606F\u9009\u62E9\uFF1A")]),s("div",{staticClass:"header"},[s("div",{staticClass:"header-body header-body-left"},[s("div",{staticClass:"sel-item"},[s("div",{staticClass:"sel-label"},[e._v("\u89D2\u8272\uFF1A")]),s("el-select",{attrs:{size:"mini",placeholder:"\u8BF7\u9009\u62E9"},model:{value:e.baseForm.role,callback:function(a){e.$set(e.baseForm,"role",a)},expression:"baseForm.role"}},e._l(e.baseData.role,function(a){return s("el-option",{key:a.id,attrs:{placeholder:"\u8BF7\u9009\u62E9\u7528\u6237\u89D2\u8272\uFF01",label:a.name,value:a.id}})}),1)],1),s("div",{staticClass:"sel-item"},[s("div",{staticClass:"sel-label"},[e._v("\u7EC4\u7EC7\u673A\u6784\uFF1A")]),s("el-cascader",{attrs:{options:e.baseData.org,placeholder:"\u8BF7\u9009\u62E9\u7EC4\u7EC7\u673A\u6784\uFF01",size:"mini",props:{checkStrictly:!0,expandTrigger:"hover",label:"name",value:"id"}},model:{value:e.baseForm.org,callback:function(a){e.$set(e.baseForm,"org",a)},expression:"baseForm.org"}})],1),s("div",{staticClass:"sel-item"},[s("div",{staticClass:"sel-label"},[e._v("\u6240\u5C5E\u8001\u5E08\uFF1A")]),s("el-select",{attrs:{size:"mini",multiple:"",filterable:"","reserve-keyword":"",placeholder:"\u8BF7\u9009\u62E9\u7BA1\u8F96\u8001\u5E08\uFF0C\u53EF\u4E3A\u7A7A\uFF01"},model:{value:e.baseForm.manageTeacher,callback:function(a){e.$set(e.baseForm,"manageTeacher",a)},expression:"baseForm.manageTeacher"}},e._l(e.baseData.teacher,function(a){return s("el-option",{key:a.id,attrs:{label:a.name,value:a.id}})}),1)],1),s("div",{staticClass:"sel-item"},[s("el-button",{staticStyle:{padding:"0"},attrs:{round:"",type:"text"},on:{click:e.downloadModelFile}},[e._v("\u4E0B\u8F7D\u6A21\u677F")]),s("div",{staticClass:"gy-label middle",staticStyle:{height:"32px","white-space":"nowrap",color:"#ed0000","line-height":"32px"}},[e._v(" \uFF08\u4E0B\u8F7D\u6A21\u677F\u540E\u6309\u8981\u6C42\u5F55\u5165\u5185\u5BB9\uFF09 ")])],1)]),s("div",{staticClass:"header-body header-body-right"},[!e.successImportList.length&&!e.isLoadAfter?s("el-button",{attrs:{type:"primary"},on:{click:e.toLoadUserExcel}},[e._v("\u5BFC\u5165")]):e._e(),e.successImportList.length&&!e.isLoadAfter?s("el-button",{attrs:{type:"primary"},on:{click:e.uploadUserList}},[e._v(e._s(e.errImportList.length?"\u8FC7\u6EE4\u9519\u8BEF\u5E76\u4E0A\u4F20":"\u4E0A\u4F20")+" ("+e._s(e.successImportList.length)+")")]):e._e(),s("el-button",{attrs:{type:"danger"},on:{click:e.clear}},[e._v("\u6E05\u7406")])],1)]),s("div",{staticClass:"content"},[e.errImportList.length===0?s("div",[s("el-empty",{attrs:{description:"\u8BF7\u5148\u5BFC\u5165\u7528\u6237"}},[s("template",{slot:"description"},[e._v(" "+e._s(e.successImportList.length&&e.errImportList.length<=0&&"\u6682\u65E0\u9519\u8BEF\u7528\u6237"||"\u8BF7\u5148\u5BFC\u5165\u7528\u6237\u4FE1\u606F")+" ")])],2)],1):s("ul",{staticClass:"error-info-list"},[e._m(0),s("div",{staticStyle:{"overflow-y":"auto","max-height":"50vh"}},e._l(e.errImportList,function(a,o){return s("li",{key:o,staticClass:"error-item"},[s("div",{staticClass:"column"},[e._v(e._s(a.username||"\u672A\u586B\u5199"))]),s("div",{staticClass:"column"},[e._v(e._s(a.ind))]),s("div",{staticClass:"column"},[e._v(e._s(a.name||"\u3010 \u672A\u586B\u5199 \u3011"))]),s("ul",{staticClass:"column"},[e._v(" "+e._s(a.errMsg)+" ")])])}),0)])])])},F=[function(){var e=this,r=e.$createElement,s=e._self._c||r;return s("li",{staticClass:"error-item header"},[s("div",{staticClass:"column"},[e._v("\u7528\u6237\u540D")]),s("div",{staticClass:"column"},[e._v("\u884C\u53F7")]),s("div",{staticClass:"column"},[e._v("\u59D3\u540D")]),s("div",{staticClass:"column"},[e._v("\u9519\u8BEF\u4FE1\u606F")])])}];const w={data(){return{baseForm:{org:null,role:null,manageTeacher:null},baseData:{org:null,role:null,teacher:null},importUserList:[],errImportList:[],successImportList:[],isLoadAfter:!1}},activated(){this.findAllRole(),this.findAllOrg(),this.findAllTeacher()},methods:{downloadModelFile(){const e=[{sheetName:"\u6DFB\u52A0\u7528\u6237",data:[["\u7528\u6237\u540D(\u767B\u5F55ID)","\u59D3\u540D","\u6027\u522B","\u51FA\u751F\u5E74\u6708","\u8EAB\u4EFD\u8BC1\u53F7","\u804C\u4F4D","\u7535\u8BDD","\u90AE\u7BB1"],["wcc123","\u738B\u4FC3\u6210-\u793A\u4F8B\uFF08\u4E0A\u4F20\u524D\u8BF7\u5220\u9664\uFF09","\u7537","1998.9.10","610100199809012043","\u5B66\u5458","17688786352","17688786352@163.com"]]}],r=[];e.forEach(a=>{const o=[],l=a.data;l.forEach((n,c)=>{n.forEach((d,i)=>{o[i]==null&&(o[i]=[]),o[i].push(this.getCellWidth(d))})});const h=u.aoa_to_sheet(l);h["!cols"]=[],o.forEach((n,c)=>{h["!cols"].push({wch:Math.max(...n)})}),r.push({name:a.sheetName,ws:h})});const s=u.book_new();r.forEach(a=>{u.book_append_sheet(s,a.ws,a.name)}),p(s,`\u7528\u6237\u5BFC\u5165\u6A21\u677F${new Date().format("yyyy-MM-dd hh-mm-ss")}.xlsx`)},getCellWidth(e){if(e==null)return 10;if(/.*[\u4e00-\u9fa5]+.*$/.test(e)){const r=e.match(/[\u4e00-\u9fa5]/g).length,s=e.length-r;return r*2.1+s*1.1}else return e.toString().length*1.1},async findAllRole(){const{data:e}=await v(),{tree:r}=e.toTree();this.baseData.role=r},async findAllOrg(){const{data:e}=await b(),{tree:r}=e.toTree();this.baseData.org=r,console.log(this.baseData)},async findAllTeacher(){const{data:e}=await y();this.baseData.teacher=e},async toLoadUserExcel(){if(!this.baseForm.org||this.baseForm.org.length<1||!this.baseForm.role){this.$message.error("\u8BF7\u5148\u9009\u62E9\u7528\u6237\u89D2\u8272\u3001\u7EC4\u7EC7\u673A\u6784\u3001\u6240\u5C5E\u8001\u5E08\u4FE1\u606F\u540E\u518D\u9009\u62E9");return}const[e]=await f({accepts:["xlsx"]});/^.+\.xlsx$/.test(e.name)||this.$message.error(new Error("\u4E0D\u662FExcel\u8868\u683C\u6587\u4EF6"));const r=new FileReader;r.onload=s=>{const a=s.target.result,o=_(a,{type:"binary"});console.log(o);const l=u.sheet_to_json(o.Sheets[o.SheetNames[0]]),h=l,n={},c=[],d=[],i=[];console.log(l),h.forEach(t=>{i.push({username:t["\u7528\u6237\u540D(\u767B\u5F55ID)"],name:t.\u59D3\u540D,sex:t.\u6027\u522B,birthday:t.\u51FA\u751F\u5E74\u6708,idcard:t.\u8EAB\u4EFD\u8BC1\u53F7,identity:t.\u804C\u4F4D,phone:t.\u7535\u8BDD,email:t.\u90AE\u7BB1})}),i.forEach((t,g)=>{t.ind=g+2,(!t.name||!t.sex||!t.username)&&(t.errMsg=["\u7F3A\u5C11\u7528\u6237\u4FE1\u606F\u5FC5\u586B\u9879\uFF01"],c.push(t)),t.username&&n[t.username]?t.errMsg?t.errMsg.push("\u7528\u6237ID\u91CD\u590D"):t.errMsg=["\u7528\u6237ID\u91CD\u590D"]:n[t.username]=t,t.errMsg||(t.sex==="\u7537"?t.sex=1:t.sex=0,t.roleId=this.baseForm.role,t.orgId=this.baseForm.org[0],t.orgIds=this.baseForm.org.join(","),t.manageTeacher=this.baseForm.manageTeacher,t.birthday&&(t.birthday=new Date(t.birthday)),d.push(t)),console.log(t)}),console.log(c),this.errImportList=c,this.importUserList=i,this.successImportList=d,c.length||this.uploadUserList()},r.readAsBinaryString(e)},async uploadUserList(){(!this.baseForm.org||this.baseForm.org.length<1||!this.baseForm.role)&&this.$message.error("\u8BF7\u5148\u9009\u62E9\u7528\u6237\u89D2\u8272\u3001\u7EC4\u7EC7\u673A\u6784\u3001\u6240\u5C5E\u8001\u5E08\u4FE1\u606F\u540E\u518D\u63D0\u4EA4");const e=this.errImportList.length,r=this.successImportList.length,s=[`\u6587\u4EF6\u4E2D\u5171\u5305\u542B ${e+r} \u4F4D\u7528\u6237,`,e?`\uFF0C\u5176\u4E2D ${e} \u4F4D\u586B\u5199\u4E0D\u7B26\u5408\u89C4\u8303,`:"",`\u672C\u6B21\u5C06\u5BFC\u5165 ${r} \u4F4D\u7528\u6237\uFF0C\u786E\u8BA4\u5BFC\u5165\u5417\uFF1F`];this.$confirm(s.join(""),"\u63D0\u793A",{type:"warn"}).then(async a=>{const{data:o}=await L(this.successImportList);console.log(o,"aaaaaaaaaa"),this.$message.warning(`\u672C\u6B21\u6210\u529F\u4E0A\u4F20${o.sucList.length}\u4E2A\u7528\u6237,\u5931\u8D25${o.errList.length}\u4E2A\uFF01`),this.errImportList=o.errList.map(l=>({...l,errMsg:l.errMsg})),this.isLoadAfter=!0}).catch(a=>{console.log(a)})},clear(){this.errImportList=[],this.importUserList=[],this.successImportList=[],this.isLoadAfter=!1,this.baseForm={org:null,role:null,manageTeacher:null}}}},m={};var I=x(w,C,F,!1,A,"36a371c7",null,null);function A(e){for(let r in m)this[r]=m[r]}const S=function(){return I.exports}();export{S as default};
|