123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("listCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
- 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.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.loading = false;
- self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
- self.list = [];
- self.pageno = 1;
- self.total_count = 0;
- self.itemsPerPage = 10;
- self.pageOptions = [10, 20, 30, 40];
- self.search = JSON.parse($.cookie("GlWorkPlatform-danganSet"));
- self.getDP = function () {
- var data = {
- userid: self.userId
- }
- $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
- self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
- self.load();
- })
- }
- self.getDP()
- self.getData = function (pageno) {
- if (self.search == null) {
- self.search = {
- DOCUMENTTYPE: "",
- FLOWNAME: ""
- }
- }
- var sqlwhere = ["and DPCODE='" + self.userDpCode + "'"];
- self.loading = true;
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- if (self.search.FLOWNAME != "") {
- sqlwhere.push("and FLOWNAME='" + self.search.FLOWNAME + "'")
- }
- if (self.search.DOCUMENTTYPE != "") {
- sqlwhere.push("and DOCUMENTTYPE='" + self.search.DOCUMENTTYPE + "'")
- }
- self.list = [];
- var data = {
- tablename: "DANGANFLOW AS A",
- pagesize: self.itemsPerPage,
- pageno: self.pageno,
- colums: "*,(SELECT count('WENHAO') FROM DATACOMPER AS B WHERE A.FLOWID=B.FLOWID ) AS COUNTS",
- order: "ID",
- sqlwhere: sqlwhere.join(" "),
- sqlorwhere: "",
- sqlinwhere: "",
- sqllikewhere: ""
- };
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage3", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.loading = false;
- if (res.data == null || res.data == undefined || res.data == "") {
- self.noDataTip = 0;
- } else {
- self.noDataTip = 1;
- self.list = res.data;
- self.total_count = res.totalCount;
- self.list.forEach(function (item) {
- item.STATUS1 = item.STATUS ? item.STATUS : "禁用";
- item.DOCUMENTTYPE1 = item.DOCUMENTTYPE != "" && item.DOCUMENTTYPE != null ? item.DOCUMENTTYPE : item.TABLENAME.indexOf("SW_") > -1 ? "收文" : item.TABLENAME.indexOf("FW_") > -1 ? "发文" : "";
- })
- }
- })
- }
-
- self.load = function () {
- if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
- self.getData(self.pageno);
- } else {
- $timeout(function () {
- self.getData(parseInt(self.get_lastReturnPageno));
- }, 1)
- }
- }
-
- ///查询-打开弹出层
- self.openSearchLayer = function () {
- if (self.search == null) {
- self.search = {
- DOCUMENTTYPE: "",
- FLOWNAME: ""
- }
- }
- sp.layer("#search");
- }
- self.btnSearch = function () {
- self.getData(1);
- $.cookie("GlWorkPlatform-danganSet", JSON.stringify(self.search), { path: '/', expires: 1 });
- sp.layerhide()
- }
- self.closeSeach = function () {
- self.search = {
- DOCUMENTTYPE: "",
- FLOWNAME: ""
- }
- sp.layerhide();
- $.cookie("GlWorkPlatform-danganSet", null, { path: '/', expires: 1 });
- self.getData(1);
- };
- self.openAddLayer = function (n) {
- var data = {
- tablename: "DANGANFLOWMANAGE",
- colums: "*",
- order: "ID",
- sqlwhere: {
- STATUS: "启用"
- },
- sqlorwhere: "",
- sqlinwhere: "",
- sqllikewhere: ""
- };
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- var data1 = {
- tablename: "DANGANFLOW",
- colums: "*",
- order: "ID",
- sqlwhere: {
- DPCODE: self.userDpCode
- },
- sqlorwhere: "",
- sqlinwhere: "",
- sqllikewhere: ""
- };
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
- .success(function (obj1) {
- var res1 = strToJson(s4.decryptData_CBC(obj1.data));
- self.flowList = res.data;
- self.list1 = JSON.parse(JSON.stringify(res1.data));//当前部门现有的所有流程
- self.list2 = JSON.parse(JSON.stringify(res1.data));//对比数据是否发生变化
- self.flowList.forEach(function (item) {
- item.checked = false;
- item.show = true;
- self.list1.forEach(function (item1) {
- item1.checked = false;
- item1.show = true
- if (item.FLOWID == item1.FLOWID) {
- item.show = false;
- }
- })
- })
- if (n == 0) {
- sp.layer("#Add")
- }
- })
- })
- }
- self.num = 0;
- self.clickInit = function () {
- self.num++
- if (self.num == 5) {
- window.location.href="init.html"
- //var data = {
- // unitid: "AA",
- // arry: ['AA01', 'AA02']
- //}
- //$http.post(apiurljs.login + "g2app/DangAn/initFlowDataToDangAnManage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- //.success(function (obj) {
- // var res = strToJson(s4.decryptData_CBC(obj.data));
- // if (res.success == true) {
- // self.openAddLayer(1)
- // self.num = 0;
- // }
- //})
- }
- }
- self.setWENHAO = function (item) {
- console.log(item)
- var data = {
- tablename: item.TABLENAME,
- order: "sortid"
- }
- $http.post(apiurljs.login + "g2app/richang/queryColumnsData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.thead = [];
- $.each(res.data, function (index, item) {
- if (item.code != "ID" && item.code != "ROUTEINFOID" && item.code != "SORTID" && item.code != "APPCODE" && item.code != "CDATE") {
- self.thead.push({ code: item.code, cname: item.cname })
- }
- })
- self.setObjWH = {
- TABLECOLUMN: "",
- FLOWID: item.FLOWID,
- FLOWNAME: item.FLOWNAME,
- TABLENAME: item.TABLENAME,
- COMPCOLUMN: "WENHAO"
- };
- sp.layer("#setWH")
- });
- }
- self.btnSetWH = function () {
- var data = {
- tablename: "DATACOMPER",
- data: self.setObjWH
- }
- $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.dialog("设置成功!");
- self.getData(self.pageno);
- $timeout(function () {
- sp.dialoghide();
- }, 1000)
- } else {
- sp.dialog(res.message);
- }
- })
- }
- self.checkItem = function (item) {
- if (item.STATUS != "启用") {
- item.checked = !item.checked
- } else {
- return
- }
- }
- self.addFlag = true;
- self.addflow = function () {
- self.addFlag = true;
- var n = 0;
- self.flowList.forEach(function (item) {
- if (item.checked == true && item.show == true) {
- self.list1.push(item);
- item.checked = false;
- item.show = false;
- }
- if (item.show == false) {
- n++
- }
- })
- if (n == self.flowList.length) {
- self.addFlag = false;
- }
- }
- self.delflow = function () {
- var array = [];
- self.list1.forEach(function (item) {
- if (item.checked == true) {
- self.flowList.forEach(function (item1) {
- if (item.FLOWID == item1.FLOWID) {
- item1.checked = false;
- item1.show = true;
- }
- })
- } else {
- array.push(item)
- }
- })
- var n = 0;
- self.flowList.forEach(function (item) {
- if (item.show == true) {
- n++
- }
- })
- self.list1 = array;
- if (n > 0) {
- self.addFlag = true;
- }
- }
- self.addflowAll = function () {
- self.addFlag = true;
- self.flowList.forEach(function (item) {
- if (item.show == true) {
- self.list1.push(item);
- item.checked = false;
- item.show = false;
- }
- })
- self.addFlag = false;
- }
- self.delflowAll = function () {
- self.list1.forEach(function (item) {
- item.checked = false;
- item.show = true;
- })
- self.flowList.forEach(function (item) {
- item.checked = false;
- item.show = true;
- })
- self.list1 = [];
- self.addFlag = true;
- }
- self.btnSubmit = function () {
- var n = 0;
- self.list1.forEach(function (item) {
- self.list2.forEach(function (item1) {
- if (item.FLOWID == item1.FLOWID) {
- n++
- }
- })
- })
- if (n == self.list1.length) {
- sp.layerhide()
- sp.dialog("操作成功!")
- $timeout(function () {
- sp.dialoghide()
- }, 2000)
- return
- }
- var list = self.list1.map(function (item) {
- return {
- FLOWID: item.FLOWID,
- TABLENAME: item.TABLENAME,
- FLOWNAME: item.FLOWNAME,
- FLOWCODE: item.FLOWCODE,
- MOBANNAME: item.MOBANNAME,
- DOCUMENTTYPE: item.TABLENAME.indexOf("SW_") > -1 ? "收文" : "发文",
- STATUS: "启用",
- OUTFILEPATH: "/tmp",
- PRINTTYPE: 1,
- DPNAME: self.userDpName,
- DPCODE: self.userDpCode
- }
- })
- self.list.forEach(function (item) {
- list.forEach(function (item1) {
- if (item1.FLOWID == item.FLOWID) {
- item1.STATUS = item.STATUS;
- }
- })
- })
- var data = {
- tablename: "DANGANFLOW",
- delwhere: " dpcode='" + self.userDpCode + "'",
- data: list
- }
- $http.post(apiurljs.login + "g2app/DangAn/DangAnflowAddAndDel", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- sp.layerhide()
- self.getData(1)
- if (res.success) {
- sp.dialog("操作成功!")
- $timeout(function () {
- sp.dialoghide()
- }, 2000)
- } else {
- sp.dialog(res.message)
- }
- })
- }
- //1更新为启用,2更新为禁用
- self.upDataStatus = function (item, n) {
- var data = {
- id: item.ID,
- tablename: "DANGANFLOW",
- data: { STATUS: "" }
- }
- if (n == 1) {
- data.data.STATUS = "启用"
- } else {
- data.data.STATUS = "禁用"
- }
- $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getData(self.pageno)
- sp.dialog("已" + data.data.STATUS + "!");
- $timeout(function () {
- sp.dialoghide();
- }, 1000)
- } else {
- sp.dialog(res.message);
- }
- })
- }
- self.btnDel = function (item) {
- 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 id='upDataTrue' 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();
- });
- $("#upDataTrue").click(function () {
- sp.dialoghide();
- var data = {
- tablename: "DANGANFLOW",
- id: item.ID
- };
- $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- sp.dialoghide();
- if (res.success) {
- self.getData(self.pageno);
- } else {
- sp.dialog("删除失败,请联系管理员!");
- }
- });
- })
- }
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
|