OOOrg.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. MWF.xDesktop.requireApp('process.Xform', 'Org', null, false);
  2. MWF.xApplication.process.Xform.OOOrg = MWF.APPOOOrg = new Class({
  3. Implements: [Events],
  4. Extends: MWF.APPOrg,
  5. iconStyle: 'textFieldIcon',
  6. options: {
  7. "moduleEvents": ["load", "queryLoad", "postLoad"]
  8. },
  9. isReadonly : function(){
  10. return !!(this.readonly || this.json.isReadonly || this.form.json.isReadonly || this.json.showMode==="readmode" || this.isSectionMergeRead());
  11. },
  12. _loadNode: function () {
  13. this._getOrgOptions();
  14. this._loadNodeEdit();
  15. },
  16. loadDescription: function () {
  17. this.node.setAttribute('placeholder', this.json.description || '');
  18. },
  19. _loadDomEvents: function(){
  20. if (!((this.json.showMode === 'read' || this.isReadonly()) && this.json.readModeEvents!=='yes')) {
  21. Object.each(this.json.events, function(e, key){
  22. if (e.code){
  23. if (this.options.moduleEvents.indexOf(key)===-1){
  24. this.node.addEvent(key, function(event){
  25. return this.form.Macro.fire(e.code, this, event);
  26. }.bind(this));
  27. }
  28. }
  29. }.bind(this));
  30. }
  31. },
  32. _loadNodeEdit: function () {
  33. this.node.set({
  34. 'id': this.json.id,
  35. 'MWFType': this.json.type,
  36. 'validity-blur': 'true',
  37. // "label-style": "width:6.2vw; min-width:5em; max-width:9em"
  38. });
  39. if (this.json.label) {
  40. this.node.setAttribute('label', this.json.label);
  41. }
  42. if (this.json.showIcon !== 'no' && !this.form.json.hideModuleIcon) {
  43. this.node.setAttribute('right-icon', 'person');
  44. } else if (this.form.json.nodeStyleWithhideModuleIcon) {
  45. this.node.setAttribute('right-icon', '');
  46. }
  47. if (this.json.properties) {
  48. this.node.set(this.json.properties);
  49. }
  50. if (this.json.styles) {
  51. this.node.setStyles(this.json.styles);
  52. }
  53. this.node.setAttribute('readonly', false);
  54. this.node.setAttribute('readmode', false);
  55. this.node.setAttribute('disabled', false);
  56. if (!this.isReadonly()){
  57. if (this.json.showMode === 'readonlyMode') {
  58. this.node.setAttribute('readonly', true);
  59. } else if (this.json.showMode === 'disabled') {
  60. this.node.setAttribute('disabled', true);
  61. } else if (this.json.showMode === 'read') {
  62. this.node.setAttribute('readmode', true);
  63. // if (this.json.readModeEvents!=='yes'){
  64. // this.node.setStyle('pointer-events', 'none');
  65. // }
  66. } else {
  67. }
  68. }else{
  69. this.node.setAttribute('readmode', true);
  70. // if (this.json.readModeEvents!=='yes'){
  71. // this.node.setStyle('pointer-events', 'none');
  72. // }
  73. }
  74. if (this.json.required){
  75. this.node.setAttribute("required", true);
  76. if (!this.json.validationConfig) this.json.validationConfig = [];
  77. var label = this.json.label ? `“${this.json.label.replace(/ /g, '')}”` : MWF.xApplication.process.Xform.LP.requiredHintField;
  78. this.json.validationConfig.push({
  79. status : "all",
  80. decision : "",
  81. valueType : "value",
  82. operateor : "isnull",
  83. value : "",
  84. prompt : MWF.xApplication.process.Xform.LP.requiredHint.replace('{label}', label),
  85. });
  86. }else{
  87. this.node.removeAttribute("required");
  88. }
  89. this.node.addEvent('change', function () {
  90. var v = this.getInputData('change');
  91. this.validationMode();
  92. this.validation();
  93. this._setBusinessData(v);
  94. this.fireEvent('change');
  95. }.bind(this));
  96. this.node.addEventListener('validity', (e) => {
  97. if (this.validationText) {
  98. e.target.setCustomValidity(this.validationText);
  99. }
  100. });
  101. this.node.setAttribute('sel-config', 'o29');
  102. this.node.select = ()=>{
  103. this.node.unInvalidStyle();
  104. this.clickSelect();
  105. }
  106. },
  107. createModelNode: function () {
  108. },
  109. clickSelect: function( ev ){
  110. if (this.isReadonly())return;
  111. if( layout.mobile ){
  112. setTimeout( function(){ //如果有输入法界面,这个时候页面的计算不对,所以等100毫秒
  113. var options = this.getOptions();
  114. if(options){
  115. if( this.selector && this.selector.loading ) {
  116. }else if( this.selector && this.selector.selector && this.selector.selector.active ){
  117. }else{
  118. /**
  119. * @summary 人员选择框package的对象
  120. * @member {o2.O2Selector}
  121. * @example
  122. * //可以在脚本中获取该组件
  123. * var selector = this.form.get("fieldId").selector.selector; //获取人员选择框对象
  124. * var options = selector.options; //获取人员选择框的选项
  125. */
  126. options.style = 'v10';
  127. this.selector = new MWF.O2Selector(this.form.app.content, options);
  128. }
  129. }
  130. }.bind(this), 100 )
  131. }else{
  132. var options = this.getOptions();
  133. if(options){
  134. if( this.selector && this.selector.loading ) {
  135. }else if( this.selector && this.selector.selector && this.selector.selector.active ){
  136. }else {
  137. options.style = 'v10';
  138. options.tabStyle = 'v10';
  139. this.selector = new MWF.O2Selector(this.form.app.content, options);
  140. }
  141. }
  142. }
  143. },
  144. selectOnComplete: function(items){
  145. var array = [];
  146. items.each(function(item){
  147. array.push(item.data);
  148. }.bind(this));
  149. var simple = this.json.storeRange === "simple";
  150. this.checkEmpower( array, function( data ){
  151. var values = [];
  152. data.each(function(d){
  153. values.push(MWF.org.parseOrgData(d, true, simple));
  154. }.bind(this));
  155. if (this.json.isInput){
  156. this.addData(values);
  157. }else{
  158. this.setData(values, true);
  159. }
  160. //this._setBusinessData(values);
  161. this.validationMode();
  162. this.validation();
  163. var p = this.getValue();
  164. if (p.then){
  165. p.then(function(){
  166. if (this.node._props.validityBlur){
  167. this.node.checkValidity();
  168. }
  169. this.node.dispatchEvent(new MouseEvent('change'));
  170. this.fireEvent("select");
  171. }.bind(this), function(){});
  172. }else{
  173. if (this.node._props.validityBlur){
  174. this.node.checkValidity();
  175. }
  176. this.node.dispatchEvent(new MouseEvent('change'));
  177. this.fireEvent("select");
  178. }
  179. }.bind(this))
  180. },
  181. __setData: function(data, fireChange){
  182. var old = this.getInputData();
  183. this._setBusinessData(data);
  184. debugger;
  185. this.node.value = data;
  186. if (fireChange && old!==data) this.fireEvent("change");
  187. this.moduleValueAG = null;
  188. },
  189. __setValue: function (value) {
  190. this.moduleValueAG = null;
  191. this._setBusinessData(value);
  192. // this.node.set('value', value || '');
  193. this.node.value = value.map(v=>(v.distinguishedName || v)).join(', ');
  194. this.fieldModuleLoaded = true;
  195. return value;
  196. },
  197. getInputData: function () {
  198. return this.node.value;
  199. },
  200. notValidationMode: function (text) {
  201. this.validationText = text;
  202. this.node.checkValidity();
  203. },
  204. validationMode: function () {
  205. this.validationText = '';
  206. this.node.unInvalidStyle();
  207. },
  208. _setValue: function(value){
  209. var flag = false;
  210. if (typeOf(value)!=="array") value = (!!value) ? [value] : [];
  211. this.__setValue(value);
  212. return value;
  213. }
  214. });