123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("realUserCtrl", ["$http", "$scope", "$timeout", function ($http, $scope, $timeout) {
- var self = this;
- self.webApiUrl2 = "";
- self.get_userid = $.cookie("GlWorkPlatform-userid");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno") || 1; ///接收传过来的第几页
- var postCfgJson = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.search = {
- USERREALNAME: "",
- IDNO: "",
- BLOCK: "",
- BUILDING: "",
- DOORNO: "",
- HOUSENO: ""
- };
- ///声明
- self.noDataTip = 1;
- self.rows = []; //声明空数组
- self.pageno = 1; // 初始化 当前页为 1
- self.total_count = 0;
- self.itemsPerPage = 10;
- self.pageOptions = [10, 15, 20, 25, 30];
- // 初始化分页数据
- self.getData = function (pageno) {
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- 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;
- ///查询这条记录,生成数组,赋值给表
- //得到返回的数据的id
- let postSearchData = {
- "entity": "XG_USER",
- "fields": "",
- "orderby": "id desc",
- "eqparams": "",
- "likeparams": set_like,
- "dateparams": "",
- "inparams": "",
- "page": self.pageno,
- "pagesize": self.itemsPerPage
- }
- $http.post(apiurljs.backend + "Data/List", postSearchData, postCfgJson)
- .success(function (res) {
- if (sp.isval(res.items)) {
- self.noDataTip = 1;
- angular.forEach(res.items, function (item, index) {
- item.CREATETIME = sp.formatMinute(item.CREATETIME);
- if (item.STATUS == "1") {
- item.STATUS_SET = "已实名";
- } else if (item.STATUS == "-1") {
- item.STATUS_SET = "正在申请注销";
- } else {
- item.STATUS_SET = "未实名";
- }
- });
- self.rows = res.items;
- self.total_count = res.total;
- } else {
- self.rows = [];
- self.noDataTip = 0;
- self.total_count = 1;
- }
- }).error(function (err) {
- sp.dialog(JSON.stringify(err));
- });
- }
- $timeout(function () {
- self.getData(self.get_lastReturnPageno);
- }, 200)
- ///刷新
- self.btnRefresh = function () {
- self.getData(self.pageno);
- };
- ///删除
- self.btnDelete = function (idnum) {
- var getDelID = idnum;
- var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
- 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>";
- $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
- sp.openCenter(".sp-dialog");
- ///取消按钮
- $('.sp-closeDialog').click(function (event) {
- sp.dialoghide();
- event.preventDefault(); event.stopPropagation();
- });
- //post消息的id
- $("#dialog_btnConfirm").click(function () {
- var getid = $(this).attr("data-id");
- var data = {
- entity: "XG_USER",
- id: getid
- };
- $http.post(apiurljs.backend + "Data/Delete", data, postCfgJson)
- .success(function (res) {
- if (res.success) {
- self.getData(self.pageno);
- sp.dialoghide();
- } else {
- sp.dialog("删除失败,请联系管理员!");
- }
- });
- });
- }
- ///筛选
- self.openSearchLayer = function () {
- sp.layer("#layer_search");
- };
- //筛选确认
- self.btnSearchTrue = function () {
- self.getData(1);
- sp.layerhide();
- };
- //筛选重置
- self.btnSearchCancel = function () {
- self.search = {
- USERREALNAME: "",
- IDNO: "",
- BLOCK: "",
- BUILDING: "",
- DOORNO: "",
- HOUSENO: ""
- };
- self.getData(1);
- sp.layerhide();
- };
- self.edit = {};
- ////修改身份证号
- self.btnEditIDNO = function (idnum) {
- var data = {
- entity: "XG_USER",
- id: idnum,
- idName: "",
- fields: ""
- };
- $http.post(apiurljs.backend + "Data/Get", data, postCfgJson)
- .success(function (res) {
- //console.log(JSON.stringify(res));
- if (sp.isval(res)) {
- self.edit = res;
- sp.layer("#layer_edit_idno");
- }
- });
- };
- //确认
- self.btnEditTrue = function () {
- if (spngvld.submit("#layer_edit_idno")) {
- var updateData = {
- userid: self.edit.USERID,
- openid: self.edit.OPENID,
- idno: self.edit.idno,
- newidno: self.edit.IDNO_New
- }
- $http.post(apiurljs.backend + "XinGuan/UpdateRegisterIdNo", updateData, postCfgJson)
- .success(function (res) {
- //console.log(res);
- if (res.success) {
- sp.layerhide();
- sp.dialog(res.message);
- $timeout(function () {
- self.getData(self.pageno);
- sp.dialoghide();
- }, 500);
- } else {
- sp.layerhide();
- sp.dialog(res.message);
- }
- });
- };
- };
- //取消
- self.btnEditCancel = function () {
- sp.layerhide();
- };
- }]);
|