xydata-tools 1.0.26 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/components/aaa/setting/permission/index.js +1 -1
- package/dist/components/aaa/setting/requesturl/index.js +1 -1
- package/dist/components/aaa/setting/role/index.js +1 -1
- package/dist/components/aaa/setting/user/index.js +1 -1
- package/dist/components/dictionary/index.js +1 -1
- package/dist/components/organization/index.js +1 -1
- package/dist/components/sso/setting/permission/index.js +1 -1
- package/dist/components/sso/setting/role/index.js +1 -1
- package/dist/components/sso/setting/user/index.js +1 -1
- package/dist/components/uploadFile/index.js +1 -1
- package/package.json +42 -42
package/README.md
CHANGED
|
@@ -72,6 +72,12 @@ const Demo = () => {
|
|
|
72
72
|
return <Form form={form}>
|
|
73
73
|
<UploadFile form={form} name="file" label="图片上传" listType="picture-card" />
|
|
74
74
|
</Form>
|
|
75
|
+
// 在FormList内使用
|
|
76
|
+
<ProFormList {...yourPorps}>
|
|
77
|
+
{(field) => {
|
|
78
|
+
return <UploadFile key={field.key} name={[field.name, "cover"]} />;
|
|
79
|
+
}}
|
|
80
|
+
</ProFormList>
|
|
75
81
|
};
|
|
76
82
|
|
|
77
83
|
export default Demo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=a.call(t)).done)&&(c.push(n.value),c.length!==r);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{s({},"")}catch(e){s=function(e,r,t){return e[r]=t}}function l(e,r,t,n){var a=r&&r.prototype instanceof v?r:v,i=Object.create(a.prototype),c=new R(n||[]);return o(i,"_invoke",{value:O(e,t,c)}),i}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var f="suspendedStart",m="suspendedYield",d="executing",h="completed",y={};function v(){}function g(){}function _(){}var x={};s(x,i,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(E([])));w&&w!==t&&n.call(w,i)&&(x=w);var j=_.prototype=v.prototype=Object.create(x);function T(e){["next","throw","return"].forEach((function(r){s(e,r,(function(e){return this._invoke(r,e)}))}))}function P(e,r){function t(o,a,i,c){var u=p(e[o],e,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,i,c)}),(function(e){t("throw",e,i,c)})):r.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return t("throw",e,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return a=a?a.then(o,o):o()}})}function O(r,t,n){var o=f;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===h){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=S(c,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=p(r,t,n);if("normal"===s.type){if(o=n.done?h:m,s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=h,n.method="throw",n.arg=s.arg)}}}function S(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,S(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(o,r.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,y;var i=a.arg;return i?i.done?(t[r.resultName]=i.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,y):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function k(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function L(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function E(r){if(r||""===r){var t=r[i];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return a.next=a}}throw new TypeError(_typeof(r)+" is not iterable")}return g.prototype=_,o(j,"constructor",{value:_,configurable:!0}),o(_,"constructor",{value:g,configurable:!0}),g.displayName=s(_,u,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,s(e,u,"GeneratorFunction")),e.prototype=Object.create(j),e},r.awrap=function(e){return{__await:e}},T(P.prototype),s(P.prototype,c,(function(){return this})),r.AsyncIterator=P,r.async=function(e,t,n,o,a){void 0===a&&(a=Promise);var i=new P(l(e,t,n,o),a);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},T(j),s(j,u,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=E,R.prototype={constructor:R,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return c.type="throw",c.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),y},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),L(t),y}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;L(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:E(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),y}},r}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function asyncGeneratorStep(e,r,t,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void t(e)}c.done?r(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function i(e){asyncGeneratorStep(a,n,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,n,o,i,c,"throw",e)}i(void 0)}))}}import{ExclamationCircleOutlined,PlusOutlined,SyncOutlined}from"@ant-design/icons";import{Button,Divider,message,Modal,Select}from"antd";import React,{useEffect,useRef,useState}from"react";import Auth from"../../auth";import ProTable from"@ant-design/pro-table";import UpdateForm from"./components/UpdateForm";import{addPerm,assignUri,getPermUris,getUriList,loadPermData,queryPerm,removePerm,updatePerm}from"./service.js";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在添加"),n=!1,e.prev=2,e.next=5,addPerm(_objectSpread({},r));case 5:"000000"===(o=e.sent).rspCode?(message.success("添加成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("添加失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleUpdate=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在更新"),n=!1,e.prev=2,e.next=5,updatePerm({permName:r.permName,permCode:r.permCode,permType:r.permType,moduleName:r.moduleName,id:r.id});case 5:"000000"===(o=e.sent).rspCode?(message.success("更新成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("更新失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在删除"),n=!1,e.prev=2,e.next=5,removePerm(r);case 5:"000000"===(o=e.sent).rspCode?(message.success("删除成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("删除失败,请重试");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),PermList=function(){var e=_slicedToArray(useState(!1),2),r=e[0],t=e[1],n=_slicedToArray(useState(!1),2),o=n[0],a=n[1],i=_slicedToArray(useState(!1),2),c=i[0],u=i[1],s=_slicedToArray(useState([]),2),l=s[0],p=s[1],f=_slicedToArray(useState([]),2),m=f[0],d=f[1],h=_slicedToArray(useState({}),2),y=h[0],v=h[1],g=useRef(),_=[{title:"权限代码",dataIndex:"permCode",rules:[{required:!0,message:"权限代码为必填项"}]},{title:"权限类型",dataIndex:"permType",valueEnum:{url:{text:"URL",permType:"URL"},btn:{text:"BTN",permType:"BTN"},data:{text:"DATA",permType:"DATA"}},fieldProps:{getPopupContainer:function(e){return e.parentNode}}},{title:"权限名称",dataIndex:"permName",valueType:"text"},{title:"模块",dataIndex:"moduleName",valueType:"text"},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,r,t,n){return _jsxs(_Fragment,{children:[_jsxs(Auth,{code:"PERM_EDIT",children:[_jsx("a",{onClick:function(){a(!0),v(r)},children:"编辑"}),_jsx(Divider,{type:"vertical"})]}),_jsx(Auth,{code:"PERM_DEL",children:_jsx("a",{onClick:function(){var e;Modal.confirm({title:"确定删除吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:(e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleRemove(r);case 2:if(!e.sent||!n){e.next=8;break}return e.next=6,n.reset();case 6:return e.next=8,n.reload();case 8:case"end":return e.stop()}}),e)}))),function(){return e.apply(this,arguments)}),onCancel:function(){}})},children:"删除"})}),_jsx(Auth,{code:"PERM_URI",children:"URL"===r.permType?[_jsx(Divider,{type:"vertical"}),_jsx("a",{onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在获取请求信息"),e.prev=1,e.next=4,getPermUris({permId:r.id});case 4:"000000"===(n=e.sent).rspCode?(o=n.data.map((function(e){return e.requestPathId})),p(o),v(r),u(!0)):message.error(n.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("获取权限请求失败");case 11:t();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:"请求"})]:null})]})}}];return useEffect((function(){var e=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,getUriList({});case 3:"000000"===(r=e.sent).rspCode?d(r.data):message.error(r.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("获取请求列表失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();e()}),[]),_jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"权限列表",actionRef:g,rowKey:"id",toolBarRender:function(){return[_jsx(Auth,{code:"PERM_ADD",children:_jsxs(Button,{type:"primary",onClick:function(){return t(!0)},children:[_jsx(PlusOutlined,{})," 新建"]})}),_jsx(Auth,{code:"PERM_LOAD",children:_jsxs(Button,{type:"primary",onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=message.loading("正在刷新权限缓存"),e.prev=1,e.next=4,loadPermData({});case 4:"000000"===(t=e.sent).rspCode?message.success("刷新成功"):message.error(t.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("刷新失败");case 11:r();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:[_jsx(SyncOutlined,{})," 刷新权限缓存"]})})]},beforeSearchSubmit:function(e){return _objectSpread(_objectSpread({},e),{},{searchObject:{permCode:e.permCode,permName:e.permName,permType:e.permType,moduleName:e.moduleName}})},params:{},request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryPerm(r);case 2:return t=e.sent,e.abrupt("return",t.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),columns:_,rowSelection:!1}),r?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleAdd(r);case 2:if(!e.sent){e.next=10;break}if(t(!1),!g.current){e.next=10;break}return e.next=8,g.current.reset();case 8:return e.next=10,g.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){t(!1)},type:"C",updateModalVisible:r,values:{}}):null,o?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleUpdate(r);case 2:if(!e.sent){e.next=10;break}if(a(!1),!g.current){e.next=10;break}return e.next=8,g.current.reset();case 8:return e.next=10,g.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){a(!1)},type:"U",updateModalVisible:o,values:y}):null,c?_jsx(Modal,{title:"设置请求",open:c,onCancel:function(){u(!1)},onOk:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=message.loading("正在设置请求信息"),e.prev=1,e.next=4,assignUri({permId:y.id,uriIds:l.join()});case 4:"000000"===(t=e.sent).rspCode?(message.success("设置成功"),u(!1)):message.error(t.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("设置请求失败");case 11:r();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:_jsx(Select,{value:l,onChange:function(e){p(e)},mode:"multiple",style:{width:"100%"},children:m.map((function(e){return _jsx(Select.Option,{value:e.id,children:e.description},e.id)}))})}):null]})};export default PermList;
|
|
1
|
+
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=a.call(t)).done)&&(c.push(n.value),c.length!==r);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{s({},"")}catch(e){s=function(e,r,t){return e[r]=t}}function l(e,r,t,n){var a=r&&r.prototype instanceof v?r:v,i=Object.create(a.prototype),c=new R(n||[]);return o(i,"_invoke",{value:O(e,t,c)}),i}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var f="suspendedStart",m="suspendedYield",d="executing",h="completed",y={};function v(){}function g(){}function _(){}var x={};s(x,i,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(E([])));w&&w!==t&&n.call(w,i)&&(x=w);var j=_.prototype=v.prototype=Object.create(x);function T(e){["next","throw","return"].forEach((function(r){s(e,r,(function(e){return this._invoke(r,e)}))}))}function P(e,r){function t(o,a,i,c){var u=p(e[o],e,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,i,c)}),(function(e){t("throw",e,i,c)})):r.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return t("throw",e,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return a=a?a.then(o,o):o()}})}function O(r,t,n){var o=f;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===h){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=S(c,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=p(r,t,n);if("normal"===s.type){if(o=n.done?h:m,s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=h,n.method="throw",n.arg=s.arg)}}}function S(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,S(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(o,r.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,y;var i=a.arg;return i?i.done?(t[r.resultName]=i.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,y):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function k(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function L(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function E(r){if(r||""===r){var t=r[i];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return a.next=a}}throw new TypeError(_typeof(r)+" is not iterable")}return g.prototype=_,o(j,"constructor",{value:_,configurable:!0}),o(_,"constructor",{value:g,configurable:!0}),g.displayName=s(_,u,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,s(e,u,"GeneratorFunction")),e.prototype=Object.create(j),e},r.awrap=function(e){return{__await:e}},T(P.prototype),s(P.prototype,c,(function(){return this})),r.AsyncIterator=P,r.async=function(e,t,n,o,a){void 0===a&&(a=Promise);var i=new P(l(e,t,n,o),a);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},T(j),s(j,u,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=E,R.prototype={constructor:R,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return c.type="throw",c.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),y},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),L(t),y}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;L(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:E(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),y}},r}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function asyncGeneratorStep(e,r,t,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void t(e)}c.done?r(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function i(e){asyncGeneratorStep(a,n,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,n,o,i,c,"throw",e)}i(void 0)}))}}import{ExclamationCircleOutlined,PlusOutlined,SyncOutlined}from"@ant-design/icons";import{Button,Divider,message,Modal,Select}from"antd";import React,{useEffect,useRef,useState}from"react";import{ProTable}from"@ant-design/pro-components";import Auth from"../../auth";import UpdateForm from"./components/UpdateForm";import{addPerm,assignUri,getPermUris,getUriList,loadPermData,queryPerm,removePerm,updatePerm}from"./service.js";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在添加"),n=!1,e.prev=2,e.next=5,addPerm(_objectSpread({},r));case 5:"000000"===(o=e.sent).rspCode?(message.success("添加成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("添加失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleUpdate=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在更新"),n=!1,e.prev=2,e.next=5,updatePerm({permName:r.permName,permCode:r.permCode,permType:r.permType,moduleName:r.moduleName,id:r.id});case 5:"000000"===(o=e.sent).rspCode?(message.success("更新成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("更新失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在删除"),n=!1,e.prev=2,e.next=5,removePerm(r);case 5:"000000"===(o=e.sent).rspCode?(message.success("删除成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("删除失败,请重试");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),PermList=function(){var e=_slicedToArray(useState(!1),2),r=e[0],t=e[1],n=_slicedToArray(useState(!1),2),o=n[0],a=n[1],i=_slicedToArray(useState(!1),2),c=i[0],u=i[1],s=_slicedToArray(useState([]),2),l=s[0],p=s[1],f=_slicedToArray(useState([]),2),m=f[0],d=f[1],h=_slicedToArray(useState({}),2),y=h[0],v=h[1],g=useRef(),_=[{title:"权限代码",dataIndex:"permCode",rules:[{required:!0,message:"权限代码为必填项"}]},{title:"权限类型",dataIndex:"permType",valueEnum:{url:{text:"URL",permType:"URL"},btn:{text:"BTN",permType:"BTN"},data:{text:"DATA",permType:"DATA"}},fieldProps:{getPopupContainer:function(e){return e.parentNode}}},{title:"权限名称",dataIndex:"permName",valueType:"text"},{title:"模块",dataIndex:"moduleName",valueType:"text"},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,r,t,n){return _jsxs(_Fragment,{children:[_jsxs(Auth,{code:"PERM_EDIT",children:[_jsx("a",{onClick:function(){a(!0),v(r)},children:"编辑"}),_jsx(Divider,{type:"vertical"})]}),_jsx(Auth,{code:"PERM_DEL",children:_jsx("a",{onClick:function(){var e;Modal.confirm({title:"确定删除吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:(e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleRemove(r);case 2:if(!e.sent||!n){e.next=8;break}return e.next=6,n.reset();case 6:return e.next=8,n.reload();case 8:case"end":return e.stop()}}),e)}))),function(){return e.apply(this,arguments)}),onCancel:function(){}})},children:"删除"})}),_jsx(Auth,{code:"PERM_URI",children:"URL"===r.permType?[_jsx(Divider,{type:"vertical"}),_jsx("a",{onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在获取请求信息"),e.prev=1,e.next=4,getPermUris({permId:r.id});case 4:"000000"===(n=e.sent).rspCode?(o=n.data.map((function(e){return e.requestPathId})),p(o),v(r),u(!0)):message.error(n.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("获取权限请求失败");case 11:t();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:"请求"})]:null})]})}}];return useEffect((function(){var e=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,getUriList({});case 3:"000000"===(r=e.sent).rspCode?d(r.data):message.error(r.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("获取请求列表失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();e()}),[]),_jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"权限列表",actionRef:g,rowKey:"id",toolBarRender:function(){return[_jsx(Auth,{code:"PERM_ADD",children:_jsxs(Button,{type:"primary",onClick:function(){return t(!0)},children:[_jsx(PlusOutlined,{})," 新建"]})}),_jsx(Auth,{code:"PERM_LOAD",children:_jsxs(Button,{type:"primary",onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=message.loading("正在刷新权限缓存"),e.prev=1,e.next=4,loadPermData({});case 4:"000000"===(t=e.sent).rspCode?message.success("刷新成功"):message.error(t.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("刷新失败");case 11:r();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:[_jsx(SyncOutlined,{})," 刷新权限缓存"]})})]},beforeSearchSubmit:function(e){return _objectSpread(_objectSpread({},e),{},{searchObject:{permCode:e.permCode,permName:e.permName,permType:e.permType,moduleName:e.moduleName}})},params:{},request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryPerm(r);case 2:return t=e.sent,e.abrupt("return",t.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),columns:_,rowSelection:!1}),r?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleAdd(r);case 2:if(!e.sent){e.next=10;break}if(t(!1),!g.current){e.next=10;break}return e.next=8,g.current.reset();case 8:return e.next=10,g.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){t(!1)},type:"C",updateModalVisible:r,values:{}}):null,o?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleUpdate(r);case 2:if(!e.sent){e.next=10;break}if(a(!1),!g.current){e.next=10;break}return e.next=8,g.current.reset();case 8:return e.next=10,g.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){a(!1)},type:"U",updateModalVisible:o,values:y}):null,c?_jsx(Modal,{title:"设置请求",open:c,onCancel:function(){u(!1)},onOk:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=message.loading("正在设置请求信息"),e.prev=1,e.next=4,assignUri({permId:y.id,uriIds:l.join()});case 4:"000000"===(t=e.sent).rspCode?(message.success("设置成功"),u(!1)):message.error(t.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("设置请求失败");case 11:r();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:_jsx(Select,{value:l,onChange:function(e){p(e)},mode:"multiple",style:{width:"100%"},children:m.map((function(e){return _jsx(Select.Option,{value:e.id,children:e.description},e.id)}))})}):null]})};export default PermList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],c=!0,s=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(s)throw o}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function s(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{s({},"")}catch(e){s=function(e,r,t){return e[r]=t}}function l(e,r,t,n){var a=r&&r.prototype instanceof v?r:v,i=Object.create(a.prototype),u=new E(n||[]);return o(i,"_invoke",{value:L(e,t,u)}),i}function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var p="suspendedStart",h="suspendedYield",y="executing",d="completed",m={};function v(){}function g(){}function b(){}var _={};s(_,i,(function(){return this}));var x=Object.getPrototypeOf,w=x&&x(x(P([])));w&&w!==t&&n.call(w,i)&&(_=w);var j=b.prototype=v.prototype=Object.create(_);function O(e){["next","throw","return"].forEach((function(r){s(e,r,(function(e){return this._invoke(r,e)}))}))}function S(e,r){function t(o,a,i,u){var c=f(e[o],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,i,u)}),(function(e){t("throw",e,i,u)})):r.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return t("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return a=a?a.then(o,o):o()}})}function L(r,t,n){var o=p;return function(a,i){if(o===y)throw new Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=R(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=f(r,t,n);if("normal"===s.type){if(o=n.done?d:h,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function R(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,R(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=f(o,r.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,m;var i=a.arg;return i?i.done?(t[r.resultName]=i.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,m):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function T(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function k(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function P(r){if(r||""===r){var t=r[i];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return a.next=a}}throw new TypeError(_typeof(r)+" is not iterable")}return g.prototype=b,o(j,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,c,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,c,"GeneratorFunction")),e.prototype=Object.create(j),e},r.awrap=function(e){return{__await:e}},O(S.prototype),s(S.prototype,u,(function(){return this})),r.AsyncIterator=S,r.async=function(e,t,n,o,a){void 0===a&&(a=Promise);var i=new S(l(e,t,n,o),a);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(j),s(j,c,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=P,E.prototype={constructor:E,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return u.type="throw",u.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),k(t),m}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;k(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:P(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),m}},r}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function asyncGeneratorStep(e,r,t,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void t(e)}u.done?r(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function i(e){asyncGeneratorStep(a,n,o,i,u,"next",e)}function u(e){asyncGeneratorStep(a,n,o,i,u,"throw",e)}i(void 0)}))}}import{PlusOutlined,ExclamationCircleOutlined}from"@ant-design/icons";import{Button,Divider,message,Modal}from"antd";import React,{useState,useRef}from"react";import ProTable from"@ant-design/pro-table";import Auth from"../../auth";import UpdateForm from"./components/UpdateForm";import{queryUri,updateUri,addUri,removeUri}from"./service.js";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在添加"),n=!1,e.prev=2,e.next=5,addUri(_objectSpread({},r));case 5:"000000"===(o=e.sent).rspCode?(message.success("添加成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("添加失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleUpdate=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在更新"),n=!1,e.prev=2,e.next=5,updateUri({url:r.url,description:r.description,id:r.id});case 5:"000000"===(o=e.sent).rspCode?(message.success("更新成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("更新失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在删除"),n=!1,e.prev=2,e.next=5,removeUri(r);case 5:"000000"===(o=e.sent).rspCode?(message.success("删除成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("删除失败,请重试");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),RequestUriList=function(){var e=_slicedToArray(useState(!1),2),r=e[0],t=e[1],n=_slicedToArray(useState(!1),2),o=n[0],a=n[1],i=_slicedToArray(useState({}),2),u=i[0],c=i[1],s=useRef(),l=[{title:"URI",dataIndex:"url",rules:[{required:!0,message:"URI为必填项"}]},{title:"描述",dataIndex:"description"},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,r,t,n){return _jsxs(_Fragment,{children:[_jsxs(Auth,{code:"URI_EDIT",children:[_jsx("a",{onClick:function(){a(!0),c(r)},children:"编辑"}),_jsx(Divider,{type:"vertical"})]}),_jsx(Auth,{code:"URI_DEL",children:_jsx("a",{onClick:function(){var e;Modal.confirm({title:"确定删除吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:(e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleRemove(r);case 2:if(!e.sent||!n){e.next=8;break}return e.next=6,n.reset();case 6:return e.next=8,n.reload();case 8:case"end":return e.stop()}}),e)}))),function(){return e.apply(this,arguments)}),onCancel:function(){}})},children:"删除"})})]})}}];return _jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"URI列表",actionRef:s,rowKey:"id",toolBarRender:function(){return[_jsx(Auth,{code:"URI_ADD",children:_jsxs(Button,{type:"primary",onClick:function(){return t(!0)},children:[_jsx(PlusOutlined,{})," 新建"]})})]},beforeSearchSubmit:function(e){return _objectSpread(_objectSpread({},e),{},{searchObject:{url:e.url,description:e.description}})},params:{},request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryUri(r);case 2:return t=e.sent,e.abrupt("return",t.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),columns:l,rowSelection:!1}),r?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleAdd(r);case 2:if(!e.sent){e.next=10;break}if(t(!1),!s.current){e.next=10;break}return e.next=8,s.current.reset();case 8:return e.next=10,s.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){t(!1)},type:"C",updateModalVisible:r,values:{}}):null,o?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleUpdate(r);case 2:if(!e.sent){e.next=10;break}if(a(!1),!s.current){e.next=10;break}return e.next=8,s.current.reset();case 8:return e.next=10,s.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){a(!1)},type:"U",updateModalVisible:o,values:u}):null]})};export default RequestUriList;
|
|
1
|
+
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],c=!0,s=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(s)throw o}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function s(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{s({},"")}catch(e){s=function(e,r,t){return e[r]=t}}function l(e,r,t,n){var a=r&&r.prototype instanceof v?r:v,i=Object.create(a.prototype),u=new E(n||[]);return o(i,"_invoke",{value:L(e,t,u)}),i}function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var p="suspendedStart",h="suspendedYield",y="executing",d="completed",m={};function v(){}function g(){}function b(){}var _={};s(_,i,(function(){return this}));var x=Object.getPrototypeOf,w=x&&x(x(P([])));w&&w!==t&&n.call(w,i)&&(_=w);var j=b.prototype=v.prototype=Object.create(_);function O(e){["next","throw","return"].forEach((function(r){s(e,r,(function(e){return this._invoke(r,e)}))}))}function S(e,r){function t(o,a,i,u){var c=f(e[o],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,i,u)}),(function(e){t("throw",e,i,u)})):r.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return t("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return a=a?a.then(o,o):o()}})}function L(r,t,n){var o=p;return function(a,i){if(o===y)throw new Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=R(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=f(r,t,n);if("normal"===s.type){if(o=n.done?d:h,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function R(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,R(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=f(o,r.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,m;var i=a.arg;return i?i.done?(t[r.resultName]=i.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,m):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function T(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function k(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function P(r){if(r||""===r){var t=r[i];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return a.next=a}}throw new TypeError(_typeof(r)+" is not iterable")}return g.prototype=b,o(j,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,c,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,c,"GeneratorFunction")),e.prototype=Object.create(j),e},r.awrap=function(e){return{__await:e}},O(S.prototype),s(S.prototype,u,(function(){return this})),r.AsyncIterator=S,r.async=function(e,t,n,o,a){void 0===a&&(a=Promise);var i=new S(l(e,t,n,o),a);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(j),s(j,c,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=P,E.prototype={constructor:E,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return u.type="throw",u.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),k(t),m}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;k(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:P(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),m}},r}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function asyncGeneratorStep(e,r,t,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void t(e)}u.done?r(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function i(e){asyncGeneratorStep(a,n,o,i,u,"next",e)}function u(e){asyncGeneratorStep(a,n,o,i,u,"throw",e)}i(void 0)}))}}import{PlusOutlined,ExclamationCircleOutlined}from"@ant-design/icons";import{Button,Divider,message,Modal}from"antd";import React,{useState,useRef}from"react";import{ProTable}from"@ant-design/pro-components";import Auth from"../../auth";import UpdateForm from"./components/UpdateForm";import{queryUri,updateUri,addUri,removeUri}from"./service.js";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在添加"),n=!1,e.prev=2,e.next=5,addUri(_objectSpread({},r));case 5:"000000"===(o=e.sent).rspCode?(message.success("添加成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("添加失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleUpdate=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在更新"),n=!1,e.prev=2,e.next=5,updateUri({url:r.url,description:r.description,id:r.id});case 5:"000000"===(o=e.sent).rspCode?(message.success("更新成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("更新失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在删除"),n=!1,e.prev=2,e.next=5,removeUri(r);case 5:"000000"===(o=e.sent).rspCode?(message.success("删除成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("删除失败,请重试");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),RequestUriList=function(){var e=_slicedToArray(useState(!1),2),r=e[0],t=e[1],n=_slicedToArray(useState(!1),2),o=n[0],a=n[1],i=_slicedToArray(useState({}),2),u=i[0],c=i[1],s=useRef(),l=[{title:"URI",dataIndex:"url",rules:[{required:!0,message:"URI为必填项"}]},{title:"描述",dataIndex:"description"},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,r,t,n){return _jsxs(_Fragment,{children:[_jsxs(Auth,{code:"URI_EDIT",children:[_jsx("a",{onClick:function(){a(!0),c(r)},children:"编辑"}),_jsx(Divider,{type:"vertical"})]}),_jsx(Auth,{code:"URI_DEL",children:_jsx("a",{onClick:function(){var e;Modal.confirm({title:"确定删除吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:(e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleRemove(r);case 2:if(!e.sent||!n){e.next=8;break}return e.next=6,n.reset();case 6:return e.next=8,n.reload();case 8:case"end":return e.stop()}}),e)}))),function(){return e.apply(this,arguments)}),onCancel:function(){}})},children:"删除"})})]})}}];return _jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"URI列表",actionRef:s,rowKey:"id",toolBarRender:function(){return[_jsx(Auth,{code:"URI_ADD",children:_jsxs(Button,{type:"primary",onClick:function(){return t(!0)},children:[_jsx(PlusOutlined,{})," 新建"]})})]},beforeSearchSubmit:function(e){return _objectSpread(_objectSpread({},e),{},{searchObject:{url:e.url,description:e.description}})},params:{},request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryUri(r);case 2:return t=e.sent,e.abrupt("return",t.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),columns:l,rowSelection:!1}),r?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleAdd(r);case 2:if(!e.sent){e.next=10;break}if(t(!1),!s.current){e.next=10;break}return e.next=8,s.current.reset();case 8:return e.next=10,s.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){t(!1)},type:"C",updateModalVisible:r,values:{}}):null,o?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleUpdate(r);case 2:if(!e.sent){e.next=10;break}if(a(!1),!s.current){e.next=10;break}return e.next=8,s.current.reset();case 8:return e.next=10,s.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){a(!1)},type:"U",updateModalVisible:o,values:u}):null]})};export default RequestUriList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],c=!0,s=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(s)throw o}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function s(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{s({},"")}catch(e){s=function(e,r,t){return e[r]=t}}function l(e,r,t,n){var a=r&&r.prototype instanceof v?r:v,i=Object.create(a.prototype),u=new E(n||[]);return o(i,"_invoke",{value:L(e,t,u)}),i}function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var p="suspendedStart",h="suspendedYield",d="executing",m="completed",y={};function v(){}function g(){}function _(){}var b={};s(b,i,(function(){return this}));var x=Object.getPrototypeOf,w=x&&x(x(A([])));w&&w!==t&&n.call(w,i)&&(b=w);var j=_.prototype=v.prototype=Object.create(b);function R(e){["next","throw","return"].forEach((function(r){s(e,r,(function(e){return this._invoke(r,e)}))}))}function O(e,r){function t(o,a,i,u){var c=f(e[o],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,i,u)}),(function(e){t("throw",e,i,u)})):r.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return t("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return a=a?a.then(o,o):o()}})}function L(r,t,n){var o=p;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=S(u,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=f(r,t,n);if("normal"===s.type){if(o=n.done?m:h,s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function S(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,S(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=f(o,r.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,y;var i=a.arg;return i?i.done?(t[r.resultName]=i.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,y):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function k(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function T(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function A(r){if(r||""===r){var t=r[i];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return a.next=a}}throw new TypeError(_typeof(r)+" is not iterable")}return g.prototype=_,o(j,"constructor",{value:_,configurable:!0}),o(_,"constructor",{value:g,configurable:!0}),g.displayName=s(_,c,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,s(e,c,"GeneratorFunction")),e.prototype=Object.create(j),e},r.awrap=function(e){return{__await:e}},R(O.prototype),s(O.prototype,u,(function(){return this})),r.AsyncIterator=O,r.async=function(e,t,n,o,a){void 0===a&&(a=Promise);var i=new O(l(e,t,n,o),a);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},R(j),s(j,c,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=A,E.prototype={constructor:E,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return u.type="throw",u.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),y},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),T(t),y}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;T(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:A(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),y}},r}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function asyncGeneratorStep(e,r,t,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void t(e)}u.done?r(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function i(e){asyncGeneratorStep(a,n,o,i,u,"next",e)}function u(e){asyncGeneratorStep(a,n,o,i,u,"throw",e)}i(void 0)}))}}import{PlusOutlined,ExclamationCircleOutlined}from"@ant-design/icons";import{Button,Divider,message,Modal,Checkbox,Col,Row}from"antd";import React,{useState,useRef,useEffect}from"react";import ProTable from"@ant-design/pro-table";import Auth from"../../auth";import UpdateForm from"./components/UpdateForm";import{queryRole,updateRole,addRole,removeRole,assignPerm,getRolePerms,getPermList}from"./service";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在添加"),n=!1,e.prev=2,e.next=5,addRole(_objectSpread({},r));case 5:"000000"===(o=e.sent).rspCode?(message.success("添加成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("添加失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleUpdate=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在更新"),n=!1,e.prev=2,e.next=5,updateRole({roleName:r.roleName,roleCode:r.roleCode,id:r.id});case 5:"000000"===(o=e.sent).rspCode?(message.success("更新成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("更新失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在删除"),n=!1,e.prev=2,e.next=5,removeRole(r);case 5:"000000"===(o=e.sent).rspCode?(message.success("删除成功"),n=!0):message.error(o.rspMsg),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(2),t(),message.error("删除失败,请重试");case 13:return t(),e.abrupt("return",n);case 15:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),RoleList=function(){var e=_slicedToArray(useState(!1),2),r=e[0],t=e[1],n=_slicedToArray(useState(!1),2),o=n[0],a=n[1],i=_slicedToArray(useState(!1),2),u=i[0],c=i[1],s=_slicedToArray(useState([]),2),l=s[0],f=s[1],p=_slicedToArray(useState([]),2),h=p[0],d=p[1],m=_slicedToArray(useState({}),2),y=m[0],v=m[1],g=useRef();useEffect((function(){_()}),[]);var _=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,t,n,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,getPermList({});case 3:"000000"===(r=e.sent).rspCode?(t=r.data,n=[],t.forEach((function(e,r){e.moduleName?n.unshift(e.moduleName):n.push("其他")})),o=_toConsumableArray(new Set(n)),a=[],o.map((function(e){var r={moduleName:e,permList:t.filter((function(r){return r.moduleName===e||null===r.moduleName&&"其他"===e}))};a.push(r)})),d(a)):message.error(r.rspMsg),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(0),console.log(e.t0),message.error("获取权限列表失败");case 11:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}(),b=[{title:"角色代码",dataIndex:"roleCode",rules:[{required:!0,message:"角色代码为必填项"}]},{title:"角色名称",dataIndex:"roleName",valueType:"textarea"},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,r,t,n){return _jsxs(_Fragment,{children:[_jsxs(Auth,{code:"ROLE_EDIT",children:[_jsx("a",{onClick:function(){a(!0),v(r)},children:"编辑"}),_jsx(Divider,{type:"vertical"})]}),_jsxs(Auth,{code:"ROLE_DEL",children:[_jsx("a",{onClick:function(){var e;Modal.confirm({title:"确定删除吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:(e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleRemove(r);case 2:if(!e.sent||!n){e.next=8;break}return e.next=6,n.reset();case 6:return e.next=8,n.reload();case 8:case"end":return e.stop()}}),e)}))),function(){return e.apply(this,arguments)}),onCancel:function(){}})},children:"删除"}),_jsx(Divider,{type:"vertical"})]}),_jsx(Auth,{code:"ROLE_PERM",children:_jsx("a",{onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在获取权限信息"),e.prev=1,e.next=4,getRolePerms({roleId:r.id});case 4:"000000"===(n=e.sent).rspCode?(o=n.data.map((function(e){return e.permId})),console.log(178,o),f(o),v(r),c(!0)):message.error(n.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("获取角色权限失败");case 11:t();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:"权限"})})]})}}];return _jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"角色列表",actionRef:g,rowKey:"id",toolBarRender:function(){return[_jsx(Auth,{code:"ROLE_ADD",children:_jsxs(Button,{type:"primary",onClick:function(){return t(!0)},children:[_jsx(PlusOutlined,{})," 新建"]})})]},beforeSearchSubmit:function(e){return{searchObject:_objectSpread({},e)}},params:{},request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryRole(r);case 2:return t=e.sent,e.abrupt("return",t.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),columns:b,rowSelection:!1}),r?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleAdd(r);case 2:if(!e.sent){e.next=10;break}if(t(!1),!g.current){e.next=10;break}return e.next=8,g.current.reset();case 8:return e.next=10,g.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){t(!1)},type:"C",updateModalVisible:r,values:{}}):null,o?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleUpdate(r);case 2:if(!e.sent){e.next=10;break}if(a(!1),!g.current){e.next=10;break}return e.next=8,g.current.reset();case 8:return e.next=10,g.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){a(!1)},type:"U",updateModalVisible:o,values:y}):null,u?_jsx(Modal,{title:"设置权限",width:1100,open:u,onCancel:function(){c(!1)},onOk:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,assignPerm({roleId:y.id,permIds:l.join()});case 3:"000000"===(r=e.sent).rspCode?(message.success("设置成功"),c(!1)):message.error(r.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("设置权限失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),children:h.map((function(e,r){return _jsxs(Row,{style:{marginBottom:16},children:[_jsx(Col,{span:6,children:e.moduleName},r),_jsx(Col,{span:18,children:_jsx(Row,{children:e.permList.map((function(e){return _jsx(Col,{span:6,children:_jsx(Checkbox,{onChange:function(e){var r,t=e.target.value;1==e.target.checked?(r=l).push(t):r=l.filter((function(e){return e!==t})),f(r)},value:e.id,defaultChecked:!(null==l||!l.includes(e.id)),children:e.permName},e.id)},e.id)}))},e.permModule)},e.permModule)]},r)}))}):null]})};export default RoleList;
|
|
1
|
+
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],c=!0,s=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(s)throw o}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function s(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{s({},"")}catch(e){s=function(e,r,t){return e[r]=t}}function l(e,r,t,n){var a=r&&r.prototype instanceof v?r:v,i=Object.create(a.prototype),u=new E(n||[]);return o(i,"_invoke",{value:L(e,t,u)}),i}function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var p="suspendedStart",h="suspendedYield",d="executing",m="completed",y={};function v(){}function g(){}function _(){}var b={};s(b,i,(function(){return this}));var x=Object.getPrototypeOf,w=x&&x(x(A([])));w&&w!==t&&n.call(w,i)&&(b=w);var j=_.prototype=v.prototype=Object.create(b);function R(e){["next","throw","return"].forEach((function(r){s(e,r,(function(e){return this._invoke(r,e)}))}))}function O(e,r){function t(o,a,i,u){var c=f(e[o],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,i,u)}),(function(e){t("throw",e,i,u)})):r.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return t("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return a=a?a.then(o,o):o()}})}function L(r,t,n){var o=p;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=S(u,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=f(r,t,n);if("normal"===s.type){if(o=n.done?m:h,s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function S(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,S(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=f(o,r.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,y;var i=a.arg;return i?i.done?(t[r.resultName]=i.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,y):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function k(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function T(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function A(r){if(r||""===r){var t=r[i];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return a.next=a}}throw new TypeError(_typeof(r)+" is not iterable")}return g.prototype=_,o(j,"constructor",{value:_,configurable:!0}),o(_,"constructor",{value:g,configurable:!0}),g.displayName=s(_,c,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,s(e,c,"GeneratorFunction")),e.prototype=Object.create(j),e},r.awrap=function(e){return{__await:e}},R(O.prototype),s(O.prototype,u,(function(){return this})),r.AsyncIterator=O,r.async=function(e,t,n,o,a){void 0===a&&(a=Promise);var i=new O(l(e,t,n,o),a);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},R(j),s(j,c,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=A,E.prototype={constructor:E,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return u.type="throw",u.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),y},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),T(t),y}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;T(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:A(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),y}},r}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function asyncGeneratorStep(e,r,t,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void t(e)}u.done?r(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function i(e){asyncGeneratorStep(a,n,o,i,u,"next",e)}function u(e){asyncGeneratorStep(a,n,o,i,u,"throw",e)}i(void 0)}))}}import{PlusOutlined,ExclamationCircleOutlined}from"@ant-design/icons";import{Button,Divider,message,Modal,Checkbox,Col,Row}from"antd";import React,{useState,useRef,useEffect}from"react";import{ProTable}from"@ant-design/pro-components";import Auth from"../../auth";import UpdateForm from"./components/UpdateForm";import{queryRole,updateRole,addRole,removeRole,assignPerm,getRolePerms,getPermList}from"./service";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在添加"),n=!1,e.prev=2,e.next=5,addRole(_objectSpread({},r));case 5:"000000"===(o=e.sent).rspCode?(message.success("添加成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("添加失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleUpdate=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在更新"),n=!1,e.prev=2,e.next=5,updateRole({roleName:r.roleName,roleCode:r.roleCode,id:r.id});case 5:"000000"===(o=e.sent).rspCode?(message.success("更新成功"),n=!0):message.error(o.rspMsg),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),message.error("更新失败请重试!");case 12:return t(),e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在删除"),n=!1,e.prev=2,e.next=5,removeRole(r);case 5:"000000"===(o=e.sent).rspCode?(message.success("删除成功"),n=!0):message.error(o.rspMsg),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(2),t(),message.error("删除失败,请重试");case 13:return t(),e.abrupt("return",n);case 15:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(r){return e.apply(this,arguments)}}(),RoleList=function(){var e=_slicedToArray(useState(!1),2),r=e[0],t=e[1],n=_slicedToArray(useState(!1),2),o=n[0],a=n[1],i=_slicedToArray(useState(!1),2),u=i[0],c=i[1],s=_slicedToArray(useState([]),2),l=s[0],f=s[1],p=_slicedToArray(useState([]),2),h=p[0],d=p[1],m=_slicedToArray(useState({}),2),y=m[0],v=m[1],g=useRef();useEffect((function(){_()}),[]);var _=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,t,n,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,getPermList({});case 3:"000000"===(r=e.sent).rspCode?(t=r.data,n=[],t.forEach((function(e,r){e.moduleName?n.unshift(e.moduleName):n.push("其他")})),o=_toConsumableArray(new Set(n)),a=[],o.map((function(e){var r={moduleName:e,permList:t.filter((function(r){return r.moduleName===e||null===r.moduleName&&"其他"===e}))};a.push(r)})),d(a)):message.error(r.rspMsg),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(0),console.log(e.t0),message.error("获取权限列表失败");case 11:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}(),b=[{title:"角色代码",dataIndex:"roleCode",rules:[{required:!0,message:"角色代码为必填项"}]},{title:"角色名称",dataIndex:"roleName",valueType:"textarea"},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,r,t,n){return _jsxs(_Fragment,{children:[_jsxs(Auth,{code:"ROLE_EDIT",children:[_jsx("a",{onClick:function(){a(!0),v(r)},children:"编辑"}),_jsx(Divider,{type:"vertical"})]}),_jsxs(Auth,{code:"ROLE_DEL",children:[_jsx("a",{onClick:function(){var e;Modal.confirm({title:"确定删除吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:(e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleRemove(r);case 2:if(!e.sent||!n){e.next=8;break}return e.next=6,n.reset();case 6:return e.next=8,n.reload();case 8:case"end":return e.stop()}}),e)}))),function(){return e.apply(this,arguments)}),onCancel:function(){}})},children:"删除"}),_jsx(Divider,{type:"vertical"})]}),_jsx(Auth,{code:"ROLE_PERM",children:_jsx("a",{onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在获取权限信息"),e.prev=1,e.next=4,getRolePerms({roleId:r.id});case 4:"000000"===(n=e.sent).rspCode?(o=n.data.map((function(e){return e.permId})),console.log(178,o),f(o),v(r),c(!0)):message.error(n.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("获取角色权限失败");case 11:t();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:"权限"})})]})}}];return _jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"角色列表",actionRef:g,rowKey:"id",toolBarRender:function(){return[_jsx(Auth,{code:"ROLE_ADD",children:_jsxs(Button,{type:"primary",onClick:function(){return t(!0)},children:[_jsx(PlusOutlined,{})," 新建"]})})]},beforeSearchSubmit:function(e){return{searchObject:_objectSpread({},e)}},params:{},request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryRole(r);case 2:return t=e.sent,e.abrupt("return",t.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),columns:b,rowSelection:!1}),r?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleAdd(r);case 2:if(!e.sent){e.next=10;break}if(t(!1),!g.current){e.next=10;break}return e.next=8,g.current.reset();case 8:return e.next=10,g.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){t(!1)},type:"C",updateModalVisible:r,values:{}}):null,o?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleUpdate(r);case 2:if(!e.sent){e.next=10;break}if(a(!1),!g.current){e.next=10;break}return e.next=8,g.current.reset();case 8:return e.next=10,g.current.reload();case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onCancel:function(){a(!1)},type:"U",updateModalVisible:o,values:y}):null,u?_jsx(Modal,{title:"设置权限",width:1100,open:u,onCancel:function(){c(!1)},onOk:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,assignPerm({roleId:y.id,permIds:l.join()});case 3:"000000"===(r=e.sent).rspCode?(message.success("设置成功"),c(!1)):message.error(r.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("设置权限失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),children:h.map((function(e,r){return _jsxs(Row,{style:{marginBottom:16},children:[_jsx(Col,{span:6,children:e.moduleName},r),_jsx(Col,{span:18,children:_jsx(Row,{children:e.permList.map((function(e){return _jsx(Col,{span:6,children:_jsx(Checkbox,{onChange:function(e){var r,t=e.target.value;1==e.target.checked?(r=l).push(t):r=l.filter((function(e){return e!==t})),f(r)},value:e.id,defaultChecked:!(null==l||!l.includes(e.id)),children:e.permName},e.id)},e.id)}))},e.permModule)},e.permModule)]},r)}))}):null]})};export default RoleList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,a,o,s,i=[],c=!0,u=!1;try{if(o=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=o.call(t)).done)&&(i.push(n.value),i.length!==r);c=!0);}catch(e){u=!0,a=e}finally{try{if(!c&&null!=t.return&&(s=t.return(),Object(s)!==s))return}finally{if(u)throw a}}return i}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,a=Object.defineProperty||function(e,r,t){e[r]=t.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{u({},"")}catch(e){u=function(e,r,t){return e[r]=t}}function l(e,r,t,n){var o=r&&r.prototype instanceof g?r:g,s=Object.create(o.prototype),i=new L(n||[]);return a(s,"_invoke",{value:R(e,t,i)}),s}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var f="suspendedStart",d="suspendedYield",h="executing",m="completed",y={};function g(){}function v(){}function x(){}var b={};u(b,s,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(A([])));w&&w!==t&&n.call(w,s)&&(b=w);var j=x.prototype=g.prototype=Object.create(b);function k(e){["next","throw","return"].forEach((function(r){u(e,r,(function(e){return this._invoke(r,e)}))}))}function S(e,r){function t(a,o,s,i){var c=p(e[a],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,s,i)}),(function(e){t("throw",e,s,i)})):r.resolve(l).then((function(e){u.value=e,s(u)}),(function(e){return t("throw",e,s,i)}))}i(c.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new r((function(r,a){t(e,n,r,a)}))}return o=o?o.then(a,a):a()}})}function R(r,t,n){var a=f;return function(o,s){if(a===h)throw new Error("Generator is already running");if(a===m){if("throw"===o)throw s;return{value:e,done:!0}}for(n.method=o,n.arg=s;;){var i=n.delegate;if(i){var c=E(i,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===f)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=h;var u=p(r,t,n);if("normal"===u.type){if(a=n.done?m:d,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function E(r,t){var n=t.method,a=r.iterator[n];if(a===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,E(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=p(a,r.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,y;var s=o.arg;return s?s.done?(t[r.resultName]=s.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,y):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function O(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function T(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function A(r){if(r||""===r){var t=r[s];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var a=-1,o=function t(){for(;++a<r.length;)if(n.call(r,a))return t.value=r[a],t.done=!1,t;return t.value=e,t.done=!0,t};return o.next=o}}throw new TypeError(_typeof(r)+" is not iterable")}return v.prototype=x,a(j,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:v,configurable:!0}),v.displayName=u(x,c,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===v||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,u(e,c,"GeneratorFunction")),e.prototype=Object.create(j),e},r.awrap=function(e){return{__await:e}},k(S.prototype),u(S.prototype,i,(function(){return this})),r.AsyncIterator=S,r.async=function(e,t,n,a,o){void 0===o&&(o=Promise);var s=new S(l(e,t,n,a),o);return r.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},k(j),u(j,c,"Generator"),u(j,s,(function(){return this})),u(j,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=A,L.prototype={constructor:L,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function a(n,a){return i.type="throw",i.arg=r,t.next=n,a&&(t.method="next",t.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],i=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var c=n.call(s,"catchLoc"),u=n.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return a(s.catchLoc,!0);if(this.prev<s.finallyLoc)return a(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return a(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return a(s.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var a=this.tryEntries[t];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=r,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(s)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),y},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),T(t),y}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;T(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:A(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),y}},r}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function asyncGeneratorStep(e,r,t,n,a,o,s){try{var i=e[o](s),c=i.value}catch(e){return void t(e)}i.done?r(c):Promise.resolve(c).then(n,a)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,a){var o=e.apply(r,t);function s(e){asyncGeneratorStep(o,n,a,s,i,"next",e)}function i(e){asyncGeneratorStep(o,n,a,s,i,"throw",e)}s(void 0)}))}}import{PlusOutlined,ExclamationCircleOutlined}from"@ant-design/icons";import{Button,Divider,message,Modal,Select,Space}from"antd";import React,{useState,useRef,useEffect}from"react";import Auth from"../../auth";import ProTable from"@ant-design/pro-table";import UpdateForm from"./components/UpdateForm";import{queryUser,updateUser,addUser,removeUser,resetPassword,assignRole,lock,unlock,enable,disable,getRoleList,getUserRoles,createGitAccount}from"./service.js";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var handleAssignRole=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n){var a,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=message.loading("正在更新角色"),e.prev=1,e.next=4,assignRole(_objectSpread({},r));case 4:if(o=e.sent,a(),"000000"!==o.rspCode){e.next=15;break}return message.success("操作成功"),n&&n(),e.next=11,t.reset();case 11:return e.next=13,t.reload();case 13:e.next=16;break;case 15:message.error(o.rspMsg);case 16:return e.abrupt("return",!0);case 19:return e.prev=19,e.t0=e.catch(1),a(),message.error("操作失败请重试!"),e.abrupt("return",!1);case 24:case"end":return e.stop()}}),e,null,[[1,19]])})));return function(r,t,n){return e.apply(this,arguments)}}(),handleUpdateEnable=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n,a){var o,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=message.loading("正在更新状态"),e.prev=1,s={},!t){e.next=9;break}return e.next=6,enable(_objectSpread({},r));case 6:s=e.sent,e.next=12;break;case 9:return e.next=11,disable(_objectSpread({},r));case 11:s=e.sent;case 12:if(o(),"000000"!==s.rspCode){e.next=22;break}return message.success("操作成功"),a&&a(),e.next=18,n.reset();case 18:return e.next=20,n.reload();case 20:e.next=23;break;case 22:message.error(s.rspMsg);case 23:return e.abrupt("return",!0);case 26:return e.prev=26,e.t0=e.catch(1),o(),message.error("操作失败请重试!"),e.abrupt("return",!1);case 31:case"end":return e.stop()}}),e,null,[[1,26]])})));return function(r,t,n,a){return e.apply(this,arguments)}}(),handleUpdateLock=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n,a){var o,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=message.loading("正在更新状态"),e.prev=1,s={},!t){e.next=9;break}return e.next=6,lock(_objectSpread({},r));case 6:s=e.sent,e.next=12;break;case 9:return e.next=11,unlock(_objectSpread({},r));case 11:s=e.sent;case 12:if(s.rspCode){e.next=16;break}return e.next=15,s.json();case 15:s=e.sent;case 16:if(o(),"000000"!==s.rspCode){e.next=26;break}return message.success("操作成功"),a&&a(),e.next=22,n.reset();case 22:return e.next=24,n.reload();case 24:e.next=27;break;case 26:message.error(s.rspMsg);case 27:return e.abrupt("return",!0);case 30:return e.prev=30,e.t0=e.catch(1),o(),message.error("操作失败请重试!"),e.abrupt("return",!1);case 35:case"end":return e.stop()}}),e,null,[[1,30]])})));return function(r,t,n,a){return e.apply(this,arguments)}}(),handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n){var a,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=message.loading("正在添加"),e.prev=1,e.next=4,addUser(_objectSpread({},r));case 4:if((o=e.sent).rspCode){e.next=9;break}return e.next=8,o.json();case 8:o=e.sent;case 9:if(a(),"000000"!==o.rspCode){e.next=19;break}return message.success("添加成功"),n&&n(),e.next=15,t.reset();case 15:return e.next=17,t.reload();case 17:e.next=20;break;case 19:message.error(o.rspMsg);case 20:return e.abrupt("return",!0);case 23:return e.prev=23,e.t0=e.catch(1),a(),message.error("添加失败请重试!"),e.abrupt("return",!1);case 28:case"end":return e.stop()}}),e,null,[[1,23]])})));return function(r,t,n){return e.apply(this,arguments)}}(),handleUpdate=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n){var a,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=message.loading("正在更新"),e.prev=1,e.next=4,updateUser(_objectSpread({},r));case 4:if((o=e.sent).rspCode){e.next=9;break}return e.next=8,o.json();case 8:o=e.sent;case 9:if(a(),"000000"!==o.rspCode){e.next=19;break}return message.success("更新成功"),n&&n(),e.next=15,t.reset();case 15:return e.next=17,t.reload();case 17:e.next=20;break;case 19:message.error(o.rspMsg);case 20:return e.abrupt("return",!0);case 23:return e.prev=23,e.t0=e.catch(1),a(),message.error("更新失败请重试!"),e.abrupt("return",!1);case 28:case"end":return e.stop()}}),e,null,[[1,23]])})));return function(r,t,n){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n){var a,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=message.loading("正在删除"),e.prev=1,e.next=4,removeUser(r);case 4:if((o=e.sent).rspCode){e.next=9;break}return e.next=8,o.json();case 8:o=e.sent;case 9:if(a(),"000000"!==o.rspCode){e.next=19;break}return message.success("删除成功"),n&&n(),e.next=15,t.reset();case 15:return e.next=17,t.reload();case 17:e.next=20;break;case 19:message.error(o.rspMsg);case 20:return e.abrupt("return",!0);case 23:return e.prev=23,e.t0=e.catch(1),a(),message.error("删除失败,请重试"),e.abrupt("return",!1);case 28:case"end":return e.stop()}}),e,null,[[1,23]])})));return function(r,t,n){return e.apply(this,arguments)}}(),handleResetPassword=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在重置密码"),e.prev=1,e.next=4,resetPassword(r);case 4:if((n=e.sent).rspCode){e.next=9;break}return e.next=8,n.json();case 8:n=e.sent;case 9:return t(),"000000"===n.rspCode?message.success("重置密码成功"):message.error(n.rspMsg),e.abrupt("return",!0);case 14:return e.prev=14,e.t0=e.catch(1),t(),message.error("重置密码失败,请重试"),e.abrupt("return",!1);case 19:case"end":return e.stop()}}),e,null,[[1,14]])})));return function(r){return e.apply(this,arguments)}}(),UserList=function(e){var r=_slicedToArray(useState(!1),2),t=r[0],n=r[1],a=_slicedToArray(useState(!1),2),o=a[0],s=a[1],i=_slicedToArray(useState([]),2),c=i[0],u=i[1],l=_slicedToArray(useState({}),2),p=l[0],f=l[1],d=_slicedToArray(useState("C"),2),h=d[0],m=d[1],y=_slicedToArray(useState([]),2),g=y[0],v=y[1],x=useRef();useEffect((function(){_()}),[]);var b=[{title:"用户名",dataIndex:"username"},{title:"姓名",dataIndex:"realName"},{title:"是否启用",dataIndex:"enabled",valueEnum:{0:{text:"否",enabled:0},1:{text:"是",enabled:1}},fieldProps:{getPopupContainer:function(e){return e.parentNode}},filters:!1},{title:"过期时间",dataIndex:"expired",valueType:"dateTime"},{title:"是否锁定",dataIndex:"locked",valueEnum:{0:{text:"否",locked:0},1:{text:"是",locked:1}},fieldProps:{getPopupContainer:function(e){return e.parentNode}},filters:!1},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,r,t,a){return _jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),size:2,children:[_jsx(Auth,{code:"USER_EDIT",children:_jsx("a",{onClick:function(){n(!0),f(r),m("U")},children:"编辑"})}),_jsx(Auth,{code:"USER_LOCK",children:_jsx("a",{onClick:function(){var e=!1;0===r.locked&&(e=!0),handleUpdateLock({id:r.id},e,a,(function(){}))},children:0===r.locked?"锁定":"解锁"})}),_jsx(Auth,{code:"USER_ENABLE",children:_jsx("a",{onClick:function(){var e=!1;0===r.enabled&&(e=!0),handleUpdateEnable({id:r.id},e,a,(function(){}))},children:0===r.enabled?"启用":"停用"})}),_jsx(Auth,{code:"USER_DEL",children:_jsx("a",{onClick:function(){Modal.confirm({title:"确定删除吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:function(){"1"!==r.id?handleRemove(r,a):message.error("超级管理员无法被删除")},onCancel:function(){}})},children:"删除"})}),_jsx(Auth,{code:"RESET_PASSWORD",children:_jsx("a",{onClick:function(){Modal.confirm({title:"确定重置密码吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:function(){handleResetPassword(r)},onCancel:function(){}})},children:"重置密码"})}),_jsx(Auth,{code:"USER_ROLE",children:_jsx("a",{onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,n,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在获取角色信息"),e.prev=1,e.next=4,getUserRoles({userId:r.id});case 4:"000000"===(n=e.sent).rspCode?(a=n.data.map((function(e){return e.roleId})),u(a),f(r),s(!0)):message.error(n.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("获取用户角色失败");case 11:t();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:"角色"})}),_jsx(Auth,{code:"CREATE_GIT",children:_jsx("a",{onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,createGitAccount({userId:r.id});case 3:"000000"===(t=e.sent).rspCode?message.success("创建成功!"):message.error(t.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("创建失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),children:"创建git账号"})})]})}}],_=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,getRoleList({});case 3:"000000"===(r=e.sent).rspCode?v(r.data):message.error(r.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("获取角色列表失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();return _jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"用户列表",actionRef:x,rowKey:"id",toolBarRender:function(){return[_jsx(Auth,{code:"USER_ADD",children:_jsxs(Button,{type:"primary",onClick:function(){n(!0),f({}),m("C")},children:[_jsx(PlusOutlined,{})," 新建"]})})]},beforeSearchSubmit:function(e){return e.expired&&(e.expired=new Date(e.expired).getTime()),{searchObject:_objectSpread({},e)}},params:{},request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryUser(r);case 2:return t=e.sent,e.abrupt("return",t.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),pagination:{showSizeChanger:!0},columns:b,rowSelection:!1}),t?_jsx(UpdateForm,{onAdd:handleAdd,onUpdate:handleUpdate,onCancel:function(){n(!1)},type:h,modalVisible:t,currentItem:p,action:x}):null,o?_jsx(Modal,{title:"设置角色",open:o,onCancel:function(){s(!1)},onOk:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,assignRole({userId:p.id,roleIds:c.join()});case 3:"000000"===(r=e.sent).rspCode?(message.success("设置成功"),s(!1)):message.error(r.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("设置角色失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),children:_jsx(Select,{value:c,onChange:function(e){u(e)},mode:"multiple",style:{width:"100%"},children:g.map((function(e){return _jsx(Select.Option,{value:e.id,children:e.roleName},e.id)}))})}):null]})};export default UserList;
|
|
1
|
+
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,a,o,s,i=[],c=!0,u=!1;try{if(o=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=o.call(t)).done)&&(i.push(n.value),i.length!==r);c=!0);}catch(e){u=!0,a=e}finally{try{if(!c&&null!=t.return&&(s=t.return(),Object(s)!==s))return}finally{if(u)throw a}}return i}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,a=Object.defineProperty||function(e,r,t){e[r]=t.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{u({},"")}catch(e){u=function(e,r,t){return e[r]=t}}function l(e,r,t,n){var o=r&&r.prototype instanceof g?r:g,s=Object.create(o.prototype),i=new L(n||[]);return a(s,"_invoke",{value:R(e,t,i)}),s}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var f="suspendedStart",d="suspendedYield",h="executing",m="completed",y={};function g(){}function v(){}function x(){}var b={};u(b,s,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(A([])));w&&w!==t&&n.call(w,s)&&(b=w);var j=x.prototype=g.prototype=Object.create(b);function k(e){["next","throw","return"].forEach((function(r){u(e,r,(function(e){return this._invoke(r,e)}))}))}function S(e,r){function t(a,o,s,i){var c=p(e[a],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,s,i)}),(function(e){t("throw",e,s,i)})):r.resolve(l).then((function(e){u.value=e,s(u)}),(function(e){return t("throw",e,s,i)}))}i(c.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new r((function(r,a){t(e,n,r,a)}))}return o=o?o.then(a,a):a()}})}function R(r,t,n){var a=f;return function(o,s){if(a===h)throw new Error("Generator is already running");if(a===m){if("throw"===o)throw s;return{value:e,done:!0}}for(n.method=o,n.arg=s;;){var i=n.delegate;if(i){var c=E(i,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===f)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=h;var u=p(r,t,n);if("normal"===u.type){if(a=n.done?m:d,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function E(r,t){var n=t.method,a=r.iterator[n];if(a===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,E(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=p(a,r.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,y;var s=o.arg;return s?s.done?(t[r.resultName]=s.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,y):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function O(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function T(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function A(r){if(r||""===r){var t=r[s];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var a=-1,o=function t(){for(;++a<r.length;)if(n.call(r,a))return t.value=r[a],t.done=!1,t;return t.value=e,t.done=!0,t};return o.next=o}}throw new TypeError(_typeof(r)+" is not iterable")}return v.prototype=x,a(j,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:v,configurable:!0}),v.displayName=u(x,c,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===v||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,u(e,c,"GeneratorFunction")),e.prototype=Object.create(j),e},r.awrap=function(e){return{__await:e}},k(S.prototype),u(S.prototype,i,(function(){return this})),r.AsyncIterator=S,r.async=function(e,t,n,a,o){void 0===o&&(o=Promise);var s=new S(l(e,t,n,a),o);return r.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},k(j),u(j,c,"Generator"),u(j,s,(function(){return this})),u(j,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=A,L.prototype={constructor:L,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function a(n,a){return i.type="throw",i.arg=r,t.next=n,a&&(t.method="next",t.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],i=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var c=n.call(s,"catchLoc"),u=n.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return a(s.catchLoc,!0);if(this.prev<s.finallyLoc)return a(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return a(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return a(s.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var a=this.tryEntries[t];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=r,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(s)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),y},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),T(t),y}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;T(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:A(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),y}},r}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function asyncGeneratorStep(e,r,t,n,a,o,s){try{var i=e[o](s),c=i.value}catch(e){return void t(e)}i.done?r(c):Promise.resolve(c).then(n,a)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,a){var o=e.apply(r,t);function s(e){asyncGeneratorStep(o,n,a,s,i,"next",e)}function i(e){asyncGeneratorStep(o,n,a,s,i,"throw",e)}s(void 0)}))}}import{PlusOutlined,ExclamationCircleOutlined}from"@ant-design/icons";import{Button,Divider,message,Modal,Select,Space}from"antd";import React,{useState,useRef,useEffect}from"react";import Auth from"../../auth";import{ProTable}from"@ant-design/pro-components";import UpdateForm from"./components/UpdateForm";import{queryUser,updateUser,addUser,removeUser,resetPassword,assignRole,lock,unlock,enable,disable,getRoleList,getUserRoles,createGitAccount}from"./service.js";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var handleAssignRole=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n){var a,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=message.loading("正在更新角色"),e.prev=1,e.next=4,assignRole(_objectSpread({},r));case 4:if(o=e.sent,a(),"000000"!==o.rspCode){e.next=15;break}return message.success("操作成功"),n&&n(),e.next=11,t.reset();case 11:return e.next=13,t.reload();case 13:e.next=16;break;case 15:message.error(o.rspMsg);case 16:return e.abrupt("return",!0);case 19:return e.prev=19,e.t0=e.catch(1),a(),message.error("操作失败请重试!"),e.abrupt("return",!1);case 24:case"end":return e.stop()}}),e,null,[[1,19]])})));return function(r,t,n){return e.apply(this,arguments)}}(),handleUpdateEnable=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n,a){var o,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=message.loading("正在更新状态"),e.prev=1,s={},!t){e.next=9;break}return e.next=6,enable(_objectSpread({},r));case 6:s=e.sent,e.next=12;break;case 9:return e.next=11,disable(_objectSpread({},r));case 11:s=e.sent;case 12:if(o(),"000000"!==s.rspCode){e.next=22;break}return message.success("操作成功"),a&&a(),e.next=18,n.reset();case 18:return e.next=20,n.reload();case 20:e.next=23;break;case 22:message.error(s.rspMsg);case 23:return e.abrupt("return",!0);case 26:return e.prev=26,e.t0=e.catch(1),o(),message.error("操作失败请重试!"),e.abrupt("return",!1);case 31:case"end":return e.stop()}}),e,null,[[1,26]])})));return function(r,t,n,a){return e.apply(this,arguments)}}(),handleUpdateLock=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n,a){var o,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=message.loading("正在更新状态"),e.prev=1,s={},!t){e.next=9;break}return e.next=6,lock(_objectSpread({},r));case 6:s=e.sent,e.next=12;break;case 9:return e.next=11,unlock(_objectSpread({},r));case 11:s=e.sent;case 12:if(s.rspCode){e.next=16;break}return e.next=15,s.json();case 15:s=e.sent;case 16:if(o(),"000000"!==s.rspCode){e.next=26;break}return message.success("操作成功"),a&&a(),e.next=22,n.reset();case 22:return e.next=24,n.reload();case 24:e.next=27;break;case 26:message.error(s.rspMsg);case 27:return e.abrupt("return",!0);case 30:return e.prev=30,e.t0=e.catch(1),o(),message.error("操作失败请重试!"),e.abrupt("return",!1);case 35:case"end":return e.stop()}}),e,null,[[1,30]])})));return function(r,t,n,a){return e.apply(this,arguments)}}(),handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n){var a,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=message.loading("正在添加"),e.prev=1,e.next=4,addUser(_objectSpread({},r));case 4:if((o=e.sent).rspCode){e.next=9;break}return e.next=8,o.json();case 8:o=e.sent;case 9:if(a(),"000000"!==o.rspCode){e.next=19;break}return message.success("添加成功"),n&&n(),e.next=15,t.reset();case 15:return e.next=17,t.reload();case 17:e.next=20;break;case 19:message.error(o.rspMsg);case 20:return e.abrupt("return",!0);case 23:return e.prev=23,e.t0=e.catch(1),a(),message.error("添加失败请重试!"),e.abrupt("return",!1);case 28:case"end":return e.stop()}}),e,null,[[1,23]])})));return function(r,t,n){return e.apply(this,arguments)}}(),handleUpdate=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n){var a,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=message.loading("正在更新"),e.prev=1,e.next=4,updateUser(_objectSpread({},r));case 4:if((o=e.sent).rspCode){e.next=9;break}return e.next=8,o.json();case 8:o=e.sent;case 9:if(a(),"000000"!==o.rspCode){e.next=19;break}return message.success("更新成功"),n&&n(),e.next=15,t.reset();case 15:return e.next=17,t.reload();case 17:e.next=20;break;case 19:message.error(o.rspMsg);case 20:return e.abrupt("return",!0);case 23:return e.prev=23,e.t0=e.catch(1),a(),message.error("更新失败请重试!"),e.abrupt("return",!1);case 28:case"end":return e.stop()}}),e,null,[[1,23]])})));return function(r,t,n){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t,n){var a,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=message.loading("正在删除"),e.prev=1,e.next=4,removeUser(r);case 4:if((o=e.sent).rspCode){e.next=9;break}return e.next=8,o.json();case 8:o=e.sent;case 9:if(a(),"000000"!==o.rspCode){e.next=19;break}return message.success("删除成功"),n&&n(),e.next=15,t.reset();case 15:return e.next=17,t.reload();case 17:e.next=20;break;case 19:message.error(o.rspMsg);case 20:return e.abrupt("return",!0);case 23:return e.prev=23,e.t0=e.catch(1),a(),message.error("删除失败,请重试"),e.abrupt("return",!1);case 28:case"end":return e.stop()}}),e,null,[[1,23]])})));return function(r,t,n){return e.apply(this,arguments)}}(),handleResetPassword=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在重置密码"),e.prev=1,e.next=4,resetPassword(r);case 4:if((n=e.sent).rspCode){e.next=9;break}return e.next=8,n.json();case 8:n=e.sent;case 9:return t(),"000000"===n.rspCode?message.success("重置密码成功"):message.error(n.rspMsg),e.abrupt("return",!0);case 14:return e.prev=14,e.t0=e.catch(1),t(),message.error("重置密码失败,请重试"),e.abrupt("return",!1);case 19:case"end":return e.stop()}}),e,null,[[1,14]])})));return function(r){return e.apply(this,arguments)}}(),UserList=function(e){var r=_slicedToArray(useState(!1),2),t=r[0],n=r[1],a=_slicedToArray(useState(!1),2),o=a[0],s=a[1],i=_slicedToArray(useState([]),2),c=i[0],u=i[1],l=_slicedToArray(useState({}),2),p=l[0],f=l[1],d=_slicedToArray(useState("C"),2),h=d[0],m=d[1],y=_slicedToArray(useState([]),2),g=y[0],v=y[1],x=useRef();useEffect((function(){_()}),[]);var b=[{title:"用户名",dataIndex:"username"},{title:"姓名",dataIndex:"realName"},{title:"是否启用",dataIndex:"enabled",valueEnum:{0:{text:"否",enabled:0},1:{text:"是",enabled:1}},fieldProps:{getPopupContainer:function(e){return e.parentNode}},filters:!1},{title:"过期时间",dataIndex:"expired",valueType:"dateTime"},{title:"是否锁定",dataIndex:"locked",valueEnum:{0:{text:"否",locked:0},1:{text:"是",locked:1}},fieldProps:{getPopupContainer:function(e){return e.parentNode}},filters:!1},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,r,t,a){return _jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),size:2,children:[_jsx(Auth,{code:"USER_EDIT",children:_jsx("a",{onClick:function(){n(!0),f(r),m("U")},children:"编辑"})}),_jsx(Auth,{code:"USER_LOCK",children:_jsx("a",{onClick:function(){var e=!1;0===r.locked&&(e=!0),handleUpdateLock({id:r.id},e,a,(function(){}))},children:0===r.locked?"锁定":"解锁"})}),_jsx(Auth,{code:"USER_ENABLE",children:_jsx("a",{onClick:function(){var e=!1;0===r.enabled&&(e=!0),handleUpdateEnable({id:r.id},e,a,(function(){}))},children:0===r.enabled?"启用":"停用"})}),_jsx(Auth,{code:"USER_DEL",children:_jsx("a",{onClick:function(){Modal.confirm({title:"确定删除吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:function(){"1"!==r.id?handleRemove(r,a):message.error("超级管理员无法被删除")},onCancel:function(){}})},children:"删除"})}),_jsx(Auth,{code:"RESET_PASSWORD",children:_jsx("a",{onClick:function(){Modal.confirm({title:"确定重置密码吗?",icon:_jsx(ExclamationCircleOutlined,{}),content:"",onOk:function(){handleResetPassword(r)},onCancel:function(){}})},children:"重置密码"})}),_jsx(Auth,{code:"USER_ROLE",children:_jsx("a",{onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,n,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=message.loading("正在获取角色信息"),e.prev=1,e.next=4,getUserRoles({userId:r.id});case 4:"000000"===(n=e.sent).rspCode?(a=n.data.map((function(e){return e.roleId})),u(a),f(r),s(!0)):message.error(n.rspMsg),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),message.error("获取用户角色失败");case 11:t();case 12:case"end":return e.stop()}}),e,null,[[1,8]])}))),children:"角色"})}),_jsx(Auth,{code:"CREATE_GIT",children:_jsx("a",{onClick:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,createGitAccount({userId:r.id});case 3:"000000"===(t=e.sent).rspCode?message.success("创建成功!"):message.error(t.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("创建失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),children:"创建git账号"})})]})}}],_=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,getRoleList({});case 3:"000000"===(r=e.sent).rspCode?v(r.data):message.error(r.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("获取角色列表失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();return _jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"用户列表",actionRef:x,rowKey:"id",toolBarRender:function(){return[_jsx(Auth,{code:"USER_ADD",children:_jsxs(Button,{type:"primary",onClick:function(){n(!0),f({}),m("C")},children:[_jsx(PlusOutlined,{})," 新建"]})})]},beforeSearchSubmit:function(e){return e.expired&&(e.expired=new Date(e.expired).getTime()),{searchObject:_objectSpread({},e)}},params:{},request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryUser(r);case 2:return t=e.sent,e.abrupt("return",t.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),pagination:{showSizeChanger:!0},columns:b,rowSelection:!1}),t?_jsx(UpdateForm,{onAdd:handleAdd,onUpdate:handleUpdate,onCancel:function(){n(!1)},type:h,modalVisible:t,currentItem:p,action:x}):null,o?_jsx(Modal,{title:"设置角色",open:o,onCancel:function(){s(!1)},onOk:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,assignRole({userId:p.id,roleIds:c.join()});case 3:"000000"===(r=e.sent).rspCode?(message.success("设置成功"),s(!1)):message.error(r.rspMsg),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),message.error("设置角色失败");case 10:case"end":return e.stop()}}),e,null,[[0,7]])}))),children:_jsx(Select,{value:c,onChange:function(e){u(e)},mode:"multiple",style:{width:"100%"},children:g.map((function(e){return _jsx(Select.Option,{value:e.id,children:e.roleName},e.id)}))})}):null]})};export default UserList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,i=Object.create(a.prototype),c=new P(n||[]);return o(i,"_invoke",{value:T(e,r,c)}),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var p="suspendedStart",d="suspendedYield",y="executing",h="completed",m={};function v(){}function g(){}function b(){}var _={};s(_,i,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(k([])));x&&x!==r&&n.call(x,i)&&(_=x);var j=b.prototype=v.prototype=Object.create(_);function O(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,a,i,c){var u=f(e[o],e,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,c)}),(function(e){r("throw",e,i,c)})):t.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function T(t,r,n){var o=p;return function(a,i){if(o===y)throw new Error("Generator is already running");if(o===h){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=L(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=f(t,r,n);if("normal"===s.type){if(o=n.done?h:d,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=h,n.method="throw",n.arg=s.arg)}}}function L(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,L(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=f(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function k(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(_typeof(t)+" is not iterable")}return g.prototype=b,o(j,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,u,"GeneratorFunction")),e.prototype=Object.create(j),e},t.awrap=function(e){return{__await:e}},O(S.prototype),s(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new S(l(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(j),s(j,u,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=k,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(E),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){asyncGeneratorStep(a,n,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,n,o,i,c,"throw",e)}i(void 0)}))}}import{addApi,queryApi,removeApi,updateApi}from"./service.js";import{PlusOutlined}from"@ant-design/icons";import ProTable from"@ant-design/pro-table";import{ROOT_ID,toTree}from"@zhengxs/js.tree";import{Button,Divider,Popconfirm,message}from"antd";import React,{useRef,useState}from"react";import UpdateForm from"./components/UpdateForm";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=message.loading("正在添加"),"C"!==r){e.next=7;break}return e.next=4,addApi(_objectSpread({},t));case 4:e.t0=e.sent,e.next=10;break;case 7:return e.next=9,updateApi(_objectSpread({},t));case 9:e.t0=e.sent;case 10:if(o=e.t0,n(),!o){e.next=15;break}return message.success("操作成功!"),e.abrupt("return",!0);case 15:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=!1,n=message.loading("正在删除"),e.next=4,removeApi(t);case 4:return"000000"===(o=e.sent).rspCode?(n(),message.success("删除成功,正在刷新"),r=!0):(message.error(o.rspMsg),r=!1),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getData=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryApi(t);case 2:if(!(r=e.sent)){e.next=5;break}return e.abrupt("return",r.data);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),deepData=function e(t){return t.forEach((function(t){var r;(null==t||null===(r=t.children)||void 0===r?void 0:r.length)>0?e(t.children):delete t.children})),t},DictionaryList=function(){var e=_slicedToArray(useState(!1),2),t=e[0],r=e[1],n=_slicedToArray(useState({}),2),o=n[0],a=n[1],i=_slicedToArray(useState([]),2),c=i[0],u=i[1],s=_slicedToArray(useState([]),2),l=s[0],f=s[1],p=_slicedToArray(useState("C"),2),d=p[0],y=p[1],h=useRef(),m=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,n){var o,i,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("U"!==t){e.next=11;break}return o=message.loading("正在加载"),e.next=4,getData({dictCode:n.dictCode,include:!0});case 4:i=e.sent,o(),(u=JSON.parse(JSON.stringify(c))).forEach((function(e,t){i.forEach((function(t){e.id===t.id&&(e.disabled=!0)}))})),f(g(u)),e.next=12;break;case 11:f(g(c));case 12:y(t),a(n),r(!0);case 15:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),v=function(){r(!1),a({})},g=function(e){return toTree(e,{root:ROOT_ID,idKey:"id",parentKey:"parentId",childrenKey:"children",transform:function(t){return!e.some((function(e){return"-1"===e.id}))&&"-1"===t.parentId&&(t.parentId=null),_objectSpread(_objectSpread({},t),{},{title:t.dictName,value:t.id})}})},b=[{title:"字典名称",dataIndex:"dictName",search:!0},{title:"字典编码",dataIndex:"dictCode",search:!1},{title:"备注",dataIndex:"remark",search:!1},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,t){return"BASE_DICT_ROOT"!==t.dictCode&&_jsxs(_Fragment,{children:[_jsx("a",{onClick:function(){return m("U",t)},children:"编辑"}),_jsx(Divider,{type:"vertical"}),_jsx(Popconfirm,{title:"确定删除吗?",onConfirm:_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleRemove(t);case 2:if(!e.sent||!h.current){e.next=8;break}return e.next=6,h.current.reset();case 6:return e.next=8,h.current.reload();case 8:case"end":return e.stop()}}),e)}))),children:_jsx("a",{href:"#",className:"ant-btn-dangerous",children:"删除"})})]})}}];return _jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"列表",actionRef:h,rowKey:"id",defaultExpandedRowKeys:["-1"],toolBarRender:function(){return[_jsxs(Button,{type:"primary",onClick:function(){return m("C",{})},children:[_jsx(PlusOutlined,{})," 新建"]})]},beforeSearchSubmit:function(e){return{dictName:e.dictName||"",include:!0}},request:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:{},e.next=3,getData(_objectSpread(_objectSpread({},t),{},{allTree:!0,include:!0}));case 3:if(!(r=e.sent)){e.next=9;break}return r.map((function(e){return e.dictName===t.dictName&&(e.parentId=null),e})),u(r),n=deepData(g(r)),e.abrupt("return",{data:n,success:!0});case 9:return e.abrupt("return",{data:[]});case 10:case"end":return e.stop()}}),e)}))),pagination:!1,columns:b}),t?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleAdd(t,d);case 2:e.sent&&(v(),h.current&&h.current.reload());case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),onCancel:v,type:d,updateModalVisible:t,values:o,treeData:l}):null]})};export default DictionaryList;
|
|
1
|
+
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,i=Object.create(a.prototype),c=new P(n||[]);return o(i,"_invoke",{value:T(e,r,c)}),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var p="suspendedStart",d="suspendedYield",y="executing",h="completed",m={};function v(){}function g(){}function b(){}var _={};s(_,i,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(k([])));x&&x!==r&&n.call(x,i)&&(_=x);var j=b.prototype=v.prototype=Object.create(_);function O(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,a,i,c){var u=l(e[o],e,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==_typeof(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,i,c)}),(function(e){r("throw",e,i,c)})):t.resolve(f).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function T(t,r,n){var o=p;return function(a,i){if(o===y)throw new Error("Generator is already running");if(o===h){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=L(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=l(t,r,n);if("normal"===s.type){if(o=n.done?h:d,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=h,n.method="throw",n.arg=s.arg)}}}function L(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,L(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function k(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(_typeof(t)+" is not iterable")}return g.prototype=b,o(j,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,u,"GeneratorFunction")),e.prototype=Object.create(j),e},t.awrap=function(e){return{__await:e}},O(S.prototype),s(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new S(f(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(j),s(j,u,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=k,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(E),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){asyncGeneratorStep(a,n,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,n,o,i,c,"throw",e)}i(void 0)}))}}import{addApi,queryApi,removeApi,updateApi}from"./service.js";import{PlusOutlined}from"@ant-design/icons";import{ProTable}from"@ant-design/pro-components";import{ROOT_ID,toTree}from"@zhengxs/js.tree";import{Button,Divider,Popconfirm,message}from"antd";import React,{useRef,useState}from"react";import UpdateForm from"./components/UpdateForm";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var handleAdd=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=message.loading("正在添加"),"C"!==r){e.next=7;break}return e.next=4,addApi(_objectSpread({},t));case 4:e.t0=e.sent,e.next=10;break;case 7:return e.next=9,updateApi(_objectSpread({},t));case 9:e.t0=e.sent;case 10:if(o=e.t0,n(),!o){e.next=15;break}return message.success("操作成功!"),e.abrupt("return",!0);case 15:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),handleRemove=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=!1,n=message.loading("正在删除"),e.next=4,removeApi(t);case 4:return"000000"===(o=e.sent).rspCode?(n(),message.success("删除成功,正在刷新"),r=!0):(message.error(o.rspMsg),r=!1),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getData=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,queryApi(t);case 2:if(!(r=e.sent)){e.next=5;break}return e.abrupt("return",r.data);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),deepData=function e(t){return t.forEach((function(t){var r;(null==t||null===(r=t.children)||void 0===r?void 0:r.length)>0?e(t.children):delete t.children})),t},DictionaryList=function(){var e=_slicedToArray(useState(!1),2),t=e[0],r=e[1],n=_slicedToArray(useState({}),2),o=n[0],a=n[1],i=_slicedToArray(useState([]),2),c=i[0],u=i[1],s=_slicedToArray(useState([]),2),f=s[0],l=s[1],p=_slicedToArray(useState("C"),2),d=p[0],y=p[1],h=useRef(),m=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,n){var o,i,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("U"!==t){e.next=11;break}return o=message.loading("正在加载"),e.next=4,getData({dictCode:n.dictCode,include:!0});case 4:i=e.sent,o(),(u=JSON.parse(JSON.stringify(c))).forEach((function(e,t){i.forEach((function(t){e.id===t.id&&(e.disabled=!0)}))})),l(g(u)),e.next=12;break;case 11:l(g(c));case 12:y(t),a(n),r(!0);case 15:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),v=function(){r(!1),a({})},g=function(e){return toTree(e,{root:ROOT_ID,idKey:"id",parentKey:"parentId",childrenKey:"children",transform:function(t){return!e.some((function(e){return"-1"===e.id}))&&"-1"===t.parentId&&(t.parentId=null),_objectSpread(_objectSpread({},t),{},{title:t.dictName,value:t.id})}})},b=[{title:"字典名称",dataIndex:"dictName",search:!0},{title:"字典编码",dataIndex:"dictCode",search:!1},{title:"备注",dataIndex:"remark",search:!1},{title:"操作",dataIndex:"option",valueType:"option",render:function(e,t){return"BASE_DICT_ROOT"!==t.dictCode&&_jsxs(_Fragment,{children:[_jsx("a",{onClick:function(){return m("U",t)},children:"编辑"}),_jsx(Divider,{type:"vertical"}),_jsx(Popconfirm,{title:"确定删除吗?",onConfirm:_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleRemove(t);case 2:if(!e.sent||!h.current){e.next=8;break}return e.next=6,h.current.reset();case 6:return e.next=8,h.current.reload();case 8:case"end":return e.stop()}}),e)}))),children:_jsx("a",{href:"#",className:"ant-btn-dangerous",children:"删除"})})]})}}];return _jsxs(_Fragment,{children:[_jsx(ProTable,{headerTitle:"列表",actionRef:h,rowKey:"id",defaultExpandedRowKeys:["-1"],toolBarRender:function(){return[_jsxs(Button,{type:"primary",onClick:function(){return m("C",{})},children:[_jsx(PlusOutlined,{})," 新建"]})]},beforeSearchSubmit:function(e){return{dictName:e.dictName||"",include:!0}},request:_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:{},e.next=3,getData(_objectSpread(_objectSpread({},t),{},{allTree:!0,include:!0}));case 3:if(!(r=e.sent)){e.next=9;break}return r.map((function(e){return e.dictName===t.dictName&&(e.parentId=null),e})),u(r),n=deepData(g(r)),e.abrupt("return",{data:n,success:!0});case 9:return e.abrupt("return",{data:[]});case 10:case"end":return e.stop()}}),e)}))),pagination:!1,columns:b}),t?_jsx(UpdateForm,{onSubmit:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,handleAdd(t,d);case 2:e.sent&&(v(),h.current&&h.current.reload());case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),onCancel:v,type:d,updateModalVisible:t,values:o,treeData:f}):null]})};export default DictionaryList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{l({},"")}catch(e){l=function(e,r,t){return e[r]=t}}function u(e,r,t,n){var i=r&&r.prototype instanceof _?r:_,a=Object.create(i.prototype),c=new A(n||[]);return o(a,"_invoke",{value:O(e,t,c)}),a}function d(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=u;var f="suspendedStart",p="suspendedYield",y="executing",h="completed",m={};function _(){}function g(){}function v(){}var b={};l(b,a,(function(){return this}));var x=Object.getPrototypeOf,j=x&&x(x(k([])));j&&j!==t&&n.call(j,a)&&(b=j);var w=v.prototype=_.prototype=Object.create(b);function T(e){["next","throw","return"].forEach((function(r){l(e,r,(function(e){return this._invoke(r,e)}))}))}function S(e,r){function t(o,i,a,c){var s=d(e[o],e,i);if("throw"!==s.type){var l=s.arg,u=l.value;return u&&"object"==_typeof(u)&&n.call(u,"__await")?r.resolve(u.__await).then((function(e){t("next",e,a,c)}),(function(e){t("throw",e,a,c)})):r.resolve(u).then((function(e){l.value=e,a(l)}),(function(e){return t("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return i=i?i.then(o,o):o()}})}function O(r,t,n){var o=f;return function(i,a){if(o===y)throw new Error("Generator is already running");if(o===h){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=P(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=d(r,t,n);if("normal"===l.type){if(o=n.done?h:p,l.arg===m)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=h,n.method="throw",n.arg=l.arg)}}}function P(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,P(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=d(o,r.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,m;var a=i.arg;return a?a.done?(t[r.resultName]=a.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,m):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function I(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function C(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function k(r){if(r||""===r){var t=r[a];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,i=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return i.next=i}}throw new TypeError(_typeof(r)+" is not iterable")}return g.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:g,configurable:!0}),g.displayName=l(v,s,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,l(e,s,"GeneratorFunction")),e.prototype=Object.create(w),e},r.awrap=function(e){return{__await:e}},T(S.prototype),l(S.prototype,c,(function(){return this})),r.AsyncIterator=S,r.async=function(e,t,n,o,i){void 0===i&&(i=Promise);var a=new S(u(e,t,n,o),i);return r.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},T(w),l(w,s,"Generator"),l(w,a,(function(){return this})),l(w,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=k,A.prototype={constructor:A,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(C),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return c.type="throw",c.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(s&&l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),C(t),m}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;C(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:k(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),m}},r}function asyncGeneratorStep(e,r,t,n,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,o)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var i=e.apply(r,t);function a(e){asyncGeneratorStep(i,n,o,a,c,"next",e)}function c(e){asyncGeneratorStep(i,n,o,a,c,"throw",e)}a(void 0)}))}}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,i,a,c=[],s=!0,l=!1;try{if(i=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;s=!1}else for(;!(s=(n=i.call(t)).done)&&(c.push(n.value),c.length!==r);s=!0);}catch(e){l=!0,o=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}import OrgTree from"./components/OrgTree";import{asyncCallback,formatFormItem,handleTableResponse}from"../../utils/utils.js";import{ArrowDownOutlined,ArrowUpOutlined,DeleteOutlined,EditOutlined,PlusOutlined}from"@ant-design/icons";import{Button,Card,Col,Descriptions,Divider,Empty,Input,Modal,Popconfirm,Row,Space,Spin,ConfigProvider}from"antd";import moment from"moment";import React,{useEffect,useReducer,useRef,useState}from"react";import CreatePeopleForm from"./components/CreatePeopleForm";import CreateSubStoreForm from"./components/CreateSubStoreForm";import"antd/dist/antd.css";import zhCN from"antd/es/locale/zh_CN";import{deleteOrganization,deletePerson,initPassword,queryOrgPeoplePage,queryOrganizationInfo,queryBaseDictList,queryRole}from"./service";import"./styles.less";import ProTable from"@ant-design/pro-table";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var orgTypeFormat=function(e){var r="";return"1"===e?r="疾控中心":"2"===e?r="行政区":"3"===e?r="教育局":"4"===e?r="卫生院":"5"===e?r="街道":"6"===e?r="学校":"10"===e?r="商家":"8"===e?r="社区":"9"===e?r="供应商":"10"===e?r="商家":"11"===e?r="成人学校":"12"===e?r="培训机构":"13"===e?r="小区":"30"===e&&(r="医疗机构"),r},Search=Input.Search,NONES=["",null,void 0],Organization=function(e){var r=useRef(),t=useRef(),n=_slicedToArray(useState(!1),2),o=n[0],i=n[1],a=_slicedToArray(useState(!1),2),c=a[0],s=a[1],l=_slicedToArray(useState(!1),2),u=l[0],d=l[1],f=_slicedToArray(useReducer((function(e){return e+1}),1),2),p=f[0],y=f[1],h=_slicedToArray(useState("C"),2),m=h[0],_=h[1],g=_slicedToArray(useState(!1),2),v=g[0],b=g[1],x=_slicedToArray(useState("C"),2),j=x[0],w=x[1],T=_slicedToArray(useState({}),2),S=T[0],O=T[1],P=_slicedToArray(useState([]),2),I=P[0],C=P[1],A=_slicedToArray(useState([]),2),k=A[0],D=A[1],R=_slicedToArray(useState([]),2),E=R[0],L=R[1],N=_slicedToArray(useState({}),2),F=N[0],G=N[1],Y=_slicedToArray(useState(""),2),z=Y[0],M=Y[1],q=_slicedToArray(useReducer((function(e){return e+1}),1),2),B=q[0],K=q[1];useEffect((function(){H("ORG_TYPE",C),W()}),[]),useEffect((function(){console.log("🚀 ~ Organization ~ selectedKey:",z),F.id&&U(F.id)}),[p]);var H=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={dictCode:r,include:!1},e.next=3,queryBaseDictList(n);case 3:o=e.sent,asyncCallback(o,!1)&&t(o.data);case 6:case"end":return e.stop()}}),e)})));return function(r,t){return e.apply(this,arguments)}}(),W=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,t,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},e.next=3,queryRole(r);case 3:t=e.sent,asyncCallback(t,!1)&&(D(null===(n=t.data)||void 0===n?void 0:n.data),console.log("🚀 ~ handleQueryRole ~ res.data:",t.data));case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),U=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={id:r},e.next=3,queryOrganizationInfo(t);case 3:n=e.sent,asyncCallback(n,!1)&&(o=_objectSpread(_objectSpread({},n.data),{},{id:r}),O(o));case 6:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),V=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i(!0),e.next=3,deleteOrganization({id:S.id});case 3:if(r=e.sent,i(!1),asyncCallback(r,!0)){e.next=8;break}return e.abrupt("return");case 8:K();case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i(!0),e.next=3,deletePerson({id:t.id});case 3:if(n=e.sent,i(!1),asyncCallback(n,!0)){e.next=8;break}return e.abrupt("return");case 8:r.current.reload();case 9:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),$=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.id,e.next=3,initPassword({id:t});case 3:n=e.sent,asyncCallback(n,!0);case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),J=[{title:"姓名",dataIndex:"realname",align:"center",valueType:"input",formItemProps:{name:"key",label:"搜索"},fieldProps:{placeholder:"姓名/手机号"}},{title:"用户名",dataIndex:"username",align:"center",hideInSearch:!0},{title:"性别",dataIndex:"gender",align:"center",render:function(e,r){return 1==e?"男":2==e?"女":"-"},hideInSearch:!0},{title:"出生日期",dataIndex:"birthday",align:"center",render:function(e,r){return r.birthday?moment(r.birthday).format("YYYY-MM-DD"):"-"},hideInSearch:!0},{title:"过期时间",dataIndex:"expiredTime",align:"center",render:function(e,r){return r.expiredTime?moment(r.expiredTime).format("YYYY-MM-DD HH:mm:ss"):"-"},hideInSearch:!0},{title:"操作",dataIndex:"action",align:"center",hideInSearch:!0,render:function(e,r){return _jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:[_jsx("a",{className:"textGreen",onClick:function(){Modal.confirm({title:"提示",content:_jsxs("div",{children:["请确认重置密码,初始密码为:",_jsx("span",{style:{color:"red"},children:"Wljsydh@123"}),_jsx("div",{style:{color:"#1F5AD8"},children:"第一个字母大写,其余小写"})]}),okText:"确认",cancelText:"取消",onOk:function(){$(r)},onCancel:function(){}})},children:"初始化密码"}),_jsx("a",{onClick:function(){return ee(!0,r,"L")},children:"查看详情"}),_jsx(Popconfirm,{title:"是否删除该人员?",onConfirm:function(){return Q(r)},children:_jsx(Button,{type:"link",id:"equipment_delete_btn",danger:!0,children:"删除"})})]})}}],X=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.log("🚀 ~ handleTreeSelect ~ orgItem:",t),t?(G(t),M(null==t?void 0:t.orgCode),U(null==t?void 0:t.id),setTimeout((function(){var e;null===(e=r.current)||void 0===e||e.reload()}),200)):(M(""),G({}));case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),Z=function(e,r){s(!!e),w(r)},ee=function(e,r,t){d(e),_(t),L(r)},re=function(e){b(e)},te=_jsxs(Space,{children:[_jsx(Button,{icon:_jsx(EditOutlined,{}),type:"primary",ghost:!0,onClick:function(){return Z(!0,"U")},children:"编辑机构详情"}),_jsx(Popconfirm,{title:"是否删除该机构?",onConfirm:function(){return V()},children:_jsx(Button,{icon:_jsx(DeleteOutlined,{}),type:"danger",id:"equipment_delete_btn",children:"删除机构"})})]});return _jsxs(ConfigProvider,{locale:zhCN,children:[_jsxs(Row,{gutter:24,className:"org-box",children:[_jsx(Col,{span:8,children:_jsx(OrgTree,{onTreeSelect:X,reloadTree:B,getSelectedKey:z,extra:_jsx(Button,{icon:_jsx(PlusOutlined,{}),size:"small",type:"primary",onClick:function(){return Z(!0,"C")},disabled:!["2","5","8"].includes(null==S?void 0:S.orgType),children:"新增下属机构"})})}),_jsx(Col,{span:16,children:_jsx(_Fragment,{children:_jsx(Spin,{spinning:o,children:z?_jsxs("div",{className:"org-content",children:[_jsxs(Card,{title:"机构信息",bordered:!1,extra:te,children:[_jsxs(Descriptions,{span:2,size:"middle",children:[_jsx(Descriptions.Item,{label:"机构名称",children:S.orgName}),_jsx(Descriptions.Item,{label:"机构编号",children:S.orgCode}),_jsx(Descriptions.Item,{label:"机构类型",children:orgTypeFormat(S.orgType)}),_jsx(Descriptions.Item,{label:"负责人",children:S.liablePerson}),_jsx(Descriptions.Item,{label:"联系方式",children:S.telephone}),_jsx(Descriptions.Item,{label:"地址",children:S.address}),_jsx(Descriptions.Item,{label:"经度",children:S.longitude}),_jsx(Descriptions.Item,{label:"纬度",children:S.latitude}),["1","3","4","6"].includes(S.orgType)&&_jsx(Descriptions.Item,{label:"所属街道",children:S.streetName}),"6"===S.orgType&&_jsx(Descriptions.Item,{label:"关联卫生院",children:S.hospitalName}),v&&_jsxs(_Fragment,{children:[_jsx(Descriptions.Item,{label:"单位具体地址",children:S.minuteAddress}),_jsx(Descriptions.Item,{label:"单位负责人联系电话",children:S.liablePersonTelePhone}),_jsx(Descriptions.Item,{label:"邮政编码",children:S.postCode}),_jsx(Descriptions.Item,{label:"录入日期",children:!NONES.includes(S.inputdate)&&moment(S.inputdate).format("YYYY-MM-DD")}),_jsx(Descriptions.Item,{label:"上报日期",children:!NONES.includes(S.reportdate)&&moment(S.reportdate).format("YYYY-MM-DD")}),_jsx(Descriptions.Item,{label:"录入人姓名",children:S.nameCreate})]})]}),_jsx("div",{style:{textAlign:"center"},children:_jsx("a",v?{onClick:function(){return re(!1)},children:_jsxs(Space,{children:[_jsx(ArrowUpOutlined,{}),"收起更多信息"]})}:{onClick:function(){return re(!0)},children:_jsxs(Space,{children:[_jsx(ArrowDownOutlined,{}),"查看更多信息"]})})})]}),_jsx(ProTable,{actionRef:r,formRef:t,headerTitle:"人员列表",rowKey:"id",search:{collapsed:!1,collapseRender:!1,optionRender:function(e,r,t){return[].concat(_toConsumableArray(t.reverse()),[_jsx(Button,{icon:_jsx(PlusOutlined,{}),type:"primary",onClick:function(){return ee(!0,{},"C")},children:"新增人员"})])}},toolBarRender:!1,request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(z){e.next=2;break}return e.abrupt("return");case 2:return t.orgCode=F.orgCode,n=formatFormItem(t),e.next=6,queryOrgPeoplePage(n);case 6:return o=e.sent,e.abrupt("return",handleTableResponse({actionRef:r,res:o}));case 8:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),columns:J,rowSelection:!1})]}):_jsx(Card,{className:"org-empryCard",children:_jsx(Empty,{description:"请选择机构"})})})})})]}),c&&_jsx(CreateSubStoreForm,{modalHandleVisible:Z,modalVisible:c,modalOrgType:j,modalFreshOrgTree:K,modalFreshOrgDtl:y,modalPersonTypes:I,modalTreeItemDtl:S}),u&&_jsx(CreatePeopleForm,{handleModalVisible:function(){return d(!1)},modalVisible:u,currentOrg:S,peopleAttrData:k,modalFreshPeople:r,mType:m,mItem:E})]})};export default Organization;
|
|
1
|
+
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{l({},"")}catch(e){l=function(e,r,t){return e[r]=t}}function u(e,r,t,n){var i=r&&r.prototype instanceof _?r:_,a=Object.create(i.prototype),c=new A(n||[]);return o(a,"_invoke",{value:O(e,t,c)}),a}function d(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=u;var f="suspendedStart",p="suspendedYield",y="executing",h="completed",m={};function _(){}function g(){}function v(){}var b={};l(b,a,(function(){return this}));var x=Object.getPrototypeOf,j=x&&x(x(k([])));j&&j!==t&&n.call(j,a)&&(b=j);var w=v.prototype=_.prototype=Object.create(b);function T(e){["next","throw","return"].forEach((function(r){l(e,r,(function(e){return this._invoke(r,e)}))}))}function S(e,r){function t(o,i,a,c){var s=d(e[o],e,i);if("throw"!==s.type){var l=s.arg,u=l.value;return u&&"object"==_typeof(u)&&n.call(u,"__await")?r.resolve(u.__await).then((function(e){t("next",e,a,c)}),(function(e){t("throw",e,a,c)})):r.resolve(u).then((function(e){l.value=e,a(l)}),(function(e){return t("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return i=i?i.then(o,o):o()}})}function O(r,t,n){var o=f;return function(i,a){if(o===y)throw new Error("Generator is already running");if(o===h){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=P(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=d(r,t,n);if("normal"===l.type){if(o=n.done?h:p,l.arg===m)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=h,n.method="throw",n.arg=l.arg)}}}function P(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,P(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=d(o,r.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,m;var a=i.arg;return a?a.done?(t[r.resultName]=a.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,m):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function I(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function C(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function k(r){if(r||""===r){var t=r[a];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,i=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return i.next=i}}throw new TypeError(_typeof(r)+" is not iterable")}return g.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:g,configurable:!0}),g.displayName=l(v,s,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,l(e,s,"GeneratorFunction")),e.prototype=Object.create(w),e},r.awrap=function(e){return{__await:e}},T(S.prototype),l(S.prototype,c,(function(){return this})),r.AsyncIterator=S,r.async=function(e,t,n,o,i){void 0===i&&(i=Promise);var a=new S(u(e,t,n,o),i);return r.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},T(w),l(w,s,"Generator"),l(w,a,(function(){return this})),l(w,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=k,A.prototype={constructor:A,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(C),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return c.type="throw",c.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(s&&l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),C(t),m}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;C(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:k(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),m}},r}function asyncGeneratorStep(e,r,t,n,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,o)}function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var i=e.apply(r,t);function a(e){asyncGeneratorStep(i,n,o,a,c,"next",e)}function c(e){asyncGeneratorStep(i,n,o,a,c,"throw",e)}a(void 0)}))}}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,i,a,c=[],s=!0,l=!1;try{if(i=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;s=!1}else for(;!(s=(n=i.call(t)).done)&&(c.push(n.value),c.length!==r);s=!0);}catch(e){l=!0,o=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}import OrgTree from"./components/OrgTree";import{asyncCallback,formatFormItem,handleTableResponse}from"../../utils/utils.js";import{ArrowDownOutlined,ArrowUpOutlined,DeleteOutlined,EditOutlined,PlusOutlined}from"@ant-design/icons";import{Button,Card,Col,Descriptions,Divider,Empty,Input,Modal,Popconfirm,Row,Space,Spin,ConfigProvider}from"antd";import moment from"moment";import React,{useEffect,useReducer,useRef,useState}from"react";import CreatePeopleForm from"./components/CreatePeopleForm";import CreateSubStoreForm from"./components/CreateSubStoreForm";import"antd/dist/antd.css";import zhCN from"antd/es/locale/zh_CN";import{deleteOrganization,deletePerson,initPassword,queryOrgPeoplePage,queryOrganizationInfo,queryBaseDictList,queryRole}from"./service";import"./styles.less";import{ProTable}from"@ant-design/pro-components";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var orgTypeFormat=function(e){var r="";return"1"===e?r="疾控中心":"2"===e?r="行政区":"3"===e?r="教育局":"4"===e?r="卫生院":"5"===e?r="街道":"6"===e?r="学校":"10"===e?r="商家":"8"===e?r="社区":"9"===e?r="供应商":"10"===e?r="商家":"11"===e?r="成人学校":"12"===e?r="培训机构":"13"===e?r="小区":"30"===e&&(r="医疗机构"),r},Search=Input.Search,NONES=["",null,void 0],Organization=function(e){var r=useRef(),t=useRef(),n=_slicedToArray(useState(!1),2),o=n[0],i=n[1],a=_slicedToArray(useState(!1),2),c=a[0],s=a[1],l=_slicedToArray(useState(!1),2),u=l[0],d=l[1],f=_slicedToArray(useReducer((function(e){return e+1}),1),2),p=f[0],y=f[1],h=_slicedToArray(useState("C"),2),m=h[0],_=h[1],g=_slicedToArray(useState(!1),2),v=g[0],b=g[1],x=_slicedToArray(useState("C"),2),j=x[0],w=x[1],T=_slicedToArray(useState({}),2),S=T[0],O=T[1],P=_slicedToArray(useState([]),2),I=P[0],C=P[1],A=_slicedToArray(useState([]),2),k=A[0],D=A[1],R=_slicedToArray(useState([]),2),E=R[0],L=R[1],N=_slicedToArray(useState({}),2),F=N[0],G=N[1],Y=_slicedToArray(useState(""),2),z=Y[0],M=Y[1],q=_slicedToArray(useReducer((function(e){return e+1}),1),2),B=q[0],K=q[1];useEffect((function(){H("ORG_TYPE",C),W()}),[]),useEffect((function(){console.log("🚀 ~ Organization ~ selectedKey:",z),F.id&&U(F.id)}),[p]);var H=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r,t){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={dictCode:r,include:!1},e.next=3,queryBaseDictList(n);case 3:o=e.sent,asyncCallback(o,!1)&&t(o.data);case 6:case"end":return e.stop()}}),e)})));return function(r,t){return e.apply(this,arguments)}}(),W=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,t,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},e.next=3,queryRole(r);case 3:t=e.sent,asyncCallback(t,!1)&&(D(null===(n=t.data)||void 0===n?void 0:n.data),console.log("🚀 ~ handleQueryRole ~ res.data:",t.data));case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),U=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={id:r},e.next=3,queryOrganizationInfo(t);case 3:n=e.sent,asyncCallback(n,!1)&&(o=_objectSpread(_objectSpread({},n.data),{},{id:r}),O(o));case 6:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),V=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i(!0),e.next=3,deleteOrganization({id:S.id});case 3:if(r=e.sent,i(!1),asyncCallback(r,!0)){e.next=8;break}return e.abrupt("return");case 8:K();case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i(!0),e.next=3,deletePerson({id:t.id});case 3:if(n=e.sent,i(!1),asyncCallback(n,!0)){e.next=8;break}return e.abrupt("return");case 8:r.current.reload();case 9:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),$=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var t,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.id,e.next=3,initPassword({id:t});case 3:n=e.sent,asyncCallback(n,!0);case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),J=[{title:"姓名",dataIndex:"realname",align:"center",valueType:"input",formItemProps:{name:"key",label:"搜索"},fieldProps:{placeholder:"姓名/手机号"}},{title:"用户名",dataIndex:"username",align:"center",hideInSearch:!0},{title:"性别",dataIndex:"gender",align:"center",render:function(e,r){return 1==e?"男":2==e?"女":"-"},hideInSearch:!0},{title:"出生日期",dataIndex:"birthday",align:"center",render:function(e,r){return r.birthday?moment(r.birthday).format("YYYY-MM-DD"):"-"},hideInSearch:!0},{title:"过期时间",dataIndex:"expiredTime",align:"center",render:function(e,r){return r.expiredTime?moment(r.expiredTime).format("YYYY-MM-DD HH:mm:ss"):"-"},hideInSearch:!0},{title:"操作",dataIndex:"action",align:"center",hideInSearch:!0,render:function(e,r){return _jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:[_jsx("a",{className:"textGreen",onClick:function(){Modal.confirm({title:"提示",content:_jsxs("div",{children:["请确认重置密码,初始密码为:",_jsx("span",{style:{color:"red"},children:"Wljsydh@123"}),_jsx("div",{style:{color:"#1F5AD8"},children:"第一个字母大写,其余小写"})]}),okText:"确认",cancelText:"取消",onOk:function(){$(r)},onCancel:function(){}})},children:"初始化密码"}),_jsx("a",{onClick:function(){return ee(!0,r,"L")},children:"查看详情"}),_jsx(Popconfirm,{title:"是否删除该人员?",onConfirm:function(){return Q(r)},children:_jsx(Button,{type:"link",id:"equipment_delete_btn",danger:!0,children:"删除"})})]})}}],X=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.log("🚀 ~ handleTreeSelect ~ orgItem:",t),t?(G(t),M(null==t?void 0:t.orgCode),U(null==t?void 0:t.id),setTimeout((function(){var e;null===(e=r.current)||void 0===e||e.reload()}),200)):(M(""),G({}));case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),Z=function(e,r){s(!!e),w(r)},ee=function(e,r,t){d(e),_(t),L(r)},re=function(e){b(e)},te=_jsxs(Space,{children:[_jsx(Button,{icon:_jsx(EditOutlined,{}),type:"primary",ghost:!0,onClick:function(){return Z(!0,"U")},children:"编辑机构详情"}),_jsx(Popconfirm,{title:"是否删除该机构?",onConfirm:function(){return V()},children:_jsx(Button,{icon:_jsx(DeleteOutlined,{}),type:"danger",id:"equipment_delete_btn",children:"删除机构"})})]});return _jsxs(ConfigProvider,{locale:zhCN,children:[_jsxs(Row,{gutter:24,className:"org-box",children:[_jsx(Col,{span:8,children:_jsx(OrgTree,{onTreeSelect:X,reloadTree:B,getSelectedKey:z,extra:_jsx(Button,{icon:_jsx(PlusOutlined,{}),size:"small",type:"primary",onClick:function(){return Z(!0,"C")},disabled:!["2","5","8"].includes(null==S?void 0:S.orgType),children:"新增下属机构"})})}),_jsx(Col,{span:16,children:_jsx(_Fragment,{children:_jsx(Spin,{spinning:o,children:z?_jsxs("div",{className:"org-content",children:[_jsxs(Card,{title:"机构信息",bordered:!1,extra:te,children:[_jsxs(Descriptions,{span:2,size:"middle",children:[_jsx(Descriptions.Item,{label:"机构名称",children:S.orgName}),_jsx(Descriptions.Item,{label:"机构编号",children:S.orgCode}),_jsx(Descriptions.Item,{label:"机构类型",children:orgTypeFormat(S.orgType)}),_jsx(Descriptions.Item,{label:"负责人",children:S.liablePerson}),_jsx(Descriptions.Item,{label:"联系方式",children:S.telephone}),_jsx(Descriptions.Item,{label:"地址",children:S.address}),_jsx(Descriptions.Item,{label:"经度",children:S.longitude}),_jsx(Descriptions.Item,{label:"纬度",children:S.latitude}),["1","3","4","6"].includes(S.orgType)&&_jsx(Descriptions.Item,{label:"所属街道",children:S.streetName}),"6"===S.orgType&&_jsx(Descriptions.Item,{label:"关联卫生院",children:S.hospitalName}),v&&_jsxs(_Fragment,{children:[_jsx(Descriptions.Item,{label:"单位具体地址",children:S.minuteAddress}),_jsx(Descriptions.Item,{label:"单位负责人联系电话",children:S.liablePersonTelePhone}),_jsx(Descriptions.Item,{label:"邮政编码",children:S.postCode}),_jsx(Descriptions.Item,{label:"录入日期",children:!NONES.includes(S.inputdate)&&moment(S.inputdate).format("YYYY-MM-DD")}),_jsx(Descriptions.Item,{label:"上报日期",children:!NONES.includes(S.reportdate)&&moment(S.reportdate).format("YYYY-MM-DD")}),_jsx(Descriptions.Item,{label:"录入人姓名",children:S.nameCreate})]})]}),_jsx("div",{style:{textAlign:"center"},children:_jsx("a",v?{onClick:function(){return re(!1)},children:_jsxs(Space,{children:[_jsx(ArrowUpOutlined,{}),"收起更多信息"]})}:{onClick:function(){return re(!0)},children:_jsxs(Space,{children:[_jsx(ArrowDownOutlined,{}),"查看更多信息"]})})})]}),_jsx(ProTable,{actionRef:r,formRef:t,headerTitle:"人员列表",rowKey:"id",search:{collapsed:!1,collapseRender:!1,optionRender:function(e,r,t){return[].concat(_toConsumableArray(t.reverse()),[_jsx(Button,{icon:_jsx(PlusOutlined,{}),type:"primary",onClick:function(){return ee(!0,{},"C")},children:"新增人员"})])}},toolBarRender:!1,request:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(z){e.next=2;break}return e.abrupt("return");case 2:return t.orgCode=F.orgCode,n=formatFormItem(t),e.next=6,queryOrgPeoplePage(n);case 6:return o=e.sent,e.abrupt("return",handleTableResponse({actionRef:r,res:o}));case 8:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),columns:J,rowSelection:!1})]}):_jsx(Card,{className:"org-empryCard",children:_jsx(Empty,{description:"请选择机构"})})})})})]}),c&&_jsx(CreateSubStoreForm,{modalHandleVisible:Z,modalVisible:c,modalOrgType:j,modalFreshOrgTree:K,modalFreshOrgDtl:y,modalPersonTypes:I,modalTreeItemDtl:S}),u&&_jsx(CreatePeopleForm,{handleModalVisible:function(){return d(!1)},modalVisible:u,currentOrg:S,peopleAttrData:k,modalFreshPeople:r,mType:m,mItem:E})]})};export default Organization;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach((function(e){_defineProperty(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var a=e&&e.prototype instanceof v?e:v,i=Object.create(a.prototype),c=new E(n||[]);return o(i,"_invoke",{value:O(t,r,c)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",y="suspendedYield",h="executing",d="completed",m={};function v(){}function b(){}function g(){}var _={};s(_,i,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(A([])));x&&x!==r&&n.call(x,i)&&(_=x);var j=g.prototype=v.prototype=Object.create(_);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(o,a,i,c){var u=f(t[o],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function O(e,r,n){var o=p;return function(a,i){if(o===h)throw new Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=L(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?d:y,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function L(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,L(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=f(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function A(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(_typeof(e)+" is not iterable")}return b.prototype=g,o(j,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:b,configurable:!0}),b.displayName=s(g,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,u,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},S(P.prototype),s(P.prototype,c,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new P(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(j),s(j,u,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=A,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:A(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function asyncGeneratorStep(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){asyncGeneratorStep(a,n,o,i,c,"next",t)}function c(t){asyncGeneratorStep(a,n,o,i,c,"throw",t)}i(void 0)}))}}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}import{asyncCallback}from"../../../../utils/utils.js";import{PlusOutlined}from"@ant-design/icons";import ProTable from"@ant-design/pro-table";import{Button,Card,Divider,Modal,Space}from"antd";import React,{useRef,useState}from"react";import{addPerm,queryPerm,removePerm,updatePerm}from"../service.js";import UpdateForm from"./components/UpdateForm";import styles from"./styles.less";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var PermList=function(){var t=_slicedToArray(useState(!1),2),e=t[0],r=t[1],n=_slicedToArray(useState({}),2),o=n[0],a=n[1],i=_slicedToArray(useState("create"),2),c=i[0],u=i[1],s=useRef(),l=[{title:"名称",dataIndex:"keyString",hideInTable:!0,fieldProps:{placeholder:"请输入"}},{title:"模块",hideInSearch:!0,dataIndex:"permModule"},{title:"编码",hideInSearch:!0,dataIndex:"permCode"},{title:"名称",hideInSearch:!0,dataIndex:"permName"},{title:"操作",hideInSearch:!0,className:styles.minw110,render:function(t,e){return _jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:[_jsx("a",{onClick:function(){return y(!0,e)},children:"编辑"}),_jsx("a",{onClick:function(){return f(e)},className:"textRed",children:"删除"})]})}}],f=function(t){Modal.confirm({title:"警告",content:"确定删除吗?",okText:"确认",cancelText:"取消",onOk:function(){p(t)}})},p=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,removePerm(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:y(),s.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),y=function(t,e){a(void 0===e?{}:e),u(void 0===e?"create":"update"),r(!!t)},h=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,addPerm(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:m(),s.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),d=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,updatePerm(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:y(),s.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),m=function(){a({}),u(""),r(!1)},v={handleAdd:h,handleUpdate:d,onCancel:m};return _jsx(Card,{children:_jsxs("div",{className:styles.tableList,children:[_jsx(ProTable,{headerTitle:"权限列表",actionRef:s,rowKey:"id",toolBarRender:function(){return[_jsx(Button,{type:"danger",onClick:function(){return y(!0)},icon:_jsx(PlusOutlined,{}),children:"新建"})]},request:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,queryPerm(_objectSpread(_objectSpread({},e),{},{page:e.current}));case 2:return r=t.sent,t.abrupt("return",{data:r.data.list,success:!0,total:r.data.total});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),pagination:{showSizeChanger:!0},columns:l,rowSelection:!1}),e?_jsx(UpdateForm,_objectSpread(_objectSpread({},v),{},{modalVisible:e,currentItem:o,formType:c})):null]})})};export default PermList;
|
|
1
|
+
function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach((function(e){_defineProperty(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var a=e&&e.prototype instanceof v?e:v,i=Object.create(a.prototype),c=new E(n||[]);return o(i,"_invoke",{value:O(t,r,c)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",y="suspendedYield",h="executing",d="completed",m={};function v(){}function g(){}function b(){}var _={};s(_,i,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(A([])));x&&x!==r&&n.call(x,i)&&(_=x);var j=b.prototype=v.prototype=Object.create(_);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(o,a,i,c){var u=f(t[o],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function O(e,r,n){var o=p;return function(a,i){if(o===h)throw new Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=L(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?d:y,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function L(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,L(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=f(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function A(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(_typeof(e)+" is not iterable")}return g.prototype=b,o(j,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},S(P.prototype),s(P.prototype,c,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new P(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(j),s(j,u,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=A,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:A(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function asyncGeneratorStep(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){asyncGeneratorStep(a,n,o,i,c,"next",t)}function c(t){asyncGeneratorStep(a,n,o,i,c,"throw",t)}i(void 0)}))}}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}import{asyncCallback}from"../../../../utils/utils.js";import{PlusOutlined}from"@ant-design/icons";import{ProTable}from"@ant-design/pro-components";import{Button,Card,Divider,Modal,Space}from"antd";import React,{useRef,useState}from"react";import{addPerm,queryPerm,removePerm,updatePerm}from"../service.js";import UpdateForm from"./components/UpdateForm";import styles from"./styles.less";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var PermList=function(){var t=_slicedToArray(useState(!1),2),e=t[0],r=t[1],n=_slicedToArray(useState({}),2),o=n[0],a=n[1],i=_slicedToArray(useState("create"),2),c=i[0],u=i[1],s=useRef(),l=[{title:"名称",dataIndex:"keyString",hideInTable:!0,fieldProps:{placeholder:"请输入"}},{title:"模块",hideInSearch:!0,dataIndex:"permModule"},{title:"编码",hideInSearch:!0,dataIndex:"permCode"},{title:"名称",hideInSearch:!0,dataIndex:"permName"},{title:"操作",hideInSearch:!0,className:styles.minw110,render:function(t,e){return _jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:[_jsx("a",{onClick:function(){return y(!0,e)},children:"编辑"}),_jsx("a",{onClick:function(){return f(e)},className:"textRed",children:"删除"})]})}}],f=function(t){Modal.confirm({title:"警告",content:"确定删除吗?",okText:"确认",cancelText:"取消",onOk:function(){p(t)}})},p=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,removePerm(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:y(),s.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),y=function(t,e){a(void 0===e?{}:e),u(void 0===e?"create":"update"),r(!!t)},h=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,addPerm(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:m(),s.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),d=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,updatePerm(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:y(),s.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),m=function(){a({}),u(""),r(!1)},v={handleAdd:h,handleUpdate:d,onCancel:m};return _jsx(Card,{children:_jsxs("div",{className:styles.tableList,children:[_jsx(ProTable,{headerTitle:"权限列表",actionRef:s,rowKey:"id",toolBarRender:function(){return[_jsx(Button,{type:"danger",onClick:function(){return y(!0)},icon:_jsx(PlusOutlined,{}),children:"新建"})]},request:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,queryPerm(_objectSpread(_objectSpread({},e),{},{page:e.current}));case 2:return r=t.sent,t.abrupt("return",{data:r.data.list,success:!0,total:r.data.total});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),pagination:{showSizeChanger:!0},columns:l,rowSelection:!1}),e?_jsx(UpdateForm,_objectSpread(_objectSpread({},v),{},{modalVisible:e,currentItem:o,formType:c})):null]})})};export default PermList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach((function(e){_defineProperty(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var a=e&&e.prototype instanceof v?e:v,i=Object.create(a.prototype),c=new E(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",y="suspendedYield",h="executing",d="completed",m={};function v(){}function b(){}function g(){}var _={};s(_,i,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(R([])));x&&x!==r&&n.call(x,i)&&(_=x);var j=g.prototype=v.prototype=Object.create(_);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=f(t[o],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=p;return function(a,i){if(o===h)throw new Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=T(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?d:y,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function T(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,T(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=f(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(_typeof(e)+" is not iterable")}return b.prototype=g,o(j,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:b,configurable:!0}),b.displayName=s(g,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,u,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(j),s(j,u,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=R,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function asyncGeneratorStep(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){asyncGeneratorStep(a,n,o,i,c,"next",t)}function c(t){asyncGeneratorStep(a,n,o,i,c,"throw",t)}i(void 0)}))}}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}import React,{useState,useRef}from"react";import{history}from"umi";import{Card,Form,Button,Modal,Divider,Space}from"antd";import styles from"./styles.less";import{PlusOutlined}from"@ant-design/icons";import UpdateForm from"./components/UpdateForm";import{addRole,queryRole,removeRole,updateRole}from"../service.js";import{asyncCallback}from"../../../../utils/utils.js";import ProTable from"@ant-design/pro-table";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var PAGE_SIZE=10,RoleList=function(t){_slicedToArray(Form.useForm(),1)[0];var e=_slicedToArray(useState(!1),2),r=e[0],n=e[1],o=_slicedToArray(useState({}),2),a=o[0],i=o[1],c=_slicedToArray(useState("create"),2),u=c[0],s=c[1],l=useRef(),f=t.currentUser,p=[{title:"查询内容",dataIndex:"keyString",hideInTable:!0,fieldProps:{placeholder:"请输入名称"}},{title:"编码",dataIndex:"roleCode",hideInSearch:!0},{title:"名称",dataIndex:"roleName",hideInSearch:!0},{title:"操作",className:styles.w180,hideInSearch:!0,render:function(t,e){return"ADMIN"===f.userType||"SUPERADMIN"===f.userType?_jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:[_jsx("a",{onClick:function(){return y(e)},className:"textGreen",children:"设置权限"}),_jsx("a",{onClick:function(){return m(!0,e)},children:"编辑"}),_jsx("a",{onClick:function(){return h(e)},className:"textRed",children:"删除"})]}):_jsx("a",{onClick:function(){return y(e)},className:"textGreen",children:"查看权限"})}}],y=function(t){history.push({pathname:"/sso/permrole",query:{roleId:t.id}})},h=function(t){Modal.confirm({title:"警告",content:"确定删除吗?",okText:"确认",cancelText:"取消",onOk:function(){d(t)}})},d=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,removeRole(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:m(),l.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),m=function(t,e){var r=void 0===e?"create":"update";i(void 0===e?{}:e),s(r),n(!!t)},v=function(){i({}),s(""),n(!1)},b=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,addRole(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:v(),l.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),g=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,updateRole(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:m(),l.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),_={handleAdd:b,handleUpdate:g,onCancel:v};return _jsx(Card,{children:_jsxs("div",{className:styles.tableList,children:[_jsx(ProTable,{headerTitle:"角色列表",actionRef:l,rowKey:"id",toolBarRender:function(){return[_jsxs(Button,{type:"danger",onClick:function(){return m(!0)},children:[_jsx(PlusOutlined,{})," 新建"]})]},request:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,queryRole(_objectSpread(_objectSpread({},e),{},{page:e.current}));case 2:return r=t.sent,t.abrupt("return",{data:r.data.list,success:!0,total:r.data.total});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),pagination:{showSizeChanger:!0},columns:p,rowSelection:!1}),r?_jsx(UpdateForm,_objectSpread(_objectSpread({},_),{},{modalVisible:r,currentItem:a,formType:u})):null]})})};export default RoleList;
|
|
1
|
+
function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach((function(e){_defineProperty(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var a=e&&e.prototype instanceof v?e:v,i=Object.create(a.prototype),c=new E(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",y="suspendedYield",h="executing",d="completed",m={};function v(){}function g(){}function b(){}var _={};s(_,i,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(R([])));x&&x!==r&&n.call(x,i)&&(_=x);var j=b.prototype=v.prototype=Object.create(_);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=f(t[o],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=p;return function(a,i){if(o===h)throw new Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=T(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?d:y,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function T(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,T(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=f(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(_typeof(e)+" is not iterable")}return g.prototype=b,o(j,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(j),s(j,u,"Generator"),s(j,i,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=R,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function asyncGeneratorStep(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){asyncGeneratorStep(a,n,o,i,c,"next",t)}function c(t){asyncGeneratorStep(a,n,o,i,c,"throw",t)}i(void 0)}))}}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}import React,{useState,useRef}from"react";import{history}from"umi";import{Card,Form,Button,Modal,Divider,Space}from"antd";import styles from"./styles.less";import{PlusOutlined}from"@ant-design/icons";import UpdateForm from"./components/UpdateForm";import{addRole,queryRole,removeRole,updateRole}from"../service.js";import{asyncCallback}from"../../../../utils/utils.js";import{ProTable}from"@ant-design/pro-components";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var PAGE_SIZE=10,RoleList=function(t){_slicedToArray(Form.useForm(),1)[0];var e=_slicedToArray(useState(!1),2),r=e[0],n=e[1],o=_slicedToArray(useState({}),2),a=o[0],i=o[1],c=_slicedToArray(useState("create"),2),u=c[0],s=c[1],l=useRef(),f=t.currentUser,p=[{title:"查询内容",dataIndex:"keyString",hideInTable:!0,fieldProps:{placeholder:"请输入名称"}},{title:"编码",dataIndex:"roleCode",hideInSearch:!0},{title:"名称",dataIndex:"roleName",hideInSearch:!0},{title:"操作",className:styles.w180,hideInSearch:!0,render:function(t,e){return"ADMIN"===f.userType||"SUPERADMIN"===f.userType?_jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:[_jsx("a",{onClick:function(){return y(e)},className:"textGreen",children:"设置权限"}),_jsx("a",{onClick:function(){return m(!0,e)},children:"编辑"}),_jsx("a",{onClick:function(){return h(e)},className:"textRed",children:"删除"})]}):_jsx("a",{onClick:function(){return y(e)},className:"textGreen",children:"查看权限"})}}],y=function(t){history.push({pathname:"/sso/permrole",query:{roleId:t.id}})},h=function(t){Modal.confirm({title:"警告",content:"确定删除吗?",okText:"确认",cancelText:"取消",onOk:function(){d(t)}})},d=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,removeRole(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:m(),l.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),m=function(t,e){var r=void 0===e?"create":"update";i(void 0===e?{}:e),s(r),n(!!t)},v=function(){i({}),s(""),n(!1)},g=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,addRole(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:v(),l.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),b=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,updateRole(e);case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:m(),l.current.reload();case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),_={handleAdd:g,handleUpdate:b,onCancel:v};return _jsx(Card,{children:_jsxs("div",{className:styles.tableList,children:[_jsx(ProTable,{headerTitle:"角色列表",actionRef:l,rowKey:"id",toolBarRender:function(){return[_jsxs(Button,{type:"danger",onClick:function(){return m(!0)},children:[_jsx(PlusOutlined,{})," 新建"]})]},request:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,queryRole(_objectSpread(_objectSpread({},e),{},{page:e.current}));case 2:return r=t.sent,t.abrupt("return",{data:r.data.list,success:!0,total:r.data.total});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),pagination:{showSizeChanger:!0},columns:p,rowSelection:!1}),r?_jsx(UpdateForm,_objectSpread(_objectSpread({},_),{},{modalVisible:r,currentItem:a,formType:u})):null]})})};export default RoleList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var a=e&&e.prototype instanceof v?e:v,i=Object.create(a.prototype),c=new k(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",y="executing",d="completed",m={};function v(){}function g(){}function b(){}var x={};s(x,i,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(R([])));w&&w!==r&&n.call(w,i)&&(x=w);var T=b.prototype=v.prototype=Object.create(x);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function r(o,a,i,c){var u=f(t[o],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===y)throw new Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=I(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?d:p,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function I(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=f(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(_typeof(e)+" is not iterable")}return g.prototype=b,o(T,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(T),t},e.awrap=function(t){return{__await:t}},S(j.prototype),s(j.prototype,c,(function(){return this})),e.AsyncIterator=j,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new j(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(T),s(T,u,"Generator"),s(T,i,(function(){return this})),s(T,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=R,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(E),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function asyncGeneratorStep(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){asyncGeneratorStep(a,n,o,i,c,"next",t)}function c(t){asyncGeneratorStep(a,n,o,i,c,"throw",t)}i(void 0)}))}}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}import{asyncCallback}from"../../../../utils/utils.js";import ProTable from"@ant-design/pro-table";import{Card,Divider,Form,Modal,Space}from"antd";import React,{useRef,useState}from"react";import{assignRole,changeAdmin,fetchUsers}from"../service.js";import RoleUpdateForm from"./components/RoleUpdateForm";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var confirm=Modal.confirm,UserList=function(t){_slicedToArray(Form.useForm(),1)[0];var e=_slicedToArray(useState(!1),2),r=e[0],n=e[1],o=_slicedToArray(useState({}),2),a=o[0],i=o[1],c=_slicedToArray(useState([]),2),u=c[0],s=c[1],l=useRef(),f=t.currentUser,h=[{title:"查询内容",dataIndex:"keyString",hideInTable:!0,fieldProps:{placeholder:"姓名、用户名、所属机构"}},{title:"姓名",dataIndex:"realName",hideInSearch:!0},{title:"用户名",dataIndex:"userName",hideInSearch:!0},{title:"角色",dataIndex:"roleName",hideInSearch:!0,render:function(t,e){var r=[];return e.roles.map((function(t){r.push(t.roleName)})),r.join(",")}},{title:"所属机构",hideInSearch:!0,dataIndex:"orgName"},{title:"操作",hideInSearch:!0,render:function(t,e){return"ADMIN"==e.userType?_jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:["SUPERADMIN"===f.userType&&e.userTypeCode>f.userTypeCode&&_jsx("a",{onClick:function(){return p(!0,e)},className:"textGreen",children:"分配角色"}),"SUPERADMIN"===f.userType&&_jsx("a",{onClick:function(){return y(e)},children:"取消管理员"})]}):"USER"==e.userType?_jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:["SUPERADMIN"===f.userType&&e.userTypeCode>f.userTypeCode&&_jsx("a",{onClick:function(){return p(!0,e)},className:"textGreen",children:"分配角色"}),"SUPERADMIN"===f.userType&&_jsx("a",{onClick:function(){return y(e)},children:"设置管理员"})]}):void 0}}],p=function(t,e){n(!!t),i(e)},y=function(t){confirm({title:"警告",content:"ADMIN"===t.userType?"确定取消管理员吗?":"确定设置管理员吗?",okText:"确认",cancelText:"取消",onOk:function(){d(t)},onCancel:function(){}})},d=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,changeAdmin({userId:e.id});case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:l.current.reload();case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),m=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r,n;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={roleIds:e.roleIds,userId:e.userId},t.next=3,assignRole(r);case 3:if(n=t.sent,asyncCallback(n)){t.next=7;break}return t.abrupt("return");case 7:p(),l.current.reload();case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return _jsxs(Card,{children:[_jsx(ProTable,{headerTitle:"用户列表",actionRef:l,rowKey:"id",request:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r,n;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetchUsers(e);case 2:return r=t.sent,n=r.data.roles,s(n),t.abrupt("return",{data:r.data.data.list,success:!0,total:r.data.data.total});case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),pagination:{showSizeChanger:!0},columns:h,rowSelection:!1}),r&&_jsx(RoleUpdateForm,{modalVisible:r,item:a,handleAdd:m,handleModalVisible:p,roles:u})]})};export default UserList;
|
|
1
|
+
function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var a=e&&e.prototype instanceof v?e:v,i=Object.create(a.prototype),c=new k(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",y="executing",d="completed",m={};function v(){}function g(){}function b(){}var x={};s(x,i,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(R([])));w&&w!==r&&n.call(w,i)&&(x=w);var T=b.prototype=v.prototype=Object.create(x);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function r(o,a,i,c){var u=f(t[o],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===y)throw new Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=I(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?d:p,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function I(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=f(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(_typeof(e)+" is not iterable")}return g.prototype=b,o(T,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(T),t},e.awrap=function(t){return{__await:t}},S(j.prototype),s(j.prototype,c,(function(){return this})),e.AsyncIterator=j,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new j(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(T),s(T,u,"Generator"),s(T,i,(function(){return this})),s(T,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=R,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(E),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function asyncGeneratorStep(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){asyncGeneratorStep(a,n,o,i,c,"next",t)}function c(t){asyncGeneratorStep(a,n,o,i,c,"throw",t)}i(void 0)}))}}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}import{asyncCallback}from"../../../../utils/utils.js";import{ProTable}from"@ant-design/pro-components";import{Card,Divider,Form,Modal,Space}from"antd";import React,{useRef,useState}from"react";import{assignRole,changeAdmin,fetchUsers}from"../service.js";import RoleUpdateForm from"./components/RoleUpdateForm";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var confirm=Modal.confirm,UserList=function(t){_slicedToArray(Form.useForm(),1)[0];var e=_slicedToArray(useState(!1),2),r=e[0],n=e[1],o=_slicedToArray(useState({}),2),a=o[0],i=o[1],c=_slicedToArray(useState([]),2),u=c[0],s=c[1],l=useRef(),f=t.currentUser,h=[{title:"查询内容",dataIndex:"keyString",hideInTable:!0,fieldProps:{placeholder:"姓名、用户名、所属机构"}},{title:"姓名",dataIndex:"realName",hideInSearch:!0},{title:"用户名",dataIndex:"userName",hideInSearch:!0},{title:"角色",dataIndex:"roleName",hideInSearch:!0,render:function(t,e){var r=[];return e.roles.map((function(t){r.push(t.roleName)})),r.join(",")}},{title:"所属机构",hideInSearch:!0,dataIndex:"orgName"},{title:"操作",hideInSearch:!0,render:function(t,e){return"ADMIN"==e.userType?_jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:["SUPERADMIN"===f.userType&&e.userTypeCode>f.userTypeCode&&_jsx("a",{onClick:function(){return p(!0,e)},className:"textGreen",children:"分配角色"}),"SUPERADMIN"===f.userType&&_jsx("a",{onClick:function(){return y(e)},children:"取消管理员"})]}):"USER"==e.userType?_jsxs(Space,{split:_jsx(Divider,{type:"vertical"}),children:["SUPERADMIN"===f.userType&&e.userTypeCode>f.userTypeCode&&_jsx("a",{onClick:function(){return p(!0,e)},className:"textGreen",children:"分配角色"}),"SUPERADMIN"===f.userType&&_jsx("a",{onClick:function(){return y(e)},children:"设置管理员"})]}):void 0}}],p=function(t,e){n(!!t),i(e)},y=function(t){confirm({title:"警告",content:"ADMIN"===t.userType?"确定取消管理员吗?":"确定设置管理员吗?",okText:"确认",cancelText:"取消",onOk:function(){d(t)},onCancel:function(){}})},d=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,changeAdmin({userId:e.id});case 2:if(r=t.sent,asyncCallback(r)){t.next=6;break}return t.abrupt("return");case 6:l.current.reload();case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),m=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r,n;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={roleIds:e.roleIds,userId:e.userId},t.next=3,assignRole(r);case 3:if(n=t.sent,asyncCallback(n)){t.next=7;break}return t.abrupt("return");case 7:p(),l.current.reload();case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return _jsxs(Card,{children:[_jsx(ProTable,{headerTitle:"用户列表",actionRef:l,rowKey:"id",request:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r,n;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetchUsers(e);case 2:return r=t.sent,n=r.data.roles,s(n),t.abrupt("return",{data:r.data.data.list,success:!0,total:r.data.data.total});case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),pagination:{showSizeChanger:!0},columns:h,rowSelection:!1}),r&&_jsx(RoleUpdateForm,{modalVisible:r,item:a,handleAdd:m,handleModalVisible:p,roles:u})]})};export default UserList;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}var _templateObject;function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,r||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var o,n,i,a,l=[],s=!0,u=!1;try{if(i=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;s=!1}else for(;!(s=(o=i.call(t)).done)&&(l.push(o.value),l.length!==r);s=!0);}catch(e){u=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(u)throw n}}return l}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _taggedTemplateLiteral(e,r){return r||(r=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(r)}}))}import{getSessionStorage}from"../../utils/token.js";import{ProFormUploadButton,ProFormUploadDragger}from"@ant-design/pro-components";import{ConfigProvider,message,Upload,Image}from"antd";import React,{useState}from"react";import zhCN from"antd/es/locale/zh_CN";import styled from"styled-components";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var StyleBox=styled.div(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n .readonly {\n .ant-upload {\n display: none;\n }\n }\n"]))),UploadFile=function(e){var r,t=_slicedToArray(useState(!1),2),o=t[0],n=t[1],i=_slicedToArray(useState({visible:!1,fileList:[],currentId:null}),2),a=i[0],l=i[1],s=e.uploadOptions,u=void 0===s?{}:s,c=e.formItemOptions,p=void 0===c?{}:c,f=e.buttonOptions,d=void 0===f?{}:f,y=e.checkFile,m=e.onChange,b=e.form,v=_objectSpread({label:e.label||"",name:e.name||"file",rules:e.rules||[],style:e.label?{}:{margin:0}},p),_=getSessionStorage("service"),g=_objectSpread({name:"file",accept:e.accept,action:e.action||"/api/".concat(_,"/file/upload/v3?type=openFile"),multiple:e.multiple||!1,headers:{Authorization:"Bearer "+getSessionStorage("Token"),SID:SID,service:_||"unknow"},beforeUpload:function(e){return h(e)},onPreview:function(r){return S(r,e.name)},showUploadList:"boolean"==typeof e.showUploadList?e.showUploadList:_objectSpread({showRemoveIcon:!e.readonly},e.showUploadList),onChange:function(e){m&&m(e),n(!0),"uploading"!==e.file.status&&n(!1)}},u),j=g.listType?g.listType:e.listType||"text",S=function(e,r){["picture","picture-card"].includes(j)
|
|
1
|
+
function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}var _templateObject;function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,r||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var o,n,i,a,l=[],s=!0,u=!1;try{if(i=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;s=!1}else for(;!(s=(o=i.call(t)).done)&&(l.push(o.value),l.length!==r);s=!0);}catch(e){u=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(u)throw n}}return l}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _taggedTemplateLiteral(e,r){return r||(r=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(r)}}))}import{getSessionStorage}from"../../utils/token.js";import{ProFormUploadButton,ProFormUploadDragger}from"@ant-design/pro-components";import{ConfigProvider,message,Upload,Image}from"antd";import React,{useState}from"react";import zhCN from"antd/es/locale/zh_CN";import styled from"styled-components";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var StyleBox=styled.div(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n .readonly {\n .ant-upload {\n display: none;\n }\n }\n"]))),UploadFile=function(e){var r,t=_slicedToArray(useState(!1),2),o=t[0],n=t[1],i=_slicedToArray(useState({visible:!1,fileList:[],currentId:null}),2),a=i[0],l=i[1],s=e.uploadOptions,u=void 0===s?{}:s,c=e.formItemOptions,p=void 0===c?{}:c,f=e.buttonOptions,d=void 0===f?{}:f,y=e.checkFile,m=e.onChange,b=e.form,v=_objectSpread({label:e.label||"",name:e.name||"file",rules:e.rules||[],style:e.label?{}:{margin:0}},p),_=getSessionStorage("service"),g=_objectSpread({name:"file",accept:e.accept,action:e.action||"/api/".concat(_,"/file/upload/v3?type=openFile"),multiple:e.multiple||!1,headers:{Authorization:"Bearer "+getSessionStorage("Token"),SID:SID,service:_||"unknow"},beforeUpload:function(e){return h(e)},onPreview:function(r){return S(r,e.name)},showUploadList:"boolean"==typeof e.showUploadList?e.showUploadList:_objectSpread({showRemoveIcon:!e.readonly},e.showUploadList),onChange:function(e){m&&m(e),n(!0),"uploading"!==e.file.status&&n(!1)}},u),j=g.listType?g.listType:e.listType||"text",S=function(e,r){if(["picture","picture-card"].includes(j)){var t=null==b?void 0:b.getFieldValue(r);l(t?{fileList:t,currentId:e.uid,visible:!0}:{fileList:[e],currentId:e.uid,visible:!0})}else window.open(e.url)},h=function(e){var r=y||{},t=r.suffixs,o=r.maxSize;if(t){var n,i=null===(n=e.name)||void 0===n||null===(n=n.split("."))||void 0===n?void 0:n.splice(-1)[0];if(!t.includes(i.toLocaleLowerCase()))return message.error("不支持".concat(e.name,"该种格式文件")),Upload.LIST_IGNORE}return o>0&&e.size/1024>o?(message.error("请选择小于".concat(o/1024,"MB的文件!")),Upload.LIST_IGNORE):Promise.resolve(e)},O=_objectSpread(_objectSpread({},e),{},{onChange:function(){},listType:j,formItemProps:v,fieldProps:g});return _jsx(ConfigProvider,{locale:zhCN,children:_jsxs(StyleBox,{children:[_jsx("div",{className:e.readonly?"readonly":"",children:"dragger"===j?_jsx(ProFormUploadDragger,_objectSpread({},O)):_jsx(ProFormUploadButton,_objectSpread(_objectSpread({},O),{},{buttonProps:_objectSpread({loading:o},d)}))}),_jsx(Image.PreviewGroup,{preview:{visible:a.visible,current:(r=a.fileList.findIndex((function(e){return e.uid===a.currentId})),r>-1?r:0),onVisibleChange:function(e){l(_objectSpread(_objectSpread({},a),{},{visible:e}))}},children:a.fileList.map((function(e,r){var t;return _jsx(Image,{style:{display:"none"},src:(null==e||null===(t=e.response)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.pathUrl)||(null==e?void 0:e.url)||(null==e?void 0:e.thumbUrl)},r)}))})]})})};
|
|
2
2
|
/**
|
|
3
3
|
* @preserve
|
|
4
4
|
*
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "xydata-tools",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "xydata tools",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"dev": "yarn link && father dev",
|
|
9
|
-
"build": "father build && node uglify.js"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"authors": [],
|
|
13
|
-
"license": "MIT",
|
|
14
|
-
"files": [
|
|
15
|
-
"/dist"
|
|
16
|
-
],
|
|
17
|
-
"publishConfig": {
|
|
18
|
-
"access": "public"
|
|
19
|
-
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@babel/core": "7.24.9",
|
|
22
|
-
"@babel/preset-env": "7.24.8",
|
|
23
|
-
"@babel/preset-react": "7.24.7",
|
|
24
|
-
"father": "4.1.5",
|
|
25
|
-
"terser": "5.31.3"
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@ant-design/icons": "4.5.0",
|
|
29
|
-
"@ant-design/pro-components": "2.7.
|
|
30
|
-
"@ant-design/pro-layout": "7.
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"react": "17",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "xydata-tools",
|
|
3
|
+
"version": "1.0.28",
|
|
4
|
+
"description": "xydata tools",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "yarn link && father dev",
|
|
9
|
+
"build": "father build && node uglify.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"authors": [],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"files": [
|
|
15
|
+
"/dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@babel/core": "7.24.9",
|
|
22
|
+
"@babel/preset-env": "7.24.8",
|
|
23
|
+
"@babel/preset-react": "7.24.7",
|
|
24
|
+
"father": "4.1.5",
|
|
25
|
+
"terser": "5.31.3"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@ant-design/icons": "4.5.0",
|
|
29
|
+
"@ant-design/pro-components": "2.7.19",
|
|
30
|
+
"@ant-design/pro-layout": "7.20.2",
|
|
31
|
+
"@zhengxs/js.tree": "0.5.0",
|
|
32
|
+
"antd": "4.24.16",
|
|
33
|
+
"moment": "2.30.1",
|
|
34
|
+
"querystring": "0.2.1",
|
|
35
|
+
"react": "17.0.0",
|
|
36
|
+
"react-dom": "17.0.0",
|
|
37
|
+
"stringify": "5.2.0",
|
|
38
|
+
"styled-components": "6.1.8",
|
|
39
|
+
"umi-request": "1.0.8",
|
|
40
|
+
"swr": "2.2.5"
|
|
41
|
+
}
|
|
42
|
+
}
|