test.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. this.org = {
  2. //群组***************
  3. //查询下级群组--返回群组的对象数组
  4. //nested 布尔 true嵌套下级;false直接下级;默认false;
  5. listSubGroup: function(name, nested){
  6. getOrgActions();
  7. var data = {"groupList": getNameFlag(name)};
  8. var v = null;
  9. if (nested){
  10. orgActions.listSubGroupNested(data, function(json){v = json.data;}, null, false);
  11. }else{
  12. orgActions.listSubGroupDirect(data, function(json){v = json.data;}, null, false);
  13. }
  14. return v;
  15. },
  16. //查询上级群组--返回群组的对象数组
  17. //nested 布尔 true嵌套上级;false直接上级;默认false;
  18. listSupGroup:function(name, nested){
  19. getOrgActions();
  20. var data = {"groupList": getNameFlag(name)};
  21. var v = null;
  22. if (nested){
  23. orgActions.listSupGroupNested(data, function(json){v = json.data;}, null, false);
  24. }else{
  25. orgActions.listSupGroupDirect(data, function(json){v = json.data;}, null, false);
  26. }
  27. return v;
  28. },
  29. //人员所在群组(嵌套)--返回群组的对象数组
  30. listGroupWithPerson:function(name){
  31. getOrgActions();
  32. var data = {"personList": getNameFlag(name)};
  33. var v = null;
  34. orgActions.listGroupWithPerson(data, function(json){v = json.data;}, null, false);
  35. return v;
  36. },
  37. //群组是否拥有角色--返回true, false
  38. groupHasRole: function(name, role){
  39. getOrgActions();
  40. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  41. var data = {"group":nameFlag,"roleList":getNameFlag(role)};
  42. var v = false;
  43. orgActions.groupHasRole(data, function(json){v = json.data.value;}, null, false);
  44. return v;
  45. },
  46. //角色***************
  47. //获取角色--返回角色的对象数组
  48. getRole: function(name){
  49. getOrgActions();
  50. var data = {"roleList": getNameFlag(name)};
  51. var v = null;
  52. orgActions.listRole(data, function(json){v = json.data;}, null, false);
  53. return (v && v.length===1) ? v[0] : v;
  54. },
  55. //人员所有角色(嵌套)--返回角色的对象数组
  56. listRoleWithPerson:function(name){
  57. getOrgActions();
  58. var data = {"personList": getNameFlag(name)};
  59. var v = null;
  60. orgActions.listRoleWithPerson(data, function(json){v = json.data;}, null, false);
  61. return v;
  62. },
  63. //人员***************
  64. //人员是否拥有角色--返回true, false
  65. personHasRole: function(name, role){
  66. getOrgActions();
  67. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  68. var data = {"person":nameFlag,"roleList":getNameFlag(role)};
  69. var v = false;
  70. orgActions.personHasRole(data, function(json){v = json.data.value;}, null, false);
  71. return v;
  72. },
  73. //查询下级人员--返回人员的对象数组
  74. //nested 布尔 true嵌套下级;false直接下级;默认false;
  75. listSubPerson: function(name, nested){
  76. getOrgActions();
  77. var data = {"personList": getNameFlag(name)};
  78. var v = null;
  79. if (nested){
  80. orgActions.listPersonSubNested(data, function(json){v = json.data;}, null, false);
  81. }else{
  82. orgActions.listPersonSubDirect(data, function(json){v = json.data;}, null, false);
  83. }
  84. return v;
  85. },
  86. //查询上级人员--返回人员的对象数组
  87. //nested 布尔 true嵌套上级;false直接上级;默认false;
  88. listSupPerson: function(name, nested){
  89. getOrgActions();
  90. var data = {"personList": getNameFlag(name)};
  91. var v = null;
  92. if (nested){
  93. orgActions.listPersonSupNested(data, function(json){v = json.data;}, null, false);
  94. }else{
  95. orgActions.listPersonSupDirect(data, function(json){v = json.data;}, null, false);
  96. }
  97. return v;
  98. },
  99. //获取群组的所有人员--返回人员的对象数组
  100. listPersonWithGroup: function(name){
  101. getOrgActions();
  102. var data = {"groupList": getNameFlag(name)};
  103. var v = null;
  104. orgActions.listPersonWithGroup(data, function(json){v = json.data;}, null, false);
  105. return v;
  106. },
  107. //获取角色的所有人员--返回人员的对象数组
  108. listPersonWithRole: function(name){
  109. getOrgActions();
  110. var data = {"roleList": getNameFlag(name)};
  111. var v = null;
  112. orgActions.listPersonWithRole(data, function(json){v = json.data;}, null, false);
  113. return v;
  114. },
  115. //获取身份的所有人员--返回人员的对象数组
  116. listPersonWithIdentity: function(name){
  117. getOrgActions();
  118. var data = {"identityList": getNameFlag(name)};
  119. var v = null;
  120. orgActions.listPersonWithIdentity(data, function(json){v = json.data;}, null, false);
  121. return v;
  122. },
  123. //获取身份的所有人员--返回人员的对象数组或人员对象
  124. getPersonWithIdentity: function(name){
  125. getOrgActions();
  126. var data = {"identityList": getNameFlag(name)};
  127. var v = null;
  128. orgActions.listPersonWithIdentity(data, function(json){v = json.data;}, null, false);
  129. return (v && v.length===1) ? v[0] : v;
  130. },
  131. //查询组织成员的人员--返回人员的对象数组
  132. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  133. listPersonWithUnit: function(name, nested){
  134. getOrgActions();
  135. var data = {"unitList": getNameFlag(name)};
  136. var v = null;
  137. if (nested){
  138. orgActions.listPersonWithUnitNested(data, function(json){v = json.data;}, null, false);
  139. }else{
  140. orgActions.listPersonWithUnitDirect(data, function(json){v = json.data;}, null, false);
  141. }
  142. return v;
  143. },
  144. //人员属性************
  145. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  146. appendPersonAttribute: function(person, attr, values){
  147. getOrgActions();
  148. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  149. var data = {"attributeList":values,"name":attr,"person":personFlag};
  150. orgActions.appendPersonAttribute(data, function(json){
  151. if (json.data.value){
  152. if (success) success();
  153. }else{
  154. if (failure) failure(null, "", "append values failed");
  155. }
  156. }, function(xhr, text, error){
  157. if (failure) failure(xhr, text, error);
  158. }, false);
  159. },
  160. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  161. setPersonAttribute: function(person, attr, values){
  162. getOrgActions();
  163. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  164. var data = {"attributeList":values,"name":attr,"person":personFlag};
  165. orgActions.setPersonAttribute(data, function(json){
  166. if (json.data.value){
  167. if (success) success();
  168. }else{
  169. if (failure) failure(null, "", "append values failed");
  170. }
  171. }, function(xhr, text, error){
  172. if (failure) failure(xhr, text, error);
  173. }, false);
  174. },
  175. //获取人员属性值
  176. getPersonAttribute: function(person, attr){
  177. getOrgActions();
  178. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  179. var data = {"name":attr,"person":personFlag};
  180. var v = null;
  181. orgActions.getPersonAttribute(data, function(json){v = json.data.attributeList;}, null, false);
  182. return v;
  183. },
  184. //列出人员所有属性的名称
  185. listPersonAttributeName: function(name){
  186. getOrgActions();
  187. var data = {"personList":getNameFlag(name)};
  188. var v = null;
  189. orgActions.listPersonAttributeName(data, function(json){v = json.data.nameList;}, null, false);
  190. return v;
  191. },
  192. //列出人员的所有属性
  193. listPersonAllAttribute: function(name){
  194. getOrgActions();
  195. var data = {"personList":getNameFlag(name)};
  196. var v = null;
  197. orgActions.listPersonAllAttribute(data, function(json){v = json.data;}, null, false);
  198. return v;
  199. },
  200. //组织**********
  201. //获取组织
  202. getUnit: function(name){
  203. getOrgActions();
  204. var data = {"unitList":getNameFlag(name)};
  205. var v = null;
  206. orgActions.listUnit(data, function(json){v = json.data;}, null, false);
  207. return (v && v.length===1) ? v[0] : v;
  208. },
  209. //查询组织的下级--返回组织的对象数组
  210. //nested 布尔 true嵌套下级;false直接下级;默认false;
  211. listSubUnit: function(name, nested){
  212. getOrgActions();
  213. var data = {"unitList": getNameFlag(name)};
  214. var v = null;
  215. if (nested){
  216. orgActions.listUnitSubNested(data, function(json){v = json.data;}, null, false);
  217. }else{
  218. orgActions.listUnitSubDirect(data, function(json){v = json.data;}, null, false);
  219. }
  220. return v;
  221. },
  222. //查询组织的上级--返回组织的对象数组
  223. //nested 布尔 true嵌套上级;false直接上级;默认false;
  224. listSupUnit: function(name, nested){
  225. getOrgActions();
  226. var data = {"unitList": getNameFlag(name)};
  227. var v = null;
  228. if (nested){
  229. orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
  230. }else{
  231. orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
  232. }
  233. return v;
  234. },
  235. //根据个人身份获取组织
  236. //flag 数字 表示获取第几层的组织
  237. // 字符串 表示获取指定类型的组织
  238. // 空 表示获取直接所在的组织
  239. getUnitByIdentity: function(name, flag){
  240. getOrgActions();
  241. var getUnitMethod = "current";
  242. var v;
  243. if (flag){
  244. if (typeOf(flag)==="string") getUnitMethod = "type";
  245. if (typeOf(flag)==="number") getUnitMethod = "level";
  246. }
  247. switch (getUnitMethod){
  248. case "current":
  249. var data = {"identityList":getNameFlag(name)};
  250. orgActions.f(data, function(json){ v = json.data; }, null, false);
  251. break;
  252. case "type":
  253. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
  254. orgActions.getUnitWithIdentityAndType(data, function(json){ v = json.data; }, null, false);
  255. break;
  256. case "level":
  257. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
  258. orgActions.getUnitWithIdentityAndLevel(data, function(json){ v = json.data; }, null, false);
  259. break;
  260. }
  261. return v;
  262. },
  263. //列出身份所在组织的所有上级组织
  264. listAllSupUnitWithIdentity: function(name){
  265. getOrgActions();
  266. var data = {"identityList":getNameFlag(name)};
  267. var v = null;
  268. orgActions.listUnitSupNestedWithIdentity(data, function(json){v = json.data;}, null, false);
  269. return v;
  270. },
  271. //获取人员所在的所有组织
  272. listUnitWithPerson: function(name){
  273. getOrgActions();
  274. var data = {"personList":getNameFlag(name)};
  275. var v = null;
  276. orgActions.listUnitWithPerson(data, function(json){v = json.data;}, null, false);
  277. return v;
  278. },
  279. //列出人员所在组织的所有上级组织
  280. listAllSupUnitWithPerson: function(name){
  281. getOrgActions();
  282. var data = {"personList":getNameFlag(name)};
  283. var v = null;
  284. orgActions.listUnitSupNestedWithPerson(data, function(json){v = json.data;}, null, false);
  285. return v;
  286. },
  287. //根据组织属性,获取所有符合的组织
  288. listUnitWithAttribute: function(name, attribute){
  289. getOrgActions();
  290. var data = {"name":name,"attribute":attribute};
  291. var v = null;
  292. orgActions.listUnitWithAttribute(data, function(json){v = json.data;}, null, false);
  293. return v;
  294. },
  295. //根据组织职务,获取所有符合的组织
  296. listUnitWithDuty: function(name, id){
  297. getOrgActions();
  298. var data = {"name":name,"identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  299. var v = null;
  300. orgActions.listUnitWithDuty(data, function(json){v = json.data;}, null, false);
  301. return v;
  302. },
  303. //组织职务***********
  304. //获取指定的组织职务的身份
  305. getDuty: function(duty, id){
  306. getOrgActions();
  307. var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  308. var v = null;
  309. orgActions.getDuty(data, function(json){v = json.data;}, null, false);
  310. return v;
  311. },
  312. //获取身份的所有职务名称
  313. listDutyNameWithIdentity: function(name){
  314. getOrgActions();
  315. var data = {"identityList":getNameFlag(name)};
  316. var v = null;
  317. orgActions.listDutyNameWithIdentity(data, function(json){v = json.data.nameList;}, null, false);
  318. return v;
  319. },
  320. //获取组织的所有职务名称
  321. listDutyNameWithUnit: function(name){
  322. getOrgActions();
  323. var data = {"unitList":getNameFlag(name)};
  324. var v = null;
  325. orgActions.listDutyNameWithUnit(data, function(json){v = json.data.nameList;}, null, false);
  326. return v;
  327. },
  328. //获取组织的所有职务
  329. listUnitAllDuty: function(name){
  330. getOrgActions();
  331. var data = {"unitList":getNameFlag(name)};
  332. var v = null;
  333. orgActions.listUnitAllDuty(data, function(json){v = json.data;}, null, false);
  334. return v;
  335. },
  336. //列出顶层组织
  337. listTopUnit: function(){
  338. var action = MWF.Actions.get("x_organization_assemble_control");
  339. var v = null;
  340. action.listTopUnit(function(json){
  341. v = json.data;
  342. }, null, false);
  343. return v;
  344. },
  345. //组织属性**************
  346. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  347. appendUnitAttribute: function(unit, attr, values){
  348. getOrgActions();
  349. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  350. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  351. orgActions.appendUnitAttribute(data, function(json){
  352. if (json.data.value){
  353. if (success) success();
  354. }else{
  355. if (failure) failure(null, "", "append values failed");
  356. }
  357. }, function(xhr, text, error){
  358. if (failure) failure(xhr, text, error);
  359. }, false);
  360. },
  361. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  362. setUnitAttribute: function(unit, attr, values){
  363. getOrgActions();
  364. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  365. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  366. orgActions.setUnitAttribute(data, function(json){
  367. if (json.data.value){
  368. if (success) success();
  369. }else{
  370. if (failure) failure(null, "", "append values failed");
  371. }
  372. }, function(xhr, text, error){
  373. if (failure) failure(xhr, text, error);
  374. }, false);
  375. },
  376. //获取组织属性值
  377. getUnitAttribute: function(unit, attr){
  378. getOrgActions();
  379. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  380. var data = {"name":attr,"unit":unitFlag};
  381. var v = null;
  382. orgActions.getUnitAttribute(data, function(json){v = json.data.attributeList;}, null, false);
  383. return v;
  384. },
  385. //列出组织所有属性的名称
  386. listUnitAttributeName: function(name){
  387. getOrgActions();
  388. var data = {"unitList":getNameFlag(name)};
  389. var v = null;
  390. orgActions.listUnitAttributeName(data, function(json){v = json.data.nameList;}, null, false);
  391. return v;
  392. },
  393. //列出组织的所有属性
  394. listUnitAllAttribute: function(name){
  395. getOrgActions();
  396. var data = {"unitList":getNameFlag(name)};
  397. var v = null;
  398. orgActions.listUnitAllAttribute(data, function(json){v = json.data;}, null, false);
  399. return v;
  400. }
  401. };