修正了userRelation.byMobile中的几个问题
This commit is contained in:
parent
122a2a52aa
commit
c461ea0e25
|
|
@ -25,7 +25,7 @@ function Render(props) {
|
|||
var strValue = e.target.value;
|
||||
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 () {
|
||||
: undefined, entity: entity, entityId: entityId, relations: relations })), (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" }))] }) })) }))] })));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var types_1 = require("oak-domain/lib/types");
|
||||
var string_1 = require("oak-domain/lib/utils/string");
|
||||
exports.default = OakComponent({
|
||||
entity: 'user',
|
||||
|
|
@ -42,7 +41,6 @@ exports.default = OakComponent({
|
|||
};
|
||||
},
|
||||
properties: {
|
||||
oakId: String,
|
||||
entity: String,
|
||||
entityId: String,
|
||||
relations: Array,
|
||||
|
|
@ -58,32 +56,14 @@ exports.default = OakComponent({
|
|||
lifetimes: {
|
||||
ready: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var _a, entity, oakId, entityStr_1;
|
||||
var _this = this;
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
_a = this.props, entity = _a.entity, oakId = _a.oakId;
|
||||
if (!oakId) {
|
||||
entityStr_1 = (0, string_1.firstLetterUpperCase)(entity);
|
||||
var entity, isCreation;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
entity = this.props.entity;
|
||||
isCreation = this.isCreation();
|
||||
if (isCreation) {
|
||||
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'));
|
||||
});
|
||||
}); });
|
||||
}
|
||||
else {
|
||||
this.update({});
|
||||
});
|
||||
}
|
||||
this.setState({
|
||||
userRelationRelativePath: "user".concat((0, string_1.firstLetterUpperCase)(entity), "$user"),
|
||||
|
|
|
|||
|
|
@ -7,18 +7,19 @@ var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
|||
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: [
|
||||
var _a = props.data, 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, isCreation = _b.isCreation;
|
||||
var isNew = oakFullpath && isCreation();
|
||||
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: !isNew ? 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,
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { disabled: !!oakId, onChange: function (e) {
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { disabled: !isNew, onChange: function (e) {
|
||||
var strValue = e.target.value;
|
||||
update({
|
||||
name: strValue,
|
||||
});
|
||||
}, 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: [
|
||||
}, value: name, placeholder: t('placeholder.name') }) }) })), !isNew ? (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: t('user:attr.nickname'), name: "nickname", rules: [
|
||||
{
|
||||
required: true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ export default function Render(props: WebComponentProps<EntityDict, 'mobile', fa
|
|||
entity={entity}
|
||||
entityId={entityId}
|
||||
relations={relations}
|
||||
oakId={userId}
|
||||
/>
|
||||
)}
|
||||
<Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ export default OakComponent({
|
|||
};
|
||||
},
|
||||
properties: {
|
||||
oakId: String,
|
||||
entity: String,
|
||||
entityId: String,
|
||||
relations: Array,
|
||||
|
|
@ -57,43 +56,15 @@ export default OakComponent({
|
|||
},
|
||||
lifetimes: {
|
||||
async ready() {
|
||||
const { entity, oakId } = this.props;
|
||||
if (!oakId) {
|
||||
const entityStr = firstLetterUpperCase(entity!);
|
||||
const { entity } = this.props;
|
||||
const isCreation = this.isCreation();
|
||||
if (isCreation) {
|
||||
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')
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
this.update({});
|
||||
}
|
||||
this.setState({
|
||||
userRelationRelativePath: `user${firstLetterUpperCase(
|
||||
entity
|
||||
|
|
|
|||
|
|
@ -21,12 +21,13 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
|
|||
onConfirm: () => Promise<void>;
|
||||
onReset: () => void;
|
||||
}>) {
|
||||
const { oakId, name, nickname, password, relations, oakFullpath, entity, entityId } = props.data;
|
||||
const { t, update } = props.methods;
|
||||
const { name, nickname, password, relations, oakFullpath, entity, entityId } = props.data;
|
||||
const { t, update, isCreation } = props.methods;
|
||||
const isNew = oakFullpath && isCreation();
|
||||
return (
|
||||
<div className={Style.container}>
|
||||
<Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}>
|
||||
<Form.Item style={{ marginBottom: 0 }} label={<div className={Style.tip}>{oakId ? t('existedUser') : t('newUser')}</div>} colon={false} />
|
||||
<Form.Item style={{ marginBottom: 0 }} label={<div className={Style.tip}>{!isNew ? t('existedUser') : t('newUser')}</div>} colon={false} />
|
||||
<Form.Item
|
||||
label={t('user:attr.name')}
|
||||
name="name"
|
||||
|
|
@ -38,7 +39,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
|
|||
>
|
||||
<>
|
||||
<Input
|
||||
disabled={!!oakId}
|
||||
disabled={!isNew}
|
||||
onChange={(e) => {
|
||||
const strValue = e.target.value;
|
||||
update({
|
||||
|
|
@ -51,7 +52,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
|
|||
</>
|
||||
</Form.Item>
|
||||
{
|
||||
!!oakId ? <Form.Item
|
||||
!isNew ? <Form.Item
|
||||
label={t('user:attr.nickname')}
|
||||
name="nickname"
|
||||
rules={[
|
||||
|
|
|
|||
Loading…
Reference in New Issue