userRelation的byUserEntityGrant

This commit is contained in:
Xu Chang 2022-11-24 18:42:41 +08:00
parent fbe64bdfe5
commit d845ac9994
8 changed files with 72 additions and 63 deletions

View File

@ -1 +1,8 @@
export default function render(this: any): JSX.Element;
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function Render(props: WebComponentProps<EntityDict, 'user', true, {
showBack: boolean;
variant: "alone" | "inline";
url: string;
expiresAt: number;
}, {}>): JSX.Element;

View File

@ -5,12 +5,11 @@ var jsx_runtime_1 = require("react/jsx-runtime");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var pageHeader_1 = tslib_1.__importDefault(require("../../../components/common/pageHeader"));
var qrCode_1 = tslib_1.__importDefault(require("../../../components/common/qrCode"));
function render() {
var _a = this.props, variant = _a.variant, _b = _a.showBack, showBack = _b === void 0 ? true : _b;
var _c = this.state, url = _c.url, expiresAt = _c.expiresAt;
function Render(props) {
var _a = props.data, variant = _a.variant, _b = _a.showBack, showBack = _b === void 0 ? true : _b, url = _a.url, expiresAt = _a.expiresAt;
return ((0, jsx_runtime_1.jsx)(Container, tslib_1.__assign({ showBack: showBack, variant: variant }, { children: (0, jsx_runtime_1.jsx)(qrCode_1.default, { url: url, expiresAt: expiresAt }) })));
}
exports.default = render;
exports.default = Render;
function Container(props) {
var children = props.children, _a = props.variant, variant = _a === void 0 ? 'alone' : _a, showBack = props.showBack;
if (['inline', 'dialog'].includes(variant)) {

View File

@ -18,10 +18,8 @@ exports.default = OakComponent({
isList: false,
formData: function (_a) {
var userEntityGrant = _a.data;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, (tslib_1.__assign({}, userEntityGrant))];
});
return ({
userEntityGrant: userEntityGrant,
});
},
properties: {

View File

@ -1 +1,11 @@
export default function render(this: any): JSX.Element;
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../../general-app-domain';
export default function render(props: WebComponentProps<EntityDict, 'userEntityGrant', false, {
relations: string[];
userEntityGrant: EntityDict['userEntityGrant']['OpSchema'];
userEntityGrantId: string;
}, {
confirm: (period: number) => Promise<void>;
onBack: () => void;
setInit: () => void;
}>): JSX.Element;

View File

@ -2,25 +2,26 @@
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var antd_1 = require("antd");
var detail_1 = tslib_1.__importDefault(require("../../../../pages/userEntityGrant/detail"));
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
function render() {
var _this = this;
var _a = this.state, relation = _a.relation, period = _a.period, type = _a.type, number = _a.number;
var _b = this.props, relations = _b.relations, entity = _b.entity, namespace = _b.namespace;
function render(props) {
var _a = props.data, relations = _a.relations, userEntityGrant = _a.userEntityGrant, userEntityGrantId = _a.userEntityGrantId;
var _b = userEntityGrant || {}, relation = _b.relation, type = _b.type, number = _b.number, entity = _b.entity;
var _c = props.methods, update = _c.update, t = _c.t, onBack = _c.onBack, confirm = _c.confirm, setInit = _c.setInit;
var _d = tslib_1.__read((0, react_1.useState)(undefined), 2), period = _d[0], setPeriod = _d[1];
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Alert, { showIcon: true, message: "\u63D0\u4EA4\u540E\uFF0C\u8BF7\u5C06\u4E8C\u7EF4\u7801\u53D1\u7ED9\u5F85\u5206\u4EAB\u6743\u9650\u7684\u7528\u6237\u626B\u63CF", type: "info", style: { marginBottom: 16 } }), (0, jsx_runtime_1.jsxs)(antd_1.Form, tslib_1.__assign({ labelCol: { span: 4 }, wrapperCol: { span: 8 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6743\u9650", rules: [
{
required: true,
message: '请选择一个权限',
},
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { value: relation, onChange: function (_a) {
var target = _a.target;
var value = target.value;
_this.setRelation(value);
update({ relation: value });
}, options: relations === null || relations === void 0 ? void 0 : relations.map(function (ele) { return ({
value: ele,
label: (_this.t && _this.t(entity + ':r.' + ele)) || ele,
label: (t(entity + ':r.' + ele)) || ele,
}); }) }) })), type === 'grant' && ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u4EBA\u6570", rules: [
{
required: true,
@ -29,7 +30,7 @@ function render() {
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { value: number, onChange: function (_a) {
var target = _a.target;
var value = target.value;
_this.setNumber(value);
update({ number: value });
}, options: [
{ value: 1, label: '单次' },
{ value: 10000, label: '不限次' },
@ -38,19 +39,8 @@ function render() {
required: true,
message: '请选择一个时效',
},
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { min: 1, max: 15, value: period, onChange: function (value) {
_this.setState({
period: value,
});
}, addonAfter: "\u5206\u949F" }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ wrapperCol: { offset: 4 } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () {
_this.confirm();
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () {
_this.onBack();
} }, { children: "\u8FD4\u56DE" }))] }) }))] })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ title: "\u4E8C\u7EF4\u7801", open: !!this.state.userEntityGrantId, destroyOnClose: true, maskClosable: false, footer: null, onCancel: function () {
_this.setState({
userEntityGrantId: '',
});
_this.setInit();
} }, { children: (0, jsx_runtime_1.jsx)(detail_1.default, { namespace: namespace, variant: "dialog", oakId: this.state.userEntityGrantId, oakAutoUnmount: true, oakPath: "$userRelation/upsert/byUserEntityGrant-userEntityGrant/detail" }) }))] })));
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { min: 1, max: 15, value: period, onChange: function (value) { return setPeriod(value); }, addonAfter: "\u5206\u949F" }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ wrapperCol: { offset: 4 } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () { return confirm(period); } }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () { return onBack(); } }, { children: "\u8FD4\u56DE" }))] }) }))] })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ title: "\u4E8C\u7EF4\u7801", open: !!userEntityGrantId, destroyOnClose: true, maskClosable: false, footer: null, onCancel: function () {
setInit();
} }, { children: (0, jsx_runtime_1.jsx)(detail_1.default, { variant: "dialog", oakId: userEntityGrantId, oakAutoUnmount: true, oakPath: "$userRelation/upsert/byUserEntityGrant-userEntityGrant/detail" }) }))] })));
}
exports.default = render;

View File

@ -2,10 +2,16 @@ import React, { Component } from 'react';
import Style from './web.module.less';
import PageHeader from '../../../components/common/pageHeader';
import QrCode from '../../../components/common/qrCode';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(this: any) {
const { variant, showBack = true } = this.props;
const { url, expiresAt } = this.state;
export default function Render(props: WebComponentProps<EntityDict, 'user', true, {
showBack: boolean;
variant: "alone" | "inline";
url: string;
expiresAt: number;
}, {}>) {
const { variant, showBack = true, url, expiresAt } = props.data;
return (
<Container showBack={showBack} variant={variant}>
<QrCode url={url} expiresAt={expiresAt} />

View File

@ -15,8 +15,8 @@ export default OakComponent({
granteeId: 1,
},
isList: false,
formData: async ({ data: userEntityGrant }) => ({
...userEntityGrant,
formData: ({ data: userEntityGrant }) => ({
userEntityGrant,
}),
properties: {
entity: String,

View File

@ -1,13 +1,25 @@
import React from 'react';
import React, { useState } from 'react';
import { Form, Radio, Button, Alert, InputNumber, Space, Modal } from 'antd';
import UserEntityGrantDetail from '../../../../pages/userEntityGrant/detail';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../../general-app-domain';
import Style from './web.module.less';
export default function render(this: any) {
const { relation, period, type, number } = this.state;
const { relations, entity, namespace } = this.props;
export default function render(props: WebComponentProps<EntityDict, 'userEntityGrant', false, {
relations: string[];
userEntityGrant: EntityDict['userEntityGrant']['OpSchema'];
userEntityGrantId: string;
}, {
confirm: (period: number) => Promise<void>;
onBack: () => void;
setInit: () => void;
}>) {
const { relations, userEntityGrant, userEntityGrantId } = props.data;
const { relation, type, number, entity } = userEntityGrant || {};
const { update, t, onBack, confirm, setInit } = props.methods;
const [period, setPeriod] = useState(undefined as number | undefined);
return (
<div className={Style.container}>
@ -23,7 +35,6 @@ export default function render(this: any) {
rules={[
{
required: true,
message: '请选择一个权限',
},
]}
>
@ -31,12 +42,12 @@ export default function render(this: any) {
value={relation}
onChange={({ target }) => {
const { value } = target;
this.setRelation(value);
update({ relation: value });
}}
options={relations?.map((ele: string) => ({
value: ele,
label:
(this.t && this.t(entity + ':r.' + ele)) || ele,
(t(entity + ':r.' + ele)) || ele,
}))}
/>
</Form.Item>
@ -54,7 +65,7 @@ export default function render(this: any) {
value={number}
onChange={({ target }) => {
const { value } = target;
this.setNumber(value);
update({ number: value });
}}
options={[
{ value: 1, label: '单次' },
@ -76,11 +87,7 @@ export default function render(this: any) {
min={1}
max={15}
value={period}
onChange={(value) => {
this.setState({
period: value,
});
}}
onChange={(value) => setPeriod(value!)}
addonAfter="分钟"
/>
</Form.Item>
@ -88,16 +95,12 @@ export default function render(this: any) {
<Space>
<Button
type="primary"
onClick={() => {
this.confirm();
}}
onClick={() => confirm(period!)}
>
</Button>
<Button
onClick={() => {
this.onBack();
}}
onClick={() => onBack()}
>
</Button>
@ -106,21 +109,17 @@ export default function render(this: any) {
</Form>
<Modal
title="二维码"
open={!!this.state.userEntityGrantId}
open={!!userEntityGrantId}
destroyOnClose={true}
maskClosable={false}
footer={null}
onCancel={() => {
this.setState({
userEntityGrantId: '',
});
this.setInit();
setInit();
}}
>
<UserEntityGrantDetail
namespace={namespace}
variant="dialog"
oakId={this.state.userEntityGrantId}
oakId={userEntityGrantId}
oakAutoUnmount={true}
oakPath="$userRelation/upsert/byUserEntityGrant-userEntityGrant/detail"
></UserEntityGrantDetail>