fastlion-amis
Version:
一种MIS页面生成工具
210 lines (209 loc) • 14 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LionCellFileRenderer = exports.LionCellFile = void 0;
var tslib_1 = require("tslib");
var factory_1 = require("../../../../factory");
var Tooltip_1 = (0, tslib_1.__importDefault)(require("antd/lib/Tooltip"));
var react_1 = (0, tslib_1.__importDefault)(require("react"));
require("./LionCellFile.css");
// import LionFilePreview from './LionFilePreview';
var LabelPrint_1 = require("../../LabelPrint");
var LodopFuncs_1 = require("../../../../utils/print/LodopFuncs");
var utils_1 = require("../../utils/utils");
var style_1 = require("./style");
var LionCellFile = /** @class */ (function (_super) {
(0, tslib_1.__extends)(LionCellFile, _super);
function LionCellFile(props) {
var _this = _super.call(this, props) || this;
_this.state = {
visible: false,
current: null,
_print_visible: false,
ctx: {
items: [],
rows: [],
selectedItems: [],
unSelectedItems: [],
ids: ''
}
};
_this.handleOpenPdf = function (current) {
_this.setState({
visible: true,
current: current
});
};
_this.matchPdfImg = function (str) {
return /(.jpe?)g|(.png)|(.pdf)/i.test(str);
};
_this.handleLabelPrint = function (current) {
if (!_this.matchPdfImg(current === null || current === void 0 ? void 0 : current.name)) {
return;
}
_this.setState({
ctx: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, _this.state.ctx), { items: [current], rows: [current], selectedItems: [current], unSelectedItems: [] })
}, function () {
var LODOP = (0, LodopFuncs_1.getLodop)();
if (LODOP) {
_this.setState({
_print_visible: true
});
}
});
};
_this.handlePreview = _this.handlePreview.bind(_this);
return _this;
}
LionCellFile.prototype.componentDidMount = function () {
this.setState({
ctx: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, this.state.ctx), { ids: this.props.ids || '', primaryField: this.props.primaryField || '' })
});
};
LionCellFile.prototype.handlePreview = function (info, index) {
var _a, _b;
var _c = this.props, onImageEnlarge = _c.onImageEnlarge, env = _c.env;
var baseURL = ((_b = (_a = env === null || env === void 0 ? void 0 : env.axiosInstance) === null || _a === void 0 ? void 0 : _a.defaults) === null || _b === void 0 ? void 0 : _b.baseURL) || (env === null || env === void 0 ? void 0 : env.ajaxApi) || '';
// const baseURL = 'https://saasdev.fastlion.cn/saas'
var isNotImg = false;
var list = info.map(function (item) {
isNotImg = !(0, utils_1.isImg)(item.name);
return {
src: isNotImg ? (0, utils_1.getMediaIcon)(item.name) : baseURL + (item.thumbnailAddr || (item === null || item === void 0 ? void 0 : item.addr)),
originalSrc: baseURL + item.preview,
downloadSrc: baseURL + (item === null || item === void 0 ? void 0 : item.addr),
title: item.name || '',
isNotImg: isNotImg
};
});
onImageEnlarge && onImageEnlarge({
src: list[index].src,
originalSrc: list[index].originalSrc,
index: index,
list: list
});
};
LionCellFile.prototype.render = function () {
var _this = this;
var _a, _b, _c, _d, _e, _f, _g;
var _h = this.props, data = _h.data, name = _h.name, env = _h.env;
var data_detail = data[name];
var _j = this.state, visible = _j.visible, current = _j.current;
var baseUrl = ((_b = (_a = env === null || env === void 0 ? void 0 : env.axiosInstance) === null || _a === void 0 ? void 0 : _a.defaults) === null || _b === void 0 ? void 0 : _b.baseURL) || (env === null || env === void 0 ? void 0 : env.ajaxApi);
// const baseUrl = 'https://saasdev.fastlion.cn/saas'
var that = this;
return (react_1.default.createElement(react_1.default.Fragment, null,
react_1.default.createElement("div", { className: "Papers-cell-view", style: { display: 'flex', cursor: 'pointer', alignItems: 'center' } },
react_1.default.createElement(Tooltip_1.default, { placement: "bottom", overlayInnerStyle: {
background: '#fff',
width: '298px',
zIndex: 9000,
borderRadius: '4px',
border: '1px solid #ebeef5',
lineHeight: '1.4',
textAlign: 'justify',
fontSize: '14px',
wordBreak: "break-all",
boxShadow: '0 2px 12px 0 rgb(0 0 0 / 10%)',
padding: '3px 4px'
}, zIndex: 9000, title: data_detail && data_detail.info && ((_c = data_detail.info) === null || _c === void 0 ? void 0 : _c.length) > 0 ? react_1.default.createElement("div", { className: "Papers-cell-list", style: { width: "290px", background: '#fff', color: '#333' } }, data_detail.info.map(function (item, idx) {
return react_1.default.createElement(style_1.WrapperFileView, { className: "Papers-cell-list-item", key: item.name },
react_1.default.createElement(Tooltip_1.default, { placement: idx === data_detail.info.length - 1 ? 'bottom' : 'top', title: item.name, arrowPointAtCenter: true, overlayInnerStyle: {
zIndex: 9999
}, zIndex: 9999 },
react_1.default.createElement("span", { className: "Papers-cell-list-item-tooltip", style: {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
} },
react_1.default.createElement("span", { className: "fa fa-link", style: {
fontSize: '13px'
} }),
"\u00A0\u00A0",
react_1.default.createElement("span", { style: {
width: '160px',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
fontSize: '12px'
} }, item.name))),
react_1.default.createElement(Tooltip_1.default, { overlayInnerStyle: { zIndex: 9999 }, zIndex: 9999, placement: 'top', title: '\u4E0B\u8F7D' },
react_1.default.createElement("span", { onClick: function () { (0, utils_1.downloadFile)((baseUrl ? baseUrl : '') + item.addr, item.name); }, style: { border: 0, cursor: 'pointer' } },
react_1.default.createElement("span", { className: "fa fa-download", style: { fontSize: '13px' } }))),
react_1.default.createElement(Tooltip_1.default, { overlayInnerStyle: { zIndex: 9999 }, zIndex: 9999, placement: 'top', title: '\u6253\u5F00' },
react_1.default.createElement("span", { onClick: function () { _this.handlePreview(data_detail.info, idx); }, style: { border: 0, cursor: 'pointer', marginRight: '5px' } },
react_1.default.createElement("span", { className: "fa fa-folder-open-o", style: { fontSize: '13px' } }))),
react_1.default.createElement(Tooltip_1.default, { overlayInnerStyle: { zIndex: 9999 }, zIndex: 9999, placement: 'top', title: '\u6253\u5370' },
react_1.default.createElement("span", { onClick: function () { _this.handleLabelPrint(item); }, style: { border: 0, marginRight: '5px', cursor: _this.matchPdfImg(item === null || item === void 0 ? void 0 : item.name) ? 'pointer' : 'not-allowed', color: _this.matchPdfImg(item === null || item === void 0 ? void 0 : item.name) ? 'inherit' : '#999' } },
react_1.default.createElement("span", { className: "fa fa-print", style: { fontSize: '13px' } }))));
})) : null },
react_1.default.createElement(Tooltip_1.default, { overlayInnerStyle: {
background: '#303133',
width: '278px',
height: 'auto',
padding: '5px 8px',
zIndex: 9000
}, zIndex: 9000, title: data_detail && data_detail.info && data_detail.info.length > 1 ? react_1.default.createElement("div", { style: { background: '#303133', display: 'flex', height: "auto", alignItems: 'center' } },
react_1.default.createElement("span", { style: {
color: '#fff'
} },
react_1.default.createElement("span", { style: {
color: "#999",
width: '50px'
} }, "\u9644\u4EF6\uFF1A"),
data_detail ? react_1.default.createElement("span", { className: "fa fa-link", style: {
fontSize: '12px'
} }) : null,
data_detail ? (_d = data_detail === null || data_detail === void 0 ? void 0 : data_detail.info) === null || _d === void 0 ? void 0 : _d.length : null,
"\u00A0\u00A0",
data_detail && data_detail.info ?
data_detail.info[0].name : null))
: null, placement: "top", mouseEnterDelay: 0.5 },
react_1.default.createElement("span", { style: {
display: 'flex',
cursor: data_detail ? 'pointer' : 'text',
alignItems: 'center'
} },
react_1.default.createElement("span", { style: {
display: 'flex',
alignItems: 'center'
} },
data_detail ? react_1.default.createElement("span", { className: "fa fa-link", style: {
fontSize: '12px'
} }) : null,
data_detail && data_detail.info && ((_e = data_detail.info) === null || _e === void 0 ? void 0 : _e.length) > 0 ? (_f = data_detail === null || data_detail === void 0 ? void 0 : data_detail.info) === null || _f === void 0 ? void 0 : _f.length : null,
"\u00A0\u00A0",
react_1.default.createElement("span", { style: {
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
width: '200px'
} }, data_detail && data_detail.info && ((_g = data_detail.info) === null || _g === void 0 ? void 0 : _g.length) > 0 ?
data_detail.info[0].name : '暂无附件'),
data_detail && data_detail.info ? (data_detail.info.length > 1 ? react_1.default.createElement("span", { className: "fa fa-angle-down", style: {
marginLeft: '10px',
fontWeight: 400,
fontSize: '12px',
color: "#999"
} }) : null) : null))))),
this.state._print_visible && react_1.default.createElement(LabelPrint_1.ModalPrint, (0, tslib_1.__assign)({ type: "lion-print" }, this.props, { isFilePrint: true, isSingleFilePrint: true, ctx: this.state.ctx, show: this.state._print_visible, onHide: function () { _this.setState({ _print_visible: false }); } }))));
};
return LionCellFile;
}(react_1.default.Component));
exports.LionCellFile = LionCellFile;
var LionCellFileRenderer = /** @class */ (function (_super) {
(0, tslib_1.__extends)(LionCellFileRenderer, _super);
function LionCellFileRenderer() {
return _super !== null && _super.apply(this, arguments) || this;
}
LionCellFileRenderer = (0, tslib_1.__decorate)([
(0, factory_1.Renderer)({
type: 'lion-cell-file'
})
], LionCellFileRenderer);
return LionCellFileRenderer;
}(LionCellFile));
exports.LionCellFileRenderer = LionCellFileRenderer;
//# sourceMappingURL=./renderers/Lion/Table/LionCellFile/LionCellFile.js.map