liuxiaolong
2019-05-06 f99bc8c6a1d10610373738edd7d0aa0181c81d99
1
webpackJsonp([8],{"5j9z":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r("Q32s"),a=r("NYaw"),s=r("qaB4"),o=r("rA5e"),i=r("ziRP");var c={props:{title:{type:String,default:"请选择人员关系"}},data:function(){return{modelList:[],total:0,length:9,currentPage:1,searchValue:"",selected:[],focused:null,dropdownOpened:null}},computed:{orgId:function(){return this.$store.getters.basicUserInfo.orgId}},methods:{showModal:function(){this.$refs.myModalRef.show(),this.getRelation()},hideModal:function(){this.$refs.myModalRef.hide()},getRelation:function(){var e,t=this;return(e=regeneratorRuntime.mark(function e(){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Object(i.m)({orgId:t.orgId,id:1,length:t.length,start:t.length*(t.currentPage-1),type:"",isAll:0,name:t.searchValue});case 2:(r=e.sent)&&(t.modelList=r.data,t.total=r.total);case 4:case"end":return e.stop()}},e,t)}),function(){var t=e.apply(this,arguments);return new Promise(function(e,r){return function n(a,s){try{var o=t[a](s),i=o.value}catch(e){return void r(e)}if(!o.done)return Promise.resolve(i).then(function(e){n("next",e)},function(e){n("throw",e)});e(i)}("next")})})()},changePage:function(e){this.currentPage=e,this.getRelation()},handleSearch:function(){this.currentPage=1,this.getRelation()},toggleSelect:function(e,t){e?this.selected=[t]:this.selected.splice(this.selected.indexOf(t),1)},handleSave:function(){this.$emit("relationData",this.selected),this.selected=[],this.hideModal()}}},l=r("XyMi");var u=function(e){r("6Inw"),r("aIuE")},d=Object(l.a)(c,function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("b-modal",{ref:"myModalRef",attrs:{title:e.title,size:"lg","ok-title":"确定","cancel-title":"取消"},on:{ok:e.handleSave,cancel:e.hideModal}},[r("div",{staticClass:"ml10"},[r("span",[e._v("姓名:")]),e._v(" "),r("b-input",{staticStyle:{width:"200px",display:"inline-block"},attrs:{placeholder:"请输入姓名"},nativeOn:{change:function(t){return e.handleSearch(t)}},model:{value:e.searchValue,callback:function(t){e.searchValue=t},expression:"searchValue"}}),e._v(" "),r("b-btn",{attrs:{variant:"primary"},on:{click:e.handleSearch}},[e._v("\n      搜索\n    ")])],1),e._v(" "),r("div",{staticClass:"row pt-3",staticStyle:{"margin-left":"0","margin-right":"0"}},e._l(e.modelList,function(t){return r("div",{key:t.id,staticClass:"col-md-6 col-xl-4"},[r("b-card",{staticClass:"card-condenced mb-3 person-card overflow-hidden",attrs:{"body-class":"media align-items-center"},on:{click:function(r){e.toggleSelect(r,t)}}},[r("b-check",{staticClass:"file-item-checkbox",attrs:{checked:e.selected.includes(t)},on:{change:function(r){e.toggleSelect(r,t)}}}),e._v(" "),r("httpImg",{staticClass:"max-img",attrs:{src:t.photos,height:"100px"}}),e._v(" "),r("div",{staticClass:"media-body ml-3"},[r("a",{staticClass:"text-dark font-weight-semibold mb-2",attrs:{href:"javascript:void(0)"}},[e._v("\n            "+e._s(t.name)+"\n          ")])])],1)],1)})),e._v(" "),r("div",{staticClass:"fr"},[e.total?r("b-pagination",{staticClass:"ml10",attrs:{size:"md","total-rows":e.total,"per-page":e.length},on:{change:e.changePage},model:{value:e.currentPage,callback:function(t){e.currentPage=t},expression:"currentPage"}}):e._e()],1)])},[],!1,u,null,null).exports,f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};function m(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}function h(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function p(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,r){return function n(a,s){try{var o=t[a](s),i=o.value}catch(e){return void r(e)}if(!o.done)return Promise.resolve(i).then(function(e){n("next",e)},function(e){n("throw",e)});e(i)}("next")})}}var b={props:{title:String,orgId:[String,Number]},data:function(){return{roleList:[],initFileIds:"",fileIds:[],form:{nickname:"",idCard:"",username:"",password:"",phone:"",sex:"1",email:"",headImgUrl:"",confirmPassword:""},optionsSex:[{text:"男",value:"1"},{text:"女",value:"0"}],ischeckUp:!1,saveLoading:!1,fileList:[]}},computed:{headerTitle:function(){return this.$route.query.userId?"编辑用户 -- "+this.$route.query.currentName:"添加用户 -- "+this.$route.query.currentName},userInfo:function(){return this.$store.getters.basicUserInfo},stateUserName:function(){return this.ischeckUp?this.form.username.length>0:null},invalidUserName:function(){return this.ischeckUp?"请输入用户名":""},statePassword:function(){return this.ischeckUp?this.form.password.length>0:null},invalidPassword:function(){return this.ischeckUp?"请输入密码":""},stateConfirmPassword:function(){return this.ischeckUp?this.form.confirmPassword.length>0:null},invalidConfirmPassword:function(){return this.ischeckUp?"请输入确认密码":""},stateNickname:function(){return this.ischeckUp?this.form.nickname.length>0:null},invalidNickname:function(){return this.ischeckUp?"请输入姓名":""},statePhone:function(){return this.ischeckUp?/^1[3-9]\d{9}$/.test(this.form.phone):null},invalidPhone:function(){return this.ischeckUp?"请正确输入手机号":""},stateIdCard:function(){return this.ischeckUp?/^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/.test(this.form.idCard):null},invalidIdCard:function(){return this.ischeckUp?"请正确输入身份证":""}},mounted:function(){this.fetchUserInfo()},methods:{fetchUserInfo:function(){var e=this;return p(regeneratorRuntime.mark(function t(){var r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.$route.query.userId){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,Object(o.a)({orgId:e.$route.query.currentId,id:e.$route.query.userId});case 4:(r=t.sent)&&(Object.keys(e.form).map(function(t){e.form[t]=r[t]}),e.form.password="123456",e.form.confirmPassword="123456");case 6:case"end":return t.stop()}},t,e)}))()},showModel:function(){this.$refs.myModalRef.show(),this.fetchRoleList()},fetchRoleList:function(){var e=this;return p(regeneratorRuntime.mark(function t(){var r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(a.c)({orgId:e.userInfo.orgId});case 2:(r=t.sent)&&r.data&&(e.roleList=r.data);case 4:case"end":return t.stop()}},t,e)}))()},handleConnectUser:function(){this.$refs.personnelFormRelation.showModal()},relationData:function(e){var t=[].concat(h(e))[0];this.form.idCard=t.cardId,this.form.nickname=t.name,this.form.phone=t.phone,this.form.headImgUrl=t.photos,this.form.sex="女"===t.gender?"0":"1"},saveUser:function(){var e=this;return p(regeneratorRuntime.mark(function t(){var r,n,a,s,i,c;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.ischeckUp=!0,e.verifyRequrie()){t.next=4;break}return t.abrupt("return");case 4:if(e.verifyPassword(e.form.password,e.form.confirmPassword)){t.next=8;break}return e.$toast({type:"warning",message:"两次输入密码不一致"}),t.abrupt("return");case 8:if(!e.$route.query.userId){t.next=16;break}return r=e.form,r.confirmPassword,r.password,n=m(r,["confirmPassword","password"]),t.next=12,Object(o.i)(f({orgId:e.$route.query.currentId,id:e.$route.query.userId},n));case 12:(a=t.sent)&&a.success?(e.$toast({type:"success",message:"编辑用户成功"}),e.$router.push({path:"/user",query:{currentId:e.$route.query.currentId}})):e.$toast({type:"warning",message:a.message}),t.next=21;break;case 16:return s=e.form,s.confirmPassword,i=m(s,["confirmPassword"]),t.next=19,Object(o.g)(f({orgId:e.$route.query.currentId,officeId:e.$route.query.officeId},i));case 19:(c=t.sent)&&400===c.code?e.$toast({type:"warning",message:c.message}):(e.$toast({type:"success",message:"添加用户成功"}),e.$router.push({path:"/user",query:{currentId:e.$route.query.currentId}}));case 21:case"end":return t.stop()}},t,e)}))()},verifyPassword:function(e,t){return e===t},verifyRequrie:function(){return this.form.username?this.form.password?this.form.confirmPassword?this.form.nickname?/^1[3-9]\d{9}$/.test(this.form.phone)?!!/^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/.test(this.form.idCard)||(this.$toast({type:"warning",message:"请正确输入身份证号"}),!1):(this.$toast({type:"warning",message:"请正确输入手机号"}),!1):(this.$toast({type:"warning",message:"请输入姓名"}),!1):(this.$toast({type:"warning",message:"请输入确认密码"}),!1):(this.$toast({type:"warning",message:"请输入密码"}),!1):(this.$toast({type:"warning",message:"请输入用户名"}),!1)},addFiles:function(e){var t=e.fileIds,r=e.fileList;this.fileList=[].concat(h(r)),this.fileIds=t,console.log(r,"fileIds"),this.form.headImgUrl=r.length&&r[r.length-1].data.path},handleDelImg:function(){this.form.headImgUrl=""},clearName:function(){console.log("cancel")}},components:{UpLoad:n.a,LaddaBtn:s.a,PersonnelFormRelation:d}};var g=function(e){r("NaYw")},v=Object(l.a)(b,function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",[r("h4",{staticClass:"font-weight-bold py-3 mb-2"},[r("router-link",{attrs:{to:"/user"}},[r("span",{staticClass:"text-muted font-weight-light"},[e._v("用户管理 /")])]),e._v("\n    "+e._s(e.headerTitle)+"\n  ")],1),e._v(" "),r("b-card",{staticClass:"pt30 pl20 pr20 pb30",attrs:{"no-body":""}},[r("div",{staticClass:"btn-content mb10"},[e.$route.query.userId?e._e():r("b-btn",{attrs:{variant:"primary"},on:{click:e.handleConnectUser}},[e._v("\n        关联人员信息\n      ")])],1),e._v(" "),r("b-form",{on:{submit:e.saveUser}},[r("div",{staticClass:"row"},[r("div",{staticClass:"col"},[r("b-form-group",{attrs:{horizontal:"",label:"用户名:","label-cols":4,"label-class":"text-sm-right","label-for":"input_username","invalid-feedback":e.invalidUserName}},[r("b-form-input",{attrs:{autocomplete:"off",required:"",id:"input_username",state:e.stateUserName,placeholder:"请输入用户名"},model:{value:e.form.username,callback:function(t){e.$set(e.form,"username",t)},expression:"form.username"}})],1),e._v(" "),r("b-form-group",{attrs:{horizontal:"",label:"密码:","label-cols":4,"label-for":"input_password","label-class":"text-sm-right","invalid-feedback":e.invalidPassword}},[r("b-form-input",{attrs:{disabled:!!e.$route.query.userId,autocomplete:"off",required:"",id:"input_password",type:"password",state:e.statePassword,placeholder:"请输入密码"},model:{value:e.form.password,callback:function(t){e.$set(e.form,"password",t)},expression:"form.password"}})],1),e._v(" "),r("b-form-group",{attrs:{horizontal:"",label:"确认密码:","label-cols":4,"label-for":"input_confirmPassword","label-class":"text-sm-right","invalid-feedback":e.invalidConfirmPassword}},[r("b-form-input",{attrs:{disabled:!!e.$route.query.userId,autocomplete:"off",required:"",id:"input_confirmPassword",type:"password",state:e.stateConfirmPassword,placeholder:"请输入确认密码"},model:{value:e.form.confirmPassword,callback:function(t){e.$set(e.form,"confirmPassword",t)},expression:"form.confirmPassword"}})],1),e._v(" "),r("b-form-group",{attrs:{horizontal:"","label-cols":4,"label-class":"text-sm-right",label:"姓名:","label-for":"input_nickname","invalid-feedback":e.invalidNickname}},[r("b-form-input",{attrs:{autocomplete:"off",id:"input_nickname",state:e.stateNickname,placeholder:"请输入姓名"},model:{value:e.form.nickname,callback:function(t){e.$set(e.form,"nickname",t)},expression:"form.nickname"}})],1),e._v(" "),r("b-form-group",{attrs:{horizontal:"","label-cols":4,"label-class":"text-sm-right",label:"头像:"}},[e.form.headImgUrl?e._e():r("UpLoad",{attrs:{isShowHr:!1,layout:1,title:"",isList:!1,initFileIds:e.initFileIds},on:{addFilesBaBackFN:e.addFiles}}),e._v(" "),e.form.headImgUrl?r("div",{staticClass:"img-content",on:{click:e.handleDelImg}},[r("span",{staticClass:"ion-md-close"}),e._v(" "),r("httpImg",{attrs:{src:e.form.headImgUrl,alt:"",width:"100%"}})],1):e._e()],1)],1),e._v(" "),r("div",{staticClass:"col"},[r("b-form-group",{attrs:{horizontal:"","label-cols":4,"label-class":"text-sm-right",label:"性别:","label-for":"radios1"}},[r("b-form-radio-group",{attrs:{id:"radios1",options:e.optionsSex,name:"radioOpenions"},model:{value:e.form.sex,callback:function(t){e.$set(e.form,"sex",t)},expression:"form.sex"}})],1),e._v(" "),r("b-form-group",{attrs:{horizontal:"","label-cols":4,label:"电话:","label-class":"text-sm-right","label-for":"input_phone","invalid-feedback":e.invalidPhone}},[r("b-form-input",{attrs:{autocomplete:"off",id:"input_phone",state:e.statePhone,placeholder:"请输入电话"},model:{value:e.form.phone,callback:function(t){e.$set(e.form,"phone",t)},expression:"form.phone"}})],1),e._v(" "),r("b-form-group",{attrs:{horizontal:"","label-cols":4,label:"电子邮件:","label-class":"text-sm-right","label-for":"input_email"}},[r("b-form-input",{attrs:{autocomplete:"off",id:"input_email",placeholder:"请输入电子邮件"},model:{value:e.form.email,callback:function(t){e.$set(e.form,"email",t)},expression:"form.email"}})],1),e._v(" "),r("b-form-group",{attrs:{horizontal:"","label-cols":4,"label-class":"text-sm-right",label:"身份证:","label-for":"input_idCard","invalid-feedback":e.invalidIdCard}},[r("b-form-input",{attrs:{autocomplete:"off",id:"input_idCard",state:e.stateIdCard,placeholder:"请输入身份证"},model:{value:e.form.idCard,callback:function(t){e.$set(e.form,"idCard",t)},expression:"form.idCard"}})],1)],1)]),e._v(" "),r("div",{staticClass:"text-right mt-3"},[r("LaddaBtn",{staticClass:"btn btn-primary",attrs:{loading:e.saveLoading,"data-style":"slide-down"},nativeOn:{click:function(t){return e.saveUser(t)}}},[e._v("\n          保存\n        ")]),e._v("\n         \n        "),r("b-btn",{attrs:{variant:"default"},on:{click:function(t){e.$router.push({path:"/user"})}}},[e._v("返回")])],1)])],1),e._v(" "),r("PersonnelFormRelation",{ref:"personnelFormRelation",attrs:{title:"选择人员"},on:{relationData:e.relationData}})],1)},[],!1,g,"data-v-2557c5fa",null);t.default=v.exports},"6Inw":function(e,t){},NaYw:function(e,t){},aIuE:function(e,t){},rA5e:function(e,t,r){"use strict";r.d(t,"c",function(){return a}),r.d(t,"g",function(){return s}),r.d(t,"h",function(){return o}),r.d(t,"e",function(){return i}),r.d(t,"b",function(){return c}),r.d(t,"i",function(){return l}),r.d(t,"a",function(){return u}),r.d(t,"d",function(){return d}),r.d(t,"f",function(){return f});var n=r("59if"),a=function(e){return Object(n.b)("data/api-u/users",{body:e})},s=function(e){return Object(n.c)("data/api-u/users-anon/register",{body:e})},o=function(e){return Object(n.b)("data/api-u/users-anon/delete",{body:e})},i=function(e){return Object(n.c)("data/api-u/users/setRoleToUser",{body:e})},c=function(e){return Object(n.b)("data/api-u/users/findRolesIdsByUserId",{body:e})},l=function(e){return Object(n.c)("data/api-u/users-anon/update",{body:e})},u=function(e){return Object(n.b)("data/api-u/users/findUserById",{body:e})},d=function(e){return Object(n.b)("data/api-u/users/setPassWord",{body:e})},f=function(e){return Object(n.b)("data/api-u/users/updateOfficeId",{body:e})}}});