Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

398 rader
17 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. // 解绑微信
  240. $('#lr_cancelweixinbind').on('click', function () {
  241. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  242. if (learun.checkrow(keyValue)) {
  243. learun.layerConfirm('是否确认要【解绑微信】!', function (res) {
  244. if (res) {
  245. learun.postForm(top.$.rootUrl + '/Home/CancelWeiXinBind', { keyValue: keyValue }, function (data) {
  246. refreshGirdData();
  247. });
  248. }
  249. });
  250. }
  251. });
  252. // 设置Ip过滤
  253. $('#lr_ipfilter').on('click', function () {
  254. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  255. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  256. if (learun.checkrow(keyValue)) {
  257. if (keyValue.indexOf(',') != -1) {
  258. learun.alert.warning('只能选择一条数据!');
  259. return;
  260. }
  261. learun.layerForm({
  262. id: 'filterIPIndex',
  263. title: 'TCP/IP 地址访问限制 - ' + selectedRow.F_RealName,
  264. url: top.$.rootUrl + '/LR_AuthorizeModule/FilterIP/Index?objectId=' + keyValue + '&objectType=Uesr',
  265. width: 600,
  266. height: 400,
  267. btn: null,
  268. callBack: function (id) { }
  269. });
  270. }
  271. });
  272. // 设置时间段过滤
  273. $('#lr_timefilter').on('click', function () {
  274. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  275. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  276. if (learun.checkrow(keyValue)) {
  277. if (keyValue.indexOf(',') != -1) {
  278. learun.alert.warning('只能选择一条数据!');
  279. return;
  280. }
  281. learun.layerForm({
  282. id: 'filterTimeForm',
  283. title: '时段访问过滤 - ' + selectedRow.F_RealName,
  284. url: top.$.rootUrl + '/LR_AuthorizeModule/FilterTime/Form?objectId=' + keyValue + '&objectType=Uesr',
  285. width: 610,
  286. height: 470,
  287. callBack: function (id) {
  288. return top[id].acceptClick();
  289. }
  290. });
  291. }
  292. });
  293. },
  294. inittree: function () {
  295. $('#companyTree').lrtree({
  296. url: top.$.rootUrl + '/LR_OrganizationModule/Company/GetTree',
  297. param: { parentId: '0' },
  298. nodeClick: page.treeNodeClick
  299. });
  300. $('#companyTree').lrtreeSet('setValue', '53298b7a-404c-4337-aa7f-80b2a4ca6681');
  301. },
  302. treeNodeClick: function (item) {
  303. companyId = item.id;
  304. $('#titleinfo').text(item.text);
  305. $('#department_select').lrselectRefresh({
  306. // 访问数据接口地址
  307. url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree',
  308. // 访问数据接口参数
  309. param: { companyId: companyId, parentId: '0' },
  310. });
  311. departmentId = '';
  312. page.search();
  313. },
  314. initGrid: function () {
  315. $('#gridtable').lrAuthorizeJfGrid({
  316. url: top.$.rootUrl + '/LR_OrganizationModule/User/GetPageList',
  317. headData: [
  318. { label: '账户', name: 'F_IdentityCardNo', width: 200, align: 'left' },
  319. //{ label: '账户', name: 'F_Account', width: 100, align: 'left' },
  320. { label: '姓名', name: 'F_RealName', width: 160, align: 'left' },
  321. { label: '手机', name: 'F_Mobile', width: 100, align: 'center' },
  322. {
  323. label: '部门', name: 'F_DepartmentId', width: 100, align: 'left',
  324. formatterAsync: function (callback, value, row) {
  325. learun.clientdata.getAsync('department', {
  326. key: value,
  327. callback: function (item) {
  328. callback(item.name);
  329. }
  330. });
  331. }
  332. },
  333. {
  334. label: '岗位', name: 'F_UserId', width: 250, align: 'left',
  335. formatterAsync: function (callback, value, row) {
  336. learun.httpAsyncGet(top.$.rootUrl + '/LR_AuthorizeModule/UserRelation/GetEntityNameByUserId?keyValue=' + value, function (res) {
  337. if (res.code == learun.httpCode.success) {
  338. callback(res.data);
  339. }
  340. });
  341. }
  342. },
  343. {
  344. label: "状态", name: "F_EnabledMark", index: "F_EnabledMark", width: 50, align: "center",
  345. formatter: function (cellvalue) {
  346. if (cellvalue == 1) {
  347. return '<span class=\"label label-success\" style=\"cursor: pointer;\">正常</span>';
  348. } else if (cellvalue == 0) {
  349. return '<span class=\"label label-default\" style=\"cursor: pointer;\">禁用</span>';
  350. }
  351. }
  352. },
  353. {
  354. label: "最后登录时间", name: "F_UserId_Log", width: 200, align: "left", formatterAsync: function (callback, value, row) {
  355. learun.httpAsyncGet(top.$.rootUrl + '/LR_OrganizationModule/User/GetLastLoginTime?userId=' + value, function (res) {
  356. if (res.code == learun.httpCode.success) {
  357. callback(res.data);
  358. }
  359. });
  360. }
  361. },
  362. { label: "备注", name: "F_Description", index: "F_Description", width: 200, align: "left" }
  363. ],
  364. isPage: true,
  365. rows: 100,
  366. reloadSelected: true,
  367. mainId: 'F_UserId',
  368. isMultiselect: true
  369. });
  370. },
  371. search: function (param) {
  372. param = param || {};
  373. param.companyId = companyId;
  374. param.departmentId = departmentId;
  375. param.tp = "0";
  376. $('#gridtable').jfGridSet('reload', param);
  377. }
  378. };
  379. refreshGirdData = function () {
  380. var keyword = $('#txt_Keyword').val();
  381. page.search({ keyword: keyword });
  382. };
  383. page.init();
  384. }