This commit is contained in:
Wang Kejun 2022-11-28 20:01:19 +08:00
parent f7386afb63
commit bcf202fa5a
20 changed files with 214 additions and 115 deletions

View File

@ -1,38 +0,0 @@
/** index.wxss **/
@import "../../../config/styles/mp/index.less";
@import "../../../config/styles/mp/mixins.less";
.page-body {
height: 100vh;
display: flex;
flex: 1;
flex-direction: column;
box-sizing: border-box;
align-items: stretch;
background-color: @bg-color-fade;
.safe-area-inset-bottom();
}
.container {
display: flex;
flex-direction: column;
flex: 1;
}
.card {
display: flex;
background-color: #fff;
padding: @spacer;
margin: @spacer;
margin-bottom: 0;
align-items: center;
justify-content: space-between;
text {
font-size: x-large;
}
}
.btn-box {
display: flex;
align-items: center;
justify-content: center;
}

View File

@ -1,2 +1,23 @@
/// <reference types="react" />
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', true, {
oakLoading: boolean;
oakExecuting: boolean;
type: 'grant';
expired: boolean;
relation: boolean;
expiresAt: boolean;
granter?: {
name: string;
nickname: string;
};
entity: string;
isExists: boolean;
granteeId: string;
number: number;
confirmed: number;
userId: string;
}, {
handleConfirm: () => void;
}>): JSX.Element;

View File

@ -6,14 +6,14 @@ var antd_1 = require("antd");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var icons_1 = require("@ant-design/icons");
var utils_1 = require("oak-frontend-base/lib/utils/utils");
function render() {
var _this = this;
var _a = this.state, oakLoading = _a.oakLoading, oakExecuting = _a.oakExecuting, type = _a.type, expired = _a.expired, relation = _a.relation, expiresAt = _a.expiresAt, granter = _a.granter, entity = _a.entity, isExists = _a.isExists, //当前用户关系是否存在
function render(props) {
var _a = props.data, oakLoading = _a.oakLoading, oakExecuting = _a.oakExecuting, type = _a.type, expired = _a.expired, relation = _a.relation, expiresAt = _a.expiresAt, granter = _a.granter, entity = _a.entity, isExists = _a.isExists, //当前用户关系是否存在
granteeId = _a.granteeId, number = _a.number, confirmed = _a.confirmed, userId = _a.userId;
var _b = props.methods, t = _b.t, handleConfirm = _b.handleConfirm;
var isOwner = !!(granteeId && userId === granteeId);
var getRelationTip = function () {
var str = "".concat((granter === null || granter === void 0 ? void 0 : granter.name) || (granter === null || granter === void 0 ? void 0 : granter.nickname));
var relationStr = relation ? _this.t("".concat(entity, ":r.").concat(relation)) : '';
var relationStr = relation ? t("".concat(entity, ":r.").concat(relation)) : '';
if (type === 'grant') {
str = str.concat('授予您【').concat(relationStr).concat('】权限');
return str;
@ -28,14 +28,14 @@ function render() {
if (expired) {
return '已过期,请联系相关人员重新分享';
}
// number设置1个的时候
// number设置1个的时候
if (number === 1 && confirmed > 0 && (!isOwner || !isExists)) {
return '被他人已领取';
}
return '请您领取';
};
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.content }, { children: [type === 'grant' ? ((0, jsx_runtime_1.jsx)(icons_1.UserAddOutlined, { className: web_module_less_1.default.icon })) : ((0, jsx_runtime_1.jsx)(icons_1.UserSwitchOutlined, { className: web_module_less_1.default.icon })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.title }, { children: getRelationTip() })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.description }, { children: getDescTip() }))] })), (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: [!oakLoading && !expired && !isExists && !isOwner && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ block: true, type: "primary", onClick: function () {
_this.handleConfirm();
handleConfirm();
}, disabled: oakExecuting }, { children: "\u9886\u53D6" }))), utils_1.isWeiXin && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ block: true, onClick: function () {
WeixinJSBridge.call('closeWindow');
} }, { children: "\u5173\u95ED" })))] }))] })));

View File

@ -1,2 +1,2 @@
/// <reference types="react" />
export default function render(): JSX.Element;
export default function Render(props: any): JSX.Element;

View File

@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var jsx_runtime_1 = require("react/jsx-runtime");
function render() {
function Render(props) {
return ((0, jsx_runtime_1.jsx)("div", { children: "react" }));
}
exports.default = render;
exports.default = Render;

View File

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

View File

@ -17,11 +17,7 @@ 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 (tslib_1.__assign({}, userEntityGrant || {}));
},
properties: {
entity: String,
@ -57,6 +53,11 @@ exports.default = OakComponent({
number: value,
});
},
setPeriod: function (value) {
this.update({
period: value,
});
},
onBack: function () {
this.navigateBack();
},

View File

@ -1,2 +1,18 @@
/// <reference types="react" />
export default function render(this: any): JSX.Element;
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function render(props: WebComponentProps<EntityDict, 'token', false, {
relation: string;
type: 'grant';
number: number;
period: number;
relations: string[];
entity: string;
entityId: string;
}, {
confirm: () => void;
reset: () => void;
setRelation: (value: string) => void;
setNumber: (value: string) => void;
setPeriod: (value: number | null) => void;
}>): JSX.Element;

View File

@ -4,21 +4,19 @@ var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
function render() {
var _this = this;
var _a = this.state, relation = _a.relation, type = _a.type, number = _a.number, period = _a.period;
var _b = this.props, relations = _b.relations, entity = _b.entity, entityId = _b.entityId;
function render(props) {
var _a = props.data, relation = _a.relation, type = _a.type, number = _a.number, period = _a.period, relations = _a.relations, entity = _a.entity, entityId = _a.entityId;
var _b = props.methods, t = _b.t, confirm = _b.confirm, reset = _b.reset, setRelation = _b.setRelation, setNumber = _b.setNumber, setPeriod = _b.setPeriod;
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.pageWithPadding }, { children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.formContainer }, { children: (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 (value) {
_this.setRelation(value);
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { value: relation, onChange: function (e) {
setRelation(e.target.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),
}); }) }) })), type === 'grant' && ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u4EBA\u6570", rules: [
{
required: true,
@ -27,7 +25,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);
setNumber(value);
}, options: [
{ value: 1, label: '单次' },
{ value: 10000, label: '不限次' },
@ -37,13 +35,11 @@ function render() {
message: '请选择一个时效',
},
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { min: 1, max: 15, value: period, onChange: function (value) {
_this.setState({
period: value,
});
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({ htmlType: "submit", type: "primary", onClick: function () {
_this.confirm();
confirm();
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ htmlType: "reset", onClick: function () {
_this.reset();
reset();
} }, { children: "\u91CD\u7F6E" }))] }) }))] })) })) })));
}
exports.default = render;

View File

@ -1,2 +1,8 @@
/// <reference types="react" />
export default function render(this: any): JSX.Element;
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function render(props: WebComponentProps<EntityDict, 'token', false, {
oakLoading: boolean;
isExist: boolean;
expired: boolean;
}, {}>): JSX.Element;

View File

@ -6,8 +6,8 @@ var icons_1 = require("@ant-design/icons");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var success_1 = tslib_1.__importDefault(require("../../../components/common/result/success"));
var fail_1 = tslib_1.__importDefault(require("../../../components/common/result/fail"));
function render() {
var _a = this.state, oakLoading = _a.oakLoading, isExist = _a.isExist, expired = _a.expired;
function render(props) {
var _a = props.data, oakLoading = _a.oakLoading, isExist = _a.isExist, expired = _a.expired;
var V;
if (oakLoading) {
V = ((0, jsx_runtime_1.jsx)(success_1.default, { icon: (0, jsx_runtime_1.jsx)(icons_1.LoadingOutlined, { className: web_module_less_1.default.brand_icon }), title: "\u52A0\u8F7D\u4E2D", description: "\u6B63\u5728\u83B7\u53D6\u6570\u636E\uFF0C\u8BF7\u7A0D\u540E" }));

View File

@ -1,2 +1,7 @@
/// <reference types="react" />
export default function render(this: any): JSX.Element;
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function render(props: WebComponentProps<EntityDict, 'token', false, {
error: string;
loading: boolean;
}, {}>): JSX.Element;

View File

@ -8,8 +8,8 @@ var utils_1 = require("oak-frontend-base/lib/utils/utils");
var fail_1 = tslib_1.__importDefault(require("../../../components/common/result/fail"));
var success_1 = tslib_1.__importDefault(require("../../../components/common/result/success"));
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
function render() {
var _a = this.state, error = _a.error, loading = _a.loading;
function render(props) {
var _a = props.data, error = _a.error, loading = _a.loading;
var V;
if (loading) {
V = ((0, jsx_runtime_1.jsx)(success_1.default, { icon: (0, jsx_runtime_1.jsx)(icons_1.LoadingOutlined, { className: web_module_less_1.default.brand_icon }), title: "\u767B\u5F55\u4E2D", description: "\u6B63\u5728\u767B\u5F55..\uFF0C\u8BF7\u7A0D\u540E" }));

View File

@ -5,8 +5,37 @@ import { UserAddOutlined, UserSwitchOutlined } from '@ant-design/icons';
import { isWeiXin } from 'oak-frontend-base/lib/utils/utils';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(this: any) {
export default function render(
props: WebComponentProps<
EntityDict,
'userEntityGrant',
true,
{
oakLoading: boolean;
oakExecuting: boolean;
type: 'grant';
expired: boolean;
relation: boolean;
expiresAt: boolean;
granter?: {
name: string;
nickname: string;
};
entity: string;
isExists: boolean; //当前用户关系是否存在
granteeId: string;
number: number;
confirmed: number;
userId: string;
},
{
handleConfirm: () => void;
}
>
) {
const {
oakLoading,
oakExecuting,
@ -21,12 +50,13 @@ export default function render(this: any) {
number,
confirmed,
userId,
} = this.state;
} = props.data;
const { t, handleConfirm } = props.methods;
const isOwner = !!(granteeId && userId === granteeId);
const getRelationTip = () => {
let str = `${granter?.name || granter?.nickname}`;
const relationStr = relation ? this.t(`${entity}:r.${relation}`) : '';
const relationStr = relation ? t(`${entity}:r.${relation}`) : '';
if (type === 'grant') {
str = str.concat('授予您【').concat(relationStr).concat('】权限');
return str;
@ -42,14 +72,13 @@ export default function render(this: any) {
if (expired) {
return '已过期,请联系相关人员重新分享';
}
// number设置1个的时候
// number设置1个的时候
if (number === 1 && confirmed > 0 && (!isOwner || !isExists)) {
return '被他人已领取';
}
return '请您领取';
}
};
return (
<div className={Style.container}>
@ -69,7 +98,7 @@ export default function render(this: any) {
block
type="primary"
onClick={() => {
this.handleConfirm();
handleConfirm();
}}
disabled={oakExecuting}
>

View File

@ -5,13 +5,21 @@ import QrCode from '../../../components/common/qrCode';
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;
}, {}>) {
const { variant, showBack = true, url, expiresAt } = props.data;
export default function Render(
props: WebComponentProps<
EntityDict,
'userEntityGrant',
true,
{
showBack: boolean;
variant: 'alone' | 'inline' | 'dialog';
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

@ -1,7 +1,7 @@
import React, { Component } from 'react';
import Style from './mobile.module.less';
export default function render() {
export default function Render(props: any) {
return (
<div>
react

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,
@ -52,6 +52,11 @@ export default OakComponent({
number: value,
});
},
setPeriod(value: number) {
this.update({
period: value,
});
},
onBack() {
this.navigateBack();
},

View File

@ -2,9 +2,36 @@ import React from 'react';
import { Form, Radio, Button, Space, InputNumber } from 'antd';
import Style from './web.module.less';
export default function render(this: any) {
const { relation, type, number, period } = this.state;
const { relations, entity, entityId } = this.props;
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function render(
props: WebComponentProps<
EntityDict,
'token',
false,
{
relation: string;
type: 'grant';
number: number;
period: number;
relations: string[];
entity: string;
entityId: string;
},
{
confirm: () => void;
reset: () => void;
setRelation: (value: string) => void;
setNumber: (value: string) => void;
setPeriod: (value: number | null) => void;
}
>
) {
const { relation, type, number, period, relations, entity, entityId } =
props.data;
const { t, confirm, reset, setRelation, setNumber, setPeriod } =
props.methods;
return (
<div className={Style.pageWithPadding}>
@ -21,14 +48,12 @@ export default function render(this: any) {
>
<Radio.Group
value={relation}
onChange={(value) => {
this.setRelation(value);
onChange={(e) => {
setRelation(e.target.value);
}}
options={relations?.map((ele: string) => ({
value: ele,
label:
(this.t && this.t(entity + ':r.' + ele)) ||
ele,
label: t(entity + ':r.' + ele),
}))}
></Radio.Group>
</Form.Item>
@ -46,7 +71,7 @@ export default function render(this: any) {
value={number}
onChange={({ target }) => {
const { value } = target;
this.setNumber(value);
setNumber(value);
}}
options={[
{ value: 1, label: '单次' },
@ -69,9 +94,7 @@ export default function render(this: any) {
max={15}
value={period}
onChange={(value) => {
this.setState({
period: value,
});
setPeriod(value);
}}
addonAfter="分钟"
/>
@ -82,7 +105,7 @@ export default function render(this: any) {
htmlType="submit"
type="primary"
onClick={() => {
this.confirm();
confirm();
}}
>
@ -90,7 +113,7 @@ export default function render(this: any) {
<Button
htmlType="reset"
onClick={() => {
this.reset();
reset();
}}
>

View File

@ -7,8 +7,23 @@ import Style from './web.module.less';
import Success from '../../../components/common/result/success';
import Fail from '../../../components/common/result/fail';
export default function render(this: any) {
const { oakLoading, isExist, expired } = this.state;
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function render(
props: WebComponentProps<
EntityDict,
'token',
false,
{
oakLoading: boolean;
isExist: boolean;
expired: boolean;
},
{}
>
) {
const { oakLoading, isExist, expired } = props.data;
let V;
if (oakLoading) {

View File

@ -7,8 +7,22 @@ import Success from '../../../components/common/result/success';
import Style from './web.module.less';
export default function render(this: any) {
const { error, loading } = this.state;
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function render(
props: WebComponentProps<
EntityDict,
'token',
false,
{
error: string;
loading: boolean;
},
{}
>
) {
const { error, loading } = props.data;
let V;
if (loading) {
@ -19,8 +33,7 @@ export default function render(this: any) {
description="正在登录..,请稍后"
/>
);
}
else if (error) {
} else if (error) {
V = (
<Fail
title={error}
@ -38,7 +51,6 @@ export default function render(this: any) {
)}
</Fail>
);
}
return <div className={Style.container}>{V}</div>;