UNPKG

tfp

Version:

A Web UI framework for TaskBuilder

173 lines (144 loc) 5.66 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; } } /** * 组织结构选择组件 * @param {[type]} dataModel [description] */ var OrgPicker = /*#__PURE__*/function (_FormInput) { (0, _inherits2["default"])(OrgPicker, _FormInput); var _super = _createSuper(OrgPicker); function OrgPicker(__tfp, dataModel, parent) { (0, _classCallCheck2["default"])(this, OrgPicker); return _super.call(this, __tfp, "OrgPicker", dataModel, parent); } (0, _createClass2["default"])(OrgPicker, [{ key: "value", get: function get() { return this.dataModel.value; }, set: function set(value) { if (typeof value == "string") value = JSON.parse(value); if (this.dataModel.valueType == "obj") { this.dataModel.value = value; } else { if (this.dataModel.multiCheck) { var val = ""; for (var i = 0; i < value.length; i++) { if (val != "") val += ","; val += value[i][this.dataModel.valueType]; } this.dataModel.value = val; } else { this.dataModel.value = value[this.dataModel.valueType]; } } if (this._jqObj) { if (this.dataModel.multiCheck) { var names = ""; for (var i = 0; i < value.length; i++) { if (names != "") names += ","; names += value[i].name; } this._jqObj.find("input").val(names); } else { this._jqObj.find("input").val(value.name); } } if (!this._tfp.isDesigning) { this.valueOnChange(); this.exeEventHandler("onChange", this.dataModel.value); } } }, { key: "iconUrl", get: function get() { return this._tfp.rootPath + "/src/components/" + this.dataModel.type.toLowerCase() + "/images/icon-24-" + this._tfp.curPage.contentColorMode + ".png"; }, set: function set(value) {} //数据绑定格式 }, { key: "dataBindingFormat", get: function get() { return this.dataModel.dataBindingFormat; }, set: function set(value) { this.dataModel.dataBindingFormat = value; } }, { key: "showIcon", get: function get() { return this.dataModel.showIcon; }, set: function set(value) { this.dataModel.showIcon = value ? true : false; if (this._jqObj) { if (this.dataModel.showIcon) { if (this._jqObj.find("img").length == 0) { this._jqObj.append("<img src=\"" + this.iconUrl + "\" />"); } } else { this._jqObj.find("img").remove(); } var iptWidth = "100%"; if (this.dataModel.showIcon) iptWidth = "calc(100% - 30px)"; this._jqObj.find("input").css("width", iptWidth + "px"); } } }, { key: "valueType", get: function get() { return this.dataModel.valueType; }, set: function set(value) { if (!this.checkAttrOption("valueType", value)) { this._tfp.showMsg("不支持类型:" + value + "!"); return; } this.dataModel.valueType = value; } }, { key: "multiCheck", get: function get() { return this.dataModel.multiCheck; }, set: function set(value) { this.dataModel.multiCheck = value ? true : false; } }, { key: "showPicker", value: function showPicker() { if (this.dataModel.multiCheck) { this._tfp.openDialog("组织结构选择", this._tfp.rootPath + "/src/components/orgpicker/orgsPicker.tfp?valueType=obj&cptId=" + this.id, "445px", "405px"); } else { this._tfp.openDialog("组织结构选择", this._tfp.rootPath + "/src/components/orgpicker/orgPicker.tfp?valueType=obj&cptId=" + this.id, "445px", "405px"); } } }, { key: "onSelected", value: function onSelected(ret) { this.value = ret; } }, { key: "initRuntime", value: function initRuntime() { var that = this; this._jqObj.click(function () { if (that.readonly || that.disabled) return; that.showPicker(); }); } }]); return OrgPicker; }(_controller.FormInput); exports["default"] = OrgPicker;