userRelation

This commit is contained in:
Xu Chang 2022-11-24 17:36:02 +08:00
parent c4935899fe
commit fbe64bdfe5
103 changed files with 757 additions and 665 deletions

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import './index.less';
declare const Empty: () => JSX.Element;
export default Empty;

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import './index.less';
declare const Empty: () => JSX.Element;
export default Empty;

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import './index.less';
interface QrCodeProps {
id?: string;

View File

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

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebConfig } from '../../../../general-app-domain/Application/Schema';
export default function Web(props: {
config: WebConfig;

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WechatMpConfig } from '../../../../general-app-domain/Application/Schema';
export default function WechatMp(props: {
config: WechatMpConfig;

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WechatPublicConfig } from '../../../../general-app-domain/Application/Schema';
export default function WechatPublic(props: {
config: WechatPublicConfig;

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { Config } from '../../../../types/Config';
export default function Account(props: {
account: Required<Config>['Account'];

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { Config } from '../../../../types/Config';
export default function Cos(props: {
cos: Required<Config>['Cos'];

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { Config } from '../../../../types/Config';
export default function Cos(props: {
live: Required<Config>['Live'];

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { Config } from '../../../../types/Config';
export default function Cos(props: {
map: Required<Config>['Map'];

View File

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

View File

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

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { UploadFile } from 'antd';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebComponentProps } from "oak-frontend-base";
import { EntityDict } from "../../../general-app-domain";
export default function Render(props: WebComponentProps<EntityDict, 'user', false, {

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(props: WebComponentProps<EntityDict, 'address', true, {

View File

@ -4,6 +4,7 @@
"ptrRelease": "正在刷新...",
"ptrFinish": "刷新完成",
"noData": "暂无数据",
"areYouSure": "请确认",
"action": {
"create": "创建",
"update": "更新",
@ -12,7 +13,7 @@
"confirm": "确定",
"cancel": "取消",
"grant": "授权",
"revoke": "回",
"revoke": "回",
"tip": "提示"
}
}

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function Render(props: WebComponentProps<EntityDict, 'address', true, {

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function Render(props: WebComponentProps<EntityDict, 'address', false, {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(props: WebComponentProps<EntityDict, 'article', true, {

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(props: WebComponentProps<EntityDict, 'article', false, {

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import '@wangeditor/editor/dist/css/style.css';
import { EntityDict } from './../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../general-app-domain';
export default function render(props: WebComponentProps<EntityDict, 'token', false, {

View File

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

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(props: WebComponentProps<EntityDict, 'mobile', true, {

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function render(props: WebComponentProps<EntityDict, 'area', true, {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function Render(props: WebComponentProps<EntityDict, 'token', true, {

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../../general-app-domain';
export default function render(props: WebComponentProps<EntityDict, 'user', false, {

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { EntityDict } from '../../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function Render(props: WebComponentProps<EntityDict, 'user', false, {

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function render(props: WebComponentProps<EntityDict, 'user', true, {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var string_1 = require("oak-domain/lib/utils/string");
var uuid_1 = require("oak-domain/lib/utils/uuid");
var extraFile_1 = require("../../../utils/extraFile");
var react_1 = tslib_1.__importDefault(require("../../../utils/react"));
exports.default = OakComponent({
@ -120,7 +121,6 @@ exports.default = OakComponent({
},
data: {
searchValue: '',
idRemove: '',
},
lifetimes: {
created: function () {
@ -153,26 +153,22 @@ exports.default = OakComponent({
relations: relations,
});
},
onDelete: function (id) {
this.setState({
idRemove: id,
});
},
confirmDelete: function () {
confirmDelete: function (idRemove) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, entity, entityId, entityStr, _b, idRemove, users, user, relations;
var _c;
return tslib_1.__generator(this, function (_d) {
switch (_d.label) {
var _a, entity, entityId, entityStr, users, user, relations;
var _b;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
_a = this.props, entity = _a.entity, entityId = _a.entityId;
entityStr = (0, string_1.firstLetterUpperCase)(entity);
_b = this.state, idRemove = _b.idRemove, users = _b.users;
users = this.state.users;
user = users.find(function (ele) { return ele.id === idRemove; });
relations = user["user".concat(entityStr, "$user")];
this.updateItem((_c = {},
_c["user".concat(entityStr, "$user")] = [
this.updateItem((_b = {},
_b["user".concat(entityStr, "$user")] = [
{
id: (0, uuid_1.generateNewId)(),
action: 'remove',
data: {},
filter: {
@ -182,13 +178,10 @@ exports.default = OakComponent({
},
}
],
_c), idRemove);
_b), idRemove);
return [4 /*yield*/, this.execute()];
case 1:
_d.sent();
this.setState({
idRemove: '',
});
_c.sent();
return [2 /*return*/];
}
});

View File

@ -0,0 +1,3 @@
{
"confirmRevokeAll": "确认删除用户的所有权限吗?"
}

View File

@ -1,2 +1,17 @@
/// <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, 'user', true, {
users: any[];
searchValue?: string;
pagination: {
pageSize: number;
total: number;
currentPage: number;
};
entity: string;
entityId: string;
}, {
goUpsert: () => void;
goDetail: (id: string) => void;
confirmDelete: (id: string) => Promise<void>;
}>): JSX.Element;

View File

@ -6,16 +6,14 @@ var antd_1 = require("antd");
var icons_1 = require("@ant-design/icons");
var mobile_module_less_1 = tslib_1.__importDefault(require("./mobile.module.less"));
var randomUser_1 = require("../../../utils/randomUser");
function render() {
var _this = this;
var t = this.t;
var entity = this.props.entity;
var users = this.state.users;
function Render(props) {
var _a = props.methods, t = _a.t, goUpsert = _a.goUpsert, goDetail = _a.goDetail;
var _b = props.data, entity = _b.entity, users = _b.users;
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: mobile_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsx)(antd_1.List, { children: users === null || users === void 0 ? void 0 : users.map(function (ele, index) {
var _a;
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ onClick: function (e) { return _this.goDetail(ele.id); } }, { children: (0, jsx_runtime_1.jsx)(antd_1.List.Item, { children: (0, jsx_runtime_1.jsx)(antd_1.List.Item.Meta, { avatar: ele.avatar ? ((0, jsx_runtime_1.jsx)(antd_1.Avatar, { className: mobile_module_less_1.default.avatar, src: ele.avatar })) : ((0, jsx_runtime_1.jsx)(antd_1.Avatar, tslib_1.__assign({ className: mobile_module_less_1.default.avatar }, { children: (0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.text }, { children: (0, randomUser_1.getName)(ele.name) })) }))), title: (0, jsx_runtime_1.jsx)("div", { children: ele.name || '--' }), description: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: mobile_module_less_1.default.description }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: mobile_module_less_1.default.row }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.label }, { children: "\u6635\u79F0:\u00A0" })), (0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.value }, { children: ele.nickname || '--' }))] })), (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: mobile_module_less_1.default.row }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.label }, { children: "\u624B\u673A\u53F7:\u00A0" })), (0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.value }, { children: ele.mobile || '--' }))] })), (0, jsx_runtime_1.jsx)(antd_1.Space, { children: (_a = ele.relations) === null || _a === void 0 ? void 0 : _a.map(function (relation, index) { return ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: "processing" }, { children: t("".concat(entity, ":r.").concat(relation)) }), index)); }) })] })) }) }) }), index));
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ onClick: function (e) { return goDetail(ele.id); } }, { children: (0, jsx_runtime_1.jsx)(antd_1.List.Item, { children: (0, jsx_runtime_1.jsx)(antd_1.List.Item.Meta, { avatar: ele.avatar ? ((0, jsx_runtime_1.jsx)(antd_1.Avatar, { className: mobile_module_less_1.default.avatar, src: ele.avatar })) : ((0, jsx_runtime_1.jsx)(antd_1.Avatar, tslib_1.__assign({ className: mobile_module_less_1.default.avatar }, { children: (0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.text }, { children: (0, randomUser_1.getName)(ele.name) })) }))), title: (0, jsx_runtime_1.jsx)("div", { children: ele.name || '--' }), description: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: mobile_module_less_1.default.description }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: mobile_module_less_1.default.row }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.label }, { children: "\u6635\u79F0:\u00A0" })), (0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.value }, { children: ele.nickname || '--' }))] })), (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: mobile_module_less_1.default.row }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.label }, { children: "\u624B\u673A\u53F7:\u00A0" })), (0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: mobile_module_less_1.default.value }, { children: ele.mobile || '--' }))] })), (0, jsx_runtime_1.jsx)(antd_1.Space, { children: (_a = ele.relations) === null || _a === void 0 ? void 0 : _a.map(function (relation, index) { return ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: "processing" }, { children: t("".concat(entity, ":r.").concat(relation)) }), index)); }) })] })) }) }) }), index));
}) }), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: mobile_module_less_1.default.fab }, { children: (0, jsx_runtime_1.jsx)(antd_1.Button, { size: "large", shape: "circle", icon: (0, jsx_runtime_1.jsx)(icons_1.PlusOutlined, {}), onClick: function () {
_this.goUpsert();
goUpsert();
} }) }))] })));
}
exports.default = render;
exports.default = Render;

View File

@ -1,2 +1,17 @@
/// <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, 'user', true, {
users: any[];
searchValue?: string;
pagination: {
pageSize: number;
total: number;
currentPage: number;
};
entity: string;
entityId: string;
}, {
goUpsert: () => void;
goUpdate: (id: string) => void;
confirmDelete: (id: string) => Promise<void>;
}>): JSX.Element;

View File

@ -2,20 +2,21 @@
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 pageHeader_1 = tslib_1.__importDefault(require("../../../components/common/pageHeader"));
var list_1 = tslib_1.__importDefault(require("../../../pages/userEntityGrant/list"));
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
function render() {
function Render(props) {
var _this = this;
var _a = this.state, pagination = _a.pagination, _b = _a.users, users = _b === void 0 ? [] : _b, oakLoading = _a.oakLoading, idRemove = _a.idRemove;
var _c = this.props, namespace = _c.namespace, entity = _c.entity, entityId = _c.entityId;
var _d = pagination || {}, pageSize = _d.pageSize, total = _d.total, currentPage = _d.currentPage;
return ((0, jsx_runtime_1.jsxs)(pageHeader_1.default, tslib_1.__assign({ title: "\u6743\u9650\u5217\u8868" }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { 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 _this.goUpsert(); } }, { children: "\u6DFB\u52A0" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () {
return _this.setState({
invite: true,
});
} }, { children: "\u9080\u8BF7\u8BB0\u5F55" }))] }), (0, jsx_runtime_1.jsx)(antd_1.Table, { loading: oakLoading, ref: this.tableRef, rowKey: "id", columns: [
var _a = props.data, pagination = _a.pagination, _b = _a.users, users = _b === void 0 ? [] : _b, entity = _a.entity, entityId = _a.entityId, oakLoading = _a.oakLoading;
var _c = pagination || {}, pageSize = _c.pageSize, total = _c.total, currentPage = _c.currentPage;
var _d = props.methods, goUpsert = _d.goUpsert, t = _d.t, setCurrentPage = _d.setCurrentPage, setPageSize = _d.setPageSize, confirmDelete = _d.confirmDelete, goUpdate = _d.goUpdate;
var _e = tslib_1.__read((0, react_1.useState)(undefined), 2), idRemove = _e[0], setIdRemove = _e[1];
var _f = tslib_1.__read((0, react_1.useState)(false), 2), inviteVisible = _f[0], setInviteVisible = _f[1];
return ((0, jsx_runtime_1.jsxs)(pageHeader_1.default, tslib_1.__assign({ title: "\u6743\u9650\u5217\u8868" }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { 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 goUpsert(); } }, { children: "\u6DFB\u52A0" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () { return setInviteVisible(true); } }, { children: "\u9080\u8BF7\u8BB0\u5F55" }))] }), (0, jsx_runtime_1.jsx)(antd_1.Table, { loading: oakLoading,
// ref={this.tableRef}
rowKey: "id", columns: [
{
width: 100,
dataIndex: 'index',
@ -70,51 +71,17 @@ function render() {
title: '权限',
render: function (value, record, index) {
var _a;
return ((0, jsx_runtime_1.jsx)(antd_1.Space, { children: (_a = record.relations) === null || _a === void 0 ? void 0 : _a.map(function (ele, index) { return ((0, jsx_runtime_1.jsx)(antd_1.Tag, { children: _this.t(entity + ':r.' + ele) }, index)); }) }));
return ((0, jsx_runtime_1.jsx)(antd_1.Space, { children: (_a = record.relations) === null || _a === void 0 ? void 0 : _a.map(function (ele, index) { return ((0, jsx_runtime_1.jsx)(antd_1.Tag, { children: t(entity + ':r.' + ele) }, index)); }) }));
},
// edit: {
// component: Select,
// // props, 透传全部属性到 Select 组件
// // props 为函数时参数有col, row, rowIndex, colIndex, editedRow。一般用于实现编辑组件之间的联动
// props: () => {
// return {
// multiple: true,
// minCollapsedNum: 1,
// autoWidth: true,
// options:
// relationArr &&
// relationArr.map(
// (
// ele: any,
// index: number
// ) => ({
// value: ele,
// label: this.t(
// entity + ':r.' + ele
// ),
// })
// ),
// };
// },
// showEditIcon: false,
// rules: [
// {
// required: true,
// message: '请至少选择一个权限',
// },
// ],
// },
},
{
title: '操作',
dataIndex: 'operate',
render: function (value, record, index) {
var _a;
var _a, _b;
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "link", onClick: function (e) {
return _this.goUpdate(record.id);
} }, { children: "\u7F16\u8F91" })), ((_a = record.relations) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ danger: true, type: "link", onClick: function () {
return _this.onDelete(record.id);
} }, { children: "\u5220\u9664" })))] }));
return goUpdate(record.id);
} }, { children: ((_a = record.relations) === null || _a === void 0 ? void 0 : _a.length) > 0 ? t('common:action.update') : t('common:action.grant') })), ((_b = record.relations) === null || _b === void 0 ? void 0 : _b.length) > 0 && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ danger: true, type: "link", onClick: function () { return setIdRemove(record.id); } }, { children: t('common:action.revoke') })))] }));
},
},
], dataSource: users, pagination: {
@ -122,14 +89,21 @@ function render() {
pageSize: pageSize,
current: currentPage,
onShowSizeChange: function (current, size) {
_this.setPageSize(current);
setPageSize(current);
},
onChange: function (page, pageSize) {
_this.setCurrentPage(page);
setCurrentPage(page);
},
} })] })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ title: "\u8BF7\u786E\u8BA4", open: !!idRemove, onOk: function () { return _this.confirmDelete(); }, onCancel: function () { return _this.setState({ idRemove: '' }); }, cancelText: "\u53D6\u6D88", okText: "\u786E\u8BA4" }, { children: (0, jsx_runtime_1.jsx)("p", { children: "\u786E\u8BA4\u5220\u9664\u7528\u6237\u7684\u6240\u6709\u6743\u9650\u5417\uFF1F" }) })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ title: "\u9080\u8BF7\u8BB0\u5F55", open: !!this.state.invite, onCancel: function () { return _this.setState({ invite: false }); },
// cancelText="关闭"
// okText=""
width: "80%", footer: null }, { children: (0, jsx_runtime_1.jsx)(list_1.default, { entity: entity, entityId: entityId, namespace: namespace, variant: "dialog", oakPath: "$userRelation/list-userEntityGrant/list" }) }))] })));
} })] })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ title: t('common:areYouSure'), open: !!idRemove, onOk: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, confirmDelete(idRemove)];
case 1:
_a.sent();
setIdRemove(undefined);
return [2 /*return*/];
}
});
}); }, onCancel: function () { return setIdRemove(undefined); }, cancelText: t('common:action.cancel'), okText: t('common:action.confirm') }, { children: (0, jsx_runtime_1.jsx)("p", { children: t('confirmRevokeAll') }) })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ title: "\u9080\u8BF7\u8BB0\u5F55", open: inviteVisible, onCancel: function () { return setInviteVisible(false); }, width: "80%", footer: null }, { children: (0, jsx_runtime_1.jsx)(list_1.default, { entity: entity, entityId: entityId, variant: "dialog", oakPath: "$userRelation/list-userEntityGrant/list" }) }))] })));
}
exports.default = render;
exports.default = Render;

View File

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

View File

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

View File

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

View File

@ -13,9 +13,7 @@ exports.default = OakComponent({
isList: false,
formData: function (_a) {
var mobile = _a.data;
var legal = this.tryExecute();
return {
legal: !!legal,
userId: mobile === null || mobile === void 0 ? void 0 : mobile.userId,
};
},
@ -36,7 +34,7 @@ exports.default = OakComponent({
switch (_a.label) {
case 0:
mobileValueReady = (0, validator_1.isMobile)(value);
if (!mobileValueReady) return [3 /*break*/, 5];
if (!mobileValueReady) return [3 /*break*/, 2];
return [4 /*yield*/, this.features.cache.refresh('mobile', {
data: {
id: 1,
@ -51,30 +49,24 @@ exports.default = OakComponent({
})];
case 1:
data = (_a.sent()).data;
if (!(data.length > 0)) return [3 /*break*/, 2];
this.clean();
this.setId(data[0].id);
return [3 /*break*/, 4];
if (data.length > 0) {
this.clean();
this.setId(data[0].id);
}
else {
this.clean();
this.unsetId();
// todo
this.update({
mobile: value,
});
}
return [3 /*break*/, 3];
case 2:
this.clean();
this.unsetId();
// todo
return [4 /*yield*/, this.addOperation({
action: 'create',
data: {
mobile: value,
}
})];
_a.label = 3;
case 3:
// todo
_a.sent();
_a.label = 4;
case 4: return [3 /*break*/, 6];
case 5:
this.clean();
this.unsetId();
_a.label = 6;
case 6:
this.setState({
mobileValueReady: mobileValueReady,
mobileValue: value,

View File

@ -1,2 +1,14 @@
/// <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, 'mobile', false, {
entity: string;
entityId: string;
relations: string[];
mobileValue: string;
mobileValueReady: boolean;
userId: string;
}, {
onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>;
onReset: () => void;
}>): JSX.Element;

View File

@ -5,10 +5,9 @@ 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"));
var index_1 = tslib_1.__importDefault(require("../onUser/index"));
function render() {
var _this = this;
var _a = this.props, relations = _a.relations, entity = _a.entity, entityId = _a.entityId;
var _b = this.state, mobileValue = _b.mobileValue, mobileValueReady = _b.mobileValueReady, legal = _b.legal;
function Render(props) {
var _a = props.data, mobileValue = _a.mobileValue, mobileValueReady = _a.mobileValueReady, relations = _a.relations, entity = _a.entity, entityId = _a.entityId, userId = _a.userId, oakFullpath = _a.oakFullpath, oakExecutable = _a.oakExecutable;
var _b = props.methods, onConfirm = _b.onConfirm, onMobileChange = _b.onMobileChange, onReset = _b.onReset;
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.Form, tslib_1.__assign({ colon: true, labelCol: { span: 4 }, wrapperCol: { span: 8 } }, { children: (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u624B\u673A\u53F7\u7801", name: "mobile", rules: [
{
required: true,
@ -24,11 +23,10 @@ function render() {
},
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { maxLength: 11, value: mobileValue, onChange: function (e) {
var strValue = e.target.value;
_this.onMobileChange(strValue);
}, placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u7801", type: "tel" }) }) })) })), mobileValueReady && ((0, jsx_runtime_1.jsx)(index_1.default, { oakAutoUnmount: true, oakPath: this.state.oakFullpath
? "".concat(this.state.oakFullpath, ".user")
: undefined, entity: entity, entityId: entityId, relations: relations, oakId: this.state.userId })), (0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ colon: true, labelCol: { span: 4 }, wrapperCol: { span: 8 } }, { children: (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.onConfirm();
}, disabled: !legal }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ htmlType: "reset", onClick: function () { return _this.onReset(); } }, { children: "\u91CD\u7F6E" }))] }) })) }))] })));
onMobileChange(strValue);
}, placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u7801", type: "tel" }) }) })) })), mobileValueReady && ((0, jsx_runtime_1.jsx)(index_1.default, { oakAutoUnmount: true, oakPath: oakFullpath ? "".concat(oakFullpath, ".user")
: undefined, entity: entity, entityId: entityId, relations: relations, oakId: userId })), (0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ colon: true, labelCol: { span: 4 }, wrapperCol: { span: 8 } }, { children: (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 () {
onConfirm();
}, disabled: !oakExecutable }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ htmlType: "reset", onClick: function () { return onReset(); } }, { children: "\u91CD\u7F6E" }))] }) })) }))] })));
}
exports.default = render;
exports.default = Render;

View File

@ -4,15 +4,15 @@ var tslib_1 = require("tslib");
exports.default = OakComponent({
isList: false,
formData: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var legal;
return tslib_1.__generator(this, function (_a) {
legal = this.tryExecute();
return [2 /*return*/, {
legal: !!legal,
}];
});
});
var legal = this.tryExecute();
return {
legal: !!legal,
};
},
properties: {
entity: String,
entityId: String,
relations: Array,
},
methods: {
onConfirm: function () {
@ -27,9 +27,6 @@ exports.default = OakComponent({
}
});
});
},
onReset: function () {
this.clean();
}
},
});

View File

@ -1,2 +1,11 @@
/// <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, 'user', false, {
relations: string[];
entity: string;
entityId: string;
oakId: string;
legal: boolean;
}, {
onConfirm: () => Promise<void>;
}>): JSX.Element;

View File

@ -6,13 +6,9 @@ var antd_1 = require("antd");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var index_1 = tslib_1.__importDefault(require("../onUser/index"));
var pageHeader_1 = tslib_1.__importDefault(require("../../../../components/common/pageHeader"));
function render() {
var _this = this;
var _a = this.props, relations = _a.relations, entity = _a.entity, entityId = _a.entityId;
return ((0, jsx_runtime_1.jsx)(pageHeader_1.default, tslib_1.__assign({ showBack: true, title: "\u7F16\u8F91\u6743\u9650" }, { children: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsx)(index_1.default, { oakAutoUnmount: true, oakPath: this.state.oakFullpath
? "".concat(this.state.oakFullpath, ".user")
: undefined, entity: entity, entityId: entityId, relations: relations, oakId: this.props.oakId }), (0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ colon: true, labelCol: { span: 4 }, wrapperCol: { span: 8 } }, { children: (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({ disabled: !this.state.legal, type: "primary", onClick: function () {
_this.onConfirm();
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ htmlType: "reset", onClick: function () { return _this.onReset(); } }, { children: "\u91CD\u7F6E" }))] }) })) }))] })) })));
function Render(props) {
var _a = props.data, relations = _a.relations, entity = _a.entity, entityId = _a.entityId, oakFullpath = _a.oakFullpath, oakId = _a.oakId, legal = _a.legal;
var _b = props.methods, onConfirm = _b.onConfirm, clean = _b.clean;
return ((0, jsx_runtime_1.jsx)(pageHeader_1.default, tslib_1.__assign({ showBack: true, title: "\u7F16\u8F91\u6743\u9650" }, { children: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsx)(index_1.default, { oakAutoUnmount: true, oakPath: oakFullpath ? "".concat(oakFullpath, ".user") : undefined, entity: entity, entityId: entityId, relations: relations, oakId: oakId }), (0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ colon: true, labelCol: { span: 4 }, wrapperCol: { span: 8 } }, { children: (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({ disabled: !legal, type: "primary", onClick: function () { return onConfirm(); } }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ htmlType: "reset", onClick: function () { return clean(); } }, { children: "\u91CD\u7F6E" }))] }) })) }))] })) })));
}
exports.default = render;
exports.default = Render;

View File

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

View File

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

View File

@ -17,44 +17,34 @@ exports.default = OakComponent({
},
lifetimes: {
ready: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var application, type, config, grantByUserEntityGrant, grantByMobile, grantByEmail, passport, grantMethodCount;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.features.application.getApplication()];
case 1:
application = _a.sent();
type = application.type, config = application.config;
grantByUserEntityGrant = false, grantByMobile = false, grantByEmail = false;
if (type.startsWith('wechat')) {
grantByUserEntityGrant = true;
}
else {
(0, assert_1.default)(type === 'web');
passport = config.passport;
grantByEmail = passport.includes('email');
grantByMobile = passport.includes('mobile');
grantByUserEntityGrant = passport.includes('wechat');
}
grantMethodCount = 0;
if (grantByEmail) {
grantMethodCount++;
}
if (grantByMobile) {
grantMethodCount++;
}
if (grantByUserEntityGrant) {
grantMethodCount++;
}
this.setState({
grantMethodCount: grantMethodCount,
grantByUserEntityGrant: grantByUserEntityGrant,
grantByEmail: grantByEmail,
grantByMobile: grantByMobile,
});
return [2 /*return*/];
}
});
var application = this.features.application.getApplication();
var type = application.type, config = application.config;
var grantByUserEntityGrant = false, grantByMobile = false, grantByEmail = false;
if (type.startsWith('wechat')) {
grantByUserEntityGrant = true;
}
else {
(0, assert_1.default)(type === 'web');
var passport = config.passport;
grantByEmail = passport.includes('email');
grantByMobile = passport.includes('mobile');
grantByUserEntityGrant = passport.includes('wechat');
}
var grantMethodCount = 0;
if (grantByEmail) {
grantMethodCount++;
}
if (grantByMobile) {
grantMethodCount++;
}
if (grantByUserEntityGrant) {
grantMethodCount++;
}
this.setState({
grantMethodCount: grantMethodCount,
grantByUserEntityGrant: grantByUserEntityGrant,
grantByEmail: grantByEmail,
grantByMobile: grantByMobile,
});
}
}

View File

@ -1,53 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var uuid_1 = require("oak-domain/lib/utils/uuid");
var assert_1 = tslib_1.__importDefault(require("assert"));
var types_1 = require("oak-domain/lib/types");
var string_1 = require("oak-domain/lib/utils/string");
exports.default = OakComponent({
entity: 'user',
projection: function (_a) {
var _b, _c, _d;
var props = _a.props;
var entity = props.entity, entityId = props.entityId;
var entityStr = (0, string_1.firstLetterUpperCase)(entity);
return _b = {
id: 1,
name: 1,
password: 1,
nickname: 1
},
_b["user".concat(entityStr, "$user")] = {
$entity: "user".concat(entityStr),
data: (_c = {
id: 1,
userId: 1
},
_c["".concat(entity, "Id")] = 1,
_c.relation = 1,
_c),
filter: (_d = {},
_d["".concat(entity, "Id")] = entityId,
_d)
},
_b;
projection: {
id: 1,
name: 1,
password: 1,
nickname: 1,
},
isList: false,
formData: function (_a) {
var user = _a.data, props = _a.props;
var entity = props.entity, entityId = props.entityId;
var entityStr = (0, string_1.firstLetterUpperCase)(entity);
var user = _a.data;
var _b = user || {}, name = _b.name, nickname = _b.nickname, password = _b.password;
var userRelations = user && user["user".concat(entityStr, "$user")];
return {
password: password,
userRelations: userRelations,
name: name,
nickname: nickname,
};
},
properties: {
oakId: String,
entity: String,
entityId: String,
relations: Array,
@ -55,77 +30,36 @@ exports.default = OakComponent({
lifetimes: {
ready: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, entity, entityId, entityStr;
var _a, entity, oakId, entityStr_1;
var _this = this;
return tslib_1.__generator(this, function (_b) {
_a = this.props, entity = _a.entity, entityId = _a.entityId;
entityStr = (0, string_1.firstLetterUpperCase)(entity);
this.update({
password: '12345678',
}, undefined, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var operations, _a, operation;
var _b;
return tslib_1.__generator(this, function (_c) {
operations = this.getOperations();
_a = tslib_1.__read(operations, 1), operation = _a[0].operation;
if (!operation.data.name) {
throw new types_1.OakInputIllegalException('user', ['name'], '用户姓名不能为空');
}
if (((_b = operation.data["user".concat(entityStr, "$user")]) === null || _b === void 0 ? void 0 : _b.length) > 0) {
return [2 /*return*/];
}
throw new types_1.OakInputIllegalException('user', ["user".concat(entityStr, "$user")], '需要至少选择一个权限');
});
}); });
_a = this.props, entity = _a.entity, oakId = _a.oakId;
if (!oakId) {
entityStr_1 = (0, string_1.firstLetterUpperCase)(entity);
this.update({
password: '12345678',
}, undefined, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var operations, _a, operation;
var _b;
return tslib_1.__generator(this, function (_c) {
operations = this.getOperations();
_a = tslib_1.__read(operations, 1), operation = _a[0].operation;
if (!operation.data.name) {
throw new types_1.OakInputIllegalException('user', ['name'], this.t('placeholder.name'));
}
if (((_b = operation.data["user".concat(entityStr_1, "$user")]) === null || _b === void 0 ? void 0 : _b.length) > 0) {
return [2 /*return*/];
}
throw new types_1.OakInputIllegalException('user', ["user".concat(entityStr_1, "$user")], this.t('placeholder.relation'));
});
}); });
}
return [2 /*return*/];
});
});
},
},
methods: {
onRelationChange: function (value) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, entity, entityId, oakId, entityStr, userRelations, toBeRemoved, toBeInserted;
var _b, _c, _d;
return tslib_1.__generator(this, function (_e) {
_a = this.props, entity = _a.entity, entityId = _a.entityId, oakId = _a.oakId;
entityStr = (0, string_1.firstLetterUpperCase)(entity);
userRelations = this.state.userRelations;
if (userRelations.length > value.length) {
(0, assert_1.default)(userRelations.length === value.length + 1);
toBeRemoved = userRelations.find(function (ele) { return !value.includes(ele.relation); });
(0, assert_1.default)(userRelations.length === value.length + 1);
// todo 这里应该改成component
this.update((_b = {},
_b["user".concat(entityStr, "$user")] = [{
action: 'remove',
data: {},
filter: {
id: toBeRemoved.id,
},
}],
_b));
}
else {
// 增加一个relation
(0, assert_1.default)(userRelations.length === value.length - 1);
toBeInserted = value.find(function (ele) { return !userRelations.find(function (userRelation) { return userRelation.relation === ele; }); });
this.update((_c = {},
_c["user".concat(entityStr, "$user")] = [{
action: 'create',
data: (_d = {
id: (0, uuid_1.generateNewId)()
},
_d["".concat(entity, "Id")] = entityId,
_d.relation = toBeInserted,
_d),
}],
_c));
}
return [2 /*return*/];
});
});
},
onConfirm: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {

View File

@ -0,0 +1,10 @@
{
"placeholder": {
"name": "请输入姓名",
"password": "密码不少于8位",
"relation": "至少应选择一个权限"
},
"auth": "权限",
"existedUser": "现有用户",
"newUser": "新建用户"
}

View File

@ -0,0 +1,3 @@
/// <reference types="react" />
declare const _default: import("react").ComponentType<any>;
export default _default;

View File

@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var assert_1 = tslib_1.__importDefault(require("assert"));
var string_1 = require("oak-domain/lib/utils/string");
exports.default = OakComponent({
entity: function () {
var entity = this.props.entity;
return "user".concat((0, string_1.firstLetterUpperCase)(entity));
},
projection: function () {
var _a;
var entity = this.props.entity;
return _a = {
id: 1,
userId: 1,
relation: 1
},
_a["".concat(entity, "Id")] = 1,
_a;
},
properties: {
entity: String,
entityId: String,
},
isList: true,
filters: [{
filter: function (_a) {
var _b;
var props = _a.props;
var entity = props.entity, entityId = props.entityId;
return _b = {},
_b["".concat(entity, "Id")] = entityId,
_b;
}
}],
formData: function (_a) {
var data = _a.data;
return {
userRelations: data,
};
},
methods: {
onRelationChange: function (relation, checked) {
var _a;
var _b = this.props, entity = _b.entity, entityId = _b.entityId;
var userRelations = this.state.userRelations;
if (checked) {
var userRelation = userRelations.find(function (ele) { return ele.relation === relation; });
if (userRelation) {
(0, assert_1.default)(userRelation.$$deleteAt$$);
this.recoverItem(userRelation.id);
}
else {
this.addItem((_a = {
relation: relation
},
_a["".concat(entity, "Id")] = entityId,
_a));
}
}
else {
var userRelation = userRelations.find(function (ele) { return ele.relation === relation; });
(0, assert_1.default)(userRelation);
this.removeItem(userRelation.id);
}
},
isChecked: function (relation) {
var userRelations = this.state.userRelations;
var userRelation = userRelations === null || userRelations === void 0 ? void 0 : userRelations.find(function (ele) { return ele.relation === relation && !ele.$$deleteAt$$; });
return !!userRelation;
}
}
});

View File

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "添加权限"
}

View File

@ -0,0 +1,8 @@
.container {
background: var(--oak-bg-color-container);
// box-shadow: 0 2px 3px #0000001a;
// border-radius: 3px;
// padding: 30px 32px;
}

View File

@ -0,0 +1,12 @@
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../../../general-app-domain';
export default function Render(props: WebComponentProps<EntityDict, 'user', false, {
entity: string;
userRelations: Array<{
relation: string;
}>;
relations: string[];
}, {
onRelationChange: (relation: string, checked: boolean) => void;
isChecked: (relation: string) => boolean;
}>): JSX.Element;

View File

@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
function Render(props) {
var _a = props.data, entity = _a.entity, relations = _a.relations;
var _b = props.methods, t = _b.t, onRelationChange = _b.onRelationChange, isChecked = _b.isChecked;
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: relations.map(function (relation) { return ((0, jsx_runtime_1.jsx)(antd_1.Checkbox, tslib_1.__assign({ checked: isChecked(relation), value: relation, onChange: function (_a) {
var target = _a.target;
var checked = target.checked;
onRelationChange(relation, checked);
} }, { children: (t("".concat(entity, ":r.").concat(relation))) || relation }))); }) }));
}
exports.default = Render;

View File

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

View File

@ -1,2 +1,17 @@
/// <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, 'user', false, {
name: string;
nickname: string;
password: string;
mobileValue: string;
mobileValueReady: boolean;
oakId: string;
relations: string[];
entity: string;
entityId: string;
}, {
onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>;
onReset: () => void;
}>): JSX.Element;

View File

@ -4,56 +4,38 @@ 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"));
var input_1 = tslib_1.__importDefault(require("../../../../components/common/input"));
function render() {
var _this = this;
var _a = this.props, relations = _a.relations, entity = _a.entity, oakId = _a.oakId;
var _b = this.state, name = _b.name, nickname = _b.nickname, password = _b.password, userRelations = _b.userRelations;
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Form, tslib_1.__assign({ colon: true, labelCol: { span: 4 }, wrapperCol: { span: 8 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { style: { marginBottom: 0 }, label: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.tip }, { children: oakId ? '现有用户' : '新建用户' })), colon: false }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u59D3\u540D", name: "name", rules: [
var userRelation_1 = tslib_1.__importDefault(require("./userRelation"));
var string_1 = require("oak-domain/lib/utils/string");
function Render(props) {
var _a = props.data, oakId = _a.oakId, name = _a.name, nickname = _a.nickname, password = _a.password, relations = _a.relations, oakFullpath = _a.oakFullpath, entity = _a.entity, entityId = _a.entityId;
var _b = props.methods, t = _b.t, update = _b.update;
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Form, tslib_1.__assign({ colon: true, labelCol: { span: 4 }, wrapperCol: { span: 8 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { style: { marginBottom: 0 }, label: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.tip }, { children: oakId ? t('existedUser') : t('newUser') })), colon: false }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: t('user:attr.name'), name: "name", rules: [
{
required: true,
message: '姓名不能为空',
},
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(input_1.default, { disabled: !!oakId, onChange: function (e) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var strValue;
return tslib_1.__generator(this, function (_a) {
strValue = e.target.value;
this.addOperation({
action: 'create',
data: {
name: strValue,
},
});
return [2 /*return*/];
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { disabled: !!oakId, onChange: function (e) {
var strValue = e.target.value;
update({
name: strValue,
});
}); }, value: name, placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D" }) }) })), !!oakId ? (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6635\u79F0", name: "nickname" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(input_1.default, { disabled: true, value: nickname }) }) })) : (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u5BC6\u7801", name: "mobile", rules: [
}, value: name, placeholder: t('placeholder.name') }) }) })), !!oakId ? (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: t('user:attr.nickname'), name: "nickname", rules: [
{
required: true,
message: '密码不能为空',
},
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(input_1.default, { value: password, onChange: function (e) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var strValue;
return tslib_1.__generator(this, function (_a) {
strValue = e.target.value;
this.addOperation({
action: 'create',
data: {
password: strValue,
},
});
return [2 /*return*/];
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { disabled: true, value: nickname }) }) })) : (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: t('user:attr.password'), name: "password", rules: [
{
required: true,
},
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { value: password, onChange: function (e) {
var strValue = e.target.value;
update({
password: strValue,
});
}); }, placeholder: "\u4E0D\u5C11\u4E8E\u516B\u4F4D" }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6743\u9650", rules: [
}, placeholder: t('placeholder.password') }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: t('auth'), rules: [
{
required: true,
message: '请至少选择一个权限',
},
], name: "relation" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Checkbox.Group, { value: (userRelations || []).map(function (ele) { return ele.relation; }), onChange: function (value) {
_this.onRelationChange(value);
}, options: relations.map(function (ele) { return ({
value: ele,
label: (_this.t && _this.t("".concat(entity, ":r.").concat(ele))) ||
ele,
}); }) }) }) }))] })) })));
], name: "relation" }, { children: (0, jsx_runtime_1.jsx)(userRelation_1.default, { oakAutoUnmount: true, oakPath: oakFullpath ? "".concat(oakFullpath, ".user").concat((0, string_1.firstLetterUpperCase)(entity), "$user")
: undefined, entity: entity, entityId: entityId, relations: relations }) }))] })) })));
}
exports.default = render;
exports.default = Render;

View File

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

View File

@ -1,2 +1,11 @@
/// <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, 'user', false, {
grantByUserEntityGrant: boolean;
grantByEmail: boolean;
grantByMobile: boolean;
grantMethodCount: number;
entity: string;
entityId: string;
relations: string[];
}, {}>): JSX.Element;

View File

@ -8,9 +8,8 @@ var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var index_1 = tslib_1.__importDefault(require("./byMobile/index"));
var byUserEntityGrant_1 = tslib_1.__importDefault(require("./byUserEntityGrant"));
var assert_1 = tslib_1.__importDefault(require("assert"));
function render() {
var _a = this.props, entity = _a.entity, entityId = _a.entityId, relations = _a.relations;
var _b = this.state, grantByUserEntityGrant = _b.grantByUserEntityGrant, grantByEmail = _b.grantByEmail, grantByMobile = _b.grantByMobile, grantMethodCount = _b.grantMethodCount;
function Render(props) {
var _a = props.data, entity = _a.entity, entityId = _a.entityId, relations = _a.relations, grantByUserEntityGrant = _a.grantByUserEntityGrant, grantByEmail = _a.grantByEmail, grantByMobile = _a.grantByMobile, grantMethodCount = _a.grantMethodCount, oakFullpath = _a.oakFullpath;
var SubPart = ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}));
if (grantMethodCount === 0) {
SubPart = ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: "\u5E94\u7528\u6CA1\u6709\u5B9A\u4E49\u6388\u6743\u65B9\u5F0F\uFF0C\u8BF7\u7BA1\u7406\u5458\u5728\u63A7\u5236\u53F0\u4E2D\u5B9A\u4E49" })));
@ -20,11 +19,11 @@ function render() {
SubPart = ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: "\u5C1A\u672A\u5B9E\u73B0" })));
}
else if (grantByMobile) {
SubPart = ((0, jsx_runtime_1.jsx)(index_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: this.state.oakFullpath ? "".concat(this.state.oakFullpath, ".mobile") : undefined, oakAutoUnmount: true }));
SubPart = ((0, jsx_runtime_1.jsx)(index_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: oakFullpath ? "".concat(oakFullpath, ".mobile") : undefined, oakAutoUnmount: true }));
}
else {
(0, assert_1.default)(grantByUserEntityGrant === true);
SubPart = ((0, jsx_runtime_1.jsx)(byUserEntityGrant_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: this.state.oakFullpath ? "".concat(this.state.oakFullpath, ".userEntityGrant") : undefined, oakAutoUnmount: true }));
SubPart = ((0, jsx_runtime_1.jsx)(byUserEntityGrant_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: oakFullpath ? "".concat(oakFullpath, ".userEntityGrant") : undefined, oakAutoUnmount: true }));
}
}
else {
@ -33,10 +32,10 @@ function render() {
label: 'Email', key: 'item-1', children: ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: "\u5C1A\u672A\u5B9E\u73B0" })))
},
{
label: '手机号', key: 'item-2', children: ((0, jsx_runtime_1.jsx)(index_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: "$userRelationUpsert/upsert-byMobile", oakAutoUnmount: true }))
label: '手机号', key: 'item-2', children: ((0, jsx_runtime_1.jsx)(index_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: oakFullpath ? "".concat(oakFullpath, ".mobile") : undefined, oakAutoUnmount: true }))
},
{
label: '二维码', key: 'item-3', children: ((0, jsx_runtime_1.jsx)(byUserEntityGrant_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: "$userRelationUpsert/upsert-byUserEntityGrant", oakAutoUnmount: true }))
label: '二维码', key: 'item-3', children: ((0, jsx_runtime_1.jsx)(byUserEntityGrant_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: oakFullpath ? "".concat(oakFullpath, ".userEntityGrant") : undefined, oakAutoUnmount: true }))
},
];
var items2 = [];
@ -53,4 +52,4 @@ function render() {
}
return ((0, jsx_runtime_1.jsx)(pageHeader_1.default, tslib_1.__assign({ showBack: true, title: "\u6DFB\u52A0\u6743\u9650" }, { children: SubPart })));
}
exports.default = render;
exports.default = Render;

View File

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

View File

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

View File

@ -4,6 +4,7 @@
"ptrRelease": "正在刷新...",
"ptrFinish": "刷新完成",
"noData": "暂无数据",
"areYouSure": "请确认",
"action": {
"create": "创建",
"update": "更新",
@ -12,7 +13,7 @@
"confirm": "确定",
"cancel": "取消",
"grant": "授权",
"revoke": "回",
"revoke": "回",
"tip": "提示"
}
}

View File

@ -1,5 +1,6 @@
import assert from 'assert';
import { firstLetterUpperCase } from 'oak-domain/lib/utils/string';
import { generateNewId } from 'oak-domain/lib/utils/uuid';
import { EntityDict } from '../../../general-app-domain';
import { composeFileUrl } from '../../../utils/extraFile';
import React from '../../../utils/react';
@ -116,7 +117,6 @@ export default OakComponent({
},
data: {
searchValue: '',
idRemove: '',
},
lifetimes: {
created() {
@ -155,15 +155,10 @@ export default OakComponent({
}
);
},
onDelete(id: string) {
this.setState({
idRemove: id,
});
},
async confirmDelete() {
async confirmDelete(idRemove: string) {
const { entity, entityId } = this.props;
const entityStr = firstLetterUpperCase(entity!);
const { idRemove, users } = this.state;
const { users } = this.state;
const user = users.find(
(ele: any) => ele.id === idRemove
);
@ -171,6 +166,7 @@ export default OakComponent({
this.updateItem({
[`user${entityStr}$user`]: [
{
id: generateNewId(),
action: 'remove',
data: {},
filter: {
@ -182,9 +178,6 @@ export default OakComponent({
]
}, idRemove);
await this.execute();
this.setState({
idRemove: '',
});
},
// 这三个函数貌似还没用上

View File

@ -0,0 +1,3 @@
{
"confirmRevokeAll": "确认删除用户的所有权限吗?"
}

View File

@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import {
Table,
Input,
@ -13,25 +13,40 @@ import PageHeader from '../../../components/common/pageHeader';
import UserEntityGrantList from '../../../pages/userEntityGrant/list';
import Style from './web.module.less';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(this: any) {
const { pagination, users = [], oakLoading, idRemove } = this.state;
const { namespace, entity, entityId } = this.props;
export default function Render(props: WebComponentProps<EntityDict, 'user', true, {
users: any[];
searchValue?: string;
pagination: {
pageSize: number;
total: number;
currentPage: number;
},
entity: string;
entityId: string;
}, {
goUpsert: () => void;
goUpdate: (id: string) => void;
confirmDelete: (id: string) => Promise<void>;
}>) {
const { pagination, users = [], entity, entityId, oakLoading } = props.data;
const { pageSize, total, currentPage } = pagination || {};
const { goUpsert, t, setCurrentPage, setPageSize, confirmDelete, goUpdate } = props.methods;
const [idRemove, setIdRemove] = useState(undefined as string | undefined);
const [inviteVisible, setInviteVisible] = useState(false);
return (
<PageHeader title="权限列表">
<div className={Style.container}>
<Space>
<Button type="primary" onClick={() => this.goUpsert()}>
<Button type="primary" onClick={() => goUpsert()}>
</Button>
<Button
onClick={() =>
this.setState({
invite: true,
})
}
onClick={() => setInviteVisible(true)}
>
</Button>
@ -39,7 +54,7 @@ export default function render(this: any) {
<Table
loading={oakLoading}
ref={this.tableRef}
// ref={this.tableRef}
rowKey="id"
columns={[
{
@ -104,7 +119,7 @@ export default function render(this: any) {
{record.relations?.map(
(ele: string, index: number) => (
<Tag key={index}>
{this.t(
{t(
entity + ':r.' + ele
)}
</Tag>
@ -113,39 +128,6 @@ export default function render(this: any) {
</Space>
);
},
// edit: {
// component: Select,
// // props, 透传全部属性到 Select 组件
// // props 为函数时参数有col, row, rowIndex, colIndex, editedRow。一般用于实现编辑组件之间的联动
// props: () => {
// return {
// multiple: true,
// minCollapsedNum: 1,
// autoWidth: true,
// options:
// relationArr &&
// relationArr.map(
// (
// ele: any,
// index: number
// ) => ({
// value: ele,
// label: this.t(
// entity + ':r.' + ele
// ),
// })
// ),
// };
// },
// showEditIcon: false,
// rules: [
// {
// required: true,
// message: '请至少选择一个权限',
// },
// ],
// },
},
{
title: '操作',
@ -156,22 +138,22 @@ export default function render(this: any) {
<Button
type="link"
onClick={(e) =>
this.goUpdate(record.id)
goUpdate(record.id)
}
>
{record.relations?.length > 0 ? t('common:action.update') : t('common:action.grant')}
</Button>
{record.relations?.length > 0 && (
<Button
danger
type="link"
onClick={() =>
this.onDelete(record.id)
}
>
</Button>
)}
{
record.relations?.length > 0 && (
<Button
danger
type="link"
onClick={() => setIdRemove(record.id)}
>
{t('common:action.revoke')}
</Button>
)
}
</Space>
);
},
@ -183,38 +165,38 @@ export default function render(this: any) {
pageSize,
current: currentPage,
onShowSizeChange: (current: number, size: number) => {
this.setPageSize(current);
setPageSize(current);
},
onChange: (page: number, pageSize: number) => {
this.setCurrentPage(page);
setCurrentPage(page);
},
}}
/>
</div>
<Modal
title="请确认"
title={t('common:areYouSure')}
open={!!idRemove}
onOk={() => this.confirmDelete()}
onCancel={() => this.setState({ idRemove: '' })}
cancelText="取消"
okText="确认"
onOk={async () => {
await confirmDelete(idRemove!);
setIdRemove(undefined);
}}
onCancel={() => setIdRemove(undefined)}
cancelText={t('common:action.cancel')}
okText={t('common:action.confirm')}
>
<p></p>
<p>{t('confirmRevokeAll')}</p>
</Modal>
<Modal
title="邀请记录"
open={!!this.state.invite}
onCancel={() => this.setState({ invite: false })}
// cancelText="关闭"
// okText=""
open={inviteVisible}
onCancel={() => setInviteVisible(false)}
width="80%"
footer={null}
>
<UserEntityGrantList
entity={entity}
entityId={entityId}
namespace={namespace}
variant="dialog"
oakPath="$userRelation/list-userEntityGrant/list"
/>

View File

@ -5,18 +5,33 @@ import { List, Avatar, Tag, Button, Space } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import Style from './mobile.module.less';
import { getName } from '../../../utils/randomUser';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(this: any) {
const { t } = this;
const { entity } = this.props;
const { users } = this.state;
export default function Render(props: WebComponentProps<EntityDict, 'user', true, {
users: any[];
searchValue?: string;
pagination: {
pageSize: number;
total: number;
currentPage: number;
},
entity: string;
entityId: string;
}, {
goUpsert: () => void;
goDetail: (id: string) => void;
confirmDelete: (id: string) => Promise<void>;
}>) {
const { t, goUpsert, goDetail } = props.methods;
const { entity, users } = props.data;
return (
<div className={Style.container}>
<List>
{users?.map((ele: any, index: number) => {
return (
<div onClick={(e) => this.goDetail(ele.id)} key={index}>
<div onClick={(e) => goDetail(ele.id)} key={index}>
<List.Item>
<List.Item.Meta
avatar={
@ -84,7 +99,7 @@ export default function render(this: any) {
shape="circle"
icon={<PlusOutlined />}
onClick={() => {
this.goUpsert();
goUpsert();
}}
/>
</div>

View File

@ -12,9 +12,7 @@ export default OakComponent({
},
isList: false,
formData({ data: mobile }) {
let legal = this.tryExecute();
return {
legal: !!legal,
userId: mobile?.userId,
};
},
@ -51,12 +49,9 @@ export default OakComponent({
this.clean();
this.unsetId();
// todo
await this.addOperation({
action: 'create',
data: {
mobile: value,
}
})
this.update({
mobile: value,
});
}
}
else {

View File

@ -2,10 +2,24 @@ import React from 'react';
import { Form, Input, Button, Space } from 'antd';
import Style from './web.module.less';
import OnUser from '../onUser/index';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../../general-app-domain';
export default function render(this: any) {
const { relations, entity, entityId } = this.props;
const { mobileValue, mobileValueReady, legal } = this.state;
export default function Render(props: WebComponentProps<EntityDict, 'mobile', false, {
entity: string;
entityId: string;
relations: string[];
mobileValue: string;
mobileValueReady: boolean;
userId: string;
}, {
onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>;
onReset: () => void;
}>) {
const { mobileValue, mobileValueReady, relations, entity, entityId, userId,
oakFullpath, oakExecutable } = props.data;
const { onConfirm, onMobileChange, onReset } = props.methods;
return (
<div className={Style.container}>
<Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}>
@ -33,7 +47,7 @@ export default function render(this: any) {
value={mobileValue}
onChange={(e) => {
const strValue = e.target.value;
this.onMobileChange(strValue);
onMobileChange(strValue);
}}
placeholder="请输入手机号码"
type="tel"
@ -44,15 +58,13 @@ export default function render(this: any) {
{mobileValueReady && (
<OnUser
oakAutoUnmount={true}
oakPath={
this.state.oakFullpath
? `${this.state.oakFullpath}.user`
oakPath={oakFullpath ? `${oakFullpath}.user`
: undefined
}
entity={entity}
entityId={entityId}
relations={relations}
oakId={this.state.userId}
oakId={userId}
/>
)}
<Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}>
@ -61,13 +73,13 @@ export default function render(this: any) {
<Button
type="primary"
onClick={() => {
this.onConfirm();
onConfirm();
}}
disabled={!legal}
disabled={!oakExecutable}
>
</Button>
<Button htmlType="reset" onClick={() => this.onReset()}>
<Button htmlType="reset" onClick={() => onReset()}>
</Button>
</Space>

View File

@ -4,19 +4,21 @@ import { isMobile } from 'oak-domain/lib/utils/validator';
export default OakComponent({
isList: false,
async formData() {
formData() {
let legal = this.tryExecute();
return {
legal: !!legal,
};
},
properties: {
entity: String,
entityId: String,
relations: Array,
},
methods: {
async onConfirm() {
await this.execute();
this.navigateBack();
},
onReset() {
this.clean();
}
},
});

View File

@ -3,40 +3,45 @@ import { Form, Button, Space } from 'antd';
import Style from './web.module.less';
import OnUser from '../onUser/index';
import PageHeader from '../../../../components/common/pageHeader';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../../general-app-domain';
export default function render(this: any) {
const { relations, entity, entityId } = this.props;
export default function Render(props: WebComponentProps<EntityDict, 'user', false, {
relations: string[];
entity: string;
entityId: string;
oakId: string;
legal: boolean;
}, {
onConfirm: () => Promise<void>;
}>) {
const { relations, entity, entityId, oakFullpath, oakId, legal } = props.data;
const { onConfirm, clean } = props.methods;
return (
<PageHeader showBack={true} title="编辑权限">
<div className={Style.container}>
<OnUser
oakAutoUnmount={true}
oakPath={
this.state.oakFullpath
? `${this.state.oakFullpath}.user`
: undefined
}
oakPath={oakFullpath ? `${oakFullpath}.user` : undefined}
entity={entity}
entityId={entityId}
relations={relations}
oakId={this.props.oakId}
oakId={oakId}
/>
<Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}>
<Form.Item wrapperCol={{ offset: 4 }}>
<Space>
<Button
disabled={!this.state.legal}
disabled={!legal}
type="primary"
onClick={() => {
this.onConfirm();
}}
onClick={() => onConfirm()}
>
</Button>
<Button
htmlType="reset"
onClick={() => this.onReset()}
onClick={() => clean()}
>
</Button>

View File

@ -14,8 +14,8 @@ export default OakComponent({
relations: Array,
},
lifetimes: {
async ready() {
const application = await this.features.application.getApplication();
ready() {
const application = this.features.application.getApplication();
const { type, config } = application;
let grantByUserEntityGrant = false, grantByMobile = false, grantByEmail = false;
if (type.startsWith('wechat')) {

View File

@ -1,117 +1,52 @@
import { generateNewId } from 'oak-domain/lib/utils/uuid';
import assert from 'assert';
import { OakInputIllegalException } from 'oak-domain/lib/types';
import { firstLetterUpperCase } from "oak-domain/lib/utils/string";
import { EntityDict as BaseEntityDict, EntityDict } from '../../../../general-app-domain';
export default OakComponent({
entity: 'user',
projection: ({ props }) => {
const { entity, entityId } = props;
const entityStr = firstLetterUpperCase(entity!);
return {
id: 1,
name: 1,
password: 1,
nickname: 1,
[`user${entityStr}$user`]: {
$entity: `user${entityStr}`,
data: {
id: 1,
userId: 1,
[`${entity}Id`]: 1,
relation: 1,
},
filter: {
[`${entity}Id`]: entityId,
}
},
} as EntityDict['user']['Selection']['data'];
projection: {
id: 1,
name: 1,
password: 1,
nickname: 1,
},
isList: false,
formData({ data: user, props }) {
const { entity, entityId } = props;
const entityStr = firstLetterUpperCase(entity!);
formData({ data: user }) {
const { name, nickname, password } = user || {};
const userRelations = user && (user as any)[`user${entityStr}$user`] as Array<{
id: string;
userId: string;
relation: string;
}>;
return {
password,
userRelations,
name,
nickname,
};
},
properties: {
oakId: String,
entity: String,
entityId: String,
relations: Array,
},
lifetimes: {
async ready() {
const { entity, entityId } = this.props;
const entityStr = firstLetterUpperCase(entity!);
this.update({
password: '12345678',
}, undefined, async () => {
const operations = this.getOperations();
const [ {operation} ] = operations! as { operation: BaseEntityDict['user']['CreateSingle']}[];
if (!operation.data.name) {
throw new OakInputIllegalException('user', ['name'], '用户姓名不能为空');
}
if ((operation.data as any)[`user${entityStr}$user`]?.length > 0) {
return;
}
throw new OakInputIllegalException('user', [`user${entityStr}$user`], '需要至少选择一个权限');
});
const { entity, oakId } = this.props;
if (!oakId) {
const entityStr = firstLetterUpperCase(entity!);
this.update({
password: '12345678',
}, undefined, async () => {
const operations = this.getOperations();
const [ {operation} ] = operations! as { operation: BaseEntityDict['user']['CreateSingle']}[];
if (!operation.data.name) {
throw new OakInputIllegalException('user', ['name'], this.t('placeholder.name'));
}
if ((operation.data as any)[`user${entityStr}$user`]?.length > 0) {
return;
}
throw new OakInputIllegalException('user', [`user${entityStr}$user`], this.t('placeholder.relation'));
});
}
},
},
methods: {
async onRelationChange(value: string[]) {
const { entity, entityId, oakId } = this.props;
const entityStr = firstLetterUpperCase(entity!);
const { userRelations } = this.state;
if (userRelations!.length > value.length) {
assert(userRelations!.length === value.length + 1);
// 删除一个relation
const toBeRemoved = userRelations!.find(
(ele: any) => !value.includes(ele.relation)
);
assert(userRelations!.length === value.length + 1);
// todo 这里应该改成component
this.update({
[`user${entityStr}$user`]: [{
action: 'remove',
data: {},
filter: {
id: toBeRemoved!.id,
},
}],
});
}
else {
// 增加一个relation
assert(userRelations!.length === value.length - 1);
const toBeInserted = value.find(
ele => !userRelations!.find(
(userRelation: any) => userRelation.relation === ele
)
);
this.update({
[`user${entityStr}$user`]: [{
action: 'create',
data: {
id: generateNewId(),
[`${entity}Id`]: entityId,
relation: toBeInserted,
},
}],
});
}
},
async onConfirm() {
await this.execute();
},

View File

@ -0,0 +1,10 @@
{
"placeholder": {
"name": "请输入姓名",
"password": "密码不少于8位",
"relation": "至少应选择一个权限"
},
"auth": "权限",
"existedUser": "现有用户",
"newUser": "新建用户"
}

View File

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "添加权限"
}

View File

@ -0,0 +1,72 @@
import assert from "assert";
import { firstLetterUpperCase } from "oak-domain/lib/utils/string";
import { EntityDict } from "../../../../../general-app-domain";
export default OakComponent({
entity() {
const { entity } = this.props;
return `user${firstLetterUpperCase(entity)}` as keyof EntityDict;
},
projection() {
const { entity } = this.props;
return {
id: 1,
userId: 1,
relation: 1,
[`${entity}Id`]: 1,
};
},
properties: {
entity: String,
entityId: String,
},
isList: true,
filters: [{
filter: ({ props }) => {
const { entity, entityId } = props;
return {
[`${entity}Id`]: entityId,
};
}
}],
formData({ data }) {
return {
userRelations: data,
};
},
methods: {
onRelationChange(relation: string, checked: boolean) {
const { entity, entityId } = this.props;
const { userRelations } = this.state;
if (checked) {
const userRelation = userRelations!.find(
(ele: { relation: string, id: string, $$deleteAt$$: number }) => ele.relation === relation
);
if (userRelation) {
assert(userRelation.$$deleteAt$$);
this.recoverItem(userRelation.id);
}
else {
this.addItem({
relation,
[`${entity}Id`]: entityId,
});
}
}
else {
const userRelation = userRelations!.find(
(ele: { relation: string, id: string }) => ele.relation === relation
);
assert(userRelation);
this.removeItem(userRelation.id);
}
},
isChecked(relation: string) {
const { userRelations } = this.state;
const userRelation = userRelations?.find(
(ele: { relation: string, $$deleteAt$$: number }) => ele.relation === relation && !ele.$$deleteAt$$
);
return !!userRelation;
}
}
})

View File

@ -0,0 +1,8 @@
.container {
background: var(--oak-bg-color-container);
// box-shadow: 0 2px 3px #0000001a;
// border-radius: 3px;
// padding: 30px 32px;
}

View File

@ -0,0 +1,39 @@
import React from 'react';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../../../general-app-domain';
import { Checkbox } from 'antd';
import { CheckboxValueType } from 'antd/es/checkbox/Group';
export default function Render(props: WebComponentProps<EntityDict, 'user', false, {
entity: string;
userRelations: Array<{
relation: string;
}>;
relations: string[];
}, {
onRelationChange: (relation: string, checked: boolean) => void;
isChecked: (relation: string) => boolean;
}>) {
const { entity, relations } = props.data;
const { t, onRelationChange, isChecked } = props.methods;
return (
<>
{
relations.map(
(relation) => (
<Checkbox
checked={isChecked(relation)}
value={relation}
onChange={({ target }) => {
const { checked } = target;
onRelationChange(relation, checked);
}}
>
{(t(`${entity}:r.${relation}`)) || relation}
</Checkbox>
)
)
}
</>
);
}

Some files were not shown because too many files have changed in this diff Show More