select_user_tools.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. var _activiti_projectUser;
  2. function selectProjectUser(title, callback, width, height) {//根据projectUser选择用户
  3. $.post('userActivitiController.do?isProjectUser', {}, function (isProjectUser) {
  4. var url = 'activitiLeaveController.do?userWorkflow';
  5. if (isProjectUser == 'true') {
  6. url = 'correctionController.do?userWorkflow&type=leave&_checkbox=false';//包括兼容机构,不包括2级部门
  7. }
  8. ;
  9. selectUser(title, url, callback, width, height);
  10. })
  11. }
  12. function selectAllUser(title, callback, checkbox, width, height) {//所有用户,不包括离职用户
  13. if (!checkbox) {
  14. checkbox = 'false';
  15. }
  16. if (!width) {
  17. width = '700px';
  18. }
  19. if (!height) {
  20. height = '550px';
  21. }
  22. var url = 'publicpageController.do?userSelect&checkbox=' + checkbox;
  23. selectUser(title, url, callback, width, height);
  24. }
  25. function selectUserByDepart(departId, title, callback, width, height) {//根据部门选择用户
  26. if (!departId) {
  27. departId = $('#departId').val();
  28. if (!departId) {
  29. tip('请先选择组织机构');
  30. return;
  31. }
  32. }
  33. var url = 'publicpageController.do?userSelectSameAndSubDepart&departid=' + departId;
  34. selectUser(title, url, callback, width, height);
  35. }
  36. function selectAllUserByDepart(departId, title, callback, width, height) {//根据部门选择用户,包括离职人员
  37. if (!departId) {
  38. departId = $('#departId').val();
  39. if (!departId) {
  40. tip('请先选择组织机构');
  41. return;
  42. }
  43. }
  44. var url = 'publicpageController.do?userSelectSameAndSubDepart&departid=' + departId + "&includeLeave=true";
  45. selectUser(title, url, callback, width, height);
  46. }
  47. function selectUserByLoginUser(title, callback, width, height) {//根据登录用户选择所在部门用户
  48. var url = 'publicpageController.do?userSelectSameAndSubDepart&includeLeave=false';
  49. selectUser(title, url, callback, width, height);
  50. }
  51. function selectUser(title, url, callback, width, height) {
  52. if (!width) {
  53. width = '600px';
  54. }
  55. if (!height) {
  56. height = '350px';
  57. }
  58. if (!title) {
  59. title = "员工列表";
  60. }
  61. var _selectDialog = $.dialog({
  62. content: 'url:' + url
  63. , zIndex: getzIndex()
  64. , title: title, lock: true, width: width, height: height, opacity: 0.4, button: [
  65. {
  66. name: '确定', callback: function () {
  67. var iframe = _selectDialog.iframe.contentWindow;
  68. var selectedRows = iframe.getSelectedRow();
  69. if (selectedRows.length == 0) {
  70. iframe.tip('请选择员工');
  71. return false;
  72. }
  73. var one = selectedRows[0];
  74. var userid = one.id;
  75. var realName = one.realName;
  76. // 获取员工时,同时获取科室信息
  77. var orgCode = one.orgIds;
  78. //科室信息写入到页面
  79. $('#sysOrgCode').val(orgCode);
  80. $('#userid').val(userid);
  81. $('#realName').val(realName);
  82. if (callback) {
  83. callback(selectedRows);
  84. }
  85. }, focus: true
  86. },
  87. {
  88. name: '取消', callback: function () {
  89. }
  90. }
  91. ]
  92. }).zindex();
  93. }
  94. function clearUser(id, name) {
  95. if (!id) {
  96. id = "userid";
  97. }
  98. if (!name) {
  99. name = "realName";
  100. }
  101. $('#' + id).val('');
  102. $('#' + name).val('');
  103. }
  104. function selectUserDep(title, callback, width, height) {//选择用户组织结构 ,包括兼容机构
  105. var url = 'userActivitiDataController.do?depSelect';
  106. selectDep(title, url, callback, width, height);
  107. }
  108. function selectAllDepCheckbox(title, callback, width, height) {//选择所有组织结构
  109. var url = 'dialogDealController.do?projectDepartTableAllCheckbox&ids=';
  110. selectDep(title, url, function (rows) {
  111. var depIds = new Array();
  112. var depNames = new Array();
  113. for (var i = 0; i < rows.length; i++) {
  114. var one = rows[i];
  115. var depId = one.id;
  116. var depName = one.departName;
  117. depIds.push(depId);
  118. depNames.push(depName);
  119. }
  120. $('#departId').val(depIds.join(','));
  121. $('#depName').val(depNames.join(','));
  122. if (callback) {
  123. callback(rows);
  124. }
  125. }, width, height);
  126. }
  127. function selectAllDep(title, callback, width, height) {//选择所有组织结构
  128. //userWageController.do?projectDepartTableAll 财务的
  129. //var url='dialogDealController.do?projectDepartTablePartChild'; 根据登录用户选择部门,包括3级部门
  130. //publicpageController.do?projectSelect 项目 不包含部门
  131. var url = 'dialogDealController.do?projectDepartTableAll&ids=';
  132. selectDep(title, url, callback, width, height);
  133. }
  134. function clearDep(depId, depName) {
  135. if (!depId) {
  136. depId = "departId";
  137. }
  138. if (!depName) {
  139. depName = "depName";
  140. }
  141. $('#departId').val('');
  142. $('#depName').val('');
  143. }
  144. function selectDep(title, url, callback, width, height) {
  145. if (!width) {
  146. width = '600px';
  147. }
  148. if (!height) {
  149. height = '350px';
  150. }
  151. if (!title) {
  152. title = '组织机构列表';
  153. }
  154. // 'url:userActivitiDataController.do?depSelect'
  155. var _selectDialog = $.dialog({
  156. content: 'url:' + url
  157. , zIndex: getzIndex()
  158. , title: title, lock: true, width: width, height: height, opacity: 0.4, button: [
  159. {
  160. name: '确定', callback: function () {
  161. var iframe = _selectDialog.iframe.contentWindow;
  162. var selectedRows = iframe.getSelectRows();
  163. if (selectedRows.length == 0) {
  164. iframe.tip('请选择组织机构');
  165. return false;
  166. }
  167. var one = selectedRows[0];
  168. var depId = one.id;
  169. var depName = one.departName;
  170. $('#departId').val(depId);
  171. $('#depName').val(depName);
  172. if (callback) {
  173. callback(selectedRows);
  174. }
  175. }, focus: true
  176. },
  177. {
  178. name: '取消', callback: function () {
  179. }
  180. }
  181. ]
  182. }).zindex();
  183. return _selectDialog;
  184. }
  185. function selectPost(callback) {//选择岗位
  186. var orgIds = $("#postId").val();
  187. var url = 'projectPostDetailController.do?postZTree&orgIds=' + orgIds;
  188. _openDialog(url, '岗位类型选择', function (iframe) {
  189. var treeObj = iframe.$.fn.zTree.getZTreeObj("departSelect");
  190. var nodes = treeObj.getCheckedNodes(true);
  191. var ids = new Array();
  192. var names = new Array();
  193. if (nodes.length > 0) {
  194. for (var i = 0; i < nodes.length; i++) {
  195. var node = nodes[i];
  196. ids.push(node.id);
  197. names.push(node.name);
  198. }
  199. }
  200. $("#postId").val(ids.join(','));
  201. $("#postName").val(names.join(','));
  202. if (callback) {
  203. callback(ids, names);
  204. }
  205. });
  206. }
  207. function selectDepPost(departId, callback) {//选择部门对应岗位,这里的postId跟原来不一样
  208. if (!departId) {
  209. departId = $('#departId').val();
  210. if (!departId) {
  211. tip('请选择组织机构');
  212. return;
  213. }
  214. }
  215. var orgIds = $("#postId").val();
  216. var url = 'userActivitiDataController.do?depPostSelect&orgIds=' + orgIds + "&departId=" + departId;
  217. _openDialog(url, '项目岗位选择', function (iframe) {
  218. var selectedRows = iframe.getSelectedRow();
  219. if (selectedRows.length == 0) {
  220. iframe.tip('请选择项目岗位');
  221. return false;
  222. }
  223. var one = selectedRows[0];
  224. var id = one.id;
  225. var name = one.ptjPostName;
  226. $("#postId").val(id);
  227. $("#postName").val(name);
  228. if (callback) {
  229. callback(selectedRows);
  230. }
  231. });
  232. }
  233. function selectLeafDuty(callback, width, height) {//选择职务,过滤非叶子节点
  234. var orgIds = $("#dutyId").val();
  235. var url = 'userActivitiDataController.do?leafDutySelect&orgIds=' + orgIds;
  236. _openDialog(url, '职务列表', function (iframe) {
  237. var selectedRows = iframe.getSelectedRow();
  238. if (selectedRows.length == 0) {
  239. iframe.tip('请选择职务');
  240. return false;
  241. }
  242. var one = selectedRows[0];
  243. var dutyId = one.id;
  244. var dutyName = one.dutiesName;
  245. $('#dutyId').val(dutyId);
  246. $('#dutyName').val(dutyName);
  247. if (callback) {
  248. callback(selectedRows);
  249. }
  250. });
  251. }
  252. function selectRelatedUnit(callback, width, height) {//选择供应商
  253. if (!height) height = '600px';
  254. var orgIds = $("#supplierId").val();
  255. var url = 'ordersController.do?selectReferUnits&classname=cn.com.lzt.relatedunits.entity.RelatedUnitsEntity&codefield=unitCode&namefield=unitName&orgIds=' + orgIds;
  256. _openDialog(url, '供应商列表', function (iframe) {
  257. var selectedRows = iframe.getSelectedRow();
  258. if (selectedRows.length == 0) {
  259. iframe.tip('请选供应商');
  260. return false;
  261. }
  262. var one = selectedRows[0];
  263. var supplierId = one.id;
  264. var supplierName = one.unitName;
  265. $('#supplierId').val(supplierId);
  266. $('#supplierName').val(supplierName);
  267. if (callback) {
  268. callback(selectedRows);
  269. }
  270. }, width, height);
  271. }
  272. function selectGoodsBySameName(params, callback, width, height) {//选择同名商品供应商
  273. if (!width) width = '800px';
  274. if (!height) height = '600px';
  275. params = params || {};
  276. var orgIds = params.orgIds;
  277. var initCategoryCode = params.initCategoryCode;
  278. var goodsName = params.goodsName
  279. var url = "ordersController.do?selectReferGoodsBySameName&classname=cn.com.lzt.goodsinfo.entity.TBGoodsInfoEntity&codefield=goodsCode&categoryfield=belongCategoryCode&categoryNamefield=belongCategoryName&namefield=goodsName&purchaseUnit=salesUnit&specification=specification&goodsDesc=goodsDesc&strEmpty=strEmpty" +
  280. "&initCategoryCode=" + initCategoryCode + "&goodsName=" + encodeURIComponent(goodsName);
  281. _openDialog(url, '商品列表', function (iframe) {
  282. var selectedRows = iframe.getSelectRows();
  283. if (selectedRows.length == 0) {
  284. iframe.tip('请选供应商');
  285. return false;
  286. }
  287. if (callback) {
  288. callback(selectedRows);
  289. }
  290. }, width, height);
  291. }
  292. function getUserInfo(userId) {
  293. var info;
  294. $.ajax({
  295. url: 'userActivitiDataController.do?userInfo'
  296. , data: {userId: userId}
  297. , dataType: 'json'
  298. , method: 'POST'
  299. , async: false
  300. , success: function (d) {
  301. info = d.obj;
  302. }
  303. });
  304. return info;
  305. }
  306. function clearPost() {
  307. $("#postId").val('');
  308. $("#postName").val('');
  309. }
  310. //选择服务合同
  311. function selectContract(callback, data, width, height) {
  312. var params = "";
  313. for (var i in data) {
  314. params += "&" + i + "=" + data[i];
  315. }
  316. var url = 'contractController.do?selectlist' + params;
  317. _openDialog(url, '选择合同', function (iframe) {
  318. var selectedRows = iframe.getSelectedRow();
  319. if (selectedRows.length == 0) {
  320. iframe.tip('请选择合同');
  321. return false;
  322. }
  323. var one = selectedRows[0];
  324. if (callback) {
  325. callback(one);
  326. }
  327. }, width, height);
  328. }
  329. function _openDialog(url, title, okCallback, width, height) {
  330. if (!width) {
  331. width = '500px';
  332. }
  333. if (!height) {
  334. height = '350px';
  335. }
  336. if (width == "100%") {
  337. width = window.top.document.body.offsetWidth;
  338. }
  339. if (height == "100%") {
  340. height = window.top.document.body.offsetHeight - 100;
  341. }
  342. var _selectDialog = $.dialog({
  343. content: 'url:' + url
  344. , zIndex: getzIndex()
  345. , title: title, lock: true, width: width, height: height, opacity: 0.4, button: [
  346. {
  347. name: '确定', callback: function () {
  348. var iframe = _selectDialog.iframe.contentWindow;
  349. if (okCallback) {
  350. var b = okCallback(iframe);
  351. return b;
  352. }
  353. }
  354. , focus: true
  355. },
  356. {
  357. name: '取消', callback: function () {
  358. }
  359. }
  360. ]
  361. }).zindex();
  362. return _selectDialog;
  363. }
  364. function _select(url, title, okCallback, width, height) {
  365. var dialog = _openDialog(url, title, function (iframe) {
  366. var selectedRows = iframe.getSelectedRow();
  367. if (selectedRows.length == 0) {
  368. iframe.tip('请至少选择一项');
  369. return false;
  370. }
  371. if (okCallback) {
  372. var b = okCallback(selectedRows);
  373. return b;
  374. }
  375. }, width, height);
  376. return dialog;
  377. }
  378. $(function () {
  379. if ($.Datatype) {
  380. $.Datatype.fix2 = function (val, obj, frm) {
  381. $(obj).val(parseFloat(val).toFixed(2));
  382. return true;
  383. }
  384. }
  385. });