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.
 
 
 
 
 
 

322 lines
14 KiB

  1. var selectedRow;
  2. var refreshGirdData;
  3. var bootstrap = function ($, learun) {
  4. "use strict";
  5. var companyId = '';
  6. var departmentId = '';
  7. var page = {
  8. init: function () {
  9. page.inittree();
  10. page.initGrid();
  11. page.bind();
  12. },
  13. bind: function () {
  14. // 查询
  15. $('#btn_Search').on('click', function () {
  16. var keyword = $('#txt_Keyword').val();
  17. page.search({ keyword: keyword });
  18. });
  19. // 系选择
  20. $('#department_select').lrselect({
  21. value: "deptno",
  22. text: "deptname",
  23. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=CdDeptInfo',
  24. placeholder: '请选择系',
  25. // 是否允许搜索
  26. allowSearch: true,
  27. select: function (item) {
  28. if (!item || item.value == '-1') {
  29. departmentId = '';
  30. }
  31. else {
  32. departmentId = item.deptno;
  33. }
  34. page.search();
  35. }
  36. });
  37. // 刷新
  38. $('#lr_refresh').on('click', function () {
  39. location.reload();
  40. });
  41. // 新增
  42. $('#lr_add').on('click', function () {
  43. if (!companyId) {
  44. learun.alert.warning('请选择公司!');
  45. return false;
  46. }
  47. selectedRow = null;
  48. learun.layerForm({
  49. id: 'form',
  50. title: '添加账号',
  51. url: top.$.rootUrl + '/LR_OrganizationModule/User/Form?companyId=' + companyId,
  52. width: 750,
  53. height: 450,
  54. callBack: function (id) {
  55. return top[id].acceptClick(refreshGirdData);
  56. }
  57. });
  58. });
  59. // 编辑
  60. $('#lr_edit').on('click', function () {
  61. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  62. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  63. if (learun.checkrow(keyValue)) {
  64. if (keyValue.indexOf(',') != -1) {
  65. learun.alert.warning('只能选择一条数据!');
  66. return;
  67. }
  68. learun.layerForm({
  69. id: 'form',
  70. title: '编辑账号',
  71. url: top.$.rootUrl + '/LR_OrganizationModule/User/Form?companyId=' + companyId,
  72. width: 750,
  73. height: 450,
  74. callBack: function (id) {
  75. return top[id].acceptClick(refreshGirdData);
  76. }
  77. });
  78. }
  79. });
  80. // 删除
  81. $('#lr_delete').on('click', function () {
  82. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  83. if (learun.checkrow(keyValue)) {
  84. learun.layerConfirm('是否确认删除该项!', function (res) {
  85. if (res) {
  86. learun.deleteForm(top.$.rootUrl + '/LR_OrganizationModule/User/DeleteForm', { keyValue: keyValue }, function () {
  87. refreshGirdData();
  88. });
  89. }
  90. });
  91. }
  92. });
  93. // 用户数据导出
  94. $('#lr_export').on('click', function () {
  95. location.href = top.$.rootUrl + "/LR_OrganizationModule/User/ExportUserListOfStudent";
  96. });
  97. // 启用
  98. $('#lr_enabled').on('click', function () {
  99. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  100. if (learun.checkrow(keyValue)) {
  101. if (keyValue.indexOf(',') != -1) {
  102. learun.alert.warning('只能选择一条数据!');
  103. return;
  104. }
  105. learun.layerConfirm('是否确认要【启用】账号!', function (res) {
  106. if (res) {
  107. learun.postForm(top.$.rootUrl + '/LR_OrganizationModule/User/UpdateState', { keyValue: keyValue, state: 1 }, function () {
  108. refreshGirdData();
  109. });
  110. }
  111. });
  112. }
  113. });
  114. // 禁用
  115. $('#lr_disabled').on('click', function () {
  116. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  117. if (learun.checkrow(keyValue)) {
  118. if (keyValue.indexOf(',') != -1) {
  119. learun.alert.warning('只能选择一条数据!');
  120. return;
  121. }
  122. learun.layerConfirm('是否确认要【禁用】账号!', function (res) {
  123. if (res) {
  124. learun.postForm(top.$.rootUrl + '/LR_OrganizationModule/User/UpdateState', { keyValue: keyValue, state: 0 }, function () {
  125. refreshGirdData();
  126. });
  127. }
  128. });
  129. }
  130. });
  131. // 重置账号
  132. $('#lr_resetpassword').on('click', function () {
  133. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  134. if (learun.checkrow(keyValue)) {
  135. learun.layerConfirm('是否确认要【重置密码】!', function (res) {
  136. if (res) {
  137. learun.postForm(top.$.rootUrl + '/LR_OrganizationModule/User/ResetPassword', { keyValue: keyValue }, function () {
  138. refreshGirdData();
  139. });
  140. }
  141. });
  142. }
  143. });
  144. // 重置账号(八位)
  145. $('#lr_resetpasswordeight').on('click', function () {
  146. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  147. if (learun.checkrow(keyValue)) {
  148. learun.layerConfirm('是否确认要【重置密码(八位)】!', function (res) {
  149. if (res) {
  150. learun.postForm(top.$.rootUrl + '/LR_OrganizationModule/User/ResetPasswordEight', { keyValue: keyValue }, function () {
  151. refreshGirdData();
  152. });
  153. }
  154. });
  155. }
  156. });
  157. // 功能授权
  158. $('#lr_authorize').on('click', function () {
  159. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  160. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  161. if (learun.checkrow(keyValue)) {
  162. if (keyValue.indexOf(',') != -1) {
  163. learun.alert.warning('只能选择一条数据!');
  164. return;
  165. }
  166. learun.layerForm({
  167. id: 'authorizeForm',
  168. title: '功能授权 - ' + selectedRow.F_RealName,
  169. url: top.$.rootUrl + '/LR_AuthorizeModule/Authorize/Form?objectId=' + keyValue + '&objectType=2',
  170. width: 550,
  171. height: 690,
  172. btn: null
  173. });
  174. }
  175. });
  176. // 移动功能授权
  177. $('#lr_appauthorize').on('click', function () {
  178. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  179. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  180. if (learun.checkrow(keyValue)) {
  181. if (keyValue.indexOf(',') != -1) {
  182. learun.alert.warning('只能选择一条数据!');
  183. return;
  184. }
  185. learun.layerForm({
  186. id: 'appAuthorizeForm',
  187. title: '移动功能授权 - ' + selectedRow.F_RealName,
  188. url: top.$.rootUrl + '/LR_AuthorizeModule/Authorize/AppForm?objectId=' + keyValue + '&objectType=2',
  189. width: 550,
  190. height: 690,
  191. callBack: function (id) {
  192. return top[id].acceptClick();
  193. }
  194. });
  195. }
  196. });
  197. // 数据授权
  198. $('#lr_dataauthorize').on('click', function () {
  199. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  200. selectedRow = $('#gridtable').jfGridGet('rowdata')[0];
  201. if (learun.checkrow(keyValue)) {
  202. if (keyValue.indexOf(',') != -1) {
  203. learun.alert.warning('只能选择一条数据!');
  204. return;
  205. }
  206. learun.layerForm({
  207. id: 'dataAuthorizeForm',
  208. title: '数据授权 - ' + selectedRow.F_RealName,
  209. url: top.$.rootUrl + '/LR_AuthorizeModule/DataAuthorize/Index?objectId=' + keyValue + '&objectType=2',
  210. width: 1100,
  211. height: 700,
  212. maxmin: true,
  213. btn: null
  214. });
  215. }
  216. });
  217. //学生角色批量添加
  218. $("#lr_addRelation").on('click', function () {
  219. learun.getForm(top.$.rootUrl + '/LR_OrganizationModule/User/ResetStudentRelation', function () {
  220. refreshGirdData();
  221. });
  222. });
  223. $("#lr_closeuser1").on('click', function() {
  224. learun.alert.success('禁用成功');
  225. })
  226. $("#lr_closeuser2").on('click', function() {
  227. learun.alert.success('禁用成功');
  228. })
  229. $("#lr_closeuser3").on('click', function() {
  230. learun.alert.success('禁用成功');
  231. })
  232. },
  233. inittree: function () {
  234. $('#companyTree').lrtree({
  235. url: top.$.rootUrl + '/LR_OrganizationModule/Company/GetTree',
  236. param: { parentId: '0' },
  237. nodeClick: page.treeNodeClick
  238. });
  239. $('#companyTree').lrtreeSet('setValue', '53298b7a-404c-4337-aa7f-80b2a4ca6681');
  240. },
  241. treeNodeClick: function (item) {
  242. companyId = item.id;
  243. $('#titleinfo').text(item.text);
  244. $('#department_select').lrselectRefresh({
  245. // 访问数据接口地址
  246. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=CdDeptInfo'
  247. });
  248. departmentId = '';
  249. page.search();
  250. },
  251. initGrid: function () {
  252. $('#gridtable').lrAuthorizeJfGrid({
  253. url: top.$.rootUrl + '/LR_OrganizationModule/User/GetPageList',
  254. headData: [
  255. { label: '账户', name: 'F_Account', width: 100, align: 'left' },
  256. { label: '姓名', name: 'F_RealName', width: 160, align: 'left' },
  257. { label: '手机', name: 'F_Mobile', width: 100, align: 'center' },
  258. {
  259. label: '系部', name: 'F_DepartmentId', width: 100, align: 'left',
  260. formatterAsync: function (callback, value, row, op, $cell) {
  261. learun.clientdata.getAsync('custmerData', {
  262. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdDeptInfo',
  263. key: value,
  264. keyId: 'deptno',
  265. callback: function (_data) {
  266. callback(_data['deptname']);
  267. }
  268. });
  269. }
  270. },
  271. {
  272. label: "状态", name: "F_EnabledMark", index: "F_EnabledMark", width: 50, align: "center",
  273. formatter: function (cellvalue) {
  274. if (cellvalue == 1) {
  275. return '<span class=\"label label-success\" style=\"cursor: pointer;\">正常</span>';
  276. } else if (cellvalue == 0) {
  277. return '<span class=\"label label-default\" style=\"cursor: pointer;\">禁用</span>';
  278. }
  279. }
  280. },
  281. {
  282. label: "最后登录时间", name: "F_UserId_Log", width: 200, align: "left", formatterAsync: function (callback, value, row) {
  283. learun.httpAsyncGet(top.$.rootUrl + '/LR_OrganizationModule/User/GetLastLoginTime?userId=' + value, function (res) {
  284. if (res.code == learun.httpCode.success) {
  285. callback(res.data);
  286. }
  287. });
  288. }
  289. },
  290. { label: "备注", name: "F_Description", index: "F_Description", width: 200, align: "left" }
  291. ],
  292. isPage: true,
  293. reloadSelected: true,
  294. mainId: 'F_UserId',
  295. isMultiselect: true
  296. });
  297. },
  298. search: function (param) {
  299. param = param || {};
  300. param.companyId = companyId;
  301. param.departmentId = departmentId;
  302. param.tp = "1";
  303. $('#gridtable').jfGridSet('reload', param);
  304. }
  305. };
  306. refreshGirdData = function () {
  307. var keyword = $('#txt_Keyword').val();
  308. page.search({ keyword: keyword });
  309. };
  310. page.init();
  311. }