记录 可以禁用
This commit is contained in:
parent
bf508951d7
commit
c0f9169d4b
|
|
@ -16,9 +16,16 @@ var checkers = [
|
|||
data = operation.data;
|
||||
if (data instanceof Array) {
|
||||
data.forEach(function (ele) {
|
||||
(0, validator_1.checkAttributesNotNull)('userEntityGrant', ele, ['type', 'entity', 'entityId', 'relation']);
|
||||
(0, validator_1.checkAttributesNotNull)('userEntityGrant', ele, [
|
||||
'type',
|
||||
'entity',
|
||||
'entityId',
|
||||
'relation',
|
||||
]);
|
||||
if (ele.type === 'grant') {
|
||||
(0, validator_1.checkAttributesNotNull)('userEntityGrant', ele, ['number']);
|
||||
(0, validator_1.checkAttributesNotNull)('userEntityGrant', ele, [
|
||||
'number',
|
||||
]);
|
||||
if (ele.number <= 0) {
|
||||
throw new types_1.OakInputIllegalException('userEntityGrant', ['number', '分享的权限数量必须大于0']);
|
||||
}
|
||||
|
|
@ -29,11 +36,19 @@ var checkers = [
|
|||
});
|
||||
}
|
||||
else {
|
||||
(0, validator_1.checkAttributesNotNull)('userEntityGrant', data, ['type', 'entity', 'entityId', 'relation']);
|
||||
(0, validator_1.checkAttributesNotNull)('userEntityGrant', data, [
|
||||
'type',
|
||||
'entity',
|
||||
'entityId',
|
||||
'relation',
|
||||
]);
|
||||
if (data.type === 'grant') {
|
||||
(0, validator_1.checkAttributesNotNull)('userEntityGrant', data, ['number']);
|
||||
if (data.number <= 0) {
|
||||
throw new types_1.OakInputIllegalException('userEntityGrant', ['number', '分享的权限数量必须大于0']);
|
||||
throw new types_1.OakInputIllegalException('userEntityGrant', [
|
||||
'number',
|
||||
'分享的权限数量必须大于0',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Object.assign(data, {
|
||||
|
|
@ -45,5 +60,40 @@ var checkers = [
|
|||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'row',
|
||||
entity: 'userEntityGrant',
|
||||
action: ['disable'],
|
||||
checker: function (event, context, params) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
||||
var filter, rowStore, _a, userEntityGrant;
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
filter = event.operation.filter;
|
||||
rowStore = context.rowStore;
|
||||
return [4 /*yield*/, rowStore.select('userEntityGrant', {
|
||||
data: {
|
||||
id: 1,
|
||||
expired: 1,
|
||||
},
|
||||
filter: {
|
||||
id: filter === null || filter === void 0 ? void 0 : filter.id,
|
||||
},
|
||||
indexFrom: 0,
|
||||
count: 1,
|
||||
}, context, params)];
|
||||
case 1:
|
||||
_a = tslib_1.__read.apply(void 0, [(_b.sent()).result, 1]), userEntityGrant = _a[0];
|
||||
if (!(userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.expired)) {
|
||||
return [2 /*return*/, 1];
|
||||
}
|
||||
else {
|
||||
throw new types_1.OakUserUnpermittedException();
|
||||
}
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); },
|
||||
},
|
||||
];
|
||||
exports.default = checkers;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
/// <reference types="react" />
|
||||
declare const _default: import("react").ComponentType<any>;
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
exports.default = OakComponent({
|
||||
entity: 'userEntityGrant',
|
||||
isList: false,
|
||||
formData: function (_a) {
|
||||
var data = _a.data;
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
return [2 /*return*/, {}];
|
||||
});
|
||||
});
|
||||
},
|
||||
actions: ['disable'],
|
||||
methods: {
|
||||
tapAction: function (action) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var id, _a;
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
id = this.props.oakId;
|
||||
_a = action;
|
||||
switch (_a) {
|
||||
case 'disable': return [3 /*break*/, 1];
|
||||
}
|
||||
return [3 /*break*/, 3];
|
||||
case 1: return [4 /*yield*/, this.addOperation({
|
||||
action: 'disable',
|
||||
data: {
|
||||
expired: true
|
||||
},
|
||||
filter: {
|
||||
id: id,
|
||||
},
|
||||
})];
|
||||
case 2:
|
||||
_b.sent();
|
||||
this.execute();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
{
|
||||
return [3 /*break*/, 4];
|
||||
}
|
||||
_b.label = 4;
|
||||
case 4: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1 @@
|
|||
export default function render(this: any): any;
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
"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");
|
||||
function render() {
|
||||
var _this = this;
|
||||
var oakLegalActions = this.state.oakLegalActions;
|
||||
return (oakLegalActions === null || oakLegalActions === void 0 ? void 0 : oakLegalActions.length) > 0
|
||||
? oakLegalActions.map(function (ele) {
|
||||
var btnName = _this.t("userEntityGrant:action.".concat(ele));
|
||||
if (ele === 'remove') {
|
||||
btnName = _this.t("common:action.".concat(ele));
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "link", onClick: function (event) {
|
||||
var modal = antd_1.Modal.confirm({
|
||||
title: "\u786E\u8BA4".concat(btnName, "\u8BE5\u6388\u6743\u8BB0\u5F55\u5417\uFF1F"),
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
onOk: function (e) { 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.tapAction(ele)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
modal.destroy();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); },
|
||||
onCancel: function (e) {
|
||||
modal.destroy();
|
||||
},
|
||||
});
|
||||
} }, { children: btnName })));
|
||||
})
|
||||
: null;
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { GenericAction } from "oak-domain/lib/actions/action";
|
||||
export declare type ParticularAction = 'confirm';
|
||||
export declare type ParticularAction = 'confirm' | 'disable';
|
||||
export declare type Action = GenericAction | ParticularAction;
|
||||
export declare const actions: string[];
|
||||
export declare type IState = 'init';
|
||||
export declare type IState = 'effective' | 'invalid';
|
||||
export declare const ActionDefDict: {};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ActionDefDict = exports.actions = void 0;
|
||||
exports.actions = ["count", "stat", "download", "select", "create", "remove", "update", "confirm"];
|
||||
exports.actions = ["count", "stat", "download", "select", "create", "remove", "update", "confirm", "disable"];
|
||||
exports.ActionDefDict = {};
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "attr": { "relation": "关系", "entity": "关联对象", "entityId": "关联对象id", "type": "类型", "number": "次数", "confirmed": "已确认人数", "remark": "备注", "grantee": "领取人", "granter": "授权人", "files": "微信码", "expired": "是否过期", "expiresAt": "过期时间", "iState": "状态" }, "action": { "confirm": "确认" }, "v": { "type": { "grant": "授予", "transfer": "转交" }, "iState": { "init": "初始" } } }
|
||||
{ "attr": { "relation": "关系", "entity": "关联对象", "entityId": "关联对象id", "type": "类型", "number": "次数", "confirmed": "已确认人数", "remark": "备注", "grantee": "领取人", "granter": "授权人", "files": "微信码", "expired": "是否过期", "expiresAt": "过期时间", "iState": "状态" }, "action": { "confirm": "确认", "disable": "禁用" }, "v": { "type": { "grant": "授予", "transfer": "转交" }, "iState": { "effective": "有效", "invalid": "失效" } } }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
.container {
|
||||
background: var(--oak-bg-color-container);
|
||||
box-shadow: 0 2px 3px #0000001a;
|
||||
border-radius: 3px;
|
||||
padding: 30px 32px;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
.container {
|
||||
background: var(--oak-bg-color-container);
|
||||
box-shadow: 0 2px 3px #0000001a;
|
||||
border-radius: 3px;
|
||||
padding: 30px 32px;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
.container {
|
||||
background: var(--oak-bg-color-container);
|
||||
box-shadow: 0 2px 3px #0000001a;
|
||||
border-radius: 3px;
|
||||
padding: 30px 32px;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
.container {
|
||||
background: var(--oak-bg-color-container);
|
||||
box-shadow: 0 2px 3px #0000001a;
|
||||
border-radius: 3px;
|
||||
padding: 30px 32px;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
.container {
|
||||
background: var(--oak-bg-color-container);
|
||||
box-shadow: 0 2px 3px #0000001a;
|
||||
border-radius: 3px;
|
||||
padding: 30px 32px;
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|||
var antd_1 = require("antd");
|
||||
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
||||
var pageHeader_1 = tslib_1.__importDefault(require("../../../components/common/pageHeader"));
|
||||
var cellButton_1 = tslib_1.__importDefault(require("../../../components/userEntityGrant/cellButton"));
|
||||
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
function render() {
|
||||
var _this = this;
|
||||
|
|
@ -68,12 +69,7 @@ function render() {
|
|||
title: '操作',
|
||||
align: 'center',
|
||||
render: function (value, record, index) {
|
||||
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "link", onClick: function () {
|
||||
_this.setMessage({
|
||||
type: 'warning',
|
||||
content: '尚未实现'
|
||||
});
|
||||
} }, { children: "\u7981\u7528" })) }));
|
||||
return ((0, jsx_runtime_1.jsx)(cellButton_1.default, { oakId: record.id, oakPath: "".concat(_this.state.oakFullpath, ".").concat(record.id) }));
|
||||
},
|
||||
fixed: 'right',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
.container {
|
||||
background: var(--oak-bg-color-container);
|
||||
box-shadow: 0 2px 3px #0000001a;
|
||||
border-radius: 3px;
|
||||
padding: 30px 32px;
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
"@uiw/react-amap": "^4.0.2",
|
||||
"@wangeditor/editor": "^5.1.22",
|
||||
"@wangeditor/editor-for-react": "^1.0.4",
|
||||
"antd": "^4.23.6",
|
||||
"antd": "^4.24.2",
|
||||
"antd-mobile": "^5.24.1",
|
||||
"antd-mobile-icons": "^0.3.0",
|
||||
"classnames": "^2.3.1",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import {
|
||||
Checker, CreateChecker, OakInputIllegalException,
|
||||
Checker,
|
||||
CreateChecker,
|
||||
UpdateChecker,
|
||||
OakInputIllegalException,
|
||||
OakUserUnpermittedException,
|
||||
} from 'oak-domain/lib/types';
|
||||
import { EntityDict } from '../general-app-domain';
|
||||
import { RuntimeContext } from '../context/RuntimeContext';
|
||||
|
|
@ -14,30 +18,45 @@ const checkers: Checker<
|
|||
type: 'data',
|
||||
action: 'create',
|
||||
entity: 'userEntityGrant',
|
||||
checker: async ({ operation }, context) => {
|
||||
checker: async ({ operation }, context) => {
|
||||
const { data } = operation;
|
||||
if (data instanceof Array) {
|
||||
data.forEach(
|
||||
ele => {
|
||||
checkAttributesNotNull('userEntityGrant', ele, ['type', 'entity', 'entityId', 'relation']);
|
||||
if (ele.type === 'grant') {
|
||||
checkAttributesNotNull('userEntityGrant', ele, ['number']);
|
||||
if (ele.number <= 0 ) {
|
||||
throw new OakInputIllegalException('userEntityGrant', ['number', '分享的权限数量必须大于0']);
|
||||
}
|
||||
data.forEach((ele) => {
|
||||
checkAttributesNotNull('userEntityGrant', ele, [
|
||||
'type',
|
||||
'entity',
|
||||
'entityId',
|
||||
'relation',
|
||||
]);
|
||||
if (ele.type === 'grant') {
|
||||
checkAttributesNotNull('userEntityGrant', ele, [
|
||||
'number',
|
||||
]);
|
||||
if (ele.number <= 0) {
|
||||
throw new OakInputIllegalException(
|
||||
'userEntityGrant',
|
||||
['number', '分享的权限数量必须大于0']
|
||||
);
|
||||
}
|
||||
Object.assign(ele, {
|
||||
confirmed: 0,
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
checkAttributesNotNull('userEntityGrant', data, ['type', 'entity', 'entityId', 'relation']);
|
||||
Object.assign(ele, {
|
||||
confirmed: 0,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
checkAttributesNotNull('userEntityGrant', data, [
|
||||
'type',
|
||||
'entity',
|
||||
'entityId',
|
||||
'relation',
|
||||
]);
|
||||
if (data.type === 'grant') {
|
||||
checkAttributesNotNull('userEntityGrant', data, ['number']);
|
||||
if (data.number <= 0 ) {
|
||||
throw new OakInputIllegalException('userEntityGrant', ['number', '分享的权限数量必须大于0']);
|
||||
if (data.number <= 0) {
|
||||
throw new OakInputIllegalException('userEntityGrant', [
|
||||
'number',
|
||||
'分享的权限数量必须大于0',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Object.assign(data, {
|
||||
|
|
@ -46,8 +65,49 @@ const checkers: Checker<
|
|||
}
|
||||
return 0;
|
||||
},
|
||||
} as CreateChecker<EntityDict, 'userEntityGrant', RuntimeContext<EntityDict>
|
||||
>,
|
||||
} as CreateChecker<
|
||||
EntityDict,
|
||||
'userEntityGrant',
|
||||
RuntimeContext<EntityDict>
|
||||
>,
|
||||
{
|
||||
type: 'row',
|
||||
entity: 'userEntityGrant',
|
||||
action: ['disable'],
|
||||
checker: async (event, context, params) => {
|
||||
const {
|
||||
operation: { filter },
|
||||
} = event;
|
||||
const { rowStore } = context;
|
||||
const {
|
||||
result: [userEntityGrant],
|
||||
} = await rowStore.select(
|
||||
'userEntityGrant',
|
||||
{
|
||||
data: {
|
||||
id: 1,
|
||||
expired: 1,
|
||||
},
|
||||
filter: {
|
||||
id: filter?.id!,
|
||||
},
|
||||
indexFrom: 0,
|
||||
count: 1,
|
||||
},
|
||||
context,
|
||||
params
|
||||
);
|
||||
if (!userEntityGrant?.expired) {
|
||||
return 1;
|
||||
} else {
|
||||
throw new OakUserUnpermittedException();
|
||||
}
|
||||
},
|
||||
} as UpdateChecker<
|
||||
EntityDict,
|
||||
'userEntityGrant',
|
||||
RuntimeContext<EntityDict>
|
||||
>,
|
||||
];
|
||||
|
||||
export default checkers;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
export default OakComponent({
|
||||
entity: 'userEntityGrant',
|
||||
isList: false,
|
||||
async formData({ data }) {
|
||||
return {};
|
||||
},
|
||||
actions: ['disable'],
|
||||
methods: {
|
||||
async tapAction(action: string) {
|
||||
const { oakId: id } = this.props;
|
||||
switch (action) {
|
||||
case 'disable': {
|
||||
await this.addOperation({
|
||||
action: 'disable',
|
||||
data: {
|
||||
expired: true,
|
||||
},
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
this.execute();
|
||||
break;
|
||||
}
|
||||
// case 'remove': {
|
||||
// await this.addOperation({
|
||||
// action: 'remove',
|
||||
// data: {},
|
||||
// filter: {
|
||||
// id,
|
||||
// },
|
||||
// });
|
||||
// this.execute();
|
||||
// break;
|
||||
// }
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
import React from 'react';
|
||||
import { Button, Modal } from 'antd';
|
||||
|
||||
export default function render(this: any) {
|
||||
const { oakLegalActions } = this.state;
|
||||
|
||||
return oakLegalActions?.length > 0
|
||||
? oakLegalActions.map((ele: string) => {
|
||||
let btnName = this.t(`userEntityGrant:action.${ele}`);
|
||||
if (ele === 'remove') {
|
||||
btnName = this.t(`common:action.${ele}`);
|
||||
}
|
||||
return (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={(event) => {
|
||||
const modal = Modal!.confirm!({
|
||||
title: `确认${btnName}该授权记录吗?`,
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
onOk: async (e) => {
|
||||
await this.tapAction(ele);
|
||||
modal!.destroy!();
|
||||
},
|
||||
onCancel: (e) => {
|
||||
modal!.destroy!();
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
{btnName}
|
||||
</Button>
|
||||
);
|
||||
})
|
||||
: null;
|
||||
}
|
||||
|
|
@ -31,6 +31,17 @@ export default OakComponent({
|
|||
},
|
||||
},
|
||||
],
|
||||
sorters: [
|
||||
{
|
||||
sorter: {
|
||||
$attr: {
|
||||
$$createAt$$: 1,
|
||||
},
|
||||
$direction: 'desc',
|
||||
},
|
||||
"#name": 'default'
|
||||
},
|
||||
],
|
||||
async formData({ data }) {
|
||||
const pagination = this.getPagination();
|
||||
return {
|
||||
|
|
@ -41,7 +52,5 @@ export default OakComponent({
|
|||
data: {
|
||||
open: false,
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
methods: {},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import * as React from 'react';
|
|||
import { Table, Button, Space, Typography, Modal } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import PageHeader from '../../../components/common/pageHeader';
|
||||
import CellButton from '../../../components/userEntityGrant/cellButton';
|
||||
|
||||
import Style from './web.module.less';
|
||||
|
||||
|
|
@ -74,8 +75,16 @@ export default function render(this: any) {
|
|||
title: '状态',
|
||||
render: (value, record, index) => {
|
||||
return (
|
||||
<Typography.Text type={record.expired ? 'danger' : "success"}>
|
||||
<Typography.Text
|
||||
type={record.expired ? 'danger' : 'success'}
|
||||
>
|
||||
{record.expired ? '失效' : '有效'}
|
||||
{!record.expired && (
|
||||
<Typography.Text>
|
||||
|
||||
{dayjs(record.expireAt).format('YYYY-MM-DD HH:mm')}
|
||||
</Typography.Text>
|
||||
)}
|
||||
</Typography.Text>
|
||||
);
|
||||
},
|
||||
|
|
@ -87,16 +96,7 @@ export default function render(this: any) {
|
|||
align: 'center',
|
||||
render: (value, record, index) => {
|
||||
return (
|
||||
<>
|
||||
<Button type="link" onClick={() => {
|
||||
this.setMessage({
|
||||
type: 'warning',
|
||||
content: '尚未实现'
|
||||
})
|
||||
}}>
|
||||
禁用
|
||||
</Button>
|
||||
</>
|
||||
<CellButton oakId={record.id} oakPath={`${this.state.oakFullpath}.${record.id}`} />
|
||||
);
|
||||
},
|
||||
fixed: 'right',
|
||||
|
|
|
|||
Loading…
Reference in New Issue