UNPKG

tfp

Version:

A Web UI framework for TaskBuilder

127 lines (97 loc) 4.16 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _controller = require("../controller.js"); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** * Excel导出组件 * @param {[type]} dataModel [description] */ var ExcelExport = /*#__PURE__*/function (_VisibleComponent) { (0, _inherits2["default"])(ExcelExport, _VisibleComponent); var _super = _createSuper(ExcelExport); function ExcelExport(__tfp, dataModel, parent, inputType) { var _this; (0, _classCallCheck2["default"])(this, ExcelExport); if (inputType) { _this = _super.call(this, __tfp, inputType, dataModel, parent); } else { _this = _super.call(this, __tfp, "ExcelExport", dataModel, parent); } return (0, _possibleConstructorReturn2["default"])(_this); } //属性 (0, _createClass2["default"])(ExcelExport, [{ key: "text", get: function get() { return this.dataModel.text; }, set: function set(value) { this.dataModel.text = value; if (this._jqObj) { this._jqObj.html(value); } } }, { key: "theme", get: function get() { return this.dataModel.theme; }, set: function set(value) { var theme = "rect"; if (value) theme = value; if (!this.checkAttrOption("theme", theme)) { this._tfp.showMsg("不支持风格:" + theme + "!"); return; } this.dataModel.theme = theme; if (this._jqObj) { this._jqObj.removeClass("tfp-button-round tfp-button-rect tfp-button-circle"); this._jqObj.addClass("tfp-button-" + theme); } } }, { key: "service", get: function get() { return this.dataModel.service; }, set: function set(value) { this.dataModel.service = value; } }, { key: "initRuntime", value: function initRuntime() { var that = this; this._jqObj.click(function () { if (!that.dataModel.service) { that._tfp.showMsg("请设置导出数据的后台服务!"); return; } var serviceCpt = that._tfp.components[that.dataModel.service]; serviceCpt.request(null, function (req, res) { if (res.code != 0) { that._tfp.showMsg(res.message); return; } $('.exportlink').remove(); $('body').append('<a class="exportlink" style="display:none;" href="javascript:"></a>'); $('.exportlink').click(function () { var url = "/Download?fileCode=" + res.fileCode; window.location.href = that._tfp.setUrlAuthData(url); }); $('.exportlink').click(); }); }); } }]); return ExcelExport; }(_controller.VisibleComponent); exports["default"] = ExcelExport;