1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-14e2798c"],{"18db":function(e,t,r){"use strict";r.r(t);var a=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("a-card",{attrs:{bordered:!1}},[r("div",{staticClass:"table-page-search-wrapper"},[r("a-form",{attrs:{layout:"inline"}},[r("a-row",{attrs:{gutter:48}},[r("a-col",{attrs:{md:4,sm:24}},[r("a-input",{attrs:{placeholder:"请输入用户名"},model:{value:e.queryParam.username,callback:function(t){e.$set(e.queryParam,"username",t)},expression:"queryParam.username"}})],1),r("a-col",{attrs:{md:4,sm:24}},[r("a-input",{attrs:{placeholder:"请输入邮箱"},model:{value:e.queryParam.email,callback:function(t){e.$set(e.queryParam,"email",t)},expression:"queryParam.email"}})],1),r("a-col",{attrs:{md:4,sm:24}},[r("a-select",{attrs:{placeholder:"请选择状态","default-value":"0"},model:{value:e.queryParam.status,callback:function(t){e.$set(e.queryParam,"status",t)},expression:"queryParam.status"}},[r("a-select-option",{attrs:{value:"1"}},[e._v("正常")]),r("a-select-option",{attrs:{value:"2"}},[e._v("禁用")])],1)],1),r("a-col",{attrs:{md:4,sm:24}},[r("span",{staticClass:"table-page-search-submitButtons"},[r("a-button",{attrs:{type:"primary"},on:{click:function(t){return e.$refs.table.refresh(!0)}}},[e._v("查询")]),r("a-button",{staticStyle:{"margin-left":"8px"},on:{click:function(t){return e.resetSearchForm()}}},[e._v("重置")])],1)])],1)],1)],1),r("div",{staticClass:"table-operator"},[r("a-button",{attrs:{type:"primary",icon:"plus"},on:{click:function(t){return e.$refs.userModal.add()}}},[e._v("新建")]),e.selectedRowKeys.length>0?r("a-dropdown",{directives:[{name:"action",rawName:"v-action:edit",arg:"edit"}]},[r("a-menu",{attrs:{slot:"overlay"},slot:"overlay"},[r("a-menu-item",{on:{click:function(t){return e.multiDel()}}},[r("a-icon",{attrs:{type:"delete"}}),e._v("删除")],1),r("a-menu-item",{on:{click:function(t){return e.multiAble()}}},[r("a-icon",{attrs:{type:"lock"}}),e._v("启用/禁用")],1)],1),r("a-button",{staticStyle:{"margin-left":"8px"}},[e._v(" 批量操作 "),r("a-icon",{attrs:{type:"down"}})],1)],1):e._e()],1),r("s-table",{ref:"table",attrs:{size:"default",rowKey:"id",bordered:!0,columns:e.columns,data:e.loadData,alert:e.options.alert,rowSelection:e.options.rowSelection,showPagination:"auto"},scopedSlots:e._u([{key:"action",fn:function(t,a){return r("span",{},[[r("a",{on:{click:function(t){return e.handleEdit(a)}}},[e._v("编辑")]),r("a-divider",{attrs:{type:"vertical"}}),r("a",{on:{click:function(t){return e.handleDel(a)}}},[e._v("删除")])]],2)}}])}),r("create-user",{ref:"userModal",on:{ok:e.handleOk}})],1)},n=[],o=(r("a15b"),r("2af9")),s=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("a-modal",{attrs:{title:"新建用户",width:640,visible:e.visible,confirmLoading:e.confirmLoading},on:{ok:e.handleSubmit,cancel:e.handleCancel}},[r("a-spin",{attrs:{spinning:e.confirmLoading}},[r("a-form",{attrs:{form:e.form}},[r("a-form-item",{attrs:{label:"用户名",type:"text",labelCol:e.labelCol,wrapperCol:e.wrapperCol}},[r("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["username",{rules:[{required:!0,min:3,message:"请输入至少3个字符!"}]}],expression:"['username', {rules: [{required: true, min: 3, message: '请输入至少3个字符!'}]}]"}],attrs:{allowClear:""}})],1),r("a-form-item",{attrs:{label:"邮箱",labelCol:e.labelCol,wrapperCol:e.wrapperCol}},[r("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["email",{rules:[{required:!0,validator:e.handleEmail}]}],expression:"['email', {rules: [{ required: true, validator: handleEmail }]}]"}],attrs:{allowClear:""}})],1),r("a-form-item",{attrs:{label:"密码",labelCol:e.labelCol,wrapperCol:e.wrapperCol}},[r("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["password",{rules:[{required:e.required,min:5,message:"请输入密码"}]}],expression:"['password', {rules: [{required: required, min: 5, message: '请输入密码'}]}]"}],attrs:{allowClear:"",allotype:"password"}})],1),r("a-form-item",{attrs:{label:"确认密码",labelCol:e.labelCol,wrapperCol:e.wrapperCol}},[r("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["passwordConfirm",{rules:[{required:e.required,min:5,message:"请确认密码"}]}],expression:"['passwordConfirm', {rules: [{required: required, min: 5, message: '请确认密码'}]}]"}],attrs:{allowClear:"",type:"password"}})],1),r("a-form-item",{attrs:{label:"选择角色",labelCol:e.labelCol,wrapperCol:e.wrapperCol}},[r("a-tree-select",{directives:[{name:"decorator",rawName:"v-decorator",value:["roles",{initialValue:e.roleids},{rules:[{required:!0,message:"请选择角色"}]}],expression:"['roles', {initialValue: roleids},{rules: [{required: true, message: '请选择角色'}]}]"}],staticStyle:{width:"320px"},attrs:{dropdownStyle:{maxHeight:"400px",overflow:"auto"},treeData:e.roles,placeholder:"请选择角色",allowClear:"",treeCheckable:"",treeDefaultExpandAll:"",showCheckedStrategy:e.SHOW_PARENT},on:{change:e.onChange}})],1)],1)],1)],1)},i=[],l=(r("d81d"),r("98a7"),r("7bec"));function u(e){var t=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;return t.test(e)}var c=r("b775");function d(e){return Object(c["b"])({url:"/users",method:"get",params:e})}function m(e){return Object(c["b"])({url:"/users",method:"post",data:e})}function f(e){return Object(c["b"])({url:"/users/"+e,method:"get"})}function h(e,t){return Object(c["b"])({url:"/users/"+e,method:"put",data:t})}function p(e){return Object(c["b"])({url:"/users/"+e,method:"delete"})}function b(e){return Object(c["b"])({url:"/users/switch/status/"+e,method:"put"})}var v=r("cc5e"),w=r("88bc"),g=r.n(w),y=l["a"].SHOW_PARENT,C={data:function(){return{labelCol:{xs:{span:24},sm:{span:7}},wrapperCol:{xs:{span:24},sm:{span:13}},visible:!1,confirmLoading:!1,id:null,form:this.$form.createForm(this),roles:[],defaultRoles:[],roleids:[],SHOW_PARENT:y,required:!0}},methods:{add:function(){this.visible=!0,this.getRoles()},edit:function(e){this.visible=!0,this.required=!1,this.id=e.id,this.getRoles(),this.getUser(this.id);var t=this.form.setFieldsValue;t(g()(e,["username","email"]))},handleEmail:function(e,t,r){u(t)||r(new Error("邮箱地址不正确")),r()},getRoles:function(){var e=this;Object(v["b"])().then((function(t){e.roles=e.resetRoles(t.data)}))},getUser:function(e){var t=this;f(e).then((function(e){var r=e.data.roles;r.map((function(e){t.roleids.push(e.id),t.defaultRoles.push(e.role_name)}))}))},resetRoles:function(e){var t=this;return e.map((function(e){e.title=e.role_name,e.value=e.id,e.children&&t.resetRoles(e.children)})),e},handleSubmit:function(){var e=this,t=this.form.validateFields;this.id?t(["username","email","roles"],(function(t,r){t||(e.confirmLoading=!0,r["roles"]=e.roleids,h(e.id,r).then((function(t){e.refresh(t.message)})).catch((function(t){return e.failed(t)})))})):t((function(t,r){t||(e.confirmLoading=!0,m(r).then((function(t){e.refresh(t.message)})).catch((function(t){return e.failed(t)})))}))},failed:function(e){this.$notification["error"]({message:e.message,duration:4}),this.handleCancel()},handleCancel:function(){this.id=null,this.visible=!1,this.required=!0,this.confirmLoading=!1,this.form.resetFields(),this.roleids=[],this.defaultRoles=[],this.roles=[]},refresh:function(e){this.$notification["success"]({message:e,duration:4}),this.handleCancel(),this.$parent.$parent.handleOk()},onChange:function(e,t,r){this.roleids=e}}},O=C,k=r("2877"),x=Object(k["a"])(O,s,i,!1,null,null,null),j=x.exports,q={name:"Users",components:{STable:o["f"],CreateUser:j},data:function(){var e=this;return{queryParam:{},columns:[{title:"用户名",dataIndex:"username"},{title:"邮箱",dataIndex:"email"},{title:"状态",dataIndex:"status",customRender:this.renderStatus},{title:"创建时间",dataIndex:"created_at",sorter:!0},{title:"更新时间",dataIndex:"updated_at",sorter:!0},{title:"操作",dataIndex:"action",width:"150px",scopedSlots:{customRender:"action"}}],loadData:function(t){return d(Object.assign(t,e.queryParam)).then((function(e){return e}))},selectedRowKeys:[],selectedRows:[],options:{alert:{show:!1,clear:function(){e.selectedRowKeys=[]}},rowSelection:{selectedRowKeys:this.selectedRowKeys,onChange:this.onSelectChange}}}},created:function(){},methods:{renderStatus:function(e,t,r){var a=this.$createElement;return 1===e?a("a-button",{attrs:{type:"normal",size:"small"}},["正常"]):a("a-button",{attrs:{type:"danger",size:"small"}},["禁用"])},handleEdit:function(e){this.$refs.userModal.edit(e)},handleDel:function(e){var t=this;this.$confirm({title:"确定删除"+e.username+"吗?",okText:"确定",okType:"danger",cancelText:"取消",onOk:function(){p(e.id).then((function(e){t.$notification["success"]({message:e.message,duration:4}),t.handleOk()}))},onCancel:function(){}})},handleOk:function(){this.$refs.table.refresh(!0)},multiDel:function(){var e=this;this.$confirm({title:"确定批量删除吗?",okText:"确定",okType:"danger",cancelText:"取消",onOk:function(){p(e.selectedRowKeys.join(",")).then((function(t){e.$notification["success"]({message:t.message,duration:4}),e.selectedRowKeys=[],e.handleOk()}))},onCancel:function(){}})},multiAble:function(){var e=this;b(this.selectedRowKeys.join(",")).then((function(t){e.$notification["success"]({message:t.message,duration:4}),e.onSelectChange([],[]),e.handleOk()}))},onSelectChange:function(e,t){this.selectedRowKeys=e,this.selectedRows=t},resetSearchForm:function(){this.queryParam={},this.handleOk()}}},S=q,_=Object(k["a"])(S,a,n,!1,null,null,null);t["default"]=_.exports},"88bc":function(e,t,r){(function(t){var r=1/0,a=9007199254740991,n="[object Arguments]",o="[object Function]",s="[object GeneratorFunction]",i="[object Symbol]",l="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,c=l||u||Function("return this")();function d(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function m(e,t){var r=-1,a=e?e.length:0,n=Array(a);while(++r<a)n[r]=t(e[r],r,e);return n}function f(e,t){var r=-1,a=t.length,n=e.length;while(++r<a)e[n+r]=t[r];return e}var h=Object.prototype,p=h.hasOwnProperty,b=h.toString,v=c.Symbol,w=h.propertyIsEnumerable,g=v?v.isConcatSpreadable:void 0,y=Math.max;function C(e,t,r,a,n){var o=-1,s=e.length;r||(r=j),n||(n=[]);while(++o<s){var i=e[o];t>0&&r(i)?t>1?C(i,t-1,r,a,n):f(n,i):a||(n[n.length]=i)}return n}function O(e,t){return e=Object(e),k(e,t,(function(t,r){return r in e}))}function k(e,t,r){var a=-1,n=t.length,o={};while(++a<n){var s=t[a],i=e[s];r(i,s)&&(o[s]=i)}return o}function x(e,t){return t=y(void 0===t?e.length-1:t,0),function(){var r=arguments,a=-1,n=y(r.length-t,0),o=Array(n);while(++a<n)o[a]=r[t+a];a=-1;var s=Array(t+1);while(++a<t)s[a]=r[a];return s[t]=o,d(e,this,s)}}function j(e){return _(e)||S(e)||!!(g&&e&&e[g])}function q(e){if("string"==typeof e||T(e))return e;var t=e+"";return"0"==t&&1/e==-r?"-0":t}function S(e){return $(e)&&p.call(e,"callee")&&(!w.call(e,"callee")||b.call(e)==n)}var _=Array.isArray;function R(e){return null!=e&&A(e.length)&&!P(e)}function $(e){return K(e)&&R(e)}function P(e){var t=E(e)?b.call(e):"";return t==o||t==s}function A(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=a}function E(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function K(e){return!!e&&"object"==typeof e}function T(e){return"symbol"==typeof e||K(e)&&b.call(e)==i}var F=x((function(e,t){return null==e?{}:O(e,m(C(t,1),q))}));e.exports=F}).call(this,r("c8ba"))},cc5e:function(e,t,r){"use strict";r.d(t,"b",(function(){return n})),r.d(t,"d",(function(){return o})),r.d(t,"c",(function(){return s})),r.d(t,"e",(function(){return i})),r.d(t,"a",(function(){return l}));var a=r("b775");function n(e){return Object(a["b"])({url:"/roles",method:"get",params:e})}function o(e){return Object(a["b"])({url:"/roles",method:"post",data:e})}function s(e){return Object(a["b"])({url:"/roles/"+e,method:"get"})}function i(e,t){return Object(a["b"])({url:"/roles/"+e,method:"put",data:t})}function l(e){return Object(a["b"])({url:"/roles/"+e,method:"delete"})}}}]); |