tfp
Version:
A Web UI framework for TaskBuilder
187 lines (158 loc) • 6.54 kB
JavaScript
"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 Org = /*#__PURE__*/function (_FormInput) {
(0, _inherits2["default"])(Org, _FormInput);
var _super = _createSuper(Org);
function Org(__tfp, inputType, dataModel, parent) {
(0, _classCallCheck2["default"])(this, Org);
return _super.call(this, __tfp, inputType, dataModel, parent);
}
(0, _createClass2["default"])(Org, [{
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.type == "Dep") {
if (this.dataModel.multiCheck) {
this._tfp.openDialog("选择部门", this._tfp.rootPath + "/src/components/org/tfp/depsPicker.tfp?valueType=obj&cptId=" + this.id, "480px", "480px");
} else {
this._tfp.openDialog("选择部门", this._tfp.rootPath + "/src/components/org/tfp/depPicker.tfp?valueType=obj&cptId=" + this.id, "480px", "480px");
}
} else if (this.dataModel.type == "User") {
if (this.dataModel.multiCheck) {
this._tfp.openDialog("选择用户", this._tfp.rootPath + "/src/components/org/tfp/usersPicker.tfp?valueType=obj&cptId=" + this.id, "480px", "480px");
} else {
this._tfp.openDialog("选择用户", this._tfp.rootPath + "/src/components/org/tfp/userPicker.tfp?valueType=obj&cptId=" + this.id, "480px", "480px");
}
} else if (this.dataModel.type == "Role") {
if (this.dataModel.multiCheck) {
this._tfp.openDialog("选择群组", this._tfp.rootPath + "/src/components/org/tfp/rolesPicker.tfp?valueType=obj&cptId=" + this.id, "480px", "480px");
} else {
this._tfp.openDialog("选择群组", this._tfp.rootPath + "/src/components/org/tfp/rolePicker.tfp?valueType=obj&cptId=" + this.id, "480px", "480px");
}
}
}
}, {
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 Org;
}(_controller.FormInput);
exports["default"] = Org;