解决relation/entity 对user的授权
This commit is contained in:
parent
dadd4fdb27
commit
a5219e46b5
|
|
@ -4,5 +4,6 @@ declare const _default: (props: import("../../..").ReactComponentProps<EntityDic
|
|||
path: string;
|
||||
openTip: boolean;
|
||||
entity: string | number;
|
||||
onClose: () => void;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ exports.default = OakComponent({
|
|||
path: '',
|
||||
openTip: false,
|
||||
entity: '',
|
||||
onClose: (function () { return undefined; }),
|
||||
},
|
||||
filters: [
|
||||
{
|
||||
|
|
@ -82,7 +83,7 @@ exports.default = OakComponent({
|
|||
methods: {
|
||||
getRelationAndActions: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var _a, path, entity, entities, sourceEntity, source, relations, actions;
|
||||
var _a, path, entity, entities, sourceEntity, source, actions, relations;
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
|
|
@ -90,6 +91,16 @@ exports.default = OakComponent({
|
|||
entities = path.split('.');
|
||||
sourceEntity = entities[(entities === null || entities === void 0 ? void 0 : entities.length) - 1];
|
||||
source = sourceEntity.includes('$') ? sourceEntity.split('$')[0] : sourceEntity;
|
||||
actions = this.features.relationAuth.getActions(entity);
|
||||
// 获取relation
|
||||
// user 没有relation
|
||||
if (source === 'user') {
|
||||
this.setState({
|
||||
relations: [{ id: '', name: '当前用户' }],
|
||||
actions: actions,
|
||||
});
|
||||
return [2 /*return*/];
|
||||
}
|
||||
return [4 /*yield*/, this.features.cache.refresh('relation', {
|
||||
data: {
|
||||
id: 1,
|
||||
|
|
@ -107,7 +118,6 @@ exports.default = OakComponent({
|
|||
})];
|
||||
case 1:
|
||||
relations = (_b.sent()).data;
|
||||
actions = this.features.relationAuth.getActions(entity);
|
||||
this.setState({
|
||||
relations: relations,
|
||||
actions: actions,
|
||||
|
|
|
|||
|
|
@ -16,5 +16,6 @@ export default function render(props: WebComponentProps<ED, 'actionAuth', true,
|
|||
path: string;
|
||||
entity: keyof ED;
|
||||
openTip: boolean;
|
||||
onClose: () => void;
|
||||
}, {}>): JSX.Element;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ var antd_2 = require("antd");
|
|||
var Title = antd_2.Typography.Title, Text = antd_2.Typography.Text;
|
||||
function render(props) {
|
||||
var data = props.data, methods = props.methods;
|
||||
var rows = data.rows, relations = data.relations, actions = data.actions, path = data.path, entity = data.entity, openTip = data.openTip, oakExecutable = data.oakExecutable;
|
||||
var rows = data.rows, relations = data.relations, actions = data.actions, path = data.path, entity = data.entity, openTip = data.openTip, oakExecutable = data.oakExecutable, onClose = data.onClose;
|
||||
var _a = tslib_1.__read((0, react_1.useState)([]), 2), datasource = _a[0], setDatasource = _a[1];
|
||||
(0, react_1.useEffect)(function () {
|
||||
var tableRows = relations.map(function (ele) { return ({
|
||||
|
|
@ -18,7 +18,7 @@ function render(props) {
|
|||
}); });
|
||||
setDatasource(tableRows);
|
||||
}, [relations]);
|
||||
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ style: { fontSize: 16 } }, { children: "\u6388\u6743" })), (0, jsx_runtime_1.jsx)(antd_1.Tooltip, tslib_1.__assign({ title: "点击保存", open: openTip, placement: "right" }, { children: (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "link", disabled: !oakExecutable, onClick: function () { return methods.execute(); } }, { children: "\u4FDD\u5B58" })) }))] }), (0, jsx_runtime_1.jsx)(antd_1.Table, { rowKey: "relationId", dataSource: datasource, columns: [
|
||||
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Space, { children: (0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ style: { fontSize: 16 } }, { children: "\u6388\u6743" })) }), (0, jsx_runtime_1.jsx)(antd_1.Table, { rowKey: "relationId", dataSource: datasource, columns: [
|
||||
{
|
||||
width: 200,
|
||||
dataIndex: 'relation',
|
||||
|
|
@ -41,7 +41,7 @@ function render(props) {
|
|||
}, options: options, defaultValue: defaultValue, onChange: function (checkedArr) {
|
||||
if (!actionAuth) {
|
||||
methods.addItem({
|
||||
relationId: row.relationId,
|
||||
relationId: row.relationId || '',
|
||||
path: path,
|
||||
deActions: checkedArr,
|
||||
destEntity: entity,
|
||||
|
|
@ -58,6 +58,9 @@ function render(props) {
|
|||
} }));
|
||||
}
|
||||
}
|
||||
], pagination: false })] })));
|
||||
], pagination: false }), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { display: 'flex', width: '100%', justifyContent: 'flex-end', padding: 8 } }, { children: (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () {
|
||||
methods.execute();
|
||||
onClose();
|
||||
} }, { children: "\u4FDD\u5B58\u5E76\u5173\u95ED" })) }))] })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
|
|||
|
|
@ -8,15 +8,7 @@ exports.default = OakComponent({
|
|||
},
|
||||
formData: function (_a) {
|
||||
var rows = _a.data;
|
||||
// 查看path为actionAuthList-cpn 是否有未提交的操作,如果有提示先提交
|
||||
var operations = this.features.runningTree.getOperations('$actionAuthList-cpn');
|
||||
var showExecuteTip = false;
|
||||
if (operations && operations.length) {
|
||||
showExecuteTip = true;
|
||||
}
|
||||
return {
|
||||
showExecuteTip: showExecuteTip,
|
||||
};
|
||||
return {};
|
||||
},
|
||||
data: {
|
||||
links: [],
|
||||
|
|
@ -52,6 +44,19 @@ exports.default = OakComponent({
|
|||
entityDNode: entityDNode,
|
||||
entitySNode: entitySNode,
|
||||
});
|
||||
},
|
||||
// 检查在当前路径下,是否有授权操作,如果有需要先保存
|
||||
checkSelectRelation: function () {
|
||||
var operations = this.features.runningTree.getOperations('$actionAuthList-cpn');
|
||||
var showExecuteTip = false;
|
||||
if (operations && operations.length) {
|
||||
showExecuteTip = true;
|
||||
this.setMessage({
|
||||
content: '请先保存当前授权',
|
||||
type: 'warning',
|
||||
});
|
||||
}
|
||||
return showExecuteTip;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
|
|||
entity: keyof ED;
|
||||
entityDNode: string[];
|
||||
entitySNode: string[];
|
||||
showExecuteTip: boolean;
|
||||
}, {
|
||||
getNodes: (entity: keyof ED) => void;
|
||||
checkSelectRelation: () => boolean;
|
||||
}>): JSX.Element;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -9,29 +9,14 @@ var react_1 = require("react");
|
|||
var actionAuthList_1 = tslib_1.__importDefault(require("../actionAuthList"));
|
||||
function render(props) {
|
||||
var methods = props.methods, data = props.data;
|
||||
var entity = data.entity, entityDNode = data.entityDNode, entitySNode = data.entitySNode, oakFullpath = data.oakFullpath, showExecuteTip = data.showExecuteTip, rows = data.rows;
|
||||
var getNodes = methods.getNodes;
|
||||
var entity = data.entity, entityDNode = data.entityDNode, entitySNode = data.entitySNode, oakFullpath = data.oakFullpath, rows = data.rows;
|
||||
var getNodes = methods.getNodes, checkSelectRelation = methods.checkSelectRelation;
|
||||
var _a = tslib_1.__read((0, react_1.useState)(false), 2), open = _a[0], setOpen = _a[1];
|
||||
var _b = tslib_1.__read((0, react_1.useState)(false), 2), openTip = _b[0], setOpenTip = _b[1];
|
||||
var _c = tslib_1.__read((0, react_1.useState)([]), 2), breadcrumbItems = _c[0], setBreadcrumbItems = _c[1];
|
||||
(0, react_1.useEffect)(function () {
|
||||
if (!showExecuteTip) {
|
||||
setOpenTip(false);
|
||||
}
|
||||
}, [showExecuteTip]);
|
||||
var checkExecute = function () {
|
||||
if (showExecuteTip) {
|
||||
methods.setMessage({
|
||||
content: '有未保存的权限设置,请先保存',
|
||||
type: 'warning',
|
||||
});
|
||||
setOpenTip(true);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () { return setOpen(true); } }, { children: "\u8BBE\u7F6E" })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ title: "\u6743\u9650\u8BBE\u7F6E", open: open, destroyOnClose: true, footer: ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () { return setOpen(false); } }, { children: "\u5173\u95ED" }))), onCancel: function () { return setOpen(false); }, width: 900 }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%', marginTop: 16 }, size: 16 }, { children: [(0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: [(0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ style: { fontSize: 16 } }, { children: "\u8DEF\u5F84" })), (0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ style: { width: '100%' }, wrap: true }, { children: (breadcrumbItems && breadcrumbItems.length > 0) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Breadcrumb, { items: breadcrumbItems.map(function (ele, index) { return ({
|
||||
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () { return setOpen(true); } }, { children: "\u8BBE\u7F6E" })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ title: "\u6743\u9650\u8BBE\u7F6E", open: open, destroyOnClose: true, footer: null, onCancel: function () { return setOpen(false); }, width: 900 }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%', marginTop: 16 }, size: 16 }, { children: [(0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: [(0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ style: { fontSize: 16 } }, { children: "\u8DEF\u5F84" })), (0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ style: { width: '100%' }, wrap: true }, { children: (breadcrumbItems && breadcrumbItems.length > 0) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Breadcrumb, { items: breadcrumbItems.map(function (ele, index) { return ({
|
||||
title: ((0, jsx_runtime_1.jsx)("a", tslib_1.__assign({ onClick: function () {
|
||||
if (checkExecute()) {
|
||||
if (checkSelectRelation()) {
|
||||
return;
|
||||
}
|
||||
var newItems = breadcrumbItems.slice(0, index + 1);
|
||||
|
|
@ -42,21 +27,23 @@ function render(props) {
|
|||
}); }) }), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ size: "small", type: "link", onClick: function () {
|
||||
setBreadcrumbItems([]);
|
||||
getNodes(entity);
|
||||
} }, { children: "\u6E05\u7A7A" }))] })) : ((0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ type: "secondary" }, { children: "\u8BF7\u5148\u9009\u62E9\u7ED3\u70B9" }))) }))] })), (0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%' } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ style: { fontSize: 16 } }, { children: "\u7ED3\u70B9" })), (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ align: "start", style: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(Text, { children: "\u5916\u952E" }), (0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ wrap: true }, { children: entityDNode.map(function (ele) { return ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ style: { cursor: 'pointer' }, color: "processing", bordered: false, onClick: function () {
|
||||
if (checkExecute()) {
|
||||
return;
|
||||
}
|
||||
breadcrumbItems.push(ele);
|
||||
setBreadcrumbItems(breadcrumbItems);
|
||||
getNodes(ele);
|
||||
} }, { children: ele }))); }) }))] })), (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ align: "start", style: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(Text, { children: "\u53CD\u6307\u7ED3\u70B9" }), (0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ wrap: true }, { children: entitySNode.map(function (ele) { return ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ style: { cursor: 'pointer' }, color: "cyan", bordered: false, onClick: function () {
|
||||
if (checkExecute()) {
|
||||
return;
|
||||
}
|
||||
var parentEntity = breadcrumbItems[breadcrumbItems.length - 1] || entity;
|
||||
breadcrumbItems.push("".concat(ele, "$").concat(parentEntity));
|
||||
setBreadcrumbItems(breadcrumbItems);
|
||||
getNodes(ele);
|
||||
} }, { children: ele }))); }) }))] }))] })) })), (0, jsx_runtime_1.jsx)(actionAuthList_1.default, { oakPath: "$actionAuthList-cpn", entity: entity, path: breadcrumbItems.join('.'), openTip: openTip })] })) }))] })));
|
||||
} }, { children: "\u6E05\u7A7A" }))] })) : ((0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ type: "secondary" }, { children: "\u8BF7\u5148\u9009\u62E9\u7ED3\u70B9" }))) }))] })), (0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%' } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", style: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ style: { fontSize: 16 } }, { children: "\u7ED3\u70B9" })), (0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ gutter: 24 }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Col, tslib_1.__assign({ span: 2 }, { children: (0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ style: { whiteSpace: 'nowrap' } }, { children: "\u5916\u952E" })) })), (0, jsx_runtime_1.jsx)(antd_1.Col, tslib_1.__assign({ span: 22 }, { children: (0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ wrap: true }, { children: entityDNode.map(function (ele) { return ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ style: { cursor: 'pointer' }, color: "processing", bordered: false, onClick: function () {
|
||||
if (checkSelectRelation()) {
|
||||
return;
|
||||
}
|
||||
breadcrumbItems.push(ele);
|
||||
setBreadcrumbItems(breadcrumbItems);
|
||||
getNodes(ele);
|
||||
} }, { children: ele }))); }) })) }))] })), (0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ gutter: 24 }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Col, tslib_1.__assign({ span: 2 }, { children: (0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ style: { whiteSpace: 'nowrap', marginRight: 16 } }, { children: "\u53CD\u6307\u7ED3\u70B9" })) })), (0, jsx_runtime_1.jsx)(antd_1.Col, tslib_1.__assign({ span: 22 }, { children: (0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ wrap: true }, { children: entitySNode.map(function (ele) { return ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ style: { cursor: 'pointer' }, color: "cyan", bordered: false, onClick: function () {
|
||||
if (checkSelectRelation()) {
|
||||
return;
|
||||
}
|
||||
var parentEntity = breadcrumbItems[breadcrumbItems.length - 1] || entity;
|
||||
breadcrumbItems.push("".concat(ele, "$").concat(parentEntity));
|
||||
setBreadcrumbItems(breadcrumbItems);
|
||||
getNodes(ele);
|
||||
} }, { children: ele }))); }) })) }))] }))] })) })), (0, jsx_runtime_1.jsx)(actionAuthList_1.default, { oakPath: "$actionAuthList-cpn", entity: entity, path: breadcrumbItems.join('.'), onClose: function () {
|
||||
setOpen(false);
|
||||
} })] })) }))] })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ var RelationAuth = /** @class */ (function (_super) {
|
|||
var links = [];
|
||||
var nodeOutSet = {};
|
||||
var nodeInSet = {};
|
||||
var ExcludeEntities = ['modi', 'modiEntity', 'oper', 'operEntity', 'relation', 'relationAuth', 'actionAuth', 'userRelation', 'user'];
|
||||
var ExcludeEntities = ['modi', 'modiEntity', 'oper', 'operEntity', 'relation', 'relationAuth', 'actionAuth', 'userRelation'];
|
||||
var _loop_1 = function (entity) {
|
||||
if (ExcludeEntities.includes(entity)) {
|
||||
return "continue";
|
||||
|
|
|
|||
|
|
@ -114,6 +114,20 @@ exports.default = OakComponent({
|
|||
actionAuths: $actionAuthsObject[ele],
|
||||
});
|
||||
});
|
||||
// path 中含有user 也要特殊处理
|
||||
var hasUserActionAuths = data.filter(function (ele) { var _a; return (_a = ele.path) === null || _a === void 0 ? void 0 : _a.split('.').includes('user'); });
|
||||
var $actionAuthsObject2 = (0, lodash_2.groupBy)(hasUserActionAuths, 'path');
|
||||
Object.keys($actionAuthsObject2).forEach(function (ele) {
|
||||
var entities = ele.split('.');
|
||||
var se = entities[entities.length - 1].split('$')[0];
|
||||
var p = ele;
|
||||
var de = entity;
|
||||
cascadeEntityActions.push({
|
||||
path: [de, p, se, true],
|
||||
relations: [{ id: '', name: '当前用户' }],
|
||||
actionAuths: $actionAuthsObject2[ele],
|
||||
});
|
||||
});
|
||||
return {
|
||||
cascadeEntityActions: cascadeEntityActions,
|
||||
};
|
||||
|
|
@ -171,7 +185,7 @@ exports.default = OakComponent({
|
|||
case 0:
|
||||
actions = this.props.actions;
|
||||
(0, assert_1.default)(actions && actions.length > 0);
|
||||
if (!!relationId) return [3 /*break*/, 2];
|
||||
if (!(!relationId && (relationName && relationName !== '当前用户'))) return [3 /*break*/, 2];
|
||||
se = path.split('$')[0];
|
||||
return [4 /*yield*/, this.features.cache.refresh('relation', {
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export default OakComponent({
|
|||
path: '',
|
||||
openTip: false,
|
||||
entity: '' as keyof ED,
|
||||
onClose: (() => undefined) as () => void,
|
||||
},
|
||||
filters: [
|
||||
{
|
||||
|
|
@ -74,7 +75,17 @@ export default OakComponent({
|
|||
const entities = path!.split('.');
|
||||
const sourceEntity = entities[entities?.length - 1];
|
||||
const source = sourceEntity.includes('$') ? sourceEntity.split('$')[0] : sourceEntity;
|
||||
// 获取actions
|
||||
const actions = this.features.relationAuth.getActions(entity!);
|
||||
// 获取relation
|
||||
// user 没有relation
|
||||
if (source === 'user') {
|
||||
this.setState({
|
||||
relations: [{id: '', name: '当前用户'}],
|
||||
actions,
|
||||
})
|
||||
return;
|
||||
}
|
||||
const { data: relations } = await this.features.cache.refresh('relation', {
|
||||
data: {
|
||||
id: 1,
|
||||
|
|
@ -90,8 +101,6 @@ export default OakComponent({
|
|||
},
|
||||
},
|
||||
});
|
||||
// 获取actions
|
||||
const actions = this.features.relationAuth.getActions(entity!);
|
||||
this.setState({
|
||||
relations,
|
||||
actions,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export default function render(
|
|||
path: string;
|
||||
entity: keyof ED;
|
||||
openTip: boolean;
|
||||
onClose: () => void;
|
||||
},
|
||||
{
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ export default function render(
|
|||
>
|
||||
) {
|
||||
const { data, methods } = props;
|
||||
const { rows, relations, actions, path, entity, openTip, oakExecutable } = data;
|
||||
const { rows, relations, actions, path, entity, openTip, oakExecutable, onClose } = data;
|
||||
const [datasource, setDatasource] = useState<TableData[]>([]);
|
||||
useEffect(() => {
|
||||
const tableRows: TableData[] = relations.map((ele) => ({
|
||||
|
|
@ -48,9 +49,6 @@ export default function render(
|
|||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<Space>
|
||||
<Text style={{fontSize: 16}}>授权</Text>
|
||||
<Tooltip title={"点击保存"} open={openTip} placement="right">
|
||||
<Button type="link" disabled={!oakExecutable} onClick={() => methods.execute()}>保存</Button>
|
||||
</Tooltip>
|
||||
</Space>
|
||||
<Table
|
||||
rowKey={"relationId"}
|
||||
|
|
@ -83,7 +81,7 @@ export default function render(
|
|||
onChange={(checkedArr) => {
|
||||
if (!actionAuth) {
|
||||
methods.addItem({
|
||||
relationId: row.relationId,
|
||||
relationId: row.relationId || '',
|
||||
path,
|
||||
deActions: checkedArr as string[],
|
||||
destEntity: entity as string,
|
||||
|
|
@ -105,6 +103,17 @@ export default function render(
|
|||
]}
|
||||
pagination={false}
|
||||
></Table>
|
||||
<div style={{ display: 'flex', width: '100%', justifyContent: 'flex-end', padding: 8 }}>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
methods.execute();
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
保存并关闭
|
||||
</Button>
|
||||
</div>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
|
@ -10,14 +10,7 @@ export default OakComponent({
|
|||
entity: '' as keyof ED,
|
||||
},
|
||||
formData({ data: rows }) {
|
||||
// 查看path为actionAuthList-cpn 是否有未提交的操作,如果有提示先提交
|
||||
const operations = this.features.runningTree.getOperations('$actionAuthList-cpn');
|
||||
let showExecuteTip = false;
|
||||
if (operations && operations.length) {
|
||||
showExecuteTip = true;
|
||||
}
|
||||
return {
|
||||
showExecuteTip,
|
||||
};
|
||||
},
|
||||
data: {
|
||||
|
|
@ -36,7 +29,7 @@ export default OakComponent({
|
|||
this.setState({
|
||||
links,
|
||||
}, () => {
|
||||
this.getNodes(entity);
|
||||
this.getNodes(entity!);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
@ -51,6 +44,19 @@ export default OakComponent({
|
|||
entityDNode,
|
||||
entitySNode,
|
||||
})
|
||||
},
|
||||
// 检查在当前路径下,是否有授权操作,如果有需要先保存
|
||||
checkSelectRelation() {
|
||||
const operations = this.features.runningTree.getOperations('$actionAuthList-cpn');
|
||||
let showExecuteTip = false;
|
||||
if (operations && operations.length) {
|
||||
showExecuteTip = true;
|
||||
this.setMessage({
|
||||
content: '请先保存当前授权',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
return showExecuteTip
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -15,31 +15,16 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
|
|||
entity: keyof ED;
|
||||
entityDNode: string[];
|
||||
entitySNode: string[];
|
||||
showExecuteTip: boolean;
|
||||
}, {
|
||||
getNodes: (entity: keyof ED) => void;
|
||||
checkSelectRelation: () => boolean;
|
||||
}>) {
|
||||
const { methods, data } = props;
|
||||
const { entity, entityDNode, entitySNode, oakFullpath, showExecuteTip, rows } = data;
|
||||
const { getNodes } = methods;
|
||||
const { entity, entityDNode, entitySNode, oakFullpath, rows } = data;
|
||||
const { getNodes, checkSelectRelation } = methods;
|
||||
const [open, setOpen] = useState(false);
|
||||
const [openTip, setOpenTip] = useState(false);
|
||||
const [breadcrumbItems, setBreadcrumbItems] = useState<string[]>([])
|
||||
useEffect(() => {
|
||||
if (!showExecuteTip) {
|
||||
setOpenTip(false);
|
||||
}
|
||||
}, [showExecuteTip]);
|
||||
const checkExecute = () => {
|
||||
if (showExecuteTip) {
|
||||
methods.setMessage({
|
||||
content: '有未保存的权限设置,请先保存',
|
||||
type: 'warning',
|
||||
})
|
||||
setOpenTip(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Space direction="vertical" style={{width: '100%'}}>
|
||||
<Button onClick={() => setOpen(true)}>设置</Button>
|
||||
|
|
@ -47,11 +32,7 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
|
|||
title={`权限设置`}
|
||||
open={open}
|
||||
destroyOnClose={true}
|
||||
footer={(
|
||||
<Button onClick={() => setOpen(false)}>
|
||||
关闭
|
||||
</Button>
|
||||
)}
|
||||
footer={null}
|
||||
onCancel={() => setOpen(false)}
|
||||
width={900}
|
||||
>
|
||||
|
|
@ -66,7 +47,7 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
|
|||
title: (
|
||||
<a
|
||||
onClick={() => {
|
||||
if (checkExecute()) {
|
||||
if (checkSelectRelation()) {
|
||||
return;
|
||||
}
|
||||
const newItems = breadcrumbItems.slice(0, index + 1)
|
||||
|
|
@ -99,58 +80,68 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
|
|||
<Space direction="vertical" style={{width: '100%'}}>
|
||||
<Space direction="vertical" style={{width: '100%'}}>
|
||||
<Text style={{ fontSize: 16 }}>结点</Text>
|
||||
<Space align="start" style={{width: '100%'}}>
|
||||
<Text>外键</Text>
|
||||
<Space wrap>
|
||||
{entityDNode.map((ele) => (
|
||||
<Tag
|
||||
style={{cursor: 'pointer'}}
|
||||
color="processing"
|
||||
bordered={false}
|
||||
onClick={() => {
|
||||
if (checkExecute()) {
|
||||
return;
|
||||
}
|
||||
breadcrumbItems.push(ele);
|
||||
setBreadcrumbItems(breadcrumbItems)
|
||||
getNodes(ele)
|
||||
}}
|
||||
>
|
||||
{ele}
|
||||
</Tag>
|
||||
))}
|
||||
</Space>
|
||||
</Space>
|
||||
<Space align="start" style={{ width: '100%' }}>
|
||||
<Text>反指结点</Text>
|
||||
<Space wrap>
|
||||
{entitySNode.map((ele) => (
|
||||
<Tag
|
||||
style={{cursor: 'pointer'}}
|
||||
color={"cyan"}
|
||||
bordered={false}
|
||||
onClick={() => {
|
||||
if (checkExecute()) {
|
||||
return;
|
||||
}
|
||||
const parentEntity = breadcrumbItems[breadcrumbItems.length - 1] || entity;
|
||||
breadcrumbItems.push(`${ele}$${parentEntity}`);
|
||||
setBreadcrumbItems(breadcrumbItems)
|
||||
getNodes(ele)
|
||||
}}
|
||||
>
|
||||
{ele}
|
||||
</Tag>
|
||||
))}
|
||||
</Space>
|
||||
</Space>
|
||||
<Row gutter={24}>
|
||||
<Col span={2}>
|
||||
<Text style={{whiteSpace: 'nowrap'}}>外键</Text>
|
||||
</Col>
|
||||
<Col span={22}>
|
||||
<Space wrap>
|
||||
{entityDNode.map((ele) => (
|
||||
<Tag
|
||||
style={{cursor: 'pointer'}}
|
||||
color="processing"
|
||||
bordered={false}
|
||||
onClick={() => {
|
||||
if (checkSelectRelation()) {
|
||||
return;
|
||||
}
|
||||
breadcrumbItems.push(ele);
|
||||
setBreadcrumbItems(breadcrumbItems)
|
||||
getNodes(ele)
|
||||
}}
|
||||
>
|
||||
{ele}
|
||||
</Tag>
|
||||
))}
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={24}>
|
||||
<Col span={2}>
|
||||
<Text style={{whiteSpace: 'nowrap', marginRight: 16}}>反指结点</Text>
|
||||
</Col>
|
||||
<Col span={22}>
|
||||
<Space wrap>
|
||||
{entitySNode.map((ele) => (
|
||||
<Tag
|
||||
style={{cursor: 'pointer'}}
|
||||
color={"cyan"}
|
||||
bordered={false}
|
||||
onClick={() => {
|
||||
if (checkSelectRelation()) {
|
||||
return;
|
||||
}
|
||||
const parentEntity = breadcrumbItems[breadcrumbItems.length - 1] || entity;
|
||||
breadcrumbItems.push(`${ele}$${parentEntity}`);
|
||||
setBreadcrumbItems(breadcrumbItems)
|
||||
getNodes(ele)
|
||||
}}
|
||||
>
|
||||
{ele}
|
||||
</Tag>
|
||||
))}
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
</Space>
|
||||
</Space>
|
||||
<ActionAuthList
|
||||
oakPath="$actionAuthList-cpn"
|
||||
entity={entity}
|
||||
path={breadcrumbItems.join('.')}
|
||||
openTip={openTip}
|
||||
onClose={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
/>
|
||||
</Space>
|
||||
</Modal>
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ export class RelationAuth<
|
|||
const nodeOutSet: Record<string, string[]> = {};
|
||||
const nodeInSet: Record<string, string[]> = {};
|
||||
|
||||
const ExcludeEntities = ['modi', 'modiEntity', 'oper', 'operEntity', 'relation', 'relationAuth', 'actionAuth', 'userRelation', 'user'];
|
||||
const ExcludeEntities = ['modi', 'modiEntity', 'oper', 'operEntity', 'relation', 'relationAuth', 'actionAuth', 'userRelation'];
|
||||
for (const entity in schema) {
|
||||
if (ExcludeEntities.includes(entity)) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -117,6 +117,21 @@ export default OakComponent({
|
|||
actionAuths: $actionAuthsObject[ele],
|
||||
})
|
||||
})
|
||||
|
||||
// path 中含有user 也要特殊处理
|
||||
const hasUserActionAuths = data.filter((ele) => ele.path?.split('.').includes('user'));
|
||||
const $actionAuthsObject2 = groupBy(hasUserActionAuths, 'path');
|
||||
Object.keys($actionAuthsObject2).forEach((ele) => {
|
||||
const entities = ele.split('.');
|
||||
const se = entities[entities.length - 1].split('$')[0];
|
||||
const p = ele;
|
||||
const de = entity!;
|
||||
cascadeEntityActions.push({
|
||||
path: [de, p, se, true],
|
||||
relations: [{id: '', name: '当前用户'}],
|
||||
actionAuths: $actionAuthsObject2[ele],
|
||||
})
|
||||
})
|
||||
return {
|
||||
cascadeEntityActions,
|
||||
};
|
||||
|
|
@ -170,7 +185,8 @@ export default OakComponent({
|
|||
async onChange(checked: boolean, relationId: string, path: string, actionAuth?: ED['actionAuth']['OpSchema'], relationName?: string) {
|
||||
const { actions } = this.props;
|
||||
assert(actions && actions.length > 0);
|
||||
if (!relationId) {
|
||||
// 排除user这种情况
|
||||
if (!relationId && (relationName && relationName !== '当前用户')) {
|
||||
const se = path.split('$')[0];
|
||||
const { data: relations } = await this.features.cache.refresh('relation', {
|
||||
data: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue