虚拟登陆 注册企业

This commit is contained in:
wangwenchen 2023-08-01 18:23:30 +08:00
parent 15c976fb5d
commit b04c1e5310
19 changed files with 309 additions and 63 deletions

View File

@ -50,5 +50,23 @@ var checkers = [
(0, assert_1.default)(data.user && data.user.action === 'create');
},
},
{
type: 'row',
entity: 'parasite',
action: ['cancel'],
errMsg: '您没有设置失效的权限',
filter: {
expired: false,
},
},
{
type: 'row',
entity: 'parasite',
action: ['qrcode'],
errMsg: '您没有查看二维码的权限',
filter: {
expired: false,
},
},
];
exports.default = checkers;

View File

@ -24,4 +24,17 @@ exports.default = OakComponent({
expiresAt: parasite === null || parasite === void 0 ? void 0 : parasite.expiresAt,
};
},
methods: {
copy: function (text) {
var _this = this;
if (text) {
navigator.clipboard.writeText(text).then(function () {
_this.setMessage({
content: '复制成功',
type: 'success',
});
});
}
},
}
});

View File

@ -6,4 +6,6 @@ export default function Render(props: WebComponentProps<EntityDict, 'userEntityG
url: string;
expiresAt: number;
title?: string;
}, {}>): import("react/jsx-runtime").JSX.Element;
}, {
copy: (text: string) => void;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -4,12 +4,25 @@ var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var qrCode_1 = tslib_1.__importDefault(require("../../../components/common/qrCode"));
var antd_1 = require("antd");
var icons_1 = require("@ant-design/icons");
function Render(props) {
var _a = props.data, url = _a.url, expiresAt = _a.expiresAt, oakLoading = _a.oakLoading;
var copy = props.methods.copy;
return oakLoading ? ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: {
display: 'flex',
justifyContent: 'center',
padding: '48px',
} }, { children: (0, jsx_runtime_1.jsx)(antd_1.Spin, { size: "large" }) }))) : ((0, jsx_runtime_1.jsx)(qrCode_1.default, { url: url, expiresAt: expiresAt }));
} }, { children: (0, jsx_runtime_1.jsx)(antd_1.Spin, { size: "large" }) }))) : ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ style: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
padding: '48px',
} }, { children: [(0, jsx_runtime_1.jsx)(qrCode_1.default, { url: url, expiresAt: expiresAt }), (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ style: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
} }, { children: [url, (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "text", icon: (0, jsx_runtime_1.jsx)(icons_1.CopyOutlined, {}), onClick: function () { return copy(url); } }, { children: "\u590D\u5236\u94FE\u63A5" }))] }))] })));
}
exports.default = Render;

View File

@ -16,6 +16,9 @@ exports.default = OakComponent({
nickname: 1,
}
},
actions: [
'cancel'
],
properties: {
entity: '',
entityId: '',

View File

@ -5,4 +5,9 @@ export default function render(props: WebComponentProps<EntityDict, 'parasite',
list: EntityDict['userEntityGrant']['Schema'][];
showBack: boolean;
variant?: 'inline' | 'alone' | 'dialog';
}, {}>): import("react/jsx-runtime").JSX.Element;
qrCodeUrl: string;
qrCodeExpiresAt: number;
}, {
cancel: () => void;
getQrCode: () => Promise<void>;
}>): import("react/jsx-runtime").JSX.Element;

View File

@ -5,50 +5,119 @@ var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var actionBtnPanel_1 = tslib_1.__importDefault(require("@oak-frontend-base/components/actionBtnPanel"));
var detail_1 = tslib_1.__importDefault(require("../detail"));
var react_1 = require("react");
function render(props) {
var _a = props.data, oakPagination = _a.oakPagination, oakFullpath = _a.oakFullpath, _b = _a.list, list = _b === void 0 ? [] : _b, oakLoading = _a.oakLoading, variant = _a.variant;
var _this = this;
var _a = props.data, oakPagination = _a.oakPagination, oakFullpath = _a.oakFullpath, _b = _a.list, list = _b === void 0 ? [] : _b, oakLoading = _a.oakLoading, variant = _a.variant, qrCodeUrl = _a.qrCodeUrl, qrCodeExpiresAt = _a.qrCodeExpiresAt;
var _c = oakPagination || {}, pageSize = _c.pageSize, total = _c.total, currentPage = _c.currentPage;
var _d = props.methods, t = _d.t, setPageSize = _d.setPageSize, setCurrentPage = _d.setCurrentPage;
return ((0, jsx_runtime_1.jsx)(Container, tslib_1.__assign({ variant: variant }, { children: (0, jsx_runtime_1.jsx)(antd_1.Table, { loading: oakLoading, dataSource: list, rowKey: "id", columns: [
{
dataIndex: 'id',
title: '#',
render: function (value, record, index) {
return index + 1;
var _d = props.methods, t = _d.t, setPageSize = _d.setPageSize, setCurrentPage = _d.setCurrentPage, updateItem = _d.updateItem, execute = _d.execute, getQrCode = _d.getQrCode;
var _e = tslib_1.__read((0, react_1.useState)(false), 2), qrCodeOpen = _e[0], setQrCodeOpen = _e[1];
var _f = tslib_1.__read((0, react_1.useState)(''), 2), parasiteId = _f[0], setParasiteId = _f[1];
return ((0, jsx_runtime_1.jsxs)(Container, tslib_1.__assign({ variant: variant }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Table, { loading: oakLoading, dataSource: list, rowKey: "id", columns: [
{
dataIndex: 'id',
title: '#',
render: function (value, record, index) {
return index + 1;
},
},
},
{
dataIndex: ['user', 'nickname'],
title: '姓名',
render: function (value, record, index) {
return value || '--';
{
dataIndex: ['user', 'nickname'],
title: '姓名',
render: function (value, record, index) {
return value || '--';
},
},
},
{
dataIndex: '$$createAt$$',
title: '创建时间',
render: function (value, record, index) {
return (0, dayjs_1.default)(value).format('YYYY-MM-DD HH:mm');
{
dataIndex: '$$createAt$$',
title: '创建时间',
render: function (value, record, index) {
return (0, dayjs_1.default)(value).format('YYYY-MM-DD HH:mm');
},
},
},
{
dataIndex: 'expired',
title: '状态',
render: function (value, record, index) {
return ((0, jsx_runtime_1.jsxs)(antd_1.Typography.Text, tslib_1.__assign({ type: record.expired ? 'danger' : 'success' }, { children: [record.expired ? '失效' : '有效', !record.expired && ((0, jsx_runtime_1.jsxs)(antd_1.Typography.Text, { children: ["\u00A0", (0, dayjs_1.default)(record.expiresAt).format('YYYY-MM-DD HH:mm')] }))] })));
{
dataIndex: 'expired',
title: '状态',
render: function (value, record, index) {
return ((0, jsx_runtime_1.jsxs)(antd_1.Typography.Text, tslib_1.__assign({ type: record.expired ? 'danger' : 'success' }, { children: [record.expired ? '失效' : '有效', !record.expired && ((0, jsx_runtime_1.jsxs)(antd_1.Typography.Text, { children: ["\u00A0", (0, dayjs_1.default)(record.expiresAt).format('YYYY-MM-DD HH:mm')] }))] })));
},
},
},
], pagination: {
total: total,
pageSize: pageSize,
current: currentPage,
onShowSizeChange: function (pageSize) {
setPageSize(pageSize);
},
onChange: function (current) {
setCurrentPage(current);
},
} }) })));
// {
// dataIndex: 'op',
// width: 200,
// title: '操作',
// align: 'center',
// render: (value, record, index) => {
// return (
// <>
// <Button
// type="link"
// onClick={() => {
// updateItem(
// {
// expired: true
// },
// record.id!,
// 'cancel'
// );
// execute();
// }}
// >
// 失效
// </Button>
// </>
// );
// },
// fixed: 'right',
// },
{
width: 200,
title: '操作',
key: 'action',
align: 'center',
fixed: 'right',
render: function (value, record, rowIndex) {
var _a;
return ((0, jsx_runtime_1.jsx)(actionBtnPanel_1.default, { mode: "table-cell", entity: "parasite", items: [
{
label: '失效',
action: 'cancel',
// alerted: true,
show: (_a = record['#oakLegalActions']) === null || _a === void 0 ? void 0 : _a.includes('cancel'),
onClick: function () {
updateItem({ expired: true }, record.id, 'cancel');
execute();
},
},
{
label: '采集码',
// alerted: true,
onClick: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
setParasiteId(record.id);
setQrCodeOpen(true);
return [2 /*return*/];
});
}); },
},
] }));
},
}
], pagination: {
total: total,
pageSize: pageSize,
current: currentPage,
onShowSizeChange: function (pageSize) {
setPageSize(pageSize);
},
onChange: function (current) {
setCurrentPage(current);
},
} }), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ width: 786, open: qrCodeOpen, destroyOnClose: true, onCancel: function () {
setQrCodeOpen(false);
}, footer: null }, { children: (0, jsx_runtime_1.jsx)(detail_1.default, { oakId: parasiteId, oakAutoUnmount: true, oakPath: "$parasite/list-parasite/detail" }) }))] })));
}
exports.default = render;
function Container(props) {

View File

@ -342,11 +342,11 @@ var BackendRuntimeContext = /** @class */ (function (_super) {
if (userState === 'disabled') {
throw new Exception_1.OakUserDisabledException('您的帐号已经被禁用,请联系客服');
}
else if (['shadow', 'merged'].includes(userState)) {
else if (['merged'].includes(userState)) {
throw new Exception_1.OakTokenExpiredException('您的登录状态有异常,请重新登录 ');
}
else {
(0, assert_1.default)(userState === 'normal');
(0, assert_1.default)(userState === 'normal'|| userState === 'shadow');
}
return true;
}

View File

@ -72,11 +72,11 @@ var FrontendRuntimeContext = /** @class */ (function (_super) {
if (userState === 'disabled') {
throw new Exception_1.OakUserDisabledException('您的帐号已经被禁用,请联系客服');
}
else if (['shadow', 'merged'].includes(userState)) {
else if (['merged'].includes(userState)) {
throw new Exception_1.OakTokenExpiredException('您的登录状态有异常,请重新登录 ');
}
else {
(0, assert_1.default)(userState === 'normal');
(0, assert_1.default)(userState === 'normal'|| userState === 'shadow');
}
return true;
}

View File

@ -18,6 +18,7 @@ var locale = {
action: {
wakeup: '激活',
cancel: '作废',
qrcode: '采集码'
},
},
};

View File

@ -1,5 +1,5 @@
import { GenericAction } from "oak-domain/lib/actions/action";
export declare type IAction = 'wakeup' | 'cancel' | string;
export declare type IAction = 'wakeup' | 'cancel' | 'qrcode' | string;
export declare type ParticularAction = IAction;
export declare type Action = GenericAction | ParticularAction | string;
export declare const actions: string[];

View File

@ -1,5 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionDefDict = exports.actions = void 0;
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "wakeup", "cancel"];
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "wakeup", "cancel", "qrcode"];
exports.ActionDefDict = {};

View File

@ -1 +1 @@
{ "name": "寄生", "attr": { "user": "用户", "showTip": "提示", "expired": "已过期", "expiresAt": "过期时间", "redirectTo": "重定向页面", "multiple": "允许反复使用", "tokens": "令牌", "entity": "关联对象", "entityId": "关联对象Id", "tokenLifeLength": "令牌生命长度" }, "action": { "wakeup": "激活", "cancel": "作废" } }
{ "name": "寄生", "attr": { "user": "用户", "showTip": "提示", "expired": "已过期", "expiresAt": "过期时间", "redirectTo": "重定向页面", "multiple": "允许反复使用", "tokens": "令牌", "entity": "关联对象", "entityId": "关联对象Id", "tokenLifeLength": "令牌生命长度" }, "action": { "wakeup": "激活", "cancel": "作废", "qrcode": "采集码" } }

View File

@ -59,6 +59,24 @@ const checkers: Checker<EntityDict, 'parasite', RuntimeCxt>[] = [
);
},
},
{
type: 'row',
entity: 'parasite',
action: ['cancel'],
errMsg: '您没有设置失效的权限',
filter: {
expired: false,
},
},
{
type: 'row',
entity: 'parasite',
action: ['qrcode'],
errMsg: '您没有查看二维码的权限',
filter: {
expired: false,
},
},
];
export default checkers;

View File

@ -14,6 +14,10 @@ export default OakComponent({
nickname: 1,
}
},
actions: [
'cancel',
'qrcode'
],
properties: {
entity: '',
entityId: '',
@ -47,5 +51,6 @@ export default OakComponent({
data: {
open: false,
},
methods: {},
methods: {
},
});

View File

@ -1,10 +1,12 @@
import * as React from 'react';
import { Table, Space, Typography } from 'antd';
import { Table, Button, Typography, Modal } from 'antd';
import dayjs from 'dayjs';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
import Style from './web.module.less';
import ActionBtnPanel from '@oak-frontend-base/components/actionBtnPanel';
import ParasiteDetail from '../detail';
import { useState } from 'react';
export default function render(
props: WebComponentProps<
EntityDict,
@ -15,8 +17,13 @@ export default function render(
list: EntityDict['userEntityGrant']['Schema'][];
showBack: boolean;
variant?: 'inline' | 'alone' | 'dialog';
qrCodeUrl: string;
qrCodeExpiresAt: number;
},
{}
{
cancel: () => void;
getQrCode: () => Promise<void>;
}
>
) {
const {
@ -25,12 +32,16 @@ export default function render(
list = [],
oakLoading,
variant,
qrCodeUrl,
qrCodeExpiresAt,
} = props.data;
const { pageSize, total, currentPage } = oakPagination || {};
const { t, setPageSize, setCurrentPage } = props.methods;
const { t, setPageSize, setCurrentPage, updateItem, execute, getQrCode } = props.methods;
const [qrCodeOpen, setQrCodeOpen] = useState(false);
const [parasiteId, setParasiteId] = useState('');
return (
<Container variant={variant}>
<Table
@ -80,6 +91,79 @@ export default function render(
);
},
},
// {
// dataIndex: 'op',
// width: 200,
// title: '操作',
// align: 'center',
// render: (value, record, index) => {
// return (
// <>
// <Button
// type="link"
// onClick={() => {
// updateItem(
// {
// expired: true
// },
// record.id!,
// 'cancel'
// );
// execute();
// }}
// >
// 失效
// </Button>
// </>
// );
// },
// fixed: 'right',
// },
{
width: 200,
title: '操作',
key: 'action',
align: 'center',
fixed: 'right',
render: (value, record, rowIndex) => {
return (
<ActionBtnPanel
mode="table-cell"
entity="parasite"
items={[
{
label: '失效',
action: 'cancel',
// alerted: true,
show: record[
'#oakLegalActions'
]?.includes('cancel'),
onClick: () => {
updateItem(
{ expired: true },
record.id!,
'cancel'
);
execute();
},
},
{
label: '采集码',
action: 'qrcode',
show: record[
'#oakLegalActions'
]?.includes('qrcode'),
// alerted: true,
onClick: async () => {
setParasiteId(record.id!)
setQrCodeOpen(true);
},
},
]}
/>
);
},
}
]}
pagination={{
total,
@ -93,6 +177,21 @@ export default function render(
},
}}
/>
<Modal
width={786}
open={qrCodeOpen}
destroyOnClose={true}
onCancel={() => {
setQrCodeOpen(false);
}}
footer={null}
>
<ParasiteDetail
oakId={parasiteId}
oakAutoUnmount={true}
oakPath="$parasite/list-parasite/detail"
/>
</Modal>
</Container>
);
}

View File

@ -21,8 +21,7 @@ import { getMpUnlimitWxaCode } from '../aspects/wechatQrCode';
*/
export class BackendRuntimeContext<ED extends EntityDict>
extends AsyncContext<ED>
implements RuntimeContext
{
implements RuntimeContext {
protected application?: Partial<ED['application']['Schema']>;
protected token?: Partial<ED['token']['Schema']>;
protected amIRoot?: boolean;
@ -299,12 +298,12 @@ export class BackendRuntimeContext<ED extends EntityDict>
throw new OakUserDisabledException(
'您的帐号已经被禁用,请联系客服'
);
} else if (['shadow', 'merged'].includes(userState!)) {
} else if (['merged'].includes(userState!)) {
throw new OakTokenExpiredException(
'您的登录状态有异常,请重新登录 '
);
} else {
assert(userState === 'normal');
assert(userState === 'normal' || userState === 'shadow');
}
return true;
}

View File

@ -23,7 +23,7 @@ export class FrontendRuntimeContext<
ED extends EntityDict,
Cxt extends BackendRuntimeContext<ED>,
AD extends AspectDict<ED, Cxt>
> extends SyncContext<ED> implements RuntimeContext {
> extends SyncContext<ED> implements RuntimeContext {
private application?: Application<ED, Cxt, any, AD>;
private token?: Token<ED, Cxt, any, AD>;
constructor(store: SyncRowStore<ED, FrontendRuntimeContext<ED, Cxt, AD>>, application?: Application<ED, Cxt, FrontendRuntimeContext<ED, Cxt, AD>, AD>, token?: Token<ED, Cxt, FrontendRuntimeContext<ED, Cxt, AD>, AD>) {
@ -57,7 +57,7 @@ export class FrontendRuntimeContext<
return this.token?.getUserId(allowUnloggedIn, this);
}
toString(): string{
toString(): string {
const data = {
};
const a = this.application?.getApplicationId();
@ -90,11 +90,11 @@ export class FrontendRuntimeContext<
if (userState === 'disabled') {
throw new OakUserDisabledException('您的帐号已经被禁用,请联系客服');
}
else if (['shadow', 'merged'].includes(userState!)) {
else if (['merged'].includes(userState!)) {
throw new OakTokenExpiredException('您的登录状态有异常,请重新登录 ');
}
else {
assert(userState === 'normal');
assert(userState === 'normal' || userState === 'shadow');
}
return true;
}

View File

@ -30,7 +30,7 @@ export interface Schema extends EntityShape {
tokens: Token[];
}
type IAction = 'wakeup' | 'cancel';
type IAction = 'wakeup' | 'cancel' | 'qrcode';
type Action = IAction;
const locale: LocaleDef<Schema, Action, '', {}> = {
@ -51,6 +51,7 @@ const locale: LocaleDef<Schema, Action, '', {}> = {
action: {
wakeup: '激活',
cancel: '作废',
qrcode: '采集码'
},
},
};