Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-general-business into dev

This commit is contained in:
Xu Chang 2022-11-02 10:27:27 +08:00
commit 89a534326e
15 changed files with 358 additions and 349 deletions

View File

@ -5,12 +5,14 @@ var jsx_runtime_1 = require("react/jsx-runtime");
var extraFile_1 = require("../../../utils/extraFile"); var extraFile_1 = require("../../../utils/extraFile");
var antd_1 = require("antd"); var antd_1 = require("antd");
var icons_1 = require("@ant-design/icons"); var icons_1 = require("@ant-design/icons");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less")); var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
function extraFileToUploadFile(extraFile, systemConfig) { function extraFileToUploadFile(extraFile, systemConfig) {
return Object.assign({}, extraFile, { return Object.assign({}, extraFile, {
url: (0, extraFile_1.composeFileUrl)(extraFile, systemConfig), url: (0, extraFile_1.composeFileUrl)(extraFile, systemConfig),
name: extraFile.filename,
thumbUrl: (0, extraFile_1.composeFileUrl)(extraFile, systemConfig), thumbUrl: (0, extraFile_1.composeFileUrl)(extraFile, systemConfig),
name: extraFile.filename,
uid: extraFile.uid || extraFile.id, //upload 组件需要uid来维护fileList
}); });
} }
function getListType(theme) { function getListType(theme) {
@ -37,11 +39,29 @@ function render() {
} }
return (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "default" }, { children: "\u9009\u62E9\u6587\u4EF6" })); return (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "default" }, { children: "\u9009\u62E9\u6587\u4EF6" }));
}; };
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Upload, tslib_1.__assign({ className: className, style: style, disabled: disabled, directory: directory, showUploadList: showUploadList, beforeUpload: beforeUpload, multiple: multiple, maxCount: maxNumber, accept: accept, listType: listType, fileList: theme === 'custom' return ((0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", className: web_module_less_1.default['oak-upload'] }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Upload, tslib_1.__assign({ className: (0, classnames_1.default)(web_module_less_1.default['oak-upload__upload'], className), style: style, disabled: disabled, directory: directory, showUploadList: showUploadList, beforeUpload: function (file) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var result;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof beforeUpload === 'function')) return [3 /*break*/, 2];
return [4 /*yield*/, beforeUpload(file)];
case 1:
result = _a.sent();
if (result) {
return [2 /*return*/, false];
}
_a.label = 2;
case 2: return [2 /*return*/, false];
}
});
}); }, multiple: multiple, maxCount: maxNumber, accept: accept, listType: listType, fileList: theme === 'custom'
? [] ? []
: (files || []).map(function (ele) { : (files === null || files === void 0 ? void 0 : files.length)
return extraFileToUploadFile(ele, systemConfig); ? files.map(function (ele) {
}), onChange: function (_a) { return extraFileToUploadFile(ele, systemConfig);
})
: null, onChange: function (_a) {
var file = _a.file, fileList = _a.fileList, event = _a.event; var file = _a.file, fileList = _a.fileList, event = _a.event;
var arr = (fileList === null || fileList === void 0 ? void 0 : fileList.filter(function (ele) { return !ele.id; })) || []; var arr = (fileList === null || fileList === void 0 ? void 0 : fileList.filter(function (ele) { return !ele.id; })) || [];
_this.setState({ _this.setState({

View File

@ -1,8 +1,7 @@
.oak-upload {
&__tips {
display: block;
.oak-upload__tips { color: var(--oak-text-color-placeholder);
display: block; margin-top: 8px;
color: var(--oak-text-color-placeholder); }
margin-top: 8px;
} }

View File

@ -5,11 +5,14 @@ var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd"); var antd_1 = require("antd");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less")); var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var index_1 = tslib_1.__importDefault(require("../onUser/index")); var index_1 = tslib_1.__importDefault(require("../onUser/index"));
var pageHeader_1 = tslib_1.__importDefault(require("../../../../components/common/pageHeader"));
function render() { function render() {
var _this = this; var _this = this;
var _a = this.props, relations = _a.relations, entity = _a.entity, entityId = _a.entityId; var _a = this.props, relations = _a.relations, entity = _a.entity, entityId = _a.entityId;
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({ 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 () { 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)(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(); _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" }))] }) })) })), (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 })] }))); } }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ htmlType: "reset", onClick: function () { return _this.onReset(); } }, { children: "\u91CD\u7F6E" }))] }) })) })), (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 })] })) })));
} }
exports.default = render; exports.default = render;

View File

@ -11,43 +11,43 @@ function render() {
if (oakId) { if (oakId) {
return (0, jsx_runtime_1.jsx)("div", { children: oakId }); return (0, jsx_runtime_1.jsx)("div", { children: oakId });
} }
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.pageWithPadding }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Alert, { message: "\u63D0\u4EA4\u6743\u9650\u540E\uFF0C\u8BF7\u5C06\u4E8C\u7EF4\u7801\u53D1\u7ED9\u5F85\u5206\u4EAB\u6743\u9650\u7684\u7528\u6237\u626B\u63CF", type: "success" }), (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, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6743\u9650", rules: [ return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Alert, { showIcon: true, message: "\u63D0\u4EA4\u6743\u9650\u540E\uFF0C\u8BF7\u5C06\u4E8C\u7EF4\u7801\u53D1\u7ED9\u5F85\u5206\u4EAB\u6743\u9650\u7684\u7528\u6237\u626B\u63CF", type: "info", style: { marginBottom: 16 } }), (0, jsx_runtime_1.jsxs)(antd_1.Form, tslib_1.__assign({ labelCol: { span: 4 }, wrapperCol: { span: 8 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6743\u9650", rules: [
{ {
required: true, required: true,
message: '请选择一个权限', message: '请选择一个权限',
}, },
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { value: relation, onChange: function (_a) { ] }, { children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { value: relation, onChange: function (_a) {
var target = _a.target; var target = _a.target;
var value = target.value; var value = target.value;
_this.setRelation(value); _this.setRelation(value);
}, options: relations.map(function (ele) { return ({ }, options: relations.map(function (ele) { return ({
value: ele, value: ele,
label: (_this.t && _this.t(entity + ':r.' + ele)) || ele, label: (_this.t && _this.t(entity + ':r.' + ele)) || ele,
}); }) }) })), type === 'grant' && (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u4EBA\u6570", rules: [ }); }) }) })), type === 'grant' && ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u4EBA\u6570", rules: [
{ {
required: true, required: true,
message: '请选择分享的目标人数', message: '请选择分享的目标人数',
}, },
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { value: number, onChange: function (_a) { ] }, { children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { value: number, onChange: function (_a) {
var target = _a.target; var target = _a.target;
var value = target.value; var value = target.value;
_this.setNumber(value); _this.setNumber(value);
}, options: [ }, options: [
{ value: 1, label: '单次' }, { value: 1, label: '单次' },
{ value: 10000, label: '不限次' } { value: 10000, label: '不限次' },
] }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u65F6\u6548", rules: [ ] }) }))), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u65F6\u6548", rules: [
{ {
required: true, required: true,
message: '请选择一个时效', message: '请选择一个时效',
}, },
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { min: 1, max: 15, value: period, onChange: function (value) { ] }, { children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { min: 1, max: 15, value: period, onChange: function (value) {
_this.setState({ _this.setState({
period: value, period: value,
}); });
}, addonAfter: "\u5206\u949F" }) })), (0, jsx_runtime_1.jsxs)(antd_1.Form.Item, tslib_1.__assign({ style: { marginLeft: 100 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", style: { marginRight: 10 }, onClick: function () { }, addonAfter: "\u5206\u949F" }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ wrapperCol: { offset: 4 } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () {
_this.confirm(); _this.confirm();
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () { } }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () {
_this.onBack(); _this.onBack();
} }, { children: "\u8FD4\u56DE" }))] }))] }) }))] }))); } }, { children: "\u8FD4\u56DE" }))] }) }))] }))] })));
} }
exports.default = render; exports.default = render;

View File

@ -4,56 +4,62 @@ var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime"); var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd"); var antd_1 = require("antd");
var mobile_module_less_1 = tslib_1.__importDefault(require("./mobile.module.less")); var mobile_module_less_1 = tslib_1.__importDefault(require("./mobile.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() { function render() {
var _this = this; var _a = this.props, entity = _a.entity, entityId = _a.entityId, relations = _a.relations;
var _a = this.props, relations = _a.relations, entity = _a.entity; var _b = this.state, grantByUserEntityGrant = _b.grantByUserEntityGrant, grantByEmail = _b.grantByEmail, grantByMobile = _b.grantByMobile, grantMethodCount = _b.grantMethodCount;
var _b = this.state, name = _b.name, mobile = _b.mobile, password = _b.password, relationArr = _b.relationArr; var SubPart = (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
var relationArr2 = typeof relations === 'object' if (grantMethodCount === 0) {
? relations SubPart = ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: mobile_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" })));
: relations && JSON.parse(relations); }
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: mobile_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, tslib_1.__assign({ label: "\u59D3\u540D", name: "name", rules: [ else if (grantMethodCount === 1) {
{ if (grantByEmail) {
required: true, SubPart = (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: mobile_module_less_1.default.container }, { children: "\u5C1A\u672A\u5B9E\u73B0" }));
message: '姓名不能为空', }
}, else if (grantByMobile) {
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { onChange: function (e) { SubPart = ((0, jsx_runtime_1.jsx)(index_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: this.state.oakFullpath
_this.setUpdateData('name', e.target.value); ? "".concat(this.state.oakFullpath, ".mobile")
}, value: name, placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D" }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u624B\u673A\u53F7\u7801", name: "mobile", rules: [ : undefined, oakAutoUnmount: true }));
{ }
required: true, else {
message: '手机号不能为空', (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")
min: 11, : undefined, oakAutoUnmount: true }));
message: '请输入11位手机号', }
}, }
{ else {
max: 11, var items = [
message: '请输入11位手机号', {
}, label: 'Email',
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { maxLength: 11, value: mobile, onChange: function (e) { key: 'item-1',
var strValue = e.target.value; children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: mobile_module_less_1.default.container }, { children: "\u5C1A\u672A\u5B9E\u73B0" })),
_this.setUpdateData('mobile$user.0.mobile', strValue.replace(/[^\d\-\d]/g, '')); },
}, placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u7801", type: "tel" }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u5BC6\u7801", name: "mobile", rules: [ {
{ label: '手机号',
required: true, key: 'item-2',
message: '密码不能为空', children: ((0, jsx_runtime_1.jsx)(index_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: "$userRelationUpsert/upsert-byMobile", oakAutoUnmount: 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) { {
_this.setUpdateData('password', e.target.value); label: '二维码',
}, placeholder: "\u4E0D\u5C11\u4E8E\u516B\u4F4D" }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6743\u9650", rules: [ key: 'item-3',
{ children: ((0, jsx_runtime_1.jsx)(byUserEntityGrant_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: "$userRelationUpsert/upsert-byUserEntityGrant", oakAutoUnmount: true })),
required: true, },
message: '请至少选择一个权限', ];
}, var items2 = [];
], name: "relation" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Checkbox.Group, { value: relationArr, onChange: function (value) { if (grantByEmail) {
_this.setRelationValue(value); items2.push(items[0]);
}, options: relationArr2.map(function (ele) { return ({ }
value: ele, if (grantByMobile) {
label: (_this.t && _this.t(entity + ':r.' + ele)) || items2.push(items[1]);
ele, }
}); }) }) }) })), (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", htmlType: "submit", onClick: function () { if (grantByUserEntityGrant) {
_this.onConfirm(); items2.push(items[2]);
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ htmlType: "reset" }, { children: "\u91CD\u7F6E" }))] }) }))] })) }))); }
SubPart = (0, jsx_runtime_1.jsx)(antd_1.Tabs, { items: items2 });
}
return SubPart;
} }
exports.default = render; exports.default = render;

View File

@ -1,8 +1,7 @@
.oak-upload {
&__tips {
display: block;
.oak-upload__tips { color: var(--oak-text-color-placeholder);
display: block; margin-top: 8px;
color: var(--oak-text-color-placeholder); }
margin-top: 8px;
} }

View File

@ -3,14 +3,16 @@ import { composeFileUrl, bytesToSize } from '../../../utils/extraFile';
import { Space, Upload, UploadFile, Tag, Button, Table, UploadProps } from 'antd'; import { Space, Upload, UploadFile, Tag, Button, Table, UploadProps } from 'antd';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import classNames from 'classnames';
import Style from './web.module.less'; import Style from './web.module.less';
function extraFileToUploadFile(extraFile: any, systemConfig: any) { function extraFileToUploadFile(extraFile: any, systemConfig: any) {
return Object.assign({}, extraFile, { return Object.assign({}, extraFile, {
url: composeFileUrl(extraFile, systemConfig), url: composeFileUrl(extraFile, systemConfig),
name: extraFile.filename,
thumbUrl: composeFileUrl(extraFile, systemConfig), thumbUrl: composeFileUrl(extraFile, systemConfig),
name: extraFile.filename,
uid: extraFile.uid || extraFile.id, //upload 组件需要uid来维护fileList
}); });
} }
@ -69,14 +71,22 @@ export default function render(this: any) {
}; };
return ( return (
<Space direction="vertical"> <Space direction="vertical" className={Style['oak-upload']}>
<Upload <Upload
className={className} className={classNames(Style['oak-upload__upload'], className)}
style={style} style={style}
disabled={disabled} disabled={disabled}
directory={directory} directory={directory}
showUploadList={showUploadList} showUploadList={showUploadList}
beforeUpload={beforeUpload} beforeUpload={async (file) => {
if (typeof beforeUpload === 'function') {
const result = await beforeUpload(file);
if (result) {
return false;
}
}
return false;
}}
multiple={multiple} multiple={multiple}
maxCount={maxNumber} maxCount={maxNumber}
accept={accept} accept={accept}
@ -84,9 +94,11 @@ export default function render(this: any) {
fileList={ fileList={
theme === 'custom' theme === 'custom'
? [] ? []
: (files || []).map((ele: any) => : files?.length
? files.map((ele: any) =>
extraFileToUploadFile(ele, systemConfig) extraFileToUploadFile(ele, systemConfig)
) )
: null
} }
onChange={({ file, fileList, event }) => { onChange={({ file, fileList, event }) => {
const arr = const arr =

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { Form, Input, Checkbox, Button, Space, Card } from 'antd'; import { Form, Input, Button, Space } from 'antd';
import Style from './web.module.less'; import Style from './web.module.less';
import OnUser from '../onUser/index'; import OnUser from '../onUser/index';

View File

@ -5,13 +5,4 @@
box-shadow: 0 2px 3px #0000001a; box-shadow: 0 2px 3px #0000001a;
border-radius: 3px; border-radius: 3px;
padding: 30px 32px; padding: 30px 32px;
}
.formContainer {
padding-top: 32px;
width: 676px;
margin: 0 auto;
}
.tip {
font-size: var(--oak-font-size-mark-small);
color: var(--oak-warning-color-7);
} }

View File

@ -2,40 +2,48 @@ import React from 'react';
import { Form, Input, Checkbox, Button, Space, Card } from 'antd'; import { Form, Input, Checkbox, Button, Space, Card } from 'antd';
import Style from './web.module.less'; import Style from './web.module.less';
import OnUser from '../onUser/index'; import OnUser from '../onUser/index';
import PageHeader from '../../../../components/common/pageHeader';
export default function render(this: any) { export default function render(this: any) {
const { relations, entity, entityId } = this.props; const { relations, entity, entityId } = this.props;
return ( return (
<div className={Style.container}> <PageHeader showBack={true} title="编辑权限">
<Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}> <div className={Style.container}>
<Form.Item wrapperCol={{ offset: 4 }}> <Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}>
<Space> <Form.Item wrapperCol={{ offset: 4 }}>
<Button <Space>
disabled={!this.state.legal} <Button
type="primary" disabled={!this.state.legal}
onClick={() => { type="primary"
this.onConfirm(); onClick={() => {
}} this.onConfirm();
> }}
>
</Button>
<Button </Button>
htmlType="reset" <Button
onClick={() => this.onReset()} htmlType="reset"
> onClick={() => this.onReset()}
>
</Button>
</Space> </Button>
</Form.Item> </Space>
</Form> </Form.Item>
<OnUser </Form>
oakAutoUnmount={true} <OnUser
oakPath={this.state.oakFullpath ? `${this.state.oakFullpath}.user` : undefined} oakAutoUnmount={true}
entity={entity} oakPath={
entityId={entityId} this.state.oakFullpath
relations={relations} ? `${this.state.oakFullpath}.user`
oakId={this.props.oakId} : undefined
/> }
</div> entity={entity}
entityId={entityId}
relations={relations}
oakId={this.props.oakId}
/>
</div>
</PageHeader>
); );
} }

View File

@ -1,13 +1,9 @@
.formContainer {
padding-top: 32px; .container {
width: 676px;
margin: 0 auto;
}
.pageWithPadding {
padding: 30px 32px; padding: 30px 32px;
background: var(--oak-bg-color-container); background: var(--oak-bg-color-container);
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1); // box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
border-radius: 3px; // border-radius: 3px;
} }

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { Form, Radio, Button, Alert, InputNumber } from 'antd'; import { Form, Radio, Button, Alert, InputNumber, Space } from 'antd';
import Style from './web.module.less'; import Style from './web.module.less';
export default function render(this: any) { export default function render(this: any) {
@ -10,33 +10,38 @@ export default function render(this: any) {
return <div>{oakId}</div>; return <div>{oakId}</div>;
} }
return ( return (
<div className={Style.pageWithPadding}> <div className={Style.container}>
<Alert message="提交权限后,请将二维码发给待分享权限的用户扫描" type="success" /> <Alert
<div className={Style.formContainer}> showIcon
<Form> message="提交权限后,请将二维码发给待分享权限的用户扫描"
type="info"
style={{ marginBottom: 16 }}
/>
<Form labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}>
<Form.Item
label="权限"
rules={[
{
required: true,
message: '请选择一个权限',
},
]}
>
<Radio.Group
value={relation}
onChange={({ target }) => {
const { value } = target;
this.setRelation(value);
}}
options={relations.map((ele: string) => ({
value: ele,
label:
(this.t && this.t(entity + ':r.' + ele)) || ele,
}))}
/>
</Form.Item>
{type === 'grant' && (
<Form.Item <Form.Item
label="权限"
rules={[
{
required: true,
message: '请选择一个权限',
},
]}
>
<Radio.Group
value={relation}
onChange={({ target }) => {
const { value } = target;
this.setRelation(value);
}}
options={relations.map((ele: string) => ({
value: ele,
label:
(this.t && this.t(entity + ':r.' + ele)) || ele,
}))}
/>
</Form.Item>
{type === 'grant' && <Form.Item
label="人数" label="人数"
rules={[ rules={[
{ {
@ -53,35 +58,36 @@ export default function render(this: any) {
}} }}
options={[ options={[
{ value: 1, label: '单次' }, { value: 1, label: '单次' },
{ value: 10000, label: '不限次' } { value: 10000, label: '不限次' },
]} ]}
/> />
</Form.Item>}
<Form.Item
label="时效"
rules={[
{
required: true,
message: '请选择一个时效',
},
]}
>
<InputNumber
min={1}
max={15}
value={period}
onChange={(value) => {
this.setState({
period: value,
});
}}
addonAfter="分钟"
/>
</Form.Item> </Form.Item>
<Form.Item style={{ marginLeft: 100 }}> )}
<Form.Item
label="时效"
rules={[
{
required: true,
message: '请选择一个时效',
},
]}
>
<InputNumber
min={1}
max={15}
value={period}
onChange={(value) => {
this.setState({
period: value,
});
}}
addonAfter="分钟"
/>
</Form.Item>
<Form.Item wrapperCol={{ offset: 4 }}>
<Space>
<Button <Button
type="primary" type="primary"
style={{ marginRight: 10 }}
onClick={() => { onClick={() => {
this.confirm(); this.confirm();
}} }}
@ -95,9 +101,9 @@ export default function render(this: any) {
> >
</Button> </Button>
</Form.Item> </Space>
</Form> </Form.Item>
</div> </Form>
</div> </div>
); );
} }

View File

@ -2,15 +2,12 @@
.container { .container {
background: var(--oak-bg-color-container); background: var(--oak-bg-color-container);
box-shadow: 0 2px 3px #0000001a; // box-shadow: 0 2px 3px #0000001a;
border-radius: 3px; // border-radius: 3px;
padding: 30px 32px; padding: 30px 32px;
} }
.formContainer {
padding-top: 32px;
width: 676px;
margin: 0 auto;
}
.tip { .tip {
font-size: var(--oak-font-size-mark-small); font-size: var(--oak-font-size-mark-small);
color: var(--oak-warning-color-7); color: var(--oak-warning-color-7);

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { Form, Input, Checkbox, Button, Space } from 'antd'; import { Form, Input, Checkbox, Button, Space } from 'antd';
import Style from './web.module.less'; import Style from './mobile.module.less';
export default function render(this: any) { export default function render(this: any) {
return <div></div> return <div></div>

View File

@ -1,131 +1,103 @@
import React from 'react'; import React from 'react';
import { Form, Input, Checkbox, Button, Space } from 'antd'; import { Tabs } from 'antd';
import Style from './mobile.module.less'; import Style from './mobile.module.less';
import ByMobile from './byMobile/index';
import ByUserEntityGrant from './byUserEntityGrant';
import assert from 'assert';
export default function render(this: any) { export default function render(this: any) {
const { relations, entity } = this.props; const { entity, entityId, relations } = this.props;
const { name, mobile, password, relationArr } = this.state; const {
const relationArr2: string[] = grantByUserEntityGrant,
typeof relations === 'object' grantByEmail,
? relations grantByMobile,
: relations && JSON.parse(relations); grantMethodCount,
return ( } = this.state;
<div className={Style.container}> let SubPart: JSX.Element = <></>;
<Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}> if (grantMethodCount === 0) {
<Form.Item SubPart = (
label="姓名" <div className={Style.container}>
name="name"
rules={[ </div>
{ );
required: true, } else if (grantMethodCount === 1) {
message: '姓名不能为空', if (grantByEmail) {
}, SubPart = <div className={Style.container}></div>;
]} } else if (grantByMobile) {
> SubPart = (
<> <ByMobile
<Input entity={entity}
onChange={(e) => { entityId={entityId}
this.setUpdateData('name', e.target.value); relations={relations}
}} oakPath={
value={name} this.state.oakFullpath
placeholder="请输入姓名" ? `${this.state.oakFullpath}.mobile`
/> : undefined
</> }
</Form.Item> oakAutoUnmount={true}
<Form.Item />
label="手机号码" );
name="mobile" } else {
rules={[ assert(grantByUserEntityGrant === true);
{ SubPart = (
required: true, <ByUserEntityGrant
message: '手机号不能为空', entity={entity}
}, entityId={entityId}
{ relations={relations}
min: 11, oakPath={
message: '请输入11位手机号', this.state.oakFullpath
}, ? `${this.state.oakFullpath}.userEntityGrant`
{ : undefined
max: 11, }
message: '请输入11位手机号', oakAutoUnmount={true}
}, />
]} );
> }
<> } else {
<Input const items = [
maxLength={11} {
value={mobile} label: 'Email',
onChange={(e) => { key: 'item-1',
const strValue = e.target.value; children: <div className={Style.container}></div>,
this.setUpdateData( },
'mobile$user.0.mobile', {
strValue.replace(/[^\d\-\d]/g, '') label: '手机号',
); key: 'item-2',
}} children: (
placeholder="请输入手机号码" <ByMobile
type="tel" entity={entity}
/> entityId={entityId}
</> relations={relations}
</Form.Item> oakPath="$userRelationUpsert/upsert-byMobile"
<Form.Item oakAutoUnmount={true}
label="密码" />
name="mobile" ),
rules={[ },
{ {
required: true, label: '二维码',
message: '密码不能为空', key: 'item-3',
}, children: (
]} <ByUserEntityGrant
> entity={entity}
<> entityId={entityId}
<Input relations={relations}
value={password} oakPath="$userRelationUpsert/upsert-byUserEntityGrant"
onChange={(e) => { oakAutoUnmount={true}
this.setUpdateData('password', e.target.value); />
}} ),
placeholder="不少于八位" },
/> ];
</> const items2: typeof items = [];
</Form.Item> if (grantByEmail) {
<Form.Item items2.push(items[0]);
label="权限" }
rules={[ if (grantByMobile) {
{ items2.push(items[1]);
required: true, }
message: '请至少选择一个权限', if (grantByUserEntityGrant) {
}, items2.push(items[2]);
]} }
name="relation" SubPart = <Tabs items={items2} />;
> }
<> return SubPart;
<Checkbox.Group
value={relationArr}
onChange={(value) => {
this.setRelationValue(value);
}}
options={relationArr2.map((ele) => ({
value: ele,
label:
(this.t && this.t(entity + ':r.' + ele)) ||
ele,
}))}
></Checkbox.Group>
</>
</Form.Item>
<Form.Item wrapperCol={{ offset: 4 }}>
<Space>
<Button
type="primary"
htmlType="submit"
onClick={() => {
this.onConfirm();
}}
>
</Button>
<Button htmlType="reset"></Button>
</Space>
</Form.Item>
</Form>
</div>
);
} }