fastlion-amis
Version:
一种MIS页面生成工具
63 lines (62 loc) • 5.45 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserDetailPopover = void 0;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var antd_1 = require("antd");
var FieldName;
(function (FieldName) {
FieldName["USER_ID"] = "USER_ID";
FieldName["USER_NAME"] = "USER_NAME";
FieldName["GROUP_NAME"] = "GROUP_NAME";
FieldName["USER_IMAGE"] = "USER_IMAGE";
FieldName["USER_DEP"] = "DEP_NAME";
FieldName["USER_TYPE"] = "USER_TYPE";
FieldName["ORG_ID"] = "ORG_ID";
})(FieldName || (FieldName = {}));
var UserDetailPopover = function (props) {
var _a = (0, react_1.useState)(false), visible = _a[0], setVisible = _a[1];
return (react_1.default.createElement(antd_1.Popover, { overlayClassName: 'user-detail-popover', visible: visible, content: react_1.default.createElement(PcContent, tslib_1.__assign({}, props)), placement: 'bottomLeft', trigger: 'click', destroyTooltipOnHide: true,
// getPopupContainer={e => e.parentElement ?? document.body}
onVisibleChange: setVisible }, props.children));
};
exports.UserDetailPopover = UserDetailPopover;
var PcContent = function (_a) {
var _b, _c, _d, _e, _f, _g;
var id = _a.id, env = _a.env;
var baseUrl = ((_c = (_b = env === null || env === void 0 ? void 0 : env.axiosInstance) === null || _b === void 0 ? void 0 : _b.defaults) === null || _c === void 0 ? void 0 : _c.baseURL) || (env === null || env === void 0 ? void 0 : env.ajaxApi) || '';
var _h = (0, react_1.useState)(true), loading = _h[0], setLoading = _h[1];
var _j = (0, react_1.useState)({ columns: [], items: [] }), _k = _j[0], columns = _k.columns, items = _k.items, setDataSource = _j[1];
var isGroup = (0, react_1.useMemo)(function () { var _a, _b; return ((_a = items[0]) === null || _a === void 0 ? void 0 : _a[FieldName.USER_TYPE]) === 'USER_GROUP' || ((_b = items[0]) === null || _b === void 0 ? void 0 : _b[FieldName.USER_TYPE]) === 'DEPART'; }, [items]);
(0, react_1.useEffect)(function () {
getDetail();
}, []);
var getDetail = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var res;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, env.fetcher({ url: "/api/v1/user/info/data?userId=".concat(id), method: 'get' }).finally(function () { return setLoading(false); })];
case 1:
res = _a.sent();
if (res.status == 0 && res.data != null) {
setDataSource(res.data);
}
return [2 /*return*/];
}
});
}); };
return (react_1.default.createElement("div", { style: { maxHeight: 'calc(100vh - 450px)', display: 'flex', flexDirection: 'column' } },
react_1.default.createElement(antd_1.Card, { bordered: false, loading: loading, style: { width: 350, borderRadius: 4 }, bodyStyle: { padding: '18px 12px' } },
react_1.default.createElement(antd_1.Card.Meta, { avatar: react_1.default.createElement(antd_1.Avatar, { style: { width: 64, height: 64, backgroundColor: 'white', borderRadius: 6, padding: 6 }, shape: 'square', src: ((_d = items[0]) === null || _d === void 0 ? void 0 : _d[FieldName.USER_IMAGE]) ? baseUrl + ((_e = items[0]) === null || _e === void 0 ? void 0 : _e[FieldName.USER_IMAGE]) : '' }), title: react_1.default.createElement("div", { style: { fontWeight: 600 } }, (_f = items[0]) === null || _f === void 0 ? void 0 : _f[isGroup ? FieldName.GROUP_NAME : FieldName.USER_NAME]), description: react_1.default.createElement("span", { style: { fontWeight: 500, color: 'rgba(0,0,0,0.6)' } }, (_g = items[0]) === null || _g === void 0 ? void 0 : _g[FieldName.USER_DEP]) })),
isGroup && (react_1.default.createElement(antd_1.Card, { bordered: false, loading: loading, style: { width: 350, borderRadius: 4, marginTop: 8 }, bodyStyle: { padding: '6px 12px' } },
react_1.default.createElement(antd_1.Row, { style: { padding: '8px 0' } },
react_1.default.createElement(antd_1.Col, { span: 6, className: 'ellipsis' }, "\u7EC4\u5458"),
react_1.default.createElement(antd_1.Col, { span: 18 }, items.slice(0, 2).map(function (item) { return "".concat(item.USER_NAME, "(").concat(item.USER_ID, ")"); }).join(',') + (items.length > 2 ? " \u7B49".concat(items.length, "\u4EBA") : ''))))),
react_1.default.createElement(antd_1.Card, { bordered: false, loading: loading, style: { width: 350, borderRadius: 4, marginTop: 8, flex: 1, overflow: 'auto' }, bodyStyle: { padding: '6px 12px' } }, columns.filter(function (column) { return !Object.values(FieldName).filter(function (field) { return isGroup ? true : field !== FieldName.USER_ID; }).some(function (field) { return field == column.name; }); }).map(function (column, index, arr) {
var _a;
return (react_1.default.createElement(antd_1.Row, { style: { padding: '8px 0' } },
react_1.default.createElement(antd_1.Col, { span: 6, className: 'ellipsis' }, column.label),
react_1.default.createElement(antd_1.Col, { span: 18 }, (_a = items[0]) === null || _a === void 0 ? void 0 : _a[column.name])));
}))));
};
//# sourceMappingURL=./components/UserDetailPop/index.js.map