Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-frontend-base into dev
This commit is contained in:
commit
7eb6221b45
|
|
@ -28,7 +28,11 @@ export default OakComponent({
|
|||
// 以entity为source 查找entity所指向的实体
|
||||
const entityDNode = links.filter((ele) => ele.source === entity).map((ele) => ele.target);
|
||||
// 以entity为target 查找指向entity的实体
|
||||
const entitySNode = links.filter((ele) => ele.target === entity).map((ele) => ele.source);
|
||||
const entitySNode = links.filter((ele) => {
|
||||
// extraFile
|
||||
const ref = this.entityToRef(ele.source, entity);
|
||||
return ele.target === ref;
|
||||
}).map((ele) => ele.source);
|
||||
this.setState({
|
||||
entityDNode,
|
||||
entitySNode,
|
||||
|
|
@ -46,6 +50,35 @@ export default OakComponent({
|
|||
});
|
||||
}
|
||||
return showExecuteTip;
|
||||
},
|
||||
entityToRef(source, target) {
|
||||
const schema = this.features.cache.getSchema();
|
||||
const { attributes } = schema[source];
|
||||
if (Object.hasOwn(attributes, 'entityId')) {
|
||||
return target;
|
||||
}
|
||||
const attr = Object.keys(attributes).find((key) => attributes[key].ref && attributes[key].ref === target);
|
||||
return attr ? attr.replace('Id', '') : '';
|
||||
},
|
||||
resolveP(path) {
|
||||
const destEntity = this.props.entity;
|
||||
const schema = this.features.cache.getSchema();
|
||||
if (path === '') {
|
||||
return destEntity;
|
||||
}
|
||||
const splitArr = path.split('.');
|
||||
splitArr.unshift(destEntity);
|
||||
for (let i = 1; i < splitArr.length; i++) {
|
||||
if (splitArr[i].includes('$')) {
|
||||
splitArr[i] = splitArr[i].split('$')[0];
|
||||
continue;
|
||||
}
|
||||
// 用已解析的前项来解析后项
|
||||
const { attributes } = schema[splitArr[i - 1]];
|
||||
const { ref } = attributes[`${splitArr[i]}Id`];
|
||||
splitArr[i] = ref;
|
||||
}
|
||||
return splitArr[splitArr.length - 1];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
|
|||
}, {
|
||||
getNodes: (entity: keyof ED) => void;
|
||||
checkSelectRelation: () => boolean;
|
||||
resolveP: (path: string) => string;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import ActionAuthList from '../actionAuthList';
|
|||
export default function render(props) {
|
||||
const { methods, data } = props;
|
||||
const { entity, entityDNode, entitySNode, oakFullpath } = data;
|
||||
const { getNodes, checkSelectRelation } = methods;
|
||||
const { getNodes, checkSelectRelation, resolveP } = methods;
|
||||
const [open, setOpen] = useState(false);
|
||||
const [breadcrumbItems, setBreadcrumbItems] = useState([]);
|
||||
return (_jsxs(Space, { direction: "vertical", style: { width: '100%' }, children: [_jsx(Button, { onClick: () => setOpen(true), children: "\u8BBE\u7F6E" }), _jsx(Modal, { title: `权限设置`, open: open, destroyOnClose: true, footer: null, onCancel: () => {
|
||||
|
|
@ -32,7 +32,9 @@ export default function render(props) {
|
|||
}
|
||||
breadcrumbItems.push(ele);
|
||||
setBreadcrumbItems(breadcrumbItems);
|
||||
getNodes(ele);
|
||||
const path = breadcrumbItems.join('.');
|
||||
const entity = resolveP(path);
|
||||
getNodes(entity);
|
||||
}, children: ele }))) }) })] }), _jsxs(Row, { gutter: 24, children: [_jsx(Col, { span: 2, children: _jsx(Text, { style: { whiteSpace: 'nowrap', marginRight: 16 }, children: "\u53CD\u6307\u7ED3\u70B9" }) }), _jsx(Col, { span: 22, children: _jsx(Space, { wrap: true, children: entitySNode.map((ele) => (_jsx(Tag, { style: { cursor: 'pointer' }, color: "cyan", bordered: false, onClick: () => {
|
||||
if (checkSelectRelation()) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -369,6 +369,7 @@ export class Cache extends Feature {
|
|||
dontCollect: true,
|
||||
dontCreateOper: true,
|
||||
dontCreateModi: true,
|
||||
blockTrigger: true,
|
||||
});
|
||||
}
|
||||
this.rollback();
|
||||
|
|
|
|||
|
|
@ -89,11 +89,17 @@ export class RelationAuth extends Feature {
|
|||
nodeOutSet[entity].push(`${attr.replace('Id', '')}(${ref})`);
|
||||
}
|
||||
else {
|
||||
nodeOutSet[entity].push(ref);
|
||||
nodeOutSet[entity].push(`${attr.replace('Id', '')}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nodeOutSet[entity] = [ref];
|
||||
// 如果外键ref是user 使用属性名(user)以解决relation/entityList页面授权路径不对的问题
|
||||
if (ref === "user") {
|
||||
nodeOutSet[entity] = [`${attr.replace('Id', '')}(${ref})`];
|
||||
}
|
||||
else {
|
||||
nodeOutSet[entity] = [`${attr.replace('Id', '')}`];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,16 @@ exports.default = OakComponent({
|
|||
},
|
||||
methods: {
|
||||
getNodes: function (entity) {
|
||||
var _this = this;
|
||||
var links = this.state.links;
|
||||
// 以entity为source 查找entity所指向的实体
|
||||
var entityDNode = links.filter(function (ele) { return ele.source === entity; }).map(function (ele) { return ele.target; });
|
||||
// 以entity为target 查找指向entity的实体
|
||||
var entitySNode = links.filter(function (ele) { return ele.target === entity; }).map(function (ele) { return ele.source; });
|
||||
var entitySNode = links.filter(function (ele) {
|
||||
// extraFile
|
||||
var ref = _this.entityToRef(ele.source, entity);
|
||||
return ele.target === ref;
|
||||
}).map(function (ele) { return ele.source; });
|
||||
this.setState({
|
||||
entityDNode: entityDNode,
|
||||
entitySNode: entitySNode,
|
||||
|
|
@ -57,6 +62,35 @@ exports.default = OakComponent({
|
|||
});
|
||||
}
|
||||
return showExecuteTip;
|
||||
},
|
||||
entityToRef: function (source, target) {
|
||||
var schema = this.features.cache.getSchema();
|
||||
var attributes = schema[source].attributes;
|
||||
if (Object.hasOwn(attributes, 'entityId')) {
|
||||
return target;
|
||||
}
|
||||
var attr = Object.keys(attributes).find(function (key) { return attributes[key].ref && attributes[key].ref === target; });
|
||||
return attr ? attr.replace('Id', '') : '';
|
||||
},
|
||||
resolveP: function (path) {
|
||||
var destEntity = this.props.entity;
|
||||
var schema = this.features.cache.getSchema();
|
||||
if (path === '') {
|
||||
return destEntity;
|
||||
}
|
||||
var splitArr = path.split('.');
|
||||
splitArr.unshift(destEntity);
|
||||
for (var i = 1; i < splitArr.length; i++) {
|
||||
if (splitArr[i].includes('$')) {
|
||||
splitArr[i] = splitArr[i].split('$')[0];
|
||||
continue;
|
||||
}
|
||||
// 用已解析的前项来解析后项
|
||||
var attributes = schema[splitArr[i - 1]].attributes;
|
||||
var ref = attributes["".concat(splitArr[i], "Id")].ref;
|
||||
splitArr[i] = ref;
|
||||
}
|
||||
return splitArr[splitArr.length - 1];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
|
|||
}, {
|
||||
getNodes: (entity: keyof ED) => void;
|
||||
checkSelectRelation: () => boolean;
|
||||
resolveP: (path: string) => string;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ 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;
|
||||
var getNodes = methods.getNodes, checkSelectRelation = methods.checkSelectRelation;
|
||||
var getNodes = methods.getNodes, checkSelectRelation = methods.checkSelectRelation, resolveP = methods.resolveP;
|
||||
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)([]), 2), breadcrumbItems = _b[0], setBreadcrumbItems = _b[1];
|
||||
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, { direction: "vertical", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { onClick: function () { return setOpen(true); }, children: "\u8BBE\u7F6E" }), (0, jsx_runtime_1.jsx)(antd_1.Modal, { title: "\u6743\u9650\u8BBE\u7F6E", open: open, destroyOnClose: true, footer: null, onCancel: function () {
|
||||
|
|
@ -35,7 +35,9 @@ function render(props) {
|
|||
}
|
||||
breadcrumbItems.push(ele);
|
||||
setBreadcrumbItems(breadcrumbItems);
|
||||
getNodes(ele);
|
||||
var path = breadcrumbItems.join('.');
|
||||
var entity = resolveP(path);
|
||||
getNodes(entity);
|
||||
}, children: ele })); }) }) })] }), (0, jsx_runtime_1.jsxs)(antd_1.Row, { gutter: 24, children: [(0, jsx_runtime_1.jsx)(antd_1.Col, { span: 2, children: (0, jsx_runtime_1.jsx)(Text, { style: { whiteSpace: 'nowrap', marginRight: 16 }, children: "\u53CD\u6307\u7ED3\u70B9" }) }), (0, jsx_runtime_1.jsx)(antd_1.Col, { span: 22, children: (0, jsx_runtime_1.jsx)(antd_1.Space, { wrap: true, children: entitySNode.map(function (ele) { return ((0, jsx_runtime_1.jsx)(antd_1.Tag, { style: { cursor: 'pointer' }, color: "cyan", bordered: false, onClick: function () {
|
||||
if (checkSelectRelation()) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -438,6 +438,7 @@ var Cache = /** @class */ (function (_super) {
|
|||
dontCollect: true,
|
||||
dontCreateOper: true,
|
||||
dontCreateModi: true,
|
||||
blockTrigger: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,11 +90,17 @@ var RelationAuth = /** @class */ (function (_super) {
|
|||
nodeOutSet[entity].push("".concat(attr.replace('Id', ''), "(").concat(ref, ")"));
|
||||
}
|
||||
else {
|
||||
nodeOutSet[entity].push(ref);
|
||||
nodeOutSet[entity].push("".concat(attr.replace('Id', '')));
|
||||
}
|
||||
}
|
||||
else {
|
||||
nodeOutSet[entity] = [ref];
|
||||
// 如果外键ref是user 使用属性名(user)以解决relation/entityList页面授权路径不对的问题
|
||||
if (ref === "user") {
|
||||
nodeOutSet[entity] = ["".concat(attr.replace('Id', ''), "(").concat(ref, ")")];
|
||||
}
|
||||
else {
|
||||
nodeOutSet[entity] = ["".concat(attr.replace('Id', ''))];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,11 @@ export default OakComponent({
|
|||
// 以entity为source 查找entity所指向的实体
|
||||
const entityDNode = links.filter((ele) => ele.source === entity).map((ele) => ele.target);
|
||||
// 以entity为target 查找指向entity的实体
|
||||
const entitySNode = links.filter((ele) => ele.target === entity).map((ele) => ele.source);
|
||||
const entitySNode = links.filter((ele) => {
|
||||
// extraFile
|
||||
const ref = this.entityToRef(ele.source, entity);
|
||||
return ele.target === ref;
|
||||
}).map((ele) => ele.source);
|
||||
this.setState({
|
||||
entityDNode,
|
||||
entitySNode,
|
||||
|
|
@ -56,6 +60,36 @@ export default OakComponent({
|
|||
})
|
||||
}
|
||||
return showExecuteTip
|
||||
},
|
||||
entityToRef(source: keyof ED, target: keyof ED): string {
|
||||
const schema = this.features.cache.getSchema();
|
||||
|
||||
const { attributes } = schema[source];
|
||||
if (Object.hasOwn(attributes, 'entityId')) {
|
||||
return target as string;
|
||||
}
|
||||
const attr = Object.keys(attributes).find((key) => attributes[key].ref && attributes[key].ref === target);
|
||||
return attr ? attr.replace('Id', '') : '';
|
||||
},
|
||||
resolveP(path: string): string {
|
||||
const destEntity = this.props.entity;
|
||||
const schema = this.features.cache.getSchema();
|
||||
if (path === '') {
|
||||
return destEntity as string;
|
||||
}
|
||||
const splitArr = path.split('.');
|
||||
splitArr.unshift(destEntity as string);
|
||||
for (let i = 1; i < splitArr.length; i++) {
|
||||
if (splitArr[i].includes('$')) {
|
||||
splitArr[i] = splitArr[i].split('$')[0];
|
||||
continue;
|
||||
}
|
||||
// 用已解析的前项来解析后项
|
||||
const { attributes } = schema[splitArr[i - 1]];
|
||||
const { ref } = attributes[`${splitArr[i]}Id`];
|
||||
splitArr[i] = ref as string;
|
||||
}
|
||||
return splitArr[splitArr.length - 1];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -17,10 +17,11 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
|
|||
}, {
|
||||
getNodes: (entity: keyof ED) => void;
|
||||
checkSelectRelation: () => boolean;
|
||||
resolveP: (path: string) => string;
|
||||
}>) {
|
||||
const { methods, data } = props;
|
||||
const { entity, entityDNode, entitySNode, oakFullpath } = data;
|
||||
const { getNodes, checkSelectRelation } = methods;
|
||||
const { getNodes, checkSelectRelation, resolveP } = methods;
|
||||
const [open, setOpen] = useState(false);
|
||||
const [breadcrumbItems, setBreadcrumbItems] = useState<string[]>([])
|
||||
return (
|
||||
|
|
@ -97,8 +98,10 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
|
|||
return;
|
||||
}
|
||||
breadcrumbItems.push(ele);
|
||||
setBreadcrumbItems(breadcrumbItems)
|
||||
getNodes(ele)
|
||||
setBreadcrumbItems(breadcrumbItems);
|
||||
const path = breadcrumbItems.join('.');
|
||||
const entity = resolveP(path);
|
||||
getNodes(entity)
|
||||
}}
|
||||
>
|
||||
{ele}
|
||||
|
|
|
|||
|
|
@ -486,6 +486,7 @@ export class Cache<
|
|||
dontCollect: true,
|
||||
dontCreateOper: true,
|
||||
dontCreateModi: true,
|
||||
blockTrigger: true,
|
||||
});
|
||||
}
|
||||
this.rollback();
|
||||
|
|
|
|||
|
|
@ -133,11 +133,17 @@ export class RelationAuth<
|
|||
nodeOutSet[entity].push(`${attr.replace('Id', '')}(${ref})`);
|
||||
}
|
||||
else {
|
||||
nodeOutSet[entity].push(ref);
|
||||
nodeOutSet[entity].push(`${attr.replace('Id', '')}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nodeOutSet[entity] = [ref];
|
||||
// 如果外键ref是user 使用属性名(user)以解决relation/entityList页面授权路径不对的问题
|
||||
if (ref === "user") {
|
||||
nodeOutSet[entity] = [`${attr.replace('Id', '')}(${ref})`];
|
||||
}
|
||||
else {
|
||||
nodeOutSet[entity] = [`${attr.replace('Id', '')}`];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue