123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- 'use strict';
- var app = angular.module('app', ["angularUtils.directives.dirPagination"]);
- app.controller("noticeCtrl", ["$http", "$scope", function ($http, $scope) {
- var self = this;
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-username");
- self.userChineseName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno") || 1; ///接收传过来的第几页
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- //搜索,查询
- self.search = {
- proname: "",
- userid:""
- };
- //数据表格的控制器,动态加载table表格数据
- self.noDataTip = 1; //声明没有数据时变量
- self.rows = [];
- self.pageno = 1;
- self.total_count = 0;
- self.itemsPerPage = 8;
- self.pageOptions = [8, 12, 16, 20, 24, 26]; ////
- self.getData = function (pageno) {
- self.rows = [];
- self.pageno = pageno;
- setTimeout(function () {
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- })
- var postData = {
- proname: self.search.proname,
- pagesize: self.itemsPerPage,
- userid:self.search.userid,
- pageno: parseInt(self.pageno)
- };
- $http.post(apiurljs.login + "g2app/duchaduban/queryDataWithPage", postData, postCfg).success(function (res) {
- if (sp.isval(res.data)) {
- self.noDataTip = 1;
- res.data.forEach(function (item) {
- item.PRODATE = sp.dateFtt("yyyy-MM-dd", new Date(item.PRODATE));
- })
- self.rows = res.data;
- self.total_count = res.totalCount;
- } else {
- self.noDataTip = 0;
- }
- });
- };
- //删除功能
- self.btnDelDate = function (strId) {
- var getDelID = strId;
- 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='delDataTrue' 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.closeCenter(".sp-dialog");
- event.preventDefault();
- event.stopPropagation();
- });
- //post消息的id
- $("#delDataTrue").click(function () {
- var getid = $(this).attr("data-id");
- sp.dialoghide();
- var data = {
- id:getid,
- tablename:"KEYPROJECT"
- };
- $http.post(apiurljs.login + "g2app/duchaduban/del", data, postCfg)
- .success(function (res) {
- sp.dialoghide();
- if (res.success) {
- self.getData(self.pageno);
- } else {
- sp.dialog("删除失败,请联系管理员!");
- }
- });
- });
- };
- //点击 筛选 打开弹出层
- self.openLayer = function () {
- sp.layer('#layer_search');
- };
- //搜索
- self.btnSearch = function () {
- sp.closeCenter('#layer_search');
- self.getData(1);
- };
- //刷新
- self.refresh = function () {
- self.search = {
- TITLE: "",
- };
- self.getData(1);
- }
- self.openSearchLayer = function () {
- sp.layer("#layer_search");
- }
- self.doSearch = function () {
- sp.layerhide();
- self.getData(1);
- }
- //先判断当前登录用户的角色
- self.getUserRole=function () {
- var data = {
- userid: self.userId
- };
- $http.post(apiurljs.login + "g2app/duchaduban/queryRole", data, postCfg)
- .success(function (res) {
- if(res.data.ADMIN=="ADMIN"){
- self.search.userid="";
- }else{
- self.search.userid=self.userId;
- }
- if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
- self.getData(1);// 初始化 当前页为 1
- } else {
- self.getData(self.get_lastReturnPageno); ///加载接收页码的数据
- }
- });
- }
- self.getUserRole();
- }]);
|