@deepinnet-components/pc 0.0.35 → 0.0.38

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.
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface MainProps {
3
+ addOrEdit: 'add' | 'edit';
4
+ actionRow?: any;
5
+ onClose: any;
6
+ onSuccess: any;
7
+ }
8
+ declare const Index: React.FC<MainProps>;
9
+ export default Index;
@@ -0,0 +1,175 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(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 === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(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, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(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 resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "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 next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(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(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(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 i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(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), y; }, finish: function finish(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), resetTryEntry(r), y; } }, catch: function _catch(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; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ 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."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import React, { useState, useEffect, useMemo, useContext } from 'react';
12
+ import { Modal, message } from 'antd';
13
+ import { Form, FormItem, Input } from '@formily/antd-v5';
14
+ import { createForm } from '@formily/core';
15
+ import { createSchemaField } from '@formily/react';
16
+ import AuthSelect from "../AuthSelect";
17
+ import ValueContext from "../context";
18
+ var SchemaField = createSchemaField({
19
+ components: {
20
+ FormItem: FormItem,
21
+ Input: Input,
22
+ AuthSelect: AuthSelect
23
+ }
24
+ });
25
+ var schema = {
26
+ type: 'object',
27
+ properties: {
28
+ parentId: {
29
+ type: 'string',
30
+ title: '上级',
31
+ 'x-decorator': 'FormItem',
32
+ 'x-component': 'AuthSelect',
33
+ 'x-component-props': {
34
+ placeholder: '请选择上级(不选择则为一级)',
35
+ disabled: '{{!isEdit}}',
36
+ treeDefaultExpandAll: true,
37
+ actionRow: '{{ actionRow }}',
38
+ isEdit: '{{isEdit}}'
39
+ },
40
+ 'x-reactions': [{
41
+ dependencies: [],
42
+ fulfill: {
43
+ state: {
44
+ visible: '{{ !!actionRow }}'
45
+ }
46
+ }
47
+ }]
48
+ },
49
+ name: {
50
+ type: 'string',
51
+ title: '权限名称',
52
+ 'x-decorator': 'FormItem',
53
+ 'x-component': 'Input',
54
+ 'x-component-props': {
55
+ placeholder: '请输入权限名称',
56
+ allowClear: true,
57
+ maxLength: 20
58
+ },
59
+ 'x-validator': [{
60
+ required: true,
61
+ message: '请输入权限名称'
62
+ }]
63
+ },
64
+ code: {
65
+ type: 'string',
66
+ title: '权限code',
67
+ 'x-decorator': 'FormItem',
68
+ 'x-component': 'Input',
69
+ 'x-component-props': {
70
+ placeholder: '请输入权限code',
71
+ allowClear: true,
72
+ maxLength: 100
73
+ },
74
+ 'x-validator': [{
75
+ required: true,
76
+ message: '请输入权限code'
77
+ }]
78
+ }
79
+ }
80
+ };
81
+ var Index = function Index(props) {
82
+ var contextValue = useContext(ValueContext);
83
+ var ApiService = contextValue.ApiService;
84
+ var _props$addOrEdit = props.addOrEdit,
85
+ addOrEdit = _props$addOrEdit === void 0 ? 'add' : _props$addOrEdit,
86
+ actionRow = props.actionRow,
87
+ onClose = props.onClose,
88
+ onSuccess = props.onSuccess;
89
+ var form = useMemo(function () {
90
+ return createForm({});
91
+ }, []);
92
+ useEffect(function () {
93
+ if (addOrEdit === 'edit') {
94
+ form.setValues({
95
+ parentId: actionRow.parentId === -1 ? undefined : actionRow.parentId,
96
+ name: actionRow.name,
97
+ code: actionRow.code
98
+ });
99
+ } else {
100
+ form.setValues({
101
+ parentId: actionRow === null || actionRow === void 0 ? void 0 : actionRow.id
102
+ });
103
+ }
104
+ }, [addOrEdit]);
105
+ var _useState = useState(false),
106
+ _useState2 = _slicedToArray(_useState, 2),
107
+ loading = _useState2[0],
108
+ setLoading = _useState2[1];
109
+ var handleSubmit = /*#__PURE__*/function () {
110
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
111
+ var values, params, _yield$ApiService$sav, success;
112
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
113
+ while (1) switch (_context.prev = _context.next) {
114
+ case 0:
115
+ _context.next = 2;
116
+ return form.submit();
117
+ case 2:
118
+ values = _context.sent;
119
+ _context.prev = 3;
120
+ setLoading(true);
121
+ params = {
122
+ name: values.name,
123
+ code: values.code,
124
+ parentId: values.parentId || '-1',
125
+ id: addOrEdit === 'add' ? undefined : actionRow.id
126
+ };
127
+ _context.next = 8;
128
+ return ApiService.savePermission(params);
129
+ case 8:
130
+ _yield$ApiService$sav = _context.sent;
131
+ success = _yield$ApiService$sav.success;
132
+ if (success) {
133
+ message.success(addOrEdit === 'add' ? '新增成功' : '编辑成功');
134
+ onClose();
135
+ onSuccess();
136
+ }
137
+ case 11:
138
+ _context.prev = 11;
139
+ setLoading(false);
140
+ return _context.finish(11);
141
+ case 14:
142
+ case "end":
143
+ return _context.stop();
144
+ }
145
+ }, _callee, null, [[3,, 11, 14]]);
146
+ }));
147
+ return function handleSubmit() {
148
+ return _ref.apply(this, arguments);
149
+ };
150
+ }();
151
+ return /*#__PURE__*/React.createElement(Modal, {
152
+ title: "".concat(addOrEdit === 'add' ? '新增' : '编辑', "\u6743\u9650"),
153
+ open: true,
154
+ onOk: handleSubmit,
155
+ onCancel: onClose,
156
+ okButtonProps: {
157
+ loading: loading
158
+ },
159
+ centered: true
160
+ }, /*#__PURE__*/React.createElement("div", {
161
+ style: {
162
+ marginTop: 20
163
+ }
164
+ }, /*#__PURE__*/React.createElement(Form, {
165
+ form: form,
166
+ labelWidth: 120
167
+ }, /*#__PURE__*/React.createElement(SchemaField, {
168
+ schema: schema,
169
+ scope: {
170
+ isEdit: addOrEdit === 'edit',
171
+ actionRow: actionRow
172
+ }
173
+ }))));
174
+ };
175
+ export default Index;
@@ -0,0 +1,3 @@
1
+ import type { FC } from 'react';
2
+ declare const Index: FC;
3
+ export default Index;
@@ -0,0 +1,229 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ 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."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(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 === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(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, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(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 resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "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 next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(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(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(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 i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(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), y; }, finish: function finish(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), resetTryEntry(r), y; } }, catch: function _catch(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; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
7
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
8
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ 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."); }
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ import { Button, message, Tooltip } from 'antd';
16
+ import { PlusOutlined } from '@ant-design/icons';
17
+ import React, { useState, useRef, useContext } from 'react';
18
+ import { ShenduTable } from "../..";
19
+ import CreateModal from "./CreateModal";
20
+ import ValueContext from "../context";
21
+ var ellipsisRenderObj = {
22
+ ellipsis: true,
23
+ render: function render(_) {
24
+ return /*#__PURE__*/React.createElement(Tooltip, {
25
+ placement: "topLeft",
26
+ title: _
27
+ }, _ || '-');
28
+ }
29
+ };
30
+ function loopKeys() {
31
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
32
+ var arr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
33
+ var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
34
+ list.forEach(function (item) {
35
+ var _item$children;
36
+ arr.push(item.id);
37
+ if ((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) {
38
+ loopKeys(item.children, arr, index + 1);
39
+ }
40
+ });
41
+ }
42
+
43
+ // 文档目录管理
44
+ var Index = function Index() {
45
+ var contextValue = useContext(ValueContext);
46
+ var ApiService = contextValue.ApiService,
47
+ Components = contextValue.Components;
48
+ var tableRef = useRef(null);
49
+ var _useState = useState('add'),
50
+ _useState2 = _slicedToArray(_useState, 2),
51
+ actionType = _useState2[0],
52
+ setActionType = _useState2[1];
53
+ var _useState3 = useState(null),
54
+ _useState4 = _slicedToArray(_useState3, 2),
55
+ actionRow = _useState4[0],
56
+ setActionRow = _useState4[1];
57
+ var _useState5 = useState(false),
58
+ _useState6 = _slicedToArray(_useState5, 2),
59
+ modalShow = _useState6[0],
60
+ setModalShow = _useState6[1];
61
+ function handleAdd(row) {
62
+ setActionType('add');
63
+ setActionRow(row);
64
+ setModalShow(true);
65
+ }
66
+ function handleEdit(row) {
67
+ setActionType('edit');
68
+ setActionRow(row);
69
+ setModalShow(true);
70
+ }
71
+ function handleDelete(_x) {
72
+ return _handleDelete.apply(this, arguments);
73
+ }
74
+ function _handleDelete() {
75
+ _handleDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(row) {
76
+ var _yield$ApiService$del, success;
77
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
78
+ while (1) switch (_context2.prev = _context2.next) {
79
+ case 0:
80
+ _context2.next = 2;
81
+ return ApiService.deletePermission({
82
+ id: row.id
83
+ });
84
+ case 2:
85
+ _yield$ApiService$del = _context2.sent;
86
+ success = _yield$ApiService$del.success;
87
+ if (success) {
88
+ message.success('删除成功');
89
+ tableRef.current.reloadCurrentPage();
90
+ }
91
+ case 5:
92
+ case "end":
93
+ return _context2.stop();
94
+ }
95
+ }, _callee2);
96
+ }));
97
+ return _handleDelete.apply(this, arguments);
98
+ }
99
+ var columns = [{
100
+ title: '权限名称',
101
+ dataIndex: 'name',
102
+ width: 200,
103
+ align: 'left'
104
+ }, {
105
+ title: '权限code',
106
+ dataIndex: 'code',
107
+ width: 200,
108
+ align: 'left'
109
+ }, {
110
+ title: '操作',
111
+ dataIndex: 'action',
112
+ fixed: 'right',
113
+ width: 100,
114
+ align: 'left',
115
+ render: function render(_, row) {
116
+ var operationList = [{
117
+ text: '添加子权限',
118
+ handleClick: function handleClick() {
119
+ handleAdd(row);
120
+ }
121
+ }, {
122
+ text: '编辑',
123
+ handleClick: function handleClick() {
124
+ handleEdit(row);
125
+ }
126
+ }, {
127
+ text: '删除',
128
+ handleClick: function handleClick() {
129
+ handleDelete(row);
130
+ },
131
+ isPopoverBtn: true,
132
+ popoverTitle: "\u786E\u5B9A\u5220\u9664\u5417"
133
+ }];
134
+ return /*#__PURE__*/React.createElement(Components.OperationButton, {
135
+ button: operationList
136
+ });
137
+ }
138
+ }];
139
+ var _useState7 = useState([]),
140
+ _useState8 = _slicedToArray(_useState7, 2),
141
+ expandedRowKeys = _useState8[0],
142
+ setExpandedRowKeys = _useState8[1];
143
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShenduTable, {
144
+ actionRef: tableRef
145
+ // search={{
146
+ // labelWidth: 'auto',
147
+ // }}
148
+ ,
149
+ request: ( /*#__PURE__*/function () {
150
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchInfo) {
151
+ var _ref2, data, arr;
152
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
153
+ while (1) switch (_context.prev = _context.next) {
154
+ case 0:
155
+ _context.next = 2;
156
+ return ApiService.getPermissionTree({});
157
+ case 2:
158
+ _ref2 = _context.sent;
159
+ data = _ref2.data;
160
+ if (data !== null && data !== void 0 && data.length) {
161
+ arr = [];
162
+ loopKeys(data, arr);
163
+ setExpandedRowKeys(arr);
164
+ }
165
+ return _context.abrupt("return", {
166
+ data: data || [],
167
+ success: true,
168
+ total: (data === null || data === void 0 ? void 0 : data.total) || 0
169
+ });
170
+ case 6:
171
+ case "end":
172
+ return _context.stop();
173
+ }
174
+ }, _callee);
175
+ }));
176
+ return function (_x2) {
177
+ return _ref.apply(this, arguments);
178
+ };
179
+ }()),
180
+ expandable: {
181
+ // defaultExpandAllRows: true, // 为啥不生效
182
+ defaultExpandedRowKeys: expandedRowKeys,
183
+ expandedRowKeys: expandedRowKeys,
184
+ onExpand: function onExpand(flag, row) {
185
+ if (flag) {
186
+ setExpandedRowKeys([].concat(_toConsumableArray(expandedRowKeys), [row.id]));
187
+ } else {
188
+ setExpandedRowKeys(_toConsumableArray(expandedRowKeys).filter(function (item) {
189
+ return item !== row.id;
190
+ }));
191
+ }
192
+ },
193
+ indentSize: 50
194
+ },
195
+ columns: columns,
196
+ rowKey: "id",
197
+ scroll: {
198
+ x: 1200
199
+ },
200
+ initSearchKey: window.location.pathname,
201
+ toolbar: {
202
+ title: /*#__PURE__*/React.createElement("div", {
203
+ style: {
204
+ display: 'flex',
205
+ justifyContent: 'flex-end'
206
+ }
207
+ }, /*#__PURE__*/React.createElement(Button, {
208
+ type: "primary",
209
+ onClick: function onClick() {
210
+ handleAdd();
211
+ }
212
+ }, /*#__PURE__*/React.createElement(PlusOutlined, {
213
+ style: {
214
+ color: '#fff'
215
+ }
216
+ }), " \u6DFB\u52A0\u6743\u9650"))
217
+ }
218
+ }), modalShow && /*#__PURE__*/React.createElement(CreateModal, {
219
+ addOrEdit: actionType,
220
+ actionRow: actionRow,
221
+ onClose: function onClose() {
222
+ setModalShow(false);
223
+ },
224
+ onSuccess: function onSuccess() {
225
+ tableRef.current.reloadCurrentPage();
226
+ }
227
+ }));
228
+ };
229
+ export default Index;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const AuthSelect: (props: any) => React.JSX.Element;
3
+ export default AuthSelect;
@@ -0,0 +1,117 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["searchParams", "actionRow", "isEdit"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(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 === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(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, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(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 resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "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 next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(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(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(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 i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(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), y; }, finish: function finish(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), resetTryEntry(r), y; } }, catch: function _catch(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; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
5
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ 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."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
14
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
15
+ import { TreeSelect } from 'antd';
16
+ import React, { useContext, useEffect, useState } from 'react';
17
+ import ValueContext from "../context";
18
+ function filterList(list, id) {
19
+ var newList = [];
20
+ list.forEach(function (item) {
21
+ var _item$children;
22
+ if (item.id === id) return;
23
+ if ((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) {
24
+ item.children = filterList(item.children, id);
25
+ }
26
+ newList.push(item);
27
+ });
28
+ return newList;
29
+ }
30
+ var AuthSelect = function AuthSelect(props) {
31
+ var contextValue = useContext(ValueContext);
32
+ var ApiService = contextValue.ApiService;
33
+ var _props$searchParams = props.searchParams,
34
+ searchParams = _props$searchParams === void 0 ? {} : _props$searchParams,
35
+ actionRow = props.actionRow,
36
+ isEdit = props.isEdit,
37
+ comProps = _objectWithoutProperties(props, _excluded); // searchParams 外部传过来的额外搜索条件
38
+ var _useState = useState(''),
39
+ _useState2 = _slicedToArray(_useState, 2),
40
+ value = _useState2[0],
41
+ setValue = _useState2[1];
42
+ useEffect(function () {
43
+ setValue(props.value);
44
+ }, [props.value]);
45
+ var _useState3 = useState([]),
46
+ _useState4 = _slicedToArray(_useState3, 2),
47
+ options = _useState4[0],
48
+ setOptions = _useState4[1];
49
+ var _useState5 = useState(false),
50
+ _useState6 = _slicedToArray(_useState5, 2),
51
+ loading = _useState6[0],
52
+ setLoading = _useState6[1];
53
+ var getData = /*#__PURE__*/function () {
54
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
55
+ var name,
56
+ _ref2,
57
+ data,
58
+ list,
59
+ _args = arguments;
60
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
61
+ while (1) switch (_context.prev = _context.next) {
62
+ case 0:
63
+ name = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
64
+ _context.prev = 1;
65
+ _context.next = 4;
66
+ return ApiService.getPermissionTree({});
67
+ case 4:
68
+ _ref2 = _context.sent;
69
+ data = _ref2.data;
70
+ if (data) {
71
+ list = data || []; // 编辑的时候不能选择自己以及children
72
+ if (isEdit) {
73
+ list = filterList(list, actionRow.id);
74
+ }
75
+ setOptions(list);
76
+ }
77
+ case 7:
78
+ _context.prev = 7;
79
+ setLoading(false);
80
+ return _context.finish(7);
81
+ case 10:
82
+ case "end":
83
+ return _context.stop();
84
+ }
85
+ }, _callee, null, [[1,, 7, 10]]);
86
+ }));
87
+ return function getData() {
88
+ return _ref.apply(this, arguments);
89
+ };
90
+ }();
91
+ useEffect(function () {
92
+ getData();
93
+ }, []);
94
+ var handleChange = function handleChange(v, options) {
95
+ var _props$onChange, _props$onOptionChange;
96
+ if (!v) {
97
+ // 点击 x 时,重新请求数据
98
+ getData();
99
+ }
100
+ setValue(v);
101
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, v);
102
+ (_props$onOptionChange = props.onOptionChange) === null || _props$onOptionChange === void 0 || _props$onOptionChange.call(props, options);
103
+ };
104
+ return /*#__PURE__*/React.createElement(TreeSelect, _extends({}, comProps, {
105
+ value: value || null,
106
+ onChange: handleChange,
107
+ treeData: options,
108
+ placeholder: props.placeholder || '请选择',
109
+ loading: loading,
110
+ allowClear: true,
111
+ fieldNames: {
112
+ label: 'name',
113
+ value: 'id'
114
+ }
115
+ }));
116
+ };
117
+ export default AuthSelect;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface MainProps {
3
+ request?: any;
4
+ api?: any;
5
+ components?: any;
6
+ children?: any;
7
+ }
8
+ declare const Index: React.FC<MainProps>;
9
+ export default Index;
@@ -0,0 +1,73 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ 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."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import React, { useEffect, useState } from 'react';
14
+ import ValueContext from "../context";
15
+ import locale from 'antd/locale/zh_CN';
16
+ import { ConfigProvider } from 'antd';
17
+ var Index = function Index(props) {
18
+ var request = props.request,
19
+ _props$api = props.api,
20
+ api = _props$api === void 0 ? {
21
+ getPermissionTree: '/manager/permission/list',
22
+ // 查询权限树
23
+ savePermission: '/manager/permission/save',
24
+ // 保存权限
25
+ deletePermission: '/manager/permission/delete' // 删除权限
26
+ } : _props$api,
27
+ _props$components = props.components,
28
+ components = _props$components === void 0 ? {} : _props$components;
29
+ var _useState = useState(),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ value = _useState2[0],
32
+ setValue = _useState2[1];
33
+ useEffect(function () {
34
+ var Service = /*#__PURE__*/function () {
35
+ function Service() {
36
+ _classCallCheck(this, Service);
37
+ }
38
+ _createClass(Service, null, [{
39
+ key: "getPermissionTree",
40
+ value: function getPermissionTree(params) {
41
+ return request.post(api.getPermissionTree, params);
42
+ }
43
+ }, {
44
+ key: "savePermission",
45
+ value: function savePermission(params) {
46
+ return request.post(api.savePermission, params);
47
+ }
48
+ }, {
49
+ key: "deletePermission",
50
+ value: function deletePermission(params) {
51
+ return request.get(api.deletePermission, {
52
+ params: params
53
+ });
54
+ }
55
+ }]);
56
+ return Service;
57
+ }();
58
+ setValue({
59
+ request: request,
60
+ api: api,
61
+ Components: components,
62
+ ApiService: Service
63
+ });
64
+ }, []);
65
+ if (!value) return null;
66
+ return /*#__PURE__*/React.createElement(ConfigProvider, {
67
+ locale: locale
68
+ }, /*#__PURE__*/React.createElement(ValueContext.Provider, {
69
+ // @ts-ignore
70
+ value: value
71
+ }, props.children));
72
+ };
73
+ export default Index;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ValueContext: React.Context<null>;
3
+ export default ValueContext;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ var ValueContext = /*#__PURE__*/React.createContext(null);
3
+ export default ValueContext;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * title: 用法
3
+ * description:
4
+ */
5
+ import type { FC } from 'react';
6
+ declare const App: FC;
7
+ export default App;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * title: 用法
3
+ * description:
4
+ */
5
+
6
+ import React from 'react';
7
+ var App = function App() {
8
+ return /*#__PURE__*/React.createElement("div", null, "\u8FD9\u4E2A\u529F\u80FD\u6587\u6863\u4E0D\u662F\u5F88\u597D\u641E\uFF0C\u95EE\u4E0B\u5FAE\u5FAE");
9
+ };
10
+ export default App;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare const AuthTreeManage: {
3
+ ConfigProvider: import("react").FC<import("./ConfigProvider").MainProps>;
4
+ AuthManagePage: import("react").FC;
5
+ };
6
+ export default AuthTreeManage;
@@ -0,0 +1,7 @@
1
+ import ConfigProvider from "./ConfigProvider";
2
+ import AuthManagePage from "./AuthManagePage";
3
+ var AuthTreeManage = {
4
+ ConfigProvider: ConfigProvider,
5
+ AuthManagePage: AuthManagePage
6
+ };
7
+ export default AuthTreeManage;
@@ -92,7 +92,7 @@ var EditPasswordModal = function EditPasswordModal(props) {
92
92
  }
93
93
  function _handleOk() {
94
94
  _handleOk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
95
- var values, params, _sm4Encrypt, key, encryptedData, _yield$yield$ApiServi, success;
95
+ var values, params, _sm4Encrypt, key, encryptedData, _yield$ApiService$edi, success;
96
96
  return _regeneratorRuntime().wrap(function _callee$(_context) {
97
97
  while (1) switch (_context.prev = _context.next) {
98
98
  case 0:
@@ -120,24 +120,21 @@ var EditPasswordModal = function EditPasswordModal(props) {
120
120
  _context.next = 11;
121
121
  return ApiService.editPassword(params);
122
122
  case 11:
123
- _context.next = 13;
124
- return _context.sent;
125
- case 13:
126
- _yield$yield$ApiServi = _context.sent;
127
- success = _yield$yield$ApiServi.success;
123
+ _yield$ApiService$edi = _context.sent;
124
+ success = _yield$ApiService$edi.success;
128
125
  if (success) {
129
126
  message.success('密码修改成功');
130
127
  onClose === null || onClose === void 0 || onClose();
131
128
  }
132
- case 16:
133
- _context.prev = 16;
129
+ case 14:
130
+ _context.prev = 14;
134
131
  setLoading(false);
135
- return _context.finish(16);
136
- case 19:
132
+ return _context.finish(14);
133
+ case 17:
137
134
  case "end":
138
135
  return _context.stop();
139
136
  }
140
- }, _callee, null, [[5,, 16, 19]]);
137
+ }, _callee, null, [[5,, 14, 17]]);
141
138
  }));
142
139
  return _handleOk.apply(this, arguments);
143
140
  }
@@ -168,7 +168,7 @@ var AccountList = function AccountList() {
168
168
  title: '操作',
169
169
  dataIndex: 'action',
170
170
  fixed: 'right',
171
- width: 140,
171
+ width: canEditPassword ? 200 : 140,
172
172
  align: 'left',
173
173
  render: function render(_, row) {
174
174
  var operationList = [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepinnet-components/pc",
3
- "version": "0.0.35",
3
+ "version": "0.0.38",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",