123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("taizhangCtrl", ["$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.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.type1st = 1;
- self.loading = false;
- self.search = {
- WJBT: "",
- WH: ""
- };
- self.pageno = 1;
- self.total_count = 0;
- self.itemsPerPage = 10;
- self.pageOptions = [10, 20, 30, 40];
- self.getData1 = function (pageno) {
- self.list = [];
- self.loading = false;
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- var data = {
- tablename: "FW_GFXWJTZ",
- pagesize: self.itemsPerPage,
- pageno: self.pageno,
- colums: "*",
- order: "WJDQRQ",
- sqlwhere: { ZT: "0" },
- sqlorwhere: "",
- sqlinwhere: "",
- sqllikewhere: { WJBT: self.search.WJBT, WH: self.search.WH }
- };
- $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));
- self.loading = false;
- self.list = res.data;
- self.total_count = res.totalCount;
- self.list.forEach(function (item) {
- item.WJSXRQ = sp.format(item.WJSXRQ)
- item.WJDQRQ = sp.format(item.WJDQRQ)
- if (item.WJDQRQ != "" && item.WJDQRQ != null) {
- item.DAYS = (new Date(item.WJDQRQ).getTime() - new Date(sp.dateCount(0)).getTime()) / 86400000
- item.DAYS1 = (item.DAYS < 0) ? "超期" + item.DAYS * -1 + "天" : item.DAYS + "天"
- item.LQTS = {
- //"background-color": item.DAYS <= 90 ? "red" : item.DAYS <= 365 && item.DAYS > 90 ? "yellow" : item.DAYS == 365 ? "blue" : "",
- "color": "black"
- }
- } else {
- item.DAYS1 = ""
- item.LQTS = {
- "color": "black"
- }
- }
- })
- })
- }
- self.getData1(self.pageno);
- self.openLayer = function () {
- if (self.type1st == 2) {
- if (self.search2 == null) {
- self.search2 = {
- FLOW: [],
- BT: "",
- USER: "",
- DATE1: "",
- DATE2: ""
- }
- } else {
- self.flowids.forEach(function (item) {
- item.checked = false;
- if (self.search2.FLOW.indexOf(item.ID) > -1) {
- item.checked = true;
- }
- })
- }
- }
- sp.layer("#Search")
- }
- self.doSearch = function () {
- if (self.type1st == 1) {
- self.getData1(self.pageno);
- } else {
- self.search2.FLOW = [];
- self.flowids.forEach(function (item) {
- if (item.checked == true) {
- self.search2.FLOW.push(item.ID)
- }
- })
- $.cookie("GlWorkPlatform-gfxwjtz", JSON.stringify(self.search2), { path: '/', expires: 1 });
- self.getData2(self.pageno)
- }
- sp.layerhide()
- }
- self.cancal = function () {
- if (self.type1st == 1) {
- self.search = {
- BT: "",
- FWZH: ""
- };
- self.getData1(1)
- } else {
- self.search2 = {
- FLOW: [],
- BT: "",
- USER: "",
- DATE1: "",
- DATE2: ""
- }
- $.cookie("GlWorkPlatform-gfxwjtz", null, { path: '/', expires: 1 });
- self.getData2(1)
- }
- sp.layerhide()
- }
- self.refresh = function () {
- if (self.type1st == 1) {
- self.getData1(self.pageno);
- } else {
- self.getData2(self.pageno);
- }
- }
- self.goUrl = function (obj) {
- console.log(obj)
- sp.openNewWindow("detail.html?id=" + obj.ID, obj.WJBT)
- }
- self.printOut = function () {
- if (self.canExportExcel) {
- $('#table td').attr('t', 's')
- var defaultCellStyle = {
- font: {
- name: 'Times New Roman',
- sz: 12,
- color: {
- rgb: "000000"
- },
- bold: false, italic: false,
- underline: false
- },
- alignment: {
- vertical: "center",
- horizontal: "center", indent: 0, wrapText: true
- },
- border: {
- top: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- },
- right: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- },
- bottom: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- },
- left: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- }
- }
- };
- var cell = { defaultCellStyle: defaultCellStyle };
- var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#table'), cell, "规范性文件台账")
- //设置表格的样式
- var wbout = XLSX.write(wb, {
- bookType: 'xlsx',
- bookSST: false,
- type: 'binary',
- cellStyles: true,
- defaultCellStyle: defaultCellStyle,
- showGridLines: false
- });
- var s2ab = function (s) {
- var buf = new ArrayBuffer(s.length);
- var view = new Uint8Array(buf);
- for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
- return buf;
- };
- try {
- saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), '规范性文件台账.xlsx')
- } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
- return wbout
- } else {
- sp.dialog('数据还未加载完成,请稍等...')
- }
- }
- self.getData = function (pageno) {
- if (self.type1st == 1) {
- self.getData1(pageno)
- } else {
- self.getData2(pageno)
- }
- }
- self.type = "todo";
- self.Url = getUrl(self.type);
- self.search2 = JSON.parse($.cookie("GlWorkPlatform-gfxwjtz"));
-
- self.getZRBM = function () {
- var data = {
- ckey: "CODE_ZRBM",
- routeinfoid: self.routeinfoid
- }
- $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.ZRBM = res.data.CODE_ZRBM;
- self.getLM()
- })
- }
- self.getLM = function () {
- var data = {
- ckey: "CODE_LM",
- routeinfoid: self.routeinfoid
- }
- $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.LM = res.data.CODE_LM;
- })
- }
- self.flowids = [{ ID: "AA73", NAME: "规范性文件清理督办", checked: false }]
- self.getData2 = function (pageno) {
- if (self.search2 == null) {
- self.search2 = {
- FLOW: [],
- BT: "",
- USER: "",
- DATE1: "",
- DATE2: ""
- }
- }
- var flowids = self.search2.FLOW.join("|");
- var querycondition = [];
- if (self.search2.BT != "") {
- querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search2.BT, "VALUEB": "" })
- }
- if (self.search2.USER != "") {
- querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "USERNAMEFROM", "VALUEA": self.search2.USER, "VALUEB": "" })
- }
- if (self.search2.DATE1 != "" && self.search2.DATE2 != "") {
- querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search2.DATE1, "VALUEB": self.search2.DATE2 })
- } else if (self.search2.DATE1 != "" && self.search2.DATE2 == "") {
- querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search2.DATE1, "VALUEB": "" })
- } else if (self.search2.DATE1 == "" && self.search2.DATE2 != "") {
- querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": "", "VALUEB": self.search2.DATE2 })
- }
- self.list = [];
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- var data = {
- flowid: flowids == "" ? "AA73" : flowids,
- userid: self.userId,
- pageno: self.pageno,
- pagesize: self.itemsPerPage,
- querycondition: JSON.stringify(querycondition)
- }
- //$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;
- } else {
- self.noDataTip = 1;
- self.list = res.data;
- self.total_count = res.totalCount;
- $.each(self.list, function (index, item) {
- self.LM.forEach(function (item1) {
- if (item[item.CODETABLE + ".LX"]) {
- if (item[item.CODETABLE + ".LX"] == item1.CODE)
- item.LX = item1.CNAME
- } else {
- if (item[item.CODETABLE + ".LM"] == item1.CODE)
- item.LX = item1.CNAME
- }
- })
- self.ZRBM.forEach(function (item2) {
- if (item[item.CODETABLE + ".FBBM"] == item2.CODE) {
- item.FBBM = item2.CNAME;
- }
- })
- 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 + "&flowid=" + item.FLOWID : item.FILEN + "&dotype=" + getDoType(self.type) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID;
- } else {
- item.FILEN = "#";
- }
- if (self.type == "finish") {
- item.RECEIVEDATE = item.FINISHEDDATE;
- }
- })
- }
- })
- }
- self.getZRBM();
-
- self.goUrl1 = function (item) {
- sp.openNewWindow(item.FILEN + "&dotype=" + getDoType(self.type), item.TITLE)
- }
- 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.getData2(self.pageno)
- } else {
- sp.dialog(res.message)
- }
- })
- }
- self.btnRecall = function (routeid) {
- var data = {
- routeid: routeid,
- 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.getData2(self.pageno)
- } else {
- sp.dialog(res.message)
- }
- })
- });
- })
- }
- self.changeType = function (str) {
- if (self.type == str) {
- return;
- } else {
- self.type = str;
- self.Url = getUrl(self.type);
- self.getData2(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 ("AA73".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&GWCODE=" + self.lcList[0].CODE + "&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&GWCODE=" + self.activeLC.CODE + "&flowid=" + self.activeLC.FLOWID, self.activeLC.FLOWNAME)
- sp.layerhide()
- }
- $interval(function () {
- if (localStorage.getItem("GlWorkPlatform-gfxwjtz-refresh") == 1) {
- localStorage.removeItem("GlWorkPlatform-gfxwjtz-refresh")
- self.refresh()
- }
- }, 1000)
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
- app.directive("repeatFinish", function () {
- return {
- link: function (scope) {
- if (scope.$last == true) {
- scope.$parent.ctl.canExportExcel = true;
- setTimeout(function () {
- //$("#table").rowspan(0)
- }, 10);
- }
- }
- };
- });
- jQuery.fn.rowspan = function (colIdx) { //封装的一个JQuery小插件
- return this.each(function () {
- var that;
- $('tr', this).each(function (row) {
- $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) {
- if (that != null && $(this).html() == $(that).html()) {
- var rowspan = $(that).attr("rowSpan");
- if (rowspan == undefined) {
- $(that).attr("rowSpan", 1);
- rowspan = $(that).attr("rowSpan");
- }
- rowspan = Number(rowspan) + 1;
- $(that).attr("rowSpan", rowspan);
- $(this).remove();
- } else {
- that = this;
- }
- });
- });
- });
- }
- 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;
- case "finish":
- return 1;
- break;
- default:
- return 0;
- break;
- }
- }
|