userRelation的部分相关代码
This commit is contained in:
parent
8a7746cae8
commit
f6cb02cb58
|
|
@ -456,7 +456,7 @@ function loginWechat(_a, context) {
|
|||
switch (_b.label) {
|
||||
case 0:
|
||||
loginLogic = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||
var rowStore, application, _a, type, config, systemId, config2, appId, appSecret, wechatInstance, _b, sessionKey, openId, unionId, _c, wechatUser, id, wechatUser2, wechatUserUpdateData, _d, token, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, wechatUser3, wechatUser2, _t, _u, _v, wechatUserCreateData_1, _w, _x, _y, userData, wechatUserCreateData, _z, _0, _1;
|
||||
var rowStore, application, _a, type, config, systemId, appId, appSecret, config2, config2, wechatInstance, _b, sessionKey, openId, unionId, _c, wechatUser, id, wechatUser2, wechatUserUpdateData, _d, token, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, wechatUser3, wechatUser2, _t, _u, _v, wechatUserCreateData_1, _w, _x, _y, userData, wechatUserCreateData, _z, _0, _1;
|
||||
var _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22;
|
||||
return tslib_1.__generator(this, function (_23) {
|
||||
switch (_23.label) {
|
||||
|
|
@ -470,11 +470,15 @@ function loginWechat(_a, context) {
|
|||
(0, assert_1.assert)(type !== 'wechatMp' && config.type !== 'wechatMp');
|
||||
if (type === 'wechatPublic') {
|
||||
config2 = config;
|
||||
appId = config2.appId;
|
||||
appSecret = config2.appSecret;
|
||||
}
|
||||
else {
|
||||
config2 = config;
|
||||
(0, assert_1.assert)(config2.wechat);
|
||||
appId = config2.wechat.appId;
|
||||
appSecret = config2.wechat.appSecret;
|
||||
}
|
||||
appId = config2.appId, appSecret = config2.appSecret;
|
||||
wechatInstance = oak_external_sdk_1.WechatSDK.getInstance(appId, appSecret, type);
|
||||
return [4 /*yield*/, wechatInstance.code2Session(code)];
|
||||
case 2:
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ var checkers = [
|
|||
if (data instanceof Array) {
|
||||
data.forEach(function (ele) {
|
||||
var a = 'name';
|
||||
(0, validator_2.checkAttributesNotNull)(ele, ['name', 'detail', 'phone', 'areaId']);
|
||||
(0, validator_2.checkAttributesNotNull)('address', ele, ['name', 'detail', 'phone', 'areaId']);
|
||||
if (!(0, validator_1.isMobile)(ele.phone)) {
|
||||
throw new types_1.OakInputIllegalException(['phone'], '手机号非法');
|
||||
throw new types_1.OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
(0, validator_2.checkAttributesNotNull)(data, ['name', 'detail', 'phone', 'areaId']);
|
||||
(0, validator_2.checkAttributesNotNull)('address', data, ['name', 'detail', 'phone', 'areaId']);
|
||||
if (!(0, validator_1.isMobile)(data.phone)) {
|
||||
throw new types_1.OakInputIllegalException(['phone'], '手机号非法');
|
||||
throw new types_1.OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
}
|
||||
return [2 /*return*/, 0];
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ var checkers = [
|
|||
return tslib_1.__generator(this, function (_b) {
|
||||
data = operation.data;
|
||||
if (Object.keys(data).filter(function (ele) { return !ele.includes('$'); }).length > 0) {
|
||||
throw new types_1.OakInputIllegalException(Object.keys(data), '授权不允许传入其它属性');
|
||||
throw new types_1.OakInputIllegalException('user', Object.keys(data), '授权不允许传入其它属性');
|
||||
}
|
||||
return [2 /*return*/, 0];
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ var checkers = [
|
|||
data = operation.data;
|
||||
if (data instanceof Array) {
|
||||
data.forEach(function (ele) {
|
||||
(0, validator_1.checkAttributesNotNull)(ele, ['type', 'entity', 'entityId', 'relation']);
|
||||
(0, validator_1.checkAttributesNotNull)('userEntityGrant', ele, ['type', 'entity', 'entityId', 'relation']);
|
||||
if (!ele.hasOwnProperty('number') || ele.type === 'transfer') {
|
||||
Object.assign(ele, {
|
||||
number: 1,
|
||||
|
|
@ -24,7 +24,7 @@ var checkers = [
|
|||
}
|
||||
else {
|
||||
if (ele.number <= 0) {
|
||||
throw new types_1.OakInputIllegalException(['number', '分享的权限数量必须大于0']);
|
||||
throw new types_1.OakInputIllegalException('userEntityGrant', ['number', '分享的权限数量必须大于0']);
|
||||
}
|
||||
}
|
||||
Object.assign(ele, {
|
||||
|
|
@ -33,7 +33,7 @@ var checkers = [
|
|||
});
|
||||
}
|
||||
else {
|
||||
(0, validator_1.checkAttributesNotNull)(data, ['type', 'entity', 'entityId', 'relation']);
|
||||
(0, validator_1.checkAttributesNotNull)('userEntityGrant', data, ['type', 'entity', 'entityId', 'relation']);
|
||||
if (!data.hasOwnProperty('number') || data.type === 'transfer') {
|
||||
Object.assign(data, {
|
||||
number: 1,
|
||||
|
|
@ -41,7 +41,7 @@ var checkers = [
|
|||
}
|
||||
else {
|
||||
if (data.number <= 0) {
|
||||
throw new types_1.OakInputIllegalException(['number', '分享的权限数量必须大于0']);
|
||||
throw new types_1.OakInputIllegalException('userEntityGrant', ['number', '分享的权限数量必须大于0']);
|
||||
}
|
||||
}
|
||||
Object.assign(data, {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
/// <reference types="react" />
|
||||
import './index.less';
|
||||
declare const Empty: () => JSX.Element;
|
||||
export default Empty;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
/// <reference types="react" />
|
||||
import './index.less';
|
||||
declare const Empty: () => JSX.Element;
|
||||
export default Empty;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
/// <reference types="react" />
|
||||
import { Config } from '../../../../types/Config';
|
||||
export default function Account(props: {
|
||||
account: Required<Config>['Account'];
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ exports.default = OakComponent({
|
|||
projection: {
|
||||
id: 1,
|
||||
tag1: 1,
|
||||
tag2: 1,
|
||||
origin: 1,
|
||||
bucket: 1,
|
||||
objectId: 1,
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ exports.applications = [
|
|||
systemId: DEV_CONFIG_1.DEV_SYSTEM_ID,
|
||||
config: {
|
||||
type: 'web',
|
||||
passport: ['email', 'mobile', 'wechat'],
|
||||
},
|
||||
description: 'web应用,指向dev_system',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { String, Text } from 'oak-domain/lib/types/DataType';
|
||||
import { EntityShape } from 'oak-domain/lib/types/Entity';
|
||||
import { Schema as System } from './System';
|
||||
declare type Passport = 'email' | 'mobile' | 'wechat';
|
||||
export declare type AppType = 'web' | 'wechatMp' | 'wechatPublic';
|
||||
export declare type WechatMpConfig = {
|
||||
type: 'wechatMp';
|
||||
|
|
@ -10,8 +11,11 @@ export declare type WechatMpConfig = {
|
|||
};
|
||||
export declare type WebConfig = {
|
||||
type: 'web';
|
||||
appId?: string;
|
||||
appSecret?: string;
|
||||
wechat?: {
|
||||
appId: string;
|
||||
appSecret: string;
|
||||
};
|
||||
passport: Passport[];
|
||||
};
|
||||
declare type WechatPublicTemplateMsgsConfig = Record<string, {
|
||||
templateId: string;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "attr": { "detail": "详情", "area": "所在地区", "phone": "联系电话", "name": "姓名", "default": "是否默认", "remark": "备注" } }
|
||||
{ "attr": { "detail": "详细地址", "area": "所在地区", "phone": "联系电话", "name": "姓名", "default": "是否默认", "remark": "备注" } }
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import * as System from "../System/Schema";
|
|||
import * as Token from "../Token/Schema";
|
||||
import * as WechatQrCode from "../WechatQrCode/Schema";
|
||||
import * as WechatUser from "../WechatUser/Schema";
|
||||
declare type Passport = 'email' | 'mobile' | 'wechat';
|
||||
export declare type AppType = 'web' | 'wechatMp' | 'wechatPublic';
|
||||
export declare type WechatMpConfig = {
|
||||
type: 'wechatMp';
|
||||
|
|
@ -17,8 +18,11 @@ export declare type WechatMpConfig = {
|
|||
};
|
||||
export declare type WebConfig = {
|
||||
type: 'web';
|
||||
appId?: string;
|
||||
appSecret?: string;
|
||||
wechat?: {
|
||||
appId: string;
|
||||
appSecret: string;
|
||||
};
|
||||
passport: Passport[];
|
||||
};
|
||||
declare type WechatPublicTemplateMsgsConfig = Record<string, {
|
||||
templateId: string;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
import '@wangeditor/editor/dist/css/style.css';
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
declare const _default: any;
|
||||
/// <reference types="react" />
|
||||
import React from '../../../utils/react';
|
||||
declare const _default: React.ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ var tslib_1 = require("tslib");
|
|||
var string_1 = require("oak-domain/lib/utils/string");
|
||||
var extraFile_1 = require("../../../utils/extraFile");
|
||||
var react_1 = tslib_1.__importDefault(require("../../../utils/react"));
|
||||
exports.default = OakPage({
|
||||
exports.default = OakComponent({
|
||||
entity: 'user',
|
||||
projection: function (_a) {
|
||||
var props = _a.props;
|
||||
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
||||
var entity, entityId, entityStr;
|
||||
var _b, _c;
|
||||
return tslib_1.__generator(this, function (_d) {
|
||||
var _b, _c, _d;
|
||||
return tslib_1.__generator(this, function (_e) {
|
||||
entity = props.entity, entityId = props.entityId;
|
||||
entityStr = (0, string_1.firstLetterUpperCase)(entity);
|
||||
return [2 /*return*/, (_b = {
|
||||
|
|
@ -36,6 +36,9 @@ exports.default = OakPage({
|
|||
_c["".concat(entity, "Id")] = 1,
|
||||
_c.relation = 1,
|
||||
_c),
|
||||
filter: (_d = {},
|
||||
_d["".concat(entity, "Id")] = entityId,
|
||||
_d)
|
||||
},
|
||||
_b.extraFile$entity = {
|
||||
$entity: 'extraFile',
|
||||
|
|
@ -65,7 +68,7 @@ exports.default = OakPage({
|
|||
// 由调用者注入oakFilter
|
||||
{
|
||||
filter: function (_a) {
|
||||
var features = _a.features, props = _a.props, onLoadOptions = _a.onLoadOptions;
|
||||
var features = _a.features, props = _a.props;
|
||||
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
||||
var entityId, entity, entityStr;
|
||||
var _b;
|
||||
|
|
@ -95,25 +98,20 @@ exports.default = OakPage({
|
|||
var _b;
|
||||
var users = _a.data, props = _a.props, features = _a.features;
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var entity, entityId, entityStr, filter, _c, pagination;
|
||||
return tslib_1.__generator(this, function (_d) {
|
||||
switch (_d.label) {
|
||||
var entity, entityId, entityStr, filter, pagination;
|
||||
return tslib_1.__generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
entity = props.entity, entityId = props.entityId;
|
||||
entityStr = (0, string_1.firstLetterUpperCase)(entity);
|
||||
_c = this.state.oakFullpath;
|
||||
if (!_c) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, this.getFilterByName('name')];
|
||||
case 1:
|
||||
_c = (_d.sent());
|
||||
_d.label = 2;
|
||||
case 2:
|
||||
filter = _c;
|
||||
pagination = this.state.oakFullpath && this.getPagination();
|
||||
filter = _c.sent();
|
||||
pagination = this.getPagination();
|
||||
return [2 /*return*/, {
|
||||
users: users === null || users === void 0 ? void 0 : users.map(function (ele) {
|
||||
var _a, _b;
|
||||
var _c = ele || {}, mobile$user = _c.mobile$user, extraFile$entity = _c.extraFile$entity;
|
||||
var mobile$user = ele.mobile$user, extraFile$entity = ele.extraFile$entity;
|
||||
var mobile = mobile$user && ((_a = mobile$user[0]) === null || _a === void 0 ? void 0 : _a.mobile);
|
||||
var relations = (_b = ele["user".concat(entityStr, "$user")]) === null || _b === void 0 ? void 0 : _b.filter(function (rt) { return rt["".concat(entity, "Id")] === entityId; }).map(function (rt2) { return rt2.relation; });
|
||||
var avatar = extraFile$entity &&
|
||||
|
|
@ -141,19 +139,8 @@ exports.default = OakPage({
|
|||
relations: Array,
|
||||
},
|
||||
data: {
|
||||
show: false,
|
||||
searchValue: '',
|
||||
deleteIndex: '',
|
||||
editableRowKeys: [],
|
||||
btnItems: [
|
||||
{
|
||||
label: '二维码授权',
|
||||
},
|
||||
{
|
||||
label: '添加授权',
|
||||
},
|
||||
],
|
||||
visible: false,
|
||||
idRemove: '',
|
||||
},
|
||||
lifetimes: {
|
||||
created: function () {
|
||||
|
|
@ -165,70 +152,74 @@ exports.default = OakPage({
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
onAdd: function () {
|
||||
if (process.env.OAK_PLATFORM === 'web') {
|
||||
this.goUpsert();
|
||||
}
|
||||
else {
|
||||
this.setState({
|
||||
visible: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
goUpsert: function () {
|
||||
var _a = this.props, entity = _a.entity, entityId = _a.entityId, relations = _a.relations;
|
||||
this.navigateTo({
|
||||
url: '/userRelation/upsert',
|
||||
entity: entity,
|
||||
entityId: entityId,
|
||||
relations: relations,
|
||||
}, {
|
||||
relations: relations,
|
||||
});
|
||||
},
|
||||
goUserEntityGrantWithGrant: function () {
|
||||
goUpdate: function (id) {
|
||||
var _a = this.props, entity = _a.entity, entityId = _a.entityId, relations = _a.relations;
|
||||
this.navigateTo({
|
||||
url: '/userEntityGrant/grant',
|
||||
url: '/userRelation/upsert/byUser',
|
||||
entity: entity,
|
||||
entityId: entityId,
|
||||
oakId: id,
|
||||
}, {
|
||||
relations: relations,
|
||||
});
|
||||
},
|
||||
onActionSelect: function (e) {
|
||||
var _a = e.detail, index = _a.index, selected = _a.selected;
|
||||
switch (index) {
|
||||
case 0: {
|
||||
this.goUserEntityGrantWithGrant();
|
||||
}
|
||||
case 1: {
|
||||
this.goUpsert();
|
||||
}
|
||||
}
|
||||
},
|
||||
onActionCancel: function () {
|
||||
onDelete: function (id) {
|
||||
this.setState({
|
||||
visible: false,
|
||||
idRemove: id,
|
||||
});
|
||||
},
|
||||
onActionClose: function () {
|
||||
this.onActionCancel();
|
||||
},
|
||||
bindClicked: function (e) {
|
||||
var id = e.currentTarget.dataset.id;
|
||||
this.goDetail(id);
|
||||
},
|
||||
goDetail: function (id) {
|
||||
var _a = this.props, relations = _a.relations, entity = _a.entity, entityId = _a.entityId;
|
||||
this.navigateTo({
|
||||
url: '/userRelation/detail',
|
||||
oakId: id,
|
||||
relations: relations,
|
||||
entity: entity,
|
||||
entityId: entityId,
|
||||
confirmDelete: function () {
|
||||
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) {
|
||||
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;
|
||||
user = users.find(function (ele) { return ele.id === idRemove; });
|
||||
relations = user["user".concat(entityStr, "$user")];
|
||||
return [4 /*yield*/, this.execute({
|
||||
action: 'update',
|
||||
data: (_c = {},
|
||||
_c["user".concat(entityStr, "$user")] = [
|
||||
{
|
||||
action: 'remove',
|
||||
data: {},
|
||||
filter: {
|
||||
id: {
|
||||
$in: relations.map(function (ele) { return ele.id; }),
|
||||
},
|
||||
},
|
||||
}
|
||||
],
|
||||
_c),
|
||||
filter: {
|
||||
id: idRemove,
|
||||
},
|
||||
})];
|
||||
case 1:
|
||||
_d.sent();
|
||||
this.setState({
|
||||
idRemove: '',
|
||||
});
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
// 这三个函数貌似还没用上
|
||||
searchChange: function (event) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var value;
|
||||
|
|
@ -272,90 +263,5 @@ exports.default = OakPage({
|
|||
});
|
||||
});
|
||||
},
|
||||
// web table methods
|
||||
onEdit: function (e) {
|
||||
var editableRowKeys = this.state.editableRowKeys;
|
||||
var id = e.currentTarget.dataset.id;
|
||||
if (!editableRowKeys.includes(id)) {
|
||||
this.setState({
|
||||
editableRowKeys: editableRowKeys.concat(id),
|
||||
});
|
||||
}
|
||||
},
|
||||
updateEditRowKey: function (id) {
|
||||
var editableRowKeys = this.state.editableRowKeys;
|
||||
var index = editableRowKeys.findIndex(function (t) { return t === id; });
|
||||
editableRowKeys.splice(index, 1);
|
||||
this.setState({
|
||||
editableRowKeys: tslib_1.__spreadArray([], tslib_1.__read(editableRowKeys), false),
|
||||
});
|
||||
},
|
||||
onSave: function (e) {
|
||||
var id = e.currentTarget.dataset.id;
|
||||
this.currentSaveId = id;
|
||||
// 触发内部校验,而后在 onRowValidate 中接收异步校验结果
|
||||
this.tableRef.current.validateRowData(id);
|
||||
},
|
||||
onCancel: function (e) {
|
||||
var id = e.currentTarget.dataset.id;
|
||||
this.updateEditRowKey(id);
|
||||
this.tableRef.current.clearValidateData();
|
||||
},
|
||||
onRowValidate: function (params) {
|
||||
var _this = this;
|
||||
if (params.result.length) {
|
||||
var r = params.result[0];
|
||||
this.setMessage({
|
||||
type: 'error',
|
||||
content: "".concat(r.col.title, " ").concat(r.errorList[0].message),
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 如果是 table 的父组件主动触发校验
|
||||
if (params.trigger === 'parent' && !params.result.length) {
|
||||
var users_1 = this.state.users;
|
||||
var _a = this.props, entity_1 = _a.entity, entityId_1 = _a.entityId;
|
||||
var entityStr_1 = (0, string_1.firstLetterUpperCase)(entity_1);
|
||||
var current_1 = this.editMap[this.currentSaveId];
|
||||
if (current_1) {
|
||||
Object.keys(current_1.editedRow).forEach(function (ele) {
|
||||
if (ele === 'relations') {
|
||||
var userRelations_1 = users_1[current_1.rowIndex].relations;
|
||||
userRelations_1.forEach(function (ele2) {
|
||||
var _a;
|
||||
if (!current_1.editedRow[ele].includes(ele2)) {
|
||||
_this.toggleNode((_a = {
|
||||
relation: ele2
|
||||
},
|
||||
_a["".concat(entity_1, "Id")] = entityId_1,
|
||||
_a), false, "".concat(current_1.rowIndex, ".user").concat(entityStr_1, "$user"));
|
||||
}
|
||||
});
|
||||
current_1.editedRow[ele].forEach(function (ele2) {
|
||||
var _a;
|
||||
if (!userRelations_1.includes(ele2)) {
|
||||
_this.toggleNode((_a = {
|
||||
relation: ele2
|
||||
},
|
||||
_a["".concat(entity_1, "Id")] = entityId_1,
|
||||
_a), true, "".concat(current_1.rowIndex, ".user").concat(entityStr_1, "$user"));
|
||||
}
|
||||
});
|
||||
_this.execute('grant');
|
||||
}
|
||||
else {
|
||||
_this.setUpdateData("".concat(0, ".").concat(ele), current_1.editedRow[ele]);
|
||||
_this.execute('update');
|
||||
}
|
||||
});
|
||||
}
|
||||
this.updateEditRowKey(this.currentSaveId);
|
||||
}
|
||||
},
|
||||
onRowEdit: function (params) {
|
||||
var _a;
|
||||
var row = params.row, col = params.col, value = params.value;
|
||||
this.editMap[row.id] = tslib_1.__assign(tslib_1.__assign({}, params), { editedRow: (_a = {}, _a[col.colKey] = value, _a) });
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -2,133 +2,127 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var jsx_runtime_1 = require("react/jsx-runtime");
|
||||
var tdesign_react_1 = require("tdesign-react");
|
||||
var antd_1 = require("antd");
|
||||
var pageHeader_1 = tslib_1.__importDefault(require("../../../components/common/pageHeader"));
|
||||
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
function render() {
|
||||
var _this = this;
|
||||
var t = this.t;
|
||||
var _a = this.state, pagination = _a.pagination, _b = _a.users, users = _b === void 0 ? [] : _b, oakLoading = _a.oakLoading, _c = _a.editableRowKeys, editableRowKeys = _c === void 0 ? [] : _c;
|
||||
var _d = this.props, relations = _d.relations, entity = _d.entity, entityId = _d.entityId;
|
||||
var _e = pagination || {}, pageSize = _e.pageSize, total = _e.total, currentPage = _e.currentPage;
|
||||
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, relations = _c.relations, entity = _c.entity, entityId = _c.entityId;
|
||||
var _d = pagination || {}, pageSize = _d.pageSize, total = _d.total, currentPage = _d.currentPage;
|
||||
var relationArr = typeof relations === 'object'
|
||||
? relations
|
||||
: relations && JSON.parse(relations);
|
||||
return ((0, jsx_runtime_1.jsx)(pageHeader_1.default, tslib_1.__assign({ title: "\u4EBA\u5458\u5217\u8868" }, { children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: [(0, jsx_runtime_1.jsxs)(tdesign_react_1.Space, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ shape: "rectangle", size: "medium", type: "button", variant: "base", onClick: function () { return _this.goUpsert(); } }, { children: "\u6DFB\u52A0" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ shape: "rectangle", size: "medium", type: "button", variant: "base", onClick: function () { return _this.goUserEntityGrantWithGrant(); } }, { children: "\u4E8C\u7EF4\u7801\u5206\u4EAB" }))] }), (0, jsx_runtime_1.jsx)(tdesign_react_1.Table, { loading: oakLoading, ref: this.tableRef, rowKey: "id", editableRowKeys: editableRowKeys, onRowEdit: function (params) { return _this.onRowEdit(params); }, onRowValidate: function (params) { return _this.onRowValidate(params); }, columns: [
|
||||
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.jsx)(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.Table, { loading: oakLoading, ref: this.tableRef, rowKey: "id", columns: [
|
||||
{
|
||||
width: 100,
|
||||
colKey: 'index',
|
||||
dataIndex: 'index',
|
||||
title: '序号',
|
||||
cell: function (_a) {
|
||||
var rowIndex = _a.rowIndex;
|
||||
return rowIndex + 1;
|
||||
},
|
||||
render: function (value, record, index) { return index + 1; },
|
||||
},
|
||||
{
|
||||
colKey: 'avatar',
|
||||
dataIndex: 'avatar',
|
||||
title: '头像',
|
||||
cell: function (_a) {
|
||||
var row = _a.row, rowIndex = _a.rowIndex, col = _a.col, colIndex = _a.colIndex;
|
||||
var avatar = row.avatar;
|
||||
return avatar ? ((0, jsx_runtime_1.jsx)(tdesign_react_1.Avatar, { hideOnLoadFailed: false, image: avatar, shape: "circle" })) : ((0, jsx_runtime_1.jsx)("span", { children: "\u672A\u8BBE\u7F6E" }));
|
||||
render: function (value, record, index) {
|
||||
return value ? ((0, jsx_runtime_1.jsx)(antd_1.Avatar, { src: value, shape: "circle" })) : ((0, jsx_runtime_1.jsx)("span", { children: "\u672A\u8BBE\u7F6E" }));
|
||||
},
|
||||
},
|
||||
{
|
||||
colKey: 'name',
|
||||
dataIndex: 'name',
|
||||
title: '姓名',
|
||||
edit: {
|
||||
component: tdesign_react_1.Input,
|
||||
props: {
|
||||
clearable: true,
|
||||
autofocus: true,
|
||||
autoWidth: true,
|
||||
},
|
||||
rules: [
|
||||
{ required: true, message: '不能为空' },
|
||||
],
|
||||
showEditIcon: false,
|
||||
},
|
||||
// edit: {
|
||||
// component: Input,
|
||||
// props: {
|
||||
// clearable: true,
|
||||
// autofocus: true,
|
||||
// autoWidth: true,
|
||||
// },
|
||||
// rules: [
|
||||
// { required: true, message: '不能为空' },
|
||||
// ],
|
||||
// showEditIcon: false,
|
||||
// },
|
||||
},
|
||||
{
|
||||
colKey: 'nickname',
|
||||
dataIndex: 'nickname',
|
||||
title: '昵称',
|
||||
edit: {
|
||||
component: tdesign_react_1.Input,
|
||||
props: {
|
||||
clearable: true,
|
||||
autofocus: true,
|
||||
autoWidth: true,
|
||||
},
|
||||
rules: [
|
||||
{ required: true, message: '不能为空' },
|
||||
],
|
||||
showEditIcon: false,
|
||||
},
|
||||
// edit: {
|
||||
// component: Input,
|
||||
// props: {
|
||||
// clearable: true,
|
||||
// autofocus: true,
|
||||
// autoWidth: true,
|
||||
// },
|
||||
// rules: [
|
||||
// { required: true, message: '不能为空' },
|
||||
// ],
|
||||
// showEditIcon: false,
|
||||
// },
|
||||
},
|
||||
{
|
||||
colKey: 'mobile',
|
||||
dataIndex: 'mobile',
|
||||
title: '手机号',
|
||||
},
|
||||
{
|
||||
colKey: 'relations',
|
||||
dataIndex: 'relations',
|
||||
title: '权限',
|
||||
cell: function (_a) {
|
||||
var _b;
|
||||
var row = _a.row, rowIndex = _a.rowIndex, col = _a.col, colIndex = _a.colIndex;
|
||||
return ((0, jsx_runtime_1.jsx)(tdesign_react_1.Space, { children: (_b = row.relations) === null || _b === void 0 ? void 0 : _b.map(function (ele, index) { return ((0, jsx_runtime_1.jsx)(tdesign_react_1.Tag, { children: t(entity + ':r.' + ele) }, index)); }) }));
|
||||
},
|
||||
edit: {
|
||||
component: tdesign_react_1.Select,
|
||||
// props, 透传全部属性到 Select 组件
|
||||
// props 为函数时,参数有:col, row, rowIndex, colIndex, editedRow。一般用于实现编辑组件之间的联动
|
||||
props: function () {
|
||||
return {
|
||||
multiple: true,
|
||||
minCollapsedNum: 1,
|
||||
autoWidth: true,
|
||||
options: relationArr &&
|
||||
relationArr.map(function (ele, index) { return ({
|
||||
value: ele,
|
||||
label: t(entity + ':r.' + ele),
|
||||
}); }),
|
||||
};
|
||||
},
|
||||
showEditIcon: false,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请至少选择一个权限',
|
||||
},
|
||||
],
|
||||
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)); }) }));
|
||||
},
|
||||
// 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: '操作',
|
||||
colKey: 'operate',
|
||||
cell: function (_a) {
|
||||
var row = _a.row;
|
||||
var editable = editableRowKeys.includes(row.id);
|
||||
return ((0, jsx_runtime_1.jsxs)(tdesign_react_1.Space, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", variant: "text", onClick: function (e) {
|
||||
return _this.goDetail(row.id);
|
||||
} }, { children: "\u8BE6\u60C5" })), !editable && ((0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", variant: "text", "data-id": row.id, onClick: function (e) {
|
||||
return _this.onEdit(e);
|
||||
} }, { children: "\u7F16\u8F91" }))), editable && ((0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", variant: "text", "data-id": row.id, onClick: function (e) {
|
||||
return _this.onSave(e);
|
||||
} }, { children: "\u4FDD\u5B58" }))), editable && ((0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", variant: "text", "data-id": row.id, onClick: function (e) {
|
||||
return _this.onCancel(e);
|
||||
} }, { children: "\u53D6\u6D88" })))] }));
|
||||
dataIndex: 'operate',
|
||||
render: function (value, record, index) {
|
||||
var _a;
|
||||
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" }))] }));
|
||||
},
|
||||
},
|
||||
], data: users, pagination: {
|
||||
], dataSource: users, pagination: {
|
||||
total: total,
|
||||
pageSize: pageSize,
|
||||
current: currentPage,
|
||||
onPageSizeChange: function (ps) {
|
||||
_this.setPageSize(ps);
|
||||
onShowSizeChange: function (current, size) {
|
||||
_this.setPageSize(current);
|
||||
},
|
||||
onCurrentChange: function (current) {
|
||||
_this.setCurrentPage(current);
|
||||
onChange: function (page, pageSize) {
|
||||
_this.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" }) }))] })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
declare const _default: any;
|
||||
/// <reference types="react" />
|
||||
declare const _default: import("react").ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var string_1 = require("oak-domain/lib/utils/string");
|
||||
exports.default = OakPage({
|
||||
exports.default = OakComponent({
|
||||
entity: 'user',
|
||||
projection: function (_a) {
|
||||
var props = _a.props;
|
||||
|
|
@ -26,7 +26,7 @@ exports.default = OakPage({
|
|||
_c),
|
||||
filter: (_d = {},
|
||||
_d["".concat(entity, "Id")] = props.entityId,
|
||||
_d)
|
||||
_d),
|
||||
},
|
||||
_b)];
|
||||
});
|
||||
|
|
@ -62,7 +62,7 @@ exports.default = OakPage({
|
|||
});
|
||||
return [2 /*return*/, {
|
||||
relationArr: relationArr,
|
||||
relationMap: relationMap
|
||||
relationMap: relationMap,
|
||||
}];
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
declare const _default: any;
|
||||
/// <reference types="react" />
|
||||
declare const _default: import("react").ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var string_1 = require("oak-domain/lib/utils/string");
|
||||
exports.default = OakPage({
|
||||
exports.default = OakComponent({
|
||||
isList: true,
|
||||
formData: function (_a) {
|
||||
var data = _a.data, props = _a.props;
|
||||
|
|
@ -15,7 +15,9 @@ exports.default = OakPage({
|
|||
rows = data === null || data === void 0 ? void 0 : data.map(function (ele) {
|
||||
var _a = ele, id = _a.id, _b = nameProperty, name = _a[_b], _c = "user".concat(entityStr, "$").concat(oakEntity), userEntity = _a[_c];
|
||||
var relations = userEntity === null || userEntity === void 0 ? void 0 : userEntity.map(function (ele) { return ele.relation; });
|
||||
var hasRelation = props.relations.map(function (ele2) { return relations.includes(ele2); });
|
||||
var hasRelation = props.relations.map(function (ele2) {
|
||||
return relations.includes(ele2);
|
||||
});
|
||||
return {
|
||||
id: id,
|
||||
name: name,
|
||||
|
|
@ -58,6 +60,6 @@ exports.default = OakPage({
|
|||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
declare const _default: any;
|
||||
/// <reference types="react" />
|
||||
declare const _default: import("react").ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
var tslib_1 = require("tslib");
|
||||
var string_1 = require("oak-domain/lib/utils/string");
|
||||
var extraFile_1 = require("../../../utils/extraFile");
|
||||
exports.default = OakPage({
|
||||
exports.default = OakComponent({
|
||||
entity: 'user',
|
||||
projection: function (_a) {
|
||||
var props = _a.props;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
/// <reference types="react" />
|
||||
declare const _default: import("react").ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var validator_1 = require("oak-domain/lib/utils/validator");
|
||||
exports.default = OakComponent({
|
||||
entity: 'mobile',
|
||||
projection: {
|
||||
id: 1,
|
||||
mobile: 1,
|
||||
ableState: 1,
|
||||
userId: 1,
|
||||
},
|
||||
isList: false,
|
||||
formData: function (_a) {
|
||||
var mobile = _a.data;
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var legal, err_1;
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
legal = false;
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, this.tryExecute()];
|
||||
case 2:
|
||||
legal = _b.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_1 = _b.sent();
|
||||
legal = false;
|
||||
return [3 /*break*/, 4];
|
||||
case 4: return [2 /*return*/, {
|
||||
legal: legal,
|
||||
userId: mobile === null || mobile === void 0 ? void 0 : mobile.userId,
|
||||
}];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
properties: {
|
||||
entity: String,
|
||||
entityId: String,
|
||||
relations: Array,
|
||||
},
|
||||
data: {
|
||||
mobileValue: '',
|
||||
mobileValueReady: false,
|
||||
},
|
||||
methods: {
|
||||
onMobileChange: function (value) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var mobileValueReady, data;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
mobileValueReady = (0, validator_1.isMobile)(value);
|
||||
if (!mobileValueReady) return [3 /*break*/, 5];
|
||||
return [4 /*yield*/, this.features.cache.refresh('mobile', {
|
||||
data: {
|
||||
id: 1,
|
||||
mobile: 1,
|
||||
ableState: 1,
|
||||
userId: 1,
|
||||
},
|
||||
filter: {
|
||||
mobile: value,
|
||||
ableState: 'enabled',
|
||||
}
|
||||
})];
|
||||
case 1:
|
||||
data = (_a.sent()).data;
|
||||
if (!(data.length > 0)) return [3 /*break*/, 2];
|
||||
this.cleanOperation();
|
||||
this.setId(data[0].id);
|
||||
return [3 /*break*/, 4];
|
||||
case 2:
|
||||
this.cleanOperation();
|
||||
this.unsetId();
|
||||
return [4 /*yield*/, this.addOperation({
|
||||
action: 'create',
|
||||
data: {
|
||||
mobile: value,
|
||||
}
|
||||
})];
|
||||
case 3:
|
||||
_a.sent();
|
||||
_a.label = 4;
|
||||
case 4: return [3 /*break*/, 6];
|
||||
case 5:
|
||||
this.cleanOperation();
|
||||
this.unsetId();
|
||||
_a.label = 6;
|
||||
case 6:
|
||||
this.setState({
|
||||
mobileValueReady: mobileValueReady,
|
||||
mobileValue: value,
|
||||
});
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
onConfirm: 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*/, this.execute()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
this.setState({
|
||||
mobileValue: '',
|
||||
mobileValueReady: false,
|
||||
});
|
||||
this.unsetId();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
onReset: function () {
|
||||
this.cleanOperation();
|
||||
this.setState({
|
||||
mobileValue: '',
|
||||
mobileValueReady: false,
|
||||
});
|
||||
this.unsetId();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"navigationBarTitleText": "添加权限",
|
||||
"usingComponents": {
|
||||
"t-checkbox": "../../../miniprogram_npm/tdesign/checkbox/checkbox",
|
||||
"t-checkbox-group": "../../../miniprogram_npm/tdesign/checkbox-group/checkbox-group",
|
||||
"t-input": "../../../miniprogram_npm/tdesign/input/input",
|
||||
"t-tag": "../../../miniprogram_npm/tdesign/tag/tag",
|
||||
"t-icon": "../../../miniprogram_npm/tdesign/icon/icon",
|
||||
"t-button": "../../../miniprogram_npm/tdesign/button/button"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export default function render(this: any): JSX.Element;
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
"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");
|
||||
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;
|
||||
return ((0, jsx_runtime_1.jsxs)("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, 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" }))] }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u624B\u673A\u53F7\u7801", name: "mobile", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '手机号不能为空',
|
||||
},
|
||||
{
|
||||
min: 11,
|
||||
message: '请输入11位手机号',
|
||||
},
|
||||
{
|
||||
max: 11,
|
||||
message: '请输入11位手机号',
|
||||
},
|
||||
] }, { 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 }))] })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
/// <reference types="react" />
|
||||
declare const _default: import("react").ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
exports.default = OakComponent({
|
||||
isList: false,
|
||||
formData: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var legal, err_1;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
legal = false;
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, this.tryExecute()];
|
||||
case 2:
|
||||
legal = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_1 = _a.sent();
|
||||
legal = false;
|
||||
return [3 /*break*/, 4];
|
||||
case 4: return [2 /*return*/, {
|
||||
legal: legal,
|
||||
}];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
onConfirm: 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*/, this.execute()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
this.navigateBack();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
onReset: function () {
|
||||
this.cleanOperation();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"navigationBarTitleText": "添加权限",
|
||||
"usingComponents": {
|
||||
"t-checkbox": "../../../miniprogram_npm/tdesign/checkbox/checkbox",
|
||||
"t-checkbox-group": "../../../miniprogram_npm/tdesign/checkbox-group/checkbox-group",
|
||||
"t-input": "../../../miniprogram_npm/tdesign/input/input",
|
||||
"t-tag": "../../../miniprogram_npm/tdesign/tag/tag",
|
||||
"t-icon": "../../../miniprogram_npm/tdesign/icon/icon",
|
||||
"t-button": "../../../miniprogram_npm/tdesign/button/button"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export default function render(this: any): JSX.Element;
|
||||
|
|
@ -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");
|
||||
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;
|
||||
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 () {
|
||||
_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 })] })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
/// <reference types="react" />
|
||||
declare const _default: import("react").ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var types_1 = require("oak-domain/lib/types");
|
||||
exports.default = OakComponent({
|
||||
entity: 'userEntityGrant',
|
||||
projection: {
|
||||
id: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
relation: 1,
|
||||
type: 1,
|
||||
remark: 1,
|
||||
granterId: 1,
|
||||
granteeId: 1,
|
||||
},
|
||||
isList: false,
|
||||
formData: function (_a) {
|
||||
var userEntityGrant = _a.data;
|
||||
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
return [2 /*return*/, (tslib_1.__assign({}, userEntityGrant))];
|
||||
});
|
||||
});
|
||||
},
|
||||
properties: {
|
||||
entity: String,
|
||||
entityId: String,
|
||||
relations: Array,
|
||||
type: String,
|
||||
},
|
||||
data: {},
|
||||
lifetimes: {
|
||||
ready: function () {
|
||||
this.setUpdateData('entity', this.props.entity);
|
||||
this.setUpdateData('entityId', this.props.entityId);
|
||||
// 默认type为授权
|
||||
this.setUpdateData('type', this.props.type || 'grant');
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
bindRadioChange: function (input) {
|
||||
var value = this.resolveInput(input).value;
|
||||
this.setRadioValue(value);
|
||||
},
|
||||
setRadioValue: function (value) {
|
||||
this.setUpdateData('relation', value);
|
||||
},
|
||||
reset: function () {
|
||||
this.cleanOperation();
|
||||
},
|
||||
confirm: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var _a, operation, id, data, error_1, data;
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_b.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, this.execute()];
|
||||
case 1:
|
||||
_a = tslib_1.__read.apply(void 0, [_b.sent(), 1]), operation = _a[0];
|
||||
id = this.props.oakId;
|
||||
if (!id) {
|
||||
data = operation.data;
|
||||
id = data.id;
|
||||
}
|
||||
this.navigateTo({
|
||||
url: '/userEntityGrant/detail',
|
||||
oakId: id,
|
||||
});
|
||||
return [3 /*break*/, 3];
|
||||
case 2:
|
||||
error_1 = _b.sent();
|
||||
if (error_1.constructor.name ===
|
||||
types_1.OakCongruentRowExists.name) {
|
||||
data = error_1.getData();
|
||||
this.redirectTo({
|
||||
url: '/userEntityGrant/detail',
|
||||
oakId: data.id,
|
||||
});
|
||||
}
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"navigationBarTitleText": "授予权限",
|
||||
"usingComponents": {
|
||||
"t-button": "../../../miniprogram_npm/tdesign/button/button",
|
||||
"t-radio": "../../../miniprogram_npm/tdesign/radio/radio",
|
||||
"t-radio-group": "../../../miniprogram_npm/tdesign/radio-group/radio-group"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export default function render(this: any): JSX.Element;
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var jsx_runtime_1 = require("react/jsx-runtime");
|
||||
var tdesign_react_1 = require("tdesign-react");
|
||||
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
var FormItem = tdesign_react_1.Form.FormItem;
|
||||
function render() {
|
||||
var _this = this;
|
||||
var relation = this.state.relation;
|
||||
var _a = this.props, relations = _a.relations, entity = _a.entity, entityId = _a.entityId;
|
||||
var relationArr = typeof relations === 'object'
|
||||
? relations
|
||||
: relations && JSON.parse(relations);
|
||||
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.pageWithPadding }, { children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.formContainer }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Form, { children: [(0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u6743\u9650", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择一个权限',
|
||||
type: 'error',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Radio.Group, { value: relation, onChange: function (value) {
|
||||
_this.setRadioValue(value);
|
||||
}, options: relationArr.map(function (ele) { return ({
|
||||
value: ele,
|
||||
label: (_this.t && _this.t(entity + ':r.' + ele)) || ele,
|
||||
}); }) }) })), (0, jsx_runtime_1.jsxs)(FormItem, tslib_1.__assign({ style: { marginLeft: 100 } }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ type: "submit", theme: "primary", style: { marginRight: 10 }, onClick: function () {
|
||||
_this.confirm();
|
||||
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ type: "reset", theme: "default", onClick: function () {
|
||||
_this.reset();
|
||||
} }, { children: "\u91CD\u7F6E" }))] }))] }) })) })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
declare const _default: any;
|
||||
/// <reference types="react" />
|
||||
declare const _default: import("react").ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -1,127 +1,61 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var string_1 = require("oak-domain/lib/utils/string");
|
||||
exports.default = OakPage({
|
||||
entity: 'user',
|
||||
projection: function (_a) {
|
||||
var props = _a.props;
|
||||
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
||||
var entity, entityId, entityStr;
|
||||
var _b, _c;
|
||||
return tslib_1.__generator(this, function (_d) {
|
||||
entity = props.entity, entityId = props.entityId;
|
||||
entityStr = (0, string_1.firstLetterUpperCase)(entity);
|
||||
return [2 /*return*/, (_b = {
|
||||
id: 1,
|
||||
name: 1,
|
||||
password: 1,
|
||||
mobile$user: {
|
||||
$entity: 'mobile',
|
||||
data: {
|
||||
id: 1,
|
||||
userId: 1,
|
||||
mobile: 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),
|
||||
},
|
||||
_b)];
|
||||
});
|
||||
});
|
||||
},
|
||||
var assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
exports.default = OakComponent({
|
||||
isList: false,
|
||||
formData: function (_a) {
|
||||
var user = _a.data, props = _a.props;
|
||||
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
||||
var entity, relations, _b, id, name, mobile$user, password, mobile;
|
||||
var _c;
|
||||
return tslib_1.__generator(this, function (_d) {
|
||||
entity = props.entity, relations = props.relations;
|
||||
_b = user || {}, id = _b.id, name = _b.name, mobile$user = _b.mobile$user, password = _b.password;
|
||||
mobile = mobile$user && ((_c = mobile$user[0]) === null || _c === void 0 ? void 0 : _c.mobile);
|
||||
return [2 /*return*/, {
|
||||
id: id,
|
||||
name: name,
|
||||
mobile: mobile,
|
||||
password: password,
|
||||
}];
|
||||
});
|
||||
});
|
||||
data: {
|
||||
grantByUserEntityGrant: false,
|
||||
grantByEmail: false,
|
||||
grantByMobile: false,
|
||||
grantMethodCount: 0,
|
||||
},
|
||||
properties: {
|
||||
entity: String,
|
||||
entityId: String,
|
||||
relations: Array,
|
||||
},
|
||||
data: {
|
||||
mobile: '',
|
||||
relationArr: [],
|
||||
},
|
||||
methods: {
|
||||
onLoad: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
if (!this.props.oakId) {
|
||||
this.setUpdateData('password', '12345678');
|
||||
}
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
},
|
||||
setValue: function (input) {
|
||||
var _a = this.resolveInput(input), dataset = _a.dataset, value = _a.value, Context = _a.Context;
|
||||
this.setUpdateData(dataset.attr, value);
|
||||
},
|
||||
onMobileChange: function (event) {
|
||||
var value = event.detail.value;
|
||||
this.setState({
|
||||
mobile: value,
|
||||
});
|
||||
this.setUpdateData('mobile$user.0.mobile', value);
|
||||
},
|
||||
onCheckBoxChange: function (event) {
|
||||
var value = event.detail.value;
|
||||
this.setRelationValue(value);
|
||||
},
|
||||
setRelationValue: function (value) {
|
||||
var _this = this;
|
||||
var _a = this.props, entity = _a.entity, entityId = _a.entityId, relations = _a.relations;
|
||||
var entityStr = (0, string_1.firstLetterUpperCase)(entity);
|
||||
var relationArr = this.state.relationArr;
|
||||
// 由于是根据index 进行删除, 所以将之前设置的node从头开始删除
|
||||
relationArr.forEach(function (ele, index) {
|
||||
_this.removeNode("user".concat(entityStr, "$user"), '0');
|
||||
});
|
||||
value.forEach(function (ele, index) {
|
||||
_this.setUpdateData("user".concat(entityStr, "$user.").concat(index, ".").concat(entity, "Id"), entityId);
|
||||
_this.setUpdateData("user".concat(entityStr, "$user.").concat(index, ".relation"), ele);
|
||||
});
|
||||
this.setState({
|
||||
relationArr: value,
|
||||
});
|
||||
},
|
||||
onConfirm: function () {
|
||||
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.execute('create')];
|
||||
case 0: return [4 /*yield*/, this.features.application.getApplication()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
this.navigateBack();
|
||||
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*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
/// <reference types="react" />
|
||||
declare const _default: import("react").ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
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 props = _a.props;
|
||||
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
||||
var entity, entityId, entityStr;
|
||||
var _b, _c, _d;
|
||||
return tslib_1.__generator(this, function (_e) {
|
||||
entity = props.entity, entityId = props.entityId;
|
||||
entityStr = (0, string_1.firstLetterUpperCase)(entity);
|
||||
return [2 /*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)];
|
||||
});
|
||||
});
|
||||
},
|
||||
isList: false,
|
||||
formData: function (_a) {
|
||||
var user = _a.data, props = _a.props;
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var entity, entityId, entityStr, _b, name, nickname, password, userRelations;
|
||||
return tslib_1.__generator(this, function (_c) {
|
||||
entity = props.entity, entityId = props.entityId;
|
||||
entityStr = (0, string_1.firstLetterUpperCase)(entity);
|
||||
_b = user || {}, name = _b.name, nickname = _b.nickname, password = _b.password;
|
||||
userRelations = user && user["user".concat(entityStr, "$user")];
|
||||
return [2 /*return*/, {
|
||||
password: password,
|
||||
userRelations: userRelations,
|
||||
name: name,
|
||||
nickname: nickname,
|
||||
}];
|
||||
});
|
||||
});
|
||||
},
|
||||
properties: {
|
||||
entity: String,
|
||||
entityId: String,
|
||||
relations: Array,
|
||||
},
|
||||
lifetimes: {
|
||||
ready: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var _a, entity, entityId, entityStr, _b;
|
||||
var _c, _d;
|
||||
var _this = this;
|
||||
return tslib_1.__generator(this, function (_e) {
|
||||
switch (_e.label) {
|
||||
case 0:
|
||||
_a = this.props, entity = _a.entity, entityId = _a.entityId;
|
||||
entityStr = (0, string_1.firstLetterUpperCase)(entity);
|
||||
if (!!this.props.oakId) return [3 /*break*/, 3];
|
||||
_b = this.addOperation;
|
||||
_c = {
|
||||
action: 'create'
|
||||
};
|
||||
_d = {};
|
||||
return [4 /*yield*/, generateNewId()];
|
||||
case 1: return [4 /*yield*/, _b.apply(this, [(_c.data = (_d.id = _e.sent(),
|
||||
_d.password = '12345678',
|
||||
_d),
|
||||
_c), function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||
var operations, _a, operation;
|
||||
var _b;
|
||||
return tslib_1.__generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4 /*yield*/, this.getOperations()];
|
||||
case 1:
|
||||
operations = _c.sent();
|
||||
_a = tslib_1.__read(operations, 1), operation = _a[0];
|
||||
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")], '需要至少选择一个权限');
|
||||
}
|
||||
});
|
||||
}); }])];
|
||||
case 2:
|
||||
_e.sent();
|
||||
return [3 /*break*/, 5];
|
||||
case 3: return [4 /*yield*/, this.addOperation({
|
||||
action: 'update',
|
||||
data: {}
|
||||
}, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||
var operations, _a, operation;
|
||||
var _b;
|
||||
return tslib_1.__generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4 /*yield*/, this.getOperations()];
|
||||
case 1:
|
||||
operations = _c.sent();
|
||||
_a = tslib_1.__read(operations, 1), operation = _a[0];
|
||||
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")], '需要至少选择一个权限');
|
||||
}
|
||||
});
|
||||
}); })];
|
||||
case 4:
|
||||
_e.sent();
|
||||
_e.label = 5;
|
||||
case 5: 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, _b, _c;
|
||||
var _d, _e, _f, _g, _h;
|
||||
return tslib_1.__generator(this, function (_j) {
|
||||
switch (_j.label) {
|
||||
case 0:
|
||||
_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)) return [3 /*break*/, 1];
|
||||
(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);
|
||||
this.addOperation({
|
||||
action: oakId ? 'update' : 'create',
|
||||
data: (_d = {},
|
||||
_d["user".concat(entityStr, "$user")] = [{
|
||||
action: 'remove',
|
||||
data: {},
|
||||
filter: {
|
||||
id: toBeRemoved.id,
|
||||
},
|
||||
}],
|
||||
_d),
|
||||
});
|
||||
return [3 /*break*/, 3];
|
||||
case 1:
|
||||
// 增加一个relation
|
||||
(0, assert_1.default)(userRelations.length === value.length - 1);
|
||||
toBeInserted = value.find(function (ele) { return !userRelations.find(function (userRelation) { return userRelation.relation === ele; }); });
|
||||
_b = this.addOperation;
|
||||
_e = {
|
||||
action: oakId ? 'update' : 'create'
|
||||
};
|
||||
_f = {};
|
||||
_c = "user".concat(entityStr, "$user");
|
||||
_g = {
|
||||
action: 'create'
|
||||
};
|
||||
_h = {};
|
||||
return [4 /*yield*/, generateNewId()];
|
||||
case 2:
|
||||
_b.apply(this, [(_e.data = (_f[_c] = [(_g.data = (_h.id = _j.sent(),
|
||||
_h["".concat(entity, "Id")] = entityId,
|
||||
_h.relation = toBeInserted,
|
||||
_h),
|
||||
_g)],
|
||||
_f),
|
||||
_e)]);
|
||||
_j.label = 3;
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
onConfirm: 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*/, this.execute()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"navigationBarTitleText": "添加权限",
|
||||
"usingComponents": {
|
||||
"t-checkbox": "../../../miniprogram_npm/tdesign/checkbox/checkbox",
|
||||
"t-checkbox-group": "../../../miniprogram_npm/tdesign/checkbox-group/checkbox-group",
|
||||
"t-input": "../../../miniprogram_npm/tdesign/input/input",
|
||||
"t-tag": "../../../miniprogram_npm/tdesign/tag/tag",
|
||||
"t-icon": "../../../miniprogram_npm/tdesign/icon/icon",
|
||||
"t-button": "../../../miniprogram_npm/tdesign/button/button"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export default function render(this: any): JSX.Element;
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
"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");
|
||||
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
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, mobile = _b.mobile, password = _b.password, userRelations = _b.userRelations, mobileValue = _b.mobileValue, mobileValueReady = _b.mobileValueReady;
|
||||
var relationArr2 = typeof relations === 'object'
|
||||
? relations
|
||||
: relations && JSON.parse(relations);
|
||||
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, tslib_1.__assign({ label: "\u624B\u673A\u53F7\u7801", name: "mobile", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '手机号不能为空',
|
||||
},
|
||||
{
|
||||
min: 11,
|
||||
message: '请输入11位手机号',
|
||||
},
|
||||
{
|
||||
max: 11,
|
||||
message: '请输入11位手机号',
|
||||
},
|
||||
] }, { 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) {
|
||||
var strValue = e.target.value;
|
||||
_this.onMobileChange(strValue);
|
||||
}, placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u7801", type: "tel" }) }) })), mobileValueReady && !oakId && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u59D3\u540D", name: "name", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '姓名不能为空',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { onChange: function (e) {
|
||||
_this.setUpdateData('name', e.target.value);
|
||||
}, value: name, placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D" }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u5BC6\u7801", name: "mobile", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '密码不能为空',
|
||||
},
|
||||
] }, { 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);
|
||||
}, placeholder: "\u4E0D\u5C11\u4E8E\u516B\u4F4D" }) }) }))] })), mobileValueReady && (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6743\u9650", 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: relations, onChange: function (value) {
|
||||
_this.setRelationValue(value);
|
||||
}, options: relationArr2.map(function (ele) { return ({
|
||||
value: ele,
|
||||
label: (_this.t && _this.t(entity + ':r.' + ele)) ||
|
||||
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 () {
|
||||
_this.onConfirm();
|
||||
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ htmlType: "reset" }, { children: "\u91CD\u7F6E" }))] }) }))] })) })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
@ -0,0 +1 @@
|
|||
export default function render(this: any): JSX.Element;
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
"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");
|
||||
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
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: [
|
||||
{
|
||||
required: true,
|
||||
message: '姓名不能为空',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { 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*/];
|
||||
});
|
||||
}); }, 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)(antd_1.Input, { disabled: true, value: nickname }) }) })) : (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u5BC6\u7801", name: "mobile", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '密码不能为空',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { 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*/];
|
||||
});
|
||||
}); }, placeholder: "\u4E0D\u5C11\u4E8E\u516B\u4F4D" }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6743\u9650", 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,
|
||||
}); }) }) }) }))] })) })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -2,62 +2,58 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var jsx_runtime_1 = require("react/jsx-runtime");
|
||||
var tdesign_react_1 = require("tdesign-react");
|
||||
var FormItem = tdesign_react_1.Form.FormItem;
|
||||
var mobile_module_less_1 = tslib_1.__importDefault(require("./mobile.module.less"));
|
||||
var antd_1 = require("antd");
|
||||
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
function render() {
|
||||
var _this = this;
|
||||
var t = this.t;
|
||||
var _a = this.props, relations = _a.relations, entity = _a.entity;
|
||||
var _b = this.state, name = _b.name, mobile = _b.mobile, password = _b.password, relationArr = _b.relationArr;
|
||||
var relations2 = typeof relations === 'object'
|
||||
var relationArr2 = typeof relations === 'object'
|
||||
? relations
|
||||
: 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.jsx)(tdesign_react_1.Row, tslib_1.__assign({ gutter: 16 }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Col, tslib_1.__assign({ xs: 12, sm: 4 }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Form, tslib_1.__assign({ colon: false, labelAlign: "right", labelWidth: "100px", layout: "vertical", preventSubmitDefault: true, resetType: "empty", showErrorMessage: true, submitWithWarningMessage: false }, { children: [(0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u59D3\u540D", name: "name", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '姓名不能为空',
|
||||
type: 'error',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { onChange: function (value, context) {
|
||||
_this.setUpdateData('name', value);
|
||||
}, value: name, align: "left", placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9", type: "text" }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u624B\u673A\u53F7\u7801", name: "mobile", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '手机号不能为空',
|
||||
type: 'error',
|
||||
},
|
||||
{
|
||||
min: 11,
|
||||
message: '请输入11位手机号',
|
||||
type: 'error',
|
||||
},
|
||||
{
|
||||
max: 11,
|
||||
message: '请输入11位手机号',
|
||||
type: 'error',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { onChange: function (value, context) {
|
||||
_this.setUpdateData('mobile$user.0.mobile', value);
|
||||
}, value: mobile, align: "left", placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9", size: "medium", type: "text" }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ initialData: "123456", label: "\u5BC6\u7801", name: "mobile", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '密码不能为空',
|
||||
type: 'error',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { value: password, align: "left", placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9", showClearIconOnEmpty: false, size: "medium", status: "default", type: "text" }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u6743\u9650", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请至少选择一个权限',
|
||||
type: 'error',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Checkbox.Group, { value: relationArr, onChange: function (value) {
|
||||
_this.setRelationValue(value);
|
||||
}, options: relations2.map(function (ele) { return ({
|
||||
value: ele,
|
||||
label: t(entity + ':r.' + ele),
|
||||
}); }) }) })), (0, jsx_runtime_1.jsxs)(FormItem, tslib_1.__assign({ style: { marginLeft: 100 } }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", type: "submit", style: { marginRight: 10 }, onClick: function () {
|
||||
_this.onConfirm();
|
||||
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ type: "reset" }, { children: "\u91CD\u7F6E" }))] }))] })) })) })) })));
|
||||
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, tslib_1.__assign({ label: "\u59D3\u540D", name: "name", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '姓名不能为空',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { onChange: function (e) {
|
||||
_this.setUpdateData('name', e.target.value);
|
||||
}, 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: [
|
||||
{
|
||||
required: true,
|
||||
message: '手机号不能为空',
|
||||
},
|
||||
{
|
||||
min: 11,
|
||||
message: '请输入11位手机号',
|
||||
},
|
||||
{
|
||||
max: 11,
|
||||
message: '请输入11位手机号',
|
||||
},
|
||||
] }, { 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) {
|
||||
var strValue = e.target.value;
|
||||
_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: [
|
||||
{
|
||||
required: true,
|
||||
message: '密码不能为空',
|
||||
},
|
||||
] }, { 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);
|
||||
}, placeholder: "\u4E0D\u5C11\u4E8E\u516B\u4F4D" }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6743\u9650", 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: relationArr, onChange: function (value) {
|
||||
_this.setRelationValue(value);
|
||||
}, options: relationArr2.map(function (ele) { return ({
|
||||
value: ele,
|
||||
label: (_this.t && _this.t(entity + ':r.' + ele)) ||
|
||||
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 () {
|
||||
_this.onConfirm();
|
||||
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ htmlType: "reset" }, { children: "\u91CD\u7F6E" }))] }) }))] })) })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -2,67 +2,55 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var jsx_runtime_1 = require("react/jsx-runtime");
|
||||
var tdesign_react_1 = require("tdesign-react");
|
||||
var antd_1 = require("antd");
|
||||
var pageHeader_1 = tslib_1.__importDefault(require("../../../components/common/pageHeader"));
|
||||
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
var FormItem = tdesign_react_1.Form.FormItem;
|
||||
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 _this = this;
|
||||
var _a = this.props, relations = _a.relations, entity = _a.entity;
|
||||
var _b = this.state, name = _b.name, mobile = _b.mobile, password = _b.password, relationArr = _b.relationArr;
|
||||
var relationArr2 = typeof relations === 'object'
|
||||
? relations
|
||||
: relations && JSON.parse(relations);
|
||||
return ((0, jsx_runtime_1.jsx)(pageHeader_1.default, tslib_1.__assign({ showBack: true, title: "\u6DFB\u52A0\u6743\u9650" }, { children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.formContainer }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Row, tslib_1.__assign({ gutter: 16 }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Col, tslib_1.__assign({ span: 8 }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Form, tslib_1.__assign({ colon: false, labelAlign: "right", labelWidth: "100px", layout: "vertical", preventSubmitDefault: true, resetType: "empty", showErrorMessage: true, submitWithWarningMessage: false }, { children: [(0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u59D3\u540D", name: "name", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '姓名不能为空',
|
||||
type: 'error',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { onChange: function (value, context) {
|
||||
_this.setUpdateData('name', value);
|
||||
}, value: name, align: "left", placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9", type: "text" }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u624B\u673A\u53F7\u7801", name: "mobile", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '手机号不能为空',
|
||||
type: 'error',
|
||||
},
|
||||
{
|
||||
min: 11,
|
||||
message: '请输入11位手机号',
|
||||
type: 'error',
|
||||
},
|
||||
{
|
||||
max: 11,
|
||||
message: '请输入11位手机号',
|
||||
type: 'error',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { maxlength: 11, value: mobile, onChange: function (value, context) {
|
||||
var strValue = String(value);
|
||||
_this.setUpdateData('mobile$user.0.mobile', strValue.replace(/[^\d\-\d]/g, ''));
|
||||
}, align: "left", placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9", size: "medium", type: "tel" }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ initialData: "12345678", label: "\u5BC6\u7801", name: "mobile", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '密码不能为空',
|
||||
type: 'error',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { value: password, onChange: function (value) {
|
||||
_this.setUpdateData('password', value);
|
||||
}, align: "left", placeholder: "\u4E0D\u5C11\u4E8E\u516B\u4F4D", showClearIconOnEmpty: false, size: "medium", status: "default", type: "text" }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u6743\u9650", rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请至少选择一个权限',
|
||||
type: 'error',
|
||||
},
|
||||
] }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Checkbox.Group, { value: relationArr, onChange: function (value) {
|
||||
_this.setRelationValue(value);
|
||||
}, options: relationArr2.map(function (ele) { return ({
|
||||
value: ele,
|
||||
label: (_this.t &&
|
||||
_this.t(entity + ':r.' + ele)) ||
|
||||
ele,
|
||||
}); }) }) })), (0, jsx_runtime_1.jsxs)(FormItem, tslib_1.__assign({ style: { marginLeft: 100 } }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", type: "submit", style: { marginRight: 10 }, onClick: function () {
|
||||
_this.onConfirm();
|
||||
} }, { children: "\u63D0\u4EA4" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "default", type: "reset" }, { children: "\u91CD\u7F6E" }))] }))] })) })) })) })) })) })));
|
||||
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;
|
||||
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" })));
|
||||
}
|
||||
else if (grantMethodCount === 1) {
|
||||
if (grantByEmail) {
|
||||
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: "$userRelationUpsert/upsert-byMobile", 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: "$userRelationUpsert/upsert-byUserEntityGrant", oakAutoUnmount: true }));
|
||||
}
|
||||
}
|
||||
else {
|
||||
var items = [
|
||||
{
|
||||
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-3', children: ((0, jsx_runtime_1.jsx)(byUserEntityGrant_1.default, { entity: entity, entityId: entityId, relations: relations, oakPath: "$userRelationUpsert/upsert-byUserEntityGrant", oakAutoUnmount: true }))
|
||||
},
|
||||
];
|
||||
var items2 = [];
|
||||
if (grantByEmail) {
|
||||
items2.push(items[0]);
|
||||
}
|
||||
if (grantByMobile) {
|
||||
items2.push(items[1]);
|
||||
}
|
||||
if (grantByUserEntityGrant) {
|
||||
items2.push(items[2]);
|
||||
}
|
||||
SubPart = ((0, jsx_runtime_1.jsx)(antd_1.Tabs, { items: items2 }));
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)(pageHeader_1.default, tslib_1.__assign({ showBack: true, title: "\u6DFB\u52A0\u6743\u9650" }, { children: SubPart })));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -385,13 +385,17 @@ export async function loginWechat<ED extends EntityDict, Cxt extends RuntimeCont
|
|||
|
||||
// 可能type是web或者wechatPublic
|
||||
assert(type !== 'wechatMp' && config.type !== 'wechatMp');
|
||||
let config2;
|
||||
let appId: string, appSecret: string;
|
||||
if (type === 'wechatPublic') {
|
||||
config2 = config as WechatPublicConfig;
|
||||
const config2 = config as WechatPublicConfig;
|
||||
appId = config2.appId;
|
||||
appSecret = config2.appSecret;
|
||||
} else {
|
||||
config2 = config as WebConfig;
|
||||
const config2 = config as WebConfig;
|
||||
assert(config2.wechat);
|
||||
appId = config2.wechat.appId;
|
||||
appSecret = config2.wechat.appSecret;
|
||||
}
|
||||
const { appId, appSecret } = config2;
|
||||
const wechatInstance = WechatSDK.getInstance(appId!, appSecret!, type);
|
||||
|
||||
const { sessionKey, openId, unionId } = await wechatInstance.code2Session(code);
|
||||
|
|
|
|||
|
|
@ -15,17 +15,17 @@ const checkers: Checker<EntityDict, 'address', RuntimeContext<EntityDict>> [] =
|
|||
data.forEach(
|
||||
ele => {
|
||||
const a: Exclude<keyof EntityDict['address']['OpSchema'], 'aa'> = 'name';
|
||||
checkAttributesNotNull(ele, ['name', 'detail', 'phone', 'areaId']);
|
||||
checkAttributesNotNull('address', ele, ['name', 'detail', 'phone', 'areaId']);
|
||||
if (!isMobile(ele.phone)) {
|
||||
throw new OakInputIllegalException(['phone'], '手机号非法');
|
||||
throw new OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
checkAttributesNotNull(data, ['name', 'detail', 'phone', 'areaId']);
|
||||
checkAttributesNotNull('address', data, ['name', 'detail', 'phone', 'areaId']);
|
||||
if (!isMobile(data.phone)) {
|
||||
throw new OakInputIllegalException(['phone'], '手机号非法');
|
||||
throw new OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ const checkers: Checker<EntityDict, 'user', RuntimeContext<EntityDict>> [] = [
|
|||
checker: async({ operation }) => {
|
||||
const { data } = operation;
|
||||
if (Object.keys(data).filter(ele => !ele.includes('$')).length > 0) {
|
||||
throw new OakInputIllegalException(Object.keys(data), '授权不允许传入其它属性');
|
||||
throw new OakInputIllegalException('user', Object.keys(data), '授权不允许传入其它属性');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ const checkers: Checker<
|
|||
if (data instanceof Array) {
|
||||
data.forEach(
|
||||
ele => {
|
||||
checkAttributesNotNull(ele, ['type', 'entity', 'entityId', 'relation']);
|
||||
checkAttributesNotNull('userEntityGrant', ele, ['type', 'entity', 'entityId', 'relation']);
|
||||
if (!ele.hasOwnProperty('number') || ele.type === 'transfer') {
|
||||
Object.assign(ele, {
|
||||
number: 1,
|
||||
|
|
@ -27,7 +27,7 @@ const checkers: Checker<
|
|||
}
|
||||
else {
|
||||
if (ele.number <= 0 ) {
|
||||
throw new OakInputIllegalException(['number', '分享的权限数量必须大于0']);
|
||||
throw new OakInputIllegalException('userEntityGrant', ['number', '分享的权限数量必须大于0']);
|
||||
}
|
||||
}
|
||||
Object.assign(ele, {
|
||||
|
|
@ -37,7 +37,7 @@ const checkers: Checker<
|
|||
);
|
||||
}
|
||||
else {
|
||||
checkAttributesNotNull(data, ['type', 'entity', 'entityId', 'relation']);
|
||||
checkAttributesNotNull('userEntityGrant', data, ['type', 'entity', 'entityId', 'relation']);
|
||||
if (!data.hasOwnProperty('number') || data.type === 'transfer') {
|
||||
Object.assign(data, {
|
||||
number: 1,
|
||||
|
|
@ -45,7 +45,7 @@ const checkers: Checker<
|
|||
}
|
||||
else {
|
||||
if (data.number <= 0 ) {
|
||||
throw new OakInputIllegalException(['number', '分享的权限数量必须大于0']);
|
||||
throw new OakInputIllegalException('userEntityGrant', ['number', '分享的权限数量必须大于0']);
|
||||
}
|
||||
}
|
||||
Object.assign(data, {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export const applications: Application[] = [
|
|||
systemId: DEV_SYSTEM_ID,
|
||||
config: {
|
||||
type: 'web',
|
||||
passport: ['email', 'mobile', 'wechat'],
|
||||
},
|
||||
description: 'web应用,指向dev_system',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { EntityShape } from 'oak-domain/lib/types/Entity';
|
|||
import { Schema as System } from './System';
|
||||
import { LocaleDef } from 'oak-domain/lib/types/Locale';
|
||||
|
||||
type Passport = 'email' | 'mobile' | 'wechat';
|
||||
export type AppType = 'web' | 'wechatMp' | 'wechatPublic';
|
||||
export type WechatMpConfig = {
|
||||
type: 'wechatMp';
|
||||
|
|
@ -13,8 +14,11 @@ export type WechatMpConfig = {
|
|||
|
||||
export type WebConfig = {
|
||||
type: 'web';
|
||||
appId?: string;
|
||||
appSecret?: string; //网站 微信扫码登录
|
||||
wechat?: {
|
||||
appId: string;
|
||||
appSecret: string; //网站 微信扫码登录
|
||||
};
|
||||
passport: Passport[];
|
||||
};
|
||||
|
||||
type WechatPublicTemplateMsgsConfig = Record<string, {
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
/** index.wxss **/
|
||||
@import "../../../config/styles/mp/index.less";
|
||||
@import "../../../config/styles/mp/mixins.less";
|
||||
|
||||
page {
|
||||
height: 100%;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.page-body {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
align-items: stretch;
|
||||
padding: 0;
|
||||
.safe-area-inset-bottom();
|
||||
}
|
||||
|
||||
.cell {
|
||||
&::after {
|
||||
border-bottom: none !important;
|
||||
border-bottom-width: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
.description {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.col {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: @font-size-base;
|
||||
color: @text-level-2-color;
|
||||
}
|
||||
|
||||
.mobile {
|
||||
font-size: @font-size-base;
|
||||
color: @text-level-2-color;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
height: 160rpx;
|
||||
width: 160rpx;
|
||||
}
|
||||
|
||||
.relation {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
import { firstLetterUpperCase } from "oak-domain/lib/utils/string";
|
||||
import { composeFileUrl } from "../../../utils/extraFile";
|
||||
|
||||
export default OakComponent({
|
||||
entity: 'user',
|
||||
projection: async ({ props }) => {
|
||||
const { entity, entityId } = props;
|
||||
const entityStr = firstLetterUpperCase(entity!);
|
||||
return {
|
||||
id: 1,
|
||||
name: 1,
|
||||
nickname: 1,
|
||||
mobile$user: {
|
||||
$entity: 'mobile',
|
||||
data: {
|
||||
id: 1,
|
||||
userId: 1,
|
||||
mobile: 1,
|
||||
},
|
||||
},
|
||||
idState: 1,
|
||||
userState: 1,
|
||||
[`user${entityStr}$user`]: {
|
||||
$entity: `user${entityStr}`,
|
||||
data: {
|
||||
id: 1,
|
||||
userId: 1,
|
||||
[`${entity}Id`]: 1,
|
||||
relation: 1,
|
||||
},
|
||||
filter: {
|
||||
[`${entity}Id`]: entityId,
|
||||
},
|
||||
},
|
||||
extraFile$entity: {
|
||||
$entity: 'extraFile',
|
||||
data: {
|
||||
id: 1,
|
||||
tag1: 1,
|
||||
origin: 1,
|
||||
bucket: 1,
|
||||
objectId: 1,
|
||||
filename: 1,
|
||||
extra1: 1,
|
||||
type: 1,
|
||||
entity: 1,
|
||||
extension: 1,
|
||||
},
|
||||
filter: {
|
||||
tag1: 'avatar',
|
||||
},
|
||||
indexFrom: 0,
|
||||
count: 1,
|
||||
},
|
||||
};
|
||||
},
|
||||
isList: false,
|
||||
formData: async ({ data: user, props }) => {
|
||||
const { entity, relations } = props;
|
||||
const relations2 =
|
||||
typeof relations === 'object'
|
||||
? relations
|
||||
: relations && JSON.parse(relations);
|
||||
const entityStr = firstLetterUpperCase(entity!);
|
||||
const relationArr: Array<any> = [];
|
||||
const {
|
||||
id,
|
||||
nickname,
|
||||
idState,
|
||||
userState,
|
||||
name,
|
||||
mobile$user,
|
||||
extraFile$entity,
|
||||
} = user || {};
|
||||
let userRelations =
|
||||
user && (user[`user${entityStr}$user`] as Array<any>);
|
||||
userRelations = userRelations?.map((ele) => ele.relation);
|
||||
relations2?.forEach((ele) => {
|
||||
relationArr.push({
|
||||
checked: userRelations?.includes(ele),
|
||||
value: ele,
|
||||
});
|
||||
});
|
||||
const mobile = mobile$user && mobile$user[0]?.mobile;
|
||||
const avatar =
|
||||
extraFile$entity &&
|
||||
extraFile$entity[0] &&
|
||||
composeFileUrl(extraFile$entity[0]);
|
||||
return {
|
||||
id,
|
||||
nickname,
|
||||
name,
|
||||
mobile,
|
||||
avatar,
|
||||
userState,
|
||||
idState,
|
||||
relationArr,
|
||||
};
|
||||
},
|
||||
properties: {
|
||||
entity: String,
|
||||
entityId: String,
|
||||
relations: Array,
|
||||
},
|
||||
data: {
|
||||
stateColor: {
|
||||
shadow: 'primary',
|
||||
normal: 'success',
|
||||
disabled: '',
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onChange(event: any) {
|
||||
const { value } = event.currentTarget.dataset;
|
||||
const { checked } = event.detail;
|
||||
this.onChangeValue(value, checked);
|
||||
},
|
||||
onChangeValue(value: string, checked: boolean) {
|
||||
const { entity, entityId } = this.props;
|
||||
const entityStr = firstLetterUpperCase(entity!);
|
||||
const nodeData = {
|
||||
[`${entity}Id`]: entityId,
|
||||
relation: value,
|
||||
};
|
||||
this.toggleNode(nodeData, checked, `user${entityStr}$user`);
|
||||
},
|
||||
async onConfirm() {
|
||||
await this.execute('grant');
|
||||
await this.navigateBack();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<!-- index.wxml -->
|
||||
<view class="page-body">
|
||||
<t-cell title="{{nickname}}" t-class="cell">
|
||||
<t-image slot="left-icon" t-class="avatar" src="{{avatar}}" mode="aspectFit" shape="circle"></t-image>
|
||||
<view slot="description" class="description">
|
||||
<text class="name">姓名: {{name || '未设置'}}</text>
|
||||
<text class="mobile">手机: {{mobile || '未设置'}}</text>
|
||||
</view>
|
||||
</t-cell>
|
||||
<t-divider t-class-content="t-class-content">
|
||||
<text slot="content">权限设置</text>
|
||||
</t-divider>
|
||||
<block wx:for="{{relationArr}}">
|
||||
<t-checkbox data-value="{{item.value}}" checked="{{item.checked}}" label="{{t(entity + ':r.' + item.value)}}" bind:change="onChange" />
|
||||
</block>
|
||||
<view style="flex: 1"></view>
|
||||
<t-button theme="primary" bind:tap="onConfirm" block>保存</t-button>
|
||||
</view>
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
|
||||
|
||||
.container {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: var(--oak-bg-color-page);
|
||||
}
|
||||
|
||||
.avatar {
|
||||
height: 56px;
|
||||
width: 56px;
|
||||
background-color: var(--oak-brand-color-8);
|
||||
|
||||
.text {
|
||||
color: var(--oak-text-color-anti);
|
||||
font-size: var(--oak-font-size-title-medium);
|
||||
}
|
||||
}
|
||||
|
||||
.description {
|
||||
.row {
|
||||
.label {
|
||||
color: var(--oak-text-color-secondary);
|
||||
font-size: var(--oak-font-size-body-small);
|
||||
}
|
||||
|
||||
.value {
|
||||
color: var(--oak-text-color-primary);
|
||||
font-size: var(--oak-font-size-body-small);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.relationList {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
|
||||
|
||||
.container {
|
||||
background: var(--oak-bg-color-container);
|
||||
box-shadow: 0 2px 3px #0000001a;
|
||||
border-radius: 3px;
|
||||
padding: 30px 32px;
|
||||
}
|
||||
|
||||
|
||||
.avatar {
|
||||
height: 56px;
|
||||
width: 56px;
|
||||
background-color: var(--oak-brand-color-8);
|
||||
|
||||
.text {
|
||||
color: var(--oak-text-color-anti);
|
||||
font-size: var(--oak-font-size-title-medium);
|
||||
}
|
||||
}
|
||||
|
||||
.description {
|
||||
.row {
|
||||
.label {
|
||||
color: var(--oak-text-color-secondary);
|
||||
font-size: var(--oak-font-size-body-small);
|
||||
}
|
||||
|
||||
.value {
|
||||
color: var(--oak-text-color-primary);
|
||||
font-size: var(--oak-font-size-body-small);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
import React from 'react';
|
||||
import { List, Avatar, Checkbox, Button, Divider, Space } from 'tdesign-react';
|
||||
import PageHeader from '../../../components/common/pageHeader';
|
||||
import Style from './web.module.less';
|
||||
import { getName } from '../../../utils/randomUser';
|
||||
|
||||
const { ListItem, ListItemMeta } = List;
|
||||
|
||||
|
||||
export default function render(this: any) {
|
||||
const {t} = this;
|
||||
const { entity } = this.props;
|
||||
const { avatar, nickname, name, mobile, relationArr } = this.state;
|
||||
return (
|
||||
<PageHeader showBack={true} title="人员详情">
|
||||
<div className={Style.container}>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemMeta
|
||||
image={
|
||||
avatar ? (
|
||||
<Avatar
|
||||
className={Style.avatar}
|
||||
image={avatar}
|
||||
/>
|
||||
) : (
|
||||
<Avatar className={Style.avatar}>
|
||||
<span className={Style.text}>
|
||||
{getName(name)}
|
||||
</span>
|
||||
</Avatar>
|
||||
)
|
||||
}
|
||||
title={<div>{name || '--'}</div>}
|
||||
description={
|
||||
<div className={Style.description}>
|
||||
<div className={Style.row}>
|
||||
<span className={Style.label}>
|
||||
昵称:
|
||||
</span>
|
||||
<span className={Style.value}>
|
||||
{nickname || '--'}
|
||||
</span>
|
||||
</div>
|
||||
<div className={Style.row}>
|
||||
<span className={Style.label}>
|
||||
手机号:
|
||||
</span>
|
||||
<span className={Style.value}>
|
||||
{mobile || '--'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
></ListItemMeta>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Divider />
|
||||
<List className={Style.relationList}>
|
||||
{relationArr?.map((item: any, index: number) => (
|
||||
<ListItem key={index}>
|
||||
<Checkbox
|
||||
checked={item.checked}
|
||||
label={t(entity + ':r.' + item.value)}
|
||||
onChange={(checked) => {
|
||||
this.onChangeValue(item.value, checked);
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
<Divider />
|
||||
<Space style={{ marginLeft: 20 }}>
|
||||
<Button theme="primary" onClick={() => this.onConfirm()}>
|
||||
保存
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
theme="primary"
|
||||
onClick={() => this.navigateBack()}
|
||||
>
|
||||
返回
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</PageHeader>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
import React, { Component } from 'react';
|
||||
|
||||
import { List, Avatar, Checkbox, Button } from 'tdesign-react';
|
||||
const { ListItem, ListItemMeta } = List;
|
||||
|
||||
import Style from './mobile.module.less';
|
||||
import { getName } from '../../../utils/randomUser';
|
||||
|
||||
|
||||
export default function render(this: any) {
|
||||
const {t} = this;
|
||||
const { entity } = this.props;
|
||||
const { avatar, nickname, name, mobile, relationArr } = this.state;
|
||||
return (
|
||||
<div className={Style.container}>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemMeta
|
||||
image={
|
||||
avatar ? (
|
||||
<Avatar
|
||||
className={Style.avatar}
|
||||
image={avatar}
|
||||
/>
|
||||
) : (
|
||||
<Avatar className={Style.avatar}>
|
||||
<span className={Style.text}>
|
||||
{getName(name)}
|
||||
</span>
|
||||
</Avatar>
|
||||
)
|
||||
}
|
||||
title={<div>{name || '--'}</div>}
|
||||
description={
|
||||
<div className={Style.description}>
|
||||
<div className={Style.row}>
|
||||
<span className={Style.label}>
|
||||
昵称:
|
||||
</span>
|
||||
<span className={Style.value}>
|
||||
{nickname || '--'}
|
||||
</span>
|
||||
</div>
|
||||
<div className={Style.row}>
|
||||
<span className={Style.label}>
|
||||
手机号:
|
||||
</span>
|
||||
<span className={Style.value}>
|
||||
{mobile || '--'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
></ListItemMeta>
|
||||
</ListItem>
|
||||
</List>
|
||||
<List className={Style.relationList}>
|
||||
{relationArr?.map((item: any, index: number) => (
|
||||
<ListItem key={index}>
|
||||
<Checkbox
|
||||
checked={item.checked}
|
||||
label={t(entity + ':r.' + item.value)}
|
||||
onChange={(checked) => {
|
||||
this.onChangeValue(item.value, checked);
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
<div style={{ flex: 1 }}></div>
|
||||
<Button
|
||||
size="large"
|
||||
theme="primary"
|
||||
block
|
||||
onClick={() => this.onConfirm()}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import assert from 'assert';
|
||||
import { firstLetterUpperCase } from 'oak-domain/lib/utils/string';
|
||||
import { composeFileUrl } from '../../../utils/extraFile';
|
||||
import React from '../../../utils/react';
|
||||
|
|
@ -27,6 +28,9 @@ export default OakComponent({
|
|||
[`${entity}Id`]: 1,
|
||||
relation: 1,
|
||||
},
|
||||
filter: {
|
||||
[`${entity}Id`]: entityId,
|
||||
}
|
||||
},
|
||||
extraFile$entity: {
|
||||
$entity: 'extraFile',
|
||||
|
|
@ -110,18 +114,8 @@ export default OakComponent({
|
|||
relations: Array,
|
||||
},
|
||||
data: {
|
||||
show: false,
|
||||
searchValue: '',
|
||||
editableRowKeys: [] as string[],
|
||||
btnItems: [
|
||||
{
|
||||
label: '二维码授权',
|
||||
},
|
||||
{
|
||||
label: '添加授权',
|
||||
},
|
||||
],
|
||||
visible: false,
|
||||
idRemove: '',
|
||||
},
|
||||
lifetimes: {
|
||||
created() {
|
||||
|
|
@ -133,15 +127,6 @@ export default OakComponent({
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
onAdd() {
|
||||
if (process.env.OAK_PLATFORM === 'web') {
|
||||
this.goUpsert();
|
||||
} else {
|
||||
this.setState({
|
||||
visible: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
goUpsert() {
|
||||
const { entity, entityId, relations } = this.props;
|
||||
this.navigateTo(
|
||||
|
|
@ -155,52 +140,58 @@ export default OakComponent({
|
|||
}
|
||||
);
|
||||
},
|
||||
goUserEntityGrantWithGrant() {
|
||||
goUpdate(id: string) {
|
||||
const { entity, entityId, relations } = this.props;
|
||||
this.navigateTo(
|
||||
{
|
||||
url: '/userEntityGrant/grant',
|
||||
url: '/userRelation/upsert/byUser',
|
||||
entity,
|
||||
entityId,
|
||||
oakId: id,
|
||||
},
|
||||
{
|
||||
relations,
|
||||
}
|
||||
);
|
||||
},
|
||||
onActionSelect(e: any) {
|
||||
const { index, selected } = e.detail;
|
||||
switch (index) {
|
||||
case 0: {
|
||||
this.goUserEntityGrantWithGrant();
|
||||
}
|
||||
case 1: {
|
||||
this.goUpsert();
|
||||
}
|
||||
}
|
||||
},
|
||||
onActionCancel() {
|
||||
onDelete(id: string) {
|
||||
this.setState({
|
||||
visible: false,
|
||||
idRemove: id,
|
||||
});
|
||||
},
|
||||
onActionClose() {
|
||||
this.onActionCancel();
|
||||
},
|
||||
bindClicked(e: any) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
this.goDetail(id);
|
||||
},
|
||||
goDetail(id: string) {
|
||||
const { relations, entity, entityId } = this.props;
|
||||
this.navigateTo({
|
||||
url: '/userRelation/detail',
|
||||
oakId: id,
|
||||
relations,
|
||||
entity,
|
||||
entityId,
|
||||
async confirmDelete() {
|
||||
const { entity, entityId } = this.props;
|
||||
const entityStr = firstLetterUpperCase(entity!);
|
||||
const { idRemove, users } = this.state;
|
||||
const user = users.find(
|
||||
(ele: any) => ele.id === idRemove
|
||||
);
|
||||
const relations = user[`user${entityStr}$user`];
|
||||
await this.execute({
|
||||
action: 'update',
|
||||
data: {
|
||||
[`user${entityStr}$user`]: [
|
||||
{
|
||||
action: 'remove',
|
||||
data: {},
|
||||
filter: {
|
||||
id: {
|
||||
$in: relations.map((ele: any) => ele.id),
|
||||
},
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
filter: {
|
||||
id: idRemove,
|
||||
},
|
||||
});
|
||||
this.setState({
|
||||
idRemove: '',
|
||||
});
|
||||
},
|
||||
|
||||
// 这三个函数貌似还没用上
|
||||
async searchChange(event: any) {
|
||||
const { value } = this.resolveInput(event);
|
||||
this.addNamedFilter({
|
||||
|
|
@ -228,102 +219,5 @@ export default OakComponent({
|
|||
async searchConfirm() {
|
||||
this.refresh();
|
||||
},
|
||||
// web table methods
|
||||
onEdit(e: any) {
|
||||
const { editableRowKeys } = this.state;
|
||||
|
||||
const { id } = e.currentTarget.dataset;
|
||||
if (!editableRowKeys.includes(id)) {
|
||||
this.setState({
|
||||
editableRowKeys: editableRowKeys.concat(id),
|
||||
});
|
||||
}
|
||||
},
|
||||
updateEditRowKey(id: string) {
|
||||
const { editableRowKeys } = this.state;
|
||||
const index = editableRowKeys.findIndex((t) => t === id);
|
||||
editableRowKeys.splice(index, 1);
|
||||
this.setState({
|
||||
editableRowKeys: [...editableRowKeys],
|
||||
});
|
||||
},
|
||||
onSave(e: any) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
(this as any).currentSaveId = id;
|
||||
// 触发内部校验,而后在 onRowValidate 中接收异步校验结果
|
||||
(this as any).tableRef.current.validateRowData(id);
|
||||
},
|
||||
onCancel(e: any) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
this.updateEditRowKey(id);
|
||||
(this as any).tableRef.current.clearValidateData();
|
||||
},
|
||||
onRowValidate(params: any) {
|
||||
if (params.result.length) {
|
||||
const r = params.result[0];
|
||||
this.setMessage({
|
||||
type: 'error',
|
||||
content: `${r.col.title} ${r.errorList[0].message}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 如果是 table 的父组件主动触发校验
|
||||
if (params.trigger === 'parent' && !params.result.length) {
|
||||
const { users } = this.state;
|
||||
const { entity, entityId } = this.props;
|
||||
const entityStr = firstLetterUpperCase(entity!);
|
||||
|
||||
const current = (this as any).editMap[
|
||||
(this as any).currentSaveId
|
||||
];
|
||||
if (current) {
|
||||
Object.keys(current.editedRow).forEach((ele) => {
|
||||
if (ele === 'relations') {
|
||||
const userRelations =
|
||||
users[current.rowIndex].relations;
|
||||
userRelations.forEach((ele2: any) => {
|
||||
if (!current.editedRow[ele].includes(ele2)) {
|
||||
this.toggleNode(
|
||||
{
|
||||
relation: ele2,
|
||||
[`${entity}Id`]: entityId,
|
||||
},
|
||||
false,
|
||||
`${current.rowIndex}.user${entityStr}$user`
|
||||
);
|
||||
}
|
||||
});
|
||||
current.editedRow[ele].forEach((ele2: string) => {
|
||||
if (!userRelations.includes(ele2)) {
|
||||
this.toggleNode(
|
||||
{
|
||||
relation: ele2,
|
||||
[`${entity}Id`]: entityId,
|
||||
},
|
||||
true,
|
||||
`${current.rowIndex}.user${entityStr}$user`
|
||||
);
|
||||
}
|
||||
});
|
||||
this.execute('grant');
|
||||
} else {
|
||||
this.setUpdateData(
|
||||
`${0}.${ele}`,
|
||||
current.editedRow[ele]
|
||||
);
|
||||
this.execute('update');
|
||||
}
|
||||
});
|
||||
}
|
||||
this.updateEditRowKey((this as any).currentSaveId);
|
||||
}
|
||||
},
|
||||
onRowEdit(params: any) {
|
||||
const { row, col, value } = params;
|
||||
(this as any).editMap[row.id] = {
|
||||
...params,
|
||||
editedRow: { [col.colKey]: value },
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import React from 'react';
|
||||
|
||||
|
||||
import {
|
||||
Table,
|
||||
Input,
|
||||
|
|
@ -9,206 +7,186 @@ import {
|
|||
Avatar,
|
||||
Space,
|
||||
Tag,
|
||||
Modal,
|
||||
} from 'antd';
|
||||
import PageHeader from '../../../components/common/pageHeader';
|
||||
import Style from './web.module.less';
|
||||
|
||||
export default function render(this: any) {
|
||||
const { t } = this;
|
||||
const { pagination, users = [], oakLoading, editableRowKeys = [] } = this.state;
|
||||
const { pagination, users = [], oakLoading, idRemove } = this.state;
|
||||
const { relations, entity, entityId } = this.props;
|
||||
const { pageSize, total, currentPage } = pagination || {};
|
||||
const relationArr =
|
||||
typeof relations === 'object'
|
||||
? relations
|
||||
: relations && JSON.parse(relations);
|
||||
return (
|
||||
<PageHeader title="人员列表">
|
||||
<div className={Style.container}>
|
||||
<Space>
|
||||
<Button type="primary" onClick={() => this.goUpsert()}>
|
||||
添加
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => this.goUserEntityGrantWithGrant()}
|
||||
>
|
||||
二维码分享
|
||||
</Button>
|
||||
</Space>
|
||||
return (
|
||||
<PageHeader title="权限列表">
|
||||
<div className={Style.container}>
|
||||
<Space>
|
||||
<Button type="primary" onClick={() => this.goUpsert()}>
|
||||
添加
|
||||
</Button>
|
||||
</Space>
|
||||
|
||||
<Table
|
||||
loading={oakLoading}
|
||||
ref={this.tableRef}
|
||||
rowKey="id"
|
||||
editableRowKeys={editableRowKeys}
|
||||
onRowEdit={(params) => this.onRowEdit(params)}
|
||||
onRowValidate={(params) => this.onRowValidate(params)}
|
||||
columns={[
|
||||
{
|
||||
width: 100,
|
||||
dataIndex: 'index',
|
||||
title: '序号',
|
||||
render: (value, record, index) => index + 1,
|
||||
},
|
||||
{
|
||||
dataIndex: 'avatar',
|
||||
title: '头像',
|
||||
render: (value, record, index) => {
|
||||
return value ? (
|
||||
<Avatar src={value} shape="circle" />
|
||||
) : (
|
||||
<span>未设置</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
dataIndex: 'name',
|
||||
title: '姓名',
|
||||
// edit: {
|
||||
// component: Input,
|
||||
// props: {
|
||||
// clearable: true,
|
||||
// autofocus: true,
|
||||
// autoWidth: true,
|
||||
// },
|
||||
// rules: [
|
||||
// { required: true, message: '不能为空' },
|
||||
// ],
|
||||
// showEditIcon: false,
|
||||
// },
|
||||
},
|
||||
{
|
||||
dataIndex: 'nickname',
|
||||
title: '昵称',
|
||||
// edit: {
|
||||
// component: Input,
|
||||
// props: {
|
||||
// clearable: true,
|
||||
// autofocus: true,
|
||||
// autoWidth: true,
|
||||
// },
|
||||
// rules: [
|
||||
// { required: true, message: '不能为空' },
|
||||
// ],
|
||||
// showEditIcon: false,
|
||||
// },
|
||||
},
|
||||
{
|
||||
dataIndex: 'mobile',
|
||||
title: '手机号',
|
||||
},
|
||||
{
|
||||
dataIndex: 'relations',
|
||||
title: '权限',
|
||||
render: (value, record, index) => {
|
||||
return (
|
||||
<Space>
|
||||
{record.relations?.map(
|
||||
(ele: string, index: number) => (
|
||||
<Tag key={index}>
|
||||
{t(entity + ':r.' + ele)}
|
||||
</Tag>
|
||||
)
|
||||
)}
|
||||
</Space>
|
||||
);
|
||||
},
|
||||
<Table
|
||||
loading={oakLoading}
|
||||
ref={this.tableRef}
|
||||
rowKey="id"
|
||||
columns={[
|
||||
{
|
||||
width: 100,
|
||||
dataIndex: 'index',
|
||||
title: '序号',
|
||||
render: (value, record, index) => index + 1,
|
||||
},
|
||||
{
|
||||
dataIndex: 'avatar',
|
||||
title: '头像',
|
||||
render: (value, record, index) => {
|
||||
return value ? (
|
||||
<Avatar src={value} shape="circle" />
|
||||
) : (
|
||||
<span>未设置</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
dataIndex: 'name',
|
||||
title: '姓名',
|
||||
// edit: {
|
||||
// component: Input,
|
||||
// props: {
|
||||
// clearable: true,
|
||||
// autofocus: true,
|
||||
// autoWidth: true,
|
||||
// },
|
||||
// rules: [
|
||||
// { required: true, message: '不能为空' },
|
||||
// ],
|
||||
// showEditIcon: false,
|
||||
// },
|
||||
},
|
||||
{
|
||||
dataIndex: 'nickname',
|
||||
title: '昵称',
|
||||
// edit: {
|
||||
// component: Input,
|
||||
// props: {
|
||||
// clearable: true,
|
||||
// autofocus: true,
|
||||
// autoWidth: true,
|
||||
// },
|
||||
// rules: [
|
||||
// { required: true, message: '不能为空' },
|
||||
// ],
|
||||
// showEditIcon: false,
|
||||
// },
|
||||
},
|
||||
{
|
||||
dataIndex: 'mobile',
|
||||
title: '手机号',
|
||||
},
|
||||
{
|
||||
dataIndex: 'relations',
|
||||
title: '权限',
|
||||
render: (value, record, index) => {
|
||||
return (
|
||||
<Space>
|
||||
{record.relations?.map(
|
||||
(ele: string, index: number) => (
|
||||
<Tag key={index}>
|
||||
{this.t(entity + ':r.' + ele)}
|
||||
</Tag>
|
||||
)
|
||||
)}
|
||||
</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: t(
|
||||
// entity + ':r.' + ele
|
||||
// ),
|
||||
// })
|
||||
// ),
|
||||
// };
|
||||
// },
|
||||
// showEditIcon: false,
|
||||
// rules: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请至少选择一个权限',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'operate',
|
||||
render: (value, record, index) => {
|
||||
const editable = editableRowKeys.includes(
|
||||
record.id
|
||||
);
|
||||
return (
|
||||
<Space>
|
||||
<Button
|
||||
type="link"
|
||||
onClick={(e) =>
|
||||
this.goDetail(record.id)
|
||||
}
|
||||
>
|
||||
详情
|
||||
</Button>
|
||||
{!editable && (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={(e) => this.onEdit(e)}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
)}
|
||||
{editable && (
|
||||
<Button
|
||||
type="link"
|
||||
variant="text"
|
||||
onClick={(e) => this.onSave(e)}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
)}
|
||||
{editable && (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={(e) => this.onCancel(e)}
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
);
|
||||
},
|
||||
},
|
||||
]}
|
||||
data={users}
|
||||
pagination={{
|
||||
total,
|
||||
pageSize,
|
||||
current: currentPage,
|
||||
onShowSizeChange: (current: number, size: number) => {
|
||||
this.setPageSize(current);
|
||||
},
|
||||
onChange: (page: number, pageSize: number) => {
|
||||
this.setCurrentPage(page);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</PageHeader>
|
||||
);
|
||||
// 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: (value, record, index) => {
|
||||
return (
|
||||
<Space>
|
||||
<Button
|
||||
type="link"
|
||||
onClick={(e) =>
|
||||
this.goUpdate(record.id)
|
||||
}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
{ record.relations?.length > 0 && <Button
|
||||
danger
|
||||
type="link"
|
||||
onClick={() => this.onDelete(record.id)}
|
||||
>
|
||||
删除
|
||||
</Button>}
|
||||
</Space>
|
||||
);
|
||||
},
|
||||
},
|
||||
]}
|
||||
dataSource={users}
|
||||
pagination={{
|
||||
total,
|
||||
pageSize,
|
||||
current: currentPage,
|
||||
onShowSizeChange: (current: number, size: number) => {
|
||||
this.setPageSize(current);
|
||||
},
|
||||
onChange: (page: number, pageSize: number) => {
|
||||
this.setCurrentPage(page);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<Modal
|
||||
title="请确认"
|
||||
open={!!idRemove}
|
||||
onOk={() => this.confirmDelete()}
|
||||
onCancel={() => this.setState({ idRemove: ''})}
|
||||
cancelText="取消"
|
||||
okText="确认"
|
||||
>
|
||||
<p>确认删除用户的所有权限吗?</p>
|
||||
</Modal>
|
||||
</PageHeader>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
{
|
||||
"navigationBarTitleText": "修改权限",
|
||||
"navigationBarTitleText": "添加权限",
|
||||
"usingComponents": {
|
||||
"t-checkbox": "../../../miniprogram_npm/tdesign/checkbox/checkbox",
|
||||
"t-checkbox-group": "../../../miniprogram_npm/tdesign/checkbox-group/checkbox-group",
|
||||
"t-input": "../../../miniprogram_npm/tdesign/input/input",
|
||||
"t-tag": "../../../miniprogram_npm/tdesign/tag/tag",
|
||||
"t-icon": "../../../miniprogram_npm/tdesign/icon/icon",
|
||||
"t-divider": "../../../miniprogram_npm/tdesign/divider/divider",
|
||||
"t-button": "../../../miniprogram_npm/tdesign/button/button",
|
||||
"t-cell": "../../../miniprogram_npm/tdesign/cell/cell",
|
||||
"t-image": "../../../miniprogram_npm/tdesign/image/image"
|
||||
"t-button": "../../../miniprogram_npm/tdesign/button/button"
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue