realUser.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("realUserCtrl", ["$http", "$scope", "$timeout", function ($http, $scope, $timeout) {
  6. var self = this;
  7. self.webApiUrl2 = "";
  8. self.get_userid = $.cookie("GlWorkPlatform-userid");
  9. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  10. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno") || 1; ///接收传过来的第几页
  11. var postCfgJson = {
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. 'Authorization': "Bearer " + self.get_AccessToken
  15. }
  16. };
  17. self.search = {
  18. USERREALNAME: "",
  19. IDNO: "",
  20. BLOCK: "",
  21. BUILDING: "",
  22. DOORNO: "",
  23. HOUSENO: ""
  24. };
  25. ///声明
  26. self.noDataTip = 1;
  27. self.rows = []; //声明空数组
  28. self.pageno = 1; // 初始化 当前页为 1
  29. self.total_count = 0;
  30. self.itemsPerPage = 10;
  31. self.pageOptions = [10, 15, 20, 25, 30];
  32. // 初始化分页数据
  33. self.getData = function (pageno) {
  34. self.pageno = pageno;
  35. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  36. var set_like = "USERREALNAME=" + self.search.USERREALNAME + "&IDNO=" + self.search.IDNO + "&BLOCK=" + self.search.BLOCK + "&BUILDING=" + self.search.BUILDING + "&DOORNO=" + self.search.DOORNO + "&HOUSENO=" + self.search.HOUSENO;
  37. ///查询这条记录,生成数组,赋值给表
  38. //得到返回的数据的id
  39. let postSearchData = {
  40. "entity": "XG_USER",
  41. "fields": "",
  42. "orderby": "id desc",
  43. "eqparams": "",
  44. "likeparams": set_like,
  45. "dateparams": "",
  46. "inparams": "",
  47. "page": self.pageno,
  48. "pagesize": self.itemsPerPage
  49. }
  50. $http.post(apiurljs.backend + "Data/List", postSearchData, postCfgJson)
  51. .success(function (res) {
  52. if (sp.isval(res.items)) {
  53. self.noDataTip = 1;
  54. angular.forEach(res.items, function (item, index) {
  55. item.CREATETIME = sp.formatMinute(item.CREATETIME);
  56. if (item.STATUS == "1") {
  57. item.STATUS_SET = "已实名";
  58. } else if (item.STATUS == "-1") {
  59. item.STATUS_SET = "正在申请注销";
  60. } else {
  61. item.STATUS_SET = "未实名";
  62. }
  63. });
  64. self.rows = res.items;
  65. self.total_count = res.total;
  66. } else {
  67. self.rows = [];
  68. self.noDataTip = 0;
  69. self.total_count = 1;
  70. }
  71. }).error(function (err) {
  72. sp.dialog(JSON.stringify(err));
  73. });
  74. }
  75. $timeout(function () {
  76. self.getData(self.get_lastReturnPageno);
  77. }, 200)
  78. ///刷新
  79. self.btnRefresh = function () {
  80. self.getData(self.pageno);
  81. };
  82. ///删除
  83. self.btnDelete = function (idnum) {
  84. var getDelID = idnum;
  85. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  86. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  87. var dialogFoot = "<div class=\"sp-dialog-foot\"><input data-id=" + getDelID + " id='dialog_btnConfirm' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  88. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  89. sp.openCenter(".sp-dialog");
  90. ///取消按钮
  91. $('.sp-closeDialog').click(function (event) {
  92. sp.dialoghide();
  93. event.preventDefault(); event.stopPropagation();
  94. });
  95. //post消息的id
  96. $("#dialog_btnConfirm").click(function () {
  97. var getid = $(this).attr("data-id");
  98. var data = {
  99. entity: "XG_USER",
  100. id: getid
  101. };
  102. $http.post(apiurljs.backend + "Data/Delete", data, postCfgJson)
  103. .success(function (res) {
  104. if (res.success) {
  105. self.getData(self.pageno);
  106. sp.dialoghide();
  107. } else {
  108. sp.dialog("删除失败,请联系管理员!");
  109. }
  110. });
  111. });
  112. }
  113. ///筛选
  114. self.openSearchLayer = function () {
  115. sp.layer("#layer_search");
  116. };
  117. //筛选确认
  118. self.btnSearchTrue = function () {
  119. self.getData(1);
  120. sp.layerhide();
  121. };
  122. //筛选重置
  123. self.btnSearchCancel = function () {
  124. self.search = {
  125. USERREALNAME: "",
  126. IDNO: "",
  127. BLOCK: "",
  128. BUILDING: "",
  129. DOORNO: "",
  130. HOUSENO: ""
  131. };
  132. self.getData(1);
  133. sp.layerhide();
  134. };
  135. self.edit = {};
  136. ////修改身份证号
  137. self.btnEditIDNO = function (idnum) {
  138. var data = {
  139. entity: "XG_USER",
  140. id: idnum,
  141. idName: "",
  142. fields: ""
  143. };
  144. $http.post(apiurljs.backend + "Data/Get", data, postCfgJson)
  145. .success(function (res) {
  146. //console.log(JSON.stringify(res));
  147. if (sp.isval(res)) {
  148. self.edit = res;
  149. sp.layer("#layer_edit_idno");
  150. }
  151. });
  152. };
  153. //确认
  154. self.btnEditTrue = function () {
  155. if (spngvld.submit("#layer_edit_idno")) {
  156. var updateData = {
  157. userid: self.edit.USERID,
  158. openid: self.edit.OPENID,
  159. idno: self.edit.idno,
  160. newidno: self.edit.IDNO_New
  161. }
  162. $http.post(apiurljs.backend + "XinGuan/UpdateRegisterIdNo", updateData, postCfgJson)
  163. .success(function (res) {
  164. //console.log(res);
  165. if (res.success) {
  166. sp.layerhide();
  167. sp.dialog(res.message);
  168. $timeout(function () {
  169. self.getData(self.pageno);
  170. sp.dialoghide();
  171. }, 500);
  172. } else {
  173. sp.layerhide();
  174. sp.dialog(res.message);
  175. }
  176. });
  177. };
  178. };
  179. //取消
  180. self.btnEditCancel = function () {
  181. sp.layerhide();
  182. };
  183. }]);