fi8x
This commit is contained in:
parent
0cefbeecc1
commit
27ed2f6ac5
|
|
@ -26,6 +26,7 @@ exports.default = OakComponent({
|
|||
data: {
|
||||
mobileValue: '',
|
||||
mobileValueReady: false,
|
||||
isNew: false,
|
||||
},
|
||||
methods: {
|
||||
onMobileChange: function (value) {
|
||||
|
|
@ -53,9 +54,15 @@ exports.default = OakComponent({
|
|||
if (data.length > 0) {
|
||||
this.clean();
|
||||
this.setId(data[0].id);
|
||||
this.setState({
|
||||
isNew: false,
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.clean();
|
||||
this.setState({
|
||||
isNew: true,
|
||||
});
|
||||
this.create({
|
||||
mobile: value,
|
||||
user: {
|
||||
|
|
@ -63,7 +70,6 @@ exports.default = OakComponent({
|
|||
action: 'create',
|
||||
data: {
|
||||
id: (0, uuid_1.generateNewId)(),
|
||||
password: '12345678',
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -85,9 +91,28 @@ exports.default = OakComponent({
|
|||
},
|
||||
onConfirm: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var userValue;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.execute()];
|
||||
case 0:
|
||||
if (this.state.isNew) {
|
||||
userValue = this.getFreshValue('user');
|
||||
if (!userValue.name) {
|
||||
this.setMessage({
|
||||
type: 'error',
|
||||
content: '用户姓名未填写',
|
||||
});
|
||||
return [2 /*return*/];
|
||||
}
|
||||
if (!userValue.password) {
|
||||
this.setMessage({
|
||||
type: 'error',
|
||||
content: '用户密码未设置',
|
||||
});
|
||||
return [2 /*return*/];
|
||||
}
|
||||
}
|
||||
return [4 /*yield*/, this.execute()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
this.setState({
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'mobile', fa
|
|||
mobileValue: string;
|
||||
mobileValueReady: boolean;
|
||||
userId: string;
|
||||
isNew: boolean;
|
||||
}, {
|
||||
onMobileChange: (value: string) => Promise<void>;
|
||||
onConfirm: () => Promise<void>;
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@
|
|||
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 web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
var index_1 = tslib_1.__importDefault(require("../onUser/index"));
|
||||
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 _this = this;
|
||||
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, isNew = _a.isNew;
|
||||
var _b = props.methods, onConfirm = _b.onConfirm, onMobileChange = _b.onMobileChange, onReset = _b.onReset;
|
||||
var _c = tslib_1.__read((0, react_1.useState)(false), 2), passwordConfirm = _c[0], setPasswordConfirm = _c[1];
|
||||
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,
|
||||
|
|
@ -25,8 +28,16 @@ function Render(props) {
|
|||
var strValue = e.target.value;
|
||||
onMobileChange(strValue);
|
||||
}, 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 () {
|
||||
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" }))] }) })) }))] })));
|
||||
: undefined, entity: entity, entityId: entityId, relations: relations, oakId: userId, setPasswordConfirm: setPasswordConfirm })), (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 () { 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*/, onConfirm()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
setPasswordConfirm(false);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); }, disabled: !oakExecutable || (isNew && !passwordConfirm) }, { 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;
|
||||
|
|
|
|||
|
|
@ -6,5 +6,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
relations: string[];
|
||||
mobile: string;
|
||||
isComponent: boolean;
|
||||
setPasswordConfirm: (value: boolean) => void;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ exports.default = OakComponent({
|
|||
relations: [],
|
||||
mobile: '',
|
||||
isComponent: false,
|
||||
setPasswordConfirm: function (value) { }
|
||||
},
|
||||
data: {
|
||||
userRelationRelativePath: '',
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
|
|||
entity: keyof EntityDict;
|
||||
entityId: string;
|
||||
isNew: boolean;
|
||||
setPasswordConfirm: (value: boolean) => void;
|
||||
}, {
|
||||
onMobileChange: (value: string) => Promise<void>;
|
||||
onConfirm: () => Promise<void>;
|
||||
|
|
|
|||
|
|
@ -2,14 +2,20 @@
|
|||
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 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");
|
||||
var icons_1 = require("@ant-design/icons");
|
||||
var password_1 = require("../../../../utils/password");
|
||||
function Render(props) {
|
||||
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 _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, setPasswordConfirm = _a.setPasswordConfirm;
|
||||
var _b = props.methods, t = _b.t, update = _b.update;
|
||||
var _c = tslib_1.__read((0, react_1.useState)(''), 2), password2 = _c[0], setPassword2 = _c[1];
|
||||
var _d = tslib_1.__read((0, react_1.useState)(''), 2), validateHelp = _d[0], setValidateHelp = _d[1];
|
||||
var _e = tslib_1.__read((0, react_1.useState)(''), 2), validateHelp1 = _e[0], setValidateHelp1 = _e[1];
|
||||
var _f = tslib_1.__read((0, react_1.useState)(''), 2), validateStatus = _f[0], setValidateStatus = _f[1];
|
||||
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,
|
||||
|
|
@ -24,16 +30,53 @@ function Render(props) {
|
|||
required: true,
|
||||
},
|
||||
] }, { 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)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: t('user:attr.password'), name: "password", rules: [
|
||||
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: t('user:attr.password'), name: "password", help: validateHelp1, rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入密码',
|
||||
validator: function (_, value) {
|
||||
if (value.length < 8) {
|
||||
setValidateHelp1('密码最短长度为8位');
|
||||
setValidateStatus('error');
|
||||
return;
|
||||
}
|
||||
else {
|
||||
setValidateHelp1('');
|
||||
setValidateStatus('');
|
||||
}
|
||||
if (password2) {
|
||||
setValidateHelp(value === password2 ? '' : '两次输入的密码不一致,请检查');
|
||||
setValidateStatus(value === password2 ? 'success' : 'error');
|
||||
}
|
||||
}
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input.Password, { value: password, onChange: function (e) {
|
||||
], hasFeedback: true, validateStatus: validateStatus }, { children: (0, jsx_runtime_1.jsx)(antd_1.Input.Password, { value: password, onChange: function (e) {
|
||||
var strValue = e.target.value;
|
||||
update({
|
||||
password: strValue,
|
||||
});
|
||||
}, iconRender: function (visible) { return (visible ? (0, jsx_runtime_1.jsx)(icons_1.EyeTwoTone, {}) : (0, jsx_runtime_1.jsx)(icons_1.EyeInvisibleOutlined, {})); }, placeholder: t('placeholder.password') }) }) })) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: t('auth'), rules: [
|
||||
setPasswordConfirm(strValue === password2 && strValue !== '');
|
||||
}, iconRender: function (visible) { return (visible ? (0, jsx_runtime_1.jsx)(icons_1.EyeTwoTone, {}) : (0, jsx_runtime_1.jsx)(icons_1.EyeInvisibleOutlined, {})); }, placeholder: t('placeholder.password') }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: '确认密码', name: "passwordConfirm", rules: [
|
||||
{
|
||||
required: true,
|
||||
validator: function (_, value) {
|
||||
if (password.length < 8) {
|
||||
return;
|
||||
}
|
||||
setValidateHelp(value === password ? '' : '两次输入的密码不一致,请检查');
|
||||
setValidateStatus(value === password ? 'success' : 'error');
|
||||
}
|
||||
},
|
||||
], validateTrigger: "onChange", help: validateHelp, validateStatus: validateStatus, hasFeedback: true }, { children: (0, jsx_runtime_1.jsx)(antd_1.Input.Password, { value: password2, onChange: function (e) {
|
||||
var strValue = e.target.value;
|
||||
setPassword2(strValue);
|
||||
if (password === strValue) {
|
||||
update({
|
||||
passwordSha1: (0, password_1.encryptPasswordSha1)(password)
|
||||
});
|
||||
}
|
||||
setPasswordConfirm(password === strValue);
|
||||
}, iconRender: function (visible) { return (visible ? (0, jsx_runtime_1.jsx)(icons_1.EyeTwoTone, {}) : (0, jsx_runtime_1.jsx)(icons_1.EyeInvisibleOutlined, {})); }, placeholder: '请再次输入密码' }) }))] }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: t('auth'), rules: [
|
||||
{
|
||||
required: true,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue