Security.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. MWF.xDesktop.requireApp("process.Xform", "Select", null, false);
  2. /** @class Security 密级选择组件。
  3. * 启用密级标识功能后,此组件允许选择客体密级
  4. * @o2cn 下拉选择
  5. * @example
  6. * //可以在脚本中获取该组件
  7. * //方法1:
  8. * var field = this.form.get("fieldId"); //获取组件对象
  9. * //方法2
  10. * var field = this.target; //在组件本身的脚本中获取,比如事件脚本、默认值脚本、校验脚本等等
  11. *
  12. * field.hide(); //隐藏字段
  13. * var id = field.json.id; //获取字段标识
  14. * var flag = field.isEmpty(); //字段是否为空
  15. * @extends MWF.xApplication.process.Xform.$Selector
  16. * @o2category FormComponents
  17. * @o2range {Process|CMS|Portal}
  18. * @hideconstructor
  19. */
  20. MWF.xApplication.process.Xform.Security = MWF.APPSecurity = new Class(
  21. /** @lends MWF.xApplication.process.Xform.Select# */
  22. {
  23. Implements: [Events],
  24. Extends: MWF.APPSelect,
  25. iconStyle: "selectIcon",
  26. /**
  27. * 值改变时触发。可以通过this.event获取修改后的选择项(Dom对象)。
  28. * @event MWF.xApplication.process.Xform.Security#change
  29. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  30. */
  31. /**
  32. * @ignore
  33. * @member {Element} descriptionNode
  34. * @memberOf MWF.xApplication.process.Xform.Security#
  35. */
  36. initialize: function(node, json, form, options){
  37. this.node = $(node);
  38. this.node.store("module", this);
  39. this.json = json;
  40. this.form = form;
  41. this.field = true;
  42. this.fieldModuleLoaded = false;
  43. this.nodeHtml = this.node.get("html");
  44. },
  45. __showValue: function(node, value, optionItems){
  46. if (value){
  47. value = value.toString();
  48. if (typeOf(value)!=="array") value = [value];
  49. var texts = [];
  50. optionItems.each(function(item){
  51. var tmps = item.split("|");
  52. var t = tmps[0];
  53. var v = tmps[1] || t;
  54. if (v){
  55. if (value.indexOf(v)!=-1){
  56. texts.push(t);
  57. }
  58. }
  59. });
  60. node.set("text", texts.join(", "));
  61. }
  62. },
  63. _getOptions: function(async, refresh){
  64. if (this.securityLabelList) return Promise.resolve(this.securityLabelList);
  65. return o2.Actions.load("x_general_assemble_control").SecurityClearanceAction.object().then(function(json){
  66. var opts = ["|"];
  67. Object.keys(json.data).forEach(function(k){
  68. opts.push(k+"|"+json.data[k]);
  69. }.bind(this))
  70. this.securityLabelList = opts;
  71. return this.securityLabelList;
  72. }.bind(this));
  73. },
  74. _setBusinessData: function(v, id){
  75. var value = v.toInt();
  76. this.setBusinessDataById(value, id);
  77. // this.form.businessData.data.$work.objectSecurityClearance = value;
  78. },
  79. getInputData: function(){
  80. if( this.isReadonly()){
  81. return this._getBusinessData();
  82. }else{
  83. var ops = this.node.getElements("option");
  84. var value = [];
  85. ops.each(function(op){
  86. if (op.selected){
  87. var v = op.get("value");
  88. value.push(v || "");
  89. }
  90. });
  91. if (!value.length) return null;
  92. return (value.length==1) ? value[0].toInt() : value.toInt();
  93. }
  94. },
  95. addOption: function(){}
  96. });