userRelation适配frontend的改动

This commit is contained in:
Xu Chang 2023-03-22 20:26:17 +08:00
parent 4996868d44
commit 6355b6c55d
9 changed files with 36 additions and 33 deletions

View File

@ -1,6 +1,7 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib"); var tslib_1 = require("tslib");
var uuid_1 = require("oak-domain/lib/utils/uuid");
var validator_1 = require("oak-domain/lib/utils/validator"); var validator_1 = require("oak-domain/lib/utils/validator");
exports.default = OakComponent({ exports.default = OakComponent({
entity: 'mobile', entity: 'mobile',
@ -55,10 +56,16 @@ exports.default = OakComponent({
} }
else { else {
this.clean(); this.clean();
this.unsetId(); this.create({
// todo
this.update({
mobile: value, mobile: value,
user: {
id: (0, uuid_1.generateNewId)(),
action: 'create',
data: {
id: (0, uuid_1.generateNewId)(),
password: '12345678',
}
}
}); });
} }
return [3 /*break*/, 3]; return [3 /*break*/, 3];

View File

@ -24,7 +24,7 @@ function Render(props) {
] }, { 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) { ] }, { 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; var strValue = e.target.value;
onMobileChange(strValue); 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") }, placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u7801", type: "tel" }) }) })) })), mobileValueReady && userId && ((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, 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(); 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" }))] }) })) }))] }))); }, 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" }))] }) })) }))] })));

View File

@ -31,13 +31,14 @@ exports.default = OakComponent({
isList: false, isList: false,
formData: function (_a) { formData: function (_a) {
var user = _a.data; var user = _a.data;
var _b = user || {}, name = _b.name, nickname = _b.nickname, password = _b.password, extraFile$entity = _b.extraFile$entity; var _b = user || {}, name = _b.name, nickname = _b.nickname, password = _b.password, extraFile$entity = _b.extraFile$entity, $$createAt$$ = _b.$$createAt$$;
var avatar = this.features.extraFile.getUrl(extraFile$entity && extraFile$entity[0]); var avatar = this.features.extraFile.getUrl(extraFile$entity && extraFile$entity[0]);
return { return {
avatar: avatar, avatar: avatar,
password: password, password: password,
name: name, name: name,
nickname: nickname, nickname: nickname,
isNew: $$createAt$$ === 1,
}; };
}, },
properties: { properties: {
@ -56,15 +57,9 @@ exports.default = OakComponent({
lifetimes: { lifetimes: {
ready: function () { ready: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () { return tslib_1.__awaiter(this, void 0, void 0, function () {
var entity, isCreation; var entity;
return tslib_1.__generator(this, function (_a) { return tslib_1.__generator(this, function (_a) {
entity = this.props.entity; entity = this.props.entity;
isCreation = this.isCreation();
if (isCreation) {
this.update({
password: '12345678',
});
}
this.setState({ this.setState({
userRelationRelativePath: "user".concat((0, string_1.firstLetterUpperCase)(entity), "$user"), userRelationRelativePath: "user".concat((0, string_1.firstLetterUpperCase)(entity), "$user"),
}); });

View File

@ -11,6 +11,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
relations: string[]; relations: string[];
entity: string; entity: string;
entityId: string; entityId: string;
isNew: boolean;
}, { }, {
onMobileChange: (value: string) => Promise<void>; onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>; onConfirm: () => Promise<void>;

View File

@ -7,9 +7,8 @@ var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var userRelation_1 = tslib_1.__importDefault(require("./userRelation")); var userRelation_1 = tslib_1.__importDefault(require("./userRelation"));
var string_1 = require("oak-domain/lib/utils/string"); var string_1 = require("oak-domain/lib/utils/string");
function Render(props) { function Render(props) {
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 _a = props.data, name = _a.name, isNew = _a.isNew, 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 _b = props.methods, t = _b.t, update = _b.update;
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: [ 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, required: true,

View File

@ -1,4 +1,6 @@
import { generateNewId } from 'oak-domain/lib/utils/uuid';
import { isMobile } from 'oak-domain/lib/utils/validator'; import { isMobile } from 'oak-domain/lib/utils/validator';
import { EntityDict } from '../../../../general-app-domain';
export default OakComponent({ export default OakComponent({
entity: 'mobile', entity: 'mobile',
@ -45,11 +47,17 @@ export default OakComponent({
} }
else { else {
this.clean(); this.clean();
this.unsetId(); this.create({
// todo
this.update({
mobile: value, mobile: value,
}); user: {
id: generateNewId(),
action: 'create',
data: {
id: generateNewId(),
password: '12345678',
}
}
} as EntityDict['mobile']['CreateSingle']['data']);
} }
} }
else { else {

View File

@ -55,7 +55,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'mobile', fa
</> </>
</Form.Item> </Form.Item>
</Form> </Form>
{mobileValueReady && ( {mobileValueReady && userId && (
<OnUser <OnUser
oakAutoUnmount={true} oakAutoUnmount={true}
oakPath={oakFullpath ? `${oakFullpath}.user` oakPath={oakFullpath ? `${oakFullpath}.user`

View File

@ -30,7 +30,7 @@ export default OakComponent({
}, },
isList: false, isList: false,
formData({ data: user }) { formData({ data: user }) {
const { name, nickname, password, extraFile$entity } = user || {}; const { name, nickname, password, extraFile$entity, $$createAt$$ } = user || {};
const avatar = this.features.extraFile.getUrl( const avatar = this.features.extraFile.getUrl(
extraFile$entity && extraFile$entity[0] extraFile$entity && extraFile$entity[0]
); );
@ -39,6 +39,7 @@ export default OakComponent({
password, password,
name, name,
nickname, nickname,
isNew: $$createAt$$ === 1,
}; };
}, },
properties: { properties: {
@ -57,14 +58,6 @@ export default OakComponent({
lifetimes: { lifetimes: {
async ready() { async ready() {
const { entity } = this.props; const { entity } = this.props;
const isCreation = this.isCreation();
if (isCreation) {
this.update(
{
password: '12345678',
},
);
}
this.setState({ this.setState({
userRelationRelativePath: `user${firstLetterUpperCase( userRelationRelativePath: `user${firstLetterUpperCase(
entity! entity!

View File

@ -16,14 +16,14 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
relations: string[]; relations: string[];
entity: string; entity: string;
entityId: string; entityId: string;
isNew: boolean;
}, { }, {
onMobileChange: (value: string) => Promise<void>; onMobileChange: (value: string) => Promise<void>;
onConfirm: () => Promise<void>; onConfirm: () => Promise<void>;
onReset: () => void; onReset: () => void;
}>) { }>) {
const { name, nickname, password, relations, oakFullpath, entity, entityId } = props.data; const { name, isNew, nickname, password, relations, oakFullpath, entity, entityId } = props.data;
const { t, update, isCreation } = props.methods; const { t, update } = props.methods;
const isNew = oakFullpath && isCreation();
return ( return (
<div className={Style.container}> <div className={Style.container}>
<Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}> <Form colon labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}>