Built files from Bizgaze WebServer
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

userselect2.component.js 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. var Unibase;
  11. (function (Unibase) {
  12. let Apps;
  13. (function (Apps) {
  14. let Collaboration;
  15. (function (Collaboration) {
  16. let Controls;
  17. (function (Controls) {
  18. class UserSelect2 extends Unibase.Platform.Core.BaseComponent {
  19. constructor() {
  20. super(...arguments);
  21. this.data = [];
  22. }
  23. init(formpropertyid, prop, callback) {
  24. var instance = UserSelect2.Instance();
  25. var container = $(".select2_" + prop.FormPropertyId);
  26. Unibase.Apps.Collaboration.Controls.UserSelect2.Instance().loadControlSettings(container, null).then(function () {
  27. if (callback != null)
  28. callback();
  29. });
  30. }
  31. loadControl(containerid, prop) {
  32. var instance = this;
  33. var IsTagSelect = false;
  34. var text;
  35. debugger;
  36. if (prop.ControlJsonText != "" && prop.ControlJsonText != null && prop.ControlJsonText != undefined) {
  37. var text = JSON.parse(prop.ControlJsonText);
  38. if (text["IsTagSelect"] == true) {
  39. IsTagSelect = true;
  40. }
  41. }
  42. var html = '<div id="div_' + prop.DocPropertyName + '" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><label for= "lbl" id = "lbl_' + prop.DocPropertyName + '" >' + prop.LabelName + '<span class="text-danger hide " id="spnIsRequired_' + prop.DocPropertyName + '"> *</span></label >' +
  43. '<input type="hidden" id="hdnselect2_' + prop.FormPropertyId + '" class="" value="0">' +
  44. '<select id="select2_' + prop.FormPropertyId + '" class="value-control select2_' + prop.FormPropertyId + ' type-control select2_' + prop.DocPropertyName + ' form-control text-control " multiple="multiple" data-isdynamic="' + prop.IsDefault + '" data-istagselect="' + IsTagSelect + '" style="width:100%;" data-propdoctypename="' + prop.DocTypeName + '" data-propertyid="' + prop.DocPropertyId + '" data-propertyname="' + prop.DocPropertyName + '" data-formpropertyid="' + prop.FormPropertyId + '" data-regularexp="" data-validatemsg="" data-textformpropertyid=""><option>Select</option></select>' +
  45. '</div>';
  46. $("#" + containerid).html(html);
  47. }
  48. loadControlSettings(Container, Parameters) {
  49. return __awaiter(this, void 0, void 0, function* () {
  50. var ColumnName = "0";
  51. var Value = "0";
  52. var DocPropertyId = Container.data('propertyid');
  53. var DocPropertyName = Container.data('propertyname');
  54. var FormPropertyId = Container.data('formpropertyid');
  55. if (Parameters != null && Parameters != "") {
  56. ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
  57. Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
  58. }
  59. var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
  60. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/membership/getallusers';
  61. var data = UserSelect2.instance.data.find(x => x.formpropertyid == FormPropertyId);
  62. $(".select2_" + FormPropertyId).select2({
  63. tags: true,
  64. multiple: true,
  65. allowClear: false,
  66. data: UserSelect2.instance.data,
  67. placeholder: 'Select',
  68. ajax: {
  69. url: function (request) {
  70. var reqUrl = url;
  71. var term = request.term;
  72. if (term == undefined || term == "")
  73. reqUrl = reqUrl + "/term/" + term + "/authtoken/" + userinfo.sessionId;
  74. else
  75. reqUrl = reqUrl + "/term/" + term + "/authtoken/" + userinfo.sessionId;
  76. return reqUrl;
  77. },
  78. contentType: 'application/json',
  79. type: "GET",
  80. delay: 250,
  81. data: function (params) {
  82. var query = {
  83. term: params.term,
  84. type: 'GET'
  85. };
  86. return query;
  87. },
  88. beforeSend: function (xhr) {
  89. if (userinfo !== undefined && userinfo !== null) {
  90. xhr.setRequestHeader("Authorization", "Basic " + userinfo.sessionId);
  91. xhr.setRequestHeader('geoposition', userinfo.latd + ':' + userinfo.lgId);
  92. }
  93. },
  94. processResults: function (data, params) {
  95. return {
  96. results: jQuery.map(JSON.parse(data.result), function (item) {
  97. return {
  98. id: item.Value,
  99. text: item.DisplayText
  100. };
  101. })
  102. };
  103. }
  104. },
  105. templateResult: function (item) { debugger; return item.text; },
  106. templateSelection: function (item) { return item.text; },
  107. });
  108. });
  109. }
  110. loadPropertySettings(propertysettings, formpropertyid) {
  111. return ``;
  112. }
  113. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  114. return ``;
  115. }
  116. static Instance() {
  117. if (this.instance === undefined) {
  118. this.instance = new UserSelect2();
  119. }
  120. return this.instance;
  121. }
  122. }
  123. Controls.UserSelect2 = UserSelect2;
  124. })(Controls = Collaboration.Controls || (Collaboration.Controls = {}));
  125. })(Collaboration = Apps.Collaboration || (Apps.Collaboration = {}));
  126. })(Apps = Unibase.Apps || (Unibase.Apps = {}));
  127. })(Unibase || (Unibase = {}));