oak-frontend-base/lib/components/relation/entity/index.js

77 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
isList: false,
properties: {
entity: '',
},
data: {
checkedActions: [],
relationIds: [],
},
formData() {
const entity = this.props.entity;
const actions = this.features.relationAuth.getActions(entity);
const daas = this.features.relationAuth.getCascadeActionAuths(entity, false);
const relations = this.features.cache.get('relation', {
data: {
id: 1,
entity: 1,
entityId: 1,
name: 1,
display: 1,
},
filter: {
entity: entity,
entityId: {
$exists: false,
},
}
});
const dras = this.features.relationAuth.getCascadeRelationAuths(entity, false);
const deduceRelationAttr = this.features.relationAuth.getDeduceRelationAttribute(entity);
return {
relations,
actions,
daas,
dras,
hasDirectActionAuth: daas.length > 0,
hasDirectRelationAuth: dras.length > 0,
deduceRelationAttr,
};
},
lifetimes: {
async ready() {
const { entity } = this.props;
// 现在的数据结构可以在任意对象上增加relation这个if以后并不成立。 by Xc
if (this.features.relationAuth.hasRelation(entity)) {
await this.features.cache.refresh('relation', {
data: {
id: 1,
entity: 1,
entityId: 1,
name: 1,
display: 1,
},
filter: {
entity: entity,
entityId: {
$exists: false,
},
}
});
// 没定义entity显式的reRender
this.reRender();
}
}
},
methods: {
onActionsSelected(checkedActions) {
this.setState({ checkedActions });
},
onRelationsSelected(relationIds) {
this.setState({ relationIds });
}
}
});