You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

381 lines
16 KiB

  1. /*
  2. * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  3. * Copyright (c) 2013-2018 北京泉江科技有限公司
  4. * 创建人:陈彬彬
  5. * 日 期:2017.03.22
  6. * 描 述:人员管理
  7. */
  8. var selectedRow;
  9. var refreshGirdData;
  10. var bootstrap = function ($, learun) {
  11. "use strict";
  12. var companyId = '';
  13. var departmentId = '';
  14. var page = {
  15. init: function () {
  16. page.inittree();
  17. page.initGrid();
  18. page.bind();
  19. },
  20. bind: function () {
  21. // 查询
  22. $('#btn_Search').on('click', function () {
  23. var keyword = $('#txt_Keyword').val();
  24. page.search({ keyword: keyword });
  25. });
  26. // 部门选择
  27. $('#department_select').lrselect({
  28. type: 'tree',
  29. placeholder: '请选择部门',
  30. // 是否允许搜索
  31. allowSearch: true,
  32. select: function (item) {
  33. if (!item || item.value == '-1') {
  34. departmentId = '';
  35. }
  36. else {
  37. departmentId = item.value;
  38. }
  39. page.search();
  40. }
  41. });
  42. // 刷新
  43. $('#lr_refresh').on('click', function () {
  44. location.reload();
  45. });
  46. // 新增
  47. $('#lr_add').on('click', function () {
  48. if (!companyId) {
  49. learun.alert.warning('请选择学校!');
  50. return false;
  51. }
  52. selectedRow = null;
  53. learun.layerForm({
  54. id: 'form',
  55. title: '添加账号',
  56. url: top.$.rootUrl + '/LR_OrganizationModule/User/Form?companyId=' + companyId,
  57. width: 750,
  58. height: 450,
  59. callBack: function (id) {
  60. return top[id].acceptClick(refreshGirdData);
  61. }
  62. });
  63. });
  64. // 编辑
  65. $('#lr_edit').on('click', function () {
  66. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  67. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  68. if (learun.checkrow(keyValue)) {
  69. if (keyValue.indexOf(',') != -1) {
  70. learun.alert.warning('只能选择一条数据!');
  71. return;
  72. }
  73. learun.layerForm({
  74. id: 'form',
  75. title: '编辑账号',
  76. url: top.$.rootUrl + '/LR_OrganizationModule/User/Form?companyId=' + companyId,
  77. width: 750,
  78. height: 450,
  79. callBack: function (id) {
  80. return top[id].acceptClick(refreshGirdData);
  81. }
  82. });
  83. }
  84. });
  85. // 删除
  86. $('#lr_delete').on('click', function () {
  87. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  88. if (learun.checkrow(keyValue)) {
  89. learun.layerConfirm('是否确认删除该项!', function (res) {
  90. if (res) {
  91. learun.deleteForm(top.$.rootUrl + '/LR_OrganizationModule/User/DeleteForm', { keyValue: keyValue }, function () {
  92. refreshGirdData();
  93. });
  94. }
  95. });
  96. }
  97. });
  98. // 用户数据导出
  99. $('#lr_export').on('click', function () {
  100. location.href = top.$.rootUrl + "/LR_OrganizationModule/User/ExportUserList";
  101. });
  102. // 启用
  103. $('#lr_enabled').on('click', function () {
  104. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  105. if (learun.checkrow(keyValue)) {
  106. if (keyValue.indexOf(',') != -1) {
  107. learun.alert.warning('只能选择一条数据!');
  108. return;
  109. }
  110. learun.layerConfirm('是否确认要【启用】账号!', function (res) {
  111. if (res) {
  112. learun.postForm(top.$.rootUrl + '/LR_OrganizationModule/User/UpdateState', { keyValue: keyValue, state: 1 }, function () {
  113. refreshGirdData();
  114. });
  115. }
  116. });
  117. }
  118. });
  119. // 禁用
  120. $('#lr_disabled').on('click', function () {
  121. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  122. if (learun.checkrow(keyValue)) {
  123. if (keyValue.indexOf(',') != -1) {
  124. learun.alert.warning('只能选择一条数据!');
  125. return;
  126. }
  127. learun.layerConfirm('是否确认要【禁用】账号!', function (res) {
  128. if (res) {
  129. learun.postForm(top.$.rootUrl + '/LR_OrganizationModule/User/UpdateState', { keyValue: keyValue, state: 0 }, function () {
  130. refreshGirdData();
  131. });
  132. }
  133. });
  134. }
  135. });
  136. // 重置账号
  137. $('#lr_resetpassword').on('click', function () {
  138. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  139. if (learun.checkrow(keyValue)) {
  140. learun.layerConfirm('是否确认要【重置密码】!', function (res) {
  141. if (res) {
  142. learun.postForm(top.$.rootUrl + '/LR_OrganizationModule/User/ResetPassword', { keyValue: keyValue }, function () {
  143. refreshGirdData();
  144. });
  145. }
  146. });
  147. }
  148. });
  149. // 重置账号(八位)
  150. $('#lr_resetpasswordeight').on('click', function () {
  151. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  152. if (learun.checkrow(keyValue)) {
  153. learun.layerConfirm('是否确认要【重置密码(八位)】!', function (res) {
  154. if (res) {
  155. learun.postForm(top.$.rootUrl + '/LR_OrganizationModule/User/ResetPasswordEight', { keyValue: keyValue }, function () {
  156. refreshGirdData();
  157. });
  158. }
  159. });
  160. }
  161. });
  162. // 功能授权
  163. $('#lr_authorize').on('click', function () {
  164. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  165. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  166. if (learun.checkrow(keyValue)) {
  167. if (keyValue.indexOf(',') != -1) {
  168. learun.alert.warning('只能选择一条数据!');
  169. return;
  170. }
  171. learun.layerForm({
  172. id: 'authorizeForm',
  173. title: '功能授权 - ' + selectedRow.F_RealName,
  174. url: top.$.rootUrl + '/LR_AuthorizeModule/Authorize/Form?objectId=' + keyValue + '&objectType=2',
  175. width: 550,
  176. height: 690,
  177. btn: null
  178. });
  179. }
  180. });
  181. // 移动功能授权
  182. $('#lr_appauthorize').on('click', function () {
  183. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  184. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  185. if (learun.checkrow(keyValue)) {
  186. if (keyValue.indexOf(',') != -1) {
  187. learun.alert.warning('只能选择一条数据!');
  188. return;
  189. }
  190. learun.layerForm({
  191. id: 'appAuthorizeForm',
  192. title: '移动功能授权 - ' + selectedRow.F_RealName,
  193. url: top.$.rootUrl + '/LR_AuthorizeModule/Authorize/AppForm?objectId=' + keyValue + '&objectType=2',
  194. width: 550,
  195. height: 690,
  196. callBack: function (id) {
  197. return top[id].acceptClick();
  198. }
  199. });
  200. }
  201. });
  202. // 数据授权
  203. $('#lr_dataauthorize').on('click', function () {
  204. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  205. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  206. if (learun.checkrow(keyValue)) {
  207. if (keyValue.indexOf(',') != -1) {
  208. learun.alert.warning('只能选择一条数据!');
  209. return;
  210. }
  211. learun.layerForm({
  212. id: 'dataAuthorizeForm',
  213. title: '数据授权 - ' + selectedRow.F_RealName,
  214. url: top.$.rootUrl + '/LR_AuthorizeModule/DataAuthorize/Index?objectId=' + keyValue + '&objectType=2',
  215. width: 1100,
  216. height: 700,
  217. maxmin: true,
  218. btn: null
  219. });
  220. }
  221. });
  222. $('#lr_roleinfo').on('click', function () {
  223. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  224. if (learun.checkrow(keyValue)) {
  225. if (keyValue.indexOf(',') != -1) {
  226. learun.alert.warning('只能选择一条数据!');
  227. return;
  228. }
  229. learun.layerForm({
  230. id: 'form_viewrole',
  231. title: '查看角色',
  232. url: top.$.rootUrl + '/LR_OrganizationModule/User/LookForm?objectId=' + keyValue,
  233. width: 800,
  234. height: 520,
  235. btn: null
  236. });
  237. }
  238. });
  239. // 设置Ip过滤
  240. $('#lr_ipfilter').on('click', function () {
  241. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  242. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  243. if (learun.checkrow(keyValue)) {
  244. if (keyValue.indexOf(',') != -1) {
  245. learun.alert.warning('只能选择一条数据!');
  246. return;
  247. }
  248. learun.layerForm({
  249. id: 'filterIPIndex',
  250. title: 'TCP/IP 地址访问限制 - ' + selectedRow.F_RealName,
  251. url: top.$.rootUrl + '/LR_AuthorizeModule/FilterIP/Index?objectId=' + keyValue + '&objectType=Uesr',
  252. width: 600,
  253. height: 400,
  254. btn: null,
  255. callBack: function (id) { }
  256. });
  257. }
  258. });
  259. // 设置时间段过滤
  260. $('#lr_timefilter').on('click', function () {
  261. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  262. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  263. if (learun.checkrow(keyValue)) {
  264. if (keyValue.indexOf(',') != -1) {
  265. learun.alert.warning('只能选择一条数据!');
  266. return;
  267. }
  268. learun.layerForm({
  269. id: 'filterTimeForm',
  270. title: '时段访问过滤 - ' + selectedRow.F_RealName,
  271. url: top.$.rootUrl + '/LR_AuthorizeModule/FilterTime/Form?objectId=' + keyValue + '&objectType=Uesr',
  272. width: 610,
  273. height: 470,
  274. callBack: function (id) {
  275. return top[id].acceptClick();
  276. }
  277. });
  278. }
  279. });
  280. },
  281. inittree: function () {
  282. $('#companyTree').lrtree({
  283. url: top.$.rootUrl + '/LR_OrganizationModule/Company/GetTree',
  284. param: { parentId: '0' },
  285. nodeClick: page.treeNodeClick
  286. });
  287. $('#companyTree').lrtreeSet('setValue', '53298b7a-404c-4337-aa7f-80b2a4ca6681');
  288. },
  289. treeNodeClick: function (item) {
  290. companyId = item.id;
  291. $('#titleinfo').text(item.text);
  292. $('#department_select').lrselectRefresh({
  293. // 访问数据接口地址
  294. url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree',
  295. // 访问数据接口参数
  296. param: { companyId: companyId, parentId: '0' },
  297. });
  298. departmentId = '';
  299. page.search();
  300. },
  301. initGrid: function () {
  302. $('#gridtable').lrAuthorizeJfGrid({
  303. url: top.$.rootUrl + '/LR_OrganizationModule/User/GetPageList',
  304. headData: [
  305. { label: '账户', name: 'F_Account', width: 100, align: 'left' },
  306. { label: '姓名', name: 'F_RealName', width: 160, align: 'left' },
  307. { label: '手机', name: 'F_Mobile', width: 100, align: 'center' },
  308. {
  309. label: '部门', name: 'F_DepartmentId', width: 100, align: 'left',
  310. formatterAsync: function (callback, value, row) {
  311. learun.clientdata.getAsync('department', {
  312. key: value,
  313. callback: function (item) {
  314. callback(item.name);
  315. }
  316. });
  317. }
  318. },
  319. {
  320. label: '岗位', name: 'F_UserId', width: 250, align: 'left',
  321. formatterAsync: function (callback, value, row) {
  322. learun.httpAsyncGet(top.$.rootUrl + '/LR_AuthorizeModule/UserRelation/GetEntityNameByUserId?keyValue=' + value, function (res) {
  323. if (res.code == learun.httpCode.success) {
  324. callback(res.data);
  325. }
  326. });
  327. }
  328. },
  329. {
  330. label: "状态", name: "F_EnabledMark", index: "F_EnabledMark", width: 50, align: "center",
  331. formatter: function (cellvalue) {
  332. if (cellvalue == 1) {
  333. return '<span class=\"label label-success\" style=\"cursor: pointer;\">正常</span>';
  334. } else if (cellvalue == 0) {
  335. return '<span class=\"label label-default\" style=\"cursor: pointer;\">禁用</span>';
  336. }
  337. }
  338. },
  339. {
  340. label: "最后登录时间", name: "F_UserId_Log", width: 200, align: "left", formatterAsync: function (callback, value, row) {
  341. learun.httpAsyncGet(top.$.rootUrl + '/LR_OrganizationModule/User/GetLastLoginTime?userId=' + value, function (res) {
  342. if (res.code == learun.httpCode.success) {
  343. callback(res.data);
  344. }
  345. });
  346. }
  347. },
  348. { label: "备注", name: "F_Description", index: "F_Description", width: 200, align: "left" }
  349. ],
  350. isPage: true,
  351. reloadSelected: true,
  352. mainId: 'F_UserId',
  353. isMultiselect: true
  354. });
  355. },
  356. search: function (param) {
  357. param = param || {};
  358. param.companyId = companyId;
  359. param.departmentId = departmentId;
  360. param.tp = "0";
  361. $('#gridtable').jfGridSet('reload', param);
  362. }
  363. };
  364. refreshGirdData = function () {
  365. var keyword = $('#txt_Keyword').val();
  366. page.search({ keyword: keyword });
  367. };
  368. page.init();
  369. }