123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("listCtrl", ["$scope", "$http", "$timeout", "$interval", function ($scope, $http, $timeout, $interval) {
- var self = this;
- var s4 = new SM4Util();
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
- self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- self.get_type = sp.getUrlName("type");
- self.params = sp.getUrlName("params");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.type = self.get_type != "" ? self.get_type : "todo";
- self.Url = getUrl(self.type);
- self.CrossPage = window.parent.CrossPage;
- self.loading = false;
- self.search = null//JSON.parse($.cookie("GlWorkPlatform-xinfangzm"));
- self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
- self.pageno = 1;
- self.total_count = 0;
- self.itemsPerPage = 10;
- self.pageOptions = [10, 20, 30, 40];
- self.ordercondition = []
- self.getData = function (pageno) {
- if (self.search == null) {
- self.search = {
- BT: "",
- SLBH: "",
- ZDRQ: "",
- DSBM: "",
- BJRQ: "",
- TITLE: "",
- DATEZ1: "",
- DATEZ2: "",
- DATEB1: "",
- DATEB2: ""
- }
- }
- var querycondition = [];
- var columnscondition = [
- { COLID: "SLBH", COLUMNS: "SX_ZMLJL.SLBH" },
- { COLID: "ZDRQ", COLUMNS: "SX_ZMLJL.ZDRQ" },
- { COLID: "DSBM", COLUMNS: "SX_ZMLJL.DSBM" },
- { COLID: "BJRQ", COLUMNS: "SX_ZMLJL.BJRQ" }
- ]
- if (self.search.BT != "") {
- querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search.BT, "VALUEB": "" })
- }
- if (self.search.SLBH != "") {
- querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "SLBH", "VALUEA": self.search.SLBH, "VALUEB": "" })
- }
- if (self.search.DSBM != "") {
- querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "DSBM", "VALUEA": self.search.DSBM, "VALUEB": "" })
- }
- if (self.params != "") {
- querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.params, "VALUEB": "" })
- }
- if (self.search.DATEZ1 != "" && self.search.DATEZ2 != "") {
- querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "BJRQ", "VALUEA": self.search.DATEZ1, "VALUEB": self.search.DATEZ2 })
- } else if (self.search.DATEZ1 != "" && self.search.DATEZ2 == "") {
- querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "BJRQ", "VALUEA": self.search.DATEZ1, "VALUEB": "" })
- } else if (self.search.DATEZ1 == "" && self.search.DATEZ2 != "") {
- querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "BJRQ", "VALUEA": "", "VALUEB": self.search.DATEZ2 })
- }
- if (self.search.DATEB1 != "" && self.search.DATEB2 != "") {
- querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "BJRQ", "VALUEA": self.search.DATEB1, "VALUEB": self.search.DATEB2 })
- } else if (self.search.DATEB1 != "" && self.search.DATEB2 == "") {
- querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "BJRQ", "VALUEA": self.search.DATEB1, "VALUEB": "" })
- } else if (self.search.DATEB1 == "" && self.search.DATEB2 != "") {
- querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "BJRQ", "VALUEA": "", "VALUEB": self.search.DATEB2 })
- }
- self.list = [];
- self.loading = false;
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- var data = {
- flowid: "AA01",
- userid: self.userId,
- pageno: self.pageno,
- pagesize: self.itemsPerPage,
- columnscondition: JSON.stringify(columnscondition),
- querycondition: JSON.stringify(querycondition),
- ordercondition: self.ordercondition.length == 0 ? "" : JSON.stringify(self.ordercondition)
- }
- //$http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, data, postCfg)
- .success(function (obj) {
- var res = obj;
- //var res = strToJson(s4.decryptData_CBC(obj.data));
- self.loading = false;
- if (res.data == null || res.data == undefined || res.data == "") {
- self.noDataTip = 0;
- if (self.params != "") {
- self.params = "";
- self.getData(1)
- }
- } else {
- self.noDataTip = 1;
- self.list = res.data;
- self.total_count = res.totalCount;
- $.each(self.list, function (index, item) {
- item.ZDRQ = sp.format(item.ZDRQ);
- item.BJRQ = sp.format(item.BJRQ);
- if (item.FILEN != "") {
- item.FILEN = item.FILEN.indexOf("dotype") > -1 ? item.FILEN.replace("dotype=1", "dotype=" + getDoType(self.type)) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno : item.FILEN + "&dotype=" + getDoType(self.type) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno;
- } else {
- item.FILEN = "#";
- }
- if (self.type == "finish") {
- item.RECEIVEDATE = item.FINISHEDDATE;
- }
- })
- }
- if (self.CrossPage.type == 0) {
- self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
- }
- })
- }
- self.load = function () {
- if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
- self.getData(self.pageno);
- } else {
- $timeout(function () {
- self.getData(self.get_lastReturnPageno);
- }, 1)
- }
- }
- self.sortFiled = function (str) {
- var n = 0, obj, x = -1;
- self.ordercondition.forEach(function (item, index) {
- if (item.COLID == str) {
- n++
- item.SORTTYPE = item.SORTTYPE == "" || item.SORTTYPE == "asc" ? "desc" : "asc"
- obj = item; x = index
- }
- })
- if (n == 0) {
- self.ordercondition.unshift({ COLID: str, SORTTYPE: "desc" })
- }
- if (x != -1) {
- self.ordercondition.splice(x, 1)
- self.ordercondition.unshift(obj)
- }
- self.getData(1);
- }
- self.load();
- self.openLayer = function () {
- self.params = "";
- if (self.search == null) {
- self.search = {
- BT: "",
- SLBH: "",
- ZDRQ: "",
- DSBM: "",
- BJRQ: "",
- TITLE: "",
- DATEZ1: "",
- DATEZ2: "",
- DATEB1: "",
- DATEB2: ""
- }
- }
- sp.layer("#Search")
- }
- self.doSearch = function () {
- $.cookie("GlWorkPlatform-xinfangzm", JSON.stringify(self.search), { path: '/', expires: 1 });
- self.getData(self.pageno)
- sp.layerhide()
- }
- self.cancal = function () {
- self.search = {
- BT: "",
- SLBH: "",
- ZDRQ: "",
- DSBM: "",
- BJRQ: "",
- TITLE: "",
- DATEZ1: "",
- DATEZ2: "",
- DATEB1: "",
- DATEB2: ""
- }
- $.cookie("GlWorkPlatform-xinfangzm", null, { path: '/', expires: 1 });
- self.getData(1)
- sp.layerhide()
- }
- self.refresh = function () {
- self.CrossPage.type = null;
- self.getData(self.pageno);
- }
- self.goUrl = function (item) {
- if (item.TODOLIST && item.TODOLIST.length > 1) {
- self.todoTitle = item.TITLE;
- self.todoList = item.TODOLIST;
- sp.layer("#todolist")
- } else {
- if (self.deviceType == "pad") {
- window.location.href = item.FILEN + "&dotype=" + getDoType(self.type)
- } else {
- sp.openNewWindow(item.FILEN + "&dotype=" + getDoType(self.type), item.TITLE)
- }
- sp.layerhide();
- }
- }
- self.btnDel = function (item) {
- var data = {
- routeinfoid: item.ROUTEINFOID,
- userid: self.userId
- }
- $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success == true) {
- self.getData(self.pageno)
- } else {
- sp.dialog(res.message)
- }
- })
- }
- self.btnRecall = function (routeid, kind) {
- var data = {
- routeid: routeid,
- kind: kind,
- userid: self.userId
- }
- $http.post(apiurljs.login + "g2work/routeinfo/queryDataRecallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- 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\">" + res.data.REMARK + "</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><input 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 () {
- $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- sp.dialoghide()
- if (res.success == true) {
- self.getData(self.pageno)
- } else {
- sp.dialog(res.message)
- }
- })
- });
- })
- }
- self.changeType = function (str) {
- if (self.type == str) {
- return;
- } else {
- var time1 = sp.getLocalDate1();
- self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url)
- self.type = str;
- self.Url = getUrl(self.type);
- self.getData(1)
- }
- }
- self.getAddFlag = function () {
- var data = {
- userid: self.userId,
- ntops: 0
- }
- $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.lcList = [];
- self.activeLC = {};
- res.data.forEach(function (item) {
- if ("AA01".indexOf(item.FLOWID) > -1) {
- self.lcList.push(item);
- }
- })
- })
- }
- self.getAddFlag()
- self.addLC = function () {
- if (self.lcList.length == 1) {
- sp.openNewWindow(self.lcList[0].FILEN + "&dotype=1&flowid=" + self.lcList[0].FLOWID, self.lcList[0].FLOWNAME)
- } else {
- sp.layer("#addLC");
- }
- }
- self.seeLCT = function (item,event) {
- event.preventDefault();
- event.stopPropagation();
- }
- self.goAddUrl = function () {
- if (!self.activeLC.FILEN) {
- return
- }
- sp.openNewWindow(self.activeLC.FILEN + "&dotype=1&flowid=" + self.activeLC.FLOWID, self.activeLC.FLOWNAME)
- sp.layerhide()
- }
- //记录日志
- self.journalRecord = function (time1, time2, title, func, url) {
- if (!self.CrossPage || !self.CrossPage.cname) { return; }
- var data = {
- tablename: "SYS_CLICKLOG",
- data: {
- CTIME: time1 == null ? sp.getLocalDate1() : time1,
- TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
- REQUESTURL: url,
- REQUESTHEADERURL: window.location.origin,
- LOGTYPE: func,
- USERTYPE: $.cookie("GlWorkPlatform-userType"),
- ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
- CLIENTIP: sp.myIP(),
- PCNAME: sp.detectOS(),
- BROWSERNAME: sp.browser(),
- RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
- USERID: self.userId,
- USERNAME: self.userName
- }
- }
- $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (res) {
- self.CrossPage.type = 1;
- })
- }
- $interval(function () {
- if (localStorage.getItem("GlWorkPlatform-xinfangzm-refresh") == 1) {
- localStorage.removeItem("GlWorkPlatform-xinfangzm-refresh")
- self.refresh()
- }
- }, 1000)
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
- function getUrl(str) {
- switch (str) {
- case "todo":
- return "queryDataTodoWithPage";
- break;
- case "done":
- return "queryDataDoneWithPage";
- break;
- case "finish":
- return "queryDataFinishWithPage";
- break;
- }
- }
- function getDoType(str) {
- switch (str) {
- case "todo":
- return 1;
- break;
- default:
- return 0;
- break;
- }
- }
|