index-real.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("indexRealCtrl", ["$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. self.get_name = decodeURI(sp.getUrlName("name"));
  12. self.get_idno = sp.getUrlName("idno");
  13. //alert(self.get_idno);
  14. ///返回按钮事件
  15. self.btnGoBack = function () {
  16. window.location.href = "index.html"
  17. }
  18. var postCfgJson = {
  19. headers: {
  20. 'Content-Type': 'application/json',
  21. 'Authorization': "Bearer " + self.get_AccessToken
  22. }
  23. };
  24. ///声明
  25. self.noDataTip = 1;
  26. self.rows = []; //声明空数组
  27. self.pageno = 1; // 初始化 当前页为 1
  28. self.total_count = 0;
  29. self.itemsPerPage = 10;
  30. self.pageOptions = [10, 15, 20, 25, 30];
  31. // 初始化分页数据
  32. self.getData = function (pageno) {
  33. self.pageno = pageno;
  34. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  35. var set_like = "USERREALNAME=" + self.get_name + "&IDNO=" + self.get_idno;
  36. ///查询这条记录,生成数组,赋值给表
  37. //得到返回的数据的id
  38. let postSearchData = {
  39. "entity": "XG_USER",
  40. "fields": "",
  41. "orderby": "id asc",
  42. "eqparams": "",
  43. "likeparams": set_like,
  44. "dateparams": "",
  45. "inparams": "",
  46. "page": self.pageno,
  47. "pagesize": self.itemsPerPage
  48. }
  49. $http.post(apiurljs.backend + "Data/List", postSearchData, postCfgJson)
  50. .success(function (res) {
  51. if (sp.isval(res.items)) {
  52. self.noDataTip = 1;
  53. angular.forEach(res.items, function (item, index) {
  54. item.CREATETIME = sp.formatMinute(item.CREATETIME);
  55. if (item.STATUS == "1") {
  56. item.STATUS_SET = "已实名";
  57. } else if (item.STATUS == "-1") {
  58. item.STATUS_SET = "正在申请注销";
  59. } else {
  60. item.STATUS_SET = "未实名";
  61. }
  62. });
  63. self.rows = res.items;
  64. self.total_count = res.total;
  65. } else {
  66. self.rows = [];
  67. self.noDataTip = 0;
  68. self.total_count = 1;
  69. }
  70. }).error(function (err) {
  71. sp.dialog(JSON.stringify(err));
  72. });
  73. }
  74. $timeout(function () {
  75. self.getData(self.get_lastReturnPageno);
  76. }, 200)
  77. ///刷新
  78. self.btnRefresh = function () {
  79. self.getData(self.pageno);
  80. };
  81. self.info = {
  82. ID: self.get_id,
  83. USERID: "",
  84. OPENID: "",
  85. USERREALNAME: "",
  86. GENDER: "",
  87. STREET: "",
  88. COMMUNITY: "",
  89. BLOCK: "",
  90. BUILDING: "",
  91. DOORNO: "",
  92. HOUSENO: ""
  93. };
  94. //////加载数据;只有编辑
  95. self.getEditInfo = function (idnum) {
  96. var data = {
  97. entity: "XG_USER",
  98. id: idnum,
  99. idName: "",
  100. fields: ""
  101. };
  102. $http.post(apiurljs.backend + "Data/Get", data, postCfgJson)
  103. .success(function (res) {
  104. //console.log(JSON.stringify(res));
  105. if (sp.isval(res)) {
  106. self.info = res;
  107. sp.layer("#layer_search");
  108. }
  109. });
  110. };
  111. //确认
  112. self.btnSearchTrue = function () {
  113. if (spngvld.submit("#tableAddData")) {
  114. var updateData = {
  115. userid: self.info.USERID,
  116. openid: self.info.OPENID,
  117. community: self.info.COMMUNITY,
  118. block: self.info.BLOCK,
  119. building: self.info.BUILDING,
  120. doorno: self.info.DOORNO,
  121. houseno: self.info.HOUSENO
  122. }
  123. $http.post(apiurljs.backend + "XinGuan/UpdateRegisterInfo", updateData, postCfgJson)
  124. .success(function (res) {
  125. //console.log(res);
  126. if (res.success) {
  127. sp.layerhide();
  128. sp.dialog(res.message);
  129. $timeout(function () {
  130. self.getData(self.pageno);
  131. sp.dialoghide();
  132. }, 500);
  133. } else {
  134. sp.layerhide();
  135. sp.dialog(res.message);
  136. }
  137. });
  138. };
  139. };
  140. //取消
  141. self.btnSearchCancel = function () {
  142. sp.layerhide();
  143. };
  144. self.edit = {};
  145. ////修改身份证号
  146. self.btnEditIDNO = function (idnum) {
  147. var data = {
  148. entity: "XG_USER",
  149. id: idnum,
  150. idName: "",
  151. fields: ""
  152. };
  153. $http.post(apiurljs.backend + "Data/Get", data, postCfgJson)
  154. .success(function (res) {
  155. //console.log(JSON.stringify(res));
  156. if (sp.isval(res)) {
  157. self.edit = res;
  158. sp.layer("#layer_edit_idno");
  159. }
  160. });
  161. };
  162. //确认
  163. self.btnEditTrue = function () {
  164. if (spngvld.submit("#layer_edit_idno")) {
  165. var updateData = {
  166. userid: self.edit.USERID,
  167. openid: self.edit.OPENID,
  168. idno: self.edit.idno,
  169. newidno: self.edit.IDNO_New
  170. }
  171. $http.post(apiurljs.backend + "XinGuan/UpdateRegisterIdNo", updateData, postCfgJson)
  172. .success(function (res) {
  173. //console.log(res);
  174. if (res.success) {
  175. sp.layerhide();
  176. sp.dialog(res.message);
  177. $timeout(function () {
  178. self.get_idno = self.edit.IDNO_New;
  179. self.getData(self.pageno);
  180. sp.dialoghide();
  181. }, 500);
  182. } else {
  183. sp.layerhide();
  184. sp.dialog(res.message);
  185. }
  186. });
  187. };
  188. };
  189. //取消
  190. self.btnEditCancel = function () {
  191. sp.layerhide();
  192. };
  193. }]);