123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597 |
- '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.type = sp.getUrlName("type") == "" ? 1 : sp.getUrlName("type");
- self.changeType = function (n) {
- if (self.type == n) {
- return;
- } else {
- self.type = n;
- self.getData(1, self.type)
- }
- }
- self.CrossPage = window.parent.CrossPage;
- self.loading = false;
- self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
- self.listTotal1 = [];
- self.listTotal2 = [];
- self.list = [];
- self.pageno = 1;
- self.total_count = 0;
- //self.itemsPerPage = 10;
- self.pageOptions = [10, 20, 30, 40];
-
- self.search = JSON.parse($.cookie("danganList1-search"));
- //1为已提交、2为退回、3为合并提交、4为合并草稿、5为封装、6为已整理提交
- self.getData = function (pageno, type) {
- if (self.search == null) {
- self.search = {
- starttime: "",
- endtime: "",
- title: "",
- itemsPerPage: 10
- }
- }
- $.cookie("danganList1-search", JSON.stringify(self.search), { path: '/', expires: 1 });
- self.loading = true;
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- self.list = [];
- var functionName = type == 1 ? "queryBuHuoDataWithPage" : "queryDataByColumnsWithPage";
- if (type == 1) {
- var data = {
- tablename: "DOCELEMENT",
- starttime: self.search.starttime,
- endtime: self.search.endtime,
- title: self.search.title,
- sendstatus: "0",
- sqlwhere: "dpcode='" + self.userDpCode + "'",
- order: "SORTID desc",
- pageno: self.pageno,
- pagesize: self.search.itemsPerPage
- }
- } else {
- var data = {
- tablename: "DOCELEMENT_ZL",
- sqlwhere: {},
- sqlinwhere: {
- sendstatus: "2"
- },
- title: "",
- order: "SORTID desc",
- pageno: self.pageno,
- pagesize: self.search.itemsPerPage,
- columns: "ID,ROUTEINFOID,DOCUMENTTYPE,DOCTITLE,FLOWID,TO_CHAR(FINISHEDDATE,'YYYY-mm-dd hh24:mi:ss') AS FINISHEDDATE,SENDSTATUS,DOCISSUEDNUM,MIJIQIXIAN"
- }
- }
- $http.post(apiurljs.login + "g2app/DangAn/" + functionName, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.loading = false;
- if (res.totalCount == 0) {
- self.noDataTip = 0;
- } else if (res.data == null || res.data == undefined || res.data == "") {
- self.noDataTip = 0;
- self.getData(self.pageno - 1, self.type)
- } else {
- self.noDataTip = 1;
- self.list = res.data;
- console.log(self.list)
- self.listChecked = false;
- self.total_count = res.totalCount;
- if (QCHB(self.list, self["listTotal" + self.type], "ID").length > 0) {
- self["listTotal" + self.type] = self["listTotal" + self.type].concat(QCHB(self.list, self["listTotal" + self.type], "ID"))
- }
- var checkedNum = 0;
- $.each(self.list, function (index, item) {
- item.checked = false;
- item.STATUS = item.SENDSTATUS == 0 ? "待提交" : "被退回";
- if (!item.DOCTITLE) {
- item.DOCTITLE = item.BT ? item.BT : item.ZT ? item.ZT : item.TITLE;
- }
- $.each(self["listTotal" + self.type], function (index1, item1) {
- if (item.ID == item1.ID) {
- item.checked = item1.checked;
- }
- })
- if (item.checked == true) {
- checkedNum++
- }
- })
- if (checkedNum == self.list.length) {
- self.listChecked = true;
- }
- }
- })
- }
- 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.changeListCheck = function () {
- $.each(self.list, function (index, item) {
- item.checked = self.listChecked;
- $.each(self["listTotal" + self.type], function (index1, item1) {
- if (item1.ID == item.ID) {
- item1.checked = item.checked;
- }
- })
- })
- }
- self.changeCheck = function (item, n) {
- item.checked = n == 1 ? item.checked : !item.checked;
- $.each(self["listTotal" + self.type], function (index1, item1) {
- if (item1.ID == item.ID) {
- item1.checked = item.checked;
- }
- })
- event.stopPropagation()
- }
- self.load = function () {
- if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
- self.getData(self.pageno, self.type);
- } else {
- $timeout(function () {
- self.getData(parseInt(self.get_lastReturnPageno), self.type);
- }, 1)
- }
- }
- self.refresh = function () {
- self.CrossPage.type = null;
- self.getData(self.pageno, self.type);
- }
- ///查询-打开弹出层
- self.openSearchLayer = function () {
- if (self.search == null) {
- self.search = {
- starttime: "",
- endtime: "",
- title: "",
- itemsPerPage: 10
- }
- }
- sp.layer("#search");
- }
- self.getFlowList = function () {
- var data1 = {
- flowkinds: "'AA01','AA02','AA03'"
- }
- $http.post(apiurljs.login + "g2work/flow/queryInData", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.AllList = res.data;
- $http.get("js/getFlow.txt", "", postCfg)
- .success(function (obj2) {
- self.showList = obj2;
- self.AllList.forEach(function (item) {
- self.showList.forEach(function (item1) {
- item1.data.forEach(function (item2) {
- if (item.FLOWID == item2.FLOWID) {
- item2.FLOWNAME = item.CNAME;
- item2.TABLENAME = item.CODETABLE
- }
- })
- })
- })
- var data2 = {
- tablename: "DANGANFLOW",
- colums: "*",
- order: "ID",
- sqlwhere: "",
- sqlorwhere: "",
- sqlinwhere: "",
- sqllikewhere: ""
- };
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data2)) }, postCfg)
- .success(function (obj1) {
- var res1 = strToJson(s4.decryptData_CBC(obj1.data));
- self.funcList = res1.data;;
- self.showList.forEach(function (item) {
- var n = 0;
- self.funcList.forEach(function (item1) {
- item.data.forEach(function (item2) {
- if (item2.FLOWID == item1.FLOWID) {
- //item.checked = true;
- n++
- }
- })
- })
- item.checked = n == item.data.length;
- })
- })
- })
- })
- }
- self.getFlowList()
- self.btnSubmit = function () {
- var ids = [], list = [];
- self["listTotal" + self.type].filter(function (item) {
- if (item.checked == true) {
- list.push(item)
- ids.push(item.ROUTEINFOID)
- }
- })
- if (ids.length == 0) {
- sp.dialog("请选择要提交的案件!");
- return;
- }
- 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();
- if (self.type == 1) {
- var data = {
- tablename: "DOCELEMENT_ZL",
- pagesize: 1,
- pageno: 1,
- colums: "ID,JIANHAO",
- order: "JIANHAO desc",
- sqlwhere: { MIJIQIXIAN: "10年" },
- sqlorwhere: "",
- sqlinwhere: {
- LOCKSTATUS: "'0','" + self.userId + "'",
- sendstatus: "1"
- } ,
- sqllikewhere: ""
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.data == null || res.data == undefined || res.data == "") {
- var JIANHAO = 0
- } else {
- var JIANHAO = res.data[0].JIANHAO;
- }
- var array = [];
- $.each(ids, function (index, item) {
- array.push({ routeinfoid: item, mijiqixian: "10年", jianhao: JIANHAO * 1 + index + 1, archyear: sp.currentYear(), organizationma: self.userDpCode })
- })
- var data1 = {
- data: ids,
- userid: self.userId,
- username: self.userName,
- updata: array
- }
- $http.post(apiurljs.login + "g2app/DangAn/SendData", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
- .success(function (obj1) {
- var res1 = strToJson(s4.decryptData_CBC(obj1.data));
- if (res1.success) {
- sp.dialog("提交成功!");
- self.getData(1, self.type);
- self["listTotal" + self.type] = self["listTotal" + self.type].filter(function (item) {
- return ids.every(function (item1) {
- return item.ROUTEINFOID != item1;
- })
- })
- $timeout(function () { sp.dialoghide() }, 1500)
- } else {
- sp.dialog(res1.message)
- }
- })
- })
- } else {
- var JIANHAO1, JIANHAO2, JIANHAO3;
- var data1 = {
- tablename: "DOCELEMENT_ZL",
- pagesize: 1,
- pageno: 1,
- colums: "ID,JIANHAO",
- order: "JIANHAO desc",
- sqlwhere: { MIJIQIXIAN: "10年" },
- sqlorwhere: "",
- sqlinwhere: {
- LOCKSTATUS: "'0','" + self.userId + "'",
- sendstatus: "1"
- },
- sqllikewhere: ""
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
- .success(function (obj1) {
- var res1 = strToJson(s4.decryptData_CBC(obj1.data));
- if (res1.data == null || res1.data == undefined || res1.data == "") {
- JIANHAO1 = 0
- } else {
- JIANHAO1 = res1.data[0].JIANHAO;
- }
- var data2 = {
- tablename: "DOCELEMENT_ZL",
- pagesize: 1,
- pageno: 1,
- colums: "ID,JIANHAO",
- order: "JIANHAO desc",
- sqlwhere: { MIJIQIXIAN: "30年" },
- sqlorwhere: "",
- sqlinwhere: {
- LOCKSTATUS: "'0','" + self.userId + "'",
- sendstatus: "1"
- },
- sqllikewhere: ""
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data2)) }, postCfg)
- .success(function (obj2) {
- var res2 = strToJson(s4.decryptData_CBC(obj2.data));
- if (res2.data == null || res2.data == undefined || res2.data == "") {
- JIANHAO2 = 0
- } else {
- JIANHAO2 = res2.data[0].JIANHAO;
- }
- var data3 = {
- tablename: "DOCELEMENT_ZL",
- pagesize: 1,
- pageno: 1,
- colums: "ID,JIANHAO",
- order: "JIANHAO desc",
- sqlwhere: { MIJIQIXIAN: "永久" },
- sqlorwhere: "",
- sqlinwhere: {
- LOCKSTATUS: "'0','" + self.userId + "'",
- sendstatus: "1"
- },
- sqllikewhere: ""
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data3)) }, postCfg)
- .success(function (obj3) {
- var res3 = strToJson(s4.decryptData_CBC(obj3.data));
- if (res3.data == null || res3.data == undefined || res3.data == "") {
- JIANHAO3 = 0
- } else {
- JIANHAO3 = res3.data[0].JIANHAO;
- }
- var array = [];
- var index1 = 1, index2 = 1, index3 = 1;
- list.forEach(function (item) {
- if (item.MIJIQIXIAN == "10年") {
- array.push({ routeinfoid: item.ROUTEINFOID, sendstatus: "1", jianhao: JIANHAO1 * 1 + index1 })
- index1++
- } else if (item.MIJIQIXIAN == "30年") {
- array.push({ routeinfoid: item.ROUTEINFOID, sendstatus: "1", jianhao: JIANHAO2 * 1 + index2 })
- index2++
- } else if (item.MIJIQIXIAN == "永久") {
- array.push({ routeinfoid: item.ROUTEINFOID, sendstatus: "1", jianhao: JIANHAO3 * 1 + index3 })
- index3++
- }
- })
- $http.post(apiurljs.login + "g2app/DangAn/SendBackData", { data: s4.encryptData_CBC(JSON.stringify(array)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.dialog("提交成功!");
- self.getData(1, self.type);
- self["listTotal" + self.type] = self["listTotal" + self.type].filter(function (item) {
- return ids.every(function (item1) {
- return item.ROUTEINFOID != item1;
- })
- })
- $timeout(function () { sp.dialoghide() }, 1500)
- } else {
- sp.dialog(res.message)
- }
- })
- })
- })
- })
- }
- })
- }
- self.btnSearch = function () {
- self.getData(1, self.type);
- sp.layerhide()
- }
- self.closeSeach = function () {
- self.search.title = "";
- sp.layerhide();
- $.cookie("danganList1-search", null, { path: '/', expires: -1 });
- self.getData(1, self.type);
- };
- ///捕获-打开弹出层
- self.openFilterLayer = function () {
- var data = {
- tablename: "DANGANFLOW",
- colums: "*",
- order: "ID",
- sqlwhere: {
- DPCODE: self.userDpCode,
- 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));
- if (res.data.length == 0) {
- sp.dialog("请先设置捕获流程!")
- } else {
- self.filter = {
- starttime: sp.format(sp.getPreMonthDay(sp.getLocalDate(), -12)),
- endtime: sp.format(sp.getLocalDate()),
- dpname: self.userDpName
- }
- self.windowFlag = 1;
- sp.layer("#filter1");
- }
- })
- }
- self.goDown = function () {
- self.windowFlag = 2;
- sp.closeCenter('.sp-layer')
- $timeout(function () {
- sp.layer("#filter2");
- },1)
- }
- self.goUp = function () {
- self.windowFlag = 1;
- sp.closeCenter('.sp-layer')
- $timeout(function () {
- sp.layer("#filter1");
- },1)
- }
- self.btnFilter = function () {
- sp.layerhide();
- self.loading = true;
- var data = {
- starttime: self.filter.starttime + " 00:00:00",
- endtime: self.filter.endtime + " 23:59:59",
- userid: self.userId,
- username: self.userName,
- cname: "DOCELEMENT",
- status: "启用",
- dpname: self.userDpName,
- dpcode: self.userDpCode
- }
- $http.post(apiurljs.login + "g2app/DangAn/BatchBuHuoApiT", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.loading = false;
- if (res.success == true) {
- self.getData(1, 1);
- sp.dialog("捕获到" + res.data.count + "条数据!");
- } else {
- sp.dialog(res.message);
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- if (textStatus != 200) {
- self.loading = false;
- sp.dialog("捕获失败!");
- }
- })
- }
- self.checkItem = function (obj) {
- obj.checked = !obj.checked;
- if (obj.checked == true) {
- var array = [];
- obj.data.forEach(function (item) {
- array.push({
- FLOWID: item.FLOWID,
- FLOWNAME: item.FLOWNAME,
- FLOWCODE: item.FLOWCODE,
- TABLENAME: item.TABLENAME
- })
- })
- var data = {
- tablename: "DANGANFLOW",
- data: array
- }
- console.log(array)
- $http.post(apiurljs.login + "g2app/Data/insertChildDataList2", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.getFlowList();
- })
- } else {
- var array = [];
- self.funcList.forEach(function (item) {
- obj.data.forEach(function (item1) {
- if (item.FLOWID == item1.FLOWID) {
- array.push("'" + item.ID + "'")
- }
- })
- })
- var data = {
- tablename: "DANGANFLOW",
- sqlwhere: "id IN (" + array.join(",") + ")"
- };
- $http.post(apiurljs.login + "g2app/dataabase/deletBywhere", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- console.log(res)
- });
- }
- }
- self.Edit = function (item) {
- //window.location.href = "formedt.html?routeinfoid=" + ROUTEINFOID + "&lastReturn=list&lastReturnPageno=" + self.pageno + "&type=" + self.type;
- window.location.href = "detail1.html?ID=" + item.ID + "&routeinfoid=" + item.ROUTEINFOID + "&lastReturn=list&lastReturnPageno=" + self.pageno + "&type=" + self.type
- event.stopPropagation()
- }
- self.Delete = function (routeinfoid) {
- 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 = {
- routeinfoid: routeinfoid
- }
- $http.post(apiurljs.login + "g2app/DangAn/deleteBuHuoData", { 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, self.type);
- }
- })
- })
- }
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
- function QCHB(arr1,arr2,filed){
- return arr1.filter(function (item) {
- return arr2.every(function (item1) {
- return item[filed] != item1[filed];
- })
- })
- }
|