oak-general-business/lib/pages/userRelation/list/web.pc.js

135 lines
9.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"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 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 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: [
{
width: 100,
colKey: 'index',
title: '序号',
cell: function (_a) {
var rowIndex = _a.rowIndex;
return rowIndex + 1;
},
},
{
colKey: '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" }));
},
},
{
colKey: 'name',
title: '姓名',
edit: {
component: tdesign_react_1.Input,
props: {
clearable: true,
autofocus: true,
autoWidth: true,
},
rules: [
{ required: true, message: '不能为空' },
],
showEditIcon: false,
},
},
{
colKey: 'nickname',
title: '昵称',
edit: {
component: tdesign_react_1.Input,
props: {
clearable: true,
autofocus: true,
autoWidth: true,
},
rules: [
{ required: true, message: '不能为空' },
],
showEditIcon: false,
},
},
{
colKey: 'mobile',
title: '手机号',
},
{
colKey: '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: '请至少选择一个权限',
},
],
},
},
{
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" })))] }));
},
},
], data: users, pagination: {
total: total,
pageSize: pageSize,
current: currentPage,
onPageSizeChange: function (ps) {
_this.setPageSize(ps);
},
onCurrentChange: function (current) {
_this.setCurrentPage(current);
},
} })] })) })) })));
}
exports.default = render;