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.
 
 
 
 
 
 

336 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. // 解绑微信
  224. $('#lr_cancelweixinbind').on('click', function () {
  225. var keyValue = $('#gridtable').jfGridValue('F_UserId');
  226. if (learun.checkrow(keyValue)) {
  227. learun.layerConfirm('是否确认要【解绑微信】!', function (res) {
  228. if (res) {
  229. learun.postForm(top.$.rootUrl + '/Home/CancelWeiXinBind', { keyValue: keyValue }, function (data) {
  230. refreshGirdData();
  231. });
  232. }
  233. });
  234. }
  235. });
  236. $("#lr_closeuser1").on('click', function () {
  237. learun.alert.success('禁用成功');
  238. })
  239. $("#lr_closeuser2").on('click', function () {
  240. learun.alert.success('禁用成功');
  241. })
  242. $("#lr_closeuser3").on('click', function () {
  243. learun.alert.success('禁用成功');
  244. })
  245. },
  246. inittree: function () {
  247. $('#companyTree').lrtree({
  248. url: top.$.rootUrl + '/LR_OrganizationModule/Company/GetTree',
  249. param: { parentId: '0' },
  250. nodeClick: page.treeNodeClick
  251. });
  252. $('#companyTree').lrtreeSet('setValue', '53298b7a-404c-4337-aa7f-80b2a4ca6681');
  253. },
  254. treeNodeClick: function (item) {
  255. companyId = item.id;
  256. $('#titleinfo').text(item.text);
  257. $('#department_select').lrselectRefresh({
  258. // 访问数据接口地址
  259. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=CdDeptInfo'
  260. });
  261. departmentId = '';
  262. page.search();
  263. },
  264. initGrid: function () {
  265. $('#gridtable').lrAuthorizeJfGrid({
  266. url: top.$.rootUrl + '/LR_OrganizationModule/User/GetPageList',
  267. headData: [
  268. { label: '账户', name: 'F_Account', width: 100, align: 'left' },
  269. { label: '姓名', name: 'F_RealName', width: 160, align: 'left' },
  270. { label: '手机', name: 'F_Mobile', width: 100, align: 'center' },
  271. {
  272. label: '系部', name: 'F_DepartmentId', width: 100, align: 'left',
  273. formatterAsync: function (callback, value, row, op, $cell) {
  274. learun.clientdata.getAsync('custmerData', {
  275. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdDeptInfo',
  276. key: value,
  277. keyId: 'deptno',
  278. callback: function (_data) {
  279. callback(_data['deptname']);
  280. }
  281. });
  282. }
  283. },
  284. {
  285. label: "状态", name: "F_EnabledMark", index: "F_EnabledMark", width: 50, align: "center",
  286. formatter: function (cellvalue) {
  287. if (cellvalue == 1) {
  288. return '<span class=\"label label-success\" style=\"cursor: pointer;\">正常</span>';
  289. } else if (cellvalue == 0) {
  290. return '<span class=\"label label-default\" style=\"cursor: pointer;\">禁用</span>';
  291. }
  292. }
  293. },
  294. {
  295. label: "最后登录时间", name: "F_UserId_Log", width: 200, align: "left", formatterAsync: function (callback, value, row) {
  296. learun.httpAsyncGet(top.$.rootUrl + '/LR_OrganizationModule/User/GetLastLoginTime?userId=' + value, function (res) {
  297. if (res.code == learun.httpCode.success) {
  298. callback(res.data);
  299. }
  300. });
  301. }
  302. },
  303. { label: "备注", name: "F_Description", index: "F_Description", width: 200, align: "left" }
  304. ],
  305. isPage: true,
  306. reloadSelected: true,
  307. mainId: 'F_UserId',
  308. isMultiselect: true
  309. });
  310. },
  311. search: function (param) {
  312. param = param || {};
  313. param.companyId = companyId;
  314. param.departmentId = departmentId;
  315. param.tp = "1";
  316. $('#gridtable').jfGridSet('reload', param);
  317. }
  318. };
  319. refreshGirdData = function () {
  320. var keyword = $('#txt_Keyword').val();
  321. page.search({ keyword: keyword });
  322. };
  323. page.init();
  324. }